Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // dllmain.cpp: определяет точку входа для приложения DLL.
- #include "targetver.h"
- #include <windows.h>
- #include <stdlib.h>
- #include <stdio.h>
- //#include "..\..\include\patcher_x86_commented.hpp"
- #include "..\..\include\HotA\HoMM3.h"
- #include "..\..\include\era.h"
- char buf[1023];
- void __stdcall PatchIt (PEvent e)
- {
- char sec_name[255];
- for(int town = 0; town!=9; town++)
- {
- for(int building = 0; building!=44; building++)
- {
- sprintf(sec_name,"TOWN%02i_BUILDING%02i",town,building);
- ReadStrFromIni( "X" , sec_name, "town_coords.ini", buf);
- if(*buf) *(short*)(0x0068AA0C + 2 + (44 * town + building) * 6 ) = atoi(buf);
- ReadStrFromIni( "Y" , sec_name, "town_coords.ini", buf);
- if(*buf) *(short*)(0x0068AA0C + 4 + (44 * town + building) * 6 ) = atoi(buf);
- ReadStrFromIni("Unk", sec_name, "town_coords.ini", buf);
- if(*buf) *(short*)(0x0068AA0C + 0 + (44 * town + building) * 6 ) = atoi(buf);
- ReadStrFromIni("DefName", sec_name, "town_coords.ini", buf);
- if(*buf)
- {
- *(int*)(0x643074 + (44 * town + building) * 4 ) = (int)o_MemAlloc(strlen(buf)+1);
- strncpy((char*)(*(int*)(0x643074 + (44 * town + building) * 4) ), buf, strlen(buf));
- ((char*)(*(int*)(0x643074 + (44 * town + building) * 4)))[strlen(buf)]=0;
- }
- ReadStrFromIni("OvrName", sec_name, "town_coords.ini", buf);
- if(*buf)
- {
- *(int*)(0x68A3DC + (44 * town + building) * 4 ) = (int)o_MemAlloc(strlen(buf)+1);
- strncpy((char*)(*(int*)(0x68A3DC + (44 * town + building) * 4) ), buf, strlen(buf));
- ((char*)(*(int*)(0x68A3DC + (44 * town + building) * 4)))[strlen(buf)]=0;
- }
- }
- sprintf(sec_name,"TOWN%02i_DEPTH",town);
- ReadStrFromIni("DepthList", sec_name, "town_coords.ini", buf);
- if(*buf)
- {
- char *p= strtok(buf, ",; ");
- int offset = 0;
- do {
- p = strtok('\0', ",; ");
- if(p)
- {
- *(char*)(0x642EC4+town*44+offset) = atoi(p);
- offset++;
- }
- } while(p);
- for(; offset<44; offset++)
- *(char*)(0x642EC4+town*44+offset) = 0xFF;
- }
- }
- }
- BOOL APIENTRY DllMain( HMODULE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved
- )
- {
- if (ul_reason_for_call == DLL_PROCESS_ATTACH)
- {
- ConnectEra();
- RegisterHandler(PatchIt,"OnAfterCreateWindow");
- /*case :
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- case DLL_PROCESS_DETACH:
- break;*/
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment