Skip to content

Commit

Permalink
TimeModels ini fix
Browse files Browse the repository at this point in the history
- updated premake
- updated injector
- updated ExtraObjectsDir fix for use with skin and bones
  • Loading branch information
ThirteenAG committed Jul 17, 2019
1 parent 0be4129 commit 49b2426
Show file tree
Hide file tree
Showing 9 changed files with 290 additions and 133 deletions.
6 changes: 3 additions & 3 deletions doc/III.VC.SA.LimitAdjuster.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ColModel = 15000
AlphaEntityList = 2000
VisibleEntityPtrs = unlimited
AtomicModels = 10000
TimeModels = unlimited
TimeModels = 10000
ClumpModels = unlimited
VehicleModels = unlimited
PedModels = unlimited
Expand All @@ -69,7 +69,7 @@ MemoryAvailable = 30%
[GTA3LIMITS]
StreamingInfo = 6350
TxdStore = 850
ExtraObjectsDir = 128
ExtraObjectsDir = 256
PtrNode = 90000
EntryInfoNode = 30000
Peds = 140
Expand All @@ -81,7 +81,7 @@ Dummys = 30000
AudioScriptObj = 256
AlphaEntityList = 2000
VisibleEntityPtrs = unlimited
TimeModels = unlimited
TimeModels = 10000
OutsideWorldWaterBlocks = 40
Coronas = 5000
FrameLimit = 30
Expand Down
1 change: 1 addition & 0 deletions premake5.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
premake5 vs2019
Binary file modified premake5.exe
Binary file not shown.
103 changes: 89 additions & 14 deletions src/limits/Misc/ExtraObjectsDir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,99 @@

using namespace injector;


struct CDirectory
{
struct DirectoryInfo {
uint32_t offset;
uint32_t size;
char name[24];
};
DirectoryInfo *entries;
int32_t maxFiles;
int32_t numFiles;

void AddItem(DirectoryInfo *dirinfo, int imgid);
int FindItem(char *name);
};
int
CDirectory::FindItem(char *name)
{
int i;
for (i = 0; i < numFiles; i++)
if (strcmpi(entries[i].name, name) == 0)
return i;
return -1;
}
void
CDirectory::AddItem(DirectoryInfo *dirinfo, int imgid)
{
int i;
DirectoryInfo dirinfo2 = *dirinfo;
dirinfo2.offset |= imgid << 24;
i = FindItem(dirinfo->name);
if (i < 0)
entries[numFiles++] = dirinfo2;
}

void __declspec(naked) dirEntryHookVC()
{
_asm
{
mov edx, [esp + 40h + 0x8] // fileID
lea eax, [esp + 40h - 0x34] // dir entry
mov ecx, ds:0xA10730 // CStreaming::ms_pExtraObjectsDir
push edx
push eax
call CDirectory::AddItem

push dword ptr 0x40FCA2
retn
}
}

void __declspec(naked) dirEntryHookIII()
{
_asm
{
mov edx, [esp + 48h + 0x8] // fileID
lea eax, [esp + 48h - 0x3C] // dir entry
mov ecx, ds:0x95CB90 // CStreaming::ms_pExtraObjectsDir
push edx
push eax
call CDirectory::AddItem

push dword ptr 0x406F30
retn
}
}

class ExtraObjectsDirIII : public SimpleAdjuster
{
public:
const char* GetLimitName() { return GetGVM().IsIII()? "ExtraObjectsDir" : nullptr; }
void ChangeLimit(int, const std::string& value)
{
int n = std::stoi(value);
WriteMemory(0x4069D2 + 1, n, true);
}
public:
const char* GetLimitName() { return GetGVM().IsIII() ? "ExtraObjectsDir" : nullptr; }
void ChangeLimit(int, const std::string& value)
{
int n = std::stoi(value);
WriteMemory(0x4069D2 + 1, n, true);

//for skin and bones mod
injector::MakeJMP(0x406F20, dirEntryHookIII, true);

// ignore txd.img
injector::MakeJMP(0x48C12E, 0x48C14C, true);
}
} ExtraObjectsDirIII;

class ExtraObjectsDirVC : public SimpleAdjuster
{
public:
const char* GetLimitName() { return GetGVM().IsVC()? "ExtraObjectsDir" : nullptr; }
void ChangeLimit(int, const std::string& value)
{
int n = std::stoi(value);
WriteMemory(0x4106E9 + 1, n, true);
}
public:
const char* GetLimitName() { return GetGVM().IsVC() ? "ExtraObjectsDir" : nullptr; }
void ChangeLimit(int, const std::string& value)
{
int n = std::stoi(value);
WriteMemory(0x4106E9 + 1, n, true);

injector::MakeJMP(0x40FC92, dirEntryHookVC, true);
}
} ExtraObjectsDirVC;
21 changes: 21 additions & 0 deletions src/shared/injector/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Copyright (C) 2012-2014 LINK/2012 <[email protected]>

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source
distribution.

20 changes: 10 additions & 10 deletions src/shared/injector/assembly.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ namespace injector
// The ordering is very important, don't change
// The first field is the last to be pushed and first to be poped

// PUSHFD / POPFD
uint32_t ef;

// PUSHAD/POPAD -- must be the lastest fields (because of esp)
union
{
uint32_t arr[8];
struct { uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; };
};

// PUSHFD / POPFD
uint32_t ef;

enum reg_name {
reg_edi, reg_esi, reg_ebp, reg_esp, reg_ebx, reg_edx, reg_ecx, reg_eax
Expand Down Expand Up @@ -100,19 +100,19 @@ namespace injector
_asm
{
// Construct the reg_pack structure on the stack
pushad // Pushes general purposes registers to reg_pack
add [esp+12], 4 // Add 4 to reg_pack::esp 'cuz of our return pointer, let it be as before this func is called
pushfd // Pushes EFLAGS to reg_pack
pushad // Pushes general purposes registers to reg_pack
add dword ptr[esp+12], 8 // Add 4 to reg_pack::esp 'cuz of our return pointer, let it be as before this func is called

// Call wrapper sending reg_pack as parameter
push esp
call W::call
add esp, 4

// Destructs the reg_pack from the stack
sub [esp+12+4], 4 // Fix reg_pack::esp before popping it (doesn't make a difference though) (+4 because eflags)
popfd // Warning: Do not use any instruction that changes EFLAGS after this (-> sub affects EF!! <-)
sub dword ptr[esp+12], 8 // Fix reg_pack::esp before popping it (doesn't make a difference though) (+4 because eflags)
popad
popfd // Warning: Do not use any instruction that changes EFLAGS after this (-> sub affects EF!! <-)

// Back to normal flow
ret
Expand Down Expand Up @@ -152,14 +152,14 @@ namespace injector
template<uintptr_t at, uintptr_t end, class FuncT>
void MakeInline(FuncT func)
{
static FuncT static_func = func; // Stores the func object
static_func = func; //
static std::unique_ptr<FuncT> static_func;
static_func.reset(new FuncT(std::move(func)));

// Encapsulates the call to static_func
struct Caps
{
void operator()(reg_pack& regs)
{ static_func(regs); }
{ (*static_func)(regs); }
};

// Does the actual MakeInline
Expand Down
1 change: 1 addition & 0 deletions src/shared/injector/calling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#pragma once
#include "injector.hpp"
#include <utility>
#include <tuple>

#if __cplusplus >= 201103L || _MSC_VER >= 1800 // MSVC 2013
#else
Expand Down
Loading

0 comments on commit 49b2426

Please sign in to comment.