static qboolean CG_ParseHudComponent(int handle, hudComponent_t *comp) { CG_RectParse(handle, &comp->location); //PC_Rect_Parse PC_Int_Parse(handle, &comp->style); PC_Int_Parse(handle, &comp->visible); return qtrue; }
void CG_BuildableStatusParse( const char *filename, buildStat_t *bs ) { pc_token_t token; int handle; const char *s; int i; float f; vec4_t c; handle = trap_Parse_LoadSource( filename ); if( !handle ) return; while( 1 ) { if( !trap_Parse_ReadToken( handle, &token ) ) break; if( !Q_stricmp( token.string, "frameShader" ) ) { if( PC_String_Parse( handle, &s ) ) bs->frameShader = trap_R_RegisterShader( s ); continue; } else if( !Q_stricmp( token.string, "overlayShader" ) ) { if( PC_String_Parse( handle, &s ) ) bs->overlayShader = trap_R_RegisterShader( s ); continue; } else if( !Q_stricmp( token.string, "noPowerShader" ) ) { if( PC_String_Parse( handle, &s ) ) bs->noPowerShader = trap_R_RegisterShader( s ); continue; } else if( !Q_stricmp( token.string, "markedShader" ) ) { if( PC_String_Parse( handle, &s ) ) bs->markedShader = trap_R_RegisterShader( s ); continue; } else if( !Q_stricmp( token.string, "healthSevereColor" ) ) { if( PC_Color_Parse( handle, &c ) ) Vector4Copy( c, bs->healthSevereColor ); continue; } else if( !Q_stricmp( token.string, "healthHighColor" ) ) { if( PC_Color_Parse( handle, &c ) ) Vector4Copy( c, bs->healthHighColor ); continue; } else if( !Q_stricmp( token.string, "healthElevatedColor" ) ) { if( PC_Color_Parse( handle, &c ) ) Vector4Copy( c, bs->healthElevatedColor ); continue; } else if( !Q_stricmp( token.string, "healthGuardedColor" ) ) { if( PC_Color_Parse( handle, &c ) ) Vector4Copy( c, bs->healthGuardedColor ); continue; } else if( !Q_stricmp( token.string, "healthLowColor" ) ) { if( PC_Color_Parse( handle, &c ) ) Vector4Copy( c, bs->healthLowColor ); continue; } else if( !Q_stricmp( token.string, "foreColor" ) ) { if( PC_Color_Parse( handle, &c ) ) Vector4Copy( c, bs->foreColor ); continue; } else if( !Q_stricmp( token.string, "backColor" ) ) { if( PC_Color_Parse( handle, &c ) ) Vector4Copy( c, bs->backColor ); continue; } else if( !Q_stricmp( token.string, "frameHeight" ) ) { if( PC_Int_Parse( handle, &i ) ) bs->frameHeight = i; continue; } else if( !Q_stricmp( token.string, "frameWidth" ) ) { if( PC_Int_Parse( handle, &i ) ) bs->frameWidth = i; continue; } else if( !Q_stricmp( token.string, "healthPadding" ) ) { if( PC_Int_Parse( handle, &i ) ) bs->healthPadding = i; continue; } else if( !Q_stricmp( token.string, "overlayHeight" ) ) { if( PC_Int_Parse( handle, &i ) ) bs->overlayHeight = i; continue; } else if( !Q_stricmp( token.string, "overlayWidth" ) ) { if( PC_Int_Parse( handle, &i ) ) bs->overlayWidth = i; continue; } else if( !Q_stricmp( token.string, "verticalMargin" ) ) { if( PC_Float_Parse( handle, &f ) ) bs->verticalMargin = f; continue; } else if( !Q_stricmp( token.string, "horizontalMargin" ) ) { if( PC_Float_Parse( handle, &f ) ) bs->horizontalMargin = f; continue; } else { Com_Printf("CG_BuildableStatusParse: unknown token %s in %s\n", token.string, filename ); bs->loaded = qfalse; return; } } bs->loaded = qtrue; }
/* =============== UI_LoadArenasFromFile =============== */ static void UI_LoadArenasFromFile( char *filename ) { /* int len; fileHandle_t f; char buf[MAX_ARENAS_TEXT]; len = trap_FS_FOpenFile( filename, &f, FS_READ ); if ( !f ) { trap_Print( va( S_COLOR_RED "file not found: %s\n", filename ) ); return; } if ( len >= MAX_ARENAS_TEXT ) { trap_Print( va( S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, MAX_ARENAS_TEXT ) ); trap_FS_FCloseFile( f ); return; } trap_FS_Read( buf, len, f ); buf[len] = 0; trap_FS_FCloseFile( f ); ui_numArenas += UI_ParseInfos( buf, MAX_ARENAS - ui_numArenas, &ui_arenaInfos[ui_numArenas], MAX_ARENAS );*/ int handle; pc_token_t token; handle = trap_PC_LoadSource( filename ); if( !handle ) { trap_Print( va( S_COLOR_RED "file not found: %s\n", filename ) ); return; } if( !trap_PC_ReadToken( handle, &token ) ) { trap_PC_FreeSource( handle ); return; } if( *token.string != '{' ) { trap_PC_FreeSource( handle ); return; } uiInfo.mapList[uiInfo.mapCount].cinematic = -1; uiInfo.mapList[uiInfo.mapCount].levelShot = -1; uiInfo.mapList[uiInfo.mapCount].typeBits = 0; while( trap_PC_ReadToken( handle, &token ) ) { if( *token.string == '}' ) { if( !uiInfo.mapList[uiInfo.mapCount].typeBits ) { uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF); } uiInfo.mapCount++; if( uiInfo.mapCount >= MAX_MAPS ) { break; } if( !trap_PC_ReadToken( handle, &token ) ) { // eof trap_PC_FreeSource( handle ); return; } if( *token.string != '{' ) { trap_Print( va( S_COLOR_RED "unexpected token '%s' inside: %s\n", token.string, filename ) ); trap_PC_FreeSource( handle ); return; } } else if( !Q_stricmp( token.string, "map" ) ) { if( !PC_String_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].mapLoadName ) ) { trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) ); trap_PC_FreeSource( handle ); return; } } else if( !Q_stricmp( token.string, "longname" ) ) { if( !PC_String_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].mapName ) ) { trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) ); trap_PC_FreeSource( handle ); return; } } else if( !Q_stricmp( token.string, "briefing" ) ) { if( !PC_String_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].briefing ) ) { trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) ); trap_PC_FreeSource( handle ); return; } } else if( !Q_stricmp( token.string, "lmsbriefing" ) ) { if( !PC_String_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].lmsbriefing ) ) { trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) ); trap_PC_FreeSource( handle ); return; } /*} else if( !Q_stricmp( token.string, "objectives" ) ) { if( !PC_String_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].objectives ) ) { trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) ); trap_PC_FreeSource( handle ); return; }*/ } else if( !Q_stricmp( token.string, "timelimit" ) ) { if( !PC_Int_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].Timelimit ) ) { trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) ); trap_PC_FreeSource( handle ); return; } } else if( !Q_stricmp( token.string, "axisrespawntime" ) ) { if( !PC_Int_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].AxisRespawnTime ) ) { trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) ); trap_PC_FreeSource( handle ); return; } } else if( !Q_stricmp( token.string, "alliedrespawntime" ) ) { if( !PC_Int_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].AlliedRespawnTime ) ) { trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) ); trap_PC_FreeSource( handle ); return; } } else if( !Q_stricmp( token.string, "type" ) ) { if( !trap_PC_ReadToken( handle, &token ) ) { trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) ); trap_PC_FreeSource( handle ); return; } else { if( strstr( token.string, "wolfsp" ) ) { uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_SINGLE_PLAYER); } if( strstr( token.string, "wolflms" ) ) { uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF_LMS); } if( strstr( token.string, "wolfmp" ) ) { uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF); } if( strstr( token.string, "wolfsw" ) ) { uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF_STOPWATCH); } } } else if( !Q_stricmp( token.string, "mapposition_x" ) ) { if( !PC_Float_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].mappos[0] ) ) { trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) ); trap_PC_FreeSource( handle ); return; } } else if( !Q_stricmp( token.string, "mapposition_y" ) ) { if( !PC_Float_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].mappos[1] ) ) { trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) ); trap_PC_FreeSource( handle ); return; } } } trap_PC_FreeSource( handle ); return; }/* ============= UI_SortArenas CHRUKER: b090 - Sorting the map list ============= */
qboolean CG_FindArenaInfo(char *filename, char *mapname, arenaInfo_t *info) { int handle; pc_token_t token; const char *dummy; qboolean found = qfalse; handle = trap_PC_LoadSource(filename); if (!handle) { trap_Print(va(S_COLOR_RED "file not found: %s\n", filename)); return qfalse; } if (!trap_PC_ReadToken(handle, &token)) { trap_PC_FreeSource(handle); return qfalse; } if (*token.string != '{') { trap_PC_FreeSource(handle); return qfalse; } while (trap_PC_ReadToken(handle, &token)) { if (*token.string == '}') { if (found) { // info->image = trap_R_RegisterShaderNoMip(va("levelshots/%s", mapname)); trap_PC_FreeSource(handle); return qtrue; } found = qfalse; if (!trap_PC_ReadToken(handle, &token)) { // eof trap_PC_FreeSource(handle); return qfalse; } if (*token.string != '{') { trap_Print(va(S_COLOR_RED "unexpected token '%s' inside: %s\n", token.string, filename)); trap_PC_FreeSource(handle); return qfalse; } } else if (!Q_stricmp(token.string, "objectives") || !Q_stricmp(token.string, "description") || !Q_stricmp(token.string, "type")) { if (!PC_String_Parse(handle, &dummy)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return qfalse; } } else if (!Q_stricmp(token.string, "longname")) { if (!PC_String_Parse(handle, &dummy)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return qfalse; } else { //char* p = info->longname; Q_strncpyz(info->longname, dummy, 128); // Gordon: removing cuz, er, no-one knows why it's here!... /* while(*p) { *p = toupper(*p); p++; }*/ } } else if (!Q_stricmp(token.string, "map")) { if (!PC_String_Parse(handle, &dummy)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return qfalse; } else { if (!Q_stricmp(dummy, mapname)) { found = qtrue; } } } else if (!Q_stricmp(token.string, "Timelimit") || !Q_stricmp(token.string, "AxisRespawnTime") || !Q_stricmp(token.string, "AlliedRespawnTime")) { if (!PC_Int_Parse(handle, (int *)&dummy)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return qfalse; } } else if (!Q_stricmp(token.string, "lmsbriefing")) { if (!PC_String_Parse(handle, &dummy)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return qfalse; } else { Q_strncpyz(info->lmsdescription, dummy, sizeof(info->lmsdescription)); } } else if (!Q_stricmp(token.string, "briefing")) { if (!PC_String_Parse(handle, &dummy)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return qfalse; } else { Q_strncpyz(info->description, dummy, sizeof(info->description)); } } else if (!Q_stricmp(token.string, "alliedwintext")) { if (!PC_String_Parse(handle, &dummy)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return qfalse; } else { Q_strncpyz(info->alliedwintext, dummy, sizeof(info->description)); } } else if (!Q_stricmp(token.string, "axiswintext")) { if (!PC_String_Parse(handle, &dummy)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return qfalse; } else { Q_strncpyz(info->axiswintext, dummy, sizeof(info->description)); } } else if (!Q_stricmp(token.string, "mapposition_x")) { vec_t x; if (!trap_PC_ReadToken(handle, &token)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return qfalse; } x = token.floatvalue; info->mappos[0] = x; } else if (!Q_stricmp(token.string, "mapposition_y")) { vec_t y; if (!trap_PC_ReadToken(handle, &token)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return qfalse; } y = token.floatvalue; info->mappos[1] = y; } } trap_PC_FreeSource(handle); return qfalse; }
static qboolean BG_SS_ParseSpeaker(int handle) { pc_token_t token; bg_speaker_t speaker; memset(&speaker, 0, sizeof(speaker)); speaker.volume = 127; speaker.range = 1250; if (!trap_PC_ReadToken(handle, &token) || Q_stricmp(token.string, "{")) { return BG_SS_ParseError(handle, "expected '{'"); } while (1) { if (!trap_PC_ReadToken(handle, &token)) { break; } if (token.string[0] == '}') { break; } if (!Q_stricmp(token.string, "noise")) { if (!PC_String_ParseNoAlloc(handle, speaker.filename, sizeof(speaker.filename))) { return BG_SS_ParseError(handle, "expected sound filename"); } } else if (!Q_stricmp(token.string, "origin")) { if (!PC_Vec_Parse(handle, &speaker.origin)) { return BG_SS_ParseError(handle, "expected origin vector"); } } else if (!Q_stricmp(token.string, "targetname")) { if (!PC_String_ParseNoAlloc(handle, speaker.targetname, sizeof(speaker.targetname))) { return BG_SS_ParseError(handle, "expected targetname string"); } else { speaker.targetnamehash = BG_StringHashValue(speaker.targetname); } } else if (!Q_stricmp(token.string, "looped")) { if (!trap_PC_ReadToken(handle, &token)) { return BG_SS_ParseError(handle, "expected loop value"); } else { if (!Q_stricmp(token.string, "no")) { speaker.loop = S_LT_NOT_LOOPED; } else if (!Q_stricmp(token.string, "on")) { speaker.loop = S_LT_LOOPED_ON; speaker.activated = qtrue; } else if (!Q_stricmp(token.string, "off")) { speaker.loop = S_LT_LOOPED_OFF; } else { return BG_SS_ParseError(handle, "unknown loop value '%s'", token.string); } } } else if (!Q_stricmp(token.string, "broadcast")) { if (!trap_PC_ReadToken(handle, &token)) { return BG_SS_ParseError(handle, "expected broadcast value"); } else { if (!Q_stricmp(token.string, "no")) { speaker.broadcast = S_BT_LOCAL; } else if (!Q_stricmp(token.string, "global")) { speaker.broadcast = S_BT_GLOBAL; } else if (!Q_stricmp(token.string, "nopvs")) { speaker.broadcast = S_BT_NOPVS; } else { return BG_SS_ParseError(handle, "unknown broadcast value '%s'", token.string); } } } else if (!Q_stricmp(token.string, "wait")) { if (!PC_Int_Parse(handle, &speaker.wait)) { return BG_SS_ParseError(handle, "expected wait value"); } else if (speaker.wait < 0) { return BG_SS_ParseError(handle, "wait value %i is invalid", speaker.wait); } } else if (!Q_stricmp(token.string, "random")) { if (!PC_Int_Parse(handle, &speaker.random)) { return BG_SS_ParseError(handle, "expected random value"); } else if (speaker.random < 0) { return BG_SS_ParseError(handle, "random value %i is invalid", speaker.random); } } else if (!Q_stricmp(token.string, "volume")) { if (!PC_Int_Parse(handle, &speaker.volume)) { return BG_SS_ParseError(handle, "expected volume value"); } else if (speaker.volume < 0 || speaker.volume > 65535) { return BG_SS_ParseError(handle, "volume value %i is invalid", speaker.volume); } } else if (!Q_stricmp(token.string, "range")) { if (!PC_Int_Parse(handle, &speaker.range)) { return BG_SS_ParseError(handle, "expected range value"); } else if (speaker.range < 0) { return BG_SS_ParseError(handle, "range value %i is invalid", speaker.range); } } else { return BG_SS_ParseError(handle, "unknown token '%s'", token.string); } } if (!BG_SS_StoreSpeaker(&speaker)) { return BG_SS_ParseError(handle, "Failed to store speaker", token.string); } return qtrue; }
static animation_t * BG_RAG_FindFreeAnimation(const char *mdxFileName, const char *name) #endif // CGAMEDLL { int i; for (i = 0; i < MAX_ANIMPOOL_SIZE; i++) { #ifdef CGAMEDLL if (animationPool[i].mdxFile == mdxFile && !Q_stricmp(animationPool[i].name, name)) { #else if (*animationPool[i].mdxFileName && !Q_stricmp(animationPool[i].mdxFileName, mdxFileName) && !Q_stricmp(animationPool[i].name, name)) { #endif // CGAMEDLL return(&animationPool[i]); } } for (i = 0; i < MAX_ANIMPOOL_SIZE; i++) { #ifdef CGAMEDLL if (!animationPool[i].mdxFile) { animationPool[i].mdxFile = mdxFile; #else if (!animationPool[i].mdxFileName[0]) { Q_strncpyz(animationPool[i].mdxFileName, mdxFileName, sizeof(animationPool[i].mdxFileName)); #endif // CGAMEDLL Q_strncpyz(animationPool[i].name, name, sizeof(animationPool[i].name)); return(&animationPool[i]); } } return NULL; } static qboolean BG_RAG_ParseError(int handle, char *format, ...) { int line; char filename[128]; va_list argptr; static char string[4096]; va_start(argptr, format); Q_vsnprintf(string, sizeof(string), format, argptr); va_end(argptr); filename[0] = '\0'; line = 0; trap_PC_SourceFileAndLine(handle, filename, &line); Com_Printf(S_COLOR_RED "ERROR: %s, line %d: %s\n", filename, line, string); trap_PC_FreeSource(handle); return qfalse; } static qboolean BG_RAG_ParseAnimation(int handle, animation_t *animation) { int i; animation->flags = 0; if (!PC_Int_Parse(handle, &animation->firstFrame)) { return BG_RAG_ParseError(handle, "expected first frame integer"); } if (!PC_Int_Parse(handle, &animation->numFrames)) { return BG_RAG_ParseError(handle, "expected length integer"); } if (!PC_Int_Parse(handle, &animation->loopFrames)) { return BG_RAG_ParseError(handle, "expected looping integer"); } if (!PC_Int_Parse(handle, &i)) { return BG_RAG_ParseError(handle, "expected fps integer"); } if (i == 0) { i = 1; } animation->frameLerp = 1000 / (float)i; animation->initialLerp = 1000 / (float)i; if (!PC_Int_Parse(handle, &animation->moveSpeed)) { return BG_RAG_ParseError(handle, "expected move speed integer"); } if (!PC_Int_Parse(handle, &animation->animBlend)) { return BG_RAG_ParseError(handle, "expected transition integer"); } if (!PC_Int_Parse(handle, &i)) { return BG_RAG_ParseError(handle, "expected reversed integer"); } if (i == 1) { animation->flags |= ANIMFL_REVERSED; } // calculate the duration animation->duration = animation->initialLerp + animation->frameLerp * animation->numFrames + animation->animBlend; // get the nameHash animation->nameHash = BG_StringHashValue(animation->name); // hacky-ish stuff if (!Q_strncmp(animation->name, "climb", 5)) { animation->flags |= ANIMFL_LADDERANIM; } if (strstr(animation->name, "firing")) { animation->flags |= ANIMFL_FIRINGANIM; animation->initialLerp = 40; } return qtrue; }
static qboolean BG_RAG_ParseAnimation(int handle, animation_t *animation) { int i; animation->flags = 0; if (!PC_Int_Parse(handle, &animation->firstFrame)) { return BG_RAG_ParseError(handle, "expected first frame integer"); } if (!PC_Int_Parse(handle, &animation->numFrames)) { return BG_RAG_ParseError(handle, "expected length integer"); } if (!PC_Int_Parse(handle, &animation->loopFrames)) { return BG_RAG_ParseError(handle, "expected looping integer"); } if (!PC_Int_Parse(handle, &i)) { return BG_RAG_ParseError(handle, "expected fps integer"); } if (i == 0) { i = 1; } animation->frameLerp = 1000 / (float)i; animation->initialLerp = 1000 / (float)i; if (!PC_Int_Parse(handle, &animation->moveSpeed)) { return BG_RAG_ParseError(handle, "expected move speed integer"); } if (!PC_Int_Parse(handle, &animation->animBlend)) { return BG_RAG_ParseError(handle, "expected transition integer"); } if (!PC_Int_Parse(handle, &i)) { return BG_RAG_ParseError(handle, "expected reversed integer"); } if (i == 1) { animation->flags |= ANIMFL_REVERSED; } // calculate the duration animation->duration = animation->initialLerp + animation->frameLerp * animation->numFrames + animation->animBlend; // get the nameHash animation->nameHash = BG_StringHashValue(animation->name); // hacky-ish stuff if (!Q_strncmp(animation->name, "climb", 5)) { animation->flags |= ANIMFL_LADDERANIM; } if (strstr(animation->name, "firing")) { animation->flags |= ANIMFL_FIRINGANIM; animation->initialLerp = 40; } return qtrue; }
static qboolean CG_ParseHUD(int handle) { pc_token_t token; hudStucture_t temphud; CG_setDefaultHudValues(&temphud); if (!trap_PC_ReadToken(handle, &token) || Q_stricmp(token.string, "{")) { return CG_HUD_ParseError(handle, "expected '{'"); } while (1) { if (!trap_PC_ReadToken(handle, &token)) { break; } if (token.string[0] == '}') { break; } if (!Q_stricmp(token.string, "hudnumber")) { if (!PC_Int_Parse(handle, &temphud.hudnumber)) { return CG_HUD_ParseError(handle, "expected hud number"); } continue; } if (!Q_stricmp(token.string, "compas")) { if (!CG_ParseHudComponent(handle, &temphud.compas)) { return CG_HUD_ParseError(handle, "expected compas"); } continue; } if (!Q_stricmp(token.string, "staminabar")) { if (!CG_ParseHudComponent(handle, &temphud.staminabar)) { return CG_HUD_ParseError(handle, "expected staminabar"); } continue; } if (!Q_stricmp(token.string, "healthbar")) { if (!CG_ParseHudComponent(handle, &temphud.healthbar)) { return CG_HUD_ParseError(handle, "expected healthbar"); } continue; } if (!Q_stricmp(token.string, "weaponchangebar")) { if (!CG_ParseHudComponent(handle, &temphud.weaponchargebar)) { return CG_HUD_ParseError(handle, "expected weaponchangebar"); } continue; } if (!Q_stricmp(token.string, "healthtext")) { if (!CG_ParseHudComponent(handle, &temphud.healthtext)) { return CG_HUD_ParseError(handle, "expected healthtext"); } continue; } if (!Q_stricmp(token.string, "xptext")) { if (!CG_ParseHudComponent(handle, &temphud.xptext)) { return CG_HUD_ParseError(handle, "expected xptext"); } continue; } if (!Q_stricmp(token.string, "statsdisplay")) { if (!CG_ParseHudComponent(handle, &temphud.statsdisplay)) { return CG_HUD_ParseError(handle, "expected statsdisplay"); } continue; } if (!Q_stricmp(token.string, "weaponicon")) { if (!CG_ParseHudComponent(handle, &temphud.weaponicon)) { return CG_HUD_ParseError(handle, "expected weaponicon"); } continue; } if (!Q_stricmp(token.string, "weaponammo")) { if (!CG_ParseHudComponent(handle, &temphud.weaponammo)) { return CG_HUD_ParseError(handle, "expected weaponammo"); } continue; } if (!Q_stricmp(token.string, "fireteam")) { if (!CG_ParseHudComponent(handle, &temphud.fireteam)) { return CG_HUD_ParseError(handle, "expected fireteam"); } continue; } if (!Q_stricmp(token.string, "popupmessages")) { if (!CG_ParseHudComponent(handle, &temphud.popupmessages)) { return CG_HUD_ParseError(handle, "expected popupmessages"); } continue; } if (!Q_stricmp(token.string, "powerups")) { if (!CG_ParseHudComponent(handle, &temphud.powerups)) { return CG_HUD_ParseError(handle, "expected powerups"); } continue; } if (!Q_stricmp(token.string, "hudhead")) { if (!CG_ParseHudComponent(handle, &temphud.hudhead)) { return CG_HUD_ParseError(handle, "expected hudhead"); } continue; } if (!Q_stricmp(token.string, "cursorhints")) { if (!CG_ParseHudComponent(handle, &temphud.cursorhint)) { return CG_HUD_ParseError(handle, "expected cursorhints"); } continue; } if (!Q_stricmp(token.string, "weaponstability")) { if (!CG_ParseHudComponent(handle, &temphud.weaponstability)) { return CG_HUD_ParseError(handle, "expected weaponstability"); } continue; } if (!Q_stricmp(token.string, "livesleft")) { if (!CG_ParseHudComponent(handle, &temphud.livesleft)) { return CG_HUD_ParseError(handle, "expected livesleft"); } continue; } return CG_HUD_ParseError(handle, "unexpected token: %s", token.string); } if (CG_isHudNumberAvailable(temphud.hudnumber)) { Com_Printf("Hud properties for hud: %i have been read!\n", temphud.hudnumber); CG_addHudToList(temphud); } else { Com_Printf("^1Hud with number: %i already exists!\n", temphud.hudnumber); } return qtrue; }
static void UI_LoadArenasFromFile(char *filename) { int handle; pc_token_t token; handle = trap_PC_LoadSource(filename); if (!handle) { trap_Print(va(S_COLOR_RED "file not found: %s\n", filename)); return; } if (!trap_PC_ReadToken(handle, &token)) { trap_PC_FreeSource(handle); return; } if (*token.string != '{') { trap_PC_FreeSource(handle); return; } uiInfo.mapList[uiInfo.mapCount].cinematic = -1; uiInfo.mapList[uiInfo.mapCount].levelShot = -1; uiInfo.mapList[uiInfo.mapCount].typeBits = 0; while (trap_PC_ReadToken(handle, &token)) { if (*token.string == '}') { if (!uiInfo.mapList[uiInfo.mapCount].typeBits) { uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF); } uiInfo.mapCount++; if (uiInfo.mapCount >= MAX_MAPS) { break; } if (!trap_PC_ReadToken(handle, &token)) { // eof trap_PC_FreeSource(handle); return; } if (*token.string != '{') { trap_Print(va(S_COLOR_RED "unexpected token '%s' inside: %s\n", token.string, filename)); trap_PC_FreeSource(handle); return; } } else if (!Q_stricmp(token.string, "map")) { if (!PC_String_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].mapLoadName)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return; } } else if (!Q_stricmp(token.string, "longname")) { if (!PC_String_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].mapName)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return; } } else if (!Q_stricmp(token.string, "briefing")) { if (!PC_String_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].briefing)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return; } } else if (!Q_stricmp(token.string, "lmsbriefing")) { if (!PC_String_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].lmsbriefing)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return; } } /* else if (!Q_stricmp(token.string, "objectives")) { if (!PC_String_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].objectives)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return; } } */ else if (!Q_stricmp(token.string, "timelimit")) { if (!PC_Int_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].Timelimit)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return; } } else if (!Q_stricmp(token.string, "axisrespawntime")) { if (!PC_Int_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].AxisRespawnTime)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return; } } else if (!Q_stricmp(token.string, "alliedrespawntime")) { if (!PC_Int_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].AlliedRespawnTime)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return; } } else if (!Q_stricmp(token.string, "type")) { if (!trap_PC_ReadToken(handle, &token)) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return; } else { if (strstr(token.string, "wolfsp")) { uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_SINGLE_PLAYER); } if (strstr(token.string, "wolflms")) { uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF_LMS); } if (strstr(token.string, "wolfmp")) { uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF); } if (strstr(token.string, "wolfsw")) { uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF_STOPWATCH); } } } else if (!Q_stricmp(token.string, "mapposition_x")) { if (!PC_Float_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].mappos[0])) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return; } } else if (!Q_stricmp(token.string, "mapposition_y")) { if (!PC_Float_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].mappos[1])) { trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename)); trap_PC_FreeSource(handle); return; } } } trap_PC_FreeSource(handle); return; }