Skip to content

Commit

Permalink
Fix refunding currency and resetting upgrades twice (#7)
Browse files Browse the repository at this point in the history
Fixes #6
  • Loading branch information
Mikusch authored Oct 3, 2021
1 parent ee1d1aa commit 8d46047
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
19 changes: 19 additions & 0 deletions addons/sourcemod/gamedata/mannvsmann.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"linux" "@_ZN18CPopulationManager22AddPlayerCurrencySpentEP9CTFPlayeri"
"windows" "\x55\x8B\xEC\x83\xEC\x08\x81\x65\xFC\xFF\xFF\x0F\xFF\x8D\x45\xF8\x56\x8B\x75\x08\x57\x8B\xF9\xC6\x45\xFF\x00\x81\x65\xFC\x00\x00\xF0\xFF\x8B\xCE\x50\xC7\x45\xF8\x00\x00\x00\x00\xE8\x2A\x2A\x2A\x2A\x84\xC0\x75\x2A\x8D\x86\x84\x0E\x00\x00\x50\x68\x2A\x2A\x2A\x2A\xFF\x15\x2A\x2A\x2A\x2A\x83\xC4\x08\x5F"
}
"CPopulationManager::RemovePlayerAndItemUpgradesFromHistory"
{
"linux" "@_ZN18CPopulationManager38RemovePlayerAndItemUpgradesFromHistoryEP9CTFPlayer"
"windows" "\x55\x8B\xEC\x83\xEC\x14\x81\x65\xF0\xFF\xFF\x0F\xFF"
}
"CTFGameRules::IsQuickBuildTime"
{
"linux" "@_ZN12CTFGameRules16IsQuickBuildTimeEv"
Expand Down Expand Up @@ -243,6 +248,20 @@
"return" "void"
"this" "entity"
}
"CPopulationManager::RemovePlayerAndItemUpgradesFromHistory"
{
"signature" "CPopulationManager::RemovePlayerAndItemUpgradesFromHistory"
"callconv" "thiscall"
"return" "void"
"this" "entity"
"arguments"
{
"pPlayer"
{
"type" "cbaseentity"
}
}
}
"CTFGameRules::IsQuickBuildTime"
{
"signature" "CTFGameRules::IsQuickBuildTime"
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/mannvsmann.sp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_VERSION "1.2.1"
#define PLUGIN_VERSION "1.2.2"

#define TF_GAMETYPE_ARENA 4
#define MEDIGUN_CHARGE_INVULN 0
Expand Down
13 changes: 13 additions & 0 deletions addons/sourcemod/scripting/mannvsmann/dhooks.sp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ void DHooks_Initialize(GameData gamedata)
CreateDynamicDetour(gamedata, "CUpgrades::ApplyUpgradeToItem", DHookCallback_ApplyUpgradeToItem_Pre, DHookCallback_ApplyUpgradeToItem_Post);
CreateDynamicDetour(gamedata, "CPopulationManager::Update", DHookCallback_PopulationManagerUpdate_Pre, _);
CreateDynamicDetour(gamedata, "CPopulationManager::ResetMap", DHookCallback_PopulationManagerResetMap_Pre, DHookCallback_PopulationManagerResetMap_Post);
CreateDynamicDetour(gamedata, "CPopulationManager::RemovePlayerAndItemUpgradesFromHistory", DHookCallback_RemovePlayerAndItemUpgradesFromHistory_Pre, DHookCallback_RemovePlayerAndItemUpgradesFromHistory_Post);
CreateDynamicDetour(gamedata, "CTFGameRules::IsQuickBuildTime", DHookCallback_IsQuickBuildTime_Pre, DHookCallback_IsQuickBuildTime_Post);
CreateDynamicDetour(gamedata, "CTFGameRules::GameModeUsesUpgrades", _, DHookCallback_GameModeUsesUpgrades_Post);
CreateDynamicDetour(gamedata, "CTFGameRules::CanPlayerUseRespec", DHookCallback_CanPlayerUseRespec_Pre, DHookCallback_CanPlayerUseRespec_Post);
Expand Down Expand Up @@ -158,6 +159,18 @@ public MRESReturn DHookCallback_PopulationManagerResetMap_Post()
}
}

public MRESReturn DHookCallback_RemovePlayerAndItemUpgradesFromHistory_Pre(int populator, DHookParam params)
{
//This function handles refunding currency and resetting upgrade history during a respec
//Block this, as we already handle it ourselves in the respec menu handler
SetMannVsMachineMode(false);
}

public MRESReturn DHookCallback_RemovePlayerAndItemUpgradesFromHistory_Post(int populator, DHookParam params)
{
ResetMannVsMachineMode();
}

public MRESReturn DHookCallback_IsQuickBuildTime_Pre()
{
//Allows Engineers to quickbuild during setup
Expand Down

0 comments on commit 8d46047

Please sign in to comment.