/* ============== G_Script_ParseSpawnbot Parses "Spawnbot" command, precaching a custom character if specified ============== */ void G_Script_ParseSpawnbot(char **ppScript, char params[], int paramsize) { qboolean parsingCharacter = qfalse; char *token; token = COM_ParseExt(ppScript, qfalse); while (token[0]) { // if we are currently parsing a spawnbot command, check the parms for // a custom character, which we will need to precache on the client // did we just see a '/character' parm? if (parsingCharacter) { parsingCharacter = qfalse; G_CharacterIndex(token); if (!BG_FindCharacter(token)) { bg_character_t *character = BG_FindFreeCharacter(token); Q_strncpyz(character->characterFile, token, sizeof(character->characterFile)); if (!G_RegisterCharacter(token, character)) { G_Error("ERROR: G_Script_ParseSpawnbot: failed to load character file '%s'\n", token); } } #ifdef DEBUG G_DPrintf("precached character %s\n", token); #endif } else if (!Q_stricmp(token, "/character")) { parsingCharacter = qtrue; } if (strlen(params)) // add a space between each param { Q_strcat(params, paramsize, " "); } if (strrchr(token, ' ')) // need to wrap this param in quotes since it has more than one word { Q_strcat(params, paramsize, "\""); } Q_strcat(params, paramsize, token); if (strrchr(token, ' ')) // need to wrap this param in quotes since it has more than one word { Q_strcat(params, paramsize, "\""); } token = COM_ParseExt(ppScript, qfalse); } }
void G_BotParseCharacterParms( char *characterFile, int *characterInt ) { if( strlen( characterFile ) ) { int characterIndex = G_CharacterIndex( characterFile ); if( characterIndex ) *characterInt = characterIndex; else *characterInt = -1; } else { *characterInt = -1; } }