/* ============== BotAIShutdownClient ============== */ int BotAIShutdownClient( int client ) { bot_state_t *bs; // Wolfenstein if ( g_entities[client].r.svFlags & SVF_CASTAI ) { AICast_ShutdownClient( client ); return BLERR_NOERROR; } // done. bs = botstates[client]; if ( !bs || !bs->inuse ) { // BotAI_Print(PRT_ERROR, "client %d already shutdown\n", client); return BLERR_AICLIENTALREADYSHUTDOWN; } if ( BotChat_ExitGame( bs ) ) { trap_BotEnterChat( bs->cs, bs->client, CHAT_ALL ); } trap_BotFreeMoveState( bs->ms ); //free the goal state trap_BotFreeGoalState( bs->gs ); //free the chat file trap_BotFreeChatState( bs->cs ); //free the weapon weights trap_BotFreeWeaponState( bs->ws ); //free the bot character trap_BotFreeCharacter( bs->character ); // BotFreeWaypoints( bs->checkpoints ); BotFreeWaypoints( bs->patrolpoints ); //clear the bot state memset( bs, 0, sizeof( bot_state_t ) ); //set the inuse flag to qfalse bs->inuse = qfalse; //there's one bot less numbots--; //everything went ok return BLERR_NOERROR; }
/* ============== BotAIShutdownClient ============== */ int BotAIShutdownClient(int client, qboolean restart) { bot_state_t *bs; bs = botstates[client]; if (!bs || !bs->inuse) { //BotAI_Print(PRT_ERROR, "BotAIShutdownClient: client %d already shutdown\n", client); return qfalse; } if (restart) { BotWriteSessionData(bs); } if (BotChat_ExitGame(bs)) { trap_BotEnterChat(bs->cs, bs->client, CHAT_ALL); } trap_BotFreeMoveState(bs->ms); //free the goal state trap_BotFreeGoalState(bs->gs); //free the chat file trap_BotFreeChatState(bs->cs); //free the weapon weights trap_BotFreeWeaponState(bs->ws); //free the bot character trap_BotFreeCharacter(bs->character); // BotFreeWaypoints(bs->checkpoints); BotFreeWaypoints(bs->patrolpoints); //clear activate goal stack BotClearActivateGoalStack(bs); //clear the bot state memset(bs, 0, sizeof(bot_state_t)); //set the inuse flag to qfalse bs->inuse = qfalse; //there's one bot less numbots--; //everything went ok return qtrue; }