Skip to content

Commit f7b4468

Browse files
committed
Added help info for a model crash.
Added possible fix for floating point precision not being restored. Updated disk space check to use correct resource cache location. Added check for Windows Safe Mode as it causes problems for MTA. Removed annoying debug check when poking GTA memory.
1 parent 024146a commit f7b4468

File tree

6 files changed

+72
-2
lines changed

6 files changed

+72
-2
lines changed

MTA10/loader/MainFunctions.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,14 @@ void CheckLibVersions( void )
823823
}
824824

825825
#endif
826+
827+
if ( GetSystemMetrics( SM_CLEANBOOT ) != 0 )
828+
{
829+
DisplayErrorMessageBox ( SStringX(_( "MTA:SA is not compatible with Windows 'Safe Mode'.\n\n"
830+
"Please restart your PC.\n" )
831+
), _E("CL42"), "safe-mode" );
832+
return ExitProcess( EXIT_ERROR );
833+
}
826834
}
827835

828836

MTA10/loader/Utils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,8 @@ void CheckAndShowModelProblems ( void )
18201820
{
18211821
SString strMsg;
18221822
strMsg += _("GTA:SA had trouble loading a model.");
1823-
strMsg += SString( " (%d)", iModelId );
1823+
strMsg += SString( " (%d)\n\n", iModelId );
1824+
strMsg += _("If you recently modified gta3.img, then try reinstalling GTA:SA.");
18241825
DisplayErrorMessageBox ( strMsg, _E("CL34"), SString( "gta-model-fail&id=%d&reason=%s", iModelId, *strReason ) );
18251826
}
18261827
}

MTA10/mods/shared_logic/lua/CLuaMain.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2228,7 +2228,16 @@ int CLuaMain::PCall ( lua_State *L, int nargs, int nresults, int errfunc )
22282228

22292229
g_pClientGame->ChangeFloatPrecision( true );
22302230
g_pClientGame->GetScriptDebugging()->PushLuaMain ( this );
2231-
int iret = lua_pcall ( L, nargs, nresults, errfunc );
2231+
int iret = 0;
2232+
try
2233+
{
2234+
iret = lua_pcall ( L, nargs, nresults, errfunc );
2235+
}
2236+
catch(...)
2237+
{
2238+
// Can this happen?
2239+
AddReportLog( 7554, "CLuaMain::PCall - Unexpected execption thrown" );
2240+
}
22322241
g_pClientGame->GetScriptDebugging()->PopLuaMain ( this );
22332242
g_pClientGame->ChangeFloatPrecision( false );
22342243

MTA10/multiplayer_sa/CMultiplayerSA_CrashFixHacks.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,50 @@ void _declspec(naked) HOOK_CAnimManager_CreateAnimAssocGroups()
15181518
}
15191519

15201520

1521+
//////////////////////////////////////////////////////////////////////////////////////////
1522+
//
1523+
// CAnimManager_CreateAnimAssocGroups
1524+
//
1525+
// A model (usually 7) has to be loaded to avoid a crash
1526+
//
1527+
//////////////////////////////////////////////////////////////////////////////////////////
1528+
void OnMY_CAnimManager_CreateAnimAssocGroups( uint uiModelId )
1529+
{
1530+
CModelInfo* pModelInfo = pGameInterface->GetModelInfo( uiModelId );
1531+
if ( pModelInfo->GetInterface()->pRwObject == NULL )
1532+
{
1533+
// Crash will occur at offset 00349b7b
1534+
LogEvent( 816, "Model not loaded", "CAnimManager_CreateAnimAssocGroups", SString( "No RwObject for model:%d", uiModelId ), 5416 );
1535+
CArgMap argMap;
1536+
argMap.Set( "id", uiModelId );
1537+
argMap.Set( "reason", "createanim" );
1538+
SetApplicationSetting( "diagnostics", "gta-model-fail", argMap.ToString() );
1539+
}
1540+
}
1541+
1542+
1543+
// Hook info
1544+
#define HOOKPOS_CAnimManager_CreateAnimAssocGroups 0x4D3D52
1545+
#define HOOKSIZE_CAnimManager_CreateAnimAssocGroups 5
1546+
#define HOOKCHECK_CAnimManager_CreateAnimAssocGroups 0x8B
1547+
DWORD RETURN_CAnimManager_CreateAnimAssocGroups = 0x4D3D59;
1548+
void _declspec(naked) HOOK_CAnimManager_CreateAnimAssocGroups()
1549+
{
1550+
_asm
1551+
{
1552+
pushad
1553+
push eax
1554+
call OnMY_CAnimManager_CreateAnimAssocGroups
1555+
add esp, 4*1
1556+
popad
1557+
1558+
// Replaced code
1559+
mov eax, 0x0A9B0C8[eax*4]
1560+
jmp RETURN_CAnimManager_CreateAnimAssocGroups
1561+
}
1562+
}
1563+
1564+
15211565
//////////////////////////////////////////////////////////////////////////////////////////
15221566
//
15231567
// Setup hooks for CrashFixHacks

Shared/sdk/SharedUtil.File.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,14 @@ uint SharedUtil::GetPathFreeSpaceMB( const SString& strPath )
448448

449449
SString SharedUtil::GetDriveNameWithNotEnoughSpace( uint uiResourcesPathMinMB, uint uiDataPathMinMB )
450450
{
451+
SString strFileCachePath = GetCommonRegistryValue( "", "File Cache Path" );
452+
if ( !strFileCachePath.empty() && DirectoryExists( PathJoin( strFileCachePath, "resources" ) ) )
453+
if ( GetPathFreeSpaceMB( strFileCachePath ) < uiResourcesPathMinMB )
454+
return GetPathDriveName( strFileCachePath );
455+
451456
if ( GetPathFreeSpaceMB( GetMTASABaseDir() ) < uiResourcesPathMinMB )
452457
return GetPathDriveName( GetMTASABaseDir() );
458+
453459
if ( GetPathFreeSpaceMB( GetSystemCommonAppDataPath() ) < uiDataPathMinMB )
454460
return GetPathDriveName( GetSystemCommonAppDataPath() );
455461
return "";

Shared/sdk/SharedUtil.MemAccess.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,13 @@ namespace SharedUtil
131131
OutputDebugLine( SString( "[Mem] OpenMemWrite at %08x for %d bytes (oldProt:%04x)", pAddr, uiAmount, hMem.oldProt ) );
132132

133133
#ifdef MTA_DEBUG
134+
#if 0 // Annoying
134135
// Checks
135136
if ( IsProtectedSlowMem( (const void*)hMem.dwFirstPage ) )
136137
assert( hMem.oldProt == PAGE_EXECUTE_READ || hMem.oldProt == PAGE_READONLY );
137138
else
138139
assert( hMem.oldProt == PAGE_EXECUTE_READWRITE || hMem.oldProt == PAGE_EXECUTE_WRITECOPY );
140+
#endif
139141
#endif
140142

141143
// Extra if more than one page

0 commit comments

Comments
 (0)