summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7722f99)
raw | patch | inline | side by side (parent: 7722f99)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 25 Aug 2017 10:41:56 +0000 (13:41 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 25 Aug 2017 10:42:18 +0000 (13:42 +0300) |
src/game/g_game.pas | patch | blob | history | |
src/game/g_map.pas | patch | blob | history | |
src/game/g_monsters.pas | patch | blob | history | |
src/game/g_saveload.pas | patch | blob | history |
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 75d2693b590e8c317a239c70d27d2a85967b7db6..24f6324b56bc27a00db40c43d9dce0f735cfc26b 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
procedure GameCommands(P: SArray);
procedure GameCheats(P: SArray);
procedure DebugCommands(P: SArray);
-//procedure ProfilerCommands(P: SArray);
procedure g_Game_Process_Params;
procedure g_Game_SetLoadingText(Text: String; Max: Integer; reWrite: Boolean);
procedure g_Game_StepLoading();
end;
end;
-(*
-// profiler console commands
-procedure ProfilerCommands (P: SArray);
-var
- cmd: string;
-
- function getBool (idx: Integer): Integer;
- begin
- if (idx < 0) or (idx > High(P)) then begin result := -1; exit; end;
- result := 0;
- if (P[idx] = '1') or (P[idx] = 'on') or (P[idx] = 'true') or (P[idx] = 'tan') then result := 1;
- end;
-
- procedure binaryFlag (var flag: Boolean; msg: string);
- begin
- if (Length(p) > 2) then
- begin
- g_Console_Add('too many arguments to '''+P[0]+'''');
- end
- else
- begin
- case getBool(1) of
- -1: begin end;
- 0: flag := false;
- 1: flag := true;
- end;
- if flag then g_Console_Add(msg+': tan') else g_Console_Add(msg+': ona');
- end;
- end;
-
-begin
- //if not gDebugMode then exit;
- cmd := LowerCase(P[0]);
-
- if (cmd = 'pf_draw_frame') then begin binaryFlag(g_profile_frame_draw, 'render profiles'); exit; end;
- if (cmd = 'pf_update_frame') then begin binaryFlag(g_profile_frame_update, 'update profiles (not yet)'); exit; end;
- if (cmd = 'pf_coldet') then begin binaryFlag(g_profile_collision, 'coldet profiles'); exit; end;
- if (cmd = 'pf_los') then begin binaryFlag(g_profile_los, 'monster LOS profiles'); exit; end;
- if (cmd = 'r_sq_draw') then begin binaryFlag(gdbg_map_use_accel_render, 'accelerated rendering'); exit; end;
- if (cmd = 'cd_sq_enabled') then begin binaryFlag(gdbg_map_use_accel_coldet, 'accelerated map coldet'); exit; end;
- if (cmd = 'mon_sq_enabled') then begin binaryFlag(gmon_debug_use_sqaccel, 'accelerated monster coldet'); exit; end;
- if (cmd = 'wtrace_sq_enabled') then begin binaryFlag(gwep_debug_fast_trace, 'accelerated weapon hitscan'); exit; end;
- if (cmd = 'pr_enabled') then begin binaryFlag(gpart_dbg_enabled, 'particles'); exit; end;
- if (cmd = 'pr_phys_enabled') then begin binaryFlag(gpart_dbg_phys_enabled, 'particle physics'); exit; end;
- if (cmd = 'los_enabled') then begin binaryFlag(gmon_dbg_los_enabled, 'LOS calculations'); exit; end;
-
- if (not gGameOn) or (not gCheats) or ((gGameSettings.GameType <> GT_SINGLE) and
- (gGameSettings.GameMode <> GM_COOP) and (not gDebugMode)) or g_Game_IsNet then exit;
-
- if (cmd = 'mon_think') then begin binaryFlag(gmon_debug_think, 'monster thinking'); exit; end;
- if (cmd = 'dbg_holmes') then begin binaryFlag(g_holmes_enabled, 'Holmes'); exit; end;
-end;
-*)
procedure DebugCommands(P: SArray);
var
diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index b9da59dd6d2064a97120d49f7bca56425d8533b3..d93f0aa8aec41cda0d3b6dc3d3ad5a7253e59ec9 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
calcBoundingBox(gLifts);
calcBoundingBox(gBlockMon);
- e_WriteLog(Format('map dimensions: (%d,%d)-(%d,%d); editor size:(0,0)-(%d,%d)', [mapX0, mapY0, mapX1, mapY1, gMapInfo.Width, gMapInfo.Height]), MSG_WARNING);
+ e_LogWritefln('map dimensions: (%d,%d)-(%d,%d); editor size:(0,0)-(%d,%d)', [mapX0, mapY0, mapX1, mapY1, gMapInfo.Width, gMapInfo.Height]);
if (mapX0 > 0) then mapX0 := 0;
if (mapY0 > 0) then mapY0 := 0;
PAMem.LoadFromMemory(Mem);
for i := 0 to Length(panels)-1 do
+ begin
if panels[i].SaveIt then
begin
// ID ïàíåëè:
end;
// Çàãðóæàåì ïàíåëü:
panels[i].LoadState(PAMem);
+ panels[i].arrIdx := i;
end;
+ end;
// Ýòîò ñïèñîê ïàíåëåé çàãðóæåí:
PAMem.Free();
// Îáíîâëÿåì êàðòó ñòîëêíîâåíèé è ñåòêó:
g_GFX_Init();
- mapCreateGrid();
+ //mapCreateGrid();
///// Çàãðóæàåì ìóçûêó: /////
// Ñèãíàòóðà ìóçûêè:
index 8c2f2d7e399093feed5c4d58481ffe2ded58cf95..04e19241b541fb591877fa8e7f4089cf233ddeb6 100644 (file)
--- a/src/game/g_monsters.pas
+++ b/src/game/g_monsters.pas
procedure g_Monsters_LoadData ();
procedure g_Monsters_FreeData ();
procedure g_Monsters_Init ();
-procedure g_Monsters_Free ();
+procedure g_Monsters_Free (clearGrid: Boolean=true);
function g_Monsters_Create (MonsterType: Byte; X, Y: Integer; Direction: TDirection;
AdjCoord: Boolean = False; ForcedUID: Integer = -1): TMonster;
procedure g_Monsters_Update ();
soulcount := 0;
end;
-procedure g_Monsters_Free();
+procedure g_Monsters_Free (clearGrid: Boolean=true);
var
a: Integer;
begin
- monsGrid.Free();
- monsGrid := nil;
+ e_LogWritefln('Cleared monster data (clearGrid=%s)', [clearGrid]);
+ if (clearGrid) then
+ begin
+ monsGrid.Free();
+ monsGrid := nil;
+ end;
for a := 0 to High(gMonsters) do gMonsters[a].Free();
gMonsters := nil;
clearUidMap();
begin
monsGrid.Free();
monsGrid := TMonsterGrid.Create(x, y, w, h);
+ //clearUidMap(); // why not?
+ e_LogWritefln('%s', ['Recreated monster tree']);
end;
begin
if Mem = nil then exit;
- g_Monsters_Free();
+ g_Monsters_Free(false);
// Çàãðóæàåì èíôîðìàöèþ öåëåóêàçàòåëÿ
Mem.ReadInt(pt_x);
end;
end;
+procedure monsPostLoad ();
+begin
+end;
+
procedure TMonster.LoadState(var Mem: TBinMemoryReader);
var
i: Integer;
begin
raise EBinSizeError.Create('TMonster.LoadState: Wrong Monster Signature');
end;
+ if (uidMap[FUID] <> nil) and (uidMap[FUID] <> self) then raise Exception.Create('internal error in monster loader (0)');
+ uidMap[FUID] := nil;
// UID ìîíñòðà:
Mem.ReadWord(FUID);
+ //if (arrIdx = -1) then raise Exception.Create('internal error in monster loader');
+ if (uidMap[FUID] <> nil) then raise Exception.Create('internal error in monster loader (1)');
+ uidMap[FUID] := self;
// Íàïðàâëåíèå:
Mem.ReadByte(b);
if b = 1 then
end;
+begin
+ g_SetPostLoadHook(monsPostLoad);
end.
index aaf01b5efd86bcac97a56a56f64787127644bc6d..e6a1ca293344ca1b603ff026a4fbc514c0ee7f54 100644 (file)
--- a/src/game/g_saveload.pas
+++ b/src/game/g_saveload.pas
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
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;
g_Game_SetLoadingText(_lc[I_LOAD_SAVE_FILE], 0, False);
gLoadGameMode := True;
+ g_CallPreLoadHooks();
+
///// Çàãðóæàåì ñîñòîÿíèå èãðû: /////
bMem := TBinMemoryReader.Create();
bFile.ReadMemory(bMem);
// Çàêðûâàåì ôàéë çàãðóçêè:
bFile.Close();
gLoadGameMode := False;
+ g_CallPostLoadHooks();
Result := True;
except