X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fg_world.qc;h=acf820803c36d502299e43659e78da0574565ac4;hp=01cbc54ab4fadc55f04f1725a7fc1b20a6366622;hb=7587f761ea3fafc4a91425cc044124d0d08709b6;hpb=4fcf581481915710392bf4373a8c2852ff9d7308 diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 01cbc54ab..acf820803 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -44,9 +44,9 @@ float world_initialized; string GetMapname(); string GetGametype(); -void GotoNextMap(); +void GotoNextMap(float reinit); void ShuffleMaplist() -float() DoNextMapOverride; +float(float reinit) DoNextMapOverride; void SetDefaultAlpha() { @@ -95,83 +95,6 @@ void fteqcc_testbugs() world.cnt = 0; } -/** - * Takes care of pausing and unpausing the game. - * Centerprints the information about an upcoming or active timeout to all active - * players. Also plays reminder sounds. - */ -void timeoutHandler_Think() { - entity plr; - if (timeoutStatus == 1) { - if (remainingLeadTime > 0) { - //centerprint the information to every player - FOR_EACH_REALCLIENT(plr) { - if(plr.classname == "player") { - Send_CSQC_Centerprint_Generic(plr, CPID_TIMEOUT_COUNTDOWN, "Timeout begins in %d seconds!", 1, remainingLeadTime); - } - } - remainingLeadTime -= 1; - //think again in 1 second: - self.nextthink = time + 1; - } - else { - //now pause the game: - timeoutStatus = 2; - //reset all the flood variables - FOR_EACH_CLIENT(plr) { - plr.nickspamcount = plr.nickspamtime = plr.floodcontrol_chat = plr.floodcontrol_chatteam = plr.floodcontrol_chattell = plr.floodcontrol_voice = plr.floodcontrol_voiceteam = 0; - } - cvar_set("slowmo", ftos(TIMEOUT_SLOWMO_VALUE)); - //copy .v_angle to .lastV_angle for every player in order to fix their view during pause (see PlayerPreThink) - FOR_EACH_REALPLAYER(plr) { - plr.lastV_angle = plr.v_angle; - } - self.nextthink = time; - } - } - else if (timeoutStatus == 2) { - if (remainingTimeoutTime > 0) { - FOR_EACH_REALCLIENT(plr) { - if(plr.classname == "player") { - Send_CSQC_Centerprint_Generic(plr, CPID_TIMEOUT_COUNTDOWN, "Timeout ends in %d seconds!", 1, remainingTimeoutTime); - } - } - if(remainingTimeoutTime == autocvar_sv_timeout_resumetime) { //play a warning sound when only seconds are left - Announce("prepareforbattle"); - } - remainingTimeoutTime -= 1; - self.nextthink = time + TIMEOUT_SLOWMO_VALUE; - } - else { - //unpause the game again - remainingTimeoutTime = timeoutStatus = 0; - cvar_set("slowmo", ftos(orig_slowmo)); - //and unlock the fixed view again once there is no timeout active anymore - FOR_EACH_REALPLAYER(plr) { - plr.fixangle = FALSE; - } - //get rid of the countdown message - FOR_EACH_REALCLIENT(plr) { - if(plr.classname == "player") { - Send_CSQC_Centerprint_Generic_Expire(plr, CPID_TIMEOUT_COUNTDOWN); - } - } - remove(self); - return; - } - - } - else if (timeoutStatus == 0) { //if a player called the resumegame command (which set timeoutStatus to 0 already) - FOR_EACH_REALCLIENT(plr) { - if(plr.classname == "player") { - Send_CSQC_Centerprint_Generic_Expire(plr, CPID_TIMEOUT_COUNTDOWN); - } - } - remove(self); - return; - } -} - void GotoFirstMap() { float n; @@ -189,8 +112,8 @@ void GotoFirstMap() MapInfo_Enumerate(); MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0); - if(!DoNextMapOverride()) - GotoNextMap(); + if(!DoNextMapOverride(1)) + GotoNextMap(1); return; } @@ -297,11 +220,12 @@ void cvar_changes_init() BADPREFIX("g_ban_"); BADPREFIX("g_banned_list"); BADPREFIX("g_chat_flood_"); + BADPREFIX("g_ghost_items"); BADPREFIX("g_playerstats_"); + BADPREFIX("g_respawn_ghosts"); BADPREFIX("g_voice_flood_"); BADPREFIX("rcon_"); - BADPREFIX("settemp_"); - BADPREFIX("sv_allowdownloads_"); + BADPREFIX("sv_allowdownloads"); BADPREFIX("sv_autodemo"); BADPREFIX("sv_curl_"); BADPREFIX("sv_eventlog"); @@ -371,13 +295,13 @@ void cvar_changes_init() BADCVAR("g_balance_kill_delay"); BADCVAR("g_ca_point_leadlimit"); BADCVAR("g_ctf_captimerecord_always"); - BADCVAR("g_ctf_capture_leadlimit"); BADCVAR("g_ctf_flag_capture_effects"); BADCVAR("g_ctf_flag_glowtrails"); BADCVAR("g_ctf_flag_pickup_effects"); BADCVAR("g_domination_point_leadlimit"); BADCVAR("g_forced_respawn"); BADCVAR("g_keyhunt_point_leadlimit"); + BADPREFIX("g_mod_"); BADCVAR("g_nexball_goalleadlimit"); BADCVAR("g_runematch_point_leadlimit"); BADCVAR("leadlimit_and_fraglimit"); @@ -385,7 +309,9 @@ void cvar_changes_init() BADCVAR("pausable"); BADCVAR("sv_allow_fullbright"); BADCVAR("sv_checkforpacketsduringsleep"); + BADCVAR("sv_fraginfo"); BADCVAR("sv_timeout"); + BADPREFIX("sv_timeout_"); BADCVAR("welcome_message_time"); BADPREFIX("crypto_"); BADPREFIX("g_chat_"); @@ -425,9 +351,7 @@ void cvar_changes_init() BADCVAR("g_balance_teams_force"); BADCVAR("g_ban_sync_trusted_servers"); BADCVAR("g_ban_sync_uri"); - BADCVAR("g_ctf_capture_limit"); BADCVAR("g_ctf_ignore_frags"); - BADCVAR("g_ctf_win_mode"); BADCVAR("g_domination_point_limit"); BADCVAR("g_friendlyfire"); BADCVAR("g_fullbrightitems"); @@ -487,6 +411,7 @@ void cvar_changes_init() BADCVAR("sys_ticrate"); BADCVAR("teamplay_mode"); BADCVAR("timelimit_override"); + BADCVAR("g_spawnshieldtime"); BADPREFIX("g_warmup_"); BADPREFIX("sv_ready_restart_"); @@ -608,6 +533,10 @@ void spawnfunc___init_dedicated_server(void) self.classname = "worldspawn"; // safeguard against various stuff ;) + // needs to be done so early because of the constants they create + RegisterWeapons(); + RegisterGametypes(); + MapInfo_Enumerate(); MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0); } @@ -651,8 +580,9 @@ void spawnfunc_worldspawn (void) head = nextent(head); } - // needs to be done so early as they would still spawn + // needs to be done so early because of the constants they create RegisterWeapons(); + RegisterGametypes(); ServerProgsDB = db_load(strcat("server.db", autocvar_sessionid)); @@ -843,6 +773,7 @@ void spawnfunc_worldspawn (void) addstat(STAT_STRENGTH_FINISHED, AS_FLOAT, strength_finished); addstat(STAT_INVINCIBLE_FINISHED, AS_FLOAT, invincible_finished); + addstat(STAT_SUPERWEAPONS_FINISHED, AS_FLOAT, superweapons_finished); addstat(STAT_PRESSED_KEYS, AS_FLOAT, pressedkeys); addstat(STAT_FUEL, AS_INT, ammo_fuel); addstat(STAT_SHOTORG, AS_INT, stat_shotorg); @@ -885,7 +816,8 @@ void spawnfunc_worldspawn (void) next_pingtime = time + 5; detect_maptype(); - + + // set up information replies for clients and server to use lsmaps_reply = "^7Maps available: "; lsnewmaps_reply = "^7Maps without a record set: "; for(i = 0, j = 0; i < MapInfo_count; ++i) @@ -897,18 +829,20 @@ void spawnfunc_worldspawn (void) col = "^2"; else col = "^3"; + ++j; + lsmaps_reply = strcat(lsmaps_reply, col, MapInfo_Map_bspname, " "); + if(g_race && !stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, RACE_RECORD, "time")))) lsnewmaps_reply = strcat(lsnewmaps_reply, col, MapInfo_Map_bspname, " "); else if(g_cts && !stof(db_get(ServerProgsDB, strcat(MapInfo_Map_bspname, CTS_RECORD, "time")))) lsnewmaps_reply = strcat(lsnewmaps_reply, col, MapInfo_Map_bspname, " "); } } + lsmaps_reply = strzone(strcat(lsmaps_reply, "\n")); - if (!g_race && !g_cts) - lsnewmaps_reply = "Need to be playing race or CTS for lsnewmaps to work."; - lsnewmaps_reply = strzone(strcat(lsnewmaps_reply, "\n")); + lsnewmaps_reply = strzone(strcat(((!g_race && !g_cts) ? "Need to be playing race or CTS for lsnewmaps to work." : lsnewmaps_reply), "\n")); maplist_reply = "^7Maps in list: "; n = tokenize_console(autocvar_g_maplist); @@ -931,11 +865,12 @@ void spawnfunc_worldspawn (void) { records_reply[i] = strzone(getrecords(i)); } - if(g_cts) - ladder_reply = strzone(getladder()); + + ladder_reply = strzone(getladder()); rankings_reply = strzone(getrankings()); + // begin other init ClientInit_Spawn(); RandomSeed_Spawn(); PingPLReport_Spawn(); @@ -974,6 +909,22 @@ void spawnfunc_worldspawn (void) PlayerStats_Init(); + modname = "Xonotic"; + // weird mutators that deserve to count as mod + if(autocvar_g_minstagib) + modname = "MinstaGib"; + // weird game types that deserve to count as mod + if(g_cts) + modname = "CTS"; + // physics/balance/config changes that count as mod + if(cvar_string("g_mod_physics") != cvar_defstring("g_mod_physics")) + modname = cvar_string("g_mod_physics"); + if(cvar_string("g_mod_balance") != cvar_defstring("g_mod_balance")) + modname = cvar_string("g_mod_balance"); + if(cvar_string("g_mod_config") != cvar_defstring("g_mod_config")) + modname = cvar_string("g_mod_config"); + modname = strzone(modname); + world_initialized = 1; } @@ -985,7 +936,7 @@ void spawnfunc_light (void) string GetGametype() { - return GametypeNameFromType(game); + return MapInfo_Type_ToString(MapInfo_LoadedGametype); } string getmapname_stored; @@ -1133,16 +1084,9 @@ void Map_Goto_SetFloat(float position) Map_Goto_SetStr(argv(position)); } -void GameResetCfg() -{ - // settings persist, except... - localcmd("\nsettemp_restore\n"); -} - -void Map_Goto() +void Map_Goto(float reinit) { - GameResetCfg(); - MapInfo_LoadMap(getmapname_stored); + MapInfo_LoadMap(getmapname_stored, reinit); } // return codes of map selectors: @@ -1278,7 +1222,7 @@ string GetNextMap() return ""; } -float DoNextMapOverride() +float DoNextMapOverride(float reinit) { if(autocvar_g_campaign) { @@ -1311,21 +1255,21 @@ float DoNextMapOverride() if(MapInfo_CheckMap(autocvar_nextmap)) { Map_Goto_SetStr(autocvar_nextmap); - Map_Goto(); + Map_Goto(reinit); alreadychangedlevel = TRUE; return TRUE; } if(autocvar_lastlevel) { - GameResetCfg(); - localcmd("set lastlevel 0\ntogglemenu\n"); + cvar_settemp_restore(); + localcmd("set lastlevel 0\ntogglemenu 1\n"); alreadychangedlevel = TRUE; return TRUE; } return FALSE; } -void GotoNextMap() +void GotoNextMap(float reinit) { //string nextmap; //float n, nummaps; @@ -1357,7 +1301,7 @@ void GotoNextMap() error("Everything is broken - not even the default map list works. Please report this to the developers."); } } - Map_Goto(); + Map_Goto(reinit); } } @@ -1376,12 +1320,15 @@ float mapvote_initialized; void IntermissionThink() { FixIntermissionClient(self); - - if( (autocvar_sv_autoscreenshot || self.cvar_cl_autoscreenshot) + + float server_screenshot = (autocvar_sv_autoscreenshot && self.cvar_cl_autoscreenshot); + float client_screenshot = (self.cvar_cl_autoscreenshot == 2); + + if( (server_screenshot || client_screenshot) && ((self.autoscreenshot > 0) && (time > self.autoscreenshot)) ) { self.autoscreenshot = -1; - if(clienttype(self) == CLIENTTYPE_REAL) { stuffcmd(self, sprintf("\nautoscreenshot \"%s\" \"%s\"\n", GetMapname(), strftime(FALSE, "%s"))); } + if(clienttype(self) == CLIENTTYPE_REAL) { stuffcmd(self, sprintf("\nscreenshot screenshots/autoscreenshot/%s-%s.jpg; echo \"^5A screenshot has been taken at request of the server.\"", GetMapname(), strftime(FALSE, "%s"))); } return; } @@ -2614,7 +2561,7 @@ float MapVote_Finished(float mappos) FixClientCvars(other); Map_Goto_SetStr(mapvote_maps[mappos]); - Map_Goto(); + Map_Goto(0); alreadychangedlevel = TRUE; return TRUE; } @@ -2810,11 +2757,11 @@ void MapVote_Think() } mapvote_initialized = TRUE; - if(DoNextMapOverride()) + if(DoNextMapOverride(0)) return; if(!autocvar_g_maplist_votable || player_count <= 0) { - GotoNextMap(); + GotoNextMap(0); return; } MapVote_Init(); @@ -2831,7 +2778,7 @@ string GotoMap(string m) cvar_set("timelimit", "-1"); if(mapvote_initialized || alreadychangedlevel) { - if(DoNextMapOverride()) + if(DoNextMapOverride(0)) return "Map switch initiated."; else return "Hm... no. For some reason I like THIS map more."; @@ -2941,14 +2888,11 @@ void RestoreGame() TargetMusic_RestoreGame(); } -void SV_Shutdown() +void Shutdown() { entity e; - if(gameover > 1) // shutting down already? - return; - - gameover = 2; // 2 = server shutting down + gameover = 2; if(world_initialized > 0) {