Skip to content

Commit

Permalink
Code style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikusch committed Jan 14, 2025
1 parent 383af7c commit 0fe7c07
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
22 changes: 11 additions & 11 deletions addons/sourcemod/scripting/mannvsmann.sp
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,10 @@ public void OnEntityCreated(int entity, const char[] classname)
// CTFPlayer::DropCurrencyPack does not assign a team to the currency pack but CTFGameRules::DistributeCurrencyAmount needs to know it
if (g_CurrencyPackTeam != TFTeam_Invalid)
{
TF2_SetTeam(entity, g_CurrencyPackTeam);
TF2_SetEntityTeam(entity, g_CurrencyPackTeam);
}
}
else if (!strcmp(classname, "tf_dropped_weapon"))
else if (StrEqual(classname, "tf_dropped_weapon"))
{
// Do not allow dropped weapons, as you can sell their upgrades for free currency
RemoveEntity(entity);
Expand Down Expand Up @@ -362,10 +362,10 @@ public void OnEntityDestroyed(int entity)
if (!GetEntProp(entity, Prop_Send, "m_bDistributed"))
{
int amount = GetEntData(entity, GetOffset("CCurrencyPack", "m_nAmount"));
AddWorldMoney(TF2_GetTeam(entity), -amount);
AddWorldMoney(TF2_GetEntityTeam(entity), -amount);
}
}
else if (!strcmp(classname, "func_regenerate"))
else if (StrEqual(classname, "func_regenerate"))
{
// DisableAndEndTouch doesn't work here because m_hTouchingEntities is empty at this point
for (int client = 1; client <= MaxClients; client++)
Expand All @@ -392,7 +392,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
GetClientWeapon(client, name, sizeof(name));

// Resist mediguns can instantly revive in MvM (CWeaponMedigun::SecondaryAttack)
if (!strcmp(name, "tf_weapon_medigun"))
if (StrEqual(name, "tf_weapon_medigun"))
{
SetMannVsMachineMode(true);
}
Expand Down Expand Up @@ -426,7 +426,7 @@ public Action OnClientCommandKeyValues(int client, KeyValues kv)
{
if (!strncmp(section, "MvM_", 4, false))
{
if (!strcmp(section, "MVM_Upgrade"))
if (StrEqual(section, "MVM_Upgrade"))
{
// Required for tracking of spent currency
SetMannVsMachineMode(true);
Expand All @@ -437,7 +437,7 @@ public Action OnClientCommandKeyValues(int client, KeyValues kv)
MvMPlayer(client).HasPurchasedUpgrades = true;
}
}
else if (!strcmp(section, "MvM_UpgradesBegin"))
else if (StrEqual(section, "MvM_UpgradesBegin"))
{
if (sm_mvm_respec_enabled.BoolValue)
{
Expand All @@ -448,7 +448,7 @@ public Action OnClientCommandKeyValues(int client, KeyValues kv)
menu.Display(client, MENU_TIME_FOREVER);
}
}
else if (!strcmp(section, "MvM_UpgradesDone"))
else if (StrEqual(section, "MvM_UpgradesDone"))
{
// Do upgrade voice lines
if (kv.GetNum("num_upgrades", 0) > 0)
Expand Down Expand Up @@ -490,7 +490,7 @@ public Action OnClientCommandKeyValues(int client, KeyValues kv)
}
}
}
else if (!strcmp(section, "+use_action_slot_item_server"))
else if (StrEqual(section, "+use_action_slot_item_server"))
{
SetMannVsMachineMode(true);

Expand Down Expand Up @@ -726,7 +726,7 @@ static Action NormalSoundHook(int clients[MAXPLAYERS], int &numClients, char sam
if (GetEntityClassname(entity, classname, sizeof(classname)))
{
// Make revive markers and money pickups silent for the other team
if (!strcmp(classname, "entity_revive_marker") || !strncmp(classname, "item_currencypack_", 18))
if (StrEqual(classname, "entity_revive_marker") || !strncmp(classname, "item_currencypack_", 18))
{
for (int i = 0; i < numClients; i++)
{
Expand Down Expand Up @@ -815,7 +815,7 @@ static int MenuHandler_UpgradeRespec(Menu menu, MenuAction action, int param1, i
char info[64];
if (menu.GetItem(param2, info, sizeof(info)))
{
if (!strcmp(info, "respec") && sm_mvm_respec_enabled.BoolValue)
if (StrEqual(info, "respec") && sm_mvm_respec_enabled.BoolValue)
{
SetVariantString("!self.GrantOrRemoveAllUpgrades(true, true)");
AcceptEntityInput(param1, "RunScriptCode");
Expand Down
10 changes: 5 additions & 5 deletions addons/sourcemod/scripting/mannvsmann/dhooks.sp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void DHooks_OnEntityCreated(int entity, const char[] classname)
}
}

if (!strcmp(classname, "tf_projectile_stun_ball") || !strcmp(classname, "tf_projectile_ball_ornament"))
if (StrEqual(classname, "tf_projectile_stun_ball") || StrEqual(classname, "tf_projectile_ball_ornament"))
{
if (g_DHook_CTFStunBall_ApplyBallImpactEffectOnVictim)
{
Expand Down Expand Up @@ -615,8 +615,8 @@ static MRESReturn DHookCallback_CBaseObject_ShouldQuickBuild_Pre(int obj, DHookR
SetMannVsMachineMode(true);

// Sentries owned by MvM defenders can be re-deployed quickly, move the sentry to the defender team
g_PreHookTeam = TF2_GetTeam(obj);
TF2_SetTeam(obj, TFTeam_Red);
g_PreHookTeam = TF2_GetEntityTeam(obj);
TF2_SetEntityTeam(obj, TFTeam_Red);
}

return MRES_Ignored;
Expand All @@ -628,7 +628,7 @@ static MRESReturn DHookCallback_CBaseObject_ShouldQuickBuild_Post(int obj, DHook
{
ResetMannVsMachineMode();

TF2_SetTeam(obj, g_PreHookTeam);
TF2_SetEntityTeam(obj, g_PreHookTeam);
}

return MRES_Ignored;
Expand Down Expand Up @@ -838,7 +838,7 @@ static MRESReturn DHookCallback_CCurrencyPack_ComeToRest_Pre(int currencypack)
SetMannVsMachineMode(true);

// Set the currency pack team for distribution
g_CurrencyPackTeam = TF2_GetTeam(currencypack);
g_CurrencyPackTeam = TF2_GetEntityTeam(currencypack);

return MRES_Ignored;
}
Expand Down
6 changes: 3 additions & 3 deletions addons/sourcemod/scripting/mannvsmann/events.sp
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ static Action EventHook_TeamplayBroadcastAudio(Event event, const char[] name, b

if (sm_mvm_music_enabled.BoolValue)
{
if (!strcmp(sound, "Game.YourTeamWon"))
if (StrEqual(sound, "Game.YourTeamWon"))
{
event.SetString("sound", IsInArenaMode() ? "music.mvm_end_wave" : "music.mvm_end_mid_wave");
return Plugin_Changed;
}
else if (!strcmp(sound, "Game.YourTeamLost") || !strcmp(sound, "Game.Stalemate"))
else if (StrEqual(sound, "Game.YourTeamLost") || StrEqual(sound, "Game.Stalemate"))
{
event.SetString("sound", "music.mvm_lost_wave");
return Plugin_Changed;
Expand Down Expand Up @@ -212,7 +212,7 @@ static void EventHook_PlayerDeath(Event event, const char[] name, bool dontBroad

// Give money directly to the enemy team if a trigger killed the player
char classname[16];
if (inflictor != -1 && GetEntityClassname(inflictor, classname, sizeof(classname)) && !strncmp(classname, "trigger_", 8))
if (inflictor != -1 && GetEntityClassname(inflictor, classname, sizeof(classname)) && StrEqual(classname, "trigger_hurt"))
{
g_CurrencyPackTeam = TF2_GetEnemyTeam(TF2_GetClientTeam(victim));
SDKCall_DistributeCurrencyAmount(dropAmount, -1, true, true);
Expand Down
10 changes: 5 additions & 5 deletions addons/sourcemod/scripting/mannvsmann/helpers.sp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ void RemoveEntitiesByClassname(const char[] classname)
}
}

TFTeam TF2_GetTeam(int entity)
TFTeam TF2_GetEntityTeam(int entity)
{
return view_as<TFTeam>(GetEntProp(entity, Prop_Send, "m_iTeamNum"));
}

void TF2_SetTeam(int entity, TFTeam team)
void TF2_SetEntityTeam(int entity, TFTeam team)
{
SetEntProp(entity, Prop_Send, "m_iTeamNum", team);
}
Expand Down Expand Up @@ -116,7 +116,7 @@ void ClearCustomUpgradesFile()
GameRules_GetPropString("m_pszCustomUpgradesFile", customUpgradesFile, sizeof(customUpgradesFile));

// Reset to the default upgrades file
if (strcmp(customUpgradesFile, DEFAULT_UPGRADES_FILE))
if (!StrEqual(customUpgradesFile, DEFAULT_UPGRADES_FILE))
{
int gamerules = FindEntityByClassname(-1, "tf_gamerules");
if (gamerules != -1)
Expand Down Expand Up @@ -148,13 +148,13 @@ void ResetMannVsMachineMode()
bool IsEntVisibleToClient(int entity, int client)
{
// Always show neutral entities and allow spectators to see everything
if (TF2_GetTeam(entity) == TFTeam_Unassigned || TF2_GetClientTeam(client) <= TFTeam_Spectator)
if (TF2_GetEntityTeam(entity) == TFTeam_Unassigned || TF2_GetClientTeam(client) <= TFTeam_Spectator)
{
return true;
}

// Only visible when on the same team
return TF2_GetTeam(entity) == TF2_GetClientTeam(client);
return TF2_GetEntityTeam(entity) == TF2_GetClientTeam(client);
}

void AddWorldMoney(TFTeam team, int amount)
Expand Down
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/mannvsmann/methodmaps.sp
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ methodmap MvMPlayer
{
int index = g_PlayerTeamCount[this._client]++;
g_PlayerTeam[this._client][index] = TF2_GetClientTeam(this._client);
TF2_SetTeam(this._client, team);
TF2_SetEntityTeam(this._client, team);
}

public void ResetTeam()
{
int index = --g_PlayerTeamCount[this._client];
TF2_SetTeam(this._client, g_PlayerTeam[this._client][index]);
TF2_SetEntityTeam(this._client, g_PlayerTeam[this._client][index]);
}

public void SetIsMiniBoss(bool isMiniBoss)
Expand Down
24 changes: 12 additions & 12 deletions addons/sourcemod/scripting/mannvsmann/sdkhooks.sp
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,37 @@ void SDKHooks_UnhookClient(int client)

void SDKHooks_OnEntityCreated(int entity, const char[] classname)
{
if (!strcmp(classname, "func_regenerate"))
if (StrEqual(classname, "func_regenerate"))
{
SDKHook(entity, SDKHook_StartTouch, SDKHookCB_Regenerate_StartTouch);
SDKHook(entity, SDKHook_EndTouch, SDKHookCB_Regenerate_EndTouch);
}
else if (!strcmp(classname, "entity_revive_marker"))
else if (StrEqual(classname, "entity_revive_marker"))
{
SDKHook(entity, SDKHook_SetTransmit, SDKHookCB_ReviveMarker_SetTransmit);
}
else if (!strncmp(classname, "item_currencypack_", 18))
{
SDKHook(entity, SDKHook_SpawnPost, SDKHookCB_CurrencyPack_SpawnPost);
}
else if (!strcmp(classname, "obj_attachment_sapper"))
else if (StrEqual(classname, "obj_attachment_sapper"))
{
SDKHook(entity, SDKHook_Spawn, SDKHookCB_Sapper_Spawn);
SDKHook(entity, SDKHook_SpawnPost, SDKHookCB_Sapper_SpawnPost);
}
else if (!strcmp(classname, "func_respawnroom"))
else if (StrEqual(classname, "func_respawnroom"))
{
SDKHook(entity, SDKHook_Touch, SDKHookCB_RespawnRoom_Touch);
}
}

void SDKHooks_UnhookEntity(int entity, const char[] classname)
{
if (!strcmp(classname, "func_regenerate"))
if (StrEqual(classname, "func_regenerate"))
{
SDKUnhook(entity, SDKHook_EndTouch, SDKHookCB_Regenerate_EndTouch);
}
else if (!strcmp(classname, "func_respawnroom"))
else if (StrEqual(classname, "func_respawnroom"))
{
SDKUnhook(entity, SDKHook_Touch, SDKHookCB_RespawnRoom_Touch);
}
Expand Down Expand Up @@ -97,7 +97,7 @@ static Action SDKHookCB_Client_OnTakeDamageAlive(int victim, int &attacker, int
if (GetEntityClassname(weapon, classname, sizeof(classname)))
{
// Modify the damage of the Gas Passer's 'Explode On Ignite' upgrade
if (!strcmp(classname, "tf_weapon_jar_gas") && (damagetype & DMG_SLASH))
if (StrEqual(classname, "tf_weapon_jar_gas") && (damagetype & DMG_SLASH))
{
damage *= sm_mvm_gas_explode_damage_modifier.FloatValue;
return Plugin_Changed;
Expand All @@ -115,7 +115,7 @@ static Action SDKHookCB_Client_OnTakeDamageAlive(int victim, int &attacker, int
{
// Modify the damage of the Medi Gun's 'Projectile Shield' upgrade
char classname[32];
if (GetEntityClassname(inflictor, classname, sizeof(classname)) && !strcmp(classname, "entity_medigun_shield"))
if (GetEntityClassname(inflictor, classname, sizeof(classname)) && StrEqual(classname, "entity_medigun_shield"))
{
damage *= sm_mvm_medigun_shield_damage_modifier.FloatValue;
return Plugin_Changed;
Expand Down Expand Up @@ -187,14 +187,14 @@ static void SDKHookCB_CurrencyPack_SpawnPost(int currencypack)
if (!GetEntProp(currencypack, Prop_Send, "m_bDistributed"))
{
int amount = GetEntData(currencypack, GetOffset("CCurrencyPack", "m_nAmount"));
AddWorldMoney(TF2_GetTeam(currencypack), amount);
AddWorldMoney(TF2_GetEntityTeam(currencypack), amount);
}

SetEdictFlags(currencypack, (GetEdictFlags(currencypack) & ~FL_EDICT_ALWAYS));
SDKHook(currencypack, SDKHook_SetTransmit, CurrencyPack_SetTransmit);
SDKHook(currencypack, SDKHook_SetTransmit, SDKHookCB_CurrencyPack_SetTransmit);
}

static Action CurrencyPack_SetTransmit(int currencypack, int client)
static Action SDKHookCB_CurrencyPack_SetTransmit(int currencypack, int client)
{
// Only transmit currency packs to our own team and spectators
if (!IsEntVisibleToClient(currencypack, client))
Expand Down Expand Up @@ -223,7 +223,7 @@ static Action SDKHookCB_RespawnRoom_Touch(int respawnroom, int other)
if (!IsInArenaMode() && sm_mvm_spawn_protection.BoolValue && GameRules_GetRoundState() != RoundState_TeamWin)
{
// Players get uber while they leave their spawn so they don't drop their cash where enemies can't pick it up
if (!GetEntProp(respawnroom, Prop_Data, "m_bDisabled") && IsValidClient(other) && TF2_GetTeam(respawnroom) == TF2_GetClientTeam(other))
if (!GetEntProp(respawnroom, Prop_Data, "m_bDisabled") && IsValidClient(other) && TF2_GetEntityTeam(respawnroom) == TF2_GetClientTeam(other))
{
TF2_AddCondition(other, TFCond_Ubercharged, 0.5);
TF2_AddCondition(other, TFCond_UberchargedHidden, 0.5);
Expand Down

0 comments on commit 0fe7c07

Please sign in to comment.