Smaller potential crashfixes from SS2 engine

This commit is contained in:
Robert Beckebans 2020-12-23 21:02:38 +01:00
parent 7f168d6415
commit 72cf7cef86
4 changed files with 94 additions and 29 deletions

View file

@ -251,8 +251,8 @@ elseif(MSVC)
-D_CRT_SECURE_NO_DEPRECATE
-D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_SECURE_NO_WARNINGS
-D_MBCS
#-DUSE_OPENAL
-D_MBCS
#-DUSE_OPENAL
-DUSE_EXCEPTIONS)
## Check for Version ##
if( WINRT OR WINDOWS10 ) # Windows RT

View file

@ -405,8 +405,6 @@ Returns the index of the new element, or -1 when list is full.
template<class type, int size>
ID_INLINE int idStaticList<type, size>::Insert( type const& obj, int index )
{
int i;
assert( num < size );
if( num >= size )
{
@ -423,7 +421,7 @@ ID_INLINE int idStaticList<type, size>::Insert( type const& obj, int index )
index = num;
}
for( i = num; i > index; --i )
for( int i = num; i > index; --i )
{
list[i] = list[i - 1];
}
@ -445,14 +443,13 @@ Returns the size of the new combined list
template<class type, int size>
ID_INLINE int idStaticList<type, size>::Append( const idStaticList<type, size>& other )
{
int i;
int n = other.Num();
if( num + n > size )
{
n = size - num;
}
for( i = 0; i < n; i++ )
for( int i = 0; i < n; i++ )
{
list[i + num] = other.list[i];
}
@ -470,9 +467,7 @@ Adds the data to the list if it doesn't already exist. Returns the index of the
template<class type, int size>
ID_INLINE int idStaticList<type, size>::AddUnique( type const& obj )
{
int index;
index = FindIndex( obj );
int index = FindIndex( obj );
if( index < 0 )
{
index = Append( obj );
@ -491,9 +486,7 @@ Searches for the specified data in the list and returns it's index. Returns -1
template<class type, int size>
ID_INLINE int idStaticList<type, size>::FindIndex( type const& obj ) const
{
int i;
for( i = 0; i < num; i++ )
for( int i = 0; i < num; i++ )
{
if( list[ i ] == obj )
{
@ -515,9 +508,7 @@ Searches for the specified data in the list and returns it's address. Returns NU
template<class type, int size>
ID_INLINE type* idStaticList<type, size>::Find( type const& obj ) const
{
int i;
i = FindIndex( obj );
int i = FindIndex( obj );
if( i >= 0 )
{
return ( type* ) &list[ i ];
@ -539,9 +530,7 @@ on non-pointer lists will cause a compiler error.
template<class type, int size>
ID_INLINE int idStaticList<type, size>::FindNull() const
{
int i;
for( i = 0; i < num; i++ )
for( int i = 0; i < num; i++ )
{
if( list[ i ] == NULL )
{
@ -609,7 +598,7 @@ ID_INLINE bool idStaticList<type, size>::RemoveIndex( int index )
/*
========================
idList<_type_,_tag_>::RemoveIndexFast
idStaticList<_type_,_tag_>::RemoveIndexFast
Removes the element at the specified index and moves the last element into its spot, rather
than moving the whole array down by one. Of course, this doesn't maintain the order of
@ -685,7 +674,7 @@ void BreakOnListDefault();
/*
========================
idList<_type_,_tag_>::Resize
idStaticList<_type_,_tag_>::Resize
Allocates memory for the amount of elements requested while keeping the contents intact.
Contents are copied using their = operator so that data is correctly instantiated.

View file

@ -935,9 +935,11 @@ void idSoundWorldLocal::ProcessDemoCommand( idDemoFile* readDemo )
break;
}
case SCMD_STATE:
{
ReadFromSaveGame( readDemo );
UnPause();
break;
}
case SCMD_PLACE_LISTENER:
{
idVec3 origin;

View file

@ -3,6 +3,8 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2014-2016 Robert Beckebans
Copyright (C) 2014-2016 Kot in Action Creative Artel
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -137,11 +139,32 @@ idSessionLocal::idSessionLocal
*/
idSessionLocal::~idSessionLocal()
{
delete processorSaveFiles;
delete processorLoadFiles;
delete processorDelete;
delete processorEnumerate;
delete sessionCallbacks;
// foresthale 2014-06-08: check before deleting these, the deletes were likely done in Shutdown already
if( processorSaveFiles )
{
delete processorSaveFiles;
processorSaveFiles = NULL;
}
if( processorLoadFiles )
{
delete processorLoadFiles;
processorLoadFiles = NULL;
}
if( processorDelete )
{
delete processorDelete;
processorDelete = NULL;
}
if( processorEnumerate )
{
delete processorEnumerate;
processorEnumerate = NULL;
}
if( sessionCallbacks )
{
delete sessionCallbacks;
sessionCallbacks = NULL;
}
}
@ -1583,11 +1606,20 @@ idSessionLocal::~idSession
*/
idSession::~idSession()
{
delete signInManager;
if( signInManager )
{
delete signInManager;
}
signInManager = NULL;
delete saveGameManager;
if( saveGameManager )
{
delete saveGameManager;
}
saveGameManager = NULL;
delete dedicatedServerSearch;
if( dedicatedServerSearch )
{
delete dedicatedServerSearch;
}
dedicatedServerSearch = NULL;
}
@ -1618,6 +1650,48 @@ idSessionLocal::Shutdown
*/
void idSessionLocal::Shutdown()
{
// foresthale 2014-05-28: shut down saveGameManager early because the thread it owns will be terminated before the dtor is reached
if( signInManager )
{
delete signInManager;
}
signInManager = NULL;
if( saveGameManager )
{
delete saveGameManager;
}
saveGameManager = NULL;
if( dedicatedServerSearch )
{
delete dedicatedServerSearch;
}
dedicatedServerSearch = NULL;
// foresthale 2014-06-08: delete these before we get to the dtor to prevent doexit crashes
if( processorSaveFiles )
{
delete processorSaveFiles;
processorSaveFiles = NULL;
}
if( processorLoadFiles )
{
delete processorLoadFiles;
processorLoadFiles = NULL;
}
if( processorDelete )
{
delete processorDelete;
processorDelete = NULL;
}
if( processorEnumerate )
{
delete processorEnumerate;
processorEnumerate = NULL;
}
if( sessionCallbacks )
{
delete sessionCallbacks;
sessionCallbacks = NULL;
}
}
/*