DEADSOFTWARE

render: separate game logic and drawing
[d2df-sdl.git] / src / game / g_main.pas
index 6e393b262f29152ce225cb4698b108970389a58f..e9ef05564104437196181c0d29b222cef99dbdce 100644 (file)
@@ -71,7 +71,7 @@ uses
   e_sound, g_options, g_sound, g_player, g_basic,
   g_weapons, SysUtils, g_triggers, MAPDEF, g_map, e_res,
   g_menu, g_language, g_net, g_touch, g_system, g_res_downloader,
-  conbuf, envvars,
+  conbuf, envvars, r_game,
   xparser;
 
 
@@ -372,6 +372,11 @@ begin
         Inc(i);
         GameWADName := ParamStr(i);
       end;
+    '--config':
+      begin
+        Inc(i);
+        gConfigScript := ParamStr(i);
+      end;
     end;
     Inc(i)
   end;
@@ -438,10 +443,9 @@ begin
   {$ENDIF}
   for i := 1 to ParamCount do
   begin
-    if (ParamStr(i) = '--con-stdout') then
-    begin
-      conbufDumpToStdOut := true;
-      break
+    case ParamStr(i) of
+      '--con-stdout': conbufDumpToStdOut := true;
+      '--no-fbo': glRenderToFBO := false;
     end
   end;
 
@@ -503,7 +507,6 @@ procedure Main();
 {$IFDEF ENABLE_HOLMES}
   var flexloaded: Boolean;
 {$ENDIF}
-  var s: AnsiString;
 begin
   InitPath;
   InitPrep;
@@ -512,9 +515,6 @@ begin
 
   g_Options_SetDefault;
   g_Options_SetDefaultVideo;
-  s := CONFIG_FILENAME;
-  if e_FindResource(ConfigDirs, s) = true then
-    g_Options_Read(s);
   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.');
@@ -647,13 +647,22 @@ end;
 
 procedure Update ();
 begin
+  // remember old mobj positions, prepare for update
+  g_Game_PreUpdate();
+  // server: receive client commands for new frame
+  // client: receive game state changes from server
+       if (NetMode = NET_SERVER) then g_Net_Host_Update()
+  else if (NetMode = NET_CLIENT) then g_Net_Client_Update();
+  // think
   g_Game_Update();
+  // server: send any accumulated outgoing data to clients
+  if NetMode = NET_SERVER then g_Net_Flush();
 end;
 
 
 procedure Draw ();
 begin
-  g_Game_Draw();
+  r_Game_Draw();
 end;