Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include "..\..\include\patcher_x86_commented.hpp"
- Patcher * globalPatcher;
- PatcherInstance *patcher;
- struct _TownBuildingInfo_
- {
- char* short_name;
- char* long_name;
- int prerequisit;
- };
- #define o_KnightBuildings ((_TownBuildingInfo_*)0x005A6458)
- #define o_SorcBuildings ((_TownBuildingInfo_*)0x005A7830)
- #define o_WizardBuildings ((_TownBuildingInfo_*)0x005A6860)
- #define o_HereticBuildings ((_TownBuildingInfo_*)0x005A6240)
- #define o_WarlockBuildings ((_TownBuildingInfo_*)0x005A71D0)
- #define o_NecromancyBuildings ((_TownBuildingInfo_*)0x005A75F0)
- #define o_BarbarianBuildings ((_TownBuildingInfo_*)0x005A6AE0)
- #define o_WitchBuildings ((_TownBuildingInfo_*)0x005A6F30)
- #define o_DervishBuildings ((_TownBuildingInfo_*)0x005A6D10)
- #define o_RandomBuildings ((_TownBuildingInfo_*)0x005A6660)
- #define ME_TOWN_HALL 0
- #define ME_CITY_HALL 1
- #define ME_CAPITOL 2
- #define ME_FORT 3
- #define ME_CITADEL 4
- #define ME_CASTLE 5
- #define ME_TAVERN 6
- #define ME_BLACKMITH 7
- #define ME_MARKETPLACE 8
- #define ME_SILO 9
- #define ME_ART_MERCHANT 10
- #define ME_MAGE_GUILD_1 11
- #define ME_MAGE_GUILD_2 12
- #define ME_MAGE_GUILD_3 13
- #define ME_MAGE_GUILD_4 14
- #define ME_MAGE_GUILD_5 15
- #define ME_SHIPYARD 16
- #define ME_GRAIL 17
- #define ME_SPEC1 18 //
- #define ME_SPEC2 19
- #define ME_SPEC3 20
- #define ME_SPEC4 21
- #define ME_DWELL1 22
- #define ME_DWELL1_UP 23
- #define ME_DWELL1_HORDE 24
- #define ME_DWELL2 25
- #define ME_DWELL2_UP 26
- #define ME_DWELL2_HORDE 27
- #define ME_DWELL3 28
- #define ME_DWELL3_UP 29
- #define ME_DWELL3_HORDE 30
- #define ME_DWELL4 31
- #define ME_DWELL4_UP 32
- #define ME_DWELL4_HORDE 33
- #define ME_DWELL5 34
- #define ME_DWELL5_UP 35
- #define ME_DWELL5_HORDE 36
- #define ME_DWELL6 37
- #define ME_DWELL6_UP 38
- #define ME_DWELL7 39
- #define ME_DWELL7_UP 40
- void CopyBuildingInformation(_TownBuildingInfo_* source, _TownBuildingInfo_* destination)
- {
- source->short_name = destination->short_name;
- source->long_name = destination->long_name;
- source->prerequisit = destination->prerequisit;
- }
- void DisableBuilding(_TownBuildingInfo_* source)
- {
- source->short_name = 0;
- source->long_name = 0;
- source->prerequisit = -1;
- }
- void FlattenBuildingsPrereqs(_TownBuildingInfo_* source)
- {
- source->prerequisit = -1;
- }
- void __stdcall OnTownsLoad(HiHook* h)
- {
- CALL_0(void, __stdcall, h->GetDefaultFunc());
- //MageGuilds
- CopyBuildingInformation(o_KnightBuildings + ME_MAGE_GUILD_5, o_WarlockBuildings + ME_MAGE_GUILD_5);
- CopyBuildingInformation(o_WitchBuildings + ME_MAGE_GUILD_4, o_WarlockBuildings + ME_MAGE_GUILD_4);
- CopyBuildingInformation(o_WitchBuildings + ME_MAGE_GUILD_5, o_WarlockBuildings + ME_MAGE_GUILD_5);
- CopyBuildingInformation(o_BarbarianBuildings + ME_MAGE_GUILD_4, o_WarlockBuildings + ME_MAGE_GUILD_4);
- CopyBuildingInformation(o_BarbarianBuildings + ME_MAGE_GUILD_5, o_WarlockBuildings + ME_MAGE_GUILD_5);
- CopyBuildingInformation(o_SorcBuildings + ME_SHIPYARD, o_KnightBuildings + ME_SHIPYARD);
- CopyBuildingInformation(o_WizardBuildings + ME_SHIPYARD, o_KnightBuildings + ME_SHIPYARD);
- CopyBuildingInformation(o_BarbarianBuildings + ME_SHIPYARD, o_KnightBuildings + ME_SHIPYARD);
- CopyBuildingInformation(o_WarlockBuildings + ME_SHIPYARD, o_KnightBuildings + ME_SHIPYARD);
- CopyBuildingInformation(o_HereticBuildings + ME_SHIPYARD, o_KnightBuildings + ME_SHIPYARD);
- /*DisableBuilding(o_KnightBuildings + ME_GRAIL);
- DisableBuilding(o_SorcBuildings + ME_GRAIL);
- DisableBuilding(o_WizardBuildings + ME_GRAIL);
- DisableBuilding(o_HereticBuildings + ME_GRAIL);
- DisableBuilding(o_NecromancyBuildings + ME_GRAIL);
- DisableBuilding(o_WarlockBuildings + ME_GRAIL);
- DisableBuilding(o_BarbarianBuildings + ME_GRAIL);
- DisableBuilding(o_WitchBuildings + ME_GRAIL);
- DisableBuilding(o_DervishBuildings + ME_GRAIL);*/
- _TownBuildingInfo_* allfractions[] = {o_KnightBuildings, o_SorcBuildings, o_WizardBuildings,
- o_HereticBuildings, o_NecromancyBuildings, o_WarlockBuildings,
- o_BarbarianBuildings, o_WitchBuildings, o_DervishBuildings,
- o_RandomBuildings};
- int dwells[] = {ME_DWELL1, ME_DWELL2, ME_DWELL3, ME_DWELL4, ME_DWELL5, ME_DWELL6, ME_DWELL7};
- for(int i = 0; i!=10; i++)
- {
- DisableBuilding(allfractions[i]+ME_GRAIL);
- for(int j = 0; j!=7; j++)
- {
- FlattenBuildingsPrereqs(allfractions[i]+dwells[j]);
- }
- }
- //Fortifications
- DisableBuilding(o_KnightBuildings + ME_SPEC1);
- //Lookout Tower
- DisableBuilding(o_WizardBuildings + ME_SPEC3);
- //Mirage
- DisableBuilding(o_DervishBuildings + ME_SPEC1);
- //Rainbow
- o_SorcBuildings[ME_SPEC2].prerequisit = -1;
- //Treasury
- o_SorcBuildings[ME_SPEC3].prerequisit = ME_CITADEL;
- //Crystal Garden
- o_SorcBuildings[ME_DWELL5_HORDE].prerequisit = ME_DWELL1;
- //Orchard
- o_WizardBuildings[ME_DWELL2_HORDE].prerequisit = ME_DWELL1;
- //Black tower
- o_WarlockBuildings[ME_SPEC2].prerequisit = ME_DWELL7_UP;
- //Upgrades
- DisableBuilding(o_KnightBuildings + ME_DWELL1_UP);
- DisableBuilding(o_SorcBuildings + ME_DWELL1_UP);
- DisableBuilding(o_SorcBuildings + ME_DWELL2_HORDE);
- DisableBuilding(o_SorcBuildings + ME_DWELL4_UP);
- DisableBuilding(o_SorcBuildings + ME_DWELL6_UP);
- DisableBuilding(o_SorcBuildings + ME_DWELL7_UP);
- DisableBuilding(o_WizardBuildings + ME_DWELL1_UP);
- DisableBuilding(o_WizardBuildings + ME_DWELL2_UP);
- DisableBuilding(o_WizardBuildings + ME_DWELL3_UP);
- DisableBuilding(o_WizardBuildings + ME_DWELL5_UP);
- DisableBuilding(o_NecromancyBuildings + ME_DWELL1_UP);
- DisableBuilding(o_NecromancyBuildings + ME_DWELL5_UP);
- DisableBuilding(o_NecromancyBuildings + ME_DWELL7_UP);
- DisableBuilding(o_WarlockBuildings + ME_DWELL1_UP);
- DisableBuilding(o_WarlockBuildings + ME_DWELL2_UP);
- DisableBuilding(o_WarlockBuildings + ME_DWELL3_UP);
- DisableBuilding(o_WarlockBuildings + ME_DWELL4_UP);
- DisableBuilding(o_WarlockBuildings + ME_DWELL6_UP);
- DisableBuilding(o_BarbarianBuildings + ME_DWELL1_UP);
- DisableBuilding(o_BarbarianBuildings + ME_DWELL3_UP);
- DisableBuilding(o_BarbarianBuildings + ME_DWELL4_UP);
- DisableBuilding(o_BarbarianBuildings + ME_DWELL7_UP);
- DisableBuilding(o_WitchBuildings + ME_DWELL1_UP);
- DisableBuilding(o_WitchBuildings + ME_DWELL2_UP);
- DisableBuilding(o_WitchBuildings + ME_DWELL4_UP);
- DisableBuilding(o_WitchBuildings + ME_DWELL5_UP);
- DisableBuilding(o_WitchBuildings + ME_DWELL6_UP);
- DisableBuilding(o_WitchBuildings + ME_DWELL7_UP);
- DisableBuilding(o_DervishBuildings + ME_DWELL2_UP);
- DisableBuilding(o_DervishBuildings + ME_DWELL3_UP);
- DisableBuilding(o_DervishBuildings + ME_DWELL5_UP);
- DisableBuilding(o_DervishBuildings + ME_DWELL6_UP);
- DisableBuilding(o_DervishBuildings + ME_DWELL7_UP);
- //005A6240 - heretic
- //005A6458 - castle
- //005A6660 - random
- //005A6860 - wizard
- //005A6AE0 - barbarian
- //005A6D10 - dervish
- //005A6F30 - witch
- //005A71D0 - warlock4
- //005A75F0 - necromancer
- //005A7830 - sorc
- //005A6240
- }
- void __stdcall ColorCycle(HiHook* h, int th, int _1, int _2, int _3)
- {
- CALL_4(void, __thiscall, h->GetDefaultFunc(), th, 0xEC, 0xED, -1);
- CALL_4(void, __thiscall, h->GetDefaultFunc(), th, 0xE7, 0xEB, -1);
- CALL_4(void, __thiscall, h->GetDefaultFunc(), th, 0xD6, 0xD9, -1);
- }
- void __stdcall ColorCycleNOP(HiHook* h, int th, int _1, int _2, int _3)
- {
- }
- BOOL APIENTRY DllMain( HMODULE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved
- )
- {
- if (ul_reason_for_call == DLL_PROCESS_ATTACH)
- {
- globalPatcher = GetPatcher();
- patcher = globalPatcher->CreateInstance("h2sw_mapeditor");
- patcher->WriteHiHook(0x4CB57C, SPLICE_, EXTENDED_, STDCALL_, OnTownsLoad);
- patcher->WriteHiHook(0x4BE88C, CALL_, EXTENDED_, THISCALL_, ColorCycle); //water 0xE5, 0xF0, -1
- patcher->WriteHiHook(0x4BE89E, CALL_, EXTENDED_, THISCALL_, ColorCycleNOP); //water 0xF2, 0xFD, -1
- //patcher->WriteHiHook(0x4BE8C5, CALL_, EXTENDED_, THISCALL_, ColorCycle); //lavatl 0xF6, 0xFE, -1
- patcher->WriteHiHook(0x4BE8DD, CALL_, EXTENDED_, THISCALL_, ColorCycle); //clrrvr 0xB7, 0xC2, -1
- patcher->WriteHiHook(0x4BE8FE, CALL_, EXTENDED_, THISCALL_, ColorCycleNOP); //clrrvr 0xC3, 0xC8, -1
- //patcher->WriteHiHook(0x4BE916, CALL_, EXTENDED_, THISCALL__, ColorCycle6); //mudrvr 0xE4, 0xEF, -1
- //patcher->WriteHiHook(0x4BE928, CALL_, EXTENDED_, THISCALL__, ColorCycle7); //mudrvr 0xB7, 0xBC, -1
- //patcher->WriteHiHook(0x4BE936, CALL_, EXTENDED_, THISCALL__, ColorCycle8); //mudrvr 0xF0, 0xF5, -1
- //patcher->WriteHiHook(0x4BE94B, CALL_, EXTENDED_, THISCALL_, ColorCycle); //lavrvr 0xF0, 0xF8, -1
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement