From: TimePath Date: Mon, 24 Aug 2015 01:28:07 +0000 (+1000) Subject: Stop using stats for itemstime X-Git-Tag: xonotic-v0.8.2~2042^2~8 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fff89cc21f874f16c6f2da9ecb61c68667d33744;p=xonotic%2Fxonotic-data.pk3dir.git Stop using stats for itemstime Also fixes large armor being tracked instead of mega armor --- diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index cfa00a1af..4310efbe9 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -4906,17 +4906,6 @@ void HUD_ItemsTime(void) (autocvar_hud_panel_itemstime == 1 && spectatee_status != 0) || (autocvar_hud_panel_itemstime == 2 && (spectatee_status != 0 || warmup_stage)) )) { return; } - - ItemsTime_time[0] = getstatf(STAT_ARMOR_LARGE_TIME); - ItemsTime_time[1] = getstatf(STAT_HEALTH_MEGA_TIME); - ItemsTime_time[2] = getstatf(STAT_INVISIBLE_TIME); - ItemsTime_time[3] = getstatf(STAT_SPEED_TIME); - ItemsTime_time[4] = getstatf(STAT_EXTRALIFE_TIME); - ItemsTime_time[5] = getstatf(STAT_STRENGTH_TIME); - ItemsTime_time[6] = getstatf(STAT_SHIELD_TIME); - ItemsTime_time[7] = getstatf(STAT_FUELREGEN_TIME); - ItemsTime_time[8] = getstatf(STAT_JETPACK_TIME); - ItemsTime_time[9] = getstatf(STAT_SUPERWEAPONS_TIME); } else { diff --git a/qcsrc/common/mutators/all.inc b/qcsrc/common/mutators/all.inc index 4cb1a6cea..44a2a4be1 100644 --- a/qcsrc/common/mutators/all.inc +++ b/qcsrc/common/mutators/all.inc @@ -1 +1,2 @@ #include "mutator/damagetext.qc" +#include "mutator/itemstime.qc" diff --git a/qcsrc/common/mutators/mutator/itemstime.qc b/qcsrc/common/mutators/mutator/itemstime.qc new file mode 100644 index 000000000..122212dc2 --- /dev/null +++ b/qcsrc/common/mutators/mutator/itemstime.qc @@ -0,0 +1,23 @@ +REGISTER_MUTATOR(itemstime, true); + +#ifdef SVQC +void IT_Write(entity e, int i, float f) { + if (!IS_REAL_CLIENT(e)) return; + msg_entity = e; + WriteByte(MSG_ONE, SVC_TEMPENTITY); + WriteMutator(MSG_ONE, itemstime); + WriteByte(MSG_ONE, i); + WriteFloat(MSG_ONE, f); +} +#endif + +#ifdef CSQC +MUTATOR_HOOKFUNCTION(itemstime, CSQC_Parse_TempEntity) { + if (MUTATOR_RETURNVALUE) return false; + if (!ReadMutatorEquals(mutator_argv_int_0, itemstime)) return false; + int i = ReadByte(); + float f = ReadFloat(); + ItemsTime_time[i] = f; + return true; +} +#endif diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index 83afc1890..74aa0e75f 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -109,16 +109,16 @@ const int STAT_OK_AMMO_CHARGE = 85; const int STAT_OK_AMMO_CHARGEPOOL = 86; const int STAT_FROZEN = 87; const int STAT_REVIVE_PROGRESS = 88; -const int STAT_ARMOR_LARGE_TIME = 89; -const int STAT_HEALTH_MEGA_TIME = 90; -const int STAT_INVISIBLE_TIME = 91; -const int STAT_SPEED_TIME = 92; -const int STAT_EXTRALIFE_TIME = 93; -const int STAT_STRENGTH_TIME = 94; -const int STAT_SHIELD_TIME = 95; -const int STAT_FUELREGEN_TIME = 96; -const int STAT_JETPACK_TIME = 97; -const int STAT_SUPERWEAPONS_TIME = 98; +// 89 empty? +// 90 empty? +// 91 empty? +// 92 empty? +// 93 empty? +// 94 empty? +// 95 empty? +// 96 empty? +// 97 empty? +// 98 empty? const int STAT_ROUNDLOST = 99; /* The following stats change depending on the gamemode, so can share the same ID */ diff --git a/qcsrc/dpdefs/csprogsdefs.qh b/qcsrc/dpdefs/csprogsdefs.qh index b10ef09ba..b42292c85 100644 --- a/qcsrc/dpdefs/csprogsdefs.qh +++ b/qcsrc/dpdefs/csprogsdefs.qh @@ -21,4 +21,6 @@ #pragma noref 0 +#define ReadFloat() ReadCoord() + #endif diff --git a/qcsrc/dpdefs/progsdefs.qh b/qcsrc/dpdefs/progsdefs.qh index c2440d3da..3592c7015 100644 --- a/qcsrc/dpdefs/progsdefs.qh +++ b/qcsrc/dpdefs/progsdefs.qh @@ -21,4 +21,6 @@ #pragma noref 0 +#define WriteFloat(to, f) WriteCoord(to, f) + #endif diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index cab4d569f..46fba8347 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -513,16 +513,18 @@ const float ACTIVE_TOGGLE = 3; .void (float act_state) setactive; .entity realowner; -.float item_armor_large_time; -.float item_health_mega_time; -.float item_invisible_time; -.float item_speed_time; -.float item_extralife_time; -.float item_strength_time; -.float item_shield_time; -.float item_fuelregen_time; -.float item_jetpack_time; -.float item_superweapons_time; +enum { + item_armor_large_time, + item_health_mega_time, + item_invisible_time, + item_speed_time, + item_extralife_time, + item_strength_time, + item_shield_time, + item_fuelregen_time, + item_jetpack_time, + item_superweapons_time +}; //float serverflags; diff --git a/qcsrc/server/mutators/mutator_superspec.qc b/qcsrc/server/mutators/mutator_superspec.qc index 267a0f71d..bc8600fb4 100644 --- a/qcsrc/server/mutators/mutator_superspec.qc +++ b/qcsrc/server/mutators/mutator_superspec.qc @@ -123,7 +123,7 @@ MUTATOR_HOOKFUNCTION(superspec_ItemTouch) if((self.autospec_flags & ASF_SHIELD && _item.invincible_finished) || (self.autospec_flags & ASF_STRENGTH && _item.strength_finished) || - (self.autospec_flags & ASF_MEGA_AR && _item.itemdef == ITEM_ArmorLarge) || + (self.autospec_flags & ASF_MEGA_AR && _item.itemdef == ITEM_ArmorMega) || (self.autospec_flags & ASF_MEGA_HP && _item.itemdef == ITEM_HealthMega) || (self.autospec_flags & ASF_FLAG_GRAB && _item.classname == "item_flag_team")) { diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 2abee7931..0dd5c9c2b 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -439,16 +439,6 @@ void Item_ItemsTime_Init() STATIC_INIT(ItemsTime_Init) { // items time - addstat(STAT_ARMOR_LARGE_TIME, AS_FLOAT, item_armor_large_time); - addstat(STAT_HEALTH_MEGA_TIME, AS_FLOAT, item_health_mega_time); - addstat(STAT_INVISIBLE_TIME, AS_FLOAT, item_invisible_time); - addstat(STAT_SPEED_TIME, AS_FLOAT, item_speed_time); - addstat(STAT_EXTRALIFE_TIME, AS_FLOAT, item_extralife_time); - addstat(STAT_STRENGTH_TIME, AS_FLOAT, item_strength_time); - addstat(STAT_SHIELD_TIME, AS_FLOAT, item_shield_time); - addstat(STAT_FUELREGEN_TIME, AS_FLOAT, item_fuelregen_time); - addstat(STAT_JETPACK_TIME, AS_FLOAT, item_jetpack_time); - addstat(STAT_SUPERWEAPONS_TIME, AS_FLOAT, item_superweapons_time); Item_ItemsTime_Init(); } @@ -465,31 +455,32 @@ void Item_ItemsTime_ResetTimes() it_jetpack_time = (it_jetpack_time == -1) ? -1 : 0; it_superweapons_time= (it_superweapons_time== -1) ? -1 : 0; } +void IT_Write(entity, int, float); void Item_ItemsTime_ResetTimesForPlayer(entity e) { - e.item_armor_large_time = (it_armor_large_time == -1) ? -1 : 0; - e.item_health_mega_time = (it_health_mega_time == -1) ? -1 : 0; - e.item_invisible_time = (it_invisible_time == -1) ? -1 : 0; - e.item_speed_time = (it_speed_time == -1) ? -1 : 0; - e.item_extralife_time = (it_extralife_time == -1) ? -1 : 0; - e.item_strength_time = (it_strength_time == -1) ? -1 : 0; - e.item_shield_time = (it_shield_time == -1) ? -1 : 0; - e.item_fuelregen_time = (it_fuelregen_time == -1) ? -1 : 0; - e.item_jetpack_time = (it_jetpack_time == -1) ? -1 : 0; - e.item_superweapons_time= (it_superweapons_time== -1) ? -1 : 0; + IT_Write(e, item_armor_large_time , (it_armor_large_time == -1) ? -1 : 0); + IT_Write(e, item_health_mega_time , (it_health_mega_time == -1) ? -1 : 0); + IT_Write(e, item_invisible_time , (it_invisible_time == -1) ? -1 : 0); + IT_Write(e, item_speed_time , (it_speed_time == -1) ? -1 : 0); + IT_Write(e, item_extralife_time , (it_extralife_time == -1) ? -1 : 0); + IT_Write(e, item_strength_time , (it_strength_time == -1) ? -1 : 0); + IT_Write(e, item_shield_time , (it_shield_time == -1) ? -1 : 0); + IT_Write(e, item_fuelregen_time , (it_fuelregen_time == -1) ? -1 : 0); + IT_Write(e, item_jetpack_time , (it_jetpack_time == -1) ? -1 : 0); + IT_Write(e, item_superweapons_time, (it_superweapons_time == -1) ? -1 : 0); } void Item_ItemsTime_SetTimesForPlayer(entity e) { - e.item_armor_large_time = it_armor_large_time; - e.item_health_mega_time = it_health_mega_time; - e.item_invisible_time = it_invisible_time; - e.item_speed_time = it_speed_time; - e.item_extralife_time = it_extralife_time; - e.item_strength_time = it_strength_time; - e.item_shield_time = it_shield_time; - e.item_fuelregen_time = it_fuelregen_time; - e.item_jetpack_time = it_jetpack_time; - e.item_superweapons_time = it_superweapons_time; + IT_Write(e, item_armor_large_time , it_armor_large_time ); + IT_Write(e, item_health_mega_time , it_health_mega_time ); + IT_Write(e, item_invisible_time , it_invisible_time ); + IT_Write(e, item_speed_time , it_speed_time ); + IT_Write(e, item_extralife_time , it_extralife_time ); + IT_Write(e, item_strength_time , it_strength_time ); + IT_Write(e, item_shield_time , it_shield_time ); + IT_Write(e, item_fuelregen_time , it_fuelregen_time ); + IT_Write(e, item_jetpack_time , it_jetpack_time ); + IT_Write(e, item_superweapons_time, it_superweapons_time); } void Item_ItemsTime_SetTime(entity e, float t) @@ -516,12 +507,12 @@ void Item_ItemsTime_SetTime(entity e, float t) { switch(e.items) { - case IT_HEALTH: - // if(e.itemdef == ITEM_MegaHealth) // e.items == IT_HEALTH unequivocally identifies it + case ITEM_HealthMega.m_itemid: + // if(e.itemdef == ITEM_HealthMega) // e.items == IT_HEALTH unequivocally identifies it it_health_mega_time = t; break; - case IT_ARMOR: - if(e.itemdef == ITEM_ArmorLarge) // e.items == IT_ARMOR doesn't unequivocally identifies it + case ITEM_ArmorMega.m_itemid: + if(e.itemdef == ITEM_ArmorMega) // e.items == IT_ARMOR doesn't unequivocally identifies it it_armor_large_time = t; break; case IT_STRENGTH://"item-strength" @@ -614,7 +605,7 @@ void Item_Respawn (void) sound (self, CH_TRIGGER, "misc/itemrespawn.wav", VOL_BASE, ATTEN_NORM); // play respawn sound setorigin (self, self.origin); - if(self.flags & FL_POWERUP || self.itemdef == ITEM_ArmorLarge || self.items == IT_HEALTH || (self.weapons & WEPSET_SUPERWEAPONS)) + if(self.flags & FL_POWERUP || self.itemdef == ITEM_ArmorMega || self.items == IT_HEALTH || (self.weapons & WEPSET_SUPERWEAPONS)) { float t = Item_ItemsTime_UpdateTime(self, 0); Item_ItemsTime_SetTime(self, t); @@ -656,7 +647,7 @@ void Item_RespawnCountdown (void) {name = "item_health_mega"; rgb = '1 0 0';} break; case ITEM_ArmorMega.m_itemid: - if (self.itemdef == ITEM_ArmorLarge) + if (self.itemdef == ITEM_ArmorMega) {name = "item_armor_large"; rgb = '0 1 0';} break; } @@ -725,7 +716,7 @@ void Item_RespawnThink() void Item_ScheduleRespawnIn(entity e, float t) { - if((e.flags & FL_POWERUP) || (e.weapons & WEPSET_SUPERWEAPONS) || e.itemdef == ITEM_ArmorLarge || e.items == IT_HEALTH) + if((e.flags & FL_POWERUP) || (e.weapons & WEPSET_SUPERWEAPONS) || e.itemdef == ITEM_ArmorMega || e.items == IT_HEALTH) { e.think = Item_RespawnCountdown; e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);