Skip to content

Commit

Permalink
possible crash fix for zip issues
Browse files Browse the repository at this point in the history
  • Loading branch information
BoyC committed Apr 9, 2022
1 parent 885972d commit 4b9d746
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
4 changes: 2 additions & 2 deletions BuildCount.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
//Automatically generated build count file. DO NOT EDIT MANUALLY!

#define BUILD_COUNT_ANUBIS 91
#define BUILD_COUNT_DESKTOP_EDTCHAL 3603
#define BUILD_COUNT_DESKTOP_EDTCHAL 3605

#define RELEASE_COUNT_ANUBIS 0
#define RELEASE_COUNT_DESKTOP_EDTCHAL 63
#define RELEASE_COUNT_DESKTOP_EDTCHAL 64

#define BUILDCOUNT (BUILD_COUNT_ANUBIS+BUILD_COUNT_DESKTOP_EDTCHAL)
#define RELEASECOUNT (RELEASE_COUNT_ANUBIS+RELEASE_COUNT_DESKTOP_EDTCHAL)
7 changes: 6 additions & 1 deletion GW2TacO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,12 @@ INT WINAPI WinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,

ShowWindow( tacoHWND, SW_HIDE );

FlushZipDict();
{
extern LIGHTWEIGHT_CRITICALSECTION zipCritSec;
CLightweightCriticalSection fileWrite( &zipCritSec );
FlushZipDict();
}

ShutDownInputHooks();
Config::Save();
ShutDownWvWChecking();
Expand Down
50 changes: 27 additions & 23 deletions MarkerPack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ TBOOL FindSavedCategory( GW2TacticalCategory* t )
if ( t->keepSaveState || t->needsExport )
return true;
for ( TS32 x = 0; x < t->children.NumItems(); x++ )
if ( FindSavedCategory( t->children[ x ] ) )
if ( FindSavedCategory( t->children[ x ] ) )
return true;
return false;
}
Expand Down Expand Up @@ -389,10 +389,10 @@ void RecursiveImportPOIType( CXMLNode& root, GW2TacticalCategory* Root, CString
void ImportPOITypes()
{
CXMLDocument d;
if ( !d.LoadFromFile( "categorydata.xml" ) )
if ( !d.LoadFromFile( "categorydata.xml" ) )
return;

if ( !d.GetDocumentNode().GetChildCount( "OverlayData" ) )
if ( !d.GetDocumentNode().GetChildCount( "OverlayData" ) )
return;
CXMLNode root = d.GetDocumentNode().GetChild( "OverlayData" );

Expand Down Expand Up @@ -474,7 +474,7 @@ TBOOL ImportTrail( CWBApplication* App, CXMLNode& t, GW2Trail& p, const CString&

void ImportPOIDocument( CWBApplication* App, CXMLDocument& d, TBOOL External, const CString& zipFile )
{
if ( !d.GetDocumentNode().GetChildCount( "OverlayData" ) )
if ( !d.GetDocumentNode().GetChildCount( "OverlayData" ) )
return;
CXMLNode root = d.GetDocumentNode().GetChild( "OverlayData" );

Expand Down Expand Up @@ -570,13 +570,15 @@ void ImportPOIFile( CWBApplication* App, CString s, TBOOL External )
void ImportPOIString( CWBApplication* App, const CString& data, const CString& zipFile )
{
CXMLDocument d;
if ( !d.LoadFromString( data ) )
if ( !d.LoadFromString( data ) )
return;
ImportPOIDocument( App, d, true, zipFile );
}

void ImportMarkerPack( CWBApplication* App, const CString& zipFile )
{
CLightweightCriticalSection fileRead( &zipCritSec );

mz_zip_archive* zip = OpenZipFile( zipFile );
if ( !zip )
return;
Expand Down Expand Up @@ -615,7 +617,10 @@ void ImportMarkerPack( CWBApplication* App, const CString& zipFile )

void ImportPOIS( CWBApplication* App )
{
FlushZipDict();
{
CLightweightCriticalSection fileWrite( &zipCritSec );
FlushZipDict();
}
ImportPOITypes();

POISet.clear();
Expand Down Expand Up @@ -653,7 +658,7 @@ void ImportPOIS( CWBApplication* App )
void ImportPOIActivationData()
{
CXMLDocument d;
if ( !d.LoadFromFile( "activationdata.xml" ) )
if ( !d.LoadFromFile( "activationdata.xml" ) )
return;

if ( !d.GetDocumentNode().GetChildCount( "OverlayData" ) ) return;
Expand Down Expand Up @@ -977,13 +982,12 @@ bool MarkerPack::UpdateFromWeb()
CreateDirectory( "POIs", 0 );
CreateDirectory( "POIs/Online", 0 );

FlushZipDict();

CString fn = "POIs/Online/" + fileName;
FILE* f = nullptr;

{
CLightweightCriticalSection fileWrite( &zipCritSec );
FlushZipDict();

CString fn = "POIs/Online/" + fileName;
FILE* f = nullptr;

fopen_s( &f, fn.GetPointer(), "wb" );
if ( !f )
Expand All @@ -1001,19 +1005,19 @@ bool MarkerPack::UpdateFromWeb()
if ( fwrite( markerPack.GetPointer(), 1, markerPack.Length(), f ) != markerPack.Length() )
failed = true;
fclose( f );
}

if ( !failed )
{
CString versionConfigValue = "MarkerPack_" + id + "_version\0";
Config::SetString( versionConfigValue.GetPointer(), versionString );

markerPackQueue.Add( fn );
beingDownloaded = false;
downloadFinished = true;
if ( !failed )
{
CLightweightCriticalSection cs( &dlTextCritSec );
currentDownload = "";
CString versionConfigValue = "MarkerPack_" + id + "_version\0";
Config::SetString( versionConfigValue.GetPointer(), versionString );

markerPackQueue.Add( fn );
beingDownloaded = false;
downloadFinished = true;
{
CLightweightCriticalSection cs( &dlTextCritSec );
currentDownload = "";
}
}
}
outdated = false;
Expand Down

0 comments on commit 4b9d746

Please sign in to comment.