6 REGISTER_NET_TEMP(net_debug, bool isNew)
10 this.sv_entnum = ReadShort();
11 if (ReadByte()) make_pure(this);
12 this.origin_x = ReadCoord();
13 this.origin_y = ReadCoord();
14 this.origin_z = ReadCoord();
15 setorigin(this, this.origin);
16 this.debug = true; // identify server entities by this
17 this.classname = strzone(ReadString());
18 this.sourceLocFile = strzone(ReadString());
19 this.sourceLocLine = ReadInt24_t();
24 bool debug_send(entity this, entity to, int sf)
26 int channel = MSG_ONE;
28 WriteHeader(channel, net_debug);
29 WriteShort(channel, num_for_edict(this));
30 WriteByte(channel, is_pure(this));
31 WriteCoord(channel, this.origin.x);
32 WriteCoord(channel, this.origin.y);
33 WriteCoord(channel, this.origin.z);
34 WriteString(channel, this.classname);
35 WriteString(channel, this.sourceLocFile);
36 WriteInt24_t(channel, this.sourceLocLine);
41 bool autocvar_debugdraw;
45 vector project_3d_to_2d(vector vec);
48 if (!autocvar_debugdraw) return;
49 static int debugdraw_frame;
52 for (entity e1 = NULL; (e1 = nextent(e1)); )
54 if (e1.debugdraw_last == debugdraw_frame) continue;
56 for (entity e = findradius(e1.origin, 100); e; e = e.chain)
58 if (e.debugdraw_last == debugdraw_frame) continue;
59 e.debugdraw_last = debugdraw_frame;
60 vector rgb = (e.debug) ? '0 0 1' : '1 0 0';
63 if (autocvar_debugdraw < 2) continue;
66 vector pos = project_3d_to_2d(e.origin);
67 if (pos.z < 0) continue;
70 drawcolorcodedstring2(pos,
71 sprintf("%d: '%s'@%s:%d", (e.debug ? e.sv_entnum : num_for_edict(e)),
72 e.classname, e.sourceLocFile, e.sourceLocLine),
73 size * '1 1 0', rgb, 0.5, DRAWFLAG_NORMAL);
81 GENERIC_COMMAND(debugdraw_sv, "Dump all server entities")
85 case CMD_REQUEST_COMMAND:
87 if (!autocvar_debugdraw) return;
90 for (entity e = NULL; (e = findfloat(e, debug, 0)) && rem > 0; )
92 if (autocvar_debugdraw < 2 && is_pure(e)) continue;
93 debug_send(e, nextent(NULL), 0);
97 LOG_INFOF("%d server entities sent\n", n - rem);
102 case CMD_REQUEST_USAGE:
104 LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " debugdraw_sv"));