From: TimePath Date: Thu, 10 Dec 2015 03:58:18 +0000 (+1100) Subject: Stats: abstract engine stats X-Git-Tag: xonotic-v0.8.2~1524 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=91d607d78b9933c0823ba763f90e679db253d1cf;p=xonotic%2Fxonotic-data.pk3dir.git Stats: abstract engine stats --- diff --git a/qcsrc/client/hud/panel/ammo.qc b/qcsrc/client/hud/panel/ammo.qc index 6c37aa13a..96343d6a9 100644 --- a/qcsrc/client/hud/panel/ammo.qc +++ b/qcsrc/client/hud/panel/ammo.qc @@ -160,7 +160,7 @@ void HUD_Ammo() Weapon wep = switchweapon; int i; - bool infinite_ammo = (getstati(STAT_ITEMS, 0, 24) & IT_UNLIMITED_WEAPON_AMMO); + bool infinite_ammo = (STAT(ITEMS) & IT_UNLIMITED_WEAPON_AMMO); row = column = 0; if(autocvar_hud_panel_ammo_onlycurrent) { diff --git a/qcsrc/client/hud/panel/healtharmor.qc b/qcsrc/client/hud/panel/healtharmor.qc index bab17556d..3b094d39d 100644 --- a/qcsrc/client/hud/panel/healtharmor.qc +++ b/qcsrc/client/hud/panel/healtharmor.qc @@ -8,13 +8,13 @@ void HUD_HealthArmor() if(hud != HUD_NORMAL) return; if(spectatee_status == -1) return; - health = getstati(STAT_HEALTH); + health = STAT(HEALTH); if(health <= 0) { prev_health = -1; return; } - armor = getstati(STAT_ARMOR); + armor = STAT(ARMOR); // code to check for spectatee_status changes is in Ent_ClientData() // prev_p_health and prev_health can be set to -1 there diff --git a/qcsrc/client/hud/panel/modicons.qc b/qcsrc/client/hud/panel/modicons.qc index 8e3166b6a..d57a23e1e 100644 --- a/qcsrc/client/hud/panel/modicons.qc +++ b/qcsrc/client/hud/panel/modicons.qc @@ -415,7 +415,7 @@ void HUD_Mod_Keepaway(vector pos, vector mySize) float BLINK_FREQ = 5; float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); - int stat_items = getstati(STAT_ITEMS, 0, 24); + int stat_items = STAT(ITEMS); int kaball = (stat_items/IT_KEY1) & 1; if(kaball != kaball_prevstatus) @@ -451,7 +451,7 @@ void HUD_Mod_NexBall(vector pos, vector mySize) float nb_pb_starttime, dt, p; int stat_items; - stat_items = getstati(STAT_ITEMS, 0, 24); + stat_items = STAT(ITEMS); nb_pb_starttime = STAT(NB_METERSTART); if (stat_items & IT_KEY1) diff --git a/qcsrc/client/hud/panel/powerups.qc b/qcsrc/client/hud/panel/powerups.qc index e75f21f36..854ed594a 100644 --- a/qcsrc/client/hud/panel/powerups.qc +++ b/qcsrc/client/hud/panel/powerups.qc @@ -56,7 +56,7 @@ int getPowerupItemAlign(int align, int column, int row, int columns, int rows, b void HUD_Powerups() { - int allItems = getstati(STAT_ITEMS, 0, 24); + int allItems = STAT(ITEMS); int allBuffs = STAT(BUFFS); int strengthTime, shieldTime, superTime; @@ -65,7 +65,7 @@ void HUD_Powerups() { if(!autocvar_hud_panel_powerups) return; if(spectatee_status == -1) return; - if(getstati(STAT_HEALTH) <= 0) return; + if(STAT(HEALTH) <= 0) return; if(!(allItems & (ITEM_Strength.m_itemid | ITEM_Shield.m_itemid | IT_SUPERWEAPON)) && !allBuffs) return; strengthTime = bound(0, STAT(STRENGTH_FINISHED) - time, 99); diff --git a/qcsrc/client/hud/panel/radar.qc b/qcsrc/client/hud/panel/radar.qc index 33f4e1e64..66d516960 100644 --- a/qcsrc/client/hud/panel/radar.qc +++ b/qcsrc/client/hud/panel/radar.qc @@ -79,7 +79,7 @@ float HUD_Radar_InputEvent(float bInputType, float nPrimary, float nSecondary) return false; } - if ( getstati(STAT_HEALTH) <= 0 ) + if ( STAT(HEALTH) <= 0 ) { // Show scoreboard if ( bInputType < 2 ) @@ -369,7 +369,7 @@ void HUD_Radar() { string message = "Click to select teleport destination"; - if ( getstati(STAT_HEALTH) <= 0 ) + if ( STAT(HEALTH) <= 0 ) { message = "Click to select spawn location"; } diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index 4d9a8c69d..06c7363af 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -986,7 +986,7 @@ float HUD_WouldDrawScoreboard() { return 1; else if (intermission == 2) return 0; - else if (spectatee_status != -1 && getstati(STAT_HEALTH) <= 0 && autocvar_cl_deathscoreboard && gametype != MAPINFO_TYPE_CTS && !active_minigame) + else if (spectatee_status != -1 && STAT(HEALTH) <= 0 && autocvar_cl_deathscoreboard && gametype != MAPINFO_TYPE_CTS && !active_minigame) return 1; else if (scoreboard_showscores_force) return 1; diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index e24e5bdf2..c15914971 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -115,7 +115,7 @@ void viewmodel_animate(entity this) prevtime = time; if (autocvar_chase_active) return; - if (getstati(STAT_HEALTH) <= 0) return; + if (STAT(HEALTH) <= 0) return; entity view = CSQCModel_server2csqc(player_localentnum - 1); @@ -272,7 +272,7 @@ void viewmodel_animate(entity this) void viewmodel_draw(entity this) { - int mask = (intermission || (getstati(STAT_HEALTH) <= 0) || autocvar_chase_active) ? 0 : MASK_NORMAL; + int mask = (intermission || (STAT(HEALTH) <= 0) || autocvar_chase_active) ? 0 : MASK_NORMAL; float a = this.alpha; int c = stof(getplayerkeyvalue(current_player, "colors")); vector g; @@ -356,7 +356,7 @@ void Porto_Draw(entity this) return; if(intermission == 2) return; - if (getstati(STAT_HEALTH) <= 0) + if (STAT(HEALTH) <= 0) return; dir = view_forward; @@ -672,7 +672,7 @@ float TrueAimCheck() break; } - vector traceorigin = entcs_receiver(player_localentnum - 1).origin + (eZ * getstati(STAT_VIEWHEIGHT)); + vector traceorigin = entcs_receiver(player_localentnum - 1).origin + (eZ * STAT(VIEWHEIGHT)); vecs = decompressShotOrigin(STAT(SHOTORG)); @@ -757,7 +757,7 @@ bool WantEventchase() return true; if(autocvar_cl_eventchase_nexball && gametype == MAPINFO_TYPE_NEXBALL && !(WepSet_GetFromStat() & WEPSET(NEXBALL))) return true; - if(autocvar_cl_eventchase_death && (getstati(STAT_HEALTH) <= 0)) + if(autocvar_cl_eventchase_death && (STAT(HEALTH) <= 0)) { if(autocvar_cl_eventchase_death == 2) { @@ -954,7 +954,7 @@ void HUD_Crosshair() case 2: // crosshair_color_by_health { - float x = getstati(STAT_HEALTH); + float x = STAT(HEALTH); //x = red //y = green @@ -1432,7 +1432,7 @@ void CSQC_UpdateView(float w, float h) ticrate = STAT(MOVEVARS_TICRATE) * STAT(MOVEVARS_TIMESCALE); - float is_dead = (getstati(STAT_HEALTH) <= 0); + float is_dead = (STAT(HEALTH) <= 0); // FIXME do we need this hack? if(isdemo()) @@ -1710,7 +1710,7 @@ void CSQC_UpdateView(float w, float h) switchingweapon = Weapons_from(STAT(SWITCHINGWEAPON)); // actually active weapon (for zoom) - activeweapon = Weapons_from(getstati(STAT_ACTIVEWEAPON)); + activeweapon = Weapons_from(STAT(ACTIVEWEAPON)); switchweapon = Weapons_from(STAT(SWITCHWEAPON)); @@ -2006,7 +2006,7 @@ void CSQC_UpdateView(float w, float h) splash_pos.y = (vid_conheight - splash_size.y) / 2; float myhealth_flash_temp; - myhealth = getstati(STAT_HEALTH); + myhealth = STAT(HEALTH); // fade out myhealth_flash = max(0, myhealth_flash - autocvar_hud_damage_fade_rate * frametime); @@ -2115,7 +2115,7 @@ void CSQC_UpdateView(float w, float h) if (strength_finished - time > 0) { sharpen_intensity += (strength_finished - time); } if (invincible_finished - time > 0) { sharpen_intensity += (invincible_finished - time); } - sharpen_intensity = bound(0, ((getstati(STAT_HEALTH) > 0) ? sharpen_intensity : 0), 5); // Check to see if player is alive (if not, set 0) - also bound to fade out starting at 5 seconds. + sharpen_intensity = bound(0, ((STAT(HEALTH) > 0) ? sharpen_intensity : 0), 5); // Check to see if player is alive (if not, set 0) - also bound to fade out starting at 5 seconds. if(autocvar_hud_powerup && sharpen_intensity > 0) { diff --git a/qcsrc/common/physics.qc b/qcsrc/common/physics.qc index 64b53b3a7..dc1dcacde 100644 --- a/qcsrc/common/physics.qc +++ b/qcsrc/common/physics.qc @@ -1258,7 +1258,7 @@ void PM_Main(entity this) { int buttons = PHYS_INPUT_BUTTON_MASK(this); #ifdef CSQC - this.items = getstati(STAT_ITEMS, 0, 24); + this.items = STAT(ITEMS); this.movement = PHYS_INPUT_MOVEVALUES(this); diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index d52329333..3780a33fe 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -9,16 +9,37 @@ // 255 is the current limit (MAX_CL_STATS - 1), engine will need to be modified if you wish to add more stats const int MAX_CL_STATS = 256; -#ifndef CSQC -const int STAT_HEALTH = 0; // .health -const int STAT_ARMOR = 4; // .armorvalue -const int STAT_SHELLS = 6; // .ammo_shells -const int STAT_NAILS = 7; // .ammo_nails -const int STAT_ROCKETS = 8; // .ammo_rockets -const int STAT_CELLS = 9; // .ammo_cells -const int STAT_ACTIVEWEAPON = 10; // .weapon -const int STAT_ITEMS = 15; // .items | .items2 << 23 | serverflags << 28 -const int STAT_VIEWHEIGHT = 16; // .view_ofs_z + +// const int STAT_HEALTH = 0; +// const int STAT_ARMOR = 4; +// const int STAT_SHELLS = 6; +// const int STAT_NAILS = 7; +// const int STAT_ROCKETS = 8; +// const int STAT_CELLS = 9; +// const int STAT_ACTIVEWEAPON = 10; +// const int STAT_ITEMS = 15; // .items | .items2 << 23 | serverflags << 28 +// const int STAT_VIEWHEIGHT = 16; + +#if defined(CSQC) + #define g_stat_HEALTH getstat_int(STAT_HEALTH) + #define g_stat_ARMOR getstat_int(STAT_ARMOR) + #define g_stat_SHELLS getstat_int(STAT_SHELLS) + #define g_stat_NAILS getstat_int(STAT_NAILS) + #define g_stat_ROCKETS getstat_int(STAT_ROCKETS) + #define g_stat_CELLS getstat_int(STAT_CELLS) + #define g_stat_ACTIVEWEAPON getstat_int(STAT_ACTIVEWEAPON) + #define g_stat_ITEMS getstat_int(STAT_ITEMS) + #define g_stat_VIEWHEIGHT getstat_int(STAT_VIEWHEIGHT) +#elif defined(SVQC) + #define stat_HEALTH health + #define stat_ARMOR armorvalue + #define stat_SHELLS ammo_shells + #define stat_NAILS ammo_nails + #define stat_ROCKETS ammo_rockets + #define stat_CELLS ammo_cells + #define stat_ACTIVEWEAPON weapon + #define stat_ITEMS items + #define stat_VIEWHEIGHT view_ofs_z #endif REGISTER_STAT(WEAPONS, vectori) diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index 38e343f65..22c3f1e02 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -532,17 +532,17 @@ void racer_draw() self.lastpushtime = time; if(!pushdeltatime) return; - tracebox(self.move_origin, self.mins, self.maxs, self.move_origin - ('0 0 1' * getstatf(STAT_VEH_RACER_SPRINGLENGTH)), MOVE_NOMONSTERS, self); + tracebox(self.move_origin, self.mins, self.maxs, self.move_origin - ('0 0 1' * STAT(VEH_RACER_SPRINGLENGTH)), MOVE_NOMONSTERS, self); - vector df = self.move_velocity * -getstatf(STAT_VEH_RACER_FRICTION); - df_z += (1 - trace_fraction) * getstatf(STAT_VEH_RACER_HOVERPOWER) + sin(time * 2) * (getstatf(STAT_VEH_RACER_SPRINGLENGTH) * 2); + vector df = self.move_velocity * -STAT(VEH_RACER_FRICTION); + df_z += (1 - trace_fraction) * STAT(VEH_RACER_HOVERPOWER) + sin(time * 2) * (STAT(VEH_RACER_SPRINGLENGTH) * 2); - float forced = getstatf(STAT_VEH_RACER_UPFORCEDAMPER); + float forced = STAT(VEH_RACER_UPFORCEDAMPER); int cont = pointcontents(self.move_origin - '0 0 64'); if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME) { - forced = getstatf(STAT_VEH_RACER_WATER_UPFORCEDAMPER); + forced = STAT(VEH_RACER_WATER_UPFORCEDAMPER); self.move_velocity_z += 200; } @@ -550,8 +550,8 @@ void racer_draw() if(self.move_velocity_z > 0) self.move_velocity_z *= 1 - forced * pushdeltatime; - self.move_angles_x *= 1 - (getstatf(STAT_VEH_RACER_ANGLESTABILIZER) * pushdeltatime); - self.move_angles_z *= 1 - (getstatf(STAT_VEH_RACER_ANGLESTABILIZER) * pushdeltatime); + self.move_angles_x *= 1 - (STAT(VEH_RACER_ANGLESTABILIZER) * pushdeltatime); + self.move_angles_z *= 1 - (STAT(VEH_RACER_ANGLESTABILIZER) * pushdeltatime); Movetype_Physics_MatchServer(false); } diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 5d4687850..13037eb7d 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -1226,7 +1226,7 @@ NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew) else { // use player origin so that third person display still works - self.origin = entcs_receiver(player_localnum).origin + ('0 0 1' * getstati(STAT_VIEWHEIGHT)); + self.origin = entcs_receiver(player_localnum).origin + ('0 0 1' * STAT(VIEWHEIGHT)); } } diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index d5445000c..2905002d9 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -128,7 +128,7 @@ void VaporizerBeam_Draw(entity this) Draw_VaporizerBeam_trace_callback_tex = string_null; /*if(!MUTATOR_CALLHOOK(Particles_VaporizerBeam, this.vorg1, this.vorg2)) - if(autocvar_cl_particles_oldvortexbeam && (getstati(STAT_ALLOW_OLDVORTEXBEAM) || isdemo())) + if(autocvar_cl_particles_oldvortexbeam && (STAT(ALLOW_OLDVORTEXBEAM) || isdemo())) WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum(EFFECT_VORTEX_BEAM_OLD), this.vorg1, this.vorg2, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE); else WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum(EFFECT_VORTEX_BEAM), this.vorg1, this.vorg2, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);*/ diff --git a/qcsrc/lib/csqcmodel/cl_player.qc b/qcsrc/lib/csqcmodel/cl_player.qc index ecc98b1a3..3fdef9583 100644 --- a/qcsrc/lib/csqcmodel/cl_player.qc +++ b/qcsrc/lib/csqcmodel/cl_player.qc @@ -202,7 +202,7 @@ void CSQCPlayer_PredictTo(entity this, float endframe, bool apply_error) #if 0 // we don't need this // darkplaces makes servercommandframe == 0 in these cases anyway - if (getstatf(STAT_HEALTH) <= 0) + if (STAT(HEALTH) <= 0) { csqcplayer_moveframe = clientcommandframe; getinputstate(csqcplayer_moveframe-1); @@ -245,7 +245,7 @@ void CSQCPlayer_SetViewLocation() void CSQCPlayer_SetCamera() { const vector v0 = pmove_vel; // TRICK: pmove_vel is set by the engine when we get here. No need to network velocity - const float vh = getstati(STAT_VIEWHEIGHT); + const float vh = STAT(VIEWHEIGHT); const vector pl_viewofs = PL_VIEW_OFS; const vector pl_viewofs_crouch = PL_CROUCH_VIEW_OFS; const entity e = csqcplayer; @@ -323,7 +323,7 @@ void CSQCPlayer_SetCamera() if (view.csqcmodel_teleported) refdefflags |= REFDEFFLAG_TELEPORTED; if (input_buttons & BIT(1)) refdefflags |= REFDEFFLAG_JUMPING; // note: these two only work in WIP2, but are harmless in WIP1 - if (getstati(STAT_HEALTH) <= 0) refdefflags |= REFDEFFLAG_DEAD; + if (STAT(HEALTH) <= 0) refdefflags |= REFDEFFLAG_DEAD; if (intermission) refdefflags |= REFDEFFLAG_INTERMISSION; V_CalcRefdef(view, refdefflags); }