]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Player templates: better formatting.
authorLyberta <lyberta@lyberta.net>
Thu, 17 May 2018 09:14:56 +0000 (12:14 +0300)
committerLyberta <lyberta@lyberta.net>
Thu, 17 May 2018 09:14:56 +0000 (12:14 +0300)
qcsrc/server/playertemplates.qc
qcsrc/server/playertemplates.qh

index 3b04d2c6036e2e429edf345eee5cb16f6b3f81fd..8322d8b06c589d664087488af0ecdfe0de1d9d5e 100644 (file)
 #include "resources.qh"
 #include "mutators/events.qh"
 
-const string playertemplate_cvar_prefix = "g_player_template_";
+const string player_template_cvar_prefix = "g_player_template_";
 
 string PlayerTemplate_GetFullCvarName(string template, string variable)
 {
-       return strcat(playertemplate_cvar_prefix, template, "_", variable);
+       return strcat(player_template_cvar_prefix, template, "_", variable);
 }
 
 string PlayerTemplate_GetDefaultCvarName(string variable)
@@ -205,16 +205,16 @@ float PlayerTemplate_GetFloatValue(string template, string variable)
        {
                return PlayerTemplate_GetDefaultFloatValue(variable);
        }
-       string fullname = PlayerTemplate_GetFullCvarName(template, variable);
-       if (!(cvar_type(fullname) & CVAR_TYPEFLAG_EXISTS))
+       string full_name = PlayerTemplate_GetFullCvarName(template, variable);
+       if (!(cvar_type(full_name) & CVAR_TYPEFLAG_EXISTS))
        {
                return PlayerTemplate_GetDefaultFloatValue(variable);
        }
-       if (cvar_string(fullname) == "default")
+       if (cvar_string(full_name) == "default")
        {
                return PlayerTemplate_GetDefaultFloatValue(variable);
        }
-       return cvar(fullname);
+       return cvar(full_name);
 }
 
 string PlayerTemplate_GetStringValue(string template, string variable)
@@ -223,16 +223,16 @@ string PlayerTemplate_GetStringValue(string template, string variable)
        {
                return PlayerTemplate_GetDefaultStringValue(variable);
        }
-       string fullname = PlayerTemplate_GetFullCvarName(template, variable);
-       if (!(cvar_type(fullname) & CVAR_TYPEFLAG_EXISTS))
+       string full_name = PlayerTemplate_GetFullCvarName(template, variable);
+       if (!(cvar_type(full_name) & CVAR_TYPEFLAG_EXISTS))
        {
                return PlayerTemplate_GetDefaultStringValue(variable);
        }
-       if (cvar_string(fullname) == "default")
+       if (cvar_string(full_name) == "default")
        {
                return PlayerTemplate_GetDefaultStringValue(variable);
        }
-       return cvar_string(fullname);
+       return cvar_string(full_name);
 }
 
 float PlayerTemplate_GivePlayerItem(entity player, string template,
@@ -243,13 +243,13 @@ float PlayerTemplate_GivePlayerItem(entity player, string template,
        {
                return MUT_ITEMTOUCH_CONTINUE;
        }
-       int numfields = tokenize_console(PlayerTemplate_GetStringValue(template,
+       int num_fields = tokenize_console(PlayerTemplate_GetStringValue(template,
                variable));
-       if (numfields == 0)
+       if (num_fields == 0)
        {
                return MUT_ITEMTOUCH_CONTINUE;
        }
-       for (int i = 1; i < numfields; ++i)
+       for (int i = 1; i < num_fields; ++i)
        {
                switch (i)
                {
@@ -692,21 +692,21 @@ float PlayerTemplateHook_ItemTouch(entity player, entity item, string template)
 }
 
 float PlayerTemplateHook_Damage_Calculate(entity attacker,
-       string attackertemplate, entity victim, string victimtemplate,
-       float deathtype, float damage)
+       string attacker_template, entity victim, string victim_template,
+       float death_type, float damage)
 {
        if (autocvar_g_instagib == 1)
        {
                return damage;
        }
-       if ((attacker == victim) && (DEATH_ISWEAPON(deathtype, WEP_BLASTER)) &&
-               (PlayerTemplate_GetFloatValue(victimtemplate, "blaster_self_damage") ==
+       if ((attacker == victim) && (DEATH_ISWEAPON(death_type, WEP_BLASTER)) &&
+               (PlayerTemplate_GetFloatValue(victim_template, "blaster_self_damage") ==
                0))
        {
                return 0;
        }
-       damage *= PlayerTemplate_GetFloatValue(attackertemplate, "attack_scale");
-       damage /= PlayerTemplate_GetFloatValue(victimtemplate, "defense_scale");
+       damage *= PlayerTemplate_GetFloatValue(attacker_template, "attack_scale");
+       damage /= PlayerTemplate_GetFloatValue(victim_template, "defense_scale");
        return damage;
 }
 
index d9ecb7acd70f3e887631d3a7586a42073f6062d2..1cf87e38454c47718a08c8ee5c17d980ce23d952 100644 (file)
@@ -53,7 +53,6 @@ float PlayerTemplate_GivePlayerItem(entity player, string template,
 /// \brief Setups the player during spawn according to the given template.
 /// \param[in,out] player Player to setup.
 /// \param[in] template Name of the template.
-/// \return No return.
 void PlayerTemplateHook_PlayerSpawn(entity player, string template);
 
 /// \brief Forbids weapon dropping according to the given template.
@@ -76,20 +75,19 @@ float PlayerTemplateHook_ItemTouch(entity player, entity item, string template);
 
 /// \brief Changes the damage done using templates' attack and defense scales.
 /// \param[in] attacke Attacker entity.
-/// \param[in] attackertemplate Template of the attacker.
+/// \param[in] attacker_template Template of the attacker.
 /// \param[in] victim Victim entity.
-/// \param[in] victimtemplate Template of the victim.
-/// \param[in] deathtype Type of the damage.
+/// \param[in] victim_template Template of the victim.
+/// \param[in] death_type Type of the damage.
 /// \param[in] damage Damage to adjust.
 /// \return Adjusted damage.
 float PlayerTemplateHook_Damage_Calculate(entity attacker,
-       string attackertemplate, entity victim, string victimtemplate,
-       float deathtype, float damage);
+       string attacker_template, entity victim, string victim_template,
+       float death_type, float damage);
 
 /// \brief Strips the player of their weapons if the player is not allowed to
 /// drop them.
 /// \param[in,out] player Player to work with.
 /// \param[in] template Name of the template.
-/// \return No return.
 /// \note You must hook with CBC_ORDER_FIRST in order for this to be effective.
 void PlayerTemplateHook_PlayerDies(entity player, string template);