From: DeaDDooMER Date: Thu, 17 Jun 2021 16:52:30 +0000 (+0300) Subject: cleanup: clean boot sequence X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=fbb649f409620a55ae48f1bffd655c5a04489371;p=d2df-sdl.git cleanup: clean boot sequence --- diff --git a/src/engine/e_input_sdl2.inc b/src/engine/e_input_sdl2.inc index d619c51..d8704f7 100644 --- a/src/engine/e_input_sdl2.inc +++ b/src/engine/e_input_sdl2.inc @@ -213,8 +213,9 @@ const JOY2_DOWN = JOYH_BEG + 2*e_MaxJoyHats*4 + 0*4 + HAT_DOWN; JOY3_DOWN = JOYH_BEG + 3*e_MaxJoyHats*4 + 0*4 + HAT_DOWN; -function e_InitInput: Boolean; -procedure e_ReleaseInput; +procedure e_Input_Initialize; +procedure e_Input_Finalize; + procedure e_UnpressAllKeys; procedure e_KeyUpDown (key: Integer; down: Boolean); @@ -377,16 +378,15 @@ begin result := i < e_MaxJoys end; -function e_InitInput: Boolean; +procedure e_Input_Initialize; var i: Integer; begin for i := 0 to e_MaxJoys - 1 do e_JoystickAvailable[i] := False; - GenerateKeyNames; - result := True + GenerateKeyNames end; -procedure e_ReleaseInput; +procedure e_Input_Finalize; var i: Integer; begin for i := 0 to e_MaxJoys - 1 do diff --git a/src/engine/e_input_stub.inc b/src/engine/e_input_stub.inc index 670390a..cd0cb3d 100644 --- a/src/engine/e_input_stub.inc +++ b/src/engine/e_input_stub.inc @@ -227,8 +227,9 @@ interface JOY2_DOWN = JOYH_BEG + 2*e_MaxJoyHats*4 + 0*4 + HAT_DOWN; JOY3_DOWN = JOYH_BEG + 3*e_MaxJoyHats*4 + 0*4 + HAT_DOWN; -function e_InitInput: Boolean; -procedure e_ReleaseInput; +procedure e_Input_Initialize; +procedure e_Input_Finalize; + procedure e_UnpressAllKeys; procedure e_KeyUpDown (key: Integer; down: Boolean); @@ -393,16 +394,15 @@ begin result := i < e_MaxJoys end; -function e_InitInput: Boolean; +procedure e_Input_Initialize; var i: Integer; begin for i := 0 to e_MaxJoys - 1 do e_JoystickAvailable[i] := False; - GenerateKeyNames; - result := True + GenerateKeyNames end; -procedure e_ReleaseInput; +procedure e_Input_Finalize; var i: Integer; begin for i := 0 to e_MaxJoys - 1 do diff --git a/src/engine/e_log.pas b/src/engine/e_log.pas index 7159c18..0dcb098 100644 --- a/src/engine/e_log.pas +++ b/src/engine/e_log.pas @@ -19,13 +19,14 @@ unit e_log; interface -uses - SysUtils; + uses SysUtils; -type - TWriteMode = (WM_NEWFILE, WM_OLDFILE); - TMsgType = (Fatal, Warning, Notify); + type + TWriteMode = (WM_NEWFILE, WM_OLDFILE); + TMsgType = (Fatal, Warning, Notify); + procedure e_Log_Initialize; + procedure e_Log_Finalize; procedure e_InitLog (fFileName: String; fWriteMode: TWriteMode); procedure e_DeinitLog (); @@ -58,6 +59,16 @@ var driverInited: Boolean = false; + procedure e_Log_Initialize; + begin + end; + + procedure e_Log_Finalize; + begin + e_DeinitLog + end; + + function DecodeIPV4 (ip: LongWord): string; begin Result := Format('%d.%d.%d.%d', [ip and $FF, (ip shr 8) and $FF, (ip shr 16) and $FF, (ip shr 24)]); diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr index 5911994..268e281 100644 --- a/src/game/Doom2DF.lpr +++ b/src/game/Doom2DF.lpr @@ -166,6 +166,7 @@ uses r_texture in 'opengl/r_texture.pas', r_weapons in 'opengl/r_weapons.pas', r_window in 'opengl/r_window.pas', + r_render in 'opengl/r_render.pas', {$IFDEF USE_FMOD} fmod in '../lib/FMOD/fmod.pas', @@ -207,6 +208,9 @@ uses {$R *.res} {$ENDIF} + const + autoexecScript = 'autoexec.cfg'; + var noct: Boolean = False; binPath: AnsiString = ''; @@ -217,6 +221,8 @@ uses Frame: Int64; flag: Boolean = false; + NoSound: Boolean; + procedure Update (); begin // remember old mobj positions, prepare for update @@ -231,58 +237,6 @@ begin if NetMode = NET_SERVER then g_Net_Flush(); end; -procedure Init(); -var - NoSound: Boolean; -begin - Randomize; - -{$IFDEF HEADLESS} - {$IFDEF USE_SDLMIXER} - NoSound := False; // hope env has set SDL_AUDIODRIVER to dummy - {$ELSE} - NoSound := True; // FMOD backend will sort it out - {$ENDIF} -{$ELSE} - NoSound := False; -{$ENDIF} - - g_Touch_Init; - -(* - if (e_JoysticksAvailable > 0) then - e_WriteLog('Input: Joysticks available.', TMsgType.Notify) - else - e_WriteLog('Input: No Joysticks.', TMsgType.Notify); -*) - - if (not gNoSound) then - begin - e_WriteLog('Initializing sound system', TMsgType.Notify); - e_InitSoundSystem(NoSound); - end; - - e_WriteLog('Init game', TMsgType.Notify); - g_Game_Init(); - -// FillChar(charbuff, sizeof(charbuff), ' '); -end; - -procedure Release(); -begin - e_WriteLog('Releasing engine', TMsgType.Notify); - e_ReleaseEngine(); - - e_WriteLog('Releasing input', TMsgType.Notify); - e_ReleaseInput(); - - if not gNoSound then - begin - e_WriteLog('Releasing sound', TMsgType.Notify); - e_ReleaseSoundSystem(); - end; -end; - function ProcessMessage (): Boolean; var i, t: Integer; @@ -351,8 +305,7 @@ begin e_SoundUpdate(); end; - -function SDLMain (): Integer; +procedure DebugOptions; var idx: Integer; arg: AnsiString; @@ -362,7 +315,6 @@ var valres: Word; {$ENDIF} begin - idx := 1; while (idx <= ParamCount) do begin @@ -453,32 +405,6 @@ begin end; end; end; - - r_Window_Initialize; - - Init; - Time_Old := sys_GetTicks(); - - g_Net_InitLowLevel(); - - // game commad line - if (ParamCount > 0) then g_Game_Process_Params(); - -{$IFNDEF HEADLESS} - if (not gGameOn) and gAskLanguage then g_Menu_AskLanguage(); -{$ENDIF} - - e_WriteLog('Entering the main loop', TMsgType.Notify); - - // main loop - while not ProcessMessage() do begin end; - - g_Net_Slist_ShutdownAll(); - - Release(); - - g_Net_DeinitLowLevel(); - result := 0; end; function GetBinaryPath (): AnsiString; @@ -814,225 +740,256 @@ begin AddDir(AllMapDirs, MegawadDirs[i]); OptimizeDirs(AllMapDirs); - if LogFileName = '' then - begin - rwdir := e_GetWriteableDir(LogDirs, false); - if rwdir <> '' then - begin - {$IFDEF HEADLESS} - LogFileName := e_CatPath(rwdir, 'Doom2DF_H.log'); - {$ELSE} - LogFileName := e_CatPath(rwdir, 'Doom2DF.log'); - {$ENDIF} - end - end; - // HACK: ensure the screenshots folder also has a stats subfolder in it rwdir := e_GetWriteableDir(ScreenshotDirs, false); if rwdir <> '' then CreateDir(rwdir + '/stats'); end; -procedure InitPrep; - {$IF DEFINED(ANDROID) AND DEFINED(USE_SDLMIXER)} - var timiditycfg: AnsiString; - {$ENDIF} - var i: Integer; -begin - {$IFDEF HEADLESS} - conbufDumpToStdOut := true; - {$ENDIF} - for i := 1 to ParamCount do + procedure EntryParams; + var i: Integer; begin - case ParamStr(i) of - '--con-stdout': conbufDumpToStdOut := true; - '--no-fbo': glRenderToFBO := false; + i := 1; + while i <= ParamCount do + begin + case ParamStr(i) of + '--gdb': noct := true; + '--log', '--con-stdout': conbufDumpToStdOut := true; + '--safe-log': e_SetSafeSlowLog(true); + '--log-file': + if i + 1 <= ParamCount then + begin + Inc(i); + LogFileName := ParamStr(i) + end; + '--no-fbo': glRenderToFBO := false; + end; + Inc(i) end end; - if LogFileName <> '' then - e_InitLog(LogFileName, TWriteMode.WM_NEWFILE); - e_InitWritelnDriver(); - e_WriteLog('Doom 2D: Forever version ' + GAME_VERSION + ' proto ' + IntToStr(NET_PROTOCOL_VER), TMsgType.Notify); - e_WriteLog('Build date: ' + GAME_BUILDDATE + ' ' + GAME_BUILDTIME, TMsgType.Notify); - e_WriteLog('Build hash: ' + g_GetBuildHash(), TMsgType.Notify); - e_WriteLog('Build by: ' + g_GetBuilderName(), TMsgType.Notify); - - e_LogWritefln('Force bin dir: %s', [forceBinDir], TMsgType.Notify); - e_LogWritefln('BINARY PATH: [%s]', [binPath], TMsgType.Notify); - - PrintDirs('DataDirs', DataDirs); - PrintDirs('ModelDirs', ModelDirs); - PrintDirs('MegawadDirs', MegawadDirs); - PrintDirs('MapDirs', MapDirs); - PrintDirs('WadDirs', WadDirs); - - PrintDirs('LogDirs', LogDirs); - PrintDirs('SaveDirs', SaveDirs); - PrintDirs('CacheDirs', CacheDirs); - PrintDirs('ConfigDirs', ConfigDirs); - PrintDirs('ScreenshotDirs', ScreenshotDirs); - PrintDirs('StatsDirs', StatsDirs); - PrintDirs('MapDownloadDirs', MapDownloadDirs); - PrintDirs('WadDownloadDirs', WadDownloadDirs); - - GameWAD := e_FindWad(DataDirs, GameWADName); - if GameWad = '' then + procedure InitLog; + var rwdir: AnsiString; begin - e_WriteLog('WAD ' + GameWADName + ' not found in data directories.', TMsgType.Fatal); - {$IF DEFINED(USE_SDL2) AND NOT DEFINED(HEADLESS)} - if forceBinDir = false then - SDL_ShowSimpleMessageBox( - SDL_MESSAGEBOX_ERROR, - 'Doom 2D Forever', - PChar('WAD ' + GameWADName + ' not found in data directories.'), - nil - ); - {$ENDIF} - e_DeinitLog; - Halt(1); - end; - - {$IF DEFINED(ANDROID) AND DEFINED(USE_SDLMIXER)} - timiditycfg := 'timidity.cfg'; - if e_FindResource(ConfigDirs, timiditycfg) = true then + if LogFileName = '' then begin - timiditycfg := ExpandFileName(timiditycfg); - SetEnvVar('TIMIDITY_CFG', timiditycfg); - e_LogWritefln('Set TIMIDITY_CFG = "%s"', [timiditycfg]); + rwdir := e_GetWriteableDir(LogDirs, false); + if rwdir <> '' then + begin + {$IFDEF HEADLESS} + LogFileName := e_CatPath(rwdir, 'Doom2DF_H.log'); + {$ELSE} + LogFileName := e_CatPath(rwdir, 'Doom2DF.log'); + {$ENDIF} + end end; - {$ENDIF} -end; - -procedure Main; -{$IFDEF ENABLE_HOLMES} - var flexloaded: Boolean; -{$ENDIF} -begin - InitPath; - InitPrep; - e_InitInput; - sys_Init; + if LogFileName <> '' then + e_InitLog(LogFileName, TWriteMode.WM_NEWFILE); + e_InitWritelnDriver + end; - sys_CharPress := @CharPress; + procedure InitPrep; + {$IF DEFINED(ANDROID) AND DEFINED(USE_SDLMIXER)} + var timiditycfg: AnsiString; + {$ENDIF} + begin + e_WriteLog('Doom 2D: Forever version ' + GAME_VERSION + ' proto ' + IntToStr(NET_PROTOCOL_VER), TMsgType.Notify); + e_WriteLog('Build date: ' + GAME_BUILDDATE + ' ' + GAME_BUILDTIME, TMsgType.Notify); + e_WriteLog('Build hash: ' + g_GetBuildHash(), TMsgType.Notify); + e_WriteLog('Build by: ' + g_GetBuilderName(), TMsgType.Notify); + + e_LogWritefln('Force bin dir: %s', [forceBinDir], TMsgType.Notify); + e_LogWritefln('BINARY PATH: [%s]', [binPath], TMsgType.Notify); + + PrintDirs('DataDirs', DataDirs); + PrintDirs('ModelDirs', ModelDirs); + PrintDirs('MegawadDirs', MegawadDirs); + PrintDirs('MapDirs', MapDirs); + PrintDirs('WadDirs', WadDirs); + + PrintDirs('LogDirs', LogDirs); + PrintDirs('SaveDirs', SaveDirs); + PrintDirs('CacheDirs', CacheDirs); + PrintDirs('ConfigDirs', ConfigDirs); + PrintDirs('ScreenshotDirs', ScreenshotDirs); + PrintDirs('StatsDirs', StatsDirs); + PrintDirs('MapDownloadDirs', MapDownloadDirs); + PrintDirs('WadDownloadDirs', WadDownloadDirs); + + {$IFDEF HEADLESS} + {$IFDEF USE_SDLMIXER} + NoSound := False; // hope env has set SDL_AUDIODRIVER to dummy + {$ELSE} + NoSound := True; // FMOD backend will sort it out + {$ENDIF} + {$ELSE} + NoSound := False; + {$ENDIF} - g_Options_SetDefault; - g_Options_SetDefaultVideo; - g_Console_SysInit; - if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = False then - raise Exception.Create('Failed to set videomode on startup.'); + {$IF DEFINED(ANDROID) AND DEFINED(USE_SDLMIXER)} + timiditycfg := 'timidity.cfg'; + if e_FindResource(ConfigDirs, timiditycfg) = true then + begin + timiditycfg := ExpandFileName(timiditycfg); + SetEnvVar('TIMIDITY_CFG', timiditycfg); + e_LogWritefln('Set TIMIDITY_CFG = "%s"', [timiditycfg]); + end; + {$ENDIF} - e_WriteLog(gLanguage, TMsgType.Notify); - g_Language_Set(gLanguage); + GameWAD := e_FindWad(DataDirs, GameWADName); + if GameWad = '' then + begin + e_WriteLog('WAD ' + GameWADName + ' not found in data directories.', TMsgType.Fatal); + {$IF DEFINED(USE_SDL2) AND NOT DEFINED(HEADLESS)} + if forceBinDir = false then + SDL_ShowSimpleMessageBox( + SDL_MESSAGEBOX_ERROR, + 'Doom 2D Forever', + PChar('WAD ' + GameWADName + ' not found in data directories.'), + nil + ); + {$ENDIF} + e_DeinitLog; + Halt(1); + end + end; -{$IF not DEFINED(HEADLESS) and DEFINED(ENABLE_HOLMES)} - flexloaded := true; - if not fuiAddWad('flexui.wad') then +{$IFDEF ENABLE_HOLMES} + procedure InitHolmes; + var flexloaded: Boolean; begin - if not fuiAddWad('./data/flexui.wad') then fuiAddWad('./flexui.wad'); - end; - try - fuiGfxLoadFont('win8', 'flexui/fonts/win8.fuifont'); - fuiGfxLoadFont('win14', 'flexui/fonts/win14.fuifont'); - fuiGfxLoadFont('win16', 'flexui/fonts/win16.fuifont'); - fuiGfxLoadFont('dos8', 'flexui/fonts/dos8.fuifont'); - fuiGfxLoadFont('msx6', 'flexui/fonts/msx6.fuifont'); - except on e: Exception do - begin - writeln('ERROR loading FlexUI fonts'); - flexloaded := false; - //raise; - end; - else + flexloaded := true; + if not fuiAddWad('flexui.wad') then begin - flexloaded := false; - //raise; + if not fuiAddWad('./data/flexui.wad') then fuiAddWad('./flexui.wad'); end; - end; - if (flexloaded) then - begin try - e_LogWriteln('FlexUI: loading stylesheet...'); - uiLoadStyles('flexui/widgets.wgs'); - except on e: TParserException do + fuiGfxLoadFont('win8', 'flexui/fonts/win8.fuifont'); + fuiGfxLoadFont('win14', 'flexui/fonts/win14.fuifont'); + fuiGfxLoadFont('win16', 'flexui/fonts/win16.fuifont'); + fuiGfxLoadFont('dos8', 'flexui/fonts/dos8.fuifont'); + fuiGfxLoadFont('msx6', 'flexui/fonts/msx6.fuifont'); + except on e: Exception do begin - writeln('ERROR at (', e.tokLine, ',', e.tokCol, '): ', e.message); - //raise; + writeln('ERROR loading FlexUI fonts'); flexloaded := false; + //raise; end; else begin - //raise; flexloaded := false; + //raise; end; end; + if flexloaded then + begin + try + e_LogWriteln('FlexUI: loading stylesheet...'); + uiLoadStyles('flexui/widgets.wgs'); + except on e: TParserException do + begin + writeln('ERROR at (', e.tokLine, ',', e.tokCol, '): ', e.message); + //raise; + flexloaded := false; + end; + else + begin + //raise; + flexloaded := false; + end; + end; + end; + g_holmes_imfunctional := not flexloaded; + if not g_holmes_imfunctional then + begin + uiInitialize(); + uiContext.font := 'win14'; + end; + if assigned(oglInitCB) then oglInitCB; end; - g_holmes_imfunctional := not flexloaded; - if (not g_holmes_imfunctional) then + procedure FreeHolmes; begin - uiInitialize(); - uiContext.font := 'win14'; + if assigned(oglDeinitCB) then + oglDeinitCB end; - - if assigned(oglInitCB) then oglInitCB; {$ENDIF} - //g_Res_CreateDatabases(true); // it will be done before connecting to the server for the first time - - e_WriteLog('Entering SDLMain', TMsgType.Notify); - - {$WARNINGS OFF} - SDLMain(); - {$WARNINGS ON} - - {$IFDEF ENABLE_HOLMES} - if assigned(oglDeinitCB) then oglDeinitCB; - {$ENDIF} - - g_Console_WriteGameConfig; - sys_Final; -end; - - -procedure EntryParams; - var f: Integer; -begin - f := 1; - while f <= ParamCount do + procedure Startup; begin - case ParamStr(f) of - '--gdb': noct := true; - '--log': conbufDumpToStdOut := true; - '--safe-log': e_SetSafeSlowLog(true); - '--log-file': - if f + 1 <= ParamCount then - begin - Inc(f); - LogFileName := ParamStr(f) - end - end; - Inc(f) - end -end; - -procedure EntryPoint; -begin - SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); //k8: fuck off, that's why - EntryParams; - if noct then - Main - else - try - Main; + Randomize; + InitPath; + InitLog; + InitPrep; + e_Input_Initialize; + e_InitSoundSystem(NoSound); + sys_Init; + sys_CharPress := @CharPress; (* install hook *) + g_Options_SetDefault; + g_Options_SetDefaultVideo; + g_Console_Initialize; + // TODO move load configs here + g_Language_Set(gLanguage); + r_Render_Initialize; + g_Touch_Init; + DebugOptions; + g_Net_InitLowLevel; + // TODO init serverlist + {$IFDEF ENABLE_HOLMES} + InitHolmes; + {$ENDIF} + g_Game_Init; + {$IFNDEF HEADLESS} + g_Menu_Init; + g_GUI_Init; + {$ENDIF} + g_Game_Process_Params; + // TODO reload GAME textures + g_Console_Init; // welcome message + {$IFNDEF HEADLESS} + if (not gGameOn) and gAskLanguage then + g_Menu_AskLanguage; + {$ENDIF} + Time_Old := sys_GetTicks(); + while not ProcessMessage() do begin end; + g_Console_WriteGameConfig; + {$IFNDEF HEADLESS} + g_GUI_Destroy; + g_Menu_Free; + {$ENDIF} + {$IFDEF ENABLE_HOLMES} + FreeHolmes; + {$ENDIF} + g_Net_Slist_ShutdownAll; + g_Net_DeinitLowLevel; + (* g_Touch_Finalize; *) + r_Render_Finalize; + sys_Final; + g_Console_Finalize; + e_ReleaseSoundSystem; + e_Input_Finalize; e_WriteLog('Shutdown with no errors.', TMsgType.Notify) - except on e: Exception do - e_WriteStackTrace(e.message) - else - e_WriteStackTrace('FATAL ERROR') end; - e_DeinitLog; -end; + procedure EntryPoint; + begin + SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); //k8: fuck off, that's why + EntryParams; + e_Log_Initialize; + {$IFDEF HEADLESS} + conbufDumpToStdOut := true; + {$ENDIF} + if noct then + Startup + else + try + Startup + except on e: Exception do + e_WriteStackTrace(e.message) + else + e_WriteStackTrace('FATAL ERROR') + end; + e_Log_Finalize + end; {$IFDEF ANDROID} function SDL_main (argc: CInt; argv: PPChar): CInt; cdecl; diff --git a/src/game/g_console.pas b/src/game/g_console.pas index 02beb87..feef35d 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -46,7 +46,8 @@ uses end; procedure g_Console_Init; -procedure g_Console_SysInit; +procedure g_Console_Initialize; +procedure g_Console_Finalize; procedure g_Console_Update; procedure g_Console_Char (C: AnsiChar); procedure g_Console_Control (K: Word); @@ -104,7 +105,6 @@ uses g_menu, g_gui, g_language, g_net, g_netmsg, e_log, conbuf; const - autoexecScript = 'autoexec.cfg'; configComment = 'generated by doom2d, do not modify'; type @@ -944,7 +944,7 @@ begin end end; -procedure g_Console_SysInit; +procedure g_Console_Initialize; var a: Integer; begin gConsoleShow := False; @@ -1158,10 +1158,17 @@ begin g_Console_ResetBinds; g_Console_ReadConfig(gConfigScript); - g_Console_ReadConfig(autoexecScript); +// g_Console_ReadConfig(autoexecScript); + g_Console_ReadConfig('autoexec.cfg'); + gParsingBinds := False; end; +procedure g_Console_Finalize; +begin + +end; + procedure g_Console_Init; begin g_Console_Add(Format(_lc[I_CONSOLE_WELCOME], [GAME_VERSION])); @@ -1683,7 +1690,7 @@ end; procedure g_Console_BindKey (key: Integer; down: AnsiString; up: AnsiString = ''); begin - //e_LogWritefln('bind "%s" "%s" <%s>', [LowerCase(e_KeyNames[key]), cmd, key]); + // e_LogWritefln('bind "%s" "%s" "%s" <%s>', [LowerCase(e_KeyNames[key]), down, up, key]); ASSERT(key >= 0); ASSERT(key < e_MaxInputKeys); if key > 0 then @@ -1928,6 +1935,7 @@ procedure g_Console_WriteConfig (filename: String); end; begin + // e_LogWritefln('g_Console_WriteConfig: %s', [filename]); AssignFile(f, filename); Rewrite(f); WriteLn(f, '// ' + configComment); diff --git a/src/game/g_game.pas b/src/game/g_game.pas index f7aed54..af3d8ad 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -1467,13 +1467,7 @@ begin g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION]), 0, False); g_Game_SetLoadingText('', 0, False); - g_Game_SetLoadingText(_lc[I_LOAD_CONSOLE], 0, False); - r_Console_Init; - g_Console_Init(); - g_Game_SetLoadingText(_lc[I_LOAD_MODELS], 0, False); - r_PlayerModel_Initialize; - // load models from all possible wad types, in all known directories // this does a loosy job (linear search, ooph!), but meh for wext in wadExtensions do @@ -1527,11 +1521,6 @@ begin g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD+':MUSIC\ROUNDMUS', True, True); g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD+':MUSIC\ENDMUS', True); -{$IFNDEF HEADLESS} - g_Game_SetLoadingText(_lc[I_LOAD_MENUS], 0, False); - g_Menu_Init(); -{$ENDIF} - gMusic := TMusic.Create(); gMusic.SetByName('MUSIC_MENU'); gMusic.Play(); @@ -2629,7 +2618,6 @@ begin g_Game_StopAllSounds(True); gMusic.Free(); g_Game_FreeData(); - r_PlayerModel_Finalize; g_PlayerModel_FreeData(); g_Texture_DeleteAll(); g_Frames_DeleteAll(); diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index 4d20921..c4d9b38 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -3531,16 +3531,11 @@ end; procedure g_Menu_Init(); begin MenuLoadData(); - g_GUI_Init(); CreateAllMenus(); end; procedure g_Menu_Free(); begin - g_GUI_Destroy(); - - e_WriteLog('Releasing menu data...', TMsgType.Notify); - MenuFreeData(); end; diff --git a/src/game/opengl/r_render.pas b/src/game/opengl/r_render.pas new file mode 100644 index 0000000..9f8b754 --- /dev/null +++ b/src/game/opengl/r_render.pas @@ -0,0 +1,43 @@ +(* Copyright (C) Doom 2D: Forever Developers + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License ONLY. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *) +{$INCLUDE ../../shared/a_modes.inc} +unit r_render; + +interface + + procedure r_Render_Initialize; + procedure r_Render_Finalize; + +implementation + + uses SysUtils, Classes, g_system, g_game, g_options, r_window, r_graphics, r_console, r_playermodel; + + procedure r_Render_Initialize; + begin + if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = False then + raise Exception.Create('Failed to set videomode on startup.'); + + r_Window_Initialize; + r_Console_Init; + r_PlayerModel_Initialize; + end; + + procedure r_Render_Finalize; + begin + r_PlayerModel_Finalize; + e_ReleaseEngine + end; + +end.