1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
16 {$IFDEF ANDROID}library{$ELSE}program{$ENDIF} Doom2DF;
35 mempool in '../shared/mempool.pas',
36 conbuf in '../shared/conbuf.pas',
37 geom in '../shared/geom.pas',
40 {$IFDEF USE_MINIUPNPC}
41 miniupnpc in '../lib/miniupnpc/miniupnpc.pas',
51 SDL2 in '../lib/sdl2/sdl2.pas',
53 SDL2_mixer in '../lib/sdl2/SDL2_mixer.pas',
58 SDL2 in '../lib/sdl2/sdl2.pas',
59 SDL2_mixer in '../lib/sdl2/SDL2_mixer.pas',
64 AL in '../lib/openal/al.pas',
65 e_soundfile in '../engine/e_soundfile.pas',
66 {$IF DEFINED(USE_SDL) OR DEFINED(USE_SDL2)}
67 e_soundfile_wav in '../engine/e_soundfile_wav.pas',
70 vorbis in '../lib/vorbis/vorbis.pas',
71 e_soundfile_vorbis in '../engine/e_soundfile_vorbis.pas',
73 {$IFDEF USE_FLUIDSYNTH}
74 fluidsynth in '../lib/fluidsynth/fluidsynth.pas',
75 e_soundfile_fluid in '../engine/e_soundfile_fluid.pas',
78 modplug in '../lib/modplug/modplug.pas',
79 e_soundfile_modplug in '../engine/e_soundfile_modplug.pas',
82 xmp in '../lib/xmp/xmp.pas',
83 e_soundfile_xmp in '../engine/e_soundfile_xmp.pas',
86 gme in '../lib/gme/gme.pas',
87 e_soundfile_gme in '../engine/e_soundfile_gme.pas',
90 mpg123 in '../lib/mpg123/mpg123.pas',
91 e_soundfile_mp3 in '../engine/e_soundfile_mp3.pas',
94 opus in '../lib/opus/opus.pas',
95 e_soundfile_opus in '../engine/e_soundfile_opus.pas',
97 {$IF DEFINED(USE_VORBIS) OR DEFINED(USE_OPUS)}
98 ogg in '../lib/vorbis/ogg.pas', // this has to come last because link order
102 ENet in '../lib/enet/enet.pp',
103 e_input in '../engine/e_input.pas',
104 e_log in '../engine/e_log.pas',
105 e_sound in '../engine/e_sound.pas',
106 e_msg in '../engine/e_msg.pas',
107 e_res in '../engine/e_res.pas',
108 utils in '../shared/utils.pas',
109 xstreams in '../shared/xstreams.pas',
110 sfs in '../sfs/sfs.pas',
111 sfsPlainFS in '../sfs/sfsPlainFS.pas',
112 sfsZipFS in '../sfs/sfsZipFS.pas',
113 wadreader in '../shared/wadreader.pas',
114 MAPDEF in '../shared/MAPDEF.pas',
115 CONFIG in '../shared/CONFIG.pas',
116 g_base in 'g_base.pas',
117 g_basic in 'g_basic.pas',
118 g_console in 'g_console.pas',
119 g_net in 'g_net.pas',
120 g_netmsg in 'g_netmsg.pas',
121 g_nethandler in 'g_nethandler.pas',
122 g_netmaster in 'g_netmaster.pas',
123 g_res_downloader in 'g_res_downloader.pas',
124 g_grid in 'g_grid.pas',
125 g_game in 'g_game.pas',
127 g_gfx in 'g_gfx.pas',
129 g_items in 'g_items.pas',
130 g_map in 'g_map.pas',
131 g_monsters in 'g_monsters.pas',
132 g_options in 'g_options.pas',
133 g_phys in 'g_phys.pas',
134 g_player in 'g_player.pas',
135 g_playermodel in 'g_playermodel.pas',
136 g_saveload in 'g_saveload.pas',
137 g_sound in 'g_sound.pas',
138 g_textures in 'g_textures.pas',
139 g_triggers in 'g_triggers.pas',
140 g_weapons in 'g_weapons.pas',
141 g_window in 'g_window.pas',
144 g_system in 'stub/g_system.pas',
147 g_system in 'sdl/g_system.pas',
150 g_system in 'sdl2/g_system.pas',
155 {$I ../shared/vampimg.inc}
156 r_animations in 'opengl/r_animations.pas',
157 r_console in 'opengl/r_console.pas',
158 r_game in 'opengl/r_game.pas',
160 r_gfx in 'opengl/r_gfx.pas',
162 r_graphics in 'opengl/r_graphics.pas',
163 r_items in 'opengl/r_items.pas',
164 r_map in 'opengl/r_map.pas',
165 r_monsters in 'opengl/r_monsters.pas',
166 r_netmaster in 'opengl/r_netmaster.pas',
167 r_player in 'opengl/r_player.pas',
168 r_playermodel in 'opengl/r_playermodel.pas',
169 r_render in 'opengl/r_render.pas',
170 r_texture in 'opengl/r_texture.pas',
171 r_textures in 'opengl/r_textures.pas',
172 r_weapons in 'opengl/r_weapons.pas',
173 r_window in 'opengl/r_window.pas',
174 {$IFDEF ENABLE_TOUCH}
175 r_touch in 'opengl/r_touch.pas',
178 g_gui in 'g_gui.pas',
179 g_menu in 'g_menu.pas',
184 fmod in '../lib/FMOD/fmod.pas',
185 fmoderrors in '../lib/FMOD/fmoderrors.pas',
186 fmodpresets in '../lib/FMOD/fmodpresets.pas',
187 fmodtypes in '../lib/FMOD/fmodtypes.pas',
189 xprofiler in '../shared/xprofiler.pas',
190 binheap in '../shared/binheap.pas',
191 hashtable in '../shared/hashtable.pas',
192 fhashdb in '../shared/fhashdb.pas',
193 idpool in '../shared/idpool.pas',
194 xparser in '../shared/xparser.pas',
195 xdynrec in '../shared/xdynrec.pas',
196 exoma in '../shared/exoma.pas',
197 envvars in '../shared/envvars.pas',
198 g_panel in 'g_panel.pas',
199 g_language in 'g_language.pas',
201 {$IFDEF ENABLE_HOLMES}
202 g_holmes in 'g_holmes.pas',
204 sdlcarcass in '../flexui/sdlcarcass.pas',
205 //sdlstandalone in '../flexui/sdlstandalone.pas',
207 fui_wadread in '../flexui/fui_wadread.pas',
208 fui_common in '../flexui/fui_common.pas',
209 fui_gfx_gl in '../flexui/fui_gfx_gl.pas',
210 fui_events in '../flexui/fui_events.pas',
211 fui_style in '../flexui/fui_style.pas',
212 fui_flexlay in '../flexui/fui_flexlay.pas',
213 fui_ctls in '../flexui/fui_ctls.pas',
223 autoexecScript = 'autoexec.cfg';
226 noct: Boolean = False;
227 binPath: AnsiString = '';
228 forceBinDir: Boolean = False;
235 // remember old mobj positions, prepare for update
237 // server: receive client commands for new frame
238 // client: receive game state changes from server
239 if (NetMode = NET_SERVER) then g_Net_Host_Update()
240 else if (NetMode = NET_CLIENT) then g_Net_Client_Update();
246 // server: send any accumulated outgoing data to clients
247 if NetMode = NET_SERVER then g_Net_Flush();
250 function ProcessMessage (): Boolean;
254 Time, Time_Delta: Int64;
260 Result := sys_HandleInput();
263 Time := GetTickCount64();
264 Time_Delta := Time-Time_Old;
268 if wNeedTimeReset then
272 wNeedTimeReset := false;
275 g_Map_ProfilersBegin();
276 g_Mons_ProfilersBegin();
278 t := Time_Delta div 28;
286 g_Map_ProfilersEnd();
287 g_Mons_ProfilersEnd();
289 if (gExit = EXIT_QUIT) then
295 // Время предыдущего обновления
297 Time_Old := Time - (Time_Delta mod 28);
299 // don't wait if VSync is on, GL already probably waits enough
301 flag := (Time - Frame >= gFrameTime) or gVSync;
305 if gPause or (not gLerpActors) or (gState = STATE_FOLD) then
308 gLerpFactor := nmin(1.0, (Time - Time_Old) / 28.0);
321 procedure DebugOptions;
326 {$IFDEF ENABLE_HOLMES}
332 while (idx <= ParamCount) do
334 arg := ParamStr(idx);
336 //if arg = '--twinkletwinkle' then gwin_k8_enable_light_experiments := true;
337 if arg = '--jah' then g_profile_history_size := 100;
338 if arg = '--no-los' then gmon_dbg_los_enabled := false;
340 if arg = '--profile-render' then g_profile_frame_draw := true;
341 if arg = '--profile-coldet' then g_profile_collision := true;
342 if arg = '--profile-los' then g_profile_los := true;
345 if arg = '--no-particles' then gpart_dbg_enabled := false;
346 if arg = '--no-part-phys' then gpart_dbg_phys_enabled := false;
347 if arg = '--no-part-physics' then gpart_dbg_phys_enabled := false;
348 if arg = '--no-particles-phys' then gpart_dbg_phys_enabled := false;
349 if arg = '--no-particles-physics' then gpart_dbg_phys_enabled := false;
350 if arg = '--no-particle-phys' then gpart_dbg_phys_enabled := false;
351 if arg = '--no-particle-physics' then gpart_dbg_phys_enabled := false;
354 if arg = '--debug-input' then g_dbg_input := True;
356 {.$IF DEFINED(D2F_DEBUG)}
357 if arg = '--aimline' then g_dbg_aimline_on := true;
360 {$IFDEF ENABLE_HOLMES}
361 if arg = '--holmes' then begin g_holmes_enabled := true; g_Game_SetDebugMode(); end;
363 if (arg = '--holmes-ui-scale') or (arg = '-holmes-ui-scale') then
365 if (idx <= ParamCount) then
367 if not conParseFloat(fuiRenderScale, ParamStr(idx)) then fuiRenderScale := 1.0;
372 if (arg = '--holmes-font') or (arg = '-holmes-font') then
374 if (idx <= ParamCount) then
377 val(ParamStr(idx), itmp, valres);
379 if (valres = 0) and (not g_holmes_imfunctional) then
382 8: uiContext.font := 'win8';
383 14: uiContext.font := 'win14';
384 16: uiContext.font := 'win16';
397 if (arg = '--game-scale') or (arg = '-game-scale') then
399 if (idx <= ParamCount) then
401 if not conParseFloat(g_dbg_scale, ParamStr(idx)) then g_dbg_scale := 1.0;
406 if (arg = '--write-mapdef') or (arg = '-write-mapdef') then
408 mdfo := createDiskFile('mapdef.txt');
409 mdfo.WriteBuffer(defaultMapDef[1], Length(defaultMapDef));
414 if (arg = '--pixel-scale') or (arg = '-pixel-scale') then
416 if (idx <= ParamCount) then
418 if not conParseFloat(r_pixel_scale, ParamStr(idx)) then r_pixel_scale := 1.0;
425 function GetBinaryPath (): AnsiString;
430 result := ExtractFilePath(ParamStr(0));
432 // it may be a symlink; do some guesswork here
433 sl := fpReadLink(ExtractFileName(ParamStr(0)));
434 if (sl = ParamStr(0)) then
436 // use current directory, as we don't have anything better
441 result := fixSlashes(result);
442 if (length(result) > 0) and (result[length(result)] <> '/') then
443 result := result + '/';
446 procedure PrintDirs (msg: AnsiString; dirs: SSArray);
449 e_LogWriteln(msg + ':');
451 e_LogWriteln(' ' + dir);
455 function NSStringToAnsiString (s: NSString): AnsiString;
459 for i := 0 to s.length - 1 do
460 result := result + AnsiChar(s.characterAtIndex(i));
463 function GetBundlePath (): AnsiString;
464 var pathRef: CFURLRef; pathCFStr: CFStringRef; pathStr: ShortString;
466 pathRef := CFBundleCopyBundleURL(CFBundleGetMainBundle());
467 pathCFStr := CFURLCopyFileSystemPath(pathRef, kCFURLPOSIXPathStyle);
468 CFStringGetPascalString(pathCFStr, @pathStr, 255, CFStringGetSystemEncoding());
470 CFRelease(pathCFStr);
476 var i: Integer; rwdir, rodir: AnsiString; rwdirs, rodirs: SSArray;
478 procedure AddDir (var dirs: SSArray; append: AnsiString);
480 SetLength(dirs, Length(dirs) + 1);
481 dirs[High(dirs)] := ExpandFileName(append)
484 function IsSep (ch: Char): Boolean;
487 result := (ch = '/') or (ch = '\');
489 result := (ch = '/');
493 function OptimizePath (dir: AnsiString): AnsiString;
494 var i, len: Integer; s: AnsiString;
496 i := 1; len := Length(dir); s := '';
499 if IsSep(dir[i]) then
501 s := s + DirectorySeparator;
503 while (i <= len) and IsSep(dir[i]) do Inc(i);
504 if (i <= len) and (dir[i] = '.') then
506 if (i = len) or IsSep(dir[i + 1]) then
510 else if (i + 1 <= len) and (dir[i + 1] = '.') then
512 if (i + 1 = len) or IsSep(dir[i + 2]) then
529 procedure OptimizeDirs (var dirs: SSArray);
530 var i, j, k: Integer;
532 for i := 0 to High(dirs) do
533 dirs[i] := OptimizePath(dirs[i]);
541 if dirs[j] = dirs[i] then
543 for k := j + 1 to High(dirs) do
544 dirs[k - 1] := dirs[k];
546 SetLength(dirs, High(dirs))
557 procedure AddDef (var dirs: SSArray; base: SSArray; append: AnsiString);
560 if Length(dirs) = 0 then
562 AddDir(dirs, e_CatPath(s, append));
566 function GetDefaultRODirs (): SSArray;
567 {$IF DEFINED(UNIX) AND NOT DEFINED(DARWIN) AND NOT DEFINED(ANDROID)}
568 var home: AnsiString;
571 var appdata: AnsiString;
574 var bundle, s: AnsiString; dirArr: NSArray; i: Integer;
579 bundle := GetBundlePath();
580 if ExtractFileExt(bundle) <> '.app' then
581 AddDir(result, binpath);
583 AddDir(result, binPath);
585 if forceBinDir = false then
588 AddDir(result, SDL_GetBasePath());
589 AddDir(result, SDL_GetPrefPath('', 'doom2df'));
592 appdata := GetEnvironmentVariable('APPDATA') + '\doom2df';
593 if appdata <> '' then
594 AddDir(result, appdata);
596 {$IF DEFINED(UNIX) AND NOT DEFINED(DARWIN) AND NOT DEFINED(ANDROID)}
597 AddDir(result, '/usr/share/doom2df');
598 AddDir(result, '/usr/local/share/doom2df');
599 home := GetEnvironmentVariable('HOME');
601 AddDir(result, e_CatPath(home, '.doom2df'));
604 bundle := GetBundlePath();
606 AddDir(result, e_CatPath(bundle, 'Contents/Resources'));
607 dirArr := NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, true);
608 for i := 0 to dirArr.count - 1 do
610 s := NSStringToAnsiString(dirArr.objectAtIndex(i));
611 AddDir(result, e_CatPath(s, 'Doom 2D Forever'))
614 {$IF DEFINED(ANDROID) AND DEFINED(USE_SDL2)}
615 AddDir(result, SDL_AndroidGetInternalStoragePath());
616 if SDL_AndroidGetExternalStorageState() <> 0 then
617 AddDir(result, SDL_AndroidGetExternalStoragePath());
622 function GetDefaultRWDirs (): SSArray;
623 {$IF DEFINED(UNIX) AND NOT DEFINED(DARWIN) AND NOT DEFINED(ANDROID)}
624 var home: AnsiString;
627 var appdata: AnsiString;
630 var bundle, s: AnsiString; dirArr: NSArray; i: Integer;
635 bundle := GetBundlePath();
636 if ExtractFileExt(bundle) <> '.app' then
637 AddDir(result, binPath);
639 AddDir(result, binPath);
641 if forceBinDir = false then
644 AddDir(result, SDL_GetPrefPath('', 'doom2df'));
647 appdata := GetEnvironmentVariable('APPDATA') + '\doom2df';
648 if appdata <> '' then
649 AddDir(result, appdata);
651 {$IF DEFINED(UNIX) AND NOT DEFINED(DARWIN) AND NOT DEFINED(ANDROID)}
652 home := GetEnvironmentVariable('HOME');
654 AddDir(result, e_CatPath(home, '.doom2df'));
657 dirArr := NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, true);
658 for i := 0 to dirArr.count - 1 do
660 s := NSStringToAnsiString(dirArr.objectAtIndex(i));
661 AddDir(result, e_CatPath(s, 'Doom 2D Forever'))
664 {$IF DEFINED(ANDROID) AND DEFINED(USE_SDL2)}
665 if SDL_AndroidGetExternalStorageState() <> 0 then
666 AddDir(result, SDL_AndroidGetExternalStoragePath());
672 forceBinDir := false;
673 binPath := GetBinaryPath();
676 while i < ParamCount do
679 '--like-windoze': forceBinDir := true;
683 rwdir := ParamStr(i);
685 AddDir(LogDirs, e_CatPath(rwdir, ''));
686 AddDir(SaveDirs, e_CatPath(rwdir, 'data'));
687 AddDir(CacheDirs, e_CatPath(rwdir, 'data/cache'));
688 AddDir(ConfigDirs, e_CatPath(rwdir, ''));
689 AddDir(MapDownloadDirs, e_CatPath(rwdir, 'maps/downloads'));
690 AddDir(WadDownloadDirs, e_CatPath(rwdir, 'wads/downloads'));
691 AddDir(ScreenshotDirs, e_CatPath(rwdir, 'screenshots'));
692 AddDir(StatsDirs, e_CatPath(rwdir, 'stats'));
694 AddDir(DataDirs, e_CatPath(rwdir, 'data'));
695 AddDir(ModelDirs, e_CatPath(rwdir, 'data/models'));
696 AddDir(MegawadDirs, e_CatPath(rwdir, 'maps/megawads'));
697 AddDir(MapDirs, e_CatPath(rwdir, 'maps'));
698 AddDir(WadDirs, e_CatPath(rwdir, 'wads'));
703 rodir := ParamStr(i);
705 AddDir(DataDirs, e_CatPath(rodir, 'data'));
706 AddDir(ModelDirs, e_CatPath(rodir, 'data/models'));
707 AddDir(MegawadDirs, e_CatPath(rodir, 'maps/megawads'));
708 AddDir(MapDirs, e_CatPath(rodir, 'maps'));
709 AddDir(WadDirs, e_CatPath(rodir, 'wads'));
714 GameWADName := ParamStr(i);
719 gConfigScript := ParamStr(i);
725 // prefer bin dir if it writable and contains game.wad
726 if forceBinDir = false then
728 if findDiskWad(binPath + 'data' + '/' + GameWADName) <> '' then
729 if e_CanCreateFilesAt(binPath) then
734 rodirs := GetDefaultRODirs();
735 AddDef(DataDirs, rodirs, 'data');
736 AddDef(ModelDirs, rodirs, 'data/models');
737 AddDef(MegawadDirs, rodirs, 'maps/megawads');
738 AddDef(MapDirs, rodirs, 'maps');
739 AddDef(WadDirs, rodirs, 'wads');
742 rwdirs := GetDefaultRWDirs();
743 AddDef(LogDirs, rwdirs, '');
744 AddDef(SaveDirs, rwdirs, 'data');
745 AddDef(CacheDirs, rwdirs, 'data/cache');
746 AddDef(ConfigDirs, rwdirs, '');
747 AddDef(MapDownloadDirs, rwdirs, 'maps/downloads');
748 AddDef(WadDownloadDirs, rwdirs, 'wads/downloads');
749 AddDef(ScreenshotDirs, rwdirs, 'screenshots');
750 AddDef(StatsDirs, rwdirs, 'stats');
752 for i := 0 to High(MapDirs) do
753 AddDir(AllMapDirs, MapDirs[i]);
754 for i := 0 to High(MegawadDirs) do
755 AddDir(AllMapDirs, MegawadDirs[i]);
756 OptimizeDirs(AllMapDirs);
758 // HACK: ensure the screenshots folder also has a stats subfolder in it
759 rwdir := e_GetWriteableDir(ScreenshotDirs, false);
760 if rwdir <> '' then CreateDir(rwdir + '/stats');
763 procedure EntryParams;
767 while i <= ParamCount do
770 '--gdb': noct := true;
771 '--log', '--con-stdout': conbufDumpToStdOut := true;
772 '--safe-log': e_SetSafeSlowLog(true);
774 if i + 1 <= ParamCount then
777 LogFileName := ParamStr(i)
779 '--no-fbo': glRenderToFBO := false;
786 var rwdir: AnsiString;
788 if LogFileName = '' then
790 rwdir := e_GetWriteableDir(LogDirs, false);
794 LogFileName := e_CatPath(rwdir, 'Doom2DF_H.log');
796 LogFileName := e_CatPath(rwdir, 'Doom2DF.log');
800 if LogFileName <> '' then
801 e_InitLog(LogFileName, TWriteMode.WM_NEWFILE);
806 {$IF DEFINED(ANDROID) AND DEFINED(USE_SDLMIXER)}
807 var timiditycfg: AnsiString;
810 e_WriteLog('Doom 2D: Forever version ' + GAME_VERSION + ' proto ' + IntToStr(NET_PROTOCOL_VER), TMsgType.Notify);
811 e_WriteLog('Build date: ' + GAME_BUILDDATE + ' ' + GAME_BUILDTIME, TMsgType.Notify);
812 e_WriteLog('Build hash: ' + g_GetBuildHash(), TMsgType.Notify);
813 e_WriteLog('Build by: ' + g_GetBuilderName(), TMsgType.Notify);
815 e_LogWritefln('Force bin dir: %s', [forceBinDir], TMsgType.Notify);
816 e_LogWritefln('BINARY PATH: [%s]', [binPath], TMsgType.Notify);
818 PrintDirs('DataDirs', DataDirs);
819 PrintDirs('ModelDirs', ModelDirs);
820 PrintDirs('MegawadDirs', MegawadDirs);
821 PrintDirs('MapDirs', MapDirs);
822 PrintDirs('WadDirs', WadDirs);
824 PrintDirs('LogDirs', LogDirs);
825 PrintDirs('SaveDirs', SaveDirs);
826 PrintDirs('CacheDirs', CacheDirs);
827 PrintDirs('ConfigDirs', ConfigDirs);
828 PrintDirs('ScreenshotDirs', ScreenshotDirs);
829 PrintDirs('StatsDirs', StatsDirs);
830 PrintDirs('MapDownloadDirs', MapDownloadDirs);
831 PrintDirs('WadDownloadDirs', WadDownloadDirs);
834 {$IFDEF USE_SDLMIXER}
835 NoSound := False; // hope env has set SDL_AUDIODRIVER to dummy
837 NoSound := True; // FMOD backend will sort it out
843 {$IF DEFINED(ANDROID) AND DEFINED(USE_SDLMIXER)}
844 timiditycfg := 'timidity.cfg';
845 if e_FindResource(ConfigDirs, timiditycfg) = true then
847 timiditycfg := ExpandFileName(timiditycfg);
848 SetEnvVar('TIMIDITY_CFG', timiditycfg);
849 e_LogWritefln('Set TIMIDITY_CFG = "%s"', [timiditycfg]);
853 GameWAD := e_FindWad(DataDirs, GameWADName);
856 e_WriteLog('WAD ' + GameWADName + ' not found in data directories.', TMsgType.Fatal);
857 {$IF DEFINED(USE_SDL2) AND NOT DEFINED(HEADLESS)}
858 if forceBinDir = false then
859 SDL_ShowSimpleMessageBox(
860 SDL_MESSAGEBOX_ERROR,
862 PChar('WAD ' + GameWADName + ' not found in data directories.'),
871 {$IFDEF ENABLE_HOLMES}
872 procedure InitHolmes;
873 var flexloaded: Boolean;
876 if not fuiAddWad('flexui.wad') then
878 if not fuiAddWad('./data/flexui.wad') then fuiAddWad('./flexui.wad');
881 fuiGfxLoadFont('win8', 'flexui/fonts/win8.fuifont');
882 fuiGfxLoadFont('win14', 'flexui/fonts/win14.fuifont');
883 fuiGfxLoadFont('win16', 'flexui/fonts/win16.fuifont');
884 fuiGfxLoadFont('dos8', 'flexui/fonts/dos8.fuifont');
885 fuiGfxLoadFont('msx6', 'flexui/fonts/msx6.fuifont');
886 except on e: Exception do
888 writeln('ERROR loading FlexUI fonts');
901 e_LogWriteln('FlexUI: loading stylesheet...');
902 uiLoadStyles('flexui/widgets.wgs');
903 except on e: TParserException do
905 writeln('ERROR at (', e.tokLine, ',', e.tokCol, '): ', e.message);
916 g_holmes_imfunctional := not flexloaded;
917 if not g_holmes_imfunctional then
920 uiContext.font := 'win14';
922 if assigned(oglInitCB) then oglInitCB;
925 procedure FreeHolmes;
927 if assigned(oglDeinitCB) then
932 procedure ScreenResize (w, h: Integer);
935 r_Render_Resize(w, h);
936 {$IFDEF ENABLE_HOLMES}
941 (* This will fix menu reset on keyboard showing *)
946 //g_Game_ClearLoading;
947 {$IFDEF ENABLE_HOLMES}
948 if assigned(oglInitCB) then oglInitCB;
960 e_InitSoundSystem(NoSound);
963 sys_CharPress := @CharPress; (* install hook *)
964 sys_ScreenResize := @ScreenResize; (* install hook *)
966 g_Options_SetDefault;
967 g_Options_SetDefaultVideo;
968 g_Console_Initialize;
969 // TODO move load configs here
970 g_Language_Set(gLanguage);
976 // TODO init serverlist
977 {$IFDEF ENABLE_HOLMES}
981 g_PlayerModel_LoadFake('doomer', 'doomer.wad');
983 g_PlayerModel_LoadAll;
991 g_Game_Process_Params;
992 // TODO reload GAME textures
993 g_Console_Init; // welcome message
995 if (not gGameOn) and gAskLanguage then
998 Time_Old := GetTickCount64();
999 while not ProcessMessage() do begin end;
1000 g_Console_WriteGameConfig;
1001 {$IFDEF ENABLE_MENU}
1008 {$IFDEF ENABLE_HOLMES}
1011 g_Net_Slist_ShutdownAll;
1012 g_Net_DeinitLowLevel;
1013 (* g_Touch_Finalize; *)
1019 e_ReleaseSoundSystem;
1021 e_WriteLog('Shutdown with no errors.', TMsgType.Notify)
1024 procedure EntryPoint;
1026 SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); //k8: fuck off, that's why
1030 conbufDumpToStdOut := true;
1037 except on e: Exception do
1038 e_WriteStackTrace(e.message)
1040 e_WriteStackTrace('FATAL ERROR')
1046 function SDL_main (argc: CInt; argv: PPChar): CInt; cdecl;
1048 // TODO pass argc+argv to rtl
1053 function JNI_OnLoad (vm: PJavaVM; reserved: pointer): JInt; cdecl;
1055 result:= JNI_VERSION_1_6;
1058 procedure JNI_OnUnload(vm: PJavaVM; reserved: pointer); cdecl;
1062 // DONT REMOVE JNI FUNCTIONS. SPECIAL HANDLING BY FPC.
1063 exports SDL_main name 'SDL_main';
1064 exports JNI_OnLoad name 'JNI_OnLoad';
1065 exports JNI_OnUnload name 'JNI_Unload';