From: terencehill Date: Mon, 18 Jun 2018 17:59:02 +0000 (+0200) Subject: Turn complain_weapon into an entity to reduce accesses to .m_id field X-Git-Tag: xonotic-v0.8.5~2010^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=41d49978fc359fee0f48165e3197ca0641fe9c84;p=xonotic%2Fxonotic-data.pk3dir.git Turn complain_weapon into an entity to reduce accesses to .m_id field --- diff --git a/qcsrc/client/hud/hud.qh b/qcsrc/client/hud/hud.qh index 950dee17a..68d1e6bff 100644 --- a/qcsrc/client/hud/hud.qh +++ b/qcsrc/client/hud/hud.qh @@ -86,8 +86,8 @@ const float BORDER_MULTIPLIER = 4; float scoreboard_bottom; int weapon_accuracy[Weapons_MAX]; -int complain_weapon; -float complain_weapon_type; +entity complain_weapon; +int complain_weapon_type; float complain_weapon_time; PlayerScoreField ps_primary, ps_secondary; diff --git a/qcsrc/client/hud/panel/weapons.qc b/qcsrc/client/hud/panel/weapons.qc index f94979133..5d75c7dd2 100644 --- a/qcsrc/client/hud/panel/weapons.qc +++ b/qcsrc/client/hud/panel/weapons.qc @@ -108,7 +108,7 @@ void HUD_Weapons() } if(!autocvar_hud_panel_weapons_complainbubble || autocvar__hud_configure || time - complain_weapon_time >= when + fadetime) - complain_weapon = 0; + complain_weapon = NULL; entity wepent = viewmodels[0]; // TODO: unhardcode @@ -169,13 +169,13 @@ void HUD_Weapons() if (autocvar_hud_panel_weapons_onlyowned >= 2) // only current { for (i = 0; i <= WEP_LAST-WEP_FIRST; ++i) - if (weaponorder[i] == panel_switchweapon || weaponorder[i].m_id == complain_weapon) + if (weaponorder[i] == panel_switchweapon || weaponorder[i] == complain_weapon) ++weapon_count; } else { for (i = 0; i <= WEP_LAST-WEP_FIRST; ++i) - if ((weapons_stat & WepSet_FromWeapon(weaponorder[i])) || weaponorder[i].m_id == complain_weapon) + if ((weapons_stat & WepSet_FromWeapon(weaponorder[i])) || weaponorder[i] == complain_weapon) ++weapon_count; } @@ -407,12 +407,12 @@ void HUD_Weapons() { if (autocvar_hud_panel_weapons_onlyowned >= 2) // only current { - if (!(it == panel_switchweapon || it.m_id == complain_weapon)) + if (!(it == panel_switchweapon || it == complain_weapon)) continue; } else { - if (!((weapons_stat & WepSet_FromWeapon(it)) || (it.m_id == complain_weapon))) + if (!((weapons_stat & WepSet_FromWeapon(it)) || (it == complain_weapon))) continue; } } @@ -534,7 +534,7 @@ void HUD_Weapons() } // draw the complain message - if(it.m_id == complain_weapon) + if(it == complain_weapon) { if(fadetime) a = ((complain_weapon_time + when > time) ? 1 : bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1)); diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 3de8cefeb..218df18a4 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -1216,7 +1216,8 @@ NET_HANDLE(TE_CSQC_PINGPLREPORT, bool isNew) NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew) { - complain_weapon = ReadByte(); + int weapon_id = ReadByte(); + complain_weapon = Weapons_from(weapon_id); complain_weapon_type = ReadByte(); return = true; @@ -1225,9 +1226,9 @@ NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew) switch(complain_weapon_type) { - case 0: Local_Notification(MSG_MULTI, ITEM_WEAPON_NOAMMO, complain_weapon); break; - case 1: Local_Notification(MSG_MULTI, ITEM_WEAPON_DONTHAVE, complain_weapon); break; - default: Local_Notification(MSG_MULTI, ITEM_WEAPON_UNAVAILABLE, complain_weapon); break; + case 0: Local_Notification(MSG_MULTI, ITEM_WEAPON_NOAMMO, weapon_id); break; + case 1: Local_Notification(MSG_MULTI, ITEM_WEAPON_DONTHAVE, weapon_id); break; + default: Local_Notification(MSG_MULTI, ITEM_WEAPON_UNAVAILABLE, weapon_id); break; } }