From 06d0434f325fd5b2a51eb6234e394cd6c79d4c04 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Wed, 25 Feb 2015 15:45:16 +0100 Subject: [PATCH] Improved modding support and loading of custom models/anims --- RELEASE-NOTES.txt | 4 ++++ neo/cm/CollisionModel_load.cpp | 6 +++++- neo/d3xp/anim/Anim.cpp | 5 ++++- neo/framework/FileSystem.cpp | 17 +++++++++++++---- neo/renderer/BinaryImage.cpp | 7 +++++-- neo/renderer/Model.cpp | 4 +++- neo/renderer/ModelManager.cpp | 6 +++++- neo/swf/SWF_Load.cpp | 6 ++++-- 8 files changed, 43 insertions(+), 12 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index b41ff0c3fa..ed45f2dda2 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -32,6 +32,10 @@ _______________________________ - Added back dmap and aas compilers (mapping tools) +- Cinematic sequences can be skipped + +- Localization support for other languages than English + _______________________________________ diff --git a/neo/cm/CollisionModel_load.cpp b/neo/cm/CollisionModel_load.cpp index cc15bb8db9..5425eba4e7 100644 --- a/neo/cm/CollisionModel_load.cpp +++ b/neo/cm/CollisionModel_load.cpp @@ -3436,10 +3436,14 @@ cm_model_t* idCollisionModelManagerLocal::LoadBinaryModelFromFile( idFile* file, } ID_TIME_T storedTimeStamp = FILE_NOT_FOUND_TIMESTAMP; file->ReadBig( storedTimeStamp ); - if( !fileSystem->InProductionMode() && storedTimeStamp != sourceTimeStamp ) + + // RB: source might be from .resources, so we ignore the time stamp and assume a release build + if( !fileSystem->InProductionMode() && ( sourceTimeStamp != FILE_NOT_FOUND_TIMESTAMP ) && ( sourceTimeStamp != 0 ) && ( sourceTimeStamp != storedTimeStamp ) ) { return NULL; } + // RB end + cm_model_t* model = AllocModel(); file->ReadString( model->name ); file->ReadBig( model->bounds ); diff --git a/neo/d3xp/anim/Anim.cpp b/neo/d3xp/anim/Anim.cpp index 2b6756672d..43283dab81 100644 --- a/neo/d3xp/anim/Anim.cpp +++ b/neo/d3xp/anim/Anim.cpp @@ -427,10 +427,13 @@ bool idMD5Anim::LoadBinary( idFile* file, ID_TIME_T sourceTimeStamp ) ID_TIME_T loadedTimeStamp; file->ReadBig( loadedTimeStamp ); - if( !fileSystem->InProductionMode() && sourceTimeStamp != loadedTimeStamp ) + + // RB: source might be from .resources, so we ignore the time stamp and assume a release build + if( !fileSystem->InProductionMode() && ( sourceTimeStamp != FILE_NOT_FOUND_TIMESTAMP ) && ( sourceTimeStamp != 0 ) && ( sourceTimeStamp != loadedTimeStamp ) ) { return false; } + // RB end file->ReadBig( numFrames ); file->ReadBig( frameRate ); diff --git a/neo/framework/FileSystem.cpp b/neo/framework/FileSystem.cpp index 13a3cfd8cf..e6608ce695 100644 --- a/neo/framework/FileSystem.cpp +++ b/neo/framework/FileSystem.cpp @@ -169,10 +169,10 @@ class idFileSystemLocal : public idFileSystem virtual void EnableBackgroundCache( bool enable ); virtual void BeginLevelLoad( const char* name, char* _blockBuffer, int _blockBufferSize ); virtual void EndLevelLoad(); - virtual bool InProductionMode() - { - return ( resourceFiles.Num() > 0 ) | ( com_productionMode.GetInteger() != 0 ); - } + + // RB begin + virtual bool InProductionMode(); + // RB end virtual bool UsingResourceFiles() { return resourceFiles.Num() > 0; @@ -783,6 +783,15 @@ void idFileSystemLocal::EndLevelLoad() } +// RB begin +bool idFileSystemLocal::InProductionMode() +{ + //return fs_resourceLoadPriority.GetBool() && ( resourceFiles.Num() > 0 ) || ( com_productionMode.GetInteger() != 0 ); + + return ( com_productionMode.GetInteger() != 0 ); +} +// RB end + bool FileExistsInAllManifests( const char* filename, idList< idFileManifest >& manifests ) { for( int i = 0; i < manifests.Num(); i++ ) diff --git a/neo/renderer/BinaryImage.cpp b/neo/renderer/BinaryImage.cpp index 1882429ca6..ed988e0384 100644 --- a/neo/renderer/BinaryImage.cpp +++ b/neo/renderer/BinaryImage.cpp @@ -446,7 +446,7 @@ idBinaryImage::LoadFromGeneratedFile Load the preprocessed image from the generated folder. ========================== */ -bool idBinaryImage::LoadFromGeneratedFile( idFile* bFile, ID_TIME_T sourceFileTime ) +bool idBinaryImage::LoadFromGeneratedFile( idFile* bFile, ID_TIME_T sourceTimeStamp ) { if( bFile->Read( &fileData, sizeof( fileData ) ) <= 0 ) { @@ -466,10 +466,13 @@ bool idBinaryImage::LoadFromGeneratedFile( idFile* bFile, ID_TIME_T sourceFileTi { return false; } - if( fileData.sourceFileTime != sourceFileTime && sourceFileTime != 0 && com_productionMode.GetInteger() == 0 ) + + // RB: source might be from .resources, so we ignore the time stamp and assume a release build + if( !fileSystem->InProductionMode() && ( sourceTimeStamp != FILE_NOT_FOUND_TIMESTAMP ) && ( sourceTimeStamp != 0 ) && ( sourceTimeStamp != fileData.sourceFileTime ) ) { return false; } + // RB end int numImages = fileData.numLevels; if( fileData.textureType == TT_CUBIC ) diff --git a/neo/renderer/Model.cpp b/neo/renderer/Model.cpp index 4f09bd8941..17f64f0cec 100644 --- a/neo/renderer/Model.cpp +++ b/neo/renderer/Model.cpp @@ -366,10 +366,12 @@ bool idRenderModelStatic::LoadBinaryModel( idFile* file, const ID_TIME_T sourceT file->ReadBig( timeStamp ); - if( !fileSystem->InProductionMode() && sourceTimeStamp != timeStamp ) + // RB: source might be from .resources, so we ignore the time stamp and assume a release build + if( !fileSystem->InProductionMode() && ( sourceTimeStamp != FILE_NOT_FOUND_TIMESTAMP ) && ( sourceTimeStamp != 0 ) && ( sourceTimeStamp != timeStamp ) ) { return false; } + // RB end common->UpdateLevelLoadPacifier(); diff --git a/neo/renderer/ModelManager.cpp b/neo/renderer/ModelManager.cpp index f9398532e1..37aa10e272 100644 --- a/neo/renderer/ModelManager.cpp +++ b/neo/renderer/ModelManager.cpp @@ -301,11 +301,15 @@ idRenderModel* idRenderModelManagerLocal::GetModel( const char* _modelName, bool idStr generatedFileName = "generated/rendermodels/"; generatedFileName.AppendPath( canonical ); generatedFileName.SetFileExtension( va( "b%s", extension.c_str() ) ); + + // Get the timestamp on the original file, if it's newer than what is stored in binary model, regenerate it + ID_TIME_T sourceTimeStamp = fileSystem->GetTimestamp( canonical ); + if( model->SupportsBinaryModel() && r_binaryLoadRenderModels.GetBool() ) { idFileLocal file( fileSystem->OpenFileReadMemory( generatedFileName ) ); model->PurgeModel(); - if( !model->LoadBinaryModel( file, 0 ) ) + if( !model->LoadBinaryModel( file, sourceTimeStamp ) ) { model->LoadModel(); } diff --git a/neo/swf/SWF_Load.cpp b/neo/swf/SWF_Load.cpp index b83c7990cd..457b5a2732 100644 --- a/neo/swf/SWF_Load.cpp +++ b/neo/swf/SWF_Load.cpp @@ -139,7 +139,7 @@ bool idSWF::LoadSWF( const char* fullpath ) idSWF::LoadBinary =================== */ -bool idSWF::LoadBinary( const char* bfilename, ID_TIME_T sourceTime ) +bool idSWF::LoadBinary( const char* bfilename, ID_TIME_T sourceTimeStamp ) { idFile* f = fileSystem->OpenFileReadMemory( bfilename ); if( f == NULL || f->Length() <= 0 ) @@ -152,11 +152,13 @@ bool idSWF::LoadBinary( const char* bfilename, ID_TIME_T sourceTime ) f->ReadBig( magic ); f->ReadBig( btimestamp ); - if( magic != BSWF_MAGIC || ( com_productionMode.GetInteger() == 0 && sourceTime != FILE_NOT_FOUND_TIMESTAMP && sourceTime != btimestamp ) ) + // RB: source might be from .resources, so we ignore the time stamp and assume a release build + if( magic != BSWF_MAGIC || ( !fileSystem->InProductionMode() && ( sourceTimeStamp != FILE_NOT_FOUND_TIMESTAMP ) && ( sourceTimeStamp != 0 ) && ( sourceTimeStamp != btimestamp ) ) ) { delete f; return false; } + // RB end f->ReadBig( frameWidth ); f->ReadBig( frameHeight );