Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Core/GameEngine/Source/Common/AddonCompat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Bool HasFullviewportDat()
if (File* file = TheFileSystem->openFile("GenTool/fullviewport.dat", File::READ | File::BINARY))
{
file->read(&value, 1);
file->close();
}
return value != '0';
}
Expand Down
58 changes: 17 additions & 41 deletions Core/GameEngine/Source/GameClient/MapUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1142,53 +1142,38 @@ const MapMetaData *MapCache::findMap(AsciiString mapName)
// ------------------------------------------------------------------------------------------------
/** Embed the pristine map into the xfer stream */
// ------------------------------------------------------------------------------------------------
static void copyFromBigToDir( const AsciiString& infile, const AsciiString& outfile )
static Bool copyFromBigToDir( const AsciiString& infile, const AsciiString& outfile )
{
// open the map file

File *file = TheFileSystem->openFile( infile.str(), File::READ | File::BINARY );
if( file == nullptr )
{
DEBUG_CRASH(( "copyFromBigToDir - Error opening source file '%s'", infile.str() ));
throw SC_INVALID_DATA;
return FALSE;
}

// how big is the map file
Int fileSize = file->seek( 0, File::END );


// rewind to beginning of file
const Int fileSize = file->seek( 0, File::END );
file->seek( 0, File::START );

// allocate buffer big enough to hold the entire map file
char *buffer = NEW char[ fileSize ];
if( buffer == nullptr )
{
DEBUG_CRASH(( "copyFromBigToDir - Unable to allocate buffer for file '%s'", infile.str() ));
throw SC_INVALID_DATA;
}

// copy the file to the buffer
if( file->read( buffer, fileSize ) < fileSize )
{
DEBUG_CRASH(( "copyFromBigToDir - Error reading from file '%s'", infile.str() ));
throw SC_INVALID_DATA;
}
// close the BIG file
const Bool readOk = file->read( buffer, fileSize ) == fileSize;
file->close();
DEBUG_ASSERTCRASH( readOk, ( "copyFromBigToDir - Error reading from file '%s'", infile.str() ) );

File *filenew = TheFileSystem->openFile( outfile.str(), File::WRITE | File::CREATE | File::BINARY );

if( !filenew || filenew->write(buffer, fileSize) < fileSize)
Bool writeOk = FALSE;
if( readOk )
{
DEBUG_CRASH(( "copyFromBigToDir - Error writing to file '%s'", outfile.str() ));
throw SC_INVALID_DATA;
File *filenew = TheFileSystem->openFile( outfile.str(), File::WRITE | File::CREATE | File::BINARY );
if( filenew != nullptr )
{
writeOk = filenew->write( buffer, fileSize ) == fileSize;
filenew->close();
}
DEBUG_ASSERTCRASH( writeOk, ( "copyFromBigToDir - Error writing to file '%s'", outfile.str() ) );
}

filenew->close();

// delete the buffer
delete [] buffer;

return writeOk;
}

Image *getMapPreviewImage( AsciiString mapName )
Expand Down Expand Up @@ -1233,16 +1218,7 @@ Image *getMapPreviewImage( AsciiString mapName )

mapPreviewDir.concat(name);

Bool success = false;
try
{
copyFromBigToDir(tgaName, mapPreviewDir);
success = true;
}
catch (...)
{
success = false; // no rethrow
}
const Bool success = copyFromBigToDir(tgaName, mapPreviewDir);

if (success)
{
Expand Down
2 changes: 2 additions & 0 deletions Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ int asyncGethostbyname(char * szName)
/* Thread finished */
stat = 0;
s_asyncDNSLookupInProgress = FALSE;
CloseHandle(s_asyncDNSThreadHandle);
s_asyncDNSThreadHandle = nullptr;
return( (s_asyncDNSThreadSucceeded)?LOOKUP_SUCCEEDED:LOOKUP_FAILED );
}
Expand Down Expand Up @@ -833,6 +834,7 @@ void StopAsyncDNSCheck()
MAYBE_UNUSED Int res = TerminateThread(s_asyncDNSThreadHandle, 0);
(void)res;
DEBUG_ASSERTCRASH(res, ("Could not terminate the Async DNS Lookup thread!")); // Thread still not killed!
CloseHandle(s_asyncDNSThreadHandle);
}
s_asyncDNSThreadHandle = nullptr;
s_asyncDNSLookupInProgress = FALSE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2747,7 +2747,9 @@ GameWindow *GameWindowManager::winCreateFromScript( AsciiString filenameString,
{

DEBUG_LOG(( "WinCreateFromScript: Error parsing layout block" ));
return FALSE;
inFile->close();
inFile = nullptr;
return nullptr;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2772,7 +2772,9 @@ GameWindow *GameWindowManager::winCreateFromScript( AsciiString filenameString,
{

DEBUG_LOG(( "WinCreateFromScript: Error parsing layout block" ));
return FALSE;
inFile->close();
inFile = nullptr;
return nullptr;

}

Expand Down
Loading