index 3a1cecdc6e0782df8ef69912b81b17284c78ba18..e6a1ca293344ca1b603ff026a4fbc514c0ee7f54 100644 (file)
--- a/src/game/g_saveload.pas
+++ b/src/game/g_saveload.pas
-{$MODE DELPHI}
+(* Copyright (C) DooM 2D:Forever Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *)
+{$INCLUDE ../shared/a_modes.inc}
unit g_saveload;
interface
procedure Obj_SaveState(o: PObj; var Mem: TBinMemoryWriter);
procedure Obj_LoadState(o: PObj; var Mem: TBinMemoryReader);
+type
+ TLoadSaveHook = procedure ();
+
+procedure g_SetPreLoadHook (ahook: TLoadSaveHook);
+procedure g_SetPostLoadHook (ahook: TLoadSaveHook);
+
+procedure g_CallPreLoadHooks ();
+procedure g_CallPostLoadHooks ();
+
+
implementation
uses
const
SAVE_SIGNATURE = $56534644; // 'DFSV'
- SAVE_VERSION = $02;
+ SAVE_VERSION = $03;
END_MARKER_STRING = 'END';
PLAYER_VIEW_SIGNATURE = $57564C50; // 'PLVW'
OBJ_SIGNATURE = $4A424F5F; // '_OBJ'
+
+var
+ preloadHooks: array of TLoadSaveHook = nil;
+ postloadHooks: array of TLoadSaveHook = nil;
+
+
+procedure g_SetPreLoadHook (ahook: TLoadSaveHook);
+begin
+ if not assigned(ahook) then exit;
+ SetLength(preloadHooks, Length(preloadHooks)+1);
+ preloadHooks[High(preloadHooks)] := ahook;
+end;
+
+
+procedure g_SetPostLoadHook (ahook: TLoadSaveHook);
+begin
+ if not assigned(ahook) then exit;
+ SetLength(postloadHooks, Length(postloadHooks)+1);
+ postloadHooks[High(postloadHooks)] := ahook;
+end;
+
+
+procedure g_CallPreLoadHooks ();
+var
+ f: Integer;
+begin
+ for f := 0 to High(preloadHooks) do preloadHooks[f]();
+end;
+
+
+procedure g_CallPostLoadHooks ();
+var
+ f: Integer;
+begin
+ for f := 0 to High(postloadHooks) do postloadHooks[f]();
+end;
+
+
procedure Obj_SaveState(o: PObj; var Mem: TBinMemoryWriter);
var
sig: DWORD;
str := gGameSettings.WAD;
bMem.WriteString(str, 128);
// Èìÿ êàðòû:
- g_ProcessResourceStr(gMapInfo.Map, nil, nil, @str);
+ str := g_ExtractFileName(gMapInfo.Map);
bMem.WriteString(str, 32);
// Êîëè÷åñòâî èãðîêîâ:
nPlayers := g_Player_GetCount();
g_Game_SetLoadingText(_lc[I_LOAD_SAVE_FILE], 0, False);
gLoadGameMode := True;
+ g_CallPreLoadHooks();
+
///// Çàãðóæàåì ñîñòîÿíèå èãðû: /////
bMem := TBinMemoryReader.Create();
bFile.ReadMemory(bMem);
///// /////
// Èùåì òðèããåðû ñ óñëîâèåì ñìåðòè ìîíñòðîâ:
- if (gMonsters <> nil) and (gTriggers <> nil) then
+ if {(gMonsters <> nil) and} (gTriggers <> nil) then
g_Map_ReAdd_DieTriggers();
// Çàêðûâàåì ôàéë çàãðóçêè:
bFile.Close();
gLoadGameMode := False;
+ g_CallPostLoadHooks();
Result := True;
except