DEADSOFTWARE

buffer network messages (broke a lot of shit)
[d2df-sdl.git] / src / game / g_window.pas
index 6dfa778096ff33f616b553c00539c81b542227fd..a8c6b6a7b3c3bf8302e95d712e2a2b875750359a 100644 (file)
@@ -13,7 +13,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *)
-{$MODE DELPHI}
+{$INCLUDE g_amodes.inc}
 unit g_window;
 
 interface
@@ -39,6 +39,7 @@ function  g_Window_SetSize(W, H: Word; FScreen: Boolean): Boolean;
 var
   gwin_dump_extensions: Boolean = false;
   gwin_has_stencil: Boolean = false;
+  gwin_k8_enable_light_experiments: Boolean = false;
 
 implementation
 
@@ -544,10 +545,17 @@ begin
   e_SoundUpdate();
 
   if NetMode = NET_SERVER then
-    g_Net_Host_Update
-  else
-    if (NetMode = NET_CLIENT) and (NetState <> NET_STATE_AUTH) then
-      g_Net_Client_UpdateWhileLoading;
+  begin
+    g_Net_Host_Update();
+    g_Net_Flush();
+  end
+  else if NetMode = NET_CLIENT then
+    if (NetState <> NET_STATE_AUTH) then
+    begin
+      g_Net_Client_UpdateWhileLoading();
+      g_Net_Flush();
+    end;
+
   wLoadingProgress := False;
 end;
 
@@ -585,12 +593,14 @@ begin
       if NetMode = NET_SERVER then g_Net_Host_Update()
       else if NetMode = NET_CLIENT then g_Net_Client_Update();
       Update();
+      if NetMode <> NET_NONE then g_Net_Flush();
     end;
   end
-  else
+  else if NetMode <> NET_NONE then
   begin
     if NetMode = NET_SERVER then g_Net_Host_Update()
     else if NetMode = NET_CLIENT then g_Net_Client_Update();
+    g_Net_Flush();
   end;
 
   if wLoadingQuit then
@@ -641,7 +651,10 @@ begin
   SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
   SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
   SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-  SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1); // lights; it is enough to have 1-bit stencil buffer for lighting
+  if gwin_k8_enable_light_experiments then
+  begin
+    SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1); // lights; it is enough to have 1-bit stencil buffer for lighting
+  end;
   SDL_GL_SetSwapInterval(v);
 end;
 
@@ -695,6 +708,12 @@ begin
   e_NoGraphics := True;
 {$ENDIF}
 
+  for idx := 1 to ParamCount do
+  begin
+    if ParamStr(idx) = '--opengl-dump-exts' then gwin_dump_extensions := true;
+    if ParamStr(idx) = '--twinkletwinkle' then gwin_k8_enable_light_experiments := true;
+  end;
+
   e_WriteLog('Initializing OpenGL', MSG_NOTIFY);
   InitOpenGL(gVSync);
 
@@ -707,16 +726,17 @@ begin
 
   {EnumDisplayModes();}
 
-  for idx := 1 to ParamCount do
+  if gwin_k8_enable_light_experiments then
   begin
-    if ParamStr(idx) = '--opengl-dump-exts' then gwin_dump_extensions := true;
+    SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, @ltmp);
+    e_WriteLog(Format('stencil buffer size: %d', [ltmp]), MSG_WARNING);
+    gwin_has_stencil := (ltmp > 0);
+  end
+  else
+  begin
+    gwin_has_stencil := false;
   end;
 
-  SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, @ltmp);
-  e_WriteLog(Format('stencil buffer size: %d', [ltmp]), MSG_WARNING);
-
-  gwin_has_stencil := (ltmp > 0);
-
   if not glHasExtension('GL_ARB_texture_non_power_of_two') then
   begin
     e_WriteLog('Driver DID''T advertised NPOT textures support', MSG_WARNING);