- if(autocvar_g_waypointeditor)
- {
- switch(imp)
- {
- case 103:
- waypoint_schedulerelink(waypoint_spawn(self.origin, self.origin, 0));
- bprint(strcat("Waypoint spawned at ",vtos(self.origin),"\n"));
- break;
- case 104:
- e = navigation_findnearestwaypoint(self, false);
- if (e)
- if (!(e.wpflags & WAYPOINTFLAG_GENERATED))
- {
- bprint(strcat("Waypoint removed at ",vtos(e.origin),"\n"));
- waypoint_remove(e);
- }
- break;
- case 105:
- waypoint_schedulerelinkall();
- break;
- case 106:
- waypoint_saveall();
- break;
- case 107:
- for(e = findchain(classname, "waypoint"); e; e = e.chain)
- {
- e.colormod = '0.5 0.5 0.5';
- e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
- }
- e2 = navigation_findnearestwaypoint(self, false);
- navigation_markroutes(e2);
- i = 0;
- m = 0;
- for(e = findchain(classname, "waypoint"); e; e = e.chain)
- {
- if(e.wpcost >= 10000000)
- {
- LOG_INFO("unreachable: ", etos(e), " ", vtos(e.origin), "\n");
- e.colormod_z = 8;
- e.effects |= EF_NODEPTHTEST | EF_BLUE;
- ++i;
- ++m;
- }
- }
- if(i)
- LOG_INFO(ftos(i), " waypoints cannot be reached from here in any way (marked with blue light)\n");
- navigation_markroutes_inverted(e2);
- i = 0;
- for(e = findchain(classname, "waypoint"); e; e = e.chain)
- {
- if(e.wpcost >= 10000000)
- {
- LOG_INFO("cannot reach me: ", etos(e), " ", vtos(e.origin), "\n");
- e.colormod_x = 8;
- if(!(e.effects & EF_NODEPTHTEST)) // not already reported before
- ++m;
- e.effects |= EF_NODEPTHTEST | EF_RED;
- ++i;
- }
- }
- if(i)
- LOG_INFO(ftos(i), " waypoints cannot walk to here in any way (marked with red light)\n");
- if(m)
- LOG_INFO(ftos(m), " waypoints have been marked total\n");
- i = 0;
- for(e = findchain(classname, "info_player_deathmatch"); e; e = e.chain)
- {
- org = e.origin;
- tracebox(e.origin, PL_MIN, PL_MAX, e.origin - '0 0 512', MOVE_NOMONSTERS, world);
- setorigin(e, trace_endpos);
- if(navigation_findnearestwaypoint(e, false))
- {
- setorigin(e, org);
- e.effects &= ~EF_NODEPTHTEST;
- e.model = "";
- }
- else
- {
- setorigin(e, org);
- LOG_INFO("spawn without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
- e.effects |= EF_NODEPTHTEST;
- _setmodel(e, self.model);
- e.frame = self.frame;
- e.skin = self.skin;
- e.colormod = '8 0.5 8';
- setsize(e, '0 0 0', '0 0 0');
- ++i;
- }
- }
- if(i)
- LOG_INFO(ftos(i), " spawnpoints have no nearest waypoint (marked by player model)\n");
- i = 0;
- entity start;
- start = findchainflags(flags, FL_ITEM);
- for(e = start; e; e = e.chain)
- {
- e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
- e.colormod = '0.5 0.5 0.5';
- }
- for(e = start; e; e = e.chain)
- {
- if(navigation_findnearestwaypoint(e, false))
- {
- }
- else
- {
- LOG_INFO("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
- e.effects |= EF_NODEPTHTEST | EF_RED;
- e.colormod_x = 8;
- ++i;
- }
- }
- if(i)
- LOG_INFO(ftos(i), " items have no nearest waypoint and cannot be walked away from (marked with red light)\n");
- i = 0;
- for(e = start; e; e = e.chain)
- {
- org = e.origin;
- if(navigation_findnearestwaypoint(e, true))
- {
- }
- else
- {
- LOG_INFO("item without waypoint: ", etos(e), " ", vtos(e.origin), "\n");
- e.effects |= EF_NODEPTHTEST | EF_BLUE;
- e.colormod_z = 8;
- ++i;
- }
- }
- if(i)
- LOG_INFO(ftos(i), " items have no nearest waypoint and cannot be walked to (marked with blue light)\n");
- break;
- }
- }