From: Mario Date: Sun, 16 Jul 2017 21:52:54 +0000 (+1000) Subject: Port race_completed to ClientState and move prevorigin to the campcheck code (only... X-Git-Tag: xonotic-v0.8.5~2589 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4bb6b84519dbf3cce06996e37db18f5678dabba1;p=xonotic%2Fxonotic-data.pk3dir.git Port race_completed to ClientState and move prevorigin to the campcheck code (only place it's used) with a new name --- diff --git a/qcsrc/common/mutators/mutator/campcheck/sv_campcheck.qc b/qcsrc/common/mutators/mutator/campcheck/sv_campcheck.qc index 41f538b7a..52fc52466 100644 --- a/qcsrc/common/mutators/mutator/campcheck/sv_campcheck.qc +++ b/qcsrc/common/mutators/mutator/campcheck/sv_campcheck.qc @@ -9,6 +9,8 @@ REGISTER_MUTATOR(campcheck, cvar("g_campcheck")); .float campcheck_nextcheck; .float campcheck_traveled_distance; +.vector campcheck_prevorigin; + MUTATOR_HOOKFUNCTION(campcheck, PlayerDies) { entity frag_target = M_ARGV(2, entity); @@ -33,23 +35,19 @@ MUTATOR_HOOKFUNCTION(campcheck, Damage_Calculate) MUTATOR_HOOKFUNCTION(campcheck, PlayerPreThink) { entity player = M_ARGV(0, entity); + bool checked = false; - if(!game_stopped) - if(!warmup_stage) // don't consider it camping during warmup? - if(time >= game_starttime) + if(autocvar_g_campcheck_interval) + if(!game_stopped && !warmup_stage && time >= game_starttime) if(IS_PLAYER(player)) - if(IS_REAL_CLIENT(player)) // bots may camp, but that's no reason to constantly kill them if(!IS_DEAD(player)) - if(!forbidWeaponUse(player)) if(!STAT(FROZEN, player)) if(!PHYS_INPUT_BUTTON_CHAT(player)) - if(autocvar_g_campcheck_interval) + if(IS_REAL_CLIENT(player)) // bots may camp, but that's no reason to constantly kill them + if(!forbidWeaponUse(player)) { - vector dist; - // calculate player movement (in 2 dimensions only, so jumping on one spot doesn't count as movement) - dist = player.prevorigin - player.origin; - dist.z = 0; + vector dist = vec2(player.campcheck_prevorigin - player.origin); player.campcheck_traveled_distance += fabs(vlen(dist)); if((autocvar_g_campaign && !campaign_bots_may_start) || (time < game_starttime) || (round_handler_IsActive() && !round_handler_IsRoundStarted())) @@ -72,10 +70,21 @@ MUTATOR_HOOKFUNCTION(campcheck, PlayerPreThink) player.campcheck_traveled_distance = 0; } - return; + checked = true; } - player.campcheck_nextcheck = time + autocvar_g_campcheck_interval; // one of the above checks failed, so keep the timer up to date + if(!checked) + player.campcheck_nextcheck = time + autocvar_g_campcheck_interval; // one of the above checks failed, so keep the timer up to date + + player.campcheck_prevorigin = player.origin; +} + +MUTATOR_HOOKFUNCTION(campcheck, CopyBody) +{ + entity player = M_ARGV(0, entity); + entity clone = M_ARGV(1, entity); + + clone.campcheck_prevorigin = player.campcheck_prevorigin; } MUTATOR_HOOKFUNCTION(campcheck, PlayerSpawn) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 2bab814a2..ec771b2d6 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -110,7 +110,7 @@ bool ClientData_Send(entity this, entity to, int sf) if (IS_SPEC(e)) e = e.enemy; sf = 0; - if (e.race_completed) sf |= 1; // forced scoreboard + 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 @@ -225,12 +225,10 @@ void PutObserverInServer(entity this) { entity spot = SelectSpawnPoint(this, true); if (!spot) LOG_FATAL("No spawnpoints for observers?!?"); - this.angles = spot.angles; - this.angles_z = 0; + this.angles = vec2(spot.angles); this.fixangle = true; // offset it so that the spectator spawns higher off the ground, looks better this way setorigin(this, spot.origin + STAT(PL_VIEW_OFS, this)); - this.prevorigin = this.origin; if (IS_REAL_CLIENT(this)) { msg_entity = this; @@ -622,7 +620,6 @@ void PutPlayerInServer(entity this) setorigin(this, spot.origin + '0 0 1' * (1 - this.mins.z - 24)); // don't reset back to last position, even if new position is stuck in solid this.oldorigin = this.origin; - this.prevorigin = this.origin; this.lastteleporttime = time; // prevent insane speeds due to changing origin if(this.conveyor) IL_REMOVE(g_conveyed, this); @@ -2203,8 +2200,6 @@ bool PlayerThink(entity this) return false; } - this.prevorigin = this.origin; - bool have_hook = false; for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 02caceb7d..bd9359cf5 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -94,6 +94,7 @@ CLASS(Client, Object) ATTRIB(Client, spectatee_status, int, this.spectatee_status); ATTRIB(Client, zoomstate, bool, this.zoomstate); ATTRIB(Client, just_joined, bool, this.just_joined); + ATTRIB(Client, race_completed, bool, this.race_completed); METHOD(Client, m_unwind, bool(Client this)); diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 827f3940f..f4d78b0e8 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -289,8 +289,6 @@ float servertime, serverprevtime, serverframetime; .float ammo_fuel; -.vector prevorigin; - //flood fields .float nickspamtime; // time of last nick change .float nickspamcount; diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index eb0376928..83911eeaf 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -785,7 +785,6 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d setorigin(targ, spot.origin + '0 0 1' * (1 - targ.mins.z - 24)); // don't reset back to last position, even if new position is stuck in solid targ.oldorigin = targ.origin; - targ.prevorigin = targ.origin; Send_Effect(EFFECT_TELEPORT, targ.origin, '0 0 0', 1); } diff --git a/qcsrc/server/mutators/mutator/gamemode_race.qc b/qcsrc/server/mutators/mutator/gamemode_race.qc index 357ed226f..b1759fb6a 100644 --- a/qcsrc/server/mutators/mutator/gamemode_race.qc +++ b/qcsrc/server/mutators/mutator/gamemode_race.qc @@ -73,7 +73,7 @@ float WinningCondition_Race(float fraglimit) c = 0; FOREACH_CLIENT(IS_PLAYER(it), LAMBDA( ++n; - if(it.race_completed) + if(CS(it).race_completed) ++c; )); if(n && (n == c)) diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index e3201c4e5..e34826cab 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -111,7 +111,6 @@ void CopyBody(entity this, float keepvelocity) //clone.weapon = this.weapon; setorigin(clone, this.origin); setsize(clone, this.mins, this.maxs); - clone.prevorigin = this.origin; clone.reset = SUB_Remove; clone._ps = this._ps; diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index 0654c5dc7..a17e8d745 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -378,7 +378,7 @@ void race_SendTime(entity e, float cp, float t, float tvalid) if(tvalid) if(cp == race_timed_checkpoint) // finish line - if (!e.race_completed) + if (!CS(e).race_completed) { float s; if(g_race_qualifying) @@ -404,7 +404,7 @@ void race_SendTime(entity e, float cp, float t, float tvalid) if(race_completing) { - e.race_completed = 1; + CS(e).race_completed = 1; MAKE_INDEPENDENT_PLAYER(e); Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_RACE_FINISHED, e.netname); ClientData_Touch(e); @@ -1030,9 +1030,9 @@ spawnfunc(target_stopTimer) { spawnfunc_target_checkpoint(this); } void race_AbandonRaceCheck(entity p) { - if(race_completing && !p.race_completed) + if(race_completing && !CS(p).race_completed) { - p.race_completed = 1; + CS(p).race_completed = 1; MAKE_INDEPENDENT_PLAYER(p); Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_RACE_ABANDONED, p.netname); ClientData_Touch(p); @@ -1170,7 +1170,7 @@ float race_GetFractionalLapCount(entity e) float l; l = PlayerScore_Add(e, SP_RACE_LAPS, 0); - if(e.race_completed) + if(CS(e).race_completed) return l; // not fractional vector o0, o1;