]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_world.qc
havocbot_keyboard_movement is supposed to update .movement even if (time < this.havoc...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_world.qc
index 5b63aa4e0c99c3e52389d6c6bf9ae1826895aa8f..0b3783488cb7dbdc50a7d295e0a7cf2eb75fe8a9 100644 (file)
 #include "teamplay.qh"
 #include "weapons/weaponstats.qh"
 #include "../common/constants.qh"
+#include <common/net_linked.qh>
 #include "../common/deathtypes/all.qh"
 #include "../common/mapinfo.qh"
-#include "../common/monsters/all.qh"
+#include "../common/monsters/_mod.qh"
 #include "../common/monsters/sv_monsters.qh"
 #include "../common/vehicles/all.qh"
 #include "../common/notifications/all.qh"
@@ -56,9 +57,9 @@ void PingPLReport_Think(entity this)
        {
                WriteHeader(MSG_BROADCAST, TE_CSQC_PINGPLREPORT);
                WriteByte(MSG_BROADCAST, this.cnt);
-               WriteShort(MSG_BROADCAST, max(1, e.ping));
-               WriteByte(MSG_BROADCAST, ceil(e.ping_packetloss * 255));
-               WriteByte(MSG_BROADCAST, ceil(e.ping_movementloss * 255));
+               WriteShort(MSG_BROADCAST, bound(1, e.ping, 65535));
+               WriteByte(MSG_BROADCAST, min(ceil(e.ping_packetloss * 255), 255));
+               WriteByte(MSG_BROADCAST, min(ceil(e.ping_movementloss * 255), 255));
 
                // record latency times for clients throughout the match so we can report it to playerstats
                if(time > (e.latency_time + LATENCY_THINKRATE))
@@ -226,9 +227,11 @@ void cvar_changes_init()
                BADCVAR("sys_specialcharactertranslation");
                BADCVAR("timeformat");
                BADCVAR("timestamps");
+               BADCVAR("g_require_stats");
                BADPREFIX("developer_");
                BADPREFIX("g_ban_");
                BADPREFIX("g_banned_list");
+               BADPREFIX("g_require_stats_");
                BADPREFIX("g_chat_flood_");
                BADPREFIX("g_ghost_items");
                BADPREFIX("g_playerstats_");
@@ -277,6 +280,7 @@ void cvar_changes_init()
                BADCVAR("nextmap");
                BADCVAR("teamplay");
                BADCVAR("timelimit");
+               BADCVAR("g_mapinfo_ignore_warnings");
 
                // long
                BADCVAR("hostname");
@@ -320,17 +324,20 @@ void cvar_changes_init()
                BADCVAR("g_invasion_point_limit");
                BADCVAR("g_keyhunt_point_leadlimit");
                BADCVAR("g_nexball_goalleadlimit");
+               BADCVAR("g_new_toys_use_pickupsound");
+               BADCVAR("g_physics_predictall");
+               BADCVAR("g_piggyback");
                BADCVAR("g_tdm_point_leadlimit");
                BADCVAR("g_tdm_point_limit");
                BADCVAR("leadlimit_and_fraglimit");
                BADCVAR("leadlimit_override");
                BADCVAR("pausable");
-               BADCVAR("sv_allow_fullbright");
                BADCVAR("sv_checkforpacketsduringsleep");
                BADCVAR("sv_intermission_cdtrack");
                BADCVAR("sv_minigames");
                BADCVAR("sv_namechangetimer");
                BADCVAR("sv_precacheplayermodels");
+               BADCVAR("sv_stepheight");
                BADCVAR("sv_timeout");
                BADPREFIX("crypto_");
                BADPREFIX("gameversion_");
@@ -342,9 +349,11 @@ void cvar_changes_init()
                BADPREFIX("net_");
                BADPREFIX("prvm_");
                BADPREFIX("skill_");
+               BADPREFIX("sv_allow_");
                BADPREFIX("sv_cullentities_");
                BADPREFIX("sv_maxidle_");
                BADPREFIX("sv_minigames_");
+               BADPREFIX("sv_radio_");
                BADPREFIX("sv_timeout_");
                BADPREFIX("sv_vote_");
                BADPREFIX("timelimit_");
@@ -369,6 +378,7 @@ void cvar_changes_init()
                BADCVAR("g_balance_teams_scorefactor");
                BADCVAR("g_ban_sync_trusted_servers");
                BADCVAR("g_ban_sync_uri");
+               BADCVAR("g_buffs");
                BADCVAR("g_ca_teams_override");
                BADCVAR("g_ctf_ignore_frags");
                BADCVAR("g_domination_point_limit");
@@ -391,6 +401,9 @@ void cvar_changes_init()
                BADCVAR("g_maxplayers");
                BADCVAR("g_mirrordamage");
                BADCVAR("g_nexball_goallimit");
+               BADCVAR("g_norecoil");
+               BADCVAR("g_physics_clientselect");
+               BADCVAR("g_pinata");
                BADCVAR("g_powerups");
                BADCVAR("g_spawnshieldtime");
                BADCVAR("g_start_delay");
@@ -443,6 +456,7 @@ void cvar_changes_init()
                BADCVAR("g_grappling_hook");
                BADCVAR("g_jetpack");
 
+#undef BADPRESUFFIX
 #undef BADPREFIX
 #undef BADCVAR
 
@@ -555,6 +569,8 @@ spawnfunc(__init_dedicated_server)
        static_init_late();
        static_init_precache();
 
+       IL_PUSH(g_spawnpoints, e); // just incase
+
        MapInfo_Enumerate();
        MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
 }
@@ -906,7 +922,8 @@ spawnfunc(worldspawn)
        if(cvar_string("g_mod_config") != cvar_defstring("g_mod_config"))
                modname = cvar_string("g_mod_config");
        // extra mutators that deserve to count as mod
-       MUTATOR_CALLHOOK(SetModname);
+       MUTATOR_CALLHOOK(SetModname, modname);
+       modname = M_ARGV(0, string);
 
        // save it for later
        modname = strzone(modname);
@@ -1124,7 +1141,7 @@ float(float exponent) MaplistMethod_Shuffle = // more clever shuffling
                string newlist;
 
                // now reinsert this at another position
-               insertpos = pow(random(), 1 / exponent);       // ]0, 1]
+               insertpos = (random() ** (1 / exponent));       // ]0, 1]
                insertpos = insertpos * (Map_Count - 1);       // ]0, Map_Count - 1]
                insertpos = ceil(insertpos) + 1;               // {2, 3, 4, ..., Map_Count}
                LOG_TRACE("SHUFFLE: insert pos = ", ftos(insertpos));
@@ -1295,7 +1312,6 @@ When the player presses attack or jump, change to the next level
 void IntermissionThink(entity this)
 {
        FixIntermissionClient(this);
-       CSQCMODEL_AUTOUPDATE(this); // PlayerPostThink returns before calling this during intermission, so run it here
 
        float server_screenshot = (autocvar_sv_autoscreenshot && this.cvar_cl_autoscreenshot);
        float client_screenshot = (this.cvar_cl_autoscreenshot == 2);
@@ -1332,32 +1348,32 @@ entity FindIntermission()
        local   float cyc;
 
 // look for info_intermission first
-       spot = find (NULL, classname, "info_intermission");
+       spot = find(NULL, classname, "info_intermission");
        if (spot)
        {       // pick a random one
                cyc = random() * 4;
                while (cyc > 1)
                {
-                       spot = find (spot, classname, "info_intermission");
+                       spot = find(spot, classname, "info_intermission");
                        if (!spot)
-                               spot = find (spot, classname, "info_intermission");
+                               spot = find(spot, classname, "info_intermission");
                        cyc = cyc - 1;
                }
                return spot;
        }
 
 // then look for the start position
-       spot = find (NULL, classname, "info_player_start");
+       spot = find(NULL, classname, "info_player_start");
        if (spot)
                return spot;
 
 // testinfo_player_start is only found in regioned levels
-       spot = find (NULL, classname, "testplayerstart");
+       spot = find(NULL, classname, "testplayerstart");
        if (spot)
                return spot;
 
 // then look for the start position
-       spot = find (NULL, classname, "info_player_deathmatch");
+       spot = find(NULL, classname, "info_player_deathmatch");
        if (spot)
                return spot;
 
@@ -1435,11 +1451,11 @@ void DumpStats(float final)
                        s = strcat(s, "spectator:");
 
                if(to_console)
-                       LOG_INFO(s, it.netname, "\n");
+                       LOG_INFO(s, playername(it, false), "\n");
                if(to_eventlog)
-                       GameLogEcho(strcat(s, ftos(it.playerid), ":", it.netname));
+                       GameLogEcho(strcat(s, ftos(it.playerid), ":", playername(it, false)));
                if(to_file)
-                       fputs(file, strcat(s, it.netname, "\n"));
+                       fputs(file, strcat(s, playername(it, false), "\n"));
        ));
 
        if(teamplay)
@@ -1483,9 +1499,6 @@ void FixIntermissionClient(entity e)
                e.autoscreenshot = time + 0.8;  // used for autoscreenshot
                e.health = -2342;
                // first intermission phase; voting phase has positive health (used to decide whether to send SVC_FINALE or not)
-               e.solid = SOLID_NOT;
-               set_movetype(e, MOVETYPE_NONE);
-               e.takedamage = DAMAGE_NO;
                for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
                    .entity weaponentity = weaponentities[slot];
@@ -1501,7 +1514,7 @@ void FixIntermissionClient(entity e)
                        stuffcmd(e, "\nscr_printspeed 1000000\n");
                        RandomSelection_Init();
                        FOREACH_WORD(autocvar_sv_intermission_cdtrack, true, LAMBDA(
-                               RandomSelection_Add(NULL, 0, it, 1, 1);
+                               RandomSelection_AddString(it, 1, 1);
                        ));
                        if (RandomSelection_chosen_string != "")
                        {
@@ -1519,11 +1532,10 @@ only called if a time or frag limit has expired
 */
 void NextLevel()
 {
-       gameover = true;
-
-       intermission_running = 1;
+       game_stopped = true;
+       intermission_running = 1; // game over
 
-// enforce a wait time before allowing changelevel
+       // enforce a wait time before allowing changelevel
        if(player_count > 0)
                intermission_exittime = time + autocvar_sv_mapchange_delay;
        else
@@ -1556,7 +1568,7 @@ void NextLevel()
        FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
                FixIntermissionClient(it);
                if(it.winning)
-                       bprint(it.netname, " ^7wins.\n");
+                       bprint(playername(it, false), " ^7wins.\n");
        ));
 
        target_music_kill();
@@ -1578,7 +1590,7 @@ Exit deathmatch games upon conditions
 */
 void CheckRules_Player(entity this)
 {
-       if (gameover)   // someone else quit the game already
+       if (game_stopped) // someone else quit the game already
                return;
 
        if(!IS_DEAD(this))
@@ -1768,7 +1780,8 @@ float WinningCondition_RanOutOfSpawns()
                }
        ));
 
-       FOREACH_ENTITY_CLASS("info_player_deathmatch", true, LAMBDA(
+       IL_EACH(g_spawnpoints, true,
+       {
                switch(it.team)
                {
                        case NUM_TEAM_1: team1_score = 1; break;
@@ -1776,7 +1789,7 @@ float WinningCondition_RanOutOfSpawns()
                        case NUM_TEAM_3: team3_score = 1; break;
                        case NUM_TEAM_4: team4_score = 1; break;
                }
-       ));
+       });
 
        ClearWinners();
        if(team1_score + team2_score + team3_score + team4_score == 0)
@@ -1829,7 +1842,7 @@ void CheckRules_World()
 
        SetDefaultAlpha();
 
-       if (gameover)   // someone else quit the game already
+       if (intermission_running) // someone else quit the game already
        {
                if(player_count == 0) // Nobody there? Then let's go to the next map
                        MapVote_Start();
@@ -2020,16 +2033,9 @@ void Physics_Frame()
                if(IS_CLIENT(it) || it.classname == "" || it.move_movetype == MOVETYPE_PUSH || it.move_movetype == MOVETYPE_FAKEPUSH || it.move_movetype == MOVETYPE_PHYSICS)
                        continue;
 
-               int mt = it.move_movetype;
-
-               if(mt == MOVETYPE_PUSH || mt == MOVETYPE_FAKEPUSH || mt == MOVETYPE_PHYSICS)
-               {
-                       it.move_qcphysics = false;
-                       set_movetype(it, mt);
-                       continue;
-               }
-
-               set_movetype(it, ((it.move_qcphysics) ? MOVETYPE_NONE : it.move_movetype));
+               //set_movetype(it, it.move_movetype);
+               // inline the set_movetype function, since this is called a lot
+               it.movetype = (it.move_qcphysics) ? MOVETYPE_NONE : it.move_movetype;
 
                if(it.move_movetype == MOVETYPE_NONE)
                        continue;
@@ -2087,10 +2093,6 @@ void EndFrame()
        {
                antilag_record(it, it, altime);
        });
-       FOREACH_CLIENT(PS(it), {
-               PlayerState s = PS(it);
-               s.ps_push(s, it);
-       });
        systems_update();
        IL_ENDFRAME();
 }
@@ -2163,7 +2165,7 @@ void RestoreGame()
 
 void Shutdown()
 {
-       gameover = 2;
+       game_stopped = 2;
 
        if(world_initialized > 0)
        {