Modified GetTile Function
From OPU Wiki
This code modifies GetTile to allow you to see if a tile has the blight on it.
// These are used to let us access more information about a tile than OP2 wants us to.
unsigned char *setTileLoc = (unsigned char *)0x00476D32;
unsigned char oldSetTile[] =
{
0x25, 0xE0, 0xFF, 0x00, 0x00, // and eax, 0FFE0h
0xC1, 0xE8, 0x05 // shr eax, 5
};
unsigned char newSetTile[] =
{
0x90, 0x90, 0x90, 0x90, 0x90, // nop * 5
0x90, 0x90, 0x90 // nop * 3
};
struct mapCell
{
int cellType:5;
int tileIndex:11;
int unitID:11;
int lava:1;
int lavaPossible:1;
int expand:1;
int microbe:1;
int wallBuilding:1;
};
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
DWORD oldAttr;
if (fdwReason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hinstDLL);
// Modify the SetTile code for our purposes
VirtualProtect(setTileLoc, sizeof(newSetTile), PAGE_EXECUTE_READWRITE, &oldAttr);
memcpy(setTileLoc, newSetTile, sizeof(newSetTile));
}
else if (fdwReason == DLL_PROCESS_DETACH)
{
// Put the old SetTile code back
memcpy(setTileLoc, oldSetTile, sizeof(newSetTile));
}
return TRUE;
}
/*
In order to use this, after calling GetTile, add this code:
"memcpy(&cell, &tile, 4);"
To determine if the blight is on the tile, use:
"if (cell.expand || cell.microbe)"
*/
