Skip to content

Commit

Permalink
Improved modding support and loading of custom models/anims
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertBeckebans committed Feb 25, 2015
1 parent b59ed94 commit 06d0434
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 12 deletions.
4 changes: 4 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ _______________________________

- Added back dmap and aas compilers (mapping tools)

- Cinematic sequences can be skipped

- Localization support for other languages than English



_______________________________________
Expand Down
6 changes: 5 additions & 1 deletion neo/cm/CollisionModel_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
5 changes: 4 additions & 1 deletion neo/d3xp/anim/Anim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
17 changes: 13 additions & 4 deletions neo/framework/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++ )
Expand Down
7 changes: 5 additions & 2 deletions neo/renderer/BinaryImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand All @@ -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 )
Expand Down
4 changes: 3 additions & 1 deletion neo/renderer/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
6 changes: 5 additions & 1 deletion neo/renderer/ModelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
6 changes: 4 additions & 2 deletions neo/swf/SWF_Load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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 );
Expand Down

0 comments on commit 06d0434

Please sign in to comment.