DEADSOFTWARE

fixed build bug in headless server (lol, i am dumb)
[d2df-sdl.git] / src / game / g_window.pas
index 52363d007e9b541009b4f5f26439203ab2ba8ff3..7e10326fcac23295aea2842cebc0d9a0e21a8f09 100644 (file)
@@ -47,8 +47,9 @@ implementation
 
 uses
 {$IFDEF WINDOWS}Windows,{$ENDIF}
-  SDL2, GL, GLExt, e_graphics, e_log, g_main,
-  g_console, SysUtils, e_input, g_options, g_game,
+  SysUtils, Classes, MAPDEF,
+  SDL2, GL, GLExt, e_graphics, e_log, e_texture, g_main,
+  g_console, e_input, g_options, g_game,
   g_basic, g_textures, e_sound, g_sound, g_menu, ENet, g_net,
   g_map, g_gfx, g_monsters, g_holmes, xprofiler, utils;
 
@@ -630,11 +631,11 @@ begin
   begin
     if forceUpdate then
     begin
-      prevLoadingUpdateTime := curTimeMilli();
+      prevLoadingUpdateTime := getTimeMilli();
     end
     else
     begin
-      stt := curTimeMilli();
+      stt := getTimeMilli();
       if (stt < prevLoadingUpdateTime) or (stt-prevLoadingUpdateTime >= 400) then
       begin
         prevLoadingUpdateTime := stt;
@@ -822,6 +823,7 @@ var
   idx: Integer;
   ltmp: Integer;
   arg: AnsiString;
+  mdfo: TStream;
 begin
 {$IFDEF HEADLESS}
   e_NoGraphics := True;
@@ -863,7 +865,6 @@ begin
       end;
     end;
 
-    {$IF DEFINED(D2F_DEBUG)}
     if (arg = '--game-scale') or (arg = '-game-scale') then
     begin
       if (idx <= ParamCount) then
@@ -872,7 +873,14 @@ begin
         Inc(idx);
       end;
     end;
-    {$ENDIF}
+
+    if (arg = '--write-mapdef') or (arg = '-write-mapdef') then
+    begin
+      mdfo := createDiskFile('mapdef.txt');
+      mdfo.WriteBuffer(defaultMapDef[1], Length(defaultMapDef));
+      mdfo.Free();
+      Halt(0);
+    end;
   end;
 
   e_WriteLog('Initializing OpenGL', MSG_NOTIFY);
@@ -887,6 +895,12 @@ begin
 
   {EnumDisplayModes();}
 
+  {$IFDEF HEADLESS}
+  gwin_k8_enable_light_experiments := false;
+  gwin_has_stencil := false;
+  glLegacyNPOT := false;
+  gwin_dump_extensions := false;
+  {$ELSE}
   if gwin_k8_enable_light_experiments then
   begin
     SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, @ltmp);
@@ -909,6 +923,7 @@ begin
     glLegacyNPOT := false;
   end;
   gwin_dump_extensions := false;
+  {$ENDIF}
 
   Init();
   Time_Old := GetTimer();