#include "server.h"
#include "../game/botlib.h"
Include dependency graph for sv_bot.c:

Go to the source code of this file.
|
|
Referenced by BotDrawDebugPolygons(), BotImport_DebugPolygonCreate(), BotImport_DebugPolygonShow(), and SV_BotInitBotLib(). |
|
||||||||||||
|
Definition at line 423 of file sv_bot.c. References serverStatic_t::clients, qtrue, SV_ExecuteClientCommand(), and svs. 00423 {
00424 SV_ExecuteClientCommand( &svs.clients[client], command, qtrue );
00425 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 96 of file sv_bot.c. References bot_debugpoly_t, bot_enable, botlib_export, botlib_export_s::BotLibVarSet, usercmd_s::buttons, serverStatic_t::clients, bot_debugpoly_s::color, entityShared_t::currentAngles, entityShared_t::currentOrigin, Cvar_Get(), cvar_t, debugpolygons, client_s::gentity, i, cvar_s::integer, bot_debugpoly_s::inuse, client_s::lastUsercmd, NULL, bot_debugpoly_s::numPoints, bot_debugpoly_s::points, sharedEntity_t::r, cvar_s::string, svs, and botlib_export_s::Test. Referenced by CM_DrawDebugSurface(). 00096 {
00097 static cvar_t *bot_debug, *bot_groundonly, *bot_reachability, *bot_highlightarea;
00098 bot_debugpoly_t *poly;
00099 int i, parm0;
00100
00101 if (!debugpolygons)
00102 return;
00103 //bot debugging
00104 if (!bot_debug) bot_debug = Cvar_Get("bot_debug", "0", 0);
00105 //
00106 if (bot_enable && bot_debug->integer) {
00107 //show reachabilities
00108 if (!bot_reachability) bot_reachability = Cvar_Get("bot_reachability", "0", 0);
00109 //show ground faces only
00110 if (!bot_groundonly) bot_groundonly = Cvar_Get("bot_groundonly", "1", 0);
00111 //get the hightlight area
00112 if (!bot_highlightarea) bot_highlightarea = Cvar_Get("bot_highlightarea", "0", 0);
00113 //
00114 parm0 = 0;
00115 if (svs.clients[0].lastUsercmd.buttons & BUTTON_ATTACK) parm0 |= 1;
00116 if (bot_reachability->integer) parm0 |= 2;
00117 if (bot_groundonly->integer) parm0 |= 4;
00118 botlib_export->BotLibVarSet("bot_highlightarea", bot_highlightarea->string);
00119 botlib_export->Test(parm0, NULL, svs.clients[0].gentity->r.currentOrigin,
00120 svs.clients[0].gentity->r.currentAngles);
00121 } //end if
00122 //draw all debug polys
00123 for (i = 0; i < bot_maxdebugpolys; i++) {
00124 poly = &debugpolygons[i];
00125 if (!poly->inuse) continue;
00126 drawPoly(poly->color, poly->numPoints, (float *) poly->points);
00127 //Com_Printf("poly %i, numpoints = %d\n", i, poly->numPoints);
00128 }
00129 }
|
Here is the call graph for this function:

|
|
Definition at line 247 of file sv_bot.c. References CM_EntityString(). 00247 {
00248 return CM_EntityString();
00249 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||
|
Definition at line 256 of file sv_bot.c. References clipHandle_t, CM_InlineModel(), CM_ModelBounds(), h(), i, max, RadiusFromBounds(), vec3_t, VectorClear, and VectorCopy. 00256 {
00257 clipHandle_t h;
00258 vec3_t mins, maxs;
00259 float max;
00260 int i;
00261
00262 h = CM_InlineModel(modelnum);
00263 CM_ModelBounds(h, mins, maxs);
00264 //if the model is rotated
00265 if ((angles[0] || angles[1] || angles[2])) {
00266 // expand for rotation
00267
00268 max = RadiusFromBounds(mins, maxs);
00269 for (i = 0; i < 3; i++) {
00270 mins[i] = -max;
00271 maxs[i] = max;
00272 }
00273 }
00274 if (outmins) VectorCopy(mins, outmins);
00275 if (outmaxs) VectorCopy(maxs, outmaxs);
00276 if (origin) VectorClear(origin);
00277 }
|
Here is the call graph for this function:

|
|
Definition at line 371 of file sv_bot.c. References BotImport_DebugPolygonCreate(), points, and vec3_t. 00371 {
00372 vec3_t points[1];
00373 return BotImport_DebugPolygonCreate(0, 0, points);
00374 }
|
Here is the call graph for this function:

|
|
Definition at line 381 of file sv_bot.c. References BotImport_DebugPolygonDelete(), and line. 00381 {
00382 BotImport_DebugPolygonDelete(line);
00383 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 390 of file sv_bot.c. References BotImport_DebugPolygonShow(), CrossProduct(), DotProduct, line, points, up, vec3_t, VectorCopy, VectorMA, VectorNormalize(), VectorSet, and VectorSubtract. 00390 {
00391 vec3_t points[4], dir, cross, up = {0, 0, 1};
00392 float dot;
00393
00394 VectorCopy(start, points[0]);
00395 VectorCopy(start, points[1]);
00396 //points[1][2] -= 2;
00397 VectorCopy(end, points[2]);
00398 //points[2][2] -= 2;
00399 VectorCopy(end, points[3]);
00400
00401
00402 VectorSubtract(end, start, dir);
00403 VectorNormalize(dir);
00404 dot = DotProduct(dir, up);
00405 if (dot > 0.99 || dot < -0.99) VectorSet(cross, 1, 0, 0);
00406 else CrossProduct(dir, up, cross);
00407
00408 VectorNormalize(cross);
00409
00410 VectorMA(points[0], 2, cross, points[0]);
00411 VectorMA(points[1], -2, cross, points[1]);
00412 VectorMA(points[2], -2, cross, points[2]);
00413 VectorMA(points[3], 2, cross, points[3]);
00414
00415 BotImport_DebugPolygonShow(line, color, 4, points);
00416 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 317 of file sv_bot.c. References bot_debugpoly_t, bot_debugpoly_s::color, Com_Memcpy(), debugpolygons, i, bot_debugpoly_s::inuse, bot_debugpoly_s::numPoints, points, bot_debugpoly_s::points, and vec3_t. Referenced by BotImport_DebugLineCreate(), and SV_GameSystemCalls(). 00317 {
00318 bot_debugpoly_t *poly;
00319 int i;
00320
00321 if (!debugpolygons)
00322 return 0;
00323
00324 for (i = 1; i < bot_maxdebugpolys; i++) {
00325 if (!debugpolygons[i].inuse)
00326 break;
00327 }
00328 if (i >= bot_maxdebugpolys)
00329 return 0;
00330 poly = &debugpolygons[i];
00331 poly->inuse = qtrue;
00332 poly->color = color;
00333 poly->numPoints = numPoints;
00334 Com_Memcpy(poly->points, points, numPoints * sizeof(vec3_t));
00335 //
00336 return i;
00337 }
|
Here is the call graph for this function:

|
|
Definition at line 360 of file sv_bot.c. References debugpolygons, and bot_debugpoly_s::inuse. Referenced by BotImport_DebugLineDelete(), and SV_GameSystemCalls(). 00361 {
00362 if (!debugpolygons) return;
00363 debugpolygons[id].inuse = qfalse;
00364 }
|
|
||||||||||||||||||||
|
Definition at line 344 of file sv_bot.c. References bot_debugpoly_t, bot_debugpoly_s::color, Com_Memcpy(), debugpolygons, bot_debugpoly_s::inuse, bot_debugpoly_s::numPoints, points, bot_debugpoly_s::points, and vec3_t. Referenced by BotImport_DebugLineShow(). 00344 {
00345 bot_debugpoly_t *poly;
00346
00347 if (!debugpolygons) return;
00348 poly = &debugpolygons[id];
00349 poly->inuse = qtrue;
00350 poly->color = color;
00351 poly->numPoints = numPoints;
00352 Com_Memcpy(poly->points, points, numPoints * sizeof(vec3_t));
00353 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||||||
Here is the call graph for this function:

|
|
Definition at line 296 of file sv_bot.c. References ptr(), and Z_Free(). 00296 {
00297 Z_Free(ptr);
00298 }
|
Here is the call graph for this function:

|
|
Definition at line 284 of file sv_bot.c. References ptr(), TAG_BOTLIB, and Z_TagMalloc(). 00284 {
00285 void *ptr;
00286
00287 ptr = Z_TagMalloc( size, TAG_BOTLIB );
00288 return ptr;
00289 }
|
Here is the call graph for this function:

|
|
Definition at line 305 of file sv_bot.c. References Com_Error(), ERR_DROP, h_high, Hunk_Alloc(), and Hunk_CheckMark(). 00305 {
00306 if( Hunk_CheckMark() ) {
00307 Com_Error( ERR_DROP, "SV_Bot_HunkAlloc: Alloc with marks already set\n" );
00308 }
00309 return Hunk_Alloc( size, h_high );
00310 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 238 of file sv_bot.c. References p2, and SV_inPVS(). 00238 {
00239 return SV_inPVS (p1, p2);
00240 }
|
Here is the call graph for this function:

|
|
Definition at line 229 of file sv_bot.c. References point, and SV_PointContents(). 00229 {
00230 return SV_PointContents(point, -1);
00231 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 136 of file sv_bot.c. References Com_Error(), Com_Printf(), ERR_DROP, PRT_ERROR, PRT_EXIT, PRT_FATAL, PRT_MESSAGE, PRT_WARNING, QDECL, S_COLOR_RED, S_COLOR_YELLOW, va_end, va_list, va_start, and vsprintf(). 00137 {
00138 char str[2048];
00139 va_list ap;
00140
00141 va_start(ap, fmt);
00142 vsprintf(str, fmt, ap);
00143 va_end(ap);
00144
00145 switch(type) {
00146 case PRT_MESSAGE: {
00147 Com_Printf("%s", str);
00148 break;
00149 }
00150 case PRT_WARNING: {
00151 Com_Printf(S_COLOR_YELLOW "Warning: %s", str);
00152 break;
00153 }
00154 case PRT_ERROR: {
00155 Com_Printf(S_COLOR_RED "Error: %s", str);
00156 break;
00157 }
00158 case PRT_FATAL: {
00159 Com_Printf(S_COLOR_RED "Fatal: %s", str);
00160 break;
00161 }
00162 case PRT_EXIT: {
00163 Com_Error(ERR_DROP, S_COLOR_RED "Exit: %s", str);
00164 break;
00165 }
00166 default: {
00167 Com_Printf("unknown print type\n");
00168 break;
00169 }
00170 }
00171 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||||||
Here is the call graph for this function:

|
|
Definition at line 47 of file sv_bot.c. References cl, client_t, serverStatic_t::clients, i, cvar_s::integer, SV_GentityNum(), sv_maxclients, svs, and serverStatic_t::time. Referenced by SV_GameSystemCalls(). 00047 {
00048 int i;
00049 client_t *cl;
00050
00051 // find a client slot
00052 for ( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ ) {
00053 if ( cl->state == CS_FREE ) {
00054 break;
00055 }
00056 }
00057
00058 if ( i == sv_maxclients->integer ) {
00059 return -1;
00060 }
00061
00062 cl->gentity = SV_GentityNum( i );
00063 cl->gentity->s.number = i;
00064 cl->state = CS_ACTIVE;
00065 cl->lastPacketTime = svs.time;
00066 cl->netchan.remoteAddress.type = NA_BOT;
00067 cl->rate = 16384;
00068
00069 return i;
00070 }
|
Here is the call graph for this function:

|
|
Definition at line 432 of file sv_bot.c. References BOTAI_START_FRAME, gvm, time(), and VM_Call(). Referenced by SV_Frame(), and SV_SpawnServer(). 00432 {
00433 if (!bot_enable) return;
00434 //NOTE: maybe the game is already shutdown
00435 if (!gvm) return;
00436 VM_Call( gvm, BOTAI_START_FRAME, time );
00437 }
|
Here is the call graph for this function:

|
|
Definition at line 77 of file sv_bot.c. References cl, client_t, serverStatic_t::clients, Com_Error(), ERR_DROP, cvar_s::integer, sv_maxclients, and svs. Referenced by SV_DropClient(), and SV_GameSystemCalls(). 00077 {
00078 client_t *cl;
00079
00080 if ( clientNum < 0 || clientNum >= sv_maxclients->integer ) {
00081 Com_Error( ERR_DROP, "SV_BotFreeClient: bad clientNum: %i", clientNum );
00082 }
00083 cl = &svs.clients[clientNum];
00084 cl->state = CS_FREE;
00085 cl->name[0] = 0;
00086 if ( cl->gentity ) {
00087 cl->gentity->r.svFlags &= ~SVF_BOT;
00088 }
00089 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 574 of file sv_bot.c. References cl, client_t, serverStatic_t::clients, MAX_RELIABLE_COMMANDS, Q_strncpyz(), svs, and serverStatic_t::time. Referenced by SV_GameSystemCalls(). 00575 {
00576 client_t *cl;
00577 int index;
00578
00579 cl = &svs.clients[client];
00580 cl->lastPacketTime = svs.time;
00581
00582 if ( cl->reliableAcknowledge == cl->reliableSequence ) {
00583 return qfalse;
00584 }
00585
00586 cl->reliableAcknowledge++;
00587 index = cl->reliableAcknowledge & ( MAX_RELIABLE_COMMANDS - 1 );
00588
00589 if ( !cl->reliableCommands[index][0] ) {
00590 return qfalse;
00591 }
00592
00593 Q_strncpyz( buf, cl->reliableCommands[index], size );
00594 return qtrue;
00595 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 624 of file sv_bot.c. References cl, client_t, serverStatic_t::clients, clientSnapshot_t::first_entity, clientSnapshot_t::num_entities, entityState_s::number, serverStatic_t::numSnapshotEntities, serverStatic_t::snapshotEntities, and svs. Referenced by SV_GameSystemCalls(). 00624 {
00625 client_t *cl;
00626 clientSnapshot_t *frame;
00627
00628 cl = &svs.clients[client];
00629 frame = &cl->frames[cl->netchan.outgoingSequence & PACKET_MASK];
00630 if (sequence < 0 || sequence >= frame->num_entities) {
00631 return -1;
00632 }
00633 return svs.snapshotEntities[(frame->first_entity + sequence) % svs.numSnapshotEntities].number;
00634 }
|
|
|
Definition at line 518 of file sv_bot.c. References assert, botlib_import_s::AvailableMemory, bot_debugpoly_t, bot_maxdebugpolys, botlib_import_s::BotClientCommand, BOTLIB_API_VERSION, botlib_export, botlib_export_t, botlib_import_t, botlib_import_s::BSPEntityData, botlib_import_s::BSPModelMinsMaxsOrigin, Com_Error(), Cvar_VariableIntegerValue(), Cvar_VariableValue(), botlib_import_s::DebugLineCreate, botlib_import_s::DebugLineDelete, botlib_import_s::DebugLineShow, botlib_import_s::DebugPolygonCreate, botlib_import_s::DebugPolygonDelete, debugpolygons, botlib_import_s::EntityTrace, ERR_NEED_CD, botlib_import_s::FreeMemory, botlib_import_s::FS_FCloseFile, botlib_import_s::FS_FOpenFile, botlib_import_s::FS_Read, botlib_import_s::FS_Seek, botlib_import_s::FS_Write, GetBotLibAPI(), botlib_import_s::GetMemory, botlib_import_s::HunkAlloc, botlib_import_s::inPVS, botlib_import_s::PointContents, Sys_CheckCD(), botlib_import_s::Trace, Z_Free(), and Z_Malloc(). Referenced by SV_Init(). 00518 {
00519 botlib_import_t botlib_import;
00520
00521 if ( !Cvar_VariableValue("fs_restrict") && !Sys_CheckCD() ) {
00522 Com_Error( ERR_NEED_CD, "Game CD not in drive" );
00523 }
00524
00525 if (debugpolygons) Z_Free(debugpolygons);
00526 bot_maxdebugpolys = Cvar_VariableIntegerValue("bot_maxdebugpolys");
00527 debugpolygons = Z_Malloc(sizeof(bot_debugpoly_t) * bot_maxdebugpolys);
00528
00529 botlib_import.Print = BotImport_Print;
00530 botlib_import.Trace = BotImport_Trace;
00531 botlib_import.EntityTrace = BotImport_EntityTrace;
00532 botlib_import.PointContents = BotImport_PointContents;
00533 botlib_import.inPVS = BotImport_inPVS;
00534 botlib_import.BSPEntityData = BotImport_BSPEntityData;
00535 botlib_import.BSPModelMinsMaxsOrigin = BotImport_BSPModelMinsMaxsOrigin;
00536 botlib_import.BotClientCommand = BotClientCommand;
00537
00538 //memory management
00539 botlib_import.GetMemory = BotImport_GetMemory;
00540 botlib_import.FreeMemory = BotImport_FreeMemory;
00541 botlib_import.AvailableMemory = Z_AvailableMemory;
00542 botlib_import.HunkAlloc = BotImport_HunkAlloc;
00543
00544 // file system access
00545 botlib_import.FS_FOpenFile = FS_FOpenFileByMode;
00546 botlib_import.FS_Read = FS_Read2;
00547 botlib_import.FS_Write = FS_Write;
00548 botlib_import.FS_FCloseFile = FS_FCloseFile;
00549 botlib_import.FS_Seek = FS_Seek;
00550
00551 //debug lines
00552 botlib_import.DebugLineCreate = BotImport_DebugLineCreate;
00553 botlib_import.DebugLineDelete = BotImport_DebugLineDelete;
00554 botlib_import.DebugLineShow = BotImport_DebugLineShow;
00555
00556 //debug polygons
00557 botlib_import.DebugPolygonCreate = BotImport_DebugPolygonCreate;
00558 botlib_import.DebugPolygonDelete = BotImport_DebugPolygonDelete;
00559
00560 botlib_export = (botlib_export_t *)GetBotLibAPI( BOTLIB_API_VERSION, &botlib_import );
00561 assert(botlib_export); // bk001129 - somehow we end up with a zero import.
00562 }
|
Here is the call graph for this function:

|
|
Definition at line 479 of file sv_bot.c. References CVAR_CHEAT, and Cvar_Get(). Referenced by SV_Init(). 00479 {
00480
00481 Cvar_Get("bot_enable", "1", 0); //enable the bot
00482 Cvar_Get("bot_developer", "0", CVAR_CHEAT); //bot developer mode
00483 Cvar_Get("bot_debug", "0", CVAR_CHEAT); //enable bot debugging
00484 Cvar_Get("bot_maxdebugpolys", "2", 0); //maximum number of debug polys
00485 Cvar_Get("bot_groundonly", "1", 0); //only show ground faces of areas
00486 Cvar_Get("bot_reachability", "0", 0); //show all reachabilities to other areas
00487 Cvar_Get("bot_visualizejumppads", "0", CVAR_CHEAT); //show jumppads
00488 Cvar_Get("bot_forceclustering", "0", 0); //force cluster calculations
00489 Cvar_Get("bot_forcereachability", "0", 0); //force reachability calculations
00490 Cvar_Get("bot_forcewrite", "0", 0); //force writing aas file
00491 Cvar_Get("bot_aasoptimize", "0", 0); //no aas file optimisation
00492 Cvar_Get("bot_saveroutingcache", "0", 0); //save routing cache
00493 Cvar_Get("bot_thinktime", "100", CVAR_CHEAT); //msec the bots thinks
00494 Cvar_Get("bot_reloadcharacters", "0", 0); //reload the bot characters each time
00495 Cvar_Get("bot_testichat", "0", 0); //test ichats
00496 Cvar_Get("bot_testrchat", "0", 0); //test rchats
00497 Cvar_Get("bot_testsolid", "0", CVAR_CHEAT); //test for solid areas
00498 Cvar_Get("bot_testclusters", "0", CVAR_CHEAT); //test the AAS clusters
00499 Cvar_Get("bot_fastchat", "0", 0); //fast chatting bots
00500 Cvar_Get("bot_nochat", "0", 0); //disable chats
00501 Cvar_Get("bot_pause", "0", CVAR_CHEAT); //pause the bots thinking
00502 Cvar_Get("bot_report", "0", CVAR_CHEAT); //get a full report in ctf
00503 Cvar_Get("bot_grapple", "0", 0); //enable grapple
00504 Cvar_Get("bot_rocketjump", "1", 0); //enable rocket jumping
00505 Cvar_Get("bot_challenge", "0", 0); //challenging bot
00506 Cvar_Get("bot_minplayers", "0", 0); //minimum players in a team or the game
00507 Cvar_Get("bot_interbreedchar", "", CVAR_CHEAT); //bot character used for inte |