/* =============== UI_TeamOrdersMenu_f =============== */ void UI_TeamOrdersMenu_f(void) { uiClientState_t cs; char info[MAX_INFO_STRING]; int team; // make sure it's a team game trap_GetConfigString(CS_SERVERINFO, info, sizeof(info)); teamOrdersMenuInfo.gametype = atoi(Info_ValueForKey(info, "g_gametype")); if (teamOrdersMenuInfo.gametype < GT_TEAM) { return; } // not available to spectators trap_GetClientState(&cs); trap_GetConfigString(CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING); team = atoi(Info_ValueForKey(info, "t")); if (team == TEAM_SPECTATOR) { return; } UI_TeamOrdersMenu(); }
/* =============== UI_TeamOrdersMenu_BuildBotList =============== */ static void UI_TeamOrdersMenu_BuildBotList(void) { uiClientState_t cs; int numPlayers; int isBot; int n; char playerTeam; char botTeam; char info[MAX_INFO_STRING]; for (n = 0; n < 9; n++) { teamOrdersMenuInfo.bots[n] = teamOrdersMenuInfo.botNames[n]; } trap_GetClientState(&cs); Q_strncpyz(teamOrdersMenuInfo.botNames[0], "Everyone", 16); teamOrdersMenuInfo.numBots = 1; trap_GetConfigString(CS_SERVERINFO, info, sizeof(info)); numPlayers = atoi(Info_ValueForKey(info, "sv_maxclients")); teamOrdersMenuInfo.gametype = atoi(Info_ValueForKey(info, "g_gametype")); //Too: get the player team before the loop, so If player enter after bots in game, the menu still works ! trap_GetConfigString(CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING); playerTeam = *Info_ValueForKey(info, "t"); for (n = 0; n < numPlayers && teamOrdersMenuInfo.numBots < 9; n++) { trap_GetConfigString(CS_PLAYERS + n, info, MAX_INFO_STRING); //playerTeam = TEAM_SPECTATOR; // bk001204 = possible uninit use /*if (n == cs.clientNum) { playerTeam = *Info_ValueForKey(info, "t"); continue; }*/ isBot = atoi(Info_ValueForKey(info, "skill")); if (!isBot) { continue; } botTeam = *Info_ValueForKey(info, "t"); if (botTeam != playerTeam) { continue; } Q_strncpyz(teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.numBots], Info_ValueForKey(info, "n"), 16); Q_CleanStr(teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.numBots]); teamOrdersMenuInfo.numBots++; } }
/* ================= UI_SPPostgameMenu_f ================= */ void UI_SPPostgameMenu_f( void ) { int playerGameRank; // int oldFrags, newFrags; const char *arena; char map[MAX_QPATH]; char info[MAX_INFO_STRING]; Mouse_Show(); memset( &postgameMenuInfo, 0, sizeof(postgameMenuInfo) ); trap_GetConfigString( CS_SYSTEMINFO, info, sizeof(info) ); postgameMenuInfo.serverId = atoi( Info_ValueForKey( info, "sv_serverid" ) ); postgameMenuInfo.menu.nobackground = qtrue; trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) ); Q_strncpyz( map, Info_ValueForKey( info, "mapname" ), sizeof(map) ); arena = UI_GetArenaInfoByMap( map ); if ( !arena ) { return; } Q_strncpyz( arenainfo, arena, sizeof(arenainfo) ); postgameMenuInfo.level = atoi( Info_ValueForKey( arenainfo, "num" ) ); playerGameRank = 8; // in case they ended game as a spectator playerGameRank = atoi( UI_Argv(1)); UI_SetBestScore( postgameMenuInfo.level, playerGameRank+1 ); postgameMenuInfo.starttime = uis.realtime; postgameMenuInfo.scoreboardtime = uis.realtime; trap_Key_SetCatcher( KEYCATCH_UI ); uis.menusp = 0; UI_SPPostgameMenu_Init(); UI_PushMenu( &postgameMenuInfo.menu ); if (playerGameRank == 0) { postgameMenuInfo.won = 1; Menu_SetCursorToItem( &postgameMenuInfo.menu, &postgameMenuInfo.item_next ); } else { Menu_SetCursorToItem( &postgameMenuInfo.menu, &postgameMenuInfo.item_menu ); } // trap_Cmd_ExecuteText( EXEC_APPEND, "music music/win\n" ); //?? always win? should this be deleted and playing cg_scoreboard now? postgameMenuInfo.lastTier = UI_GetNumSPTiers(); if ( UI_GetSpecialArenaInfo( "final" ) ) { postgameMenuInfo.lastTier++; } }
/* * CG_InitGameShared * * Give gameshared access to some utilities */ static void CG_InitGameShared( void ) { char cstring[MAX_CONFIGSTRING_CHARS]; memset( &gs, 0, sizeof( gs_state_t ) ); gs.module = GS_MODULE_CGAME; trap_GetConfigString( CS_MAXCLIENTS, cstring, MAX_CONFIGSTRING_CHARS ); gs.maxclients = atoi( cstring ); if( gs.maxclients < 1 || gs.maxclients > MAX_CLIENTS ) gs.maxclients = MAX_CLIENTS; module_PredictedEvent = CG_PredictedEvent; module_Error = CG_Error; module_Printf = CG_Printf; module_Malloc = CG_GS_Malloc; module_Free = CG_GS_Free; module_Trace = CG_GS_Trace; module_GetEntityState = CG_GS_GetEntityState; module_PointContents = CG_GS_PointContents; module_RoundUpToHullSize = CG_GS_RoundUpToHullSize; module_PMoveTouchTriggers = CG_Predict_TouchTriggers; module_GetConfigString = CG_GS_GetConfigString; GS_InitWeapons(); }
void UI_ServerInfo( void ) { char info[ MAX_INFO_VALUE ]; info[0] = '\0'; if( trap_GetConfigString( CS_SERVERINFO, info, sizeof( info ) ) ) { trap_Cvar_Set( "ui_serverinfo_mapname", Info_ValueForKey( info, "mapname" ) ); trap_Cvar_Set( "ui_serverinfo_timelimit", Info_ValueForKey( info, "timelimit" ) ); trap_Cvar_Set( "ui_serverinfo_sd", Info_ValueForKey( info, "g_suddenDeathTime" ) ); trap_Cvar_Set( "ui_serverinfo_hostname", Info_ValueForKey( info, "sv_hostname" ) ); trap_Cvar_Set( "ui_serverinfo_maxclients", Info_ValueForKey( info, "sv_maxclients" ) ); trap_Cvar_Set( "ui_serverinfo_version", Info_ValueForKey( info, "version" ) ); trap_Cvar_Set( "ui_serverinfo_unlagged", Info_ValueForKey( info, "g_unlagged" ) ); trap_Cvar_Set( "ui_serverinfo_ff", Info_ValueForKey( info, "ff" ) ); } }
static void UI_TurboliftMenu_LoadDecks( void ) { char buffer[MAX_TOKEN_CHARS]; int i; char *temp; s_turbolift.numDecks = 0; //load the string trap_GetConfigString( CS_TURBOLIFT_DATA, buffer, sizeof( buffer ) ); if ( !buffer[0] ) return; memset( &s_turbolift.deckData, 0, sizeof( s_turbolift.deckData ) ); for ( i=0; i < MAX_DECKS; i++ ) { temp = Info_ValueForKey( buffer, va( "d%i", i ) ); if ( !temp[0] ) break; s_turbolift.deckData[ s_turbolift.numDecks ].deckNum = atoi( temp ); temp = Info_ValueForKey( buffer, va( "n%i", i ) ); Q_strncpyz( s_turbolift.deckData[ s_turbolift.numDecks ].deckDesc, temp, sizeof( s_turbolift.deckData[ s_turbolift.numDecks ].deckDesc ) ); s_turbolift.numDecks++; } //TiM - sort the decks into their sequential order qsort( s_turbolift.deckData, s_turbolift.numDecks, sizeof( deckData_t ), SortDecks ); }
void UI_ServerInfo( void ) { char info[ MAX_INFO_VALUE ]; char hostname[MAX_HOSTNAME_LENGTH]; info[0] = '\0'; if( trap_GetConfigString( CS_SERVERINFO, info, sizeof( info ) ) ) { trap_Cvar_Set( "ui_serverinfo_mapname", Info_ValueForKey( info, "mapname" ) ); trap_Cvar_Set( "ui_serverinfo_timelimit", Info_ValueForKey( info, "timelimit" ) ); trap_Cvar_Set( "ui_serverinfo_sd", Info_ValueForKey( info, "g_suddenDeathTime" ) ); UI_EscapeEmoticons( hostname, Info_ValueForKey( info, "sv_hostname" ), sizeof( hostname ) ); trap_Cvar_Set( "ui_serverinfo_hostname", hostname ); trap_Cvar_Set( "ui_serverinfo_maxclients", Info_ValueForKey( info, "sv_maxclients" ) ); trap_Cvar_Set( "ui_serverinfo_version", Info_ValueForKey( info, "version" ) ); trap_Cvar_Set( "ui_serverinfo_unlagged", Info_ValueForKey( info, "g_unlagged" ) ); trap_Cvar_Set( "ui_serverinfo_friendlyFire", Info_ValueForKey( info, "g_friendlyFire" ) ); trap_Cvar_Set( "ui_serverinfo_friendlyBuildableFire", Info_ValueForKey( info, "g_friendlyBuildableFire" ) ); trap_Cvar_Set( "ui_serverinfo_allowdl", Info_ValueForKey( info, "sv_allowdownload" ) ); } }
static void MenuDrawScoreLine(int n, int y) { int rank; char name[64], info[MAX_INFO_STRING]; if(n > (postgame.numClients + 1)) n -= (postgame.numClients + 2); if(n >= postgame.numClients) return; rank = postgame.ranks[n]; if(rank & RANK_TIED_FLAG){ UI_DrawString(640 - 31 * SMALLCHAR_WIDTH, y, "(tie)", UI_LEFT | UI_SMALLFONT, color_white); rank &= ~RANK_TIED_FLAG; } trap_GetConfigString(CS_PLAYERS + postgame.clientNums[n], info, MAX_INFO_STRING); Q_strncpyz(name, Info_ValueForKey(info, "n"), sizeof(name)); Q_cleanstr(name); UI_DrawString(640 - 25 * SMALLCHAR_WIDTH, y, va("#%i: %-16s %2i", rank + 1, name, postgame.scores[n]), UI_LEFT | UI_SMALLFONT, color_white); }
/* * CG_RegisterConfigStrings */ static void CG_RegisterConfigStrings( void ) { int i; const char *cs; cg.precacheCount = cg.precacheTotal = 0; for( i = 0; i < CS_GENERAL; i++ ) { trap_GetConfigString( i, cgs.configStrings[i], MAX_CONFIGSTRING_CHARS ); cs = cgs.configStrings[i]; if( i >= CS_MODELS && cs[0] ) { if( i >= CS_LOCATIONS && i < CS_LOCATIONS + MAX_LOCATIONS ) continue; if( ( i >= CS_SOUNDS && i < CS_SOUNDS + MAX_SOUNDS ) && ( cs[0] == '*' ) ) continue; cg.precacheTotal++; } } // if we got the server settings configstring, update our local copy of the data CG_UpdateTVServerString(); GS_SetGametypeName( cgs.configStrings[CS_GAMETYPENAME] ); trap_Cmd_ExecuteText( EXEC_NOW, va( "exec configs/client/%s.cfg silent", gs.gametypeName ) ); CG_SC_AutoRecordAction( cgs.configStrings[i] ); }
/* =============== UI_TeamOrdersMenu_BuildBotList =============== */ static void UI_TeamOrdersMenu_BuildBotList(void) { uiClientState_t cs; int numPlayers; int isBot; int n; char playerTeam = '3'; char botTeam; char info[MAX_INFO_STRING]; for (n = 0; n < 9; n++) { teamOrdersMenuInfo.bots[n] = teamOrdersMenuInfo.botNames[n]; } trap_GetClientState(&cs); Q_strncpyz(teamOrdersMenuInfo.botNames[0], "Everyone", 16); teamOrdersMenuInfo.numBots = 1; trap_GetConfigString(CS_SERVERINFO, info, sizeof(info)); numPlayers = atoi(Info_ValueForKey(info, "sv_maxclients")); teamOrdersMenuInfo.gametype = atoi(Info_ValueForKey(info, "g_gametype")); for (n = 0; n < numPlayers && teamOrdersMenuInfo.numBots < 9; n++) { trap_GetConfigString(CS_PLAYERS + n, info, MAX_INFO_STRING); if (n == cs.clientNum) { playerTeam = *Info_ValueForKey(info, "t"); continue; } isBot = atoi(Info_ValueForKey(info, "skill")); if (!isBot) { continue; } botTeam = *Info_ValueForKey(info, "t"); if (botTeam != playerTeam) { continue; } Q_strncpyz(teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.numBots], Info_ValueForKey(info, "n"), 16); Q_CleanStr(teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.numBots]); teamOrdersMenuInfo.numBots++; } }
/* =============== TeamMain_MenuEvent =============== */ static void TeamMain_MenuEvent(void* ptr, int event) { char info[MAX_INFO_STRING]; int gametype; trap_GetConfigString(CS_SERVERINFO, info, MAX_INFO_STRING); gametype = atoi(Info_ValueForKey(info,"g_gametype")); if (event != QM_ACTIVATED) { return; } switch (((menucommon_s*)ptr)->id) { case ID_JOINRED: if (gametype == GT_INVASION) trap_Cmd_ExecuteText(EXEC_APPEND, "cmd team red male\n"); else trap_Cmd_ExecuteText(EXEC_APPEND, "cmd team red\n"); UI_ForceMenuOff(); break; case ID_JOINREDFEMALE: trap_Cmd_ExecuteText(EXEC_APPEND, "cmd team red female\n"); UI_ForceMenuOff(); break; case ID_JOINBLUE: if (gametype == GT_INVASION) trap_Cmd_ExecuteText(EXEC_APPEND, "cmd team blue male\n"); else trap_Cmd_ExecuteText(EXEC_APPEND, "cmd team blue\n"); UI_ForceMenuOff(); break; case ID_JOINAUTO: trap_Cmd_ExecuteText(EXEC_APPEND, "cmd team auto male\n"); UI_ForceMenuOff(); break; case ID_JOINBLUEFEMALE: trap_Cmd_ExecuteText(EXEC_APPEND, "cmd team blue female\n"); UI_ForceMenuOff(); break; case ID_JOINGAME: trap_Cmd_ExecuteText(EXEC_APPEND, "cmd team free\n"); UI_ForceMenuOff(); break; case ID_SPECTATE: trap_Cmd_ExecuteText(EXEC_APPEND, "cmd team spectator\n"); UI_ForceMenuOff(); break; } }
/* * Cmd_ListLocations_f */ static void Cmd_ListLocations_f( void ) { int i; for( i = 0; i < MAX_LOCATIONS; i++ ) { const char *cs = trap_GetConfigString(CS_LOCATIONS + i); if( !cs[0] ) { break; } G_Printf( "%2d %s\n", i, cs ); } }
/* =============== UI_HelpMenu_SetTopic =============== */ static void UI_HelpMenu_SetTopic( void ) { char *arg; char info[MAX_INFO_STRING]; int gametype; if ( trap_Argc() > 1 ) { arg = UI_Argv( 1 ); if ( Q_stricmp( arg, "gametype" ) == 0 ) { helpList = HELP_GAMETYPE; trap_GetConfigString( CS_SERVERINFO, info, sizeof( info ) ); gametype = atoi( Info_ValueForKey( info, "g_gametype" ) ); if ( ( gametype < 0 ) || ( gametype > GT_MAX_GAME_TYPE ) ) { gametype = GT_MAX_GAME_TYPE; } helpIndex = GAMETYPE_REMAP[gametype]; helpMin = helpIndex; helpMax = helpIndex; helpMenuInfo.prev.generic.flags = QMF_HIDDEN; helpMenuInfo.next.generic.flags = QMF_HIDDEN; helpMenuInfo.width = HMI_GAMETYPE_W; helpMenuInfo.height = HMI_GAMETYPE_H; helpMenuInfo.x = HMI_GAMETYPE_X; helpMenuInfo.y = HMI_GAMETYPE_Y; } else { helpMin = 0; helpMax = ( NUM_HELP_ITEM - 1 ); helpList = HELP_ITEM; helpIndex = helpMin; helpMenuInfo.width = HMI_ITEM_W; helpMenuInfo.height = HMI_ITEM_H; helpMenuInfo.x = HMI_ITEM_X; helpMenuInfo.y = HMI_ITEM_Y; } } else { helpMin = 0; helpMax = ( NUM_HELP_ITEM - 1 ); helpList = HELP_ITEM; helpIndex = helpMax; helpMenuInfo.width = HMI_ITEM_W; helpMenuInfo.height = HMI_ITEM_H; helpMenuInfo.x = HMI_ITEM_X; helpMenuInfo.y = HMI_ITEM_Y; } UI_HelpMenu_AdjustButtons(); }
/* =============== UI_TeamOrdersMenu_f =============== */ void UI_TeamOrdersMenu_f( void ) { char info[MAX_INFO_STRING]; int team; // make sure it's a team game trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) ); teamOrdersMenuInfo.gametype = atoi( Info_ValueForKey( info, "g_gametype" ) ); if( teamOrdersMenuInfo.gametype < GT_TEAM ) { return; } // not available to spectators if ( cg.localPlayers[0].playerNum == -1 ) { return; } trap_GetConfigString( CS_PLAYERS + cg.localPlayers[0].playerNum, info, MAX_INFO_STRING ); team = atoi( Info_ValueForKey( info, "t" ) ); if( team == TEAM_SPECTATOR ) { return; } UI_TeamOrdersMenu(); }
//Makro - returns qtrue if the player can access the weapon/item menus qboolean UI_RQ3_WeaponMenuAccess() { char info[MAX_INFO_STRING]; int game, tdmMode; trap_GetConfigString(CS_SERVERINFO, info, sizeof(info)); game = atoi(Info_ValueForKey(info, "g_gametype")); tdmMode = atoi(Info_ValueForKey(info, "g_RQ3_tdmMode")); if (game == GT_TEAMPLAY || game == GT_CTF || (game == GT_TEAM && !tdmMode)) return qtrue; else return qfalse; }
static void populatePlayerList( void ) { int i; char playerinfo[MAX_INFO_STRING]; s_votemenu_kick.numPlayers = 0; for(i=0;i<MAX_CLIENTS;i++) { trap_GetConfigString( CS_PLAYERS + i, playerinfo, MAX_INFO_STRING ); if(strlen(playerinfo) ) { s_votemenu_kick.players_profiles[s_votemenu_kick.numPlayers].id = i; Q_strncpyz( s_votemenu_kick.players_profiles[s_votemenu_kick.numPlayers].name, Info_ValueForKey( playerinfo, "n" ), SIZE_OF_NAME - 2); s_votemenu_kick.numPlayers++; } } }
static void Prepname( int index ) { int len; char name[64]; char info[MAX_INFO_STRING]; trap_GetConfigString( CS_PLAYERS + postgameMenuInfo.clientNums[index], info, MAX_INFO_STRING ); Q_strncpyz( name, Info_ValueForKey( info, "n" ), sizeof(name) ); Q_CleanStr( name ); len = strlen( name ); while( len && UI_ProportionalStringWidth( name ) > 256 ) { len--; name[len] = 0; } Q_strncpyz( postgameMenuInfo.placeNames[index], name, sizeof(postgameMenuInfo.placeNames[index]) ); }
const char* UI_NameForCampaign( void ) { int i = 0, j = 0; char* mapname; char info[MAX_INFO_STRING]; trap_GetConfigString(CS_SERVERINFO, info, sizeof(info)); mapname = Info_ValueForKey( info, "mapname" ); for( ; i < uiInfo.campaignCount; i++ ) { for( ; j < uiInfo.campaignList[i].mapCount; j++ ) { if( !Q_stricmp( mapname, uiInfo.campaignList[i].mapInfos[j]->mapName ) ) { return uiInfo.campaignList[i].campaignName; } } } return NULL; }
/* * G_InitGameShared * give gameshared access to some utilities */ static void G_InitGameShared( void ) { memset( &gs, 0, sizeof( gs_state_t ) ); gs.module = GS_MODULE_GAME; gs.maxclients = atoi( trap_GetConfigString( CS_MAXCLIENTS ) ); if( gs.maxclients < 1 || gs.maxclients > MAX_EDICTS ) G_Error( "Invalid maxclients value %i\n", gs.maxclients ); module_PredictedEvent = G_PredictedEvent; module_Error = G_Error; module_Printf = G_Printf; module_Malloc = G_GS_Malloc; module_Free = G_GS_Free; module_Trace = G_GS_Trace; module_GetEntityState = G_GetEntityStateForDeltaTime; module_PointContents = G_PointContents4D; module_RoundUpToHullSize = G_GS_RoundUpToHullSize; module_PMoveTouchTriggers = G_PMoveTouchTriggers; module_GetConfigString = trap_GetConfigString; }
/* ================= UI_VoteFraglimitMenu *Called from outside ================= */ void UI_VoteFraglimitMenu( void ) { char serverinfo[MAX_INFO_STRING]; // zero set all our globals memset( &s_votemenu_fraglmit, 0 ,sizeof(votemenu_t) ); trap_GetConfigString( CS_SERVERINFO, serverinfo, MAX_INFO_STRING ); s_votemenu_fraglmit.min = atoi(Info_ValueForKey(serverinfo,"g_voteMinFraglimit")); s_votemenu_fraglmit.max = atoi(Info_ValueForKey(serverinfo,"g_voteMaxFraglimit")); UI_VoteFraglimitMenuInternal(); Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.banner ); Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.back ); //Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.go ); Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.bLimit10 ); Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.bLimit15 ); Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.bLimit20 ); Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.bLimit30 ); Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.bLimit40 ); Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.bLimit50 ); Menu_AddItem( &s_votemenu_fraglmit.menu, (void*) &s_votemenu_fraglmit.bLimitInf ); UI_PushMenu( &s_votemenu_fraglmit.menu ); }
/* * G_Match_Autorecord_Start */ void G_Match_Autorecord_Start( void ) { int team, i, playerCount; G_Match_SetAutorecordState( "start" ); // do not start autorecording if all playing clients are bots for( playerCount = 0, team = TEAM_PLAYERS; team < GS_MAX_TEAMS; team++ ) { // add our team info to the string for( i = 0; i < teamlist[team].numplayers; i++ ) { if( game.edicts[ teamlist[team].playerIndices[i] ].r.svflags & SVF_FAKECLIENT ) continue; playerCount++; break; // we only need one for this check } } if( playerCount && g_autorecord->integer ) { char datetime[17], players[MAX_STRING_CHARS]; time_t long_time; struct tm *newtime; // date & time time( &long_time ); newtime = localtime( &long_time ); Q_snprintfz( datetime, sizeof( datetime ), "%04d-%02d-%02d_%02d-%02d", newtime->tm_year + 1900, newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min ); // list of players Q_strncpyz( players, trap_GetConfigString( CS_MATCHNAME ), sizeof( players ) ); if( players[0] == '\0' ) { if( GS_InvidualGameType() ) { const char *netname; int team; edict_t *ent; for( team = TEAM_ALPHA; team < GS_MAX_TEAMS; team++ ) { if( !teamlist[team].numplayers ) continue; ent = game.edicts + teamlist[team].playerIndices[0]; netname = ent->r.client->netname; Q_strncatz( players, netname, sizeof( players ) ); if( team != GS_MAX_TEAMS - 1 ) Q_strncatz( players, " vs ", sizeof( players ) ); } } } if( players[0] != '\0' ) { char *t = strstr( players, " vs " ); if( t ) memcpy( t, "_vs_", strlen( "_vs_" ) ); Q_strncpyz( players, COM_RemoveJunkChars( COM_RemoveColorTokens( players ) ), sizeof( players ) ); } // combine Q_snprintfz( level.autorecord_name, sizeof( level.autorecord_name ), "%s_%s_%s%s%s_auto%04i", datetime, gs.gametypeName, level.mapname, players[0] == '\0' ? "" : "_", players, (int)brandom( 1, 9999 ) ); trap_Cmd_ExecuteText( EXEC_APPEND, va( "serverrecord %s\n", level.autorecord_name ) ); } }
/* ================= UI_ServerInfoMenu ================= */ void UI_ServerInfoMenu( void ) { const char *s; char key[MAX_INFO_KEY]; char value[MAX_INFO_VALUE]; // zero set all our globals memset( &s_serverinfo, 0 ,sizeof(serverinfo_t) ); ServerInfo_Cache(); s_serverinfo.menu.draw = ServerInfo_MenuDraw; s_serverinfo.menu.key = ServerInfo_MenuKey; s_serverinfo.menu.wrapAround = qtrue; s_serverinfo.menu.fullscreen = qtrue; s_serverinfo.banner.generic.type = MTYPE_BTEXT; s_serverinfo.banner.generic.x = 320; s_serverinfo.banner.generic.y = 16; s_serverinfo.banner.string = "SERVER INFO"; s_serverinfo.banner.color = color_white; s_serverinfo.banner.style = UI_CENTER; s_serverinfo.framel.generic.type = MTYPE_BITMAP; s_serverinfo.framel.generic.name = SERVERINFO_FRAMEL; s_serverinfo.framel.generic.flags = QMF_INACTIVE; s_serverinfo.framel.generic.x = 0; s_serverinfo.framel.generic.y = 78; s_serverinfo.framel.width = 256; s_serverinfo.framel.height = 329; s_serverinfo.framer.generic.type = MTYPE_BITMAP; s_serverinfo.framer.generic.name = SERVERINFO_FRAMER; s_serverinfo.framer.generic.flags = QMF_INACTIVE; s_serverinfo.framer.generic.x = 376; s_serverinfo.framer.generic.y = 76; s_serverinfo.framer.width = 256; s_serverinfo.framer.height = 334; s_serverinfo.add.generic.type = MTYPE_PTEXT; s_serverinfo.add.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; s_serverinfo.add.generic.callback = ServerInfo_Event; s_serverinfo.add.generic.id = ID_ADD; s_serverinfo.add.generic.x = 320; s_serverinfo.add.generic.y = 371; s_serverinfo.add.string = "ADD TO FAVORITES"; s_serverinfo.add.style = UI_CENTER|UI_SMALLFONT; s_serverinfo.add.color = color_red; if( trap_Cvar_VariableValue( "sv_running" ) ) { s_serverinfo.add.generic.flags |= QMF_GRAYED; } s_serverinfo.back.generic.type = MTYPE_BITMAP; s_serverinfo.back.generic.name = SERVERINFO_BACK0; s_serverinfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; s_serverinfo.back.generic.callback = ServerInfo_Event; s_serverinfo.back.generic.id = ID_BACK; s_serverinfo.back.generic.x = 0; s_serverinfo.back.generic.y = 480-64; s_serverinfo.back.width = 128; s_serverinfo.back.height = 64; s_serverinfo.back.focuspic = SERVERINFO_BACK1; trap_GetConfigString( CS_SERVERINFO, s_serverinfo.info, MAX_INFO_STRING ); s_serverinfo.numlines = 0; s = s_serverinfo.info; while ( s ) { Info_NextPair( &s, key, value ); if ( !key[0] ) { break; } s_serverinfo.numlines++; } if (s_serverinfo.numlines > 16) s_serverinfo.numlines = 16; Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.banner ); Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.framel ); Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.framer ); Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.add ); Menu_AddItem( &s_serverinfo.menu, (void*) &s_serverinfo.back ); UI_PushMenu( &s_serverinfo.menu ); }
/* ======================== UI_DrawConnectScreen This will also be overlaid on the cgame info screen during loading to prevent it from blinking away too rapidly on local or lan games. ======================== */ void UI_DrawConnectScreen( qboolean overlay ) { char *s; uiClientState_t cstate; char info[MAX_INFO_VALUE]; Menu_Cache(); if ( !overlay ) { // draw the dialog background UI_SetColor( color_white ); UI_DrawHandlePic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, uis.connecting ); } // see what information we should display trap_GetClientState( &cstate ); info[0] = '\0'; if( trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) ) ) { UI_DrawProportionalString( 320, 16, va( "Loading %s", Info_ValueForKey( info, "mapname" ) ), UI_BIGFONT|UI_CENTER|UI_DROPSHADOW, 1.0, g_color_table[60] ); } UI_DrawProportionalString( 320, 64, va("Connecting to %s", cstate.servername), UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, 0.75, g_color_table[60] ); //UI_DrawProportionalString( 320, 96, "Press Esc to abort", UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color ); // display global MOTD at bottom UI_DrawProportionalString( SCREEN_WIDTH/2, SCREEN_HEIGHT-32, Info_ValueForKey( cstate.updateInfoString, "motd" ), UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, 0.75, menu_text_color ); // print any server info (server full, bad version, etc) if ( cstate.connState < CA_CONNECTED ) { UI_DrawProportionalString_AutoWrapped( 320, 192, 630, 20, cstate.messageString, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color ); //Here is what prints the ban message! //Com_Printf("DBG: %s\n", cstate.messageString); } #if 0 // display password field if ( passwordNeeded ) { s_ingame_menu.x = SCREEN_WIDTH * 0.50 - 128; s_ingame_menu.nitems = 0; s_ingame_menu.wrapAround = qtrue; passwordField.generic.type = MTYPE_FIELD; passwordField.generic.name = "Password:"******"password"), sizeof(passwordField.field.buffer) ); Menu_AddItem( &s_ingame_menu, ( void * ) &s_customize_player_action ); MField_Draw( &passwordField ); } #endif if ( lastConnState > cstate.connState ) { lastLoadingText[0] = '\0'; } lastConnState = cstate.connState; switch ( cstate.connState ) { case CA_CONNECTING: s = va("Awaiting challenge...%i", cstate.connectPacketCount); break; case CA_CHALLENGING: s = va("Awaiting connection...%i", cstate.connectPacketCount); break; case CA_CONNECTED: { char downloadName[MAX_INFO_VALUE]; trap_Cvar_VariableStringBuffer( "cl_downloadName", downloadName, sizeof(downloadName) ); if (*downloadName) { UI_DisplayDownloadInfo( downloadName ); return; } } s = "Awaiting gamestate..."; break; case CA_LOADING: return; case CA_PRIMED: return; default: return; } UI_DrawProportionalString( 320, 128, s, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, 0.75, g_color_table[60] ); // password required / connection rejected information goes here }
/* ================= UI_SPPostgameMenu_MenuDraw ================= */ static void UI_SPPostgameMenu_MenuDraw( void ) { int timer; int serverId; int n; char info[MAX_INFO_STRING]; trap_GetConfigString( CS_SYSTEMINFO, info, sizeof(info) ); serverId = atoi( Info_ValueForKey( info, "sv_serverid" ) ); if( serverId != postgameMenuInfo.serverId ) { UI_PopMenu(); return; } // phase 1 if ( postgameMenuInfo.numClients > 2 ) { UI_DrawProportionalString( 510, 480 - 64 - PROP_HEIGHT, postgameMenuInfo.placeNames[2], UI_CENTER, color_white ); } UI_DrawProportionalString( 130, 480 - 64 - PROP_HEIGHT, postgameMenuInfo.placeNames[1], UI_CENTER, color_white ); UI_DrawProportionalString( 320, 480 - 64 - 2 * PROP_HEIGHT, postgameMenuInfo.placeNames[0], UI_CENTER, color_white ); if( postgameMenuInfo.phase == 1 ) { timer = uis.realtime - postgameMenuInfo.starttime; if( timer >= 1000 && postgameMenuInfo.winnerSound ) { trap_S_StartLocalSound( postgameMenuInfo.winnerSound, CHAN_ANNOUNCER ); postgameMenuInfo.winnerSound = 0; } if( timer < 5000 ) { return; } postgameMenuInfo.phase = 2; postgameMenuInfo.starttime = uis.realtime; } // phase 2 if( postgameMenuInfo.phase == 2 ) { timer = uis.realtime - postgameMenuInfo.starttime; if( timer >= ( postgameMenuInfo.numAwards * AWARD_PRESENTATION_TIME ) ) { if( timer < 5000 ) { return; } postgameMenuInfo.phase = 3; postgameMenuInfo.starttime = uis.realtime; } else { UI_SPPostgameMenu_DrawAwardsPresentation( timer ); } } // phase 3 if( postgameMenuInfo.phase == 3 ) { if( uis.demoversion ) { if( postgameMenuInfo.won == 1 && UI_ShowTierVideo( 8 )) { trap_Cvar_Set( "nextmap", "" ); trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect; cinematic demoEnd.RoQ\n" ); return; } } else if( postgameMenuInfo.won > -1 && UI_ShowTierVideo( postgameMenuInfo.won + 1 )) { if( postgameMenuInfo.won == postgameMenuInfo.lastTier ) { trap_Cvar_Set( "nextmap", "" ); trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect; cinematic end.RoQ\n" ); return; } trap_Cvar_SetValue( "ui_spSelection", postgameMenuInfo.won * ARENAS_PER_TIER ); trap_Cvar_Set( "nextmap", "levelselect" ); trap_Cmd_ExecuteText( EXEC_APPEND, va( "disconnect; cinematic tier%i.RoQ\n", postgameMenuInfo.won + 1 ) ); return; } postgameMenuInfo.item_again.generic.flags &= ~QMF_INACTIVE; postgameMenuInfo.item_next.generic.flags &= ~QMF_INACTIVE; postgameMenuInfo.item_menu.generic.flags &= ~QMF_INACTIVE; UI_SPPostgameMenu_DrawAwardsMedals( postgameMenuInfo.numAwards ); Menu_Draw( &postgameMenuInfo.menu ); } // draw the scoreboard if( !trap_Cvar_VariableValue( "ui_spScoreboard" ) ) { return; } timer = uis.realtime - postgameMenuInfo.scoreboardtime; if( postgameMenuInfo.numClients <= 3 ) { n = 0; } else { n = timer / 1500 % (postgameMenuInfo.numClients + 2); } UI_SPPostgameMenu_MenuDrawScoreLine( n, 0 ); UI_SPPostgameMenu_MenuDrawScoreLine( n + 1, 0 + SMALLCHAR_HEIGHT ); UI_SPPostgameMenu_MenuDrawScoreLine( n + 2, 0 + 2 * SMALLCHAR_HEIGHT ); }
static void UI_ManageDeckLoading( void ) { char fileRoute[MAX_QPATH]; char mapRoute[MAX_QPATH]; char info[MAX_TOKEN_CHARS]; fileHandle_t f; int file_len; char *textPtr; char buffer[20000]; char *token; //get the map name trap_GetConfigString( CS_SERVERINFO, info, sizeof( info ) ); Com_sprintf( mapRoute, sizeof( fileRoute ), "maps/%s", Info_ValueForKey( info, "mapname" ) ); //check for language UI_LanguageFilename( mapRoute, "turbolift", fileRoute ); file_len = trap_FS_FOpenFile( fileRoute, &f, FS_READ ); if ( file_len <= 1 ) { //Com_Printf( S_COLOR_YELLOW "WARNING: Attempted to load %s, but wasn't found.\n", fileRoute ); UI_TurboliftMenu_LoadDecks(); return; } trap_FS_Read( buffer, file_len, f ); trap_FS_FCloseFile( f ); if ( !buffer[0] ) { Com_Printf( S_COLOR_RED "ERROR: Attempted to load %s, but no data was read.\n", fileRoute ); UI_TurboliftMenu_LoadDecks(); return; } s_turbolift.numDecks = 0; memset( &s_turbolift.deckData, 0, sizeof( s_turbolift.deckData ) ); buffer[file_len] = '\0'; COM_BeginParseSession(); textPtr = buffer; //Com_Printf( S_COLOR_RED "Beginning Parse\n" ); //expected format is 'decknum' <space> 'deck Desc' while( 1 ) { token = COM_Parse( &textPtr ); if ( !token[0] ) break; //Com_Printf( S_COLOR_RED "First Token: %s\n", token ); //in case of Scooter's EF SP style DAT files, which require 'DECK' in front of the number if ( !Q_strncmp( token, "DECK", 4 ) ) token += 4; //grab the deck number s_turbolift.deckData[s_turbolift.numDecks].deckNum = atoi( token ); token = COM_ParseExt( &textPtr, qfalse ); if (!token[0]) continue; //Com_Printf( S_COLOR_RED "Second Token: %s\n", token ); Q_strncpyz( s_turbolift.deckData[s_turbolift.numDecks].deckDesc, token, sizeof( s_turbolift.deckData[s_turbolift.numDecks].deckDesc ) ); s_turbolift.numDecks++; //if this is an EF SP style script, there may be more data after these two. ignore them if ( COM_ParseExt( &textPtr, qfalse ) == NULL ) SkipRestOfLine( &textPtr ); } qsort( s_turbolift.deckData, s_turbolift.numDecks, sizeof( deckData_t ), SortDecks ); }
/* ======================================================================================================================================= TeamMain_MenuInit ======================================================================================================================================= */ void TeamMain_MenuInit(void) { int y; int gametype; char info[MAX_INFO_STRING]; memset(&s_teammain, 0, sizeof(s_teammain)); TeamMain_Cache(); s_teammain.menu.wrapAround = qtrue; s_teammain.menu.fullscreen = qfalse; s_teammain.frame.generic.type = MTYPE_BITMAP; s_teammain.frame.generic.flags = QMF_INACTIVE; s_teammain.frame.generic.name = TEAMMAIN_FRAME; s_teammain.frame.generic.x = 142; s_teammain.frame.generic.y = 118; s_teammain.frame.width = 359; s_teammain.frame.height = 256; y = 194; s_teammain.joinred.generic.type = MTYPE_PTEXT; s_teammain.joinred.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; s_teammain.joinred.generic.id = ID_JOINRED; s_teammain.joinred.generic.callback = TeamMain_MenuEvent; s_teammain.joinred.generic.x = 320; s_teammain.joinred.generic.y = y; s_teammain.joinred.string = "JOIN RED"; s_teammain.joinred.style = UI_CENTER|UI_SMALLFONT; s_teammain.joinred.color = colorRed; y += 20; s_teammain.joinblue.generic.type = MTYPE_PTEXT; s_teammain.joinblue.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; s_teammain.joinblue.generic.id = ID_JOINBLUE; s_teammain.joinblue.generic.callback = TeamMain_MenuEvent; s_teammain.joinblue.generic.x = 320; s_teammain.joinblue.generic.y = y; s_teammain.joinblue.string = "JOIN BLUE"; s_teammain.joinblue.style = UI_CENTER|UI_SMALLFONT; s_teammain.joinblue.color = colorRed; y += 20; s_teammain.joingame.generic.type = MTYPE_PTEXT; s_teammain.joingame.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; s_teammain.joingame.generic.id = ID_JOINGAME; s_teammain.joingame.generic.callback = TeamMain_MenuEvent; s_teammain.joingame.generic.x = 320; s_teammain.joingame.generic.y = y; s_teammain.joingame.string = "JOIN GAME"; s_teammain.joingame.style = UI_CENTER|UI_SMALLFONT; s_teammain.joingame.color = colorRed; y += 20; s_teammain.spectate.generic.type = MTYPE_PTEXT; s_teammain.spectate.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; s_teammain.spectate.generic.id = ID_SPECTATE; s_teammain.spectate.generic.callback = TeamMain_MenuEvent; s_teammain.spectate.generic.x = 320; s_teammain.spectate.generic.y = y; s_teammain.spectate.string = "SPECTATE"; s_teammain.spectate.style = UI_CENTER|UI_SMALLFONT; s_teammain.spectate.color = colorRed; trap_GetConfigString(CS_SERVERINFO, info, MAX_INFO_STRING); gametype = atoi(Info_ValueForKey(info, "g_gametype")); // set initial states switch (gametype) { case GT_SINGLE_PLAYER: case GT_FFA: case GT_TOURNAMENT: s_teammain.joinred.generic.flags |= QMF_GRAYED; s_teammain.joinblue.generic.flags |= QMF_GRAYED; break; default: case GT_TEAM: case GT_CTF: s_teammain.joingame.generic.flags |= QMF_GRAYED; break; } Menu_AddItem(&s_teammain.menu, (void *)&s_teammain.frame); Menu_AddItem(&s_teammain.menu, (void *)&s_teammain.joinred); Menu_AddItem(&s_teammain.menu, (void *)&s_teammain.joinblue); Menu_AddItem(&s_teammain.menu, (void *)&s_teammain.joingame); Menu_AddItem(&s_teammain.menu, (void *)&s_teammain.spectate); }
/* ======================= UI_CalcPostGameStats ======================= */ static void UI_CalcPostGameStats( void ) { char map[MAX_QPATH]; char fileName[MAX_QPATH]; char info[MAX_INFO_STRING]; fileHandle_t f; int size, game, time, adjustedTime; postGameInfo_t oldInfo; postGameInfo_t newInfo; qboolean newHigh = qfalse; trap_GetConfigString(CS_SERVERINFO, info, sizeof(info)); Q_strncpyz(map, Info_ValueForKey(info, "mapname"), sizeof(map)); game = atoi(Info_ValueForKey(info, "g_gametype")); // compose file name Com_sprintf(fileName, MAX_QPATH, "games/%s_%i.game", map, game); // see if we have one already memset(&oldInfo, 0, sizeof(postGameInfo_t)); if (trap_FS_FOpenFile(fileName, &f, FS_READ) >= 0) { // if so load it size = 0; trap_FS_Read(&size, sizeof(int), f); if (size == sizeof(postGameInfo_t)) { trap_FS_Read(&oldInfo, sizeof(postGameInfo_t), f); } trap_FS_FCloseFile(f); } newInfo.accuracy = atoi(UI_Argv(3)); newInfo.impressives = atoi(UI_Argv(4)); newInfo.excellents = atoi(UI_Argv(5)); newInfo.defends = atoi(UI_Argv(6)); newInfo.assists = atoi(UI_Argv(7)); newInfo.gauntlets = atoi(UI_Argv(8)); newInfo.baseScore = atoi(UI_Argv(9)); newInfo.perfects = atoi(UI_Argv(10)); newInfo.redScore = atoi(UI_Argv(11)); newInfo.blueScore = atoi(UI_Argv(12)); time = atoi(UI_Argv(13)); newInfo.captures = atoi(UI_Argv(14)); newInfo.time = (time - trap_Cvar_VariableValue("ui_matchStartTime")) / 1000; adjustedTime = uiInfo.mapList[ui_currentMap.integer].timeToBeat[game]; if (newInfo.time < adjustedTime) { newInfo.timeBonus = (adjustedTime - newInfo.time) * 10; } else { newInfo.timeBonus = 0; } if (newInfo.redScore > newInfo.blueScore && newInfo.blueScore <= 0) { newInfo.shutoutBonus = 100; } else { newInfo.shutoutBonus = 0; } newInfo.skillBonus = trap_Cvar_VariableValue("g_spSkill"); if (newInfo.skillBonus <= 0) { newInfo.skillBonus = 1; } newInfo.score = newInfo.baseScore + newInfo.shutoutBonus + newInfo.timeBonus; newInfo.score *= newInfo.skillBonus; // see if the score is higher for this one newHigh = (newInfo.redScore > newInfo.blueScore && newInfo.score > oldInfo.score); if (newHigh) { // if so write out the new one uiInfo.newHighScoreTime = uiInfo.uiDC.realTime + 20000; if (trap_FS_FOpenFile(fileName, &f, FS_WRITE) >= 0) { size = sizeof(postGameInfo_t); trap_FS_Write(&size, sizeof(int), f); trap_FS_Write(&newInfo, sizeof(postGameInfo_t), f); trap_FS_FCloseFile(f); } } if (newInfo.time < oldInfo.time) { uiInfo.newBestTime = uiInfo.uiDC.realTime + 20000; } // put back all the ui overrides trap_Cvar_Set("capturelimit", UI_Cvar_VariableString("ui_saveCaptureLimit")); trap_Cvar_Set("fraglimit", UI_Cvar_VariableString("ui_saveFragLimit")); trap_Cvar_Set("cg_drawTimer", UI_Cvar_VariableString("ui_drawTimer")); trap_Cvar_Set("g_doWarmup", UI_Cvar_VariableString("ui_doWarmup")); trap_Cvar_Set("g_Warmup", UI_Cvar_VariableString("ui_Warmup")); trap_Cvar_Set("sv_pure", UI_Cvar_VariableString("ui_pure")); trap_Cvar_Set("g_friendlyFire", UI_Cvar_VariableString("ui_friendlyFire")); UI_SetBestScores(&newInfo, qtrue); UI_ShowPostGame(newHigh); }
/* ================= UI_SPPostgameMenu_f ================= */ void UI_SPPostgameMenu_f( void ) { int playerGameRank; int playerClientNum; int n; int oldFrags, newFrags; const char *arena; int awardValues[6]; char map[MAX_QPATH]; char info[MAX_INFO_STRING]; memset( &postgameMenuInfo, 0, sizeof(postgameMenuInfo) ); trap_GetConfigString( CS_SYSTEMINFO, info, sizeof(info) ); postgameMenuInfo.serverId = atoi( Info_ValueForKey( info, "sv_serverid" ) ); trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) ); Q_strncpyz( map, Info_ValueForKey( info, "mapname" ), sizeof(map) ); arena = UI_GetArenaInfoByMap( map ); if ( !arena ) { return; } Q_strncpyz( arenainfo, arena, sizeof(arenainfo) ); postgameMenuInfo.level = atoi( Info_ValueForKey( arenainfo, "num" ) ); postgameMenuInfo.numClients = atoi( UI_Argv( 1 ) ); playerClientNum = atoi( UI_Argv( 2 ) ); playerGameRank = 8; // in case they ended game as a spectator if( postgameMenuInfo.numClients > MAX_SCOREBOARD_CLIENTS ) { postgameMenuInfo.numClients = MAX_SCOREBOARD_CLIENTS; } for( n = 0; n < postgameMenuInfo.numClients; n++ ) { postgameMenuInfo.clientNums[n] = atoi( UI_Argv( 8 + n * 3 + 1 ) ); postgameMenuInfo.ranks[n] = atoi( UI_Argv( 8 + n * 3 + 2 ) ); postgameMenuInfo.scores[n] = atoi( UI_Argv( 8 + n * 3 + 3 ) ); if( postgameMenuInfo.clientNums[n] == playerClientNum ) { playerGameRank = (postgameMenuInfo.ranks[n] & ~RANK_TIED_FLAG) + 1; } } UI_SetBestScore( postgameMenuInfo.level, playerGameRank ); // process award stats and prepare presentation data awardValues[AWARD_ACCURACY] = atoi( UI_Argv( 3 ) ); awardValues[AWARD_IMPRESSIVE] = atoi( UI_Argv( 4 ) ); awardValues[AWARD_EXCELLENT] = atoi( UI_Argv( 5 ) ); awardValues[AWARD_GAUNTLET] = atoi( UI_Argv( 6 ) ); awardValues[AWARD_FRAGS] = atoi( UI_Argv( 7 ) ); awardValues[AWARD_PERFECT] = atoi( UI_Argv( 8 ) ); postgameMenuInfo.numAwards = 0; if( awardValues[AWARD_ACCURACY] >= 50 ) { UI_LogAwardData( AWARD_ACCURACY, 1 ); postgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_ACCURACY; postgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = awardValues[AWARD_ACCURACY]; postgameMenuInfo.numAwards++; } if( awardValues[AWARD_IMPRESSIVE] ) { UI_LogAwardData( AWARD_IMPRESSIVE, awardValues[AWARD_IMPRESSIVE] ); postgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_IMPRESSIVE; postgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = awardValues[AWARD_IMPRESSIVE]; postgameMenuInfo.numAwards++; } if( awardValues[AWARD_EXCELLENT] ) { UI_LogAwardData( AWARD_EXCELLENT, awardValues[AWARD_EXCELLENT] ); postgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_EXCELLENT; postgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = awardValues[AWARD_EXCELLENT]; postgameMenuInfo.numAwards++; } if( awardValues[AWARD_GAUNTLET] ) { UI_LogAwardData( AWARD_GAUNTLET, awardValues[AWARD_GAUNTLET] ); postgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_GAUNTLET; postgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = awardValues[AWARD_GAUNTLET]; postgameMenuInfo.numAwards++; } oldFrags = UI_GetAwardLevel( AWARD_FRAGS ) / 100; UI_LogAwardData( AWARD_FRAGS, awardValues[AWARD_FRAGS] ); newFrags = UI_GetAwardLevel( AWARD_FRAGS ) / 100; if( newFrags > oldFrags ) { postgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_FRAGS; postgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = newFrags * 100; postgameMenuInfo.numAwards++; } if( awardValues[AWARD_PERFECT] ) { UI_LogAwardData( AWARD_PERFECT, 1 ); postgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_PERFECT; postgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = 1; postgameMenuInfo.numAwards++; } if ( playerGameRank == 1 ) { postgameMenuInfo.won = UI_TierCompleted( postgameMenuInfo.level ); } else { postgameMenuInfo.won = -1; } postgameMenuInfo.starttime = uis.realtime; postgameMenuInfo.scoreboardtime = uis.realtime; trap_Key_SetCatcher( KEYCATCH_UI ); uis.menusp = 0; UI_SPPostgameMenu_Init(); UI_PushMenu( &postgameMenuInfo.menu ); if ( playerGameRank == 1 ) { Menu_SetCursorToItem( &postgameMenuInfo.menu, &postgameMenuInfo.item_next ); } else { Menu_SetCursorToItem( &postgameMenuInfo.menu, &postgameMenuInfo.item_again ); } Prepname( 0 ); Prepname( 1 ); Prepname( 2 ); if ( playerGameRank != 1 ) { postgameMenuInfo.winnerSound = trap_S_RegisterSound( va( "sound/player/announce/%s_wins.wav", postgameMenuInfo.placeNames[0] ), qfalse ); trap_Cmd_ExecuteText( EXEC_APPEND, "music music/loss\n" ); } else { postgameMenuInfo.winnerSound = trap_S_RegisterSound( "sound/player/announce/youwin.wav", qfalse ); trap_Cmd_ExecuteText( EXEC_APPEND, "music music/win\n" ); } postgameMenuInfo.phase = 1; postgameMenuInfo.lastTier = UI_GetNumSPTiers(); if ( UI_GetSpecialArenaInfo( "final" ) ) { postgameMenuInfo.lastTier++; } }
/* ================= InGame_MenuInit ================= */ void InGame_MenuInit( void ) { int y; uiClientState_t cs; char info[MAX_INFO_STRING]; int team; memset( &s_ingame, 0 ,sizeof(ingamemenu_t) ); InGame_Cache(); s_ingame.menu.wrapAround = qtrue; s_ingame.menu.fullscreen = qfalse; s_ingame.frame.generic.type = MTYPE_BITMAP; s_ingame.frame.generic.flags = QMF_INACTIVE; s_ingame.frame.generic.name = INGAME_FRAME; s_ingame.frame.generic.x = 320-233; s_ingame.frame.generic.y = 240-166-INGAME_MENU_VERTICAL_SPACING/2; s_ingame.frame.width = 466; s_ingame.frame.height = 332+INGAME_MENU_VERTICAL_SPACING/2; y = (s_ingame.frame.height - INGAME_MENU_VERTICAL_SPACING * (INGAME_MENU_ITEMS-1) - SMALLCHAR_HEIGHT)/2 + s_ingame.frame.generic.y; s_ingame.slugrock.generic.type = MTYPE_PTEXT; s_ingame.slugrock.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; s_ingame.slugrock.generic.x = 320; s_ingame.slugrock.generic.y = y; s_ingame.slugrock.generic.id = ID_SLUGROCK; s_ingame.slugrock.generic.callback = InGame_Event; s_ingame.slugrock.string = "SLUGROCK"; s_ingame.slugrock.color = color_red; s_ingame.slugrock.style = UI_CENTER|UI_SMALLFONT; y += INGAME_MENU_VERTICAL_SPACING; s_ingame.team.generic.type = MTYPE_PTEXT; s_ingame.team.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; s_ingame.team.generic.x = 320; s_ingame.team.generic.y = y; s_ingame.team.generic.id = ID_TEAM; s_ingame.team.generic.callback = InGame_Event; s_ingame.team.string = "START"; s_ingame.team.color = color_red; s_ingame.team.style = UI_CENTER|UI_SMALLFONT; y += INGAME_MENU_VERTICAL_SPACING; s_ingame.addbots.generic.type = MTYPE_PTEXT; s_ingame.addbots.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; s_ingame.addbots.generic.x = 320; s_ingame.addbots.generic.y = y; s_ingame.addbots.generic.id = ID_ADDBOTS; s_ingame.addbots.generic.callback = InGame_Event; s_ingame.addbots.string = "ADD BOTS"; s_ingame.addbots.color = color_red; s_ingame.addbots.style = UI_CENTER|UI_SMALLFONT; if( !trap_Cvar_VariableValue( "sv_running" ) || !trap_Cvar_VariableValue( "bot_enable" ) || (trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER)) { s_ingame.addbots.generic.flags |= QMF_GRAYED; } y += INGAME_MENU_VERTICAL_SPACING; s_ingame.removebots.generic.type = MTYPE_PTEXT; s_ingame.removebots.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; s_ingame.removebots.generic.x = 320; s_ingame.removebots.generic.y = y; s_ingame.removebots.generic.id = ID_REMOVEBOTS; s_ingame.removebots.generic.callback = InGame_Event; s_ingame.removebots.string = "REMOVE BOTS"; s_ingame.removebots.color = color_red; s_ingame.removebots.style = UI_CENTER|UI_SMALLFONT; if( !trap_Cvar_VariableValue( "sv_running" ) || !trap_Cvar_VariableValue( "bot_enable" ) || (trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER)) { s_ingame.removebots.generic.flags |= QMF_GRAYED; } y += INGAME_MENU_VERTICAL_SPACING; s_ingame.teamorders.generic.type = MTYPE_PTEXT; s_ingame.teamorders.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; s_ingame.teamorders.generic.x = 320; s_ingame.teamorders.generic.y = y; s_ingame.teamorders.generic.id = ID_TEAMORDERS; s_ingame.teamorders.generic.callback = InGame_Event; s_ingame.teamorders.string = "TEAM ORDERS"; s_ingame.teamorders.color = color_red; s_ingame.teamorders.style = UI_CENTER|UI_SMALLFONT; if( !(trap_Cvar_VariableValue( "g_gametype" ) >= GT_TEAM) ) { s_ingame.teamorders.generic.flags |= QMF_GRAYED; } else { trap_GetClientState( &cs ); trap_GetConfigString( CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING ); team = atoi( Info_ValueForKey( info, "t" ) ); if( team == TEAM_SPECTATOR ) { s_ingame.teamorders.generic.flags |= QMF_GRAYED; } } y += INGAME_MENU_VERTICAL_SPACING; s_ingame.setup.generic.type = MTYPE_PTEXT; s_ingame.setup.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; s_ingame.setup.generic.x = 320; s_ingame.setup.generic.y = y; s_ingame.setup.generic.id = ID_SETUP; s_ingame.setup.generic.callback = InGame_Event; s_ingame.setup.string = "SETUP"; s_ingame.setup.color = color_red; s_ingame.setup.style = UI_CENTER|UI_SMALLFONT; y += INGAME_MENU_VERTICAL_SPACING; s_ingame.server.generic.type = MTYPE_PTEXT; s_ingame.server.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; s_ingame.server.generic.x = 320; s_ingame.server.generic.y = y; s_ingame.server.generic.id = ID_SERVERINFO; s_ingame.server.generic.callback = InGame_Event; s_ingame.server.string = "SERVER INFO"; s_ingame.server.color = color_red; s_ingame.server.style = UI_CENTER|UI_SMALLFONT; y += INGAME_MENU_VERTICAL_SPACING; s_ingame.restart.generic.type = MTYPE_PTEXT; s_ingame.restart.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; s_ingame.restart.generic.x = 320; s_ingame.restart.generic.y = y; s_ingame.restart.generic.id = ID_RESTART; s_ingame.restart.generic.callback = InGame_Event; s_ingame.restart.string = "RESTART ARENA"; s_ingame.restart.color = color_red; s_ingame.restart.style = UI_CENTER|UI_SMALLFONT; if( !trap_Cvar_VariableValue( "sv_running" ) ) { s_ingame.restart.generic.flags |= QMF_GRAYED; } y += INGAME_MENU_VERTICAL_SPACING; s_ingame.resume.generic.type = MTYPE_PTEXT; s_ingame.resume.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; s_ingame.resume.generic.x = 320; s_ingame.resume.generic.y = y; s_ingame.resume.generic.id = ID_RESUME; s_ingame.resume.generic.callback = InGame_Event; s_ingame.resume.string = "RESUME GAME"; s_ingame.resume.color = color_red; s_ingame.resume.style = UI_CENTER|UI_SMALLFONT; y += INGAME_MENU_VERTICAL_SPACING; s_ingame.leave.generic.type = MTYPE_PTEXT; s_ingame.leave.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; s_ingame.leave.generic.x = 320; s_ingame.leave.generic.y = y; s_ingame.leave.generic.id = ID_LEAVEARENA; s_ingame.leave.generic.callback = InGame_Event; s_ingame.leave.string = "LEAVE ARENA"; s_ingame.leave.color = color_red; s_ingame.leave.style = UI_CENTER|UI_SMALLFONT; y += INGAME_MENU_VERTICAL_SPACING; s_ingame.quit.generic.type = MTYPE_PTEXT; s_ingame.quit.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; s_ingame.quit.generic.x = 320; s_ingame.quit.generic.y = y; s_ingame.quit.generic.id = ID_QUIT; s_ingame.quit.generic.callback = InGame_Event; s_ingame.quit.string = "EXIT GAME"; s_ingame.quit.color = color_red; s_ingame.quit.style = UI_CENTER|UI_SMALLFONT; Menu_AddItem( &s_ingame.menu, &s_ingame.frame ); Menu_AddItem( &s_ingame.menu, &s_ingame.slugrock ); Menu_AddItem( &s_ingame.menu, &s_ingame.team ); Menu_AddItem( &s_ingame.menu, &s_ingame.addbots ); Menu_AddItem( &s_ingame.menu, &s_ingame.removebots ); Menu_AddItem( &s_ingame.menu, &s_ingame.teamorders ); Menu_AddItem( &s_ingame.menu, &s_ingame.setup ); Menu_AddItem( &s_ingame.menu, &s_ingame.slugrock ); Menu_AddItem( &s_ingame.menu, &s_ingame.server ); Menu_AddItem( &s_ingame.menu, &s_ingame.restart ); Menu_AddItem( &s_ingame.menu, &s_ingame.resume ); Menu_AddItem( &s_ingame.menu, &s_ingame.leave ); Menu_AddItem( &s_ingame.menu, &s_ingame.quit ); }
static void UI_AddBotsMenu_Init( void ) { int n; int y; int gametype; int count; char info[MAX_INFO_STRING]; trap_GetConfigString(CS_SERVERINFO, info, MAX_INFO_STRING); gametype = atoi( Info_ValueForKey( info,"g_gametype" ) ); memset( &addBotsMenuInfo, 0 ,sizeof(addBotsMenuInfo) ); addBotsMenuInfo.menu.draw = UI_AddBotsMenu_Draw; addBotsMenuInfo.menu.fullscreen = qfalse; addBotsMenuInfo.menu.wrapAround = qtrue; addBotsMenuInfo.delay = 1000; UI_AddBots_Cache(); addBotsMenuInfo.numBots = UI_GetNumBots(); count = addBotsMenuInfo.numBots < 7 ? addBotsMenuInfo.numBots : 7; addBotsMenuInfo.arrows.generic.type = MTYPE_BITMAP; addBotsMenuInfo.arrows.generic.name = ART_ARROWS; addBotsMenuInfo.arrows.generic.flags = QMF_INACTIVE; addBotsMenuInfo.arrows.generic.x = 200; addBotsMenuInfo.arrows.generic.y = 128; addBotsMenuInfo.arrows.width = 64; addBotsMenuInfo.arrows.height = 128; addBotsMenuInfo.up.generic.type = MTYPE_BITMAP; addBotsMenuInfo.up.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; addBotsMenuInfo.up.generic.x = 200; addBotsMenuInfo.up.generic.y = 128; addBotsMenuInfo.up.generic.id = ID_UP; addBotsMenuInfo.up.generic.callback = UI_AddBotsMenu_UpEvent; addBotsMenuInfo.up.width = 64; addBotsMenuInfo.up.height = 64; addBotsMenuInfo.up.focuspic = ART_ARROWUP; addBotsMenuInfo.down.generic.type = MTYPE_BITMAP; addBotsMenuInfo.down.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; addBotsMenuInfo.down.generic.x = 200; addBotsMenuInfo.down.generic.y = 128+64; addBotsMenuInfo.down.generic.id = ID_DOWN; addBotsMenuInfo.down.generic.callback = UI_AddBotsMenu_DownEvent; addBotsMenuInfo.down.width = 64; addBotsMenuInfo.down.height = 64; addBotsMenuInfo.down.focuspic = ART_ARROWDOWN; for( n = 0, y = 120; n < count; n++, y += 20 ) { addBotsMenuInfo.bots[n].generic.type = MTYPE_PTEXT; addBotsMenuInfo.bots[n].generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; addBotsMenuInfo.bots[n].generic.id = ID_BOTNAME0 + n; addBotsMenuInfo.bots[n].generic.x = 320 - 56; addBotsMenuInfo.bots[n].generic.y = y; addBotsMenuInfo.bots[n].generic.callback = UI_AddBotsMenu_BotEvent; addBotsMenuInfo.bots[n].string = addBotsMenuInfo.botnames[n]; addBotsMenuInfo.bots[n].color = color_orange; addBotsMenuInfo.bots[n].style = UI_LEFT|UI_SMALLFONT; } y += 12; addBotsMenuInfo.skill.generic.type = MTYPE_SPINCONTROL; addBotsMenuInfo.skill.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; addBotsMenuInfo.skill.generic.x = 320; addBotsMenuInfo.skill.generic.y = y; addBotsMenuInfo.skill.generic.name = "Skill:"; addBotsMenuInfo.skill.generic.id = ID_SKILL; addBotsMenuInfo.skill.itemnames = skillNames; addBotsMenuInfo.skill.curvalue = Com_Clamp( 0, 4, (int)trap_Cvar_VariableValue( "g_spSkill" ) - 1 ); y += SMALLCHAR_HEIGHT; addBotsMenuInfo.team.generic.type = MTYPE_SPINCONTROL; addBotsMenuInfo.team.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; addBotsMenuInfo.team.generic.x = 320; addBotsMenuInfo.team.generic.y = y; addBotsMenuInfo.team.generic.name = "Team: "; addBotsMenuInfo.team.generic.id = ID_TEAM; if( gametype >= GT_TEAM ) { addBotsMenuInfo.team.itemnames = teamNames2; } else { addBotsMenuInfo.team.itemnames = teamNames1; addBotsMenuInfo.team.generic.flags = QMF_GRAYED; } addBotsMenuInfo.go.generic.type = MTYPE_BITMAP; addBotsMenuInfo.go.generic.name = ART_FIGHT0; addBotsMenuInfo.go.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; addBotsMenuInfo.go.generic.id = ID_GO; addBotsMenuInfo.go.generic.callback = UI_AddBotsMenu_FightEvent; addBotsMenuInfo.go.generic.x = 320+128-128; addBotsMenuInfo.go.generic.y = 256+128-64; addBotsMenuInfo.go.width = 128; addBotsMenuInfo.go.height = 64; addBotsMenuInfo.go.focuspic = ART_FIGHT1; addBotsMenuInfo.back.generic.type = MTYPE_BITMAP; addBotsMenuInfo.back.generic.name = ART_BACK0; addBotsMenuInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; addBotsMenuInfo.back.generic.id = ID_BACK; addBotsMenuInfo.back.generic.callback = UI_AddBotsMenu_BackEvent; addBotsMenuInfo.back.generic.x = 320-128; addBotsMenuInfo.back.generic.y = 256+128-64; addBotsMenuInfo.back.width = 128; addBotsMenuInfo.back.height = 64; addBotsMenuInfo.back.focuspic = ART_BACK1; addBotsMenuInfo.baseBotNum = 0; addBotsMenuInfo.selectedBotNum = 0; addBotsMenuInfo.bots[0].color = color_white; UI_AddBotsMenu_GetSortedBotNums(); UI_AddBotsMenu_SetBotNames(); Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.arrows ); Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.up ); Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.down ); for( n = 0; n < count; n++ ) { Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.bots[n] ); } Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.skill ); Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.team ); Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.go ); Menu_AddItem( &addBotsMenuInfo.menu, &addBotsMenuInfo.back ); }