Guest User

towns

a guest
Jul 10th, 2020
645
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.47 KB | None | 0 0
  1. // dllmain.cpp: определяет точку входа для приложения DLL.
  2. #include "targetver.h"
  3.  
  4. #include <windows.h>
  5. #include <stdlib.h>
  6. #include <stdio.h>
  7.  
  8. //#include "..\..\include\patcher_x86_commented.hpp"
  9. #include "..\..\include\HotA\HoMM3.h"
  10. #include "..\..\include\era.h"
  11.  
  12.  
  13. char buf[1023];
  14.  
  15. void __stdcall PatchIt (PEvent e)
  16. {  
  17.     char sec_name[255];
  18.    
  19.     for(int town = 0; town!=9; town++)
  20.     {
  21.         for(int building = 0; building!=44; building++)
  22.         {
  23.             sprintf(sec_name,"TOWN%02i_BUILDING%02i",town,building);
  24.  
  25.             ReadStrFromIni( "X" , sec_name, "town_coords.ini", buf);
  26.             if(*buf) *(short*)(0x0068AA0C + 2 + (44 * town + building) * 6 ) = atoi(buf);
  27.             ReadStrFromIni( "Y" , sec_name, "town_coords.ini", buf);
  28.             if(*buf) *(short*)(0x0068AA0C + 4 + (44 * town + building) * 6 ) = atoi(buf);
  29.             ReadStrFromIni("Unk", sec_name, "town_coords.ini", buf);
  30.             if(*buf) *(short*)(0x0068AA0C + 0 + (44 * town + building) * 6 ) = atoi(buf);
  31.  
  32.             ReadStrFromIni("DefName", sec_name, "town_coords.ini", buf);
  33.             if(*buf)
  34.             {
  35.                 *(int*)(0x643074 + (44 * town + building) * 4 ) = (int)o_MemAlloc(strlen(buf)+1);
  36.                 strncpy((char*)(*(int*)(0x643074 + (44 * town + building) * 4) ), buf, strlen(buf));
  37.                 ((char*)(*(int*)(0x643074 + (44 * town + building) * 4)))[strlen(buf)]=0;
  38.  
  39.             }
  40.             ReadStrFromIni("OvrName", sec_name, "town_coords.ini", buf);
  41.             if(*buf)
  42.             {
  43.                 *(int*)(0x68A3DC + (44 * town + building) * 4 ) = (int)o_MemAlloc(strlen(buf)+1);
  44.                 strncpy((char*)(*(int*)(0x68A3DC + (44 * town + building) * 4) ), buf, strlen(buf));
  45.                 ((char*)(*(int*)(0x68A3DC + (44 * town + building) * 4)))[strlen(buf)]=0;
  46.             }
  47.         }  
  48.  
  49.         sprintf(sec_name,"TOWN%02i_DEPTH",town);
  50.         ReadStrFromIni("DepthList", sec_name, "town_coords.ini", buf);
  51.                    
  52.         if(*buf)
  53.         {
  54.               char *p= strtok(buf, ",; ");
  55.               int offset = 0;
  56.  
  57.               do {
  58.                 p = strtok('\0', ",; ");
  59.                 if(p)
  60.                 {
  61.                     *(char*)(0x642EC4+town*44+offset) = atoi(p);
  62.                     offset++;
  63.                 }
  64.               } while(p);
  65.  
  66.  
  67.                 for(; offset<44; offset++)
  68.                     *(char*)(0x642EC4+town*44+offset) = 0xFF;
  69.         }
  70.     }
  71.  
  72. }
  73.  
  74. BOOL APIENTRY DllMain( HMODULE hModule,
  75.                        DWORD  ul_reason_for_call,
  76.                        LPVOID lpReserved
  77.                      )
  78. {
  79.     if (ul_reason_for_call == DLL_PROCESS_ATTACH)
  80.     {
  81.         ConnectEra();
  82.        
  83.         RegisterHandler(PatchIt,"OnAfterCreateWindow");
  84.  
  85.     /*case :
  86.     case DLL_THREAD_ATTACH:
  87.     case DLL_THREAD_DETACH:
  88.     case DLL_PROCESS_DETACH:
  89.         break;*/
  90.     }
  91.     return TRUE;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment