]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/client.qc
Merge branch 'master' into Lyberta/StandaloneOverkillWeapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / client.qc
index 1b8ee24ce72fa1f2619f414106815d4d5655c9c8..b56305b69b8d117e7a2ece7229678c588725fed8 100644 (file)
@@ -115,20 +115,18 @@ bool ClientData_Send(entity this, entity to, int sf)
        if (IS_SPEC(e)) e = e.enemy;
 
        sf = 0;
        if (IS_SPEC(e)) e = e.enemy;
 
        sf = 0;
-       if (CS(e).race_completed)       sf |= 1; // forced scoreboard
-       if (CS(to).spectatee_status)    sf |= 2; // spectator ent number follows
-       if (CS(e).zoomstate)            sf |= 4; // zoomed
-       if (autocvar_sv_showspectators) sf |= 16; // show spectators
+       if (CS(e).race_completed)       sf |= BIT(0); // forced scoreboard
+       if (CS(to).spectatee_status)    sf |= BIT(1); // spectator ent number follows
+       if (CS(e).zoomstate)            sf |= BIT(2); // zoomed
+       if (autocvar_sv_showspectators) sf |= BIT(4); // show spectators
 
        WriteHeader(MSG_ENTITY, ENT_CLIENT_CLIENTDATA);
        WriteByte(MSG_ENTITY, sf);
 
 
        WriteHeader(MSG_ENTITY, ENT_CLIENT_CLIENTDATA);
        WriteByte(MSG_ENTITY, sf);
 
-       if (sf & 2)
-       {
+       if (sf & BIT(1))
                WriteByte(MSG_ENTITY, CS(to).spectatee_status);
                WriteByte(MSG_ENTITY, CS(to).spectatee_status);
-       }
 
 
-       if(sf & 16)
+       if(sf & BIT(4))
        {
                float specs = CountSpectators(e, to);
                WriteByte(MSG_ENTITY, specs);
        {
                float specs = CountSpectators(e, to);
                WriteByte(MSG_ENTITY, specs);
@@ -1191,7 +1189,10 @@ void ClientConnect(entity this)
        PlayerStats_GameReport_AddEvent(sprintf("kills-%d", this.playerid));
 
        // always track bots, don't ask for cl_allow_uidtracking
        PlayerStats_GameReport_AddEvent(sprintf("kills-%d", this.playerid));
 
        // always track bots, don't ask for cl_allow_uidtracking
-    if (IS_BOT_CLIENT(this)) PlayerStats_GameReport_AddPlayer(this);
+       if (IS_BOT_CLIENT(this))
+               PlayerStats_GameReport_AddPlayer(this);
+       else
+               CS(this).allowed_timeouts = autocvar_sv_timeout_number;
 
        if (autocvar_sv_eventlog)
                GameLogEcho(strcat(":join:", ftos(this.playerid), ":", ftos(etof(this)), ":", ((IS_REAL_CLIENT(this)) ? this.netaddress : "bot"), ":", playername(this, false)));
 
        if (autocvar_sv_eventlog)
                GameLogEcho(strcat(":join:", ftos(this.playerid), ":", ftos(etof(this)), ":", ((IS_REAL_CLIENT(this)) ? this.netaddress : "bot"), ":", playername(this, false)));
@@ -1240,7 +1241,6 @@ void ClientConnect(entity this)
        }
 
        CS(this).jointime = time;
        }
 
        CS(this).jointime = time;
-       CS(this).allowed_timeouts = autocvar_sv_timeout_number;
 
        if (IS_REAL_CLIENT(this))
        {
 
        if (IS_REAL_CLIENT(this))
        {
@@ -1624,7 +1624,6 @@ void player_regen(entity this)
        regen_health_stable = M_ARGV(9, float);
        regen_health_rotstable = M_ARGV(10, float);
 
        regen_health_stable = M_ARGV(9, float);
        regen_health_rotstable = M_ARGV(10, float);
 
-
        if(!mutator_returnvalue)
        if(!STAT(FROZEN, this))
        {
        if(!mutator_returnvalue)
        if(!STAT(FROZEN, this))
        {
@@ -1663,6 +1662,18 @@ void player_regen(entity this)
 
                this.ammo_fuel = CalcRotRegen(this.ammo_fuel, minf, autocvar_g_balance_fuel_regen, autocvar_g_balance_fuel_regenlinear, frametime * (time > this.pauseregen_finished) * ((this.items & ITEM_JetpackRegen.m_itemid) != 0), maxf, autocvar_g_balance_fuel_rot, autocvar_g_balance_fuel_rotlinear, frametime * (time > this.pauserotfuel_finished), limitf);
        }
 
                this.ammo_fuel = CalcRotRegen(this.ammo_fuel, minf, autocvar_g_balance_fuel_regen, autocvar_g_balance_fuel_regenlinear, frametime * (time > this.pauseregen_finished) * ((this.items & ITEM_JetpackRegen.m_itemid) != 0), maxf, autocvar_g_balance_fuel_rot, autocvar_g_balance_fuel_rotlinear, frametime * (time > this.pauserotfuel_finished), limitf);
        }
+       // Ugly hack to make sure the health and armor don't go beyond hard limit.
+       // TODO: Remove this hack when all code uses GivePlayerHealth and
+       // GivePlayerArmor.
+       if (this.health > RESOURCE_AMOUNT_HARD_LIMIT)
+       {
+               this.health = RESOURCE_AMOUNT_HARD_LIMIT;
+       }
+       if (this.armorvalue > RESOURCE_AMOUNT_HARD_LIMIT)
+       {
+               this.armorvalue = RESOURCE_AMOUNT_HARD_LIMIT;
+       }
+       // End hack.
 }
 
 bool zoomstate_set;
 }
 
 bool zoomstate_set;