#include "g_local.h"Go to the source code of this file.
Data Structures | |
| struct | ipFilter_s |
Defines | |
| #define | MAX_IPFILTERS 1024 |
Typedefs | |
| typedef ipFilter_s | ipFilter_t |
Functions | |
| qboolean | G_FilterPacket (char *from) |
| void | G_ProcessIPBans (void) |
| void | Svcmd_AddIP_f (void) |
| void | Svcmd_RemoveIP_f (void) |
| void | Svcmd_EntityList_f (void) |
| gclient_t * | ClientForString (const char *s) |
| void | Svcmd_ForceTeam_f (void) |
| char * | ConcatArgs (int start) |
| qboolean | ConsoleCommand (void) |
|
|
Definition at line 51 of file g_svcmds.c. |
|
|
Referenced by Svcmd_RemoveIP_f(). |
|
|
Definition at line 340 of file g_svcmds.c. References atoi(), level_locals_t::clients, Com_Printf(), CON_DISCONNECTED, clientPersistant_t::connected, G_Printf(), gclient_t, level, level_locals_t::maxclients, clientPersistant_t::netname, NULL, gclient_s::pers, and Q_stricmp(). Referenced by Svcmd_ForceTeam_f().
00340 {
00341 gclient_t *cl;
00342 int i;
00343 int idnum;
00344
00345 // numeric values are just slot numbers
00346 if ( s[0] >= '0' && s[0] <= '9' ) {
00347 idnum = atoi( s );
00348 if ( idnum < 0 || idnum >= level.maxclients ) {
00349 Com_Printf( "Bad client slot: %i\n", idnum );
00350 return NULL;
00351 }
00352
00353 cl = &level.clients[idnum];
00354 if ( cl->pers.connected == CON_DISCONNECTED ) {
00355 G_Printf( "Client %i is not connected\n", idnum );
00356 return NULL;
00357 }
00358 return cl;
00359 }
00360
00361 // check for a name match
00362 for ( i=0 ; i < level.maxclients ; i++ ) {
00363 cl = &level.clients[i];
00364 if ( cl->pers.connected == CON_DISCONNECTED ) {
00365 continue;
00366 }
00367 if ( !Q_stricmp( cl->pers.netname, s ) ) {
00368 return cl;
00369 }
00370 }
00371
00372 G_Printf( "User %s is not on the server\n", s );
00373
00374 return NULL;
00375 }
|
|
|
Definition at line 127 of file g_cmds.c. References MAX_STRING_CHARS, memcpy(), strlen(), trap_Argc(), and trap_Argv(). Referenced by AcceptBotCommand(), and ConsoleCommand().
00127 {
00128 int i, c, tlen;
00129 static char line[MAX_STRING_CHARS];
00130 int len;
00131 char arg[MAX_STRING_CHARS];
00132
00133 len = 0;
00134 c = trap_Argc();
00135 for ( i = start ; i < c ; i++ ) {
00136 trap_Argv( i, arg, sizeof( arg ) );
00137 tlen = strlen( arg );
00138 if ( len + tlen >= MAX_STRING_CHARS - 1 ) {
00139 break;
00140 }
00141 memcpy( line + len, arg, tlen );
00142 len += tlen;
00143 if ( i != c - 1 ) {
00144 line[len] = ' ';
00145 len++;
00146 }
00147 }
00148
00149 line[len] = 0;
00150
00151 return line;
00152 }
|
|
|
Definition at line 408 of file g_svcmds.c. References ConcatArgs(), EXEC_NOW, g_dedicated, vmCvar_t::integer, MAX_TOKEN_CHARS, Q_stricmp(), qboolean, qfalse, qtrue, Svcmd_AddBot_f(), Svcmd_AddIP_f(), Svcmd_BotList_f(), Svcmd_EntityList_f(), Svcmd_ForceTeam_f(), Svcmd_GameMem_f(), Svcmd_RemoveIP_f(), trap_Argv(), trap_SendConsoleCommand(), trap_SendServerCommand(), and va(). Referenced by vmMain().
00408 {
00409 char cmd[MAX_TOKEN_CHARS];
00410
00411 trap_Argv( 0, cmd, sizeof( cmd ) );
00412
00413 if ( Q_stricmp (cmd, "entitylist") == 0 ) {
00414 Svcmd_EntityList_f();
00415 return qtrue;
00416 }
00417
00418 if ( Q_stricmp (cmd, "forceteam") == 0 ) {
00419 Svcmd_ForceTeam_f();
00420 return qtrue;
00421 }
00422
00423 if (Q_stricmp (cmd, "game_memory") == 0) {
00424 Svcmd_GameMem_f();
00425 return qtrue;
00426 }
00427
00428 if (Q_stricmp (cmd, "addbot") == 0) {
00429 Svcmd_AddBot_f();
00430 return qtrue;
00431 }
00432
00433 if (Q_stricmp (cmd, "botlist") == 0) {
00434 Svcmd_BotList_f();
00435 return qtrue;
00436 }
00437
00438 /* if (Q_stricmp (cmd, "abort_podium") == 0) {
00439 Svcmd_AbortPodium_f();
00440 return qtrue;
00441 }
00442 */
00443 if (Q_stricmp (cmd, "addip") == 0) {
00444 Svcmd_AddIP_f();
00445 return qtrue;
00446 }
00447
00448 if (Q_stricmp (cmd, "removeip") == 0) {
00449 Svcmd_RemoveIP_f();
00450 return qtrue;
00451 }
00452
00453 if (Q_stricmp (cmd, "listip") == 0) {
00454 trap_SendConsoleCommand( EXEC_NOW, "g_banIPs\n" );
00455 return qtrue;
00456 }
00457
00458 if (g_dedicated.integer) {
00459 if (Q_stricmp (cmd, "say") == 0) {
00460 trap_SendServerCommand( -1, va("print \"server: %s\n\"", ConcatArgs(1) ) );
00461 return qtrue;
00462 }
00463 // everything else will also be printed as a say command
00464 trap_SendServerCommand( -1, va("print \"server: %s\n\"", ConcatArgs(0) ) );
00465 return qtrue;
00466 }
00467
00468 return qfalse;
00469 }
|
|
|
Definition at line 134 of file g_svcmds.c. References byte, ipFilter_s::compare, g_filterBan, vmCvar_t::integer, ipFilter_s::mask, and qboolean. Referenced by ClientConnect().
00135 {
00136 byte m[4];// = {'\0','\0','\0','\0'};
00137 int i = 0;
00138 unsigned int in;
00139 char *p;
00140
00141 while (i < 4)
00142 {
00143 m[i] = 0;
00144 i++;
00145 }
00146
00147 i = 0;
00148 p = from;
00149 while (*p && i < 4) {
00150 while (*p >= '0' && *p <= '9') {
00151 m[i] = m[i]*10 + (*p - '0');
00152 p++;
00153 }
00154 if (!*p || *p == ':')
00155 break;
00156 i++, p++;
00157 }
00158
00159 in = *(unsigned int *)m;
00160
00161 for (i=0 ; i<numIPFilters ; i++)
00162 if ( (in & ipFilters[i].mask) == ipFilters[i].compare)
00163 return g_filterBan.integer != 0;
00164
00165 return g_filterBan.integer == 0;
00166 }
|
|
|
Definition at line 201 of file g_svcmds.c. References g_banIPs, MAX_TOKEN_CHARS, Q_strncpyz(), strchr(), and vmCvar_t::string. Referenced by G_InitGame().
00202 {
00203 char *s, *t;
00204 char str[MAX_TOKEN_CHARS];
00205
00206 Q_strncpyz( str, g_banIPs.string, sizeof(str) );
00207
00208 for (t = s = g_banIPs.string; *t; /* */ ) {
00209 s = strchr(s, ' ');
00210 if (!s)
00211 break;
00212 while (*s == ' ')
00213 *s++ = 0;
00214 if (*t)
00215 AddIP( t );
00216 t = s;
00217 }
00218 }
|
|
|
Definition at line 226 of file g_svcmds.c. References G_Printf(), MAX_TOKEN_CHARS, trap_Argc(), and trap_Argv(). Referenced by ConsoleCommand().
00227 {
00228 char str[MAX_TOKEN_CHARS];
00229
00230 if ( trap_Argc() < 2 ) {
00231 G_Printf("Usage: addip <ip-mask>\n");
00232 return;
00233 }
00234
00235 trap_Argv( 1, str, sizeof( str ) );
00236
00237 AddIP( str );
00238
00239 }
|
|
|
Definition at line 281 of file g_svcmds.c. References gentity_s::classname, ET_BEAM, ET_GENERAL, ET_INVISIBLE, ET_ITEM, ET_MISSILE, ET_MOVER, ET_NPC, ET_PLAYER, ET_PORTAL, ET_PUSH_TRIGGER, ET_SPEAKER, ET_TELEPORT_TRIGGER, entityState_s::eType, g_entities, G_Printf(), gentity_t, gentity_s::inuse, level, level_locals_t::num_entities, and gentity_s::s. Referenced by ConsoleCommand().
00281 {
00282 int e;
00283 gentity_t *check;
00284
00285 check = g_entities+1;
00286 for (e = 1; e < level.num_entities ; e++, check++) {
00287 if ( !check->inuse ) {
00288 continue;
00289 }
00290 G_Printf("%3i:", e);
00291 switch ( check->s.eType ) {
00292 case ET_GENERAL:
00293 G_Printf("ET_GENERAL ");
00294 break;
00295 case ET_PLAYER:
00296 G_Printf("ET_PLAYER ");
00297 break;
00298 case ET_ITEM:
00299 G_Printf("ET_ITEM ");
00300 break;
00301 case ET_MISSILE:
00302 G_Printf("ET_MISSILE ");
00303 break;
00304 case ET_MOVER:
00305 G_Printf("ET_MOVER ");
00306 break;
00307 case ET_BEAM:
00308 G_Printf("ET_BEAM ");
00309 break;
00310 case ET_PORTAL:
00311 G_Printf("ET_PORTAL ");
00312 break;
00313 case ET_SPEAKER:
00314 G_Printf("ET_SPEAKER ");
00315 break;
00316 case ET_PUSH_TRIGGER:
00317 G_Printf("ET_PUSH_TRIGGER ");
00318 break;
00319 case ET_TELEPORT_TRIGGER:
00320 G_Printf("ET_TELEPORT_TRIGGER ");
00321 break;
00322 case ET_INVISIBLE:
00323 G_Printf("ET_INVISIBLE ");
00324 break;
00325 case ET_NPC:
00326 G_Printf("ET_NPC ");
00327 break;
00328 default:
00329 G_Printf("%3i ", check->s.eType);
00330 break;
00331 }
00332
00333 if ( check->classname ) {
00334 G_Printf("%s", check->classname);
00335 }
00336 G_Printf("\n");
00337 }
00338 }
|
|
|
Definition at line 384 of file g_svcmds.c. References ClientForString(), level_locals_t::clients, g_entities, gclient_t, level, MAX_TOKEN_CHARS, SetTeam(), and trap_Argv(). Referenced by ConsoleCommand().
00384 {
00385 gclient_t *cl;
00386 char str[MAX_TOKEN_CHARS];
00387
00388 // find the player
00389 trap_Argv( 1, str, sizeof( str ) );
00390 cl = ClientForString( str );
00391 if ( !cl ) {
00392 return;
00393 }
00394
00395 // set the team
00396 trap_Argv( 2, str, sizeof( str ) );
00397 SetTeam( &g_entities[cl - level.clients], str );
00398 }
|
|
|
Definition at line 246 of file g_svcmds.c. References ipFilter_s::compare, G_Printf(), ipFilter_t, ipFilter_s::mask, MAX_TOKEN_CHARS, trap_Argc(), and trap_Argv(). Referenced by ConsoleCommand().
00247 {
00248 ipFilter_t f;
00249 int i;
00250 char str[MAX_TOKEN_CHARS];
00251
00252 if ( trap_Argc() < 2 ) {
00253 G_Printf("Usage: sv removeip <ip-mask>\n");
00254 return;
00255 }
00256
00257 trap_Argv( 1, str, sizeof( str ) );
00258
00259 if (!StringToFilter (str, &f))
00260 return;
00261
00262 for (i=0 ; i<numIPFilters ; i++) {
00263 if (ipFilters[i].mask == f.mask &&
00264 ipFilters[i].compare == f.compare) {
00265 ipFilters[i].compare = 0xffffffffu;
00266 G_Printf ("Removed.\n");
00267
00268 UpdateIPBans();
00269 return;
00270 }
00271 }
00272
00273 G_Printf ( "Didn't find %s.\n", str );
00274 }
|