]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamecommand.qc
renamed roughmap to radarmap; automatically sharpen it
[divverent/nexuiz.git] / data / qcsrc / server / gamecommand.qc
1 string GotoMap(string m);
2
3 #if 0
4 // TODO make this algorithm work (no idea why it is failing), it would be much faster
5 float FullTraceFraction(vector a, vector mi, vector ma, vector b)
6 {
7         vector c;
8         float d;
9         if(a_z > b_z)
10                 return 0;
11         tracebox(a, mi, ma, b, MOVE_WORLDONLY, world);
12         if(trace_startsolid)
13         {
14                 // a leaves solid, then hits trace_endpos
15                 // where does a leave solid?
16                 c = trace_endpos;
17                 tracebox(c, mi, ma, a, MOVE_WORLDONLY, world);
18                 // a to trace_endpos is solid
19                 // trace_endpos to c is not solid
20                 d = trace_endpos_z - a_z;
21                 return FullTraceFraction(c + '0 0 1', mi, ma, b) + d;
22         }
23         else
24         {
25                 // a hits trace_endpos
26                 return FullTraceFraction(trace_endpos + '0 0 1', mi, ma, b);
27         }
28 }
29
30 float RadarMapAtPoint(float x, float y, float w, float h)
31 {
32         vector a, b, mi, ma;
33         mi = '0 0 0';
34         ma = '1 0 0' * w + '0 1 0' * h;
35         a = '1 0 0' * x + '0 1 0' * y + '0 0 1' * world.mins_z;
36         b = '1 0 0' * x + '0 1 0' * y + '0 0 1' * world.maxs_z;
37         return floor(FullTraceFraction(a, mi, ma, b) / (world.maxs_z - world.mins_z) * 255);
38 }
39 #else
40 float RadarMapAtPoint(float x, float y, float w, float h, float zmin, float zsize)
41 {
42         vector o, mi, ma;
43         float i, r;
44         vector dz;
45         mi = '0 0 0';
46         dz = (zsize / 256) * '0 0 1';
47         ma = '1 0 0' * w + '0 1 0' * h + dz;
48         o = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
49
50         if(x < world.mins_x - w)
51                 return 0;
52         if(y < world.mins_y - h)
53                 return 0;
54         if(x > world.maxs_x)
55                 return 0;
56         if(y > world.maxs_y)
57                 return 0;
58         
59         r = 0;
60         for(i = 0; i < 255; ++i)
61         {
62                 tracebox(o + dz * i, mi, ma, o + dz * i, MOVE_WORLDONLY, world);
63                 if(trace_startsolid)
64                         ++r;
65         }
66         return r / 255.0; // 0 .. 1
67 }
68 #endif
69
70 string doublehex = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF";
71
72 float RADAR_WIDTH = 512;
73 float RADAR_HEIGHT = 512;
74 float sharpen_buffer[RADAR_WIDTH * 3];
75
76 void sharpen_set(float x, float v)
77 {
78         sharpen_buffer[x + 2 * RADAR_WIDTH] = v;
79 }
80
81 float sharpen_getpixel(float x, float y)
82 {
83         if(x < 0)
84                 return 0;
85         if(x >= RADAR_WIDTH)
86                 return 0;
87         if(y < 0)
88                 return 0;
89         if(y > 2)
90                 return 0;
91         return sharpen_buffer[x + y * RADAR_WIDTH];
92 }
93
94 float sharpen_get(float x, float a)
95 {
96         float sum;
97         sum = sharpen_getpixel(x, 1);
98         if(a == 0)
99                 return sum;
100         sum *= (8 + 1/a);
101         sum -= sharpen_getpixel(x - 1, 0);
102         sum -= sharpen_getpixel(x - 1, 1);
103         sum -= sharpen_getpixel(x - 1, 2);
104         sum -= sharpen_getpixel(x + 1, 0);
105         sum -= sharpen_getpixel(x + 1, 1);
106         sum -= sharpen_getpixel(x + 1, 2);
107         sum -= sharpen_getpixel(x, 0);
108         sum -= sharpen_getpixel(x, 2);
109         return bound(0, sum * a, 1);
110 }
111
112 void sharpen_shift()
113 {
114         float i;
115         for(i = 0; i < RADAR_WIDTH; ++i)
116         {
117                 sharpen_buffer[i] = sharpen_buffer[i + RADAR_WIDTH];
118                 sharpen_buffer[i + RADAR_WIDTH] = sharpen_buffer[i + 2 * RADAR_WIDTH];
119                 sharpen_buffer[i + 2 * RADAR_WIDTH] = 0;
120         }
121 }
122
123 void sharpen_init()
124 {
125         float i;
126         for(i = 0; i < 3 * RADAR_WIDTH; ++i)
127                 sharpen_buffer[i] = 0;
128 }
129
130 entity radarmapper;
131 // rough map entity
132 //   cnt: current line
133 //   size: pixel width/height
134 //   maxs: cell width/height
135 //   frame: counter
136 void RadarMap_Think()
137 {
138         float i, x, l;
139         string si;
140
141         if(self.frame == 0)
142         {
143                 // initialize
144                 get_mi_min_max_texcoords(1);
145                 self.size_x = RADAR_WIDTH;
146                 self.size_y = RADAR_HEIGHT;
147                 self.mins = mi_picmin;
148                 self.maxs_x = (mi_picmax_x - mi_picmin_x) / self.size_x;
149                 self.maxs_y = (mi_picmax_y - mi_picmin_y) / self.size_y;
150                 self.maxs_z = mi_max_z - mi_min_z;
151                 print("Picture mins/maxs: ", ftos(self.maxs_x), " and ", ftos(self.maxs_y), " should match\n");
152                 self.netname = strzone(strcat("gfx/", mi_shortname, "_radar.xpm"));
153                 if(!(self.count & 1))
154                 {
155                         self.cnt = fopen(self.netname, FILE_READ);
156                         if(self.cnt >= 0)
157                         {
158                                 print(self.netname, " already exists, aborting (you may want to specify --force)\n");
159                                 if(self.count & 4)
160                                 {
161                                         localcmd("quit\n");
162                                 }
163                                 else if(self.count & 2)
164                                 {
165                                         if(self.count & 1)
166                                                 localcmd(strcat("defer 1 \"sv_cmd radarmap --force --loop", ftos(self.ltime), "\"\n"));
167                                         else
168                                                 localcmd(strcat("defer 1 \"sv_cmd radarmap --loop ", ftos(self.ltime), "\"\n"));
169                                         GotoNextMap();
170                                 }
171                                 remove(self);
172                                 radarmapper = world;
173                                 return;
174                         }
175                 }
176                 self.cnt = fopen(self.netname, FILE_WRITE);
177                 if(self.cnt < 0)
178                 {
179                         print("Error writing ", self.netname, "\n");
180                         remove(self);
181                         radarmapper = world;
182                         return;
183                 }
184                 print("Writing to ", self.netname, "...\n");
185                 fputs(self.cnt, "/* XPM */\n");
186                 fputs(self.cnt, "static char *RadarMap[] = {\n");
187                 fputs(self.cnt, "/* columns rows colors chars-per-pixel */\n");
188                 fputs(self.cnt, strcat("\"", ftos(self.size_x), " ", ftos(self.size_y), " 256 2\",\n"));
189                 for(i = 0; i < 256; ++i)
190                 {
191                         si = substring(doublehex, i*2, 2);
192                         fputs(self.cnt, strcat("\"", si, " c #", si, si, si, "\",\n"));
193                 }
194                 self.frame += 1;
195                 self.nextthink = time;
196                 sharpen_init();
197         }
198         else if(self.frame <= self.size_y)
199         {
200                 // fill the sharpen buffer with this line
201                 sharpen_shift();
202                 for(x = 0; x < self.size_x; ++x)
203                 {
204                         l = RadarMapAtPoint(self.mins_x + x * self.maxs_x, self.mins_y + (self.size_y - self.frame) * self.maxs_y, self.maxs_x, self.maxs_y, self.mins_z, self.maxs_z);
205                         sharpen_set(x, l);
206                 }
207
208                 // do we have enough lines?
209                 if(self.frame >= 2)
210                 {
211                         // write a pixel line
212                         fputs(self.cnt, "\"");
213                         for(x = 0; x < self.size_x; ++x)
214                         {
215                                 l = sharpen_get(x, self.ltime);
216                                 fputs(self.cnt, substring(doublehex, 2 * floor(l * 255.0 + 0.5), 2));
217                         }
218                         if(self.frame == self.size_y)
219                                 fputs(self.cnt, "\"\n");
220                         else
221                         {
222                                 fputs(self.cnt, "\",\n");
223                                 print(ftos(self.size_y - self.frame), " lines left\n");
224                         }
225                 }
226
227                 // is this the last line? then write back the missing line
228                 if(self.frame == self.size_y)
229                 {
230                         sharpen_shift();
231                         // write a pixel line
232                         fputs(self.cnt, "\"");
233                         for(x = 0; x < self.size_x; ++x)
234                         {
235                                 l = sharpen_get(x, self.ltime);
236                                 fputs(self.cnt, substring(doublehex, 2 * floor(l * 255.0 + 0.5), 2));
237                         }
238                         if(self.frame == self.size_y)
239                                 fputs(self.cnt, "\"\n");
240                         else
241                         {
242                                 fputs(self.cnt, "\",\n");
243                                 print(ftos(self.size_y - self.frame), " lines left\n");
244                         }
245                 }
246
247                 self.frame += 1;
248                 self.nextthink = time;
249         }
250         else
251         {
252                 // close the file
253                 fputs(self.cnt, "};\n");
254                 fclose(self.cnt);
255                 print("Finished. Please edit data/", self.netname, " with an image editing application and place it in the TGA format in the gfx folder.\n");
256                 if(self.count & 4)
257                 {
258                         localcmd("quit\n");
259                 }
260                 else if(self.count & 2)
261                 {
262                         if(self.count & 1)
263                                 localcmd(strcat("defer 1 \"sv_cmd radarmap --force --loop", ftos(self.ltime), "\"\n"));
264                         else
265                                 localcmd(strcat("defer 1 \"sv_cmd radarmap --loop ", ftos(self.ltime), "\"\n"));
266                         GotoNextMap();
267                 }
268                 remove(self);
269                 radarmapper = world;
270         }
271 }
272
273 void RadarMap(float argc)
274 {
275         if(radarmapper)
276                 return;
277         float i;
278         radarmapper = spawn();
279         radarmapper.classname = "radarmapper";
280         radarmapper.think = RadarMap_Think;
281         radarmapper.nextthink = time;
282         radarmapper.count = 0;
283         radarmapper.ltime = 1;
284
285         for(i = 1; i < argc; ++i)
286         {
287                 if(argv(i) == "--force")
288                         radarmapper.count |= 1;
289                 else if(argv(i) == "--loop")
290                         radarmapper.count |= 2;
291                 else if(argv(i) == "--quit")
292                         radarmapper.count |= 4;
293                 else
294                         radarmapper.ltime = stof(argv(i));
295         }
296 }
297
298 void BBox()
299 {
300         print("Original size: ", ftos(world.absmin_x), " ", ftos(world.absmin_y), " ", ftos(world.absmin_z));
301         print(" ", ftos(world.absmax_x), " ", ftos(world.absmax_y), " ", ftos(world.absmax_z), "\n");
302         print("Currently set size: ", ftos(world.mins_x), " ", ftos(world.mins_y), " ", ftos(world.mins_z));
303         print(" ", ftos(world.maxs_x), " ", ftos(world.maxs_y), " ", ftos(world.maxs_z), "\n");
304         print("Solid bounding box size:");
305
306         tracebox('1 0 0' * world.absmin_x,
307                  '0 1 0' * world.absmin_y + '0 0 1' * world.absmin_z,
308                  '0 1 0' * world.absmax_y + '0 0 1' * world.absmax_z,
309                  '1 0 0' * world.absmax_x,
310                          MOVE_WORLDONLY,
311                          world);
312         if(trace_startsolid)
313                 print(" ", ftos(world.absmin_x));
314         else
315                 print(" ", ftos(trace_endpos_x));
316
317         tracebox('0 1 0' * world.absmin_y,
318                  '1 0 0' * world.absmin_x + '0 0 1' * world.absmin_z,
319                  '1 0 0' * world.absmax_x + '0 0 1' * world.absmax_z,
320                  '0 1 0' * world.absmax_y,
321                          MOVE_WORLDONLY,
322                          world);
323         if(trace_startsolid)
324                 print(" ", ftos(world.absmin_y));
325         else
326                 print(" ", ftos(trace_endpos_y));
327
328         tracebox('0 0 1' * world.absmin_z,
329                  '1 0 0' * world.absmin_x + '0 1 0' * world.absmin_y,
330                  '1 0 0' * world.absmax_x + '0 1 0' * world.absmax_y,
331                  '0 0 1' * world.absmax_z,
332                          MOVE_WORLDONLY,
333                          world);
334         if(trace_startsolid)
335                 print(" ", ftos(world.absmin_z));
336         else
337                 print(" ", ftos(trace_endpos_z));
338
339         tracebox('1 0 0' * world.absmax_x,
340                  '0 1 0' * world.absmin_y + '0 0 1' * world.absmin_z,
341                  '0 1 0' * world.absmax_y + '0 0 1' * world.absmax_z,
342                  '1 0 0' * world.absmin_x,
343                          MOVE_WORLDONLY,
344                          world);
345         if(trace_startsolid)
346                 print(" ", ftos(world.absmax_x));
347         else
348                 print(" ", ftos(trace_endpos_x));
349
350         tracebox('0 1 0' * world.absmax_y,
351                  '1 0 0' * world.absmin_x + '0 0 1' * world.absmin_z,
352                  '1 0 0' * world.absmax_x + '0 0 1' * world.absmax_z,
353                  '0 1 0' * world.absmin_y,
354                          MOVE_WORLDONLY,
355                          world);
356         if(trace_startsolid)
357                 print(" ", ftos(world.absmax_y));
358         else
359                 print(" ", ftos(trace_endpos_y));
360
361         tracebox('0 0 1' * world.absmax_z,
362                  '1 0 0' * world.absmin_x + '0 1 0' * world.absmin_y,
363                  '1 0 0' * world.absmax_x + '0 1 0' * world.absmax_y,
364                  '0 0 1' * world.absmin_z,
365                          MOVE_WORLDONLY,
366                          world);
367         if(trace_startsolid)
368                 print(" ", ftos(world.absmax_z));
369         else
370                 print(" ", ftos(trace_endpos_z));
371
372         print("\n");
373 }
374
375 void EffectIndexDump()
376 {
377         float d;
378         float fh;
379         string s;
380
381         d = db_create();
382
383         print("begin of effects list\n");
384         db_put(d, "TE_GUNSHOT", "1"); print("effect TE_GUNSHOT is ", ftos(particleeffectnum("TE_GUNSHOT")), "\n");
385         db_put(d, "TE_GUNSHOTQUAD", "1"); print("effect TE_GUNSHOTQUAD is ", ftos(particleeffectnum("TE_GUNSHOTQUAD")), "\n");
386         db_put(d, "TE_SPIKE", "1"); print("effect TE_SPIKE is ", ftos(particleeffectnum("TE_SPIKE")), "\n");
387         db_put(d, "TE_SPIKEQUAD", "1"); print("effect TE_SPIKEQUAD is ", ftos(particleeffectnum("TE_SPIKEQUAD")), "\n");
388         db_put(d, "TE_SUPERSPIKE", "1"); print("effect TE_SUPERSPIKE is ", ftos(particleeffectnum("TE_SUPERSPIKE")), "\n");
389         db_put(d, "TE_SUPERSPIKEQUAD", "1"); print("effect TE_SUPERSPIKEQUAD is ", ftos(particleeffectnum("TE_SUPERSPIKEQUAD")), "\n");
390         db_put(d, "TE_WIZSPIKE", "1"); print("effect TE_WIZSPIKE is ", ftos(particleeffectnum("TE_WIZSPIKE")), "\n");
391         db_put(d, "TE_KNIGHTSPIKE", "1"); print("effect TE_KNIGHTSPIKE is ", ftos(particleeffectnum("TE_KNIGHTSPIKE")), "\n");
392         db_put(d, "TE_EXPLOSION", "1"); print("effect TE_EXPLOSION is ", ftos(particleeffectnum("TE_EXPLOSION")), "\n");
393         db_put(d, "TE_EXPLOSIONQUAD", "1"); print("effect TE_EXPLOSIONQUAD is ", ftos(particleeffectnum("TE_EXPLOSIONQUAD")), "\n");
394         db_put(d, "TE_TAREXPLOSION", "1"); print("effect TE_TAREXPLOSION is ", ftos(particleeffectnum("TE_TAREXPLOSION")), "\n");
395         db_put(d, "TE_TELEPORT", "1"); print("effect TE_TELEPORT is ", ftos(particleeffectnum("TE_TELEPORT")), "\n");
396         db_put(d, "TE_LAVASPLASH", "1"); print("effect TE_LAVASPLASH is ", ftos(particleeffectnum("TE_LAVASPLASH")), "\n");
397         db_put(d, "TE_SMALLFLASH", "1"); print("effect TE_SMALLFLASH is ", ftos(particleeffectnum("TE_SMALLFLASH")), "\n");
398         db_put(d, "TE_FLAMEJET", "1"); print("effect TE_FLAMEJET is ", ftos(particleeffectnum("TE_FLAMEJET")), "\n");
399         db_put(d, "EF_FLAME", "1"); print("effect EF_FLAME is ", ftos(particleeffectnum("EF_FLAME")), "\n");
400         db_put(d, "TE_BLOOD", "1"); print("effect TE_BLOOD is ", ftos(particleeffectnum("TE_BLOOD")), "\n");
401         db_put(d, "TE_SPARK", "1"); print("effect TE_SPARK is ", ftos(particleeffectnum("TE_SPARK")), "\n");
402         db_put(d, "TE_PLASMABURN", "1"); print("effect TE_PLASMABURN is ", ftos(particleeffectnum("TE_PLASMABURN")), "\n");
403         db_put(d, "TE_TEI_G3", "1"); print("effect TE_TEI_G3 is ", ftos(particleeffectnum("TE_TEI_G3")), "\n");
404         db_put(d, "TE_TEI_SMOKE", "1"); print("effect TE_TEI_SMOKE is ", ftos(particleeffectnum("TE_TEI_SMOKE")), "\n");
405         db_put(d, "TE_TEI_BIGEXPLOSION", "1"); print("effect TE_TEI_BIGEXPLOSION is ", ftos(particleeffectnum("TE_TEI_BIGEXPLOSION")), "\n");
406         db_put(d, "TE_TEI_PLASMAHIT", "1"); print("effect TE_TEI_PLASMAHIT is ", ftos(particleeffectnum("TE_TEI_PLASMAHIT")), "\n");
407         db_put(d, "EF_STARDUST", "1"); print("effect EF_STARDUST is ", ftos(particleeffectnum("EF_STARDUST")), "\n");
408         db_put(d, "TR_ROCKET", "1"); print("effect TR_ROCKET is ", ftos(particleeffectnum("TR_ROCKET")), "\n");
409         db_put(d, "TR_GRENADE", "1"); print("effect TR_GRENADE is ", ftos(particleeffectnum("TR_GRENADE")), "\n");
410         db_put(d, "TR_BLOOD", "1"); print("effect TR_BLOOD is ", ftos(particleeffectnum("TR_BLOOD")), "\n");
411         db_put(d, "TR_WIZSPIKE", "1"); print("effect TR_WIZSPIKE is ", ftos(particleeffectnum("TR_WIZSPIKE")), "\n");
412         db_put(d, "TR_SLIGHTBLOOD", "1"); print("effect TR_SLIGHTBLOOD is ", ftos(particleeffectnum("TR_SLIGHTBLOOD")), "\n");
413         db_put(d, "TR_KNIGHTSPIKE", "1"); print("effect TR_KNIGHTSPIKE is ", ftos(particleeffectnum("TR_KNIGHTSPIKE")), "\n");
414         db_put(d, "TR_VORESPIKE", "1"); print("effect TR_VORESPIKE is ", ftos(particleeffectnum("TR_VORESPIKE")), "\n");
415         db_put(d, "TR_NEHAHRASMOKE", "1"); print("effect TR_NEHAHRASMOKE is ", ftos(particleeffectnum("TR_NEHAHRASMOKE")), "\n");
416         db_put(d, "TR_NEXUIZPLASMA", "1"); print("effect TR_NEXUIZPLASMA is ", ftos(particleeffectnum("TR_NEXUIZPLASMA")), "\n");
417         db_put(d, "TR_GLOWTRAIL", "1"); print("effect TR_GLOWTRAIL is ", ftos(particleeffectnum("TR_GLOWTRAIL")), "\n");
418         db_put(d, "SVC_PARTICLE", "1"); print("effect SVC_PARTICLE is ", ftos(particleeffectnum("SVC_PARTICLE")), "\n");
419
420         fh = fopen("effectinfo.txt", FILE_READ);
421         while((s = fgets(fh)))
422         {
423                 tokenize(s);
424                 if(argv(0) == "effect")
425                 {
426                         if(db_get(d, argv(1)) != "1")
427                         {
428                                 if(particleeffectnum(argv(1)) >= 0)
429                                         print("effect ", argv(1), " is ", ftos(particleeffectnum(argv(1))), "\n");
430                                 db_put(d, argv(1), "1");
431                         }
432                 }
433         }
434         print("end of effects list\n");
435
436         db_close(d);
437 }
438
439 void make_mapinfo_Think()
440 {
441         if(MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 1))
442         {
443                 print("Done rebuiling mapinfos.\n");
444                 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 0);
445                 remove(self);
446         }
447         else
448         {
449                 self.think = make_mapinfo_Think;
450                 self.nextthink = time;
451         }
452 }
453
454 void GameCommand(string command)
455 {
456         float argc;
457         entity client;
458         float entno;
459         argc = tokenize(command);
460
461         if(argv(0) == "help" || argc == 0)
462         {
463                 print("Usage: sv_cmd COMMAND..., where possible commands are:\n");
464                 print("  adminmsg clientnumber \"message\"\n");
465                 print("  teamstatus\n");
466                 print("  printstats\n");
467                 print("  make_mapinfo\n");
468                 print("  gametype dm|ctf|...\n");
469                 print("  savedb filename\n");
470                 print("  dumpdb filename\n");
471                 print("  loaddb filename\n");
472                 print("  allready\n");
473                 print("  effectindexdump\n");
474                 print("  radarmap\n");
475                 print("  bbox\n");
476                 GameCommand_Vote("help", world);
477                 GameCommand_Ban("help");
478                 GameCommand_Generic("help");
479                 return;
480         }
481
482         if(GameCommand_Vote(command, world))
483                 return;
484
485         if(GameCommand_Ban(command))
486                 return;
487
488         if(GameCommand_Generic(command))
489                 return;
490
491         if(argv(0) == "printstats")
492         {
493                 DumpStats(FALSE);
494                 return;
495         }
496
497         if(argv(0) == "make_mapinfo")
498         {
499                 entity e;
500                 e = spawn();
501                 e.classname = "make_mapinfo";
502                 e.think = make_mapinfo_Think;
503                 e.nextthink = time;
504                 MapInfo_Enumerate();
505                 return;
506         }
507
508         if(argv(0) == "warp") if(argc == 2) if(cvar("g_campaign"))
509         {
510                 CampaignLevelWarp(stof(argv(1)));
511                 return;
512         }
513
514         if(argv(0) == "gotomap") if(argc == 2)
515         {
516                 print(GotoMap(argv(1)), "\n");
517                 return;
518         }
519
520         if(argv(0) == "gametype") if(argc == 2)
521         {
522                 float t, tsave;
523                 string s;
524                 s = argv(1);
525                 t = MapInfo_Type_FromString(s);
526                 tsave = MapInfo_CurrentGametype();
527                 if(t)
528                 {
529                         MapInfo_SwitchGameType(t);
530                         MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 0);
531                         if(MapInfo_count > 0)
532                         {
533                                 bprint("Game type successfully switched to ", s, "\n");
534                         }
535                         else
536                         {
537                                 bprint("Cannot use this game type: no map for it found\n");
538                                 MapInfo_SwitchGameType(tsave);
539                                 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 0);
540                         }
541                 }
542                 else
543                         bprint("Game type switch to ", s, " failed: this type does not exist!\n");
544                 return;
545         }
546
547         if(argv(0) == "adminmsg") if(argc == 3)
548         {
549                 entno = stof(argv(1));
550                 client = world;
551                 if(entno <= maxclients)
552                         client = edict_num(entno);
553                 if(client.flags & FL_CLIENT)
554                 {
555                         centerprint_atprio(client, CENTERPRIO_ADMIN, strcat("^3SERVER ADMIN:\n\n^7", argv(2)));
556                         sprint(client, strcat("\{1}\{13}^3SERVER ADMIN^7: ", argv(2), "\n"));
557                         print("Message sent to ", client.netname, "\n");
558                 }
559                 else
560                         print("Client not found\n");
561                 return;
562         }
563
564         if(argv(0) == "savedb") if(argc == 2)
565         {
566                 db_save(ServerProgsDB, argv(1));
567                 print("DB saved.\n");
568                 return;
569         }
570
571         if(argv(0) == "dumpdb") if(argc == 2)
572         {
573                 db_dump(ServerProgsDB, argv(1));
574                 print("DB dumped.\n");
575                 return;
576         }
577
578         if(argv(0) == "loaddb") if(argc == 2)
579         {
580                 db_close(ServerProgsDB);
581                 ServerProgsDB = db_load(argv(1));
582                 print("DB loaded.\n");
583                 return;
584         }
585         if (argv(0) == "nospectators")
586         {
587                 blockSpectators = 1;
588                 local entity plr;
589                 FOR_EACH_CLIENT(plr) //give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
590                 {
591                         if(plr.classname == "spectator" || plr.classname == "observer")
592                         {
593                                 plr.spectatortime = time;
594                                 sprint(plr, strcat("^7You have to become a player within the next ", ftos(cvar("g_maxplayers_spectator_blocktime")), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
595                         }
596                 }
597                 bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(cvar("g_maxplayers_spectator_blocktime")), " seconds!\n"));
598                 return;
599         }
600         if (argv(0) == "lockteams")
601         {
602                 if(teamplay)
603                 {
604                         lockteams = 1;
605                         bprint("^1The teams are now locked.\n");
606                 }
607                 else
608                         bprint("That command can only be used in a team-based gamemode.\n");
609                 return;
610         }
611         if (argv(0) == "unlockteams")
612         {
613                 if(teamplay)
614                 {
615                         lockteams = 0;
616                         bprint("^1The teams are now unlocked.\n");
617                 }
618                 else
619                         bprint("That command can only be used in a team-based gamemode.\n");
620                 return;
621         }
622         if (argv(0) == "movetoteam") if(argc == 3)
623         {
624                 entno = stof(argv(1));
625                 client = world;
626                 if(entno <= maxclients)
627                         client = edict_num(entno);
628                 if(client.flags & FL_CLIENT)
629                 {
630                         float lt;
631                         lt = lockteams;
632                         lockteams = 0;
633
634                         self = client;
635                         SV_ParseClientCommand(strcat("selectteam ", argv(2)));
636
637                         lockteams = lt;
638                 }
639                 else
640                         print("Client not found\n");
641                 return;
642         }
643         if (argv(0) == "teamstatus")
644         {
645                 Score_NicePrint(world);
646                 return;
647         }
648         if (argv(0) == "allready")
649         {
650                 ReadyRestart();
651                 return;
652         }
653         if (argv(0) == "effectindexdump")
654         {
655                 EffectIndexDump();
656                 return;
657         }
658         if (argv(0) == "radarmap")
659         {
660                 RadarMap(argc);
661                 return;
662         }
663         if (argv(0) == "bbox")
664         {
665                 BBox();
666                 return;
667         }
668         if (argv(0) == "cvar_changes")
669         {
670                 print(cvar_changes);
671                 return;
672         }
673
674         print("Invalid command. For a list of supported commands, try sv_cmd help.\n");
675 }
676