]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
GunGame: Small improvements. Lyberta/GunGame
authorLyberta <lyberta@lyberta.net>
Wed, 31 Oct 2018 22:56:47 +0000 (01:56 +0300)
committerLyberta <lyberta@lyberta.net>
Wed, 31 Oct 2018 22:56:47 +0000 (01:56 +0300)
qcsrc/client/hud/panel/modicons.qc
qcsrc/common/gamemodes/gamemode/gungame/sv_gungame.qc

index 1d11ca98ae200c9740a498db70add0b3ab75c937..5a79c14cc93d605c4db6242a7e3caa3b6cc3f9ae 100644 (file)
@@ -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;
index b6699619f57e046c384b26680aeed1dcc8181793..4eb6985c71c10a910b6247926fad58a46906d779 100644 (file)
@@ -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.