Skip to content

Commit

Permalink
fix building loading
Browse files Browse the repository at this point in the history
  • Loading branch information
FynnTW committed Oct 9, 2024
1 parent 3ef6a0a commit da2a7c1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
19 changes: 19 additions & 0 deletions M2TWEOP Code/M2TWEOP library/Injects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4887,6 +4887,25 @@ void onPartialConstructionPush::SetNewCode()
delete a;
}

onLoadBuilding::onLoadBuilding(MemWork* mem, LPVOID addr, int ver)
:AATemplate(mem), funcAddress(addr)
{
if (ver == 2)//steam
m_adress = 0x005EE0EB;

else if (ver == 1)//kingdoms
m_adress = 0x005EDC8B;
}

void onLoadBuilding::SetNewCode()
{
const auto a = new Assembler();
a->mov(ecx, dword_ptr(eax, 0x38));
a->ret();
m_cheatBytes = static_cast<unsigned char*>(a->make());
delete a;
}

onOffMapModelThing::onOffMapModelThing(MemWork* mem, LPVOID addr, int ver)
:AATemplate(mem), funcAddress(addr)
{
Expand Down
12 changes: 12 additions & 0 deletions M2TWEOP Code/M2TWEOP library/Injects.h
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,18 @@ class onHiddenResourceCheck
LPVOID funcAddress;
};

class onLoadBuilding
:public AATemplate
{
public:
onLoadBuilding(MemWork* mem, LPVOID addr, int ver);
~onLoadBuilding() = default;

void SetNewCode();
private:
LPVOID funcAddress;
};

class onHiddenResourceCheck2
:public AATemplate
{
Expand Down
6 changes: 6 additions & 0 deletions M2TWEOP Code/M2TWEOP library/managerF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,12 @@ void managerF::execPatches()
toPartialConstructionPush->Enable();
f1 << "Done" << '\n';

f1 << "Start applying onLoadBuilding patch" << '\n';
onLoadBuilding* toLoadBuilding = new onLoadBuilding(mem, (LPVOID)noFunc, globals::dataS.gameVersion);
toLoadBuilding->SetNewCode();
toLoadBuilding->Enable();
f1 << "Done" << '\n';

f1 << "Start applying onOffMapModelThing patch" << '\n';
onOffMapModelThing* toOffMapModelThing = new onOffMapModelThing(mem, (LPVOID)patchesForGame::onOffMapModelThing, globals::dataS.gameVersion);
toOffMapModelThing->SetNewCode();
Expand Down

0 comments on commit da2a7c1

Please sign in to comment.