PR #249 but only for Release build

This commit is contained in:
dexy
2024-07-12 14:55:53 +10:00
Unverified
parent d83135d284
commit f01644a8cc
2 changed files with 238 additions and 95 deletions
+54 -45
View File
@@ -2518,55 +2518,64 @@ namespace CodeWalker.GameFiles
//UpdateStatus("Loading " + req.RpfFileEntry.Name + "..."); //UpdateStatus("Loading " + req.RpfFileEntry.Name + "...");
//} //}
switch (req.Type) #if !DEBUG
try
{ {
case GameFileType.Ydr: #endif
req.Loaded = LoadFile(req as YdrFile);
break; switch (req.Type)
case GameFileType.Ydd: {
req.Loaded = LoadFile(req as YddFile); case GameFileType.Ydr:
break; req.Loaded = LoadFile(req as YdrFile);
case GameFileType.Ytd: break;
req.Loaded = LoadFile(req as YtdFile); case GameFileType.Ydd:
//if (req.Loaded) AddTextureLookups(req as YtdFile); req.Loaded = LoadFile(req as YddFile);
break; break;
case GameFileType.Ymap: case GameFileType.Ytd:
YmapFile y = req as YmapFile; req.Loaded = LoadFile(req as YtdFile);
req.Loaded = LoadFile(y); //if (req.Loaded) AddTextureLookups(req as YtdFile);
if (req.Loaded) y.InitYmapEntityArchetypes(this); break;
break; case GameFileType.Ymap:
case GameFileType.Yft: YmapFile y = req as YmapFile;
req.Loaded = LoadFile(req as YftFile); req.Loaded = LoadFile(y);
break; if (req.Loaded) y.InitYmapEntityArchetypes(this);
case GameFileType.Ybn: break;
req.Loaded = LoadFile(req as YbnFile); case GameFileType.Yft:
break; req.Loaded = LoadFile(req as YftFile);
case GameFileType.Ycd: break;
req.Loaded = LoadFile(req as YcdFile); case GameFileType.Ybn:
break; req.Loaded = LoadFile(req as YbnFile);
case GameFileType.Yed: break;
req.Loaded = LoadFile(req as YedFile); case GameFileType.Ycd:
break; req.Loaded = LoadFile(req as YcdFile);
case GameFileType.Ynv: break;
req.Loaded = LoadFile(req as YnvFile); case GameFileType.Yed:
break; req.Loaded = LoadFile(req as YedFile);
case GameFileType.Yld: break;
req.Loaded = LoadFile(req as YldFile); case GameFileType.Ynv:
break; req.Loaded = LoadFile(req as YnvFile);
default: break;
break; case GameFileType.Yld:
req.Loaded = LoadFile(req as YldFile);
break;
default:
break;
}
UpdateStatus((req.Loaded ? "Loaded " : "Error loading ") + req.ToString());
if (!req.Loaded)
{
ErrorLog("Error loading " + req.ToString());
}
#if !DEBUG
} }
catch (Exception ex)
string str = (req.Loaded ? "Loaded " : "Error loading ") + req.ToString();
//string str = string.Format("{0}: {1}: {2}", requestQueue.Count, (req.Loaded ? "Loaded" : "Error loading"), req);
UpdateStatus(str);
//ErrorLog(str);
if (!req.Loaded)
{ {
ErrorLog("Error loading " + req.ToString()); ErrorLog($"Failed to load file {req.Name}: {ex.Message}");
//TODO: try to stop subsequent attempts to load this!
} }
#endif
//loadedsomething = true; //loadedsomething = true;
} }
+184 -50
View File
@@ -4157,45 +4157,143 @@ namespace CodeWalker
private void LoadWorld() private void LoadWorld()
{ {
UpdateStatus("Loading timecycles..."); #if !DEBUG
timecycle.Init(gameFileCache, UpdateStatus); try
timecycle.SetTime(Renderer.timeofday); {
#endif
UpdateStatus("Loading materials..."); UpdateStatus("Loading timecycles...");
BoundsMaterialTypes.Init(gameFileCache); timecycle.Init(gameFileCache, UpdateStatus);
timecycle.SetTime(Renderer.timeofday);
UpdateStatus("Loading weather..."); #if !DEBUG
weather.Init(gameFileCache, UpdateStatus, timecycle); }
UpdateWeatherTypesComboBox(weather); catch (Exception ex)
{
UpdateStatus("Loading clouds..."); MessageBox.Show($"Error loading timecycles: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
clouds.Init(gameFileCache, UpdateStatus, weather); }
UpdateCloudTypesComboBox(clouds); try
{
UpdateStatus("Loading water..."); #endif
water.Init(gameFileCache, UpdateStatus); UpdateStatus("Loading materials...");
BoundsMaterialTypes.Init(gameFileCache);
UpdateStatus("Loading trains..."); #if !DEBUG
trains.Init(gameFileCache, UpdateStatus); }
catch (Exception ex)
UpdateStatus("Loading scenarios..."); {
scenarios.Init(gameFileCache, UpdateStatus, timecycle); MessageBox.Show($"Error loading materials: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
UpdateStatus("Loading popzones..."); try
popzones.Init(gameFileCache, UpdateStatus); {
#endif
UpdateStatus("Loading heightmaps..."); UpdateStatus("Loading weather...");
heightmaps.Init(gameFileCache, UpdateStatus); weather.Init(gameFileCache, UpdateStatus, timecycle);
UpdateWeatherTypesComboBox(weather);
UpdateStatus("Loading watermaps..."); #if !DEBUG
watermaps.Init(gameFileCache, UpdateStatus); }
catch (Exception ex)
UpdateStatus("Loading audio zones..."); {
audiozones.Init(gameFileCache, UpdateStatus); MessageBox.Show($"Error loading weather files, ensure you do not have FiveMods installed or any Redux mod. Game may require reinstall.: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
UpdateStatus("Loading world..."); try
space.Init(gameFileCache, UpdateStatus); {
#endif
UpdateStatus("Loading clouds...");
clouds.Init(gameFileCache, UpdateStatus, weather);
UpdateCloudTypesComboBox(clouds);
#if !DEBUG
}
catch (Exception ex)
{
MessageBox.Show($"Error loading clouds: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
#endif
UpdateStatus("Loading water...");
water.Init(gameFileCache, UpdateStatus);
#if !DEBUG
}
catch (Exception ex)
{
MessageBox.Show($"Error loading water: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
#endif
UpdateStatus("Loading trains...");
trains.Init(gameFileCache, UpdateStatus);
#if !DEBUG
}
catch (Exception ex)
{
MessageBox.Show($"Error loading trains: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
#endif
UpdateStatus("Loading scenarios...");
scenarios.Init(gameFileCache, UpdateStatus, timecycle);
#if !DEBUG
}
catch (Exception ex)
{
MessageBox.Show($"Error loading scenarios: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
#endif
UpdateStatus("Loading popzones...");
popzones.Init(gameFileCache, UpdateStatus);
#if !DEBUG
}
catch (Exception ex)
{
MessageBox.Show($"Error loading popzones: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
#endif
UpdateStatus("Loading heightmaps...");
heightmaps.Init(gameFileCache, UpdateStatus);
#if !DEBUG
}
catch (Exception ex)
{
MessageBox.Show($"Error loading heightmaps: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
#endif
UpdateStatus("Loading watermaps...");
watermaps.Init(gameFileCache, UpdateStatus);
#if !DEBUG
}
catch (Exception ex)
{
MessageBox.Show($"Error loading watermaps: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
#endif
UpdateStatus("Loading audio zones...");
audiozones.Init(gameFileCache, UpdateStatus);
#if !DEBUG
}
catch (Exception ex)
{
MessageBox.Show($"Error loading audio zones: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
#endif
UpdateStatus("Loading world...");
space.Init(gameFileCache, UpdateStatus);
#if !DEBUG
}
catch (Exception ex)
{
MessageBox.Show($"Error loading world: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
#endif
UpdateStatus("World loaded"); UpdateStatus("World loaded");
} }
@@ -4263,7 +4361,7 @@ namespace CodeWalker
} }
catch catch
{ {
MessageBox.Show("Keys not found! This shouldn't happen."); MessageBox.Show("Keys not found! This shouldn't happen, GTA5.exe outdated? CodeWalker outdated?");
Close(); Close();
return; return;
} }
@@ -4275,8 +4373,20 @@ namespace CodeWalker
EnableCacheDependentUI(); EnableCacheDependentUI();
#if !DEBUG
LoadWorld(); try
{
#endif
LoadWorld();
#if !DEBUG
}
catch (Exception ex)
{
MessageBox.Show($"Failed to load world: {ex.Message}");
Close();
return;
}
#endif
@@ -4288,23 +4398,47 @@ namespace CodeWalker
Task.Run(() => { Task.Run(() => {
while (formopen && !IsDisposed) //renderer content loop while (formopen && !IsDisposed) //renderer content loop
{ {
bool rcItemsPending = Renderer.ContentThreadProc(); #if !DEBUG
try
if (!rcItemsPending)
{ {
Thread.Sleep(1); //sleep if there's nothing to do #endif
bool rcItemsPending = Renderer.ContentThreadProc();
if (!rcItemsPending)
{
Thread.Sleep(1); //sleep if there's nothing to do
}
#if !DEBUG
} }
catch (Exception ex)
{
MessageBox.Show($"Renderer Failed: {ex.Message}");
Close();
return;
}
#endif
} }
}); });
while (formopen && !IsDisposed) //main asset loop while (formopen && !IsDisposed) //main asset loop
{ {
bool fcItemsPending = gameFileCache.ContentThreadProc(); #if !DEBUG
try
if (!fcItemsPending)
{ {
Thread.Sleep(1); //sleep if there's nothing to do #endif
bool fcItemsPending = gameFileCache.ContentThreadProc();
if (!fcItemsPending)
{
Thread.Sleep(1); //sleep if there's nothing to do
}
#if !DEBUG
} }
catch (Exception ex)
{
MessageBox.Show($"GameFileCache Failed: {ex.Message}");
Close();
return;
}
#endif
} }
gameFileCache.Clear(); gameFileCache.Clear();