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.sourceLoc = strzone(ReadString());
28 bool debug_send(entity this, entity to, int sf)
30 int channel = MSG_ONE;
32 WriteHeader(channel, net_debug);
33 WriteShort(channel, etof(this));
34 WriteByte(channel, is_pure(this));
35 WriteCoord(channel, this.origin.x);
36 WriteCoord(channel, this.origin.y);
37 WriteCoord(channel, this.origin.z);
38 WriteString(channel, this.classname);
39 WriteString(channel, this.sourceLoc);
45 bool autocvar_debugdraw;
49 string autocvar_debugdraw_filter, autocvar_debugdraw_filterout;
51 vector project_3d_to_2d(vector vec);
54 if (!autocvar_debugdraw) return;
55 static int debugdraw_frame;
58 FOREACH_ENTITY(true, LAMBDA(
59 if (it.debugdraw_last == debugdraw_frame) continue;
61 for (entity e = findradius(it.origin, 100); e; e = e.chain)
63 if (e.debugdraw_last == debugdraw_frame) continue;
64 e.debugdraw_last = debugdraw_frame;
65 vector rgb = (e.debug) ? '0 0 1' : '1 0 0';
66 if (autocvar_debugdraw_filterout != "" && strhasword(autocvar_debugdraw_filterout, e.classname)) continue;
67 if (autocvar_debugdraw_filter != "" && !strhasword(autocvar_debugdraw_filter, e.classname)) continue;
68 if (autocvar_debugdraw == 3)
70 if (!e.entnum) continue;
72 if (autocvar_debugdraw == 4)
74 if (e.origin) continue;
76 else if (autocvar_debugdraw > 4)
80 // if (e.modelindex) break;
81 // if (e.absmin) break;
82 // if (e.absmax) break;
83 // if (e.entnum) break;
84 // if (e.drawmask) break;
85 // if (e.predraw) break;
86 // if (e.movetype) break;
88 // if (e.origin) break;
89 // if (e.oldorigin) break;
90 // if (e.velocity) break;
91 // if (e.angles) break;
92 // if (e.avelocity) break;
93 // if (e.classname) break;
94 // if (e.model) break;
95 // if (e.frame) break;
97 // if (e.effects) break;
100 // if (e.size) break;
101 // if (e.touch) break;
103 // if (e.think) break;
104 // if (e.blocked) break;
105 // if (e.nextthink) break;
106 // if (e.chain) break;
107 // if (e.netname) break;
108 // if (e.enemy) break;
109 // if (e.flags) break;
110 // if (e.colormap) break;
111 // if (e.owner) break;
118 if (autocvar_debugdraw < 2) continue;
121 vector pos = project_3d_to_2d(e.origin);
122 if (pos.z < 0) continue;
125 drawcolorcodedstring2(pos,
126 sprintf("%d: '%s'@%s", (e.debug ? e.sv_entnum : etof(e)),
127 e.classname, e.sourceLoc),
128 sz * '1 1 0', rgb, 0.5, DRAWFLAG_NORMAL);
136 COMMON_COMMAND(debugdraw_sv, "Dump all server entities")
140 case CMD_REQUEST_COMMAND:
142 if (!autocvar_debugdraw) return;
145 for (entity e = NULL; (e = findfloat(e, debug, 0)) && rem > 0; )
147 if (autocvar_debugdraw < 2 && is_pure(e)) continue;
148 debug_send(e, nextent(NULL), 0);
152 LOG_INFOF("%d server entities sent\n", n - rem);
157 case CMD_REQUEST_USAGE:
159 LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " debugdraw_sv"));
166 GENERIC_COMMAND(bufstr_get, "Examine a string buffer object")
170 case CMD_REQUEST_COMMAND:
172 int bufhandle = stof(argv(1));
173 int string_index = stof(argv(2));
174 string s = bufstr_get(bufhandle, string_index);
175 LOG_INFOF("%s\n", s);
180 case CMD_REQUEST_USAGE:
182 LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " bufstr_get bufhandle string_index"));