From 621bfb05407a169f6511f5b115d0622e5ec8bdd5 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 10 Oct 2007 17:50:05 +0000 Subject: Added Hook and Service Class for new Plugin System to Trunc Added Core and CoreModule. That maybe will be used for new Core management. Core needs many code to write Some Info to Plugin SDK added git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@497 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UCore.pas | 278 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 278 insertions(+) create mode 100644 Game/Code/Classes/UCore.pas (limited to 'Game/Code/Classes/UCore.pas') diff --git a/Game/Code/Classes/UCore.pas b/Game/Code/Classes/UCore.pas new file mode 100644 index 00000000..744fabe2 --- /dev/null +++ b/Game/Code/Classes/UCore.pas @@ -0,0 +1,278 @@ +unit UCore; + +interface +uses uPluginDefs, uCoreModule, UHooks, UServices, uModules; +{********************* + TCore + Class manages all CoreModules, teh StartUp, teh MainLoop and the shutdown process + Also it does some Error Handling, and maybe sometime multithreaded Loading ;) +*********************} + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +{$I switches.inc} + +type + TModuleListItem = record + Module: TCoreModule; //Instance of the Modules Class + Info: TModuleInfo; //ModuleInfo returned by Modules Modulinfo Proc + NeedsDeInit: Boolean; //True if Module was succesful inited + end; + + TCore = class + private + //Some Hook Handles. See Plugin SDKs Hooks.txt for Infos + hLoadingFinished: THandle; + hMainLoop: THandle; + hLoadTextures: THandle; + hExitQuery: THandle; + hExit: THandle; + hDebug: THandle; + hError: THandle; + sgiveError: THandle; + sgiveDebug: THandle; + + Modules: Array [0..High(CORE_MODULES_TO_LOAD)] of TModuleListItem; + + //Function Get all Modules and Creates them + Function GetModules: Boolean; + + //Loads Core and all Modules + Function Load: Boolean; + + //Inits Core and all Modules + Function Init: Boolean; + + //DeInits Core and all Modules + Function DeInit: Boolean; + + //Load the Core + Function LoadCore: Boolean; + + //Init the Core + Function InitCore: Boolean; + + //DeInit the Core + Function DeInitCore: Boolean; + + //Called one Time per Frame + Function MainLoop: Boolean; + + public + Hooks: THookManager; //Teh Hook Manager ;) + Services: TServiceManager;//The Service Manager + + CurExecuted: Integer; //ID of Plugin or Module curently Executed + + Name: String; //Name of this Application + Version: LongWord; //Version of this ". For Info Look PluginDefs Functions + + //--------------- + //Main Methods to control the Core: + //--------------- + Constructor Create(const cName: String; const cVersion: LongWord); + + //Starts Loading and Init Process. Then Runs MainLoop. DeInits on Shutdown + Procedure Run; + + //-------------- + // Hook and Service Procs: + //-------------- + Function ShowMessage(wParam, lParam: DWord): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol) + Function ShowMessage(wParam, lParam: DWord): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol) + Function ShowMessage(wParam, lParam: DWord): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol) + end; + +var + Core: TCore; + +implementation +{$IFDEF win32} +uses Windows; +{$ENDIF} + +//------------- +// Create - Creates Class + Hook and Service Manager +//------------- +Constructor TCore.Create(const cName: String; const cVersion: LongWord); +begin + Name := cName; + Version := cVersion; + CurExecuted := 0; + + Hooks := THookManager.Create(50); + Services := TServiceManager.Create; +end; + +//------------- +//Starts Loading and Init Process. Then Runs MainLoop. DeInits on Shutdown +//------------- +Procedure TCore.Run; +var + noError: Boolean; +begin + //Get Modules + Try + noError := GetModules; + Except + noError := False; + end; + + //Loading + if (noError) then + begin + Try + noError := Load; + Except + noError := False; + end; + end + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar(''))); +end; + +//------------- +//Called one Time per Frame +//------------- +Function TCore.MainLoop: Boolean; +begin + Result := True; + +end; + +//------------- +//Function Get all Modules and Creates them +//------------- +Function TCore.GetModules: Boolean; +var + I: Integer; +begin + For I := 0 to high(Modules) do + begin + Modules[I].NeedsDeInit := False; + Modules[I].Module := CORE_MODULES_TO_LOAD[I].Create; + Modules[I].Module.Info(@Modules[I].Info); + end; +end; + +//------------- +//Loads Core and all Modules +//------------- +Function TCore.Load: Boolean; +var + I: Integer; +begin + Result := LoadCore; + + I := 0; + While ((Result = True) AND (I <= High(CORE_MODULES_TO_LOAD))) do + begin + Result := Modules[I].Module.Load; + Inc(I); + end; +end; + +//------------- +//Inits Core and all Modules +//------------- +Function TCore.Init: Boolean; +begin + Result := InitCore; + + I := 0; + While ((Result = True) AND (I <= High(CORE_MODULES_TO_LOAD))) do + begin + Result := Modules[I].Module.Init; + Inc(I); + end; +end; + +//------------- +//DeInits Core and all Modules +//------------- +Function TCore.DeInit: Boolean; + + label Continue; +begin + I := High(CORE_MODULES_TO_LOAD); + + Continue: + Try + While (I >= 0) do + begin + If (Modules[I].NeedsDeInit) then + Modules[I].Module.DeInit; + + Dec(I); + end; + Except + + GoTo Continue; + end; + + DeInitCore; +end; + +//------------- +//Load the Core +//------------- +Function TCore.LoadCore: Boolean; +begin + hLoadingFinished := Hooks.AddEvent('Core/LoadingFinished'); + hMainLoop := Hooks.AddEvent('Core/MainLoop'); + hLoadTextures := Hooks.AddEvent('Core/LoadTextures'); + hExitQuery := Hooks.AddEvent('Core/ExitQuery'); + hExit := Hooks.AddEvent('Core/Exit'); + hDebug := Hooks.AddEvent('Core/NewDebugInfo'); + hError := Hooks.AddEvent('Core/NewError'); + sReportError := Services.AddService('Core/ReportError'); + sReportDebug := Services.AddService('Core/ReportDebug'); +end; + +//------------- +//Init the Core +//------------- +Function TCore.InitCore: Boolean; +begin + //Dont Init s.th. atm. +end; + +//------------- +//DeInit the Core +//------------- +Function TCore.DeInitCore: Boolean; +begin + + + // to-do : write TService-/HookManager.Free and call it here +end; + +//------------- +//Shows a MessageDialog (lParam: PChar Text, wParam: Symbol) +//------------- +Function TCore.ShowMessage(wParam, lParam: DWord): integer; +var Params: Cardinal; +begin + Result := -1; + + {$IFDEF win32} + If (ptr(lParam)<>nil) then + begin + Params := MB_OK; + Case wParam of + CORE_SM_ERROR: Params := Params or MB_ICONERROR; + CORE_SM_WARNING: Params := Params or MB_ICONWARNING; + CORE_SM_INFO: Params := Params or MB_ICONINFORMATION; + end; + + //Anzeigen: + Result := Messagebox(0, ptr(lParam), PChar(Name), Params); + end; + {$ENDIF} + + // to-do : write ShowMessage for other OSes +end; + +end. \ No newline at end of file -- cgit v1.2.3 From 2f80e3be339f528bd0c7ef54db8ff7cc641883e3 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 10 Oct 2007 18:07:01 +0000 Subject: Fixed some Bugs from Previous Commit git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@498 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UCore.pas | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'Game/Code/Classes/UCore.pas') diff --git a/Game/Code/Classes/UCore.pas b/Game/Code/Classes/UCore.pas index 744fabe2..990ee7ab 100644 --- a/Game/Code/Classes/UCore.pas +++ b/Game/Code/Classes/UCore.pas @@ -31,8 +31,8 @@ type hExit: THandle; hDebug: THandle; hError: THandle; - sgiveError: THandle; - sgiveDebug: THandle; + sReportError: THandle; + sReportDebug: THandle; Modules: Array [0..High(CORE_MODULES_TO_LOAD)] of TModuleListItem; @@ -81,8 +81,8 @@ type // Hook and Service Procs: //-------------- Function ShowMessage(wParam, lParam: DWord): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol) - Function ShowMessage(wParam, lParam: DWord): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol) - Function ShowMessage(wParam, lParam: DWord): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol) + {Function ShowMessage(wParam, lParam: DWord): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol) + Function ShowMessage(wParam, lParam: DWord): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol)} end; var @@ -178,6 +178,8 @@ end; //Inits Core and all Modules //------------- Function TCore.Init: Boolean; +var + I: Integer; begin Result := InitCore; @@ -193,8 +195,9 @@ end; //DeInits Core and all Modules //------------- Function TCore.DeInit: Boolean; - - label Continue; +var + I: Integer; +label Continue; begin I := High(CORE_MODULES_TO_LOAD); @@ -209,8 +212,10 @@ begin end; Except - GoTo Continue; + end; + If (I >= 0) then + GoTo Continue; DeInitCore; end; -- cgit v1.2.3 From 4231c33ad7c7765fd3851c5c7168f8c7d367deef Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 16 Oct 2007 23:19:11 +0000 Subject: nearly finished Cores loading procs Add PluginLoader Unit to implent new PluginLoader Reordered Delphi .dpr uses clausel git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@519 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UCore.pas | 216 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 198 insertions(+), 18 deletions(-) (limited to 'Game/Code/Classes/UCore.pas') diff --git a/Game/Code/Classes/UCore.pas b/Game/Code/Classes/UCore.pas index 990ee7ab..de44fb3b 100644 --- a/Game/Code/Classes/UCore.pas +++ b/Game/Code/Classes/UCore.pas @@ -26,13 +26,18 @@ type //Some Hook Handles. See Plugin SDKs Hooks.txt for Infos hLoadingFinished: THandle; hMainLoop: THandle; + hTranslate: THandle; hLoadTextures: THandle; hExitQuery: THandle; hExit: THandle; hDebug: THandle; hError: THandle; - sReportError: THandle; - sReportDebug: THandle; + sReportError: THandle; + sReportDebug: THandle; + sShowMessage: THandle; + sRetranslate: THandle; + sReloadTextures: THandle; + sGetModuleInfo: THandle; Modules: Array [0..High(CORE_MODULES_TO_LOAD)] of TModuleListItem; @@ -69,6 +74,10 @@ type Name: String; //Name of this Application Version: LongWord; //Version of this ". For Info Look PluginDefs Functions + LastErrorReporter:String; //Who Reported the Last Error String + LastErrorString: String; //Last Error String reported + + //--------------- //Main Methods to control the Core: //--------------- @@ -81,17 +90,21 @@ type // Hook and Service Procs: //-------------- Function ShowMessage(wParam, lParam: DWord): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol) - {Function ShowMessage(wParam, lParam: DWord): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol) - Function ShowMessage(wParam, lParam: DWord): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol)} + Function ReportError(wParam, lParam: DWord): integer; //Shows a Message (wParam: Pchar(Message), lParam: PChar(Reportername)) + Function ReportDebug(wParam, lParam: DWord): integer; //Shows a Message (wParam: Pchar(Message), lParam: PChar(Reportername)) + Function Retranslate(wParam, lParam: DWord): integer; //Calls Translate hook + Function ReloadTextures(wParam, lParam: DWord): integer; //Calls LoadTextures hook + Function GetModuleInfo(wParam, lParam: DWord): integer; //If lParam = nil then get length of Moduleinfo Array. If lparam <> nil then write array of TModuleInfo to address at lparam end; var Core: TCore; implementation +uses SysUtils, {$IFDEF win32} -uses Windows; -{$ENDIF} +Windows +{$ENDIF}; //------------- // Create - Creates Class + Hook and Service Manager @@ -102,6 +115,9 @@ begin Version := cVersion; CurExecuted := 0; + LastErrorReporter := ''; + LastErrorString := ''; + Hooks := THookManager.Create(50); Services := TServiceManager.Create; end; @@ -128,9 +144,88 @@ begin Except noError := False; end; + + if (noError) then + begin //Init + Try + noError := Init; + Except + noError := False; + end; + + If noError then + begin + //Call Translate Hook + noError := (Hooks.CallEventChain(hTranslate, 0, 0) = 0); + + If noError then + begin //Calls LoadTextures Hook + noError := (Hooks.CallEventChain(hLoadTextures, 0, 0) = 0); + + if noError then + begin //Calls Loading Finished Hook + noError := (Hooks.CallEventChain(hLoadingFinished, 0, 0) = 0); + + If noError then + begin + //Start MainLoop + While noError do + begin + noError := MainLoop; + // to-do : Call Display Draw here + end; + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error calling LoadingFinished Hook: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error calling LoadingFinished Hook'))); + end; + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading textures: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading textures'))); + end; + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error translating: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error translating'))); + end; + + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error initing Modules: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error initing Modules'))); + end; + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading Modules: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading Modules'))); + end; end else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar(''))); + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error Getting Modules: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error Getting Modules'))); + end; + + //DeInit + DeInit; end; //------------- @@ -138,7 +233,7 @@ end; //------------- Function TCore.MainLoop: Boolean; begin - Result := True; + Result := False; end; @@ -149,11 +244,17 @@ Function TCore.GetModules: Boolean; var I: Integer; begin - For I := 0 to high(Modules) do - begin - Modules[I].NeedsDeInit := False; - Modules[I].Module := CORE_MODULES_TO_LOAD[I].Create; - Modules[I].Module.Info(@Modules[I].Info); + Result := False; + try + For I := 0 to high(Modules) do + begin + Modules[I].NeedsDeInit := False; + Modules[I].Module := CORE_MODULES_TO_LOAD[I].Create; + Modules[I].Module.Info(@Modules[I].Info); + end; + Result := True; + except + ReportError(Integer(PChar('Can''t get module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); end; end; @@ -169,7 +270,13 @@ begin I := 0; While ((Result = True) AND (I <= High(CORE_MODULES_TO_LOAD))) do begin - Result := Modules[I].Module.Load; + try + Result := Modules[I].Module.Load; + except + Result := False; + ReportError(Integer(PChar('Error loading module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); + end; + Inc(I); end; end; @@ -186,7 +293,14 @@ begin I := 0; While ((Result = True) AND (I <= High(CORE_MODULES_TO_LOAD))) do begin - Result := Modules[I].Module.Init; + try + Result := Modules[I].Module.Init; + except + Result := False; + ReportError(Integer(PChar('Error initing module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); + end; + + Modules[I].NeedsDeInit := Result; Inc(I); end; end; @@ -227,13 +341,19 @@ Function TCore.LoadCore: Boolean; begin hLoadingFinished := Hooks.AddEvent('Core/LoadingFinished'); hMainLoop := Hooks.AddEvent('Core/MainLoop'); + hTranslate := Hooks.AddEvent('Core/Translate'); hLoadTextures := Hooks.AddEvent('Core/LoadTextures'); hExitQuery := Hooks.AddEvent('Core/ExitQuery'); hExit := Hooks.AddEvent('Core/Exit'); hDebug := Hooks.AddEvent('Core/NewDebugInfo'); hError := Hooks.AddEvent('Core/NewError'); - sReportError := Services.AddService('Core/ReportError'); - sReportDebug := Services.AddService('Core/ReportDebug'); + + sReportError := Services.AddService('Core/ReportError', nil, Self.ReportError); + sReportDebug := Services.AddService('Core/ReportDebug', nil, Self.ReportDebug); + sShowMessage := Services.AddService('Core/ShowMessage', nil, Self.ShowMessage); + sRetranslate := Services.AddService('Core/Retranslate', nil, Self.Retranslate); + sReloadTextures := Services.AddService('Core/ReloadTextures', nil, Self.ReloadTextures); + sGetModuleInfo := Services.AddService('Core/GetModuleInfo', nil, Self.GetModuleInfo); end; //------------- @@ -255,7 +375,7 @@ begin end; //------------- -//Shows a MessageDialog (lParam: PChar Text, wParam: Symbol) +// Shows a MessageDialog (lParam: PChar Text, wParam: Symbol) //------------- Function TCore.ShowMessage(wParam, lParam: DWord): integer; var Params: Cardinal; @@ -280,4 +400,64 @@ begin // to-do : write ShowMessage for other OSes end; +//------------- +// Calls NewError HookChain (wParam: Pchar(Message), lParam: PChar(Reportername)) +//------------- +Function TCore.ReportError(wParam, lParam: DWord): integer; +begin + Hooks.CallEventChain(hError, wParam, lParam); + + //Update LastErrorReporter and LastErrorString + LastErrorReporter := String(PChar(Ptr(lParam))); + LastErrorString := String(PChar(Ptr(wParam))); +end; + +//------------- +// Calls NewDebugInfo HookChain (wParam: Pchar(Message), lParam: PChar(Reportername)) +//------------- +Function TCore.ReportDebug(wParam, lParam: DWord): integer; +begin + Hooks.CallEventChain(hDebug, wParam, lParam); +end; + +//------------- +// Calls Translate hook +//------------- +Function TCore.Retranslate(wParam, lParam: DWord): integer; +begin + Hooks.CallEventChain(hTranslate, 0, 1); +end; + +//------------- +// Calls LoadTextures hook +//------------- +Function TCore.ReloadTextures(wParam, lParam: DWord): integer; +begin + Hooks.CallEventChain(hLoadTextures, 0, 1); +end; + +//------------- +// If lParam = nil then get length of Moduleinfo Array. If lparam <> nil then write array of TModuleInfo to address at lparam +//------------- +Function TCore.GetModuleInfo(wParam, lParam: DWord): integer; +begin + if (ptr(lParam) = nil) then + begin + Result := Length(Modules); + end + else + begin + Try + For Result := 0 to High(Modules) do + begin + AModuleInfo(ptr(lParam))[Result].Name := Modules[Result].Info.Name; + AModuleInfo(ptr(lParam))[Result].Version := Modules[Result].Info.Version; + AModuleInfo(ptr(lParam))[Result].Description := Modules[Result].Info.Description; + end; + Except + Result := -1; + end; + end; +end; + end. \ No newline at end of file -- cgit v1.2.3 From e270d3193a2a5b958e6416ce340246e790f7bd86 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sat, 27 Oct 2007 09:10:29 +0000 Subject: Finished pluginloader, plugininterface Some fixes and error management (needs improvement) in Core and Service/Hook classes. "Clean Plugin Unloading on Error" finished Some debuging messages on startup. to Fix this remove old Plugins from Pluginfolder git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@535 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UCore.pas | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'Game/Code/Classes/UCore.pas') diff --git a/Game/Code/Classes/UCore.pas b/Game/Code/Classes/UCore.pas index de44fb3b..a8a29aeb 100644 --- a/Game/Code/Classes/UCore.pas +++ b/Game/Code/Classes/UCore.pas @@ -38,6 +38,7 @@ type sRetranslate: THandle; sReloadTextures: THandle; sGetModuleInfo: THandle; + sGetApplicationHandle: THandle; Modules: Array [0..High(CORE_MODULES_TO_LOAD)] of TModuleListItem; @@ -86,6 +87,9 @@ type //Starts Loading and Init Process. Then Runs MainLoop. DeInits on Shutdown Procedure Run; + //Method for other Classes to get Pointer to a specific Module + Function GetModulebyName(const Name: String): PCoreModule; + //-------------- // Hook and Service Procs: //-------------- @@ -95,6 +99,7 @@ type Function Retranslate(wParam, lParam: DWord): integer; //Calls Translate hook Function ReloadTextures(wParam, lParam: DWord): integer; //Calls LoadTextures hook Function GetModuleInfo(wParam, lParam: DWord): integer; //If lParam = nil then get length of Moduleinfo Array. If lparam <> nil then write array of TModuleInfo to address at lparam + Function GetApplicationHandle(wParam, lParam: DWord): integer; //Returns Application Handle end; var @@ -354,6 +359,10 @@ begin sRetranslate := Services.AddService('Core/Retranslate', nil, Self.Retranslate); sReloadTextures := Services.AddService('Core/ReloadTextures', nil, Self.ReloadTextures); sGetModuleInfo := Services.AddService('Core/GetModuleInfo', nil, Self.GetModuleInfo); + sGetApplicationHandle := Services.AddService('Core/GetApplicationHandle', nil, Self.GetApplicationHandle); + + //A little Test + Hooks.AddSubscriber('Core/NewError', HookTest); end; //------------- @@ -374,6 +383,21 @@ begin // to-do : write TService-/HookManager.Free and call it here end; +//------------- +//Method for other Classes to get Pointer to a specific Module +//------------- +Function TCore.GetModulebyName(const Name: String): PCoreModule; +var I: Integer; +begin + Result := nil; + For I := 0 to high(Modules) do + If (Modules[I].Info.Name = Name) then + begin + Result := @Modules[I].Module; + Break; + end; +end; + //------------- // Shows a MessageDialog (lParam: PChar Text, wParam: Symbol) //------------- @@ -405,11 +429,11 @@ end; //------------- Function TCore.ReportError(wParam, lParam: DWord): integer; begin - Hooks.CallEventChain(hError, wParam, lParam); - //Update LastErrorReporter and LastErrorString LastErrorReporter := String(PChar(Ptr(lParam))); LastErrorString := String(PChar(Ptr(wParam))); + + Hooks.CallEventChain(hError, wParam, lParam); end; //------------- @@ -460,4 +484,12 @@ begin end; end; +//------------- +// Returns Application Handle +//------------- +Function TCore.GetApplicationHandle(wParam, lParam: DWord): integer; +begin + Result := hInstance; +end; + end. \ No newline at end of file -- cgit v1.2.3 From 5802c7be05f25e5da3a991377942c00ee7d95639 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sat, 27 Oct 2007 09:36:49 +0000 Subject: try to fix build errors git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@537 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UCore.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Game/Code/Classes/UCore.pas') diff --git a/Game/Code/Classes/UCore.pas b/Game/Code/Classes/UCore.pas index a8a29aeb..9c31e79a 100644 --- a/Game/Code/Classes/UCore.pas +++ b/Game/Code/Classes/UCore.pas @@ -1,7 +1,7 @@ unit UCore; interface -uses uPluginDefs, uCoreModule, UHooks, UServices, uModules; +uses uPluginDefs, uCoreModule, UHooks, UServices, UModules; {********************* TCore Class manages all CoreModules, teh StartUp, teh MainLoop and the shutdown process -- cgit v1.2.3 From 391d30716d48dc709f6444b19c008e82311623b9 Mon Sep 17 00:00:00 2001 From: eddie-0815 Date: Thu, 1 Nov 2007 19:34:40 +0000 Subject: Mac OS X version compiles and links. I hope I didn't break too many files on windows/linux. Added switches.inc to all files. Changed many IFDEFs. For Windows-only code please use MSWINDOWS instead of WIN32 now. WIN32 is also used by the Mac port. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@546 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UCore.pas | 985 ++++++++++++++++++++++---------------------- 1 file changed, 491 insertions(+), 494 deletions(-) (limited to 'Game/Code/Classes/UCore.pas') diff --git a/Game/Code/Classes/UCore.pas b/Game/Code/Classes/UCore.pas index 9c31e79a..091868f2 100644 --- a/Game/Code/Classes/UCore.pas +++ b/Game/Code/Classes/UCore.pas @@ -1,495 +1,492 @@ -unit UCore; - -interface -uses uPluginDefs, uCoreModule, UHooks, UServices, UModules; -{********************* - TCore - Class manages all CoreModules, teh StartUp, teh MainLoop and the shutdown process - Also it does some Error Handling, and maybe sometime multithreaded Loading ;) -*********************} - -{$IFDEF FPC} - {$MODE Delphi} -{$ENDIF} - -{$I switches.inc} - -type - TModuleListItem = record - Module: TCoreModule; //Instance of the Modules Class - Info: TModuleInfo; //ModuleInfo returned by Modules Modulinfo Proc - NeedsDeInit: Boolean; //True if Module was succesful inited - end; - - TCore = class - private - //Some Hook Handles. See Plugin SDKs Hooks.txt for Infos - hLoadingFinished: THandle; - hMainLoop: THandle; - hTranslate: THandle; - hLoadTextures: THandle; - hExitQuery: THandle; - hExit: THandle; - hDebug: THandle; - hError: THandle; - sReportError: THandle; - sReportDebug: THandle; - sShowMessage: THandle; - sRetranslate: THandle; - sReloadTextures: THandle; - sGetModuleInfo: THandle; - sGetApplicationHandle: THandle; - - Modules: Array [0..High(CORE_MODULES_TO_LOAD)] of TModuleListItem; - - //Function Get all Modules and Creates them - Function GetModules: Boolean; - - //Loads Core and all Modules - Function Load: Boolean; - - //Inits Core and all Modules - Function Init: Boolean; - - //DeInits Core and all Modules - Function DeInit: Boolean; - - //Load the Core - Function LoadCore: Boolean; - - //Init the Core - Function InitCore: Boolean; - - //DeInit the Core - Function DeInitCore: Boolean; - - //Called one Time per Frame - Function MainLoop: Boolean; - - public - Hooks: THookManager; //Teh Hook Manager ;) - Services: TServiceManager;//The Service Manager - - CurExecuted: Integer; //ID of Plugin or Module curently Executed - - Name: String; //Name of this Application - Version: LongWord; //Version of this ". For Info Look PluginDefs Functions - - LastErrorReporter:String; //Who Reported the Last Error String - LastErrorString: String; //Last Error String reported - - - //--------------- - //Main Methods to control the Core: - //--------------- - Constructor Create(const cName: String; const cVersion: LongWord); - - //Starts Loading and Init Process. Then Runs MainLoop. DeInits on Shutdown - Procedure Run; - - //Method for other Classes to get Pointer to a specific Module - Function GetModulebyName(const Name: String): PCoreModule; - - //-------------- - // Hook and Service Procs: - //-------------- - Function ShowMessage(wParam, lParam: DWord): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol) - Function ReportError(wParam, lParam: DWord): integer; //Shows a Message (wParam: Pchar(Message), lParam: PChar(Reportername)) - Function ReportDebug(wParam, lParam: DWord): integer; //Shows a Message (wParam: Pchar(Message), lParam: PChar(Reportername)) - Function Retranslate(wParam, lParam: DWord): integer; //Calls Translate hook - Function ReloadTextures(wParam, lParam: DWord): integer; //Calls LoadTextures hook - Function GetModuleInfo(wParam, lParam: DWord): integer; //If lParam = nil then get length of Moduleinfo Array. If lparam <> nil then write array of TModuleInfo to address at lparam - Function GetApplicationHandle(wParam, lParam: DWord): integer; //Returns Application Handle - end; - -var - Core: TCore; - -implementation -uses SysUtils, -{$IFDEF win32} -Windows -{$ENDIF}; - -//------------- -// Create - Creates Class + Hook and Service Manager -//------------- -Constructor TCore.Create(const cName: String; const cVersion: LongWord); -begin - Name := cName; - Version := cVersion; - CurExecuted := 0; - - LastErrorReporter := ''; - LastErrorString := ''; - - Hooks := THookManager.Create(50); - Services := TServiceManager.Create; -end; - -//------------- -//Starts Loading and Init Process. Then Runs MainLoop. DeInits on Shutdown -//------------- -Procedure TCore.Run; -var - noError: Boolean; -begin - //Get Modules - Try - noError := GetModules; - Except - noError := False; - end; - - //Loading - if (noError) then - begin - Try - noError := Load; - Except - noError := False; - end; - - if (noError) then - begin //Init - Try - noError := Init; - Except - noError := False; - end; - - If noError then - begin - //Call Translate Hook - noError := (Hooks.CallEventChain(hTranslate, 0, 0) = 0); - - If noError then - begin //Calls LoadTextures Hook - noError := (Hooks.CallEventChain(hLoadTextures, 0, 0) = 0); - - if noError then - begin //Calls Loading Finished Hook - noError := (Hooks.CallEventChain(hLoadingFinished, 0, 0) = 0); - - If noError then - begin - //Start MainLoop - While noError do - begin - noError := MainLoop; - // to-do : Call Display Draw here - end; - end - else - begin - If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error calling LoadingFinished Hook: ' + LastErrorString))) - else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error calling LoadingFinished Hook'))); - end; - end - else - begin - If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading textures: ' + LastErrorString))) - else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading textures'))); - end; - end - else - begin - If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error translating: ' + LastErrorString))) - else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error translating'))); - end; - - end - else - begin - If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error initing Modules: ' + LastErrorString))) - else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error initing Modules'))); - end; - end - else - begin - If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading Modules: ' + LastErrorString))) - else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading Modules'))); - end; - end - else - begin - If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error Getting Modules: ' + LastErrorString))) - else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error Getting Modules'))); - end; - - //DeInit - DeInit; -end; - -//------------- -//Called one Time per Frame -//------------- -Function TCore.MainLoop: Boolean; -begin - Result := False; - -end; - -//------------- -//Function Get all Modules and Creates them -//------------- -Function TCore.GetModules: Boolean; -var - I: Integer; -begin - Result := False; - try - For I := 0 to high(Modules) do - begin - Modules[I].NeedsDeInit := False; - Modules[I].Module := CORE_MODULES_TO_LOAD[I].Create; - Modules[I].Module.Info(@Modules[I].Info); - end; - Result := True; - except - ReportError(Integer(PChar('Can''t get module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); - end; -end; - -//------------- -//Loads Core and all Modules -//------------- -Function TCore.Load: Boolean; -var - I: Integer; -begin - Result := LoadCore; - - I := 0; - While ((Result = True) AND (I <= High(CORE_MODULES_TO_LOAD))) do - begin - try - Result := Modules[I].Module.Load; - except - Result := False; - ReportError(Integer(PChar('Error loading module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); - end; - - Inc(I); - end; -end; - -//------------- -//Inits Core and all Modules -//------------- -Function TCore.Init: Boolean; -var - I: Integer; -begin - Result := InitCore; - - I := 0; - While ((Result = True) AND (I <= High(CORE_MODULES_TO_LOAD))) do - begin - try - Result := Modules[I].Module.Init; - except - Result := False; - ReportError(Integer(PChar('Error initing module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); - end; - - Modules[I].NeedsDeInit := Result; - Inc(I); - end; -end; - -//------------- -//DeInits Core and all Modules -//------------- -Function TCore.DeInit: Boolean; -var - I: Integer; -label Continue; -begin - I := High(CORE_MODULES_TO_LOAD); - - Continue: - Try - While (I >= 0) do - begin - If (Modules[I].NeedsDeInit) then - Modules[I].Module.DeInit; - - Dec(I); - end; - Except - - - end; - If (I >= 0) then - GoTo Continue; - - DeInitCore; -end; - -//------------- -//Load the Core -//------------- -Function TCore.LoadCore: Boolean; -begin - hLoadingFinished := Hooks.AddEvent('Core/LoadingFinished'); - hMainLoop := Hooks.AddEvent('Core/MainLoop'); - hTranslate := Hooks.AddEvent('Core/Translate'); - hLoadTextures := Hooks.AddEvent('Core/LoadTextures'); - hExitQuery := Hooks.AddEvent('Core/ExitQuery'); - hExit := Hooks.AddEvent('Core/Exit'); - hDebug := Hooks.AddEvent('Core/NewDebugInfo'); - hError := Hooks.AddEvent('Core/NewError'); - - sReportError := Services.AddService('Core/ReportError', nil, Self.ReportError); - sReportDebug := Services.AddService('Core/ReportDebug', nil, Self.ReportDebug); - sShowMessage := Services.AddService('Core/ShowMessage', nil, Self.ShowMessage); - sRetranslate := Services.AddService('Core/Retranslate', nil, Self.Retranslate); - sReloadTextures := Services.AddService('Core/ReloadTextures', nil, Self.ReloadTextures); - sGetModuleInfo := Services.AddService('Core/GetModuleInfo', nil, Self.GetModuleInfo); - sGetApplicationHandle := Services.AddService('Core/GetApplicationHandle', nil, Self.GetApplicationHandle); - - //A little Test - Hooks.AddSubscriber('Core/NewError', HookTest); -end; - -//------------- -//Init the Core -//------------- -Function TCore.InitCore: Boolean; -begin - //Dont Init s.th. atm. -end; - -//------------- -//DeInit the Core -//------------- -Function TCore.DeInitCore: Boolean; -begin - - - // to-do : write TService-/HookManager.Free and call it here -end; - -//------------- -//Method for other Classes to get Pointer to a specific Module -//------------- -Function TCore.GetModulebyName(const Name: String): PCoreModule; -var I: Integer; -begin - Result := nil; - For I := 0 to high(Modules) do - If (Modules[I].Info.Name = Name) then - begin - Result := @Modules[I].Module; - Break; - end; -end; - -//------------- -// Shows a MessageDialog (lParam: PChar Text, wParam: Symbol) -//------------- -Function TCore.ShowMessage(wParam, lParam: DWord): integer; -var Params: Cardinal; -begin - Result := -1; - - {$IFDEF win32} - If (ptr(lParam)<>nil) then - begin - Params := MB_OK; - Case wParam of - CORE_SM_ERROR: Params := Params or MB_ICONERROR; - CORE_SM_WARNING: Params := Params or MB_ICONWARNING; - CORE_SM_INFO: Params := Params or MB_ICONINFORMATION; - end; - - //Anzeigen: - Result := Messagebox(0, ptr(lParam), PChar(Name), Params); - end; - {$ENDIF} - - // to-do : write ShowMessage for other OSes -end; - -//------------- -// Calls NewError HookChain (wParam: Pchar(Message), lParam: PChar(Reportername)) -//------------- -Function TCore.ReportError(wParam, lParam: DWord): integer; -begin - //Update LastErrorReporter and LastErrorString - LastErrorReporter := String(PChar(Ptr(lParam))); - LastErrorString := String(PChar(Ptr(wParam))); - - Hooks.CallEventChain(hError, wParam, lParam); -end; - -//------------- -// Calls NewDebugInfo HookChain (wParam: Pchar(Message), lParam: PChar(Reportername)) -//------------- -Function TCore.ReportDebug(wParam, lParam: DWord): integer; -begin - Hooks.CallEventChain(hDebug, wParam, lParam); -end; - -//------------- -// Calls Translate hook -//------------- -Function TCore.Retranslate(wParam, lParam: DWord): integer; -begin - Hooks.CallEventChain(hTranslate, 0, 1); -end; - -//------------- -// Calls LoadTextures hook -//------------- -Function TCore.ReloadTextures(wParam, lParam: DWord): integer; -begin - Hooks.CallEventChain(hLoadTextures, 0, 1); -end; - -//------------- -// If lParam = nil then get length of Moduleinfo Array. If lparam <> nil then write array of TModuleInfo to address at lparam -//------------- -Function TCore.GetModuleInfo(wParam, lParam: DWord): integer; -begin - if (ptr(lParam) = nil) then - begin - Result := Length(Modules); - end - else - begin - Try - For Result := 0 to High(Modules) do - begin - AModuleInfo(ptr(lParam))[Result].Name := Modules[Result].Info.Name; - AModuleInfo(ptr(lParam))[Result].Version := Modules[Result].Info.Version; - AModuleInfo(ptr(lParam))[Result].Description := Modules[Result].Info.Description; - end; - Except - Result := -1; - end; - end; -end; - -//------------- -// Returns Application Handle -//------------- -Function TCore.GetApplicationHandle(wParam, lParam: DWord): integer; -begin - Result := hInstance; -end; - +unit UCore; + +interface + +{$I switches.inc} + +uses uPluginDefs, uCoreModule, UHooks, UServices, UModules; +{********************* + TCore + Class manages all CoreModules, teh StartUp, teh MainLoop and the shutdown process + Also it does some Error Handling, and maybe sometime multithreaded Loading ;) +*********************} + +type + TModuleListItem = record + Module: TCoreModule; //Instance of the Modules Class + Info: TModuleInfo; //ModuleInfo returned by Modules Modulinfo Proc + NeedsDeInit: Boolean; //True if Module was succesful inited + end; + + TCore = class + private + //Some Hook Handles. See Plugin SDKs Hooks.txt for Infos + hLoadingFinished: THandle; + hMainLoop: THandle; + hTranslate: THandle; + hLoadTextures: THandle; + hExitQuery: THandle; + hExit: THandle; + hDebug: THandle; + hError: THandle; + sReportError: THandle; + sReportDebug: THandle; + sShowMessage: THandle; + sRetranslate: THandle; + sReloadTextures: THandle; + sGetModuleInfo: THandle; + sGetApplicationHandle: THandle; + + Modules: Array [0..High(CORE_MODULES_TO_LOAD)] of TModuleListItem; + + //Function Get all Modules and Creates them + Function GetModules: Boolean; + + //Loads Core and all Modules + Function Load: Boolean; + + //Inits Core and all Modules + Function Init: Boolean; + + //DeInits Core and all Modules + Function DeInit: Boolean; + + //Load the Core + Function LoadCore: Boolean; + + //Init the Core + Function InitCore: Boolean; + + //DeInit the Core + Function DeInitCore: Boolean; + + //Called one Time per Frame + Function MainLoop: Boolean; + + public + Hooks: THookManager; //Teh Hook Manager ;) + Services: TServiceManager;//The Service Manager + + CurExecuted: Integer; //ID of Plugin or Module curently Executed + + Name: String; //Name of this Application + Version: LongWord; //Version of this ". For Info Look PluginDefs Functions + + LastErrorReporter:String; //Who Reported the Last Error String + LastErrorString: String; //Last Error String reported + + + //--------------- + //Main Methods to control the Core: + //--------------- + Constructor Create(const cName: String; const cVersion: LongWord); + + //Starts Loading and Init Process. Then Runs MainLoop. DeInits on Shutdown + Procedure Run; + + //Method for other Classes to get Pointer to a specific Module + Function GetModulebyName(const Name: String): PCoreModule; + + //-------------- + // Hook and Service Procs: + //-------------- + Function ShowMessage(wParam, lParam: DWord): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol) + Function ReportError(wParam, lParam: DWord): integer; //Shows a Message (wParam: Pchar(Message), lParam: PChar(Reportername)) + Function ReportDebug(wParam, lParam: DWord): integer; //Shows a Message (wParam: Pchar(Message), lParam: PChar(Reportername)) + Function Retranslate(wParam, lParam: DWord): integer; //Calls Translate hook + Function ReloadTextures(wParam, lParam: DWord): integer; //Calls LoadTextures hook + Function GetModuleInfo(wParam, lParam: DWord): integer; //If lParam = nil then get length of Moduleinfo Array. If lparam <> nil then write array of TModuleInfo to address at lparam + Function GetApplicationHandle(wParam, lParam: DWord): integer; //Returns Application Handle + end; + +var + Core: TCore; + +implementation +uses SysUtils, +{$IFDEF win32} +Windows +{$ENDIF}; + +//------------- +// Create - Creates Class + Hook and Service Manager +//------------- +Constructor TCore.Create(const cName: String; const cVersion: LongWord); +begin + Name := cName; + Version := cVersion; + CurExecuted := 0; + + LastErrorReporter := ''; + LastErrorString := ''; + + Hooks := THookManager.Create(50); + Services := TServiceManager.Create; +end; + +//------------- +//Starts Loading and Init Process. Then Runs MainLoop. DeInits on Shutdown +//------------- +Procedure TCore.Run; +var + noError: Boolean; +begin + //Get Modules + Try + noError := GetModules; + Except + noError := False; + end; + + //Loading + if (noError) then + begin + Try + noError := Load; + Except + noError := False; + end; + + if (noError) then + begin //Init + Try + noError := Init; + Except + noError := False; + end; + + If noError then + begin + //Call Translate Hook + noError := (Hooks.CallEventChain(hTranslate, 0, 0) = 0); + + If noError then + begin //Calls LoadTextures Hook + noError := (Hooks.CallEventChain(hLoadTextures, 0, 0) = 0); + + if noError then + begin //Calls Loading Finished Hook + noError := (Hooks.CallEventChain(hLoadingFinished, 0, 0) = 0); + + If noError then + begin + //Start MainLoop + While noError do + begin + noError := MainLoop; + // to-do : Call Display Draw here + end; + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error calling LoadingFinished Hook: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error calling LoadingFinished Hook'))); + end; + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading textures: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading textures'))); + end; + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error translating: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error translating'))); + end; + + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error initing Modules: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error initing Modules'))); + end; + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading Modules: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading Modules'))); + end; + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error Getting Modules: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error Getting Modules'))); + end; + + //DeInit + DeInit; +end; + +//------------- +//Called one Time per Frame +//------------- +Function TCore.MainLoop: Boolean; +begin + Result := False; + +end; + +//------------- +//Function Get all Modules and Creates them +//------------- +Function TCore.GetModules: Boolean; +var + I: Integer; +begin + Result := False; + try + For I := 0 to high(Modules) do + begin + Modules[I].NeedsDeInit := False; + Modules[I].Module := CORE_MODULES_TO_LOAD[I].Create; + Modules[I].Module.Info(@Modules[I].Info); + end; + Result := True; + except + ReportError(Integer(PChar('Can''t get module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); + end; +end; + +//------------- +//Loads Core and all Modules +//------------- +Function TCore.Load: Boolean; +var + I: Integer; +begin + Result := LoadCore; + + I := 0; + While ((Result = True) AND (I <= High(CORE_MODULES_TO_LOAD))) do + begin + try + Result := Modules[I].Module.Load; + except + Result := False; + ReportError(Integer(PChar('Error loading module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); + end; + + Inc(I); + end; +end; + +//------------- +//Inits Core and all Modules +//------------- +Function TCore.Init: Boolean; +var + I: Integer; +begin + Result := InitCore; + + I := 0; + While ((Result = True) AND (I <= High(CORE_MODULES_TO_LOAD))) do + begin + try + Result := Modules[I].Module.Init; + except + Result := False; + ReportError(Integer(PChar('Error initing module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); + end; + + Modules[I].NeedsDeInit := Result; + Inc(I); + end; +end; + +//------------- +//DeInits Core and all Modules +//------------- +Function TCore.DeInit: Boolean; +var + I: Integer; +label Continue; +begin + I := High(CORE_MODULES_TO_LOAD); + + Continue: + Try + While (I >= 0) do + begin + If (Modules[I].NeedsDeInit) then + Modules[I].Module.DeInit; + + Dec(I); + end; + Except + + + end; + If (I >= 0) then + GoTo Continue; + + DeInitCore; +end; + +//------------- +//Load the Core +//------------- +Function TCore.LoadCore: Boolean; +begin + hLoadingFinished := Hooks.AddEvent('Core/LoadingFinished'); + hMainLoop := Hooks.AddEvent('Core/MainLoop'); + hTranslate := Hooks.AddEvent('Core/Translate'); + hLoadTextures := Hooks.AddEvent('Core/LoadTextures'); + hExitQuery := Hooks.AddEvent('Core/ExitQuery'); + hExit := Hooks.AddEvent('Core/Exit'); + hDebug := Hooks.AddEvent('Core/NewDebugInfo'); + hError := Hooks.AddEvent('Core/NewError'); + + sReportError := Services.AddService('Core/ReportError', nil, Self.ReportError); + sReportDebug := Services.AddService('Core/ReportDebug', nil, Self.ReportDebug); + sShowMessage := Services.AddService('Core/ShowMessage', nil, Self.ShowMessage); + sRetranslate := Services.AddService('Core/Retranslate', nil, Self.Retranslate); + sReloadTextures := Services.AddService('Core/ReloadTextures', nil, Self.ReloadTextures); + sGetModuleInfo := Services.AddService('Core/GetModuleInfo', nil, Self.GetModuleInfo); + sGetApplicationHandle := Services.AddService('Core/GetApplicationHandle', nil, Self.GetApplicationHandle); + + //A little Test + Hooks.AddSubscriber('Core/NewError', HookTest); +end; + +//------------- +//Init the Core +//------------- +Function TCore.InitCore: Boolean; +begin + //Dont Init s.th. atm. +end; + +//------------- +//DeInit the Core +//------------- +Function TCore.DeInitCore: Boolean; +begin + + + // to-do : write TService-/HookManager.Free and call it here +end; + +//------------- +//Method for other Classes to get Pointer to a specific Module +//------------- +Function TCore.GetModulebyName(const Name: String): PCoreModule; +var I: Integer; +begin + Result := nil; + For I := 0 to high(Modules) do + If (Modules[I].Info.Name = Name) then + begin + Result := @Modules[I].Module; + Break; + end; +end; + +//------------- +// Shows a MessageDialog (lParam: PChar Text, wParam: Symbol) +//------------- +Function TCore.ShowMessage(wParam, lParam: DWord): integer; +var Params: Cardinal; +begin + Result := -1; + + {$IFDEF MSWINDOWS} + If (ptr(lParam)<>nil) then + begin + Params := MB_OK; + Case wParam of + CORE_SM_ERROR: Params := Params or MB_ICONERROR; + CORE_SM_WARNING: Params := Params or MB_ICONWARNING; + CORE_SM_INFO: Params := Params or MB_ICONINFORMATION; + end; + + //Anzeigen: + Result := Messagebox(0, ptr(lParam), PChar(Name), Params); + end; + {$ENDIF} + + // to-do : write ShowMessage for other OSes +end; + +//------------- +// Calls NewError HookChain (wParam: Pchar(Message), lParam: PChar(Reportername)) +//------------- +Function TCore.ReportError(wParam, lParam: DWord): integer; +begin + //Update LastErrorReporter and LastErrorString + LastErrorReporter := String(PChar(Pointer(lParam))); + LastErrorString := String(PChar(Pointer(wParam))); + + Hooks.CallEventChain(hError, wParam, lParam); +end; + +//------------- +// Calls NewDebugInfo HookChain (wParam: Pchar(Message), lParam: PChar(Reportername)) +//------------- +Function TCore.ReportDebug(wParam, lParam: DWord): integer; +begin + Hooks.CallEventChain(hDebug, wParam, lParam); +end; + +//------------- +// Calls Translate hook +//------------- +Function TCore.Retranslate(wParam, lParam: DWord): integer; +begin + Hooks.CallEventChain(hTranslate, 0, 1); +end; + +//------------- +// Calls LoadTextures hook +//------------- +Function TCore.ReloadTextures(wParam, lParam: DWord): integer; +begin + Hooks.CallEventChain(hLoadTextures, 0, 1); +end; + +//------------- +// If lParam = nil then get length of Moduleinfo Array. If lparam <> nil then write array of TModuleInfo to address at lparam +//------------- +Function TCore.GetModuleInfo(wParam, lParam: DWord): integer; +begin + if (Pointer(lParam) = nil) then + begin + Result := Length(Modules); + end + else + begin + Try + For Result := 0 to High(Modules) do + begin + AModuleInfo(Pointer(lParam))[Result].Name := Modules[Result].Info.Name; + AModuleInfo(Pointer(lParam))[Result].Version := Modules[Result].Info.Version; + AModuleInfo(Pointer(lParam))[Result].Description := Modules[Result].Info.Description; + end; + Except + Result := -1; + end; + end; +end; + +//------------- +// Returns Application Handle +//------------- +Function TCore.GetApplicationHandle(wParam, lParam: DWord): integer; +begin + Result := hInstance; +end; + end. \ No newline at end of file -- cgit v1.2.3 From 99955c78f63d1cb0d8bec666bc33953590a74c8a Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 1 Nov 2007 23:22:01 +0000 Subject: fixed failed builds build:USDX-LAZLIN-75 build:USDX-LAZLIN-76 for some reason we can not use {$MODE Delphi} in an included file. ( Probably because of the way the compier scopes this switch to each pas file ) ive had to revert this part of eddies changes. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@548 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UCore.pas | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'Game/Code/Classes/UCore.pas') diff --git a/Game/Code/Classes/UCore.pas b/Game/Code/Classes/UCore.pas index 091868f2..acd9ead7 100644 --- a/Game/Code/Classes/UCore.pas +++ b/Game/Code/Classes/UCore.pas @@ -2,9 +2,17 @@ unit UCore; interface +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + {$I switches.inc} -uses uPluginDefs, uCoreModule, UHooks, UServices, UModules; +uses uPluginDefs, + uCoreModule, + UHooks, + UServices, + UModules; {********************* TCore Class manages all CoreModules, teh StartUp, teh MainLoop and the shutdown process @@ -103,10 +111,11 @@ var Core: TCore; implementation -uses SysUtils, -{$IFDEF win32} -Windows -{$ENDIF}; + +uses {$IFDEF win32} + Windows, + {$ENDIF} + SysUtils; //------------- // Create - Creates Class + Hook and Service Manager @@ -489,4 +498,4 @@ begin Result := hInstance; end; -end. \ No newline at end of file +end. -- cgit v1.2.3 From 8c9c787a1326b90490543bd50b56fce9b89d9807 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Sat, 3 Nov 2007 02:31:06 +0000 Subject: Windows Lazarus Build working again... Lazarus Project file includes the DPR, so that we have a unified Uses Clause ( keep this in mind please ) added "Delphi" to switches git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@560 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UCore.pas | 1002 +++++++++++++++++++++---------------------- 1 file changed, 501 insertions(+), 501 deletions(-) (limited to 'Game/Code/Classes/UCore.pas') diff --git a/Game/Code/Classes/UCore.pas b/Game/Code/Classes/UCore.pas index acd9ead7..e0f9fec2 100644 --- a/Game/Code/Classes/UCore.pas +++ b/Game/Code/Classes/UCore.pas @@ -1,501 +1,501 @@ -unit UCore; - -interface - -{$IFDEF FPC} - {$MODE Delphi} -{$ENDIF} - -{$I switches.inc} - -uses uPluginDefs, - uCoreModule, - UHooks, - UServices, - UModules; -{********************* - TCore - Class manages all CoreModules, teh StartUp, teh MainLoop and the shutdown process - Also it does some Error Handling, and maybe sometime multithreaded Loading ;) -*********************} - -type - TModuleListItem = record - Module: TCoreModule; //Instance of the Modules Class - Info: TModuleInfo; //ModuleInfo returned by Modules Modulinfo Proc - NeedsDeInit: Boolean; //True if Module was succesful inited - end; - - TCore = class - private - //Some Hook Handles. See Plugin SDKs Hooks.txt for Infos - hLoadingFinished: THandle; - hMainLoop: THandle; - hTranslate: THandle; - hLoadTextures: THandle; - hExitQuery: THandle; - hExit: THandle; - hDebug: THandle; - hError: THandle; - sReportError: THandle; - sReportDebug: THandle; - sShowMessage: THandle; - sRetranslate: THandle; - sReloadTextures: THandle; - sGetModuleInfo: THandle; - sGetApplicationHandle: THandle; - - Modules: Array [0..High(CORE_MODULES_TO_LOAD)] of TModuleListItem; - - //Function Get all Modules and Creates them - Function GetModules: Boolean; - - //Loads Core and all Modules - Function Load: Boolean; - - //Inits Core and all Modules - Function Init: Boolean; - - //DeInits Core and all Modules - Function DeInit: Boolean; - - //Load the Core - Function LoadCore: Boolean; - - //Init the Core - Function InitCore: Boolean; - - //DeInit the Core - Function DeInitCore: Boolean; - - //Called one Time per Frame - Function MainLoop: Boolean; - - public - Hooks: THookManager; //Teh Hook Manager ;) - Services: TServiceManager;//The Service Manager - - CurExecuted: Integer; //ID of Plugin or Module curently Executed - - Name: String; //Name of this Application - Version: LongWord; //Version of this ". For Info Look PluginDefs Functions - - LastErrorReporter:String; //Who Reported the Last Error String - LastErrorString: String; //Last Error String reported - - - //--------------- - //Main Methods to control the Core: - //--------------- - Constructor Create(const cName: String; const cVersion: LongWord); - - //Starts Loading and Init Process. Then Runs MainLoop. DeInits on Shutdown - Procedure Run; - - //Method for other Classes to get Pointer to a specific Module - Function GetModulebyName(const Name: String): PCoreModule; - - //-------------- - // Hook and Service Procs: - //-------------- - Function ShowMessage(wParam, lParam: DWord): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol) - Function ReportError(wParam, lParam: DWord): integer; //Shows a Message (wParam: Pchar(Message), lParam: PChar(Reportername)) - Function ReportDebug(wParam, lParam: DWord): integer; //Shows a Message (wParam: Pchar(Message), lParam: PChar(Reportername)) - Function Retranslate(wParam, lParam: DWord): integer; //Calls Translate hook - Function ReloadTextures(wParam, lParam: DWord): integer; //Calls LoadTextures hook - Function GetModuleInfo(wParam, lParam: DWord): integer; //If lParam = nil then get length of Moduleinfo Array. If lparam <> nil then write array of TModuleInfo to address at lparam - Function GetApplicationHandle(wParam, lParam: DWord): integer; //Returns Application Handle - end; - -var - Core: TCore; - -implementation - -uses {$IFDEF win32} - Windows, - {$ENDIF} - SysUtils; - -//------------- -// Create - Creates Class + Hook and Service Manager -//------------- -Constructor TCore.Create(const cName: String; const cVersion: LongWord); -begin - Name := cName; - Version := cVersion; - CurExecuted := 0; - - LastErrorReporter := ''; - LastErrorString := ''; - - Hooks := THookManager.Create(50); - Services := TServiceManager.Create; -end; - -//------------- -//Starts Loading and Init Process. Then Runs MainLoop. DeInits on Shutdown -//------------- -Procedure TCore.Run; -var - noError: Boolean; -begin - //Get Modules - Try - noError := GetModules; - Except - noError := False; - end; - - //Loading - if (noError) then - begin - Try - noError := Load; - Except - noError := False; - end; - - if (noError) then - begin //Init - Try - noError := Init; - Except - noError := False; - end; - - If noError then - begin - //Call Translate Hook - noError := (Hooks.CallEventChain(hTranslate, 0, 0) = 0); - - If noError then - begin //Calls LoadTextures Hook - noError := (Hooks.CallEventChain(hLoadTextures, 0, 0) = 0); - - if noError then - begin //Calls Loading Finished Hook - noError := (Hooks.CallEventChain(hLoadingFinished, 0, 0) = 0); - - If noError then - begin - //Start MainLoop - While noError do - begin - noError := MainLoop; - // to-do : Call Display Draw here - end; - end - else - begin - If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error calling LoadingFinished Hook: ' + LastErrorString))) - else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error calling LoadingFinished Hook'))); - end; - end - else - begin - If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading textures: ' + LastErrorString))) - else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading textures'))); - end; - end - else - begin - If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error translating: ' + LastErrorString))) - else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error translating'))); - end; - - end - else - begin - If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error initing Modules: ' + LastErrorString))) - else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error initing Modules'))); - end; - end - else - begin - If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading Modules: ' + LastErrorString))) - else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading Modules'))); - end; - end - else - begin - If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error Getting Modules: ' + LastErrorString))) - else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error Getting Modules'))); - end; - - //DeInit - DeInit; -end; - -//------------- -//Called one Time per Frame -//------------- -Function TCore.MainLoop: Boolean; -begin - Result := False; - -end; - -//------------- -//Function Get all Modules and Creates them -//------------- -Function TCore.GetModules: Boolean; -var - I: Integer; -begin - Result := False; - try - For I := 0 to high(Modules) do - begin - Modules[I].NeedsDeInit := False; - Modules[I].Module := CORE_MODULES_TO_LOAD[I].Create; - Modules[I].Module.Info(@Modules[I].Info); - end; - Result := True; - except - ReportError(Integer(PChar('Can''t get module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); - end; -end; - -//------------- -//Loads Core and all Modules -//------------- -Function TCore.Load: Boolean; -var - I: Integer; -begin - Result := LoadCore; - - I := 0; - While ((Result = True) AND (I <= High(CORE_MODULES_TO_LOAD))) do - begin - try - Result := Modules[I].Module.Load; - except - Result := False; - ReportError(Integer(PChar('Error loading module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); - end; - - Inc(I); - end; -end; - -//------------- -//Inits Core and all Modules -//------------- -Function TCore.Init: Boolean; -var - I: Integer; -begin - Result := InitCore; - - I := 0; - While ((Result = True) AND (I <= High(CORE_MODULES_TO_LOAD))) do - begin - try - Result := Modules[I].Module.Init; - except - Result := False; - ReportError(Integer(PChar('Error initing module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); - end; - - Modules[I].NeedsDeInit := Result; - Inc(I); - end; -end; - -//------------- -//DeInits Core and all Modules -//------------- -Function TCore.DeInit: Boolean; -var - I: Integer; -label Continue; -begin - I := High(CORE_MODULES_TO_LOAD); - - Continue: - Try - While (I >= 0) do - begin - If (Modules[I].NeedsDeInit) then - Modules[I].Module.DeInit; - - Dec(I); - end; - Except - - - end; - If (I >= 0) then - GoTo Continue; - - DeInitCore; -end; - -//------------- -//Load the Core -//------------- -Function TCore.LoadCore: Boolean; -begin - hLoadingFinished := Hooks.AddEvent('Core/LoadingFinished'); - hMainLoop := Hooks.AddEvent('Core/MainLoop'); - hTranslate := Hooks.AddEvent('Core/Translate'); - hLoadTextures := Hooks.AddEvent('Core/LoadTextures'); - hExitQuery := Hooks.AddEvent('Core/ExitQuery'); - hExit := Hooks.AddEvent('Core/Exit'); - hDebug := Hooks.AddEvent('Core/NewDebugInfo'); - hError := Hooks.AddEvent('Core/NewError'); - - sReportError := Services.AddService('Core/ReportError', nil, Self.ReportError); - sReportDebug := Services.AddService('Core/ReportDebug', nil, Self.ReportDebug); - sShowMessage := Services.AddService('Core/ShowMessage', nil, Self.ShowMessage); - sRetranslate := Services.AddService('Core/Retranslate', nil, Self.Retranslate); - sReloadTextures := Services.AddService('Core/ReloadTextures', nil, Self.ReloadTextures); - sGetModuleInfo := Services.AddService('Core/GetModuleInfo', nil, Self.GetModuleInfo); - sGetApplicationHandle := Services.AddService('Core/GetApplicationHandle', nil, Self.GetApplicationHandle); - - //A little Test - Hooks.AddSubscriber('Core/NewError', HookTest); -end; - -//------------- -//Init the Core -//------------- -Function TCore.InitCore: Boolean; -begin - //Dont Init s.th. atm. -end; - -//------------- -//DeInit the Core -//------------- -Function TCore.DeInitCore: Boolean; -begin - - - // to-do : write TService-/HookManager.Free and call it here -end; - -//------------- -//Method for other Classes to get Pointer to a specific Module -//------------- -Function TCore.GetModulebyName(const Name: String): PCoreModule; -var I: Integer; -begin - Result := nil; - For I := 0 to high(Modules) do - If (Modules[I].Info.Name = Name) then - begin - Result := @Modules[I].Module; - Break; - end; -end; - -//------------- -// Shows a MessageDialog (lParam: PChar Text, wParam: Symbol) -//------------- -Function TCore.ShowMessage(wParam, lParam: DWord): integer; -var Params: Cardinal; -begin - Result := -1; - - {$IFDEF MSWINDOWS} - If (ptr(lParam)<>nil) then - begin - Params := MB_OK; - Case wParam of - CORE_SM_ERROR: Params := Params or MB_ICONERROR; - CORE_SM_WARNING: Params := Params or MB_ICONWARNING; - CORE_SM_INFO: Params := Params or MB_ICONINFORMATION; - end; - - //Anzeigen: - Result := Messagebox(0, ptr(lParam), PChar(Name), Params); - end; - {$ENDIF} - - // to-do : write ShowMessage for other OSes -end; - -//------------- -// Calls NewError HookChain (wParam: Pchar(Message), lParam: PChar(Reportername)) -//------------- -Function TCore.ReportError(wParam, lParam: DWord): integer; -begin - //Update LastErrorReporter and LastErrorString - LastErrorReporter := String(PChar(Pointer(lParam))); - LastErrorString := String(PChar(Pointer(wParam))); - - Hooks.CallEventChain(hError, wParam, lParam); -end; - -//------------- -// Calls NewDebugInfo HookChain (wParam: Pchar(Message), lParam: PChar(Reportername)) -//------------- -Function TCore.ReportDebug(wParam, lParam: DWord): integer; -begin - Hooks.CallEventChain(hDebug, wParam, lParam); -end; - -//------------- -// Calls Translate hook -//------------- -Function TCore.Retranslate(wParam, lParam: DWord): integer; -begin - Hooks.CallEventChain(hTranslate, 0, 1); -end; - -//------------- -// Calls LoadTextures hook -//------------- -Function TCore.ReloadTextures(wParam, lParam: DWord): integer; -begin - Hooks.CallEventChain(hLoadTextures, 0, 1); -end; - -//------------- -// If lParam = nil then get length of Moduleinfo Array. If lparam <> nil then write array of TModuleInfo to address at lparam -//------------- -Function TCore.GetModuleInfo(wParam, lParam: DWord): integer; -begin - if (Pointer(lParam) = nil) then - begin - Result := Length(Modules); - end - else - begin - Try - For Result := 0 to High(Modules) do - begin - AModuleInfo(Pointer(lParam))[Result].Name := Modules[Result].Info.Name; - AModuleInfo(Pointer(lParam))[Result].Version := Modules[Result].Info.Version; - AModuleInfo(Pointer(lParam))[Result].Description := Modules[Result].Info.Description; - end; - Except - Result := -1; - end; - end; -end; - -//------------- -// Returns Application Handle -//------------- -Function TCore.GetApplicationHandle(wParam, lParam: DWord): integer; -begin - Result := hInstance; -end; - -end. +unit UCore; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +{$I switches.inc} + +uses uPluginDefs, + uCoreModule, + UHooks, + UServices, + UModules; +{********************* + TCore + Class manages all CoreModules, teh StartUp, teh MainLoop and the shutdown process + Also it does some Error Handling, and maybe sometime multithreaded Loading ;) +*********************} + +type + TModuleListItem = record + Module: TCoreModule; //Instance of the Modules Class + Info: TModuleInfo; //ModuleInfo returned by Modules Modulinfo Proc + NeedsDeInit: Boolean; //True if Module was succesful inited + end; + + TCore = class + private + //Some Hook Handles. See Plugin SDKs Hooks.txt for Infos + hLoadingFinished: THandle; + hMainLoop: THandle; + hTranslate: THandle; + hLoadTextures: THandle; + hExitQuery: THandle; + hExit: THandle; + hDebug: THandle; + hError: THandle; + sReportError: THandle; + sReportDebug: THandle; + sShowMessage: THandle; + sRetranslate: THandle; + sReloadTextures: THandle; + sGetModuleInfo: THandle; + sGetApplicationHandle: THandle; + + Modules: Array [0..High(CORE_MODULES_TO_LOAD)] of TModuleListItem; + + //Function Get all Modules and Creates them + Function GetModules: Boolean; + + //Loads Core and all Modules + Function Load: Boolean; + + //Inits Core and all Modules + Function Init: Boolean; + + //DeInits Core and all Modules + Function DeInit: Boolean; + + //Load the Core + Function LoadCore: Boolean; + + //Init the Core + Function InitCore: Boolean; + + //DeInit the Core + Function DeInitCore: Boolean; + + //Called one Time per Frame + Function MainLoop: Boolean; + + public + Hooks: THookManager; //Teh Hook Manager ;) + Services: TServiceManager;//The Service Manager + + CurExecuted: Integer; //ID of Plugin or Module curently Executed + + Name: String; //Name of this Application + Version: LongWord; //Version of this ". For Info Look PluginDefs Functions + + LastErrorReporter:String; //Who Reported the Last Error String + LastErrorString: String; //Last Error String reported + + + //--------------- + //Main Methods to control the Core: + //--------------- + Constructor Create(const cName: String; const cVersion: LongWord); + + //Starts Loading and Init Process. Then Runs MainLoop. DeInits on Shutdown + Procedure Run; + + //Method for other Classes to get Pointer to a specific Module + Function GetModulebyName(const Name: String): PCoreModule; + + //-------------- + // Hook and Service Procs: + //-------------- + Function ShowMessage(wParam, lParam: DWord): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol) + Function ReportError(wParam, lParam: DWord): integer; //Shows a Message (wParam: Pchar(Message), lParam: PChar(Reportername)) + Function ReportDebug(wParam, lParam: DWord): integer; //Shows a Message (wParam: Pchar(Message), lParam: PChar(Reportername)) + Function Retranslate(wParam, lParam: DWord): integer; //Calls Translate hook + Function ReloadTextures(wParam, lParam: DWord): integer; //Calls LoadTextures hook + Function GetModuleInfo(wParam, lParam: DWord): integer; //If lParam = nil then get length of Moduleinfo Array. If lparam <> nil then write array of TModuleInfo to address at lparam + Function GetApplicationHandle(wParam, lParam: DWord): integer; //Returns Application Handle + end; + +var + Core: TCore; + +implementation + +uses {$IFDEF win32} + Windows, + {$ENDIF} + SysUtils; + +//------------- +// Create - Creates Class + Hook and Service Manager +//------------- +Constructor TCore.Create(const cName: String; const cVersion: LongWord); +begin + Name := cName; + Version := cVersion; + CurExecuted := 0; + + LastErrorReporter := ''; + LastErrorString := ''; + + Hooks := THookManager.Create(50); + Services := TServiceManager.Create; +end; + +//------------- +//Starts Loading and Init Process. Then Runs MainLoop. DeInits on Shutdown +//------------- +Procedure TCore.Run; +var + noError: Boolean; +begin + //Get Modules + Try + noError := GetModules; + Except + noError := False; + end; + + //Loading + if (noError) then + begin + Try + noError := Load; + Except + noError := False; + end; + + if (noError) then + begin //Init + Try + noError := Init; + Except + noError := False; + end; + + If noError then + begin + //Call Translate Hook + noError := (Hooks.CallEventChain(hTranslate, 0, 0) = 0); + + If noError then + begin //Calls LoadTextures Hook + noError := (Hooks.CallEventChain(hLoadTextures, 0, 0) = 0); + + if noError then + begin //Calls Loading Finished Hook + noError := (Hooks.CallEventChain(hLoadingFinished, 0, 0) = 0); + + If noError then + begin + //Start MainLoop + While noError do + begin + noError := MainLoop; + // to-do : Call Display Draw here + end; + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error calling LoadingFinished Hook: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error calling LoadingFinished Hook'))); + end; + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading textures: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading textures'))); + end; + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error translating: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error translating'))); + end; + + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error initing Modules: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error initing Modules'))); + end; + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading Modules: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading Modules'))); + end; + end + else + begin + If (LastErrorString <> '') then + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error Getting Modules: ' + LastErrorString))) + else + Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error Getting Modules'))); + end; + + //DeInit + DeInit; +end; + +//------------- +//Called one Time per Frame +//------------- +Function TCore.MainLoop: Boolean; +begin + Result := False; + +end; + +//------------- +//Function Get all Modules and Creates them +//------------- +Function TCore.GetModules: Boolean; +var + I: Integer; +begin + Result := False; + try + For I := 0 to high(Modules) do + begin + Modules[I].NeedsDeInit := False; + Modules[I].Module := CORE_MODULES_TO_LOAD[I].Create; + Modules[I].Module.Info(@Modules[I].Info); + end; + Result := True; + except + ReportError(Integer(PChar('Can''t get module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); + end; +end; + +//------------- +//Loads Core and all Modules +//------------- +Function TCore.Load: Boolean; +var + I: Integer; +begin + Result := LoadCore; + + I := 0; + While ((Result = True) AND (I <= High(CORE_MODULES_TO_LOAD))) do + begin + try + Result := Modules[I].Module.Load; + except + Result := False; + ReportError(Integer(PChar('Error loading module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); + end; + + Inc(I); + end; +end; + +//------------- +//Inits Core and all Modules +//------------- +Function TCore.Init: Boolean; +var + I: Integer; +begin + Result := InitCore; + + I := 0; + While ((Result = True) AND (I <= High(CORE_MODULES_TO_LOAD))) do + begin + try + Result := Modules[I].Module.Init; + except + Result := False; + ReportError(Integer(PChar('Error initing module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); + end; + + Modules[I].NeedsDeInit := Result; + Inc(I); + end; +end; + +//------------- +//DeInits Core and all Modules +//------------- +Function TCore.DeInit: Boolean; +var + I: Integer; +label Continue; +begin + I := High(CORE_MODULES_TO_LOAD); + + Continue: + Try + While (I >= 0) do + begin + If (Modules[I].NeedsDeInit) then + Modules[I].Module.DeInit; + + Dec(I); + end; + Except + + + end; + If (I >= 0) then + GoTo Continue; + + DeInitCore; +end; + +//------------- +//Load the Core +//------------- +Function TCore.LoadCore: Boolean; +begin + hLoadingFinished := Hooks.AddEvent('Core/LoadingFinished'); + hMainLoop := Hooks.AddEvent('Core/MainLoop'); + hTranslate := Hooks.AddEvent('Core/Translate'); + hLoadTextures := Hooks.AddEvent('Core/LoadTextures'); + hExitQuery := Hooks.AddEvent('Core/ExitQuery'); + hExit := Hooks.AddEvent('Core/Exit'); + hDebug := Hooks.AddEvent('Core/NewDebugInfo'); + hError := Hooks.AddEvent('Core/NewError'); + + sReportError := Services.AddService('Core/ReportError', nil, Self.ReportError); + sReportDebug := Services.AddService('Core/ReportDebug', nil, Self.ReportDebug); + sShowMessage := Services.AddService('Core/ShowMessage', nil, Self.ShowMessage); + sRetranslate := Services.AddService('Core/Retranslate', nil, Self.Retranslate); + sReloadTextures := Services.AddService('Core/ReloadTextures', nil, Self.ReloadTextures); + sGetModuleInfo := Services.AddService('Core/GetModuleInfo', nil, Self.GetModuleInfo); + sGetApplicationHandle := Services.AddService('Core/GetApplicationHandle', nil, Self.GetApplicationHandle); + + //A little Test + Hooks.AddSubscriber('Core/NewError', HookTest); +end; + +//------------- +//Init the Core +//------------- +Function TCore.InitCore: Boolean; +begin + //Dont Init s.th. atm. +end; + +//------------- +//DeInit the Core +//------------- +Function TCore.DeInitCore: Boolean; +begin + + + // to-do : write TService-/HookManager.Free and call it here +end; + +//------------- +//Method for other Classes to get Pointer to a specific Module +//------------- +Function TCore.GetModulebyName(const Name: String): PCoreModule; +var I: Integer; +begin + Result := nil; + For I := 0 to high(Modules) do + If (Modules[I].Info.Name = Name) then + begin + Result := @Modules[I].Module; + Break; + end; +end; + +//------------- +// Shows a MessageDialog (lParam: PChar Text, wParam: Symbol) +//------------- +Function TCore.ShowMessage(wParam, lParam: DWord): integer; +var Params: Cardinal; +begin + Result := -1; + + {$IFDEF Delphi} + If (ptr(lParam)<>nil) then + begin + Params := MB_OK; + Case wParam of + CORE_SM_ERROR: Params := Params or MB_ICONERROR; + CORE_SM_WARNING: Params := Params or MB_ICONWARNING; + CORE_SM_INFO: Params := Params or MB_ICONINFORMATION; + end; + + //Anzeigen: + Result := Messagebox(0, ptr(lParam), PChar(Name), Params); + end; + {$ENDIF} + + // to-do : write ShowMessage for other OSes +end; + +//------------- +// Calls NewError HookChain (wParam: Pchar(Message), lParam: PChar(Reportername)) +//------------- +Function TCore.ReportError(wParam, lParam: DWord): integer; +begin + //Update LastErrorReporter and LastErrorString + LastErrorReporter := String(PChar(Pointer(lParam))); + LastErrorString := String(PChar(Pointer(wParam))); + + Hooks.CallEventChain(hError, wParam, lParam); +end; + +//------------- +// Calls NewDebugInfo HookChain (wParam: Pchar(Message), lParam: PChar(Reportername)) +//------------- +Function TCore.ReportDebug(wParam, lParam: DWord): integer; +begin + Hooks.CallEventChain(hDebug, wParam, lParam); +end; + +//------------- +// Calls Translate hook +//------------- +Function TCore.Retranslate(wParam, lParam: DWord): integer; +begin + Hooks.CallEventChain(hTranslate, 0, 1); +end; + +//------------- +// Calls LoadTextures hook +//------------- +Function TCore.ReloadTextures(wParam, lParam: DWord): integer; +begin + Hooks.CallEventChain(hLoadTextures, 0, 1); +end; + +//------------- +// If lParam = nil then get length of Moduleinfo Array. If lparam <> nil then write array of TModuleInfo to address at lparam +//------------- +Function TCore.GetModuleInfo(wParam, lParam: DWord): integer; +begin + if (Pointer(lParam) = nil) then + begin + Result := Length(Modules); + end + else + begin + Try + For Result := 0 to High(Modules) do + begin + AModuleInfo(Pointer(lParam))[Result].Name := Modules[Result].Info.Name; + AModuleInfo(Pointer(lParam))[Result].Version := Modules[Result].Info.Version; + AModuleInfo(Pointer(lParam))[Result].Description := Modules[Result].Info.Description; + end; + Except + Result := -1; + end; + end; +end; + +//------------- +// Returns Application Handle +//------------- +Function TCore.GetApplicationHandle(wParam, lParam: DWord): integer; +begin + Result := hInstance; +end; + +end. -- cgit v1.2.3 From 5e733f7e9cb2118651df90171db1892c9155e089 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 4 Nov 2007 21:00:20 +0000 Subject: Partymodule finished. All PartyScreens and SingScreen needs some adapting. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@583 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UCore.pas | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'Game/Code/Classes/UCore.pas') diff --git a/Game/Code/Classes/UCore.pas b/Game/Code/Classes/UCore.pas index e0f9fec2..5b144b45 100644 --- a/Game/Code/Classes/UCore.pas +++ b/Game/Code/Classes/UCore.pas @@ -47,6 +47,12 @@ type Modules: Array [0..High(CORE_MODULES_TO_LOAD)] of TModuleListItem; + //Cur + Last Executed Setting and Getting ;) + iCurExecuted: Integer; + iLastExecuted: Integer; + + Procedure SetCurExecuted(Value: Integer); + //Function Get all Modules and Creates them Function GetModules: Boolean; @@ -75,14 +81,14 @@ type Hooks: THookManager; //Teh Hook Manager ;) Services: TServiceManager;//The Service Manager - CurExecuted: Integer; //ID of Plugin or Module curently Executed - Name: String; //Name of this Application Version: LongWord; //Version of this ". For Info Look PluginDefs Functions LastErrorReporter:String; //Who Reported the Last Error String LastErrorString: String; //Last Error String reported + property CurExecuted: Integer read iCurExecuted write SetCurExecuted; //ID of Plugin or Module curently Executed + property LastExecuted: Integer read iLastExecuted; //--------------- //Main Methods to control the Core: @@ -124,7 +130,8 @@ Constructor TCore.Create(const cName: String; const cVersion: LongWord); begin Name := cName; Version := cVersion; - CurExecuted := 0; + iLastExecuted := 0; + iCurExecuted := 0; LastErrorReporter := ''; LastErrorString := ''; @@ -498,4 +505,16 @@ begin Result := hInstance; end; +//------------- +// Called when setting CurExecuted +//------------- +Procedure TCore.SetCurExecuted(Value: Integer); +begin + //Set Last Executed + iLastExecuted := iCurExecuted; + + //Set Cur Executed + iCurExecuted := Value; +end; + end. -- cgit v1.2.3 From a1a9c43dcd6f61610eb3afea542aec5de5dabf30 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 6 Nov 2007 19:40:06 +0000 Subject: Some changes to PluginInterface to fit with 64 Bit Systems. lParam is maily for use as Pointer, therefore standardtype: Pointer. wParam should mainly be used for ordinals. (Integer or Int64 on 64Bit Systems). Don't return addresses. Result is not assured to be Int64 on 64 Bit Systems. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@592 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UCore.pas | 68 ++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'Game/Code/Classes/UCore.pas') diff --git a/Game/Code/Classes/UCore.pas b/Game/Code/Classes/UCore.pas index 5b144b45..c150ff34 100644 --- a/Game/Code/Classes/UCore.pas +++ b/Game/Code/Classes/UCore.pas @@ -104,13 +104,13 @@ type //-------------- // Hook and Service Procs: //-------------- - Function ShowMessage(wParam, lParam: DWord): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol) - Function ReportError(wParam, lParam: DWord): integer; //Shows a Message (wParam: Pchar(Message), lParam: PChar(Reportername)) - Function ReportDebug(wParam, lParam: DWord): integer; //Shows a Message (wParam: Pchar(Message), lParam: PChar(Reportername)) - Function Retranslate(wParam, lParam: DWord): integer; //Calls Translate hook - Function ReloadTextures(wParam, lParam: DWord): integer; //Calls LoadTextures hook - Function GetModuleInfo(wParam, lParam: DWord): integer; //If lParam = nil then get length of Moduleinfo Array. If lparam <> nil then write array of TModuleInfo to address at lparam - Function GetApplicationHandle(wParam, lParam: DWord): integer; //Returns Application Handle + Function ShowMessage(wParam: TwParam; lParam: TlParam): integer; //Shows a Message (lParam: PChar Text, wParam: Symbol) + Function ReportError(wParam: TwParam; lParam: TlParam): integer; //Shows a Message (wParam: Pchar(Message), lParam: PChar(Reportername)) + Function ReportDebug(wParam: TwParam; lParam: TlParam): integer; //Shows a Message (wParam: Pchar(Message), lParam: PChar(Reportername)) + Function Retranslate(wParam: TwParam; lParam: TlParam): integer; //Calls Translate hook + Function ReloadTextures(wParam: TwParam; lParam: TlParam): integer; //Calls LoadTextures hook + Function GetModuleInfo(wParam: TwParam; lParam: TlParam): integer; //If lParam = nil then get length of Moduleinfo Array. If lparam <> nil then write array of TModuleInfo to address at lparam + Function GetApplicationHandle(wParam: TwParam; lParam: TlParam): integer; //Returns Application Handle end; var @@ -196,50 +196,50 @@ begin else begin If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error calling LoadingFinished Hook: ' + LastErrorString))) + Self.ShowMessage(CORE_SM_ERROR, PChar('Error calling LoadingFinished Hook: ' + LastErrorString)) else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error calling LoadingFinished Hook'))); + Self.ShowMessage(CORE_SM_ERROR, PChar('Error calling LoadingFinished Hook')); end; end else begin If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading textures: ' + LastErrorString))) + Self.ShowMessage(CORE_SM_ERROR, PChar('Error loading textures: ' + LastErrorString)) else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading textures'))); + Self.ShowMessage(CORE_SM_ERROR, PChar('Error loading textures')); end; end else begin If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error translating: ' + LastErrorString))) + Self.ShowMessage(CORE_SM_ERROR, PChar('Error translating: ' + LastErrorString)) else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error translating'))); + Self.ShowMessage(CORE_SM_ERROR, PChar('Error translating')); end; end else begin If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error initing Modules: ' + LastErrorString))) + Self.ShowMessage(CORE_SM_ERROR, PChar('Error initing Modules: ' + LastErrorString)) else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error initing Modules'))); + Self.ShowMessage(CORE_SM_ERROR, PChar('Error initing Modules')); end; end else begin If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading Modules: ' + LastErrorString))) + Self.ShowMessage(CORE_SM_ERROR, PChar('Error loading Modules: ' + LastErrorString)) else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error loading Modules'))); + Self.ShowMessage(CORE_SM_ERROR, PChar('Error loading Modules')); end; end else begin If (LastErrorString <> '') then - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error Getting Modules: ' + LastErrorString))) + Self.ShowMessage(CORE_SM_ERROR, PChar('Error Getting Modules: ' + LastErrorString)) else - Self.ShowMessage(CORE_SM_ERROR, Integer(PChar('Error Getting Modules'))); + Self.ShowMessage(CORE_SM_ERROR, PChar('Error Getting Modules')); end; //DeInit @@ -272,7 +272,7 @@ begin end; Result := True; except - ReportError(Integer(PChar('Can''t get module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); + ReportError(Integer(PChar('Can''t get module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), PChar('Core')); end; end; @@ -292,7 +292,7 @@ begin Result := Modules[I].Module.Load; except Result := False; - ReportError(Integer(PChar('Error loading module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); + ReportError(Integer(PChar('Error loading module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), PChar('Core')); end; Inc(I); @@ -315,7 +315,7 @@ begin Result := Modules[I].Module.Init; except Result := False; - ReportError(Integer(PChar('Error initing module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), Integer(PChar('Core'))); + ReportError(Integer(PChar('Error initing module #' + InttoStr(I) + ' "' + Modules[I].Info.Name + '"')), PChar('Core')); end; Modules[I].NeedsDeInit := Result; @@ -414,13 +414,13 @@ end; //------------- // Shows a MessageDialog (lParam: PChar Text, wParam: Symbol) //------------- -Function TCore.ShowMessage(wParam, lParam: DWord): integer; +Function TCore.ShowMessage(wParam: TwParam; lParam: TlParam): integer; var Params: Cardinal; begin Result := -1; {$IFDEF Delphi} - If (ptr(lParam)<>nil) then + If (lParam<>nil) then begin Params := MB_OK; Case wParam of @@ -430,7 +430,7 @@ begin end; //Anzeigen: - Result := Messagebox(0, ptr(lParam), PChar(Name), Params); + Result := Messagebox(0, lParam, PChar(Name), Params); end; {$ENDIF} @@ -440,10 +440,10 @@ end; //------------- // Calls NewError HookChain (wParam: Pchar(Message), lParam: PChar(Reportername)) //------------- -Function TCore.ReportError(wParam, lParam: DWord): integer; +Function TCore.ReportError(wParam: TwParam; lParam: TlParam): integer; begin //Update LastErrorReporter and LastErrorString - LastErrorReporter := String(PChar(Pointer(lParam))); + LastErrorReporter := String(PChar(lParam)); LastErrorString := String(PChar(Pointer(wParam))); Hooks.CallEventChain(hError, wParam, lParam); @@ -452,7 +452,7 @@ end; //------------- // Calls NewDebugInfo HookChain (wParam: Pchar(Message), lParam: PChar(Reportername)) //------------- -Function TCore.ReportDebug(wParam, lParam: DWord): integer; +Function TCore.ReportDebug(wParam: TwParam; lParam: TlParam): integer; begin Hooks.CallEventChain(hDebug, wParam, lParam); end; @@ -460,23 +460,23 @@ end; //------------- // Calls Translate hook //------------- -Function TCore.Retranslate(wParam, lParam: DWord): integer; +Function TCore.Retranslate(wParam: TwParam; lParam: TlParam): integer; begin - Hooks.CallEventChain(hTranslate, 0, 1); + Hooks.CallEventChain(hTranslate, 1, nil); end; //------------- // Calls LoadTextures hook //------------- -Function TCore.ReloadTextures(wParam, lParam: DWord): integer; +Function TCore.ReloadTextures(wParam: TwParam; lParam: TlParam): integer; begin - Hooks.CallEventChain(hLoadTextures, 0, 1); + Hooks.CallEventChain(hLoadTextures, 1, nil); end; //------------- // If lParam = nil then get length of Moduleinfo Array. If lparam <> nil then write array of TModuleInfo to address at lparam //------------- -Function TCore.GetModuleInfo(wParam, lParam: DWord): integer; +Function TCore.GetModuleInfo(wParam: TwParam; lParam: TlParam): integer; begin if (Pointer(lParam) = nil) then begin @@ -500,7 +500,7 @@ end; //------------- // Returns Application Handle //------------- -Function TCore.GetApplicationHandle(wParam, lParam: DWord): integer; +Function TCore.GetApplicationHandle(wParam: TwParam; lParam: TlParam): integer; begin Result := hInstance; end; -- cgit v1.2.3 From 08ac48400b9cd669ef80c9ed0f1acf57743d6875 Mon Sep 17 00:00:00 2001 From: tobigun Date: Thu, 27 Dec 2007 12:27:55 +0000 Subject: Added missing return-values (always true) to InitCore and LoadCore. Whiteshark: Please change this to the appropriate values. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@749 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UCore.pas | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Game/Code/Classes/UCore.pas') diff --git a/Game/Code/Classes/UCore.pas b/Game/Code/Classes/UCore.pas index c150ff34..9718b2eb 100644 --- a/Game/Code/Classes/UCore.pas +++ b/Game/Code/Classes/UCore.pas @@ -376,6 +376,8 @@ begin //A little Test Hooks.AddSubscriber('Core/NewError', HookTest); + + result := true; end; //------------- @@ -384,6 +386,7 @@ end; Function TCore.InitCore: Boolean; begin //Dont Init s.th. atm. + result := true; end; //------------- -- cgit v1.2.3 From 575a05b31780cc02145e14476d8f5e343b676ad4 Mon Sep 17 00:00:00 2001 From: tobigun Date: Tue, 5 Feb 2008 16:31:20 +0000 Subject: Changed Delphi-define to MSWINDOWS (works in FPC too) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@824 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UCore.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Game/Code/Classes/UCore.pas') diff --git a/Game/Code/Classes/UCore.pas b/Game/Code/Classes/UCore.pas index 9718b2eb..7e76c9c4 100644 --- a/Game/Code/Classes/UCore.pas +++ b/Game/Code/Classes/UCore.pas @@ -422,7 +422,7 @@ var Params: Cardinal; begin Result := -1; - {$IFDEF Delphi} + {$IFDEF MSWINDOWS} If (lParam<>nil) then begin Params := MB_OK; -- cgit v1.2.3