void GAME_SetMode (const cgame_export_t *gametype) { const cgame_export_t *list; if (cls.gametype == gametype) return; list = GAME_GetCurrentType(); if (list) { Com_Printf("Shutdown gametype '%s'\n", list->name); list->Shutdown(); /* we dont need to go back to "main" stack if we are already on this stack */ if (!UI_IsWindowOnStack("main")) UI_InitStack("main", "", qtrue, qtrue); } cls.gametype = gametype; CL_Disconnect(); list = GAME_GetCurrentType(); if (list) { Com_Printf("Change gametype to '%s'\n", list->name); /* inventory structure switched/initialized */ INV_DestroyInventory(&cls.i); INV_InitInventory(list->name, &cls.i, &csi, &inventoryImport); /** @todo this should be in GetCGameAPI */ list->Init(NULL); } }
static qboolean GAME_Spawn (void) { const size_t size = GAME_GetCharacterArraySize(); int i; /* If there is no active gametype we create a team with default values. * This is e.g. the case when someone starts a map with the map command */ if (GAME_GetCurrentType() == NULL || chrDisplayList.num == 0) { const char *teamDefID = GAME_GetTeamDef(); const equipDef_t *ed = INV_GetEquipmentDefinitionByID("multiplayer_initial"); /* inventory structure switched/initialized */ INV_DestroyInventory(&cls.i); INV_InitInventory("client", &cls.i, &csi, &inventoryImport); GAME_GenerateTeam(teamDefID, ed, size); } for (i = 0; i < size; i++) cl.chrList.chr[i] = chrDisplayList.chr[i]; cl.chrList.num = chrDisplayList.num; return qtrue; }
static inline void ResetInventoryList (void) { INV_DestroyInventory(&i); INV_InitInventory("test", &i, &csi, &inventoryImport); }
/** * @brief This will be called when the game library is first loaded * @note only happens when a new game/map is started */ static void G_Init (void) { gi.DPrintf("==== InitGame ====\n"); /* noset vars */ sv_dedicated = gi.Cvar_Get("sv_dedicated", "0", CVAR_SERVERINFO | CVAR_NOSET, "Is this a dedicated server?"); /* latched vars */ sv_cheats = gi.Cvar_Get("sv_cheats", "0", CVAR_SERVERINFO | CVAR_LATCH, "Activate cheats"); gi.Cvar_Get("gamename", GAMEVERSION, CVAR_SERVERINFO | CVAR_LATCH, NULL); gi.Cvar_Get("gamedate", __DATE__, CVAR_SERVERINFO | CVAR_LATCH, NULL); developer = gi.Cvar_Get("developer", "0", 0, "Print out a lot of developer debug messages - useful to track down bugs"); logstats = gi.Cvar_Get("logstats", "1", CVAR_ARCHIVE, "Server logfile output for kills"); /* max. players per team (original quake) */ sv_maxplayersperteam = gi.Cvar_Get("sv_maxplayersperteam", "8", CVAR_SERVERINFO | CVAR_LATCH, "How many players (humans) may a team have"); /* max. soldiers per team */ sv_maxsoldiersperteam = gi.Cvar_Get("sv_maxsoldiersperteam", "4", CVAR_ARCHIVE | CVAR_SERVERINFO | CVAR_LATCH, "How many soldiers may one team have"); /* max soldiers per player */ sv_maxsoldiersperplayer = gi.Cvar_Get("sv_maxsoldiersperplayer", STRINGIFY(MAX_ACTIVETEAM), CVAR_ARCHIVE | CVAR_SERVERINFO | CVAR_LATCH, "How many soldiers one player is able to control in a given team"); /* enable moralestates in multiplayer */ sv_enablemorale = gi.Cvar_Get("sv_enablemorale", "1", CVAR_ARCHIVE | CVAR_SERVERINFO | CVAR_LATCH, "Enable morale behaviour for actors"); sv_roundtimelimit = gi.Cvar_Get("sv_roundtimelimit", "90", CVAR_ARCHIVE | CVAR_SERVERINFO, "Timelimit in seconds for multiplayer rounds"); sv_roundtimelimit->modified = false; sv_maxentities = gi.Cvar_Get("sv_maxentities", "1024", CVAR_LATCH, NULL); sv_maxteams = gi.Cvar_Get("sv_maxteams", "2", CVAR_SERVERINFO, "How many teams for current running map"); sv_maxteams->modified = false; /* change anytime vars */ password = gi.Cvar_Get("password", "", CVAR_USERINFO, NULL); sv_needpass = gi.Cvar_Get("sv_needpass", "0", CVAR_SERVERINFO, NULL); sv_filterban = gi.Cvar_Get("sv_filterban", "1", 0, NULL); sv_ai = gi.Cvar_Get("sv_ai", "1", 0, "Activate or deativate the ai"); sv_teamplay = gi.Cvar_Get("sv_teamplay", "0", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SERVERINFO, "Is teamplay activated? see sv_maxclients, sv_maxplayersperteam, sv_maxsoldiersperteam and sv_maxsoldiersperplayer"); /* how many connected clients */ sv_maxclients = gi.Cvar_Get("sv_maxclients", "1", CVAR_SERVERINFO, "If sv_maxclients is 1 we are in singleplayer - otherwise we are mutliplayer mode (see sv_teamplay)"); sv_shot_origin = gi.Cvar_Get("sv_shot_origin", "8", 0, "Assumed distance of muzzle from model"); sv_send_edicts = gi.Cvar_Get("sv_send_edicts", "0", CVAR_ARCHIVE | CVAR_CHEAT, "Send server side edicts for client display like triggers"); sv_hurtaliens = gi.Cvar_Get("sv_hurtaliens", "0", CVAR_SERVERINFO, "Spawn hurt aliens"); ai_alien = gi.Cvar_Get("ai_alien", "ortnok", 0, "Alien team"); ai_civilian = gi.Cvar_Get("ai_civilian", "europe", 0, "Civilian team"); /* this cvar is set in singleplayer via campaign definition */ ai_equipment = gi.Cvar_Get("ai_equipment", "multiplayer_alien", 0, "Initial equipment definition for aliens"); /* aliens in singleplayer (can differ each mission) */ ai_numaliens = gi.Cvar_Get("ai_numaliens", "30", 0, "How many aliens in this battle (singleplayer)"); /* civilians for singleplayer */ ai_numcivilians = gi.Cvar_Get("ai_numcivilians", "10", 0, "How many civilians in this battle"); /* aliens in multiplayer */ ai_numactors = gi.Cvar_Get("ai_numactors", "8", CVAR_ARCHIVE, "How many (ai controlled) actors in this battle (multiplayer)"); mob_death = gi.Cvar_Get("mob_death", "10", CVAR_LATCH|CVAR_NOSET, NULL); mob_wound = gi.Cvar_Get("mob_wound", "0.1", CVAR_LATCH|CVAR_NOSET, NULL); mof_watching = gi.Cvar_Get("mof_watching", "1.7", CVAR_LATCH|CVAR_NOSET, NULL); mof_teamkill = gi.Cvar_Get("mof_teamkill", "2.0", CVAR_LATCH|CVAR_NOSET, NULL); mof_civilian = gi.Cvar_Get("mof_civilian", "0.3", CVAR_LATCH|CVAR_NOSET, NULL); mof_enemy = gi.Cvar_Get("mof_ememy", "0.5", CVAR_LATCH|CVAR_NOSET, NULL); mor_pain = gi.Cvar_Get("mof_pain", "3.6", CVAR_LATCH|CVAR_NOSET, NULL); /* everyone gets this times morale damage */ mor_default = gi.Cvar_Get("mor_default", "0.3", CVAR_LATCH|CVAR_NOSET, "Everyone gets this times morale damage"); /* at this distance the following two get halved (exponential scale) */ mor_distance = gi.Cvar_Get("mor_distance", "120", CVAR_LATCH|CVAR_NOSET, "At this distance the following two get halved (exponential scale)"); /* at this distance the following two get halved (exponential scale) */ mor_victim = gi.Cvar_Get("mor_victim", "0.7", CVAR_LATCH|CVAR_NOSET, "At this distance the following two get halved (exponential scale)"); /* at this distance the following two get halved (exponential scale) */ mor_attacker = gi.Cvar_Get("mor_attacker", "0.3", CVAR_LATCH|CVAR_NOSET, "At this distance the following two get halved (exponential scale)"); /* how much the morale depends on the size of the damaged team */ mon_teamfactor = gi.Cvar_Get("mon_teamfactor", "0.6", CVAR_LATCH|CVAR_NOSET, "How much the morale depends on the size of the damaged team"); mor_regeneration = gi.Cvar_Get("mor_regeneration", "15", CVAR_LATCH|CVAR_NOSET, NULL); mor_shaken = gi.Cvar_Get("mor_shaken", "50", CVAR_LATCH|CVAR_NOSET, NULL); mor_panic = gi.Cvar_Get("mor_panic", "30", CVAR_LATCH|CVAR_NOSET, NULL); mor_brave = gi.Cvar_Get("mor_brave", "85", CVAR_LATCH|CVAR_NOSET, NULL); m_sanity = gi.Cvar_Get("m_sanity", "1.0", CVAR_LATCH|CVAR_NOSET, NULL); m_rage = gi.Cvar_Get("m_rage", "0.6", CVAR_LATCH|CVAR_NOSET, NULL); m_rage_stop = gi.Cvar_Get("m_rage_stop", "2.0", CVAR_LATCH|CVAR_NOSET, NULL); m_panic_stop = gi.Cvar_Get("m_panic_stop", "1.0", CVAR_LATCH|CVAR_NOSET, NULL); g_endlessaliens = gi.Cvar_Get("g_endlessaliens", "0", CVAR_LATCH|CVAR_SERVERINFO, "Spawn endless aliens"); g_ailua = gi.Cvar_Get("g_ailua", "0", 0, "Activate or deactivate the LUA AI"); g_aihumans = gi.Cvar_Get("g_aihumans", "0", CVAR_DEVELOPER, "Activate or deactivate the ai for human actors"); g_aidebug = gi.Cvar_Get("g_aidebug", "0", CVAR_DEVELOPER|CVAR_CHEAT, "All AI actors are visible"); g_drawtraces = gi.Cvar_Get("g_drawtraces", "0", CVAR_DEVELOPER, "All traces will be rendered"); g_nodamage = gi.Cvar_Get("g_nodamage", "0", CVAR_DEVELOPER|CVAR_CHEAT, "No damage in developer mode"); g_notu = gi.Cvar_Get("g_notu", "0", CVAR_DEVELOPER|CVAR_CHEAT, "No TU costs while performing any action"); g_actorspeed = gi.Cvar_Get("g_actorspeed", "1.0", CVAR_ARCHIVE|CVAR_SERVERINFO, "Moving speed of the actor"); g_lastseen = gi.Cvar_Get("g_lastseen", "20", CVAR_ARCHIVE|CVAR_SERVERINFO, "Quit the match if no player was seen in this amount of rounds"); g_nospawn = gi.Cvar_Get("g_nospawn", "0", CVAR_DEVELOPER|CVAR_CHEAT, "Do not spawn a soldier"); /* flood control */ flood_msgs = gi.Cvar_Get("flood_msgs", "4", 0, NULL); flood_persecond = gi.Cvar_Get("flood_persecond", "4", 0, NULL); flood_waitdelay = gi.Cvar_Get("flood_waitdelay", "10", 0, "Delay until someone is unlocked from talking again"); g_difficulty = gi.Cvar_Get("g_difficulty", "0", CVAR_NOSET, "Singleplayer difficulty level"); game.sv_maxentities = sv_maxentities->integer; game.sv_maxplayersperteam = sv_maxplayersperteam->integer; /* initialize the entity storage */ globals.edicts = G_EdictsInit(); globals.max_edicts = game.sv_maxentities; globals.num_edicts = game.sv_maxplayersperteam; /* initialize all players for this game */ /* game.sv_maxplayersperteam for human controlled players * + game.sv_maxplayer for ai */ game.players = (player_t *)G_TagMalloc(game.sv_maxplayersperteam * 2 * sizeof(game.players[0]), TAG_GAME); globals.players = game.players; globals.maxplayersperteam = game.sv_maxplayersperteam; /* init csi and inventory */ INVSH_InitCSI(gi.csi); INV_InitInventory("game", &game.i, gi.csi, &inventoryImport); if (logstats->integer) logstatsfile = fopen(va("%s/stats.log", gi.FS_Gamedir()), "a"); else logstatsfile = NULL; AI_Init(); AIL_Init(); }
static inline void ResetInventoryList (void) { INV_DestroyInventory(&cls.i); INV_InitInventory("testCampaign", &cls.i, &csi, &inventoryImport); }