summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ca3a442)
raw | patch | inline | side by side (parent: ca3a442)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 13 Oct 2019 00:41:07 +0000 (03:41 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 13 Oct 2019 00:41:40 +0000 (03:41 +0300) |
src/game/g_game.pas | patch | blob | history | |
src/game/g_main.pas | patch | blob | history | |
src/game/g_res_downloader.pas | patch | blob | history |
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 4e2382628b74a8faa5a2198439b96e5695ae8bc8..2b827412980e5292b5ecd3db459292af8ed0c734 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
NetState := NET_STATE_AUTH;
g_Game_SetLoadingText(_lc[I_LOAD_CONNECT], 0, False);
+
+ // create (or update) map/resource databases
+ g_Res_CreateDatabases(true);
+
// Ñòàðòóåì êëèåíò
if not g_Net_Connect(Addr, Port) then
begin
diff --git a/src/game/g_main.pas b/src/game/g_main.pas
index 5ea72be400acb2a56f9809a70217175121492ddc..3b84f30eb820982eae315c8147e4eccdfdc9458a 100644 (file)
--- a/src/game/g_main.pas
+++ b/src/game/g_main.pas
g_holmes_imfunctional := not flexloaded;
{$ENDIF}
- g_Res_CreateDatabases();
+ //g_Res_CreateDatabases(); // it will be done before connecting to the server for the first time
e_WriteLog('Entering SDLMain', TMsgType.Notify);
index 438cd58357c6a1a0ecde23a83ffe62f4cc12c2ed..85438c474b4cae73bb9774cb945c740e9d792cb3 100644 (file)
function g_Res_FindReplacementWad (oldname: AnsiString): AnsiString;
// call this somewhere in startup sequence
-procedure g_Res_CreateDatabases ();
+procedure g_Res_CreateDatabases (allowRescan: Boolean=false);
implementation
// g_Res_CreateDatabases
//
//==========================================================================
-procedure g_Res_CreateDatabases ();
+procedure g_Res_CreateDatabases (allowRescan: Boolean=false);
var
st: TStream;
+ upmap: Boolean;
+ upres: Boolean;
+ forcesave: Boolean;
begin
- // create and load a know map database, if necessary
- knownMaps.Free;
- knownMaps := TFileHashDB.Create(GameDir+'/maps/');
- knownRes := TFileHashDB.Create(GameDir+'/wads/');
- saveDBsToDiskEnabled := true;
- // load map database
- st := nil;
- try
- st := openDiskFileRO(GameDir+'/data/maphash.db');
- knownMaps.loadFrom(st);
- e_LogWriteln('loaded map database');
- except
- end;
- st.Free;
- // load resource database
- st := nil;
- try
- st := openDiskFileRO(GameDir+'/data/reshash.db');
- knownRes.loadFrom(st);
- e_LogWriteln('loaded resource database');
- except
+ if not assigned(knownMaps) then
+ begin
+ // create and load a know map database, if necessary
+ knownMaps := TFileHashDB.Create(GameDir+'/maps/');
+ knownRes := TFileHashDB.Create(GameDir+'/wads/');
+ saveDBsToDiskEnabled := true;
+ // load map database
+ st := nil;
+ try
+ st := openDiskFileRO(GameDir+'/data/maphash.db');
+ knownMaps.loadFrom(st);
+ e_LogWriteln('loaded map database');
+ except
+ end;
+ st.Free;
+ // load resource database
+ st := nil;
+ try
+ st := openDiskFileRO(GameDir+'/data/reshash.db');
+ knownRes.loadFrom(st);
+ e_LogWriteln('loaded resource database');
+ except
+ end;
+ st.Free;
+ forcesave := true;
+ end
+ else
+ begin
+ if (not allowRescan) then exit;
+ forcesave := false;
end;
- st.Free;
// rescan dirs
e_LogWriteln('refreshing map database');
- knownMaps.scanFiles();
+ upmap := knownMaps.scanFiles();
e_LogWriteln('refreshing resource database');
- knownRes.scanFiles();
+ upres := knownRes.scanFiles();
// save databases
- saveDatabases(true, true);
+ if (forcesave) then begin upmap := true; upres := true; end;
+ if upmap or upres then saveDatabases(upmap, upres);
end;
begin
result := '';
clearReplacementWads();
+ g_Res_CreateDatabases();
try
g_Res_received_map_start := 1;