7 REGISTER_NET_TEMP(net_debug)
11 NET_HANDLE(net_debug, bool isNew)
13 Net_Accept(net_debug);
14 this.sv_entnum = ReadShort();
15 if (ReadByte()) make_pure(this);
16 this.origin_x = ReadCoord();
17 this.origin_y = ReadCoord();
18 this.origin_z = ReadCoord();
19 setorigin(this, this.origin);
20 this.debug = true; // identify server entities by this
21 this.classname = strzone(ReadString());
22 this.sourceLocFile = strzone(ReadString());
23 this.sourceLocLine = ReadInt24_t();
29 bool debug_send(entity this, entity to, int sf)
31 int channel = MSG_ONE;
33 WriteHeader(channel, net_debug);
34 WriteShort(channel, etof(this));
35 WriteByte(channel, is_pure(this));
36 WriteCoord(channel, this.origin.x);
37 WriteCoord(channel, this.origin.y);
38 WriteCoord(channel, this.origin.z);
39 WriteString(channel, this.classname);
40 WriteString(channel, this.sourceLocFile);
41 WriteInt24_t(channel, this.sourceLocLine);
47 bool autocvar_debugdraw;
51 string autocvar_debugdraw_filter, autocvar_debugdraw_filterout;
53 vector project_3d_to_2d(vector vec);
56 if (!autocvar_debugdraw) return;
57 static int debugdraw_frame;
60 FOREACH_ENTITY(true, LAMBDA(
61 if (it.debugdraw_last == debugdraw_frame) continue;
63 for (entity e = findradius(it.origin, 100); e; e = e.chain)
65 if (e.debugdraw_last == debugdraw_frame) continue;
66 e.debugdraw_last = debugdraw_frame;
67 vector rgb = (e.debug) ? '0 0 1' : '1 0 0';
68 if (autocvar_debugdraw_filterout != "" && strhasword(autocvar_debugdraw_filterout, e.classname)) continue;
69 if (autocvar_debugdraw_filter != "" && !strhasword(autocvar_debugdraw_filter, e.classname)) continue;
70 if (autocvar_debugdraw == 3)
72 if (!e.entnum) continue;
74 if (autocvar_debugdraw == 4)
76 if (e.origin) continue;
78 else if (autocvar_debugdraw > 4)
82 // if (e.modelindex) break;
83 // if (e.absmin) break;
84 // if (e.absmax) break;
85 // if (e.entnum) break;
86 // if (e.drawmask) break;
87 // if (e.predraw) break;
88 // if (e.movetype) break;
90 // if (e.origin) break;
91 // if (e.oldorigin) break;
92 // if (e.velocity) break;
93 // if (e.angles) break;
94 // if (e.avelocity) break;
95 // if (e.classname) break;
96 // if (e.model) break;
97 // if (e.frame) break;
99 // if (e.effects) break;
100 // if (e.mins) break;
101 // if (e.maxs) break;
102 // if (e.size) break;
103 // if (e.touch) break;
105 // if (e.think) break;
106 // if (e.blocked) break;
107 // if (e.nextthink) break;
108 // if (e.chain) break;
109 // if (e.netname) break;
110 // if (e.enemy) break;
111 // if (e.flags) break;
112 // if (e.colormap) break;
113 // if (e.owner) break;
120 if (autocvar_debugdraw < 2) continue;
123 vector pos = project_3d_to_2d(e.origin);
124 if (pos.z < 0) continue;
127 drawcolorcodedstring2(pos,
128 sprintf("%d: '%s'@%s:%d", (e.debug ? e.sv_entnum : etof(e)),
129 e.classname, e.sourceLocFile, e.sourceLocLine),
130 sz * '1 1 0', rgb, 0.5, DRAWFLAG_NORMAL);
138 COMMON_COMMAND(debugdraw_sv, "Dump all server entities")
142 case CMD_REQUEST_COMMAND:
144 if (!autocvar_debugdraw) return;
147 for (entity e = NULL; (e = findfloat(e, debug, 0)) && rem > 0; )
149 if (autocvar_debugdraw < 2 && is_pure(e)) continue;
150 debug_send(e, nextent(NULL), 0);
154 LOG_INFOF("%d server entities sent\n", n - rem);
159 case CMD_REQUEST_USAGE:
161 LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " debugdraw_sv"));
168 GENERIC_COMMAND(bufstr_get, "Examine a string buffer object")
172 case CMD_REQUEST_COMMAND:
174 int bufhandle = stof(argv(1));
175 int string_index = stof(argv(2));
176 string s = bufstr_get(bufhandle, string_index);
177 LOG_INFOF("%s\n", s);
182 case CMD_REQUEST_USAGE:
184 LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " bufstr_get bufhandle string_index"));