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=8ce4ebdae08e669358a80fbe70b872eba5825f23;hb=7587f761ea3fafc4a91425cc044124d0d08709b6;hpb=6247d490047631d05b4e1eba9590fcc1a8cce5aa diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 8ce4ebdae..acf820803 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -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; @@ -302,7 +225,6 @@ void cvar_changes_init() BADPREFIX("g_respawn_ghosts"); BADPREFIX("g_voice_flood_"); BADPREFIX("rcon_"); - BADPREFIX("settemp_"); BADPREFIX("sv_allowdownloads"); BADPREFIX("sv_autodemo"); BADPREFIX("sv_curl_"); @@ -373,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"); @@ -387,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_"); @@ -427,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"); @@ -489,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_"); @@ -610,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); } @@ -653,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)); @@ -845,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); @@ -887,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) @@ -899,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); @@ -933,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(); @@ -976,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; } @@ -987,7 +936,7 @@ void spawnfunc_light (void) string GetGametype() { - return GametypeNameFromType(game); + return MapInfo_Type_ToString(MapInfo_LoadedGametype); } string getmapname_stored; @@ -1135,15 +1084,8 @@ void Map_Goto_SetFloat(float position) Map_Goto_SetStr(argv(position)); } -void GameResetCfg() -{ - // settings persist, except... - localcmd("\nsettemp_restore\n"); -} - void Map_Goto(float reinit) { - GameResetCfg(); MapInfo_LoadMap(getmapname_stored, reinit); } @@ -1319,8 +1261,8 @@ float DoNextMapOverride(float reinit) } if(autocvar_lastlevel) { - GameResetCfg(); - localcmd("set lastlevel 0\ntogglemenu\n"); + cvar_settemp_restore(); + localcmd("set lastlevel 0\ntogglemenu 1\n"); alreadychangedlevel = TRUE; return TRUE; } @@ -1378,13 +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, "\nscreenshot\necho \"^5A screenshot has been taken at request of the server.\"\n"); + 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; } @@ -2052,7 +1996,6 @@ float WinningCondition_Race(float fraglimit) return wc; } -void ReadyRestart(); float WinningCondition_QualifyingThenRace(float limit) { float wc; @@ -2142,6 +2085,7 @@ CheckRules_World Exit deathmatch games upon conditions ============ */ +void ReadyRestart(); void CheckRules_World() { float timelimit; @@ -2338,7 +2282,7 @@ float mapvote_maps_suggested[MAPVOTE_COUNT]; string mapvote_suggestions[MAPVOTE_COUNT]; float mapvote_suggestion_ptr; float mapvote_voters; -float mapvote_votes[MAPVOTE_COUNT]; +float mapvote_selections[MAPVOTE_COUNT]; float mapvote_run; float mapvote_detail; float mapvote_abstain; @@ -2495,20 +2439,6 @@ void MapVote_SendPicture(float id) WritePicture(MSG_ONE, strcat(mapvote_screenshot_dirs[mapvote_maps_screenshot_dir[id]], "/", mapvote_maps[id]), 3072); } -float GameCommand_MapVote(string cmd) -{ - if(!intermission_running) - return FALSE; - - if(cmd == "mv_getpic") - { - MapVote_SendPicture(stof(argv(1))); - return TRUE; - } - - return FALSE; -} - float MapVote_GetMapMask() { float mask, i, power; @@ -2576,7 +2506,7 @@ float MapVote_SendEntity(entity to, float sf) if(mapvote_detail) for(i = 0; i < mapvote_count; ++i) if(mapvote_maps[i] != "") - WriteByte(MSG_ENTITY, mapvote_votes[i]); + WriteByte(MSG_ENTITY, mapvote_selections[i]); WriteByte(MSG_ENTITY, to.mapvote); } @@ -2608,16 +2538,16 @@ float MapVote_Finished(float mappos) if(autocvar_sv_eventlog) { result = strcat(":vote:finished:", mapvote_maps[mappos]); - result = strcat(result, ":", ftos(mapvote_votes[mappos]), "::"); + result = strcat(result, ":", ftos(mapvote_selections[mappos]), "::"); didntvote = mapvote_voters; for(i = 0; i < mapvote_count; ++i) if(mapvote_maps[i] != "") { - didntvote -= mapvote_votes[i]; + didntvote -= mapvote_selections[i]; if(i != mappos) { result = strcat(result, ":", mapvote_maps[i]); - result = strcat(result, ":", ftos(mapvote_votes[i])); + result = strcat(result, ":", ftos(mapvote_selections[i])); } } result = strcat(result, ":didn't vote:", ftos(didntvote)); @@ -2642,7 +2572,7 @@ void MapVote_CheckRules_1() for(i = 0; i < mapvote_count; ++i) if(mapvote_maps[i] != "") { //dprint("Map ", ftos(i), ": "); dprint(mapvote_maps[i], "\n"); - mapvote_votes[i] = 0; + mapvote_selections[i] = 0; } mapvote_voters = 0; @@ -2653,7 +2583,7 @@ void MapVote_CheckRules_1() { i = other.mapvote - 1; //dprint("Player ", other.netname, " vote = ", ftos(other.mapvote - 1), "\n"); - mapvote_votes[i] = mapvote_votes[i] + 1; + mapvote_selections[i] = mapvote_selections[i] + 1; } } } @@ -2671,11 +2601,11 @@ float MapVote_CheckRules_2() mapvote_voters_real = mapvote_voters; if(mapvote_abstain) - mapvote_voters_real -= mapvote_votes[mapvote_count - 1]; + mapvote_voters_real -= mapvote_selections[mapvote_count - 1]; RandomSelection_Init(); for(i = 0; i < mapvote_count_real; ++i) if(mapvote_maps[i] != "") - RandomSelection_Add(world, i, string_null, 1, mapvote_votes[i]); + RandomSelection_Add(world, i, string_null, 1, mapvote_selections[i]); firstPlace = RandomSelection_chosen_float; firstPlaceVotes = RandomSelection_best_priority; //dprint("First place: ", ftos(firstPlace), "\n"); @@ -2684,7 +2614,7 @@ float MapVote_CheckRules_2() RandomSelection_Init(); for(i = 0; i < mapvote_count_real; ++i) if(mapvote_maps[i] != "") if(i != firstPlace) - RandomSelection_Add(world, i, string_null, 1, mapvote_votes[i]); + RandomSelection_Add(world, i, string_null, 1, mapvote_selections[i]); secondPlace = RandomSelection_chosen_float; secondPlaceVotes = RandomSelection_best_priority; //dprint("Second place: ", ftos(secondPlace), "\n"); @@ -2711,12 +2641,12 @@ float MapVote_CheckRules_2() for(i = 0; i < mapvote_count; ++i) if(mapvote_maps[i] != "") { - didntvote -= mapvote_votes[i]; + didntvote -= mapvote_selections[i]; if(i != firstPlace) if(i != secondPlace) { result = strcat(result, ":", mapvote_maps[i]); - result = strcat(result, ":", ftos(mapvote_votes[i])); + result = strcat(result, ":", ftos(mapvote_selections[i])); if(i < mapvote_count_real) { strunzone(mapvote_maps[i]); @@ -2958,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) {