diff --git a/FALuaFuncs.txt b/FALuaFuncs.txt index 2449b6dd..c9904d78 100644 --- a/FALuaFuncs.txt +++ b/FALuaFuncs.txt @@ -1,3 +1,5 @@ +//LUA funcs map github.com/Eximius/forged_jit + namespace gpg { class RRef {public: void* d; void* t;}; diff --git a/README.md b/README.md index 05dcb13d..6ed73e6a 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,6 @@ This are just the patch files for this game. I decided to separate them from pat - hooks/CameraPerf.cpp - Fix replays desyncing when a player leaves the game - hooks/DesyncFix.cpp - - section/ext_sector.cpp - section/gpg_net.cpp - section/moho_decode.cpp - section/moho_input.cpp @@ -36,7 +35,7 @@ This are just the patch files for this game. I decided to separate them from pat - hooks/Kill_maploader_except.cpp - Make xact3d the error message print once - hooks/xact_3dapply.cpp - - section/ext_sector.cpp + - section/xact_3d_fix.cpp - Prevent blueprint editor being used without cheat mode - hooks/FixOpenBPEditor.cpp - Can't become an observer while your human allies are still alive @@ -57,19 +56,18 @@ This are just the patch files for this game. I decided to separate them from pat - GetSessionClients also output maximum sim speed(maxSP) - hooks/HOutputMaxSP.cpp - section/OutputMaxSP.cpp -- Console command: "cam_DefaultMiniLOD 0" now completely disable mesh renderer for minimap +- Console command: "cam_DefaultMiniLOD 0" now disable mesh renderer for minimap - hooks/MinimapMesh.cpp - section/MinimapMesh.cpp - Allow players to double-click to select Walls - hooks/Walls.cpp -- Similar to GetSystemTimeSecondsOnlyForProfileUse - Allows to deal with the loss of accuracy. It is present in the Sim and UI +- Adds GetTimeForProfile to Sim and UI. Allows to deal with the loss of accuracy - section/GetTimeForProfile.cpp - - section/ext_sector.cpp + - section/LuaFuncRegs.cpp - Adds optimized table.getsize2(~25 times faster) and table.empty2 - Added getn2 as alias getn. Entry point to math functions queue + Adds getn2 as alias getn. Entry point to math functions queue - hooks/GetTableSize.cpp - - section/ext_sector.cpp + - section/LuaFuncRegs.cpp - Maximum sim rate up to 50 - hooks/DelClampMaxSimRate.cpp - Adds an amphibious mode toggle to the Salem @@ -78,18 +76,27 @@ This are just the patch files for this game. I decided to separate them from pat - Make `LOWSELECTPRIO` apply to units under construction - hooks/selectionPriority.cpp - section/selectionPriority.cpp -- Allow the getting of Mass or Energy spots around a location & Entry point to ui functions queue +- Adds GetDepositsAroundPoint to Sim and UI & Entry point to ui functions queue + Allow the getting of Mass or Energy spots around a location - hooks/UserGetDepositsAroundPoint.cpp - section/SimGetDepositsAroundPoint.cpp - - section/ext_sector.cpp + - section/LuaFuncRegs.cpp - Allow devs to write console commands to the log - hooks/ConsoleLog.cpp - section/ConsoleLog.cpp - Unlock an "Ultra" graphics preset - hooks/UnlockUltraPreset.cpp -- Allow armies to be shared by multiple players & Entry point to sim functions queue +- Adds SetCommandSource to Sim. Allow armies to be shared by multiple players + - section/SimSetCommandSource.cpp + - section/LuaFuncRegs.cpp +- Adds SessionIsReplay to Sim + - section/SimIsReplay.cpp + - section/LuaFuncRegs.cpp +- Adds SetFocusArmy to Sim. Sets focus without restrictions + Entry point to sim functions queue - hooks/SimSetFocusArmy.cpp - section/SimSetFocusArmy.cpp + - section/LuaFuncRegs.cpp - Allow upgrades to be queued on units under construction - hooks/BuildUnit.cpp - section/BuildUnit.cpp diff --git a/section/ext_sector.cpp b/section/LuaFuncRegs.cpp similarity index 51% rename from section/ext_sector.cpp rename to section/LuaFuncRegs.cpp index 4a4c29ec..5d7624c7 100644 --- a/section/ext_sector.cpp +++ b/section/LuaFuncRegs.cpp @@ -1,9 +1,4 @@ #include "include/moho.h" -#include "include/desync_fix_global.h" - -// New unit categories. -//const char* sCQUEMOV = "CQUEMOV"; -//const char* sSTAYONWATSUR = "STAYONWATSUR"; int SimSessionIsReplay(void* L); luaFuncDescReg SSIRRegDesc = {0x00E45E90, // Std register func @@ -68,140 +63,4 @@ luaFuncDescReg UGDAPRegDesc = {0x00E45E90, s_GDAPDesc, &UGTFPRegDesc, // Next reg desc SimGetDepositsAroundPoint, - 0x00000000}; - -register int eax asm("eax"); - -bool game_ended = false; - -void EndGame() -{ - game_ended = true; - asm("mov dword ptr [0x011FD23F], 0xB;"); //remove block when last player remains. - asm - ( - "push esi;" - "mov esi,eax;" - "mov eax,dword ptr [esi];" - "push edi;" - "mov edi,dword ptr [0x10BA600];" - "push eax;" - "call 0x90C590;" - "add esp,0x4;" - "test eax,eax;" - "je L0xABEL_0x0074B8DB;" - "push eax;" - "push 0x0;" - "push edi;" - "push 0xE0A220;" - "push esi;" - "call 0x90C1D0;" - "add esp,0x14;" - "L0xABEL_0x0074B8DB:;" - "mov esi,dword ptr [esi];" - "push esi;" - "call 0x924050;" - "mov edx,dword ptr [eax];" - "mov ecx,eax;" - "mov eax,dword ptr [edx+0x5C];" - "add esp,0x4;" - "call eax;" - "pop edi;" - "xor eax,eax;" - "pop esi;" - "ret;" - ); -} - -void xact_3d_apply() -{ - static bool once = true; - asm - ( - "push ebx;" - "push edi;" - "mov ebx,ecx;" - "mov edi,eax;" - "mov eax,dword ptr [ebx];" - "cmp dword ptr [eax+0x34],0x0;" - "je L0xABEL_0x004D9B2A;" - "push esi;" - "push 0x64;" - "lea esi,dword ptr [eax+0xAC];" - "push 0x0;" - "push esi;" - "call 0xA89110;" - "xorps xmm0,xmm0;" - "mov dword ptr [esi+0x3C],0x1;" - "mov dword ptr [esi],0x0;" - "fld dword ptr [edi];" - "fstp dword ptr [esi+0x1C];" - "fld dword ptr [edi+0x4];" - "fstp dword ptr [esi+0x20];" - "fld dword ptr [edi+0x8];" - "movss dword ptr [esi+0x28],xmm0;" - "movss dword ptr [esi+0x2C],xmm0;" - "fstp dword ptr [esi+0x24];" - "movss dword ptr [esi+0x30],xmm0;" - "movss xmm0,dword ptr [0xDFEC20];" - "movss dword ptr [esi+0x5C],xmm0;" - "movss dword ptr [esi+0xC],xmm0;" - "movss dword ptr [esi+0x14],xmm0;" - "mov ecx,dword ptr [ebx];" - "lea edi,dword ptr [ecx+0x7C];" - "lea eax,dword ptr [ecx+0xAC];" - "lea edx,dword ptr [ecx+0x38];" - "add ecx,0x110;" - "push ecx;" - "call 0x4D81E0;" - "add esp,0x10;" - "test eax,eax;" - "jge L0xABEL_0x004D9B04;" - "call 0x4D8A50;" - ); - - asm - ( - "push eax;" - "push 0xE0B410;" - "call 0x937D30;" - "add esp,0x8;" - ); - - asm - ( - "pop esi;" - "pop edi;" - "pop ebx;" - "ret 0x4;" - "L0xABEL_0x004D9B04:;" - "mov ebx,dword ptr [ebx];" - "mov esi,dword ptr [esp+0x10];" - "lea edi,dword ptr [ebx+0x7C];" - "call 0x4D82A0;" - "test eax,eax;" - "jge L0xABEL_0x004D9B29;" - "call 0x4D8A50;" - ); - if(once) - { - asm - ( - "push eax;" - "push 0xE0B430;" - "call 0x937D30;" - "add esp,0x8;" - ); - once = false; - } - - asm - ( - "L0xABEL_0x004D9B29:;" - "pop esi;" - "L0xABEL_0x004D9B2A:;" - "pop edi;" - "pop ebx;" - "ret 0x4;" - ); -} \ No newline at end of file + 0x00000000}; \ No newline at end of file diff --git a/section/RangeRings2.cpp b/section/RangeRings2.cpp index 63475247..5aa61cb8 100644 --- a/section/RangeRings2.cpp +++ b/section/RangeRings2.cpp @@ -16,8 +16,8 @@ void* _thiscall HeightCylinders(char* this_) if (*Heights > MaxH) MaxH = *Heights; Heights++; } - MinCHeight = MinH * 0.0078125 - 5; - MaxCHeight = MaxH * 0.0078125; + MinCHeight = MinH * 0.0078125f - 5.f; + MaxCHeight = MaxH * 0.0078125f; this_ = (char*)*(uint32_t*)(0x10C7C28); reinterpret_cast(0x7EDFE0)(this_ + 0x37C); reinterpret_cast(0x81C0C0)(this_ + 0x410); diff --git a/section/gpg_net.cpp b/section/gpg_net.cpp index 619da919..27619a94 100644 --- a/section/gpg_net.cpp +++ b/section/gpg_net.cpp @@ -7,6 +7,7 @@ uint32_t p_index = 0; uint32_t sender_sock = 1; uint32_t sync_buffer[17]; uint32_t discard = 0; +bool game_ended = false; __attribute__((noinline)) void p_SetEvent() { @@ -847,4 +848,43 @@ void Gpg_Net_Entry() "add esp,0x64;" "ret 0x8;" ); +} + +void EndGame() +{ + game_ended = true; + asm("mov dword ptr [0x011FD23F], 0xB;"); //remove block when last player remains. + asm + ( + "push esi;" + "mov esi,eax;" + "mov eax,dword ptr [esi];" + "push edi;" + "mov edi,dword ptr [0x10BA600];" + "push eax;" + "call 0x90C590;" + "add esp,0x4;" + "test eax,eax;" + "je L0xABEL_0x0074B8DB;" + "push eax;" + "push 0x0;" + "push edi;" + "push 0xE0A220;" + "push esi;" + "call 0x90C1D0;" + "add esp,0x14;" + "L0xABEL_0x0074B8DB:;" + "mov esi,dword ptr [esi];" + "push esi;" + "call 0x924050;" + "mov edx,dword ptr [eax];" + "mov ecx,eax;" + "mov eax,dword ptr [edx+0x5C];" + "add esp,0x4;" + "call eax;" + "pop edi;" + "xor eax,eax;" + "pop esi;" + "ret;" + ); } \ No newline at end of file diff --git a/section/include/LuaAPI.h b/section/include/LuaAPI.h index 1f3ff518..7b29bf4a 100644 --- a/section/include/LuaAPI.h +++ b/section/include/LuaAPI.h @@ -114,6 +114,7 @@ typedef struct { int tt; Value value; } TObject; +VALIDATE_SIZE(TObject, 8) //namespace gpg class RRef {public: void* d; void* t;}; @@ -127,6 +128,7 @@ typedef struct { LuaState* m_state; int m_stackIndex; }; + VALIDATE_SIZE(LuaStackObject, 8) namespace CLuaStackObject { @@ -142,6 +144,7 @@ typedef struct { LuaState* m_state; TObject m_object; }; + VALIDATE_SIZE(LuaObject, 0x14) namespace CLuaObject { @@ -242,6 +245,7 @@ typedef struct { LuaObject* m_prev; // only valid when in used list } m_headObject, m_tailObject; }; + VALIDATE_SIZE(LuaState, 0x34) namespace CLuaState { diff --git a/section/include/global.h b/section/include/global.h index ba374bc3..dee92b30 100644 --- a/section/include/global.h +++ b/section/include/global.h @@ -22,21 +22,27 @@ Get debugging info about a Lua call: [[CallInfo+0C]-[Proto+0C]+[Proto+14]] = currentline */ #define GDecl(addr, type) \ - ((type)*(int*)(addr)) + (*(type*)addr) + +#define WDecl(addr, type) \ + ((type)*(uintptr_t*)addr) #define FDecl(addr, name, type) \ inline const auto name = (type)addr; -#define g_STIDriver GDecl(0x10C4F50, void*) -#define g_SWldSessionInfo GDecl(0x10C4F58, void*) -#define g_CWldSession GDecl(0x10A6470, void*) -#define g_Sim GDecl(0x10A63F0, void*) -#define g_EntityCategoryTypeInfo GDecl(0x10C6E70, void*) -#define g_CAiBrainTypeInfo GDecl(0x10C6FA0, void*) -#define g_CUIManager GDecl(0x10A6450, void*) -#define g_EngineStats GDecl(0x10A67B8, void*) -#define g_WRenViewport GDecl(0x10C7C28, void*) -#define g_ConsoleLuaState GDecl(0x1104410, LuaState) +#define VALIDATE_SIZE(struc, size) \ + static_assert(sizeof(struc) == size, "Invalid structure size of " #struc); + +#define g_STIDriver GDecl(0x10C4F50, uintptr_t) +#define g_SWldSessionInfo GDecl(0x10C4F58, uintptr_t) +#define g_CWldSession GDecl(0x10A6470, uintptr_t) +#define g_Sim GDecl(0x10A63F0, uintptr_t) +#define g_EntityCategoryTypeInfo GDecl(0x10C6E70, uintptr_t) +#define g_CAiBrainTypeInfo GDecl(0x10C6FA0, uintptr_t) +#define g_CUIManager GDecl(0x10A6450, uintptr_t) +#define g_EngineStats GDecl(0x10A67B8, uintptr_t) +#define g_WRenViewport GDecl(0x10C7C28, uintptr_t) +#define g_ConsoleLuaState GDecl(0x10A6478, uintptr_t) #define ui_ProgressBarColor GDecl(0x0F57BB8, int) #define ui_SelectTolerance GDecl(0x0F57A90, float) @@ -47,6 +53,7 @@ Get debugging info about a Lua call: #define range_RenderHighlighted GDecl(0x10A640B, bool) #define range_RenderBuild GDecl(0x10A6414, bool) #define d3d_WindowsCursor GDecl(0x10A636E, bool) +#define debugSelect GDecl(0x10A645E, bool) #define s_FACTORY GDecl(0xE19824, const char*) #define s_EXPERIMENTAL GDecl(0xE204B8, const char*) @@ -63,9 +70,11 @@ FDecl(0x41C990, ConsoleLogF, int (*)(const char *fmt, ...)) FDecl(0xA9B4E6, FileWrite, int (*)(int fileIndex, const char *str, int strlen)) //index 3 is log. FDecl(0xA825B9, shi_new, void* (*)(uint32_t size)) FDecl(0x958C40, shi_delete, void (*)(void* ptr)) +FDecl(0xA94450, strlen, size_t (*)(const char *str)) +FDecl(0x405550, InitString, __thiscall void (*)(void *this_, const char* str)) -#define GetModuleHandle GDecl(0xC0F378, __stdcall void* (*)(const char* lpLibFileName)) -#define GetProcAddress GDecl(0xC0F48C, __stdcall void* (*)(void* hModule, const char* lpProcName)) +#define GetModuleHandle WDecl(0xC0F378, __stdcall void* (*)(const char* lpLibFileName)) +#define GetProcAddress WDecl(0xC0F48C, __stdcall void* (*)(void* hModule, const char* lpProcName)) /* LuaPlus: See FALuaFuncs.txt @@ -84,6 +93,9 @@ LuaObjectFinalize //Lua internals. For debug only. +009133A0 luaG_typeerror +004154B0 LuaStackObjectTypeError +009134B0 errorfb 00457880 luaplus_assert 009274D0 luaH_getstr 0091A240 luaM_realloc @@ -179,6 +191,11 @@ LuaObjectFinalize 008F4260 D3DXEffect::EndPass ? 00941D70 D3DXEffect::SetMatrix ? 00941F60 D3DXEffect::SetTechnique +008F5950 LockVertexBuffer +008F5B40 UnlockVertexBuffer +0081F7B0 GetLeftMouseButtonAction +0081EC00 GetRightMouseButtonAction +008B43F0 GetEntitiesUnderCursor ? 00858D80 DisplayEconomyOverlay 00430590 D3DGetDevice 008D82F0 CreateBitArray2D @@ -199,6 +216,10 @@ LuaObjectFinalize 0040A0A0 CreateStatItemRoot(EngineStats*):eax 00408730 InitStatItem(StatItem*, char* name):eax 008E5050 CalcHash +005D62B0 CreateCAiAttackerImpl +005D6AA0 InitCAiAttackerImpl +005D5D90 AiAttacker::GetWeaponCount +005BE6E0 InitReconBlip 00542870 CreateLaunchInfoNew 00542790 InitLaunchInfoNew 005427F0 DestroyLaunchInfoNew @@ -297,4 +318,8 @@ const int _Moho_SSTICommandIssueData_Destructor = 0x0057ABB0; // MSVCR80.dll #define _memmove_s = 0x00A824E7; + +// New unit categories. +//const char* sCQUEMOV = "CQUEMOV"; +//const char* sSTAYONWATSUR = "STAYONWATSUR"; */ \ No newline at end of file diff --git a/section/include/moho.h b/section/include/moho.h index 63227a06..e722e5bf 100644 --- a/section/include/moho.h +++ b/section/include/moho.h @@ -1,8 +1,6 @@ -//MohoEngine Disassembling notes - -//LUA funcs map github.com/Eximius/forged_jit - #pragma once + +#include "global.h" typedef unsigned int uint; typedef unsigned int bool32; typedef unsigned short uint16; @@ -17,6 +15,7 @@ struct luaFuncDescReg void* FuncPtr; // code address void* ClassPtr; // C++ class type address. NULL if class none }; +VALIDATE_SIZE(luaFuncDescReg, 0x1C) struct vtable; struct typeInfo @@ -54,16 +53,11 @@ struct string uint strLen; uint size; // 0f if SSO, 1f not SSO -#ifdef CXX_BUILD - const char* data() - { - if(size < 0x10) - return (const char*)&m_data; - else - return (const char*)m_data; + const char* data() { + return size == 0xF ? &str : (const char*)str; } -#endif }; +VALIDATE_SIZE(string, 0x1C) struct vector { // 0x10 bytes @@ -71,29 +65,26 @@ struct vector void* objects_begin; void* objects_end; void* objects_capacity_end; - -#ifdef CXX_BUILD - void* operator[](int index) - { - if(index >= size()) - return 0; +/* + void* operator[](int index) { + if(index >= size()) return 0; return objects_begin[index]; } - int size() - { + int size() { return objects_end - objects_begin; - } -#endif + }*/ }; +VALIDATE_SIZE(vector, 0x10) // probably not from visual c++ 9, but made by gpg struct list -{ // 0x0C bytes +{ // 0xC bytes void* objects_begin; // 0 if empty void* objects_end; void* objects_capacity_end; }; +VALIDATE_SIZE(list, 0xC) typedef int SOCKET; // GPGCore @@ -118,7 +109,7 @@ struct RObject void* vtable; }; -struct CScriptObject // : RObject +struct CScriptObject : RObject { // ~0x34 bytes }; @@ -139,11 +130,11 @@ struct Stream void* vtable; }; -struct PipeStream // : Stream +struct PipeStream : Stream { // 0x48 bytes }; -struct FileStream // : Stream +struct FileStream : Stream { // 0x34 bytes }; @@ -193,6 +184,7 @@ struct lua_var //lua.org/source/5.0/lobject.h.html#TObject 9 - Thread */ }; +VALIDATE_SIZE(lua_var, 8) struct lua_State //lua.org/source/5.0/lstate.h.html#lua_State { @@ -242,16 +234,17 @@ struct Camera // : RCamCamera { // 0x858 bytes }; -struct CMauiControl // : CScriptObject +struct CMauiControl : CScriptObject { }; -struct CUIWorldView // : CMauiControl +struct CUIWorldView : CMauiControl { // 0x2A8 bytes // at 0x120 Camera* Camera; // at 0x208 void* CWldSession; + void* unk1; //if shift pressed }; struct linked_list @@ -269,7 +262,6 @@ struct moho_set uint value; // Used as memory for 'Short Set Optimization' void* unknown8; -#ifdef CXX_BUILD void add(int item) { uint* itemPtr = &items_begin[item >> 5]; @@ -287,8 +279,8 @@ struct moho_set { return items_begin[item>>5] & (1 << (item & 0x1f)); } -#endif }; +VALIDATE_SIZE(moho_set, 0x20) struct RRuleGameRules { // 0xD0 bytes @@ -328,15 +320,15 @@ struct LaunchInfoNew int unknown4; }; -struct REffectBlueprint // : RObject +struct REffectBlueprint : RObject { }; -struct RBeamBlueprint // : REffectBlueprint +struct RBeamBlueprint : REffectBlueprint { // 0x140 bytes }; -struct RBlueprint // : RObject +struct RBlueprint : RObject { // ~0x60 bytes // at 0x4 RRuleGameRules* owner; @@ -347,13 +339,13 @@ struct RBlueprint // : RObject uint BlueprintOrdinal; }; -struct RMeshBlueprint // : RBlueprint +struct RMeshBlueprint : RBlueprint { // 0x80 bytes // at 0x70 float IconFadeInZoom; }; -struct REntityBlueprint // : RBlueprint +struct REntityBlueprint : RBlueprint { // ~0x17C bytes // at 0x60 vector Categories; //vector @@ -370,15 +362,15 @@ struct REntityBlueprint // : RBlueprint } Footprint, AltFootprint; }; -struct RPropBlueprint // : REntityBlueprint +struct RPropBlueprint : REntityBlueprint { // 0x1AC bytes }; -struct RProjectileBlueprint // : REntityBlueprint +struct RProjectileBlueprint : REntityBlueprint { // 0x268 bytes }; -struct RUnitBlueprint // : REntityBlueprint +struct RUnitBlueprint : REntityBlueprint { // 0x568 bytes // at 0x17C struct RUnitBlueprintGeneral { @@ -569,28 +561,23 @@ struct UserArmy uint maxMass; int unknown4; // =0 bool isResourceSharing; -#ifndef FORGED_ALLIANCE - char datas[0xba]; -#else - char datas[0xb2]; -#endif - // at 0x130 Moho | at 0x128 FA + + // at 0x128 moho_set mValidCommandSources; - // at 0x148 FA + // at 0x148 uint color; uint iconColor; string mArmyType; // 'human' for players - // at 0x16C FA + // at 0x16C int faction; - // at 0x188 FA + // at 0x188 bool showScore; - // at 0x1B8 FA + // at 0x1B8 bool outOfGame; }; struct SimArmy // : IArmy { // 0x288 bytes -#ifdef FORGED_ALLIANCE void* vtable; // at 0xA4 in vtable //void* GetUnitCap; @@ -627,19 +614,20 @@ struct SimArmy // : IArmy moho_set allies; moho_set enemies; - char datas[0x4A]; - // at 0x130 FA + // at 0x128 + bool IsAlly; + // at 0x130 moho_set mValidCommandSources; - // at 0x150 FA + // at 0x150 uint color; uint iconColor; string mArmyType; // 'human' for players - // at 0x174 FA + // at 0x174 int faction; - // at 0x1C0 FA + // at 0x1C0 bool outOfGame; - // at 0x1C4 FA + // at 0x1C4 Vector2f StartPosition; // at 0x1D0 float noRushRadius; @@ -650,10 +638,10 @@ struct SimArmy // : IArmy void* Sim; void* CAiBrain; - // at 0x1F0 FA + // at 0x1F0 void* CAiReconDBImpl; SimArmyEconomyInfo* EconomyInfo; - // at 0x1F8 FA + // at 0x1F8 string unknown5; // at 0x270 float unitCap; @@ -661,13 +649,9 @@ struct SimArmy // : IArmy int pathCap_Land; int pathCap_Sea; int pathCap_Both; -#else - // at 0x138 Moho - moho_set mValidCommandSources; -#endif }; -struct CArmyImpl // : SimArmy +struct CArmyImpl : SimArmy { }; @@ -684,21 +668,24 @@ struct EntityChain // [[Entities+4]+4] void* Entity; }; -struct Entity // : CScriptObject +struct Sim; +struct Entity : CScriptObject { // 0x270 bytes // at 0x68 uint EntityID; //For units x|xx|xxxxxx Type,Army,Num. Uses for UserSync REntityBlueprint* Blueprint; uint CreationIndex; //? + // at 0x110 + bool VisibleAndControl; }; -struct Projectile // : Entity +struct Projectile : Entity { // 0x380 bytes // at 0x6C RProjectileBlueprint* Blueprint; }; -struct Prop // : Entity +struct Prop : Entity { // 0x288 bytes // at 0x6C RPropBlueprint* Blueprint; @@ -747,8 +734,53 @@ struct CommandQueue bool Unk5; }; -struct Unit // : WeakObject +struct UnitWeapon //: CScriptEvent +{ // 0x188 bytes + void* vtable; + // at 0x10 + void* vtable2; + // at 0x1C + LuaObject UserData; + LuaObject Table; + // at 0x5C + float RateOfFire; + float MinRadius; + float MaxRadius; + float SquaredMinRadius; + float SquaredMaxRadius; + // at 0xA0 + Unit* Owner; +}; + +struct CAiAttackerImpl // : IAiAttacker +{ // 0xA4 bytes + void* vtable; + // at 0x58 + vector Weapons; // +}; + +struct UserUnitWeapon +{ // 0x98 bytes + // at 0x54 + float MinRadius; + float MaxRadius; +}; + +struct UnitIntel +{ // 0x20 bytes, AND 7FFFFFFF + int VisionRadius; + int WaterVisionRadius; + int RadarRadius; + int SonarRadius; + int OmniRadius; + int RadarStealthFieldRadius; + int SonarStealthFieldRadius; + int CloakFieldRadius; +}; + +struct Unit : WeakObject { // 0x6A8 bytes + //WeakObject WeakObject; // at 0x8 //Entity Entity; to 0x278 // at 0x50 @@ -781,15 +813,15 @@ struct Unit // : WeakObject void* Unk14; void* Unk15; void* Unk16; - bool Unk17; + bool VisibleAndControl; // at 0x118 char pad2[3]; void* Unk18; void* Unk19; bool Unk20; char pad3[3]; void* Unk21; - void* Unk22; // at 0x130 - // at 0x154 + UnitIntel UnitIntel; // at 0x130 + Sim* Sim; // at 0x150 SimArmy* Owner; Vector4f Rot3; Vector3f Pos3; @@ -804,23 +836,32 @@ struct Unit // : WeakObject float ShieldRatio; // Readonly // at 0x2AC float WorkProgress; + // at 0x380 + UserUnitWeapon* Weapons; + list unk1; // Weapons? + void* unk2; // Weapons? // at 0x4B0 void* MotionEngine; // +0xC FuelUseTime void* CommandQueue; + int Enum; //0..4 // at 0x534 void* WorkValues; //+0x8 bool Flag; // at 0x53C float WorkRate; + // at 0x544 + void* IAiAttacker; // at 0x55C void* IAiTransport; // at 0x59C Vector3f Pos6; // at 0x668 int TickCount2; // Readonly + // at 0x68E + bool UpdWeaponRadius; }; -struct UserEntity // : WeakObject +struct UserEntity : WeakObject { // 0x148 bytes // at 0x44 int EntityID; @@ -838,19 +879,50 @@ struct UserEntity // : WeakObject Vector4f Pos2; // at 0xD0 //float x1,y1,x2,y2; - // at 0x120 - UserArmy* Owner; + // at 0x100 + UnitIntel UnitIntel; + UserArmy* Owner; // at 0x120 Vector4f Rot3; Vector4f Pos3; }; -struct UserUnit // : UserEntity +struct UserUnit : UserEntity { // 0x3E8 bytes // at 0x44 int UnitID; RUnitBlueprint* Blueprint; // at 0x1DC string customUnitName; + // at 0x290 + UserUnitWeapon* Weapons; +}; + +struct ReconBlip : Entity +{ // 0x4D0 bytes + Entity Entity; + // at 0x270 + void* OriginUnit; //-0x4 + // at 0x28C + void* StatItem; + void* StatItem2; + // at 0x320 + void* CAniPose; + // at 0x328 + void* CAniPose2; + // at 0x330, size 0x30? + list unk1; + void* unk2; + // at 0x360, size 0x30? + list unk3; + void* unk4; + // at 0x390, size 0x30? + list unk5; // Weapons? + void* unk6; // Weapons? + // at 0x450, size 0x30? + list unk7; + void* unk8; + // at 0x4C4 + void* ArmyesData[]; //size 0x34 }; struct Sim // : ICommandSink @@ -880,7 +952,7 @@ struct Sim // : ICommandSink vector armies;// // at 0x920 list SSTICommandSources; - // at 0x93C Moho | at 0x92C FA + // at 0x92C int ourCmdSource; // possibly just current in simulation. // at 0x97C void** unknown4; // 0x30 bytes @@ -936,13 +1008,24 @@ struct CWldSession int focusArmyIndex; // focused army, -1 = observer bool32 isGameOver; - // at 0x4B4 - float mouseWorldPosX; - float mouseWorldPosY; - float mouseWorldPosZ; - // at 0x4CC - float mouseScreenPosX; - float mouseScreenPosY; + // at 0x4A0 + struct { + int Unk1; + void** SelList; //+0x10 + int SelCount; + int SelCount2; + } SelectedUnits; + struct // at 0x4B0 + { // size 0x20 + // at 0x4B4 + float mouseWorldPosX; + float mouseWorldPosY; + float mouseWorldPosZ; + // at 0x4C8 + int IsDragger; + float mouseScreenPosX; + float mouseScreenPosY; + } Unk1; // at 0x4D4 bool cheatsEnabled; // copied from LaunchInfoNew + 0x88 // at 0x4E8 @@ -1051,7 +1134,6 @@ struct CLobby } peer_list; // Probably singly-linked list }; -/// Tres Importante struct sub_10392B10_ret { // 0x20 bytes @@ -1064,6 +1146,7 @@ struct sub_10392B10_ret char one1; char zero4; // 1 in CLobbyPeer.unknown2 }; + struct CLobbyPeer { // 0x50 bytes @@ -1163,11 +1246,11 @@ struct CClientBase // : IClient int maxSimRate; // from CalcMaxSimRate }; -struct CLocalClient // : CClientBase +struct CLocalClient : CClientBase { // 0xD8 bytes }; // equal CClientBase -struct CReplayClient // : CClientBase +struct CReplayClient : CClientBase { // 0x160 bytes // before 0xD8 it CClientBase // at 0xD8 diff --git a/section/xact_3d_fix.cpp b/section/xact_3d_fix.cpp new file mode 100644 index 00000000..a017f901 --- /dev/null +++ b/section/xact_3d_fix.cpp @@ -0,0 +1,92 @@ +void xact_3d_apply() +{ + static bool once = true; + asm + ( + "push ebx;" + "push edi;" + "mov ebx,ecx;" + "mov edi,eax;" + "mov eax,dword ptr [ebx];" + "cmp dword ptr [eax+0x34],0x0;" + "je L0xABEL_0x004D9B2A;" + "push esi;" + "push 0x64;" + "lea esi,dword ptr [eax+0xAC];" + "push 0x0;" + "push esi;" + "call 0xA89110;" + "xorps xmm0,xmm0;" + "mov dword ptr [esi+0x3C],0x1;" + "mov dword ptr [esi],0x0;" + "fld dword ptr [edi];" + "fstp dword ptr [esi+0x1C];" + "fld dword ptr [edi+0x4];" + "fstp dword ptr [esi+0x20];" + "fld dword ptr [edi+0x8];" + "movss dword ptr [esi+0x28],xmm0;" + "movss dword ptr [esi+0x2C],xmm0;" + "fstp dword ptr [esi+0x24];" + "movss dword ptr [esi+0x30],xmm0;" + "movss xmm0,dword ptr [0xDFEC20];" + "movss dword ptr [esi+0x5C],xmm0;" + "movss dword ptr [esi+0xC],xmm0;" + "movss dword ptr [esi+0x14],xmm0;" + "mov ecx,dword ptr [ebx];" + "lea edi,dword ptr [ecx+0x7C];" + "lea eax,dword ptr [ecx+0xAC];" + "lea edx,dword ptr [ecx+0x38];" + "add ecx,0x110;" + "push ecx;" + "call 0x4D81E0;" + "add esp,0x10;" + "test eax,eax;" + "jge L0xABEL_0x004D9B04;" + "call 0x4D8A50;" + ); + + asm + ( + "push eax;" + "push 0xE0B410;" + "call 0x937D30;" + "add esp,0x8;" + ); + + asm + ( + "pop esi;" + "pop edi;" + "pop ebx;" + "ret 0x4;" + "L0xABEL_0x004D9B04:;" + "mov ebx,dword ptr [ebx];" + "mov esi,dword ptr [esp+0x10];" + "lea edi,dword ptr [ebx+0x7C];" + "call 0x4D82A0;" + "test eax,eax;" + "jge L0xABEL_0x004D9B29;" + "call 0x4D8A50;" + ); + if(once) + { + asm + ( + "push eax;" + "push 0xE0B430;" + "call 0x937D30;" + "add esp,0x8;" + ); + once = false; + } + + asm + ( + "L0xABEL_0x004D9B29:;" + "pop esi;" + "L0xABEL_0x004D9B2A:;" + "pop edi;" + "pop ebx;" + "ret 0x4;" + ); +} \ No newline at end of file