Skip to content

Commit

Permalink
feat(Era): Update Era source code to 3.9.14. Commit: 83748ff
Browse files Browse the repository at this point in the history
Signed-off-by: VuceticBranislav <[email protected]>
  • Loading branch information
VuceticBranislav committed Jun 22, 2024
1 parent a0f7696 commit 0aa1a1f
Show file tree
Hide file tree
Showing 29 changed files with 1,067 additions and 464 deletions.
42 changes: 34 additions & 8 deletions Era/AdvErm.pas
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
unit AdvErm;
{
DESCRIPTION: Era custom Memory implementation
AUTHOR: Alexander Shostak (aka Berserker aka EtherniDee aka BerSoft)
}
(*
Description: Era custom Memory implementation
Author: Alexander Shostak aka Berserker
*)

(***) interface (***)

uses
Windows, SysUtils, Math, Crypto, UtilsB2, AssocArrays, DataLib, StrLib, TypeWrappers, Files, ApiJack, Alg,
PatchApi, Core, GameExt, Erm, Stores, Triggers, Heroes, Lodman, Network, Trans, EventMan, DlgMes, Legacy;
Math,
SysUtils,
Windows,

Alg,
ApiJack,
AssocArrays,
Core,
Crypto,
DataLib,
DlgMes,
Files,
PatchApi,
StrLib,
TypeWrappers,
UtilsB2,

EraSettings,
Erm,
EventMan,
GameExt,
Heroes,
Lodman,
Network,
Stores,
Trans,
Triggers, Legacy;

const
AUTO_ALLOC_SLOT = -1;
Expand Down Expand Up @@ -57,7 +83,7 @@
(* Hint code flags *)
CODE_TYPE_SUBTYPE = $01000000;

ERM_MEMORY_DUMP_FILE : myAStr = GameExt.DEBUG_DIR + '\erm memory dump.txt';
ERM_MEMORY_DUMP_FILE : myAStr = EraSettings.DEBUG_DIR + '\erm memory dump.txt';

type
(* Import *)
Expand Down Expand Up @@ -2839,7 +2865,7 @@ function Hook_ZvsHintControl0 (OrigFunc, Self: pointer; MapTile: Heroes.PMapTile
result := PatchApi.Call(THISCALL_, OrigFunc, [Self, MapTile, Unk1, Unk2]);
end;

function Hook_ZvsHintWindow (OrigFunc: pointer; Self: Heroes.PAdvManager; x, y, z: integer): integer; stdcall;
function Hook_ZvsHintWindow (OrigFunc: pointer; Self: Heroes.PWndManager; x, y, z: integer): integer; stdcall;
begin
Heroes.TextBuf[0] := #0;
TileHintEventType := TILE_POPUP_EVENT;
Expand Down
8 changes: 4 additions & 4 deletions Era/Era.dpr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
library Era;
{
DESCRIPTION: HMM 3.5 WogEra
AUTHOR: Alexander Shostak (aka Berserker aka EtherniDee aka BerSoft)
}
(*
Description: Heroes of Might and Magic 3.5: In The Wake of Gods (ERA)
Author: Alexander Shostak aka Berserker
*)
{$R 'VersionInfo.res' 'VersionInfo.rc'}
{$R *.RES}

Expand Down
93 changes: 68 additions & 25 deletions Era/EraLog.pas
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
unit EraLog;
{
DESCRIPTION: Logging support
AUTHOR: Alexander Shostak (aka Berserker aka EtherniDee aka BerSoft)
}
(*
Description: Logging support
Author: Alexander Shostak aka Berserker
*)


(***) interface (***)
uses Windows, SysUtils, UtilsB2, Files, ConsoleAPI, Log, StrLib, Concur, DlgMes, Legacy;

uses
Concur,
ConsoleAPI,
Log,
StrLib,
SysUtils,
Windows,

EraSettings,
VfsImport, Legacy;


type
TLogger = class (Log.TLogger)
Expand All @@ -24,39 +36,44 @@ TLogger = class (Log.TLogger)
function GetPos (out Pos: integer): boolean; override;
function Seek (NewPos: integer): boolean; override;
function GetCount (out Count: integer): boolean; override;
end; // .class TLogger
end;

TMemoryLogger = class (TLogger)
TFakeLogger = class (TLogger)
function Write (const EventSource, Operation, Description: myAStr): boolean; override;
end;

TConsoleLogger = class (TLogger)
(***) protected (***)
{O} fCon: ConsoleAPI.TConsole;
protected
{O} fCon: ConsoleAPI.TConsole;

(***) public (***)
constructor Create (const Title: myAStr);
destructor Destroy; override;
function Write (const EventSource, Operation, Description: myAStr): boolean; override;
end; // .class TConsoleLogger
public
constructor Create (const Title: myAStr);
destructor Destroy; override;

function Write (const EventSource, Operation, Description: myAStr): boolean; override;
end;

TFileLogger = class (TLogger)
(***) protected (***)
{O} fFile: Windows.THandle;
(***) public (***)
constructor Create (const FilePath: myAStr);
destructor Destroy; override;
function Write (const EventSource, Operation, Description: myAStr): boolean; override;
protected
{O} fFile: Windows.THandle;

public
constructor Create (const FilePath: myAStr);
destructor Destroy; override;

function Write (const EventSource, Operation, Description: myAStr): boolean; override;
end;


procedure InstallLoggers (const GameDir: myAStr);


(***) implementation (***)


const
LOG_FILE_NAME = myAStr('log.txt');

BR = myAStr(#13#10);
RECORD_BEGIN_SEPARATOR : myAStr = '>> ';
RECORD_END_SEPARATOR : myAStr = BR + BR;
Expand Down Expand Up @@ -126,7 +143,7 @@ function TLogger.GetCount (out Count: integer): boolean;
result := false;
end;

function TMemoryLogger.Write (const EventSource, Operation, Description: myAStr): boolean;
function TFakeLogger.Write (const EventSource, Operation, Description: myAStr): boolean;
begin
result := true;
end;
Expand Down Expand Up @@ -175,7 +192,11 @@ function TConsoleLogger.Write (const EventSource, Operation, Description: myAStr
constructor TFileLogger.Create (const FilePath: myAStr);
begin
inherited Create;
Self.fFile := Windows.CreateFileA(myPChar(FilePath), Windows.GENERIC_WRITE, Windows.FILE_SHARE_READ or Windows.FILE_SHARE_DELETE, nil, Windows.CREATE_ALWAYS, Windows.FILE_ATTRIBUTE_NORMAL, 0);

Self.fFile := Windows.CreateFileA(
myPChar(FilePath), Windows.GENERIC_WRITE, Windows.FILE_SHARE_READ or Windows.FILE_SHARE_DELETE, nil, Windows.CREATE_ALWAYS,
Windows.FILE_ATTRIBUTE_NORMAL, 0
);
end;

destructor TFileLogger.Destroy;
Expand Down Expand Up @@ -218,4 +239,26 @@ function TFileLogger.Write (const EventSource, Operation, Description: myAStr):
end; // .with
end; // .function TFileLogger.Write

procedure VfsLogger (Operation, Msg: myPChar); stdcall;
begin
Log.Write('VFS', Operation, Msg);
end;

procedure InstallLoggers (const GameDir: myAStr);
begin
if EraSettings.IsDebug then begin
if Legacy.AnsiLowerCase(EraSettings.GetOpt('Debug.LogDestination').Str('File')) = 'file' then begin
Log.InstallLogger(EraLog.TFileLogger.Create(GameDir + '\' + EraSettings.DEBUG_DIR + '\' + LOG_FILE_NAME), true);
end else begin
Log.InstallLogger(EraLog.TConsoleLogger.Create('Era Log'), true);
end;
end else begin
Log.InstallLogger(EraLog.TFakeLogger.Create, true);
end;

if EraSettings.GetDebugBoolOpt('Debug.LogVirtualFileSystem', false) then begin
VfsImport.SetLoggingProc(@VfsLogger);
end;
end;

end.
Loading

0 comments on commit 0aa1a1f

Please sign in to comment.