From: Lyberta Date: Wed, 31 Oct 2018 22:56:47 +0000 (+0300) Subject: GunGame: Small improvements. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=56204dc1367b0e4fe8beb7244d00794dec00d218;p=xonotic%2Fxonotic-data.pk3dir.git GunGame: Small improvements. --- diff --git a/qcsrc/client/hud/panel/modicons.qc b/qcsrc/client/hud/panel/modicons.qc index 1d11ca98a..5a79c14cc 100644 --- a/qcsrc/client/hud/panel/modicons.qc +++ b/qcsrc/client/hud/panel/modicons.qc @@ -716,21 +716,6 @@ int gg_previous_weapon; ///< Previous weapon. string gg_previous_weapon_picture; ///< Previous weapon picture. float gg_weapon_change_time; ///< Time when the weapon changed. -/// \brief Returns the picture of the weapon. -/// \param[in] weapon Index of the weapon. -/// \return Picture of the weapon. -string GG_GetWeaponPicture(int weapon) -{ - FOREACH(Weapons, it != WEP_Null, - { - if (it.m_id == weapon) - { - return it.model2; - } - }); - return ""; -} - void HUD_Mod_GG(vector pos, vector mySize) { // Required in each mod function that always shows something. @@ -742,7 +727,7 @@ void HUD_Mod_GG(vector pos, vector mySize) gg_previous_weapon = gg_current_weapon; gg_previous_weapon_picture = gg_current_weapon_picture; gg_current_weapon = stat_weapon; - gg_current_weapon_picture = GG_GetWeaponPicture(gg_current_weapon); + gg_current_weapon_picture = Weapons_from(gg_current_weapon).model2; gg_weapon_change_time = time; } vector pic_pos, pic_size; diff --git a/qcsrc/common/gamemodes/gamemode/gungame/sv_gungame.qc b/qcsrc/common/gamemodes/gamemode/gungame/sv_gungame.qc index b6699619f..4eb6985c7 100644 --- a/qcsrc/common/gamemodes/gamemode/gungame/sv_gungame.qc +++ b/qcsrc/common/gamemodes/gamemode/gungame/sv_gungame.qc @@ -65,16 +65,13 @@ entity GunGame_GetWeapon(int level) return NULL; } tokenize_console(gungame_weapons); - string weapon = argv(floor(level / autocvar_g_gg_kills_per_weapon)); - FOREACH(Weapons, it != WEP_Null, + string weapon_name = argv(floor(level / autocvar_g_gg_kills_per_weapon)); + Weapon weapon = Weapons_fromstr(weapon_name); + if (weapon == WEP_Null) { - if (it.netname == weapon) - { - return it; - } - }); - LOG_FATAL("GunGame_GetWeapon: Invalid level or weapon name"); - return NULL; + LOG_FATAL("GunGame_GetWeapon: Invalid level or weapon name"); + } + return weapon; } /// \brief Returns the player level.