DEADSOFTWARE

buffer network messages (broke a lot of shit)
[d2df-sdl.git] / src / game / g_game.pas
index 206d6e4d8301b561a14fb27b460731e9e78ad84c..36b1016abb6720dab7e7006448c8ef2ad7e966c5 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_game;
 
 interface
@@ -341,6 +341,7 @@ procedure g_ResetDynlights ();
 var
   lnum, idx: Integer;
 begin
+  if not gwin_has_stencil then begin g_dynLightCount := 0; exit; end;
   lnum := 0;
   for idx := 0 to g_dynLightCount-1 do
   begin
@@ -367,6 +368,7 @@ end;
 
 procedure g_AddDynLight (x, y, radius: Integer; r, g, b, a: Single);
 begin
+  if not gwin_has_stencil then exit;
   if g_dynLightCount = length(g_dynLights) then SetLength(g_dynLights, g_dynLightCount+1024);
   g_dynLights[g_dynLightCount].x := x;
   g_dynLights[g_dynLightCount].y := y;
@@ -381,6 +383,7 @@ end;
 
 procedure g_DynLightExplosion (x, y, radius: Integer; r, g, b: Single);
 begin
+  if not gwin_has_stencil then exit;
   if g_dynLightCount = length(g_dynLights) then SetLength(g_dynLights, g_dynLightCount+1024);
   g_dynLights[g_dynLightCount].x := x;
   g_dynLights[g_dynLightCount].y := y;
@@ -394,6 +397,7 @@ begin
   Inc(g_dynLightCount);
 end;
 
+
 type
   TEndCustomGameStat = record
     PlayerStat: TPlayerStatArray;
@@ -1361,16 +1365,19 @@ begin
   end;
 
   // HACK: add dynlight here
-  if e_KeyPressed(IK_F8) and gGameOn and (not gConsoleShow) and (g_ActiveWindow = nil) then
-  begin
-    g_playerLight := true;
-  end;
-  if e_KeyPressed(IK_F9) and gGameOn and (not gConsoleShow) and (g_ActiveWindow = nil) then
+  if gwin_k8_enable_light_experiments then
   begin
-    g_playerLight := false;
+    if e_KeyPressed(IK_F8) and gGameOn and (not gConsoleShow) and (g_ActiveWindow = nil) then
+    begin
+      g_playerLight := true;
+    end;
+    if e_KeyPressed(IK_F9) and gGameOn and (not gConsoleShow) and (g_ActiveWindow = nil) then
+    begin
+      g_playerLight := false;
+    end;
   end;
 
-  if (g_playerLight) then g_AddDynLight(plr.GameX+32, plr.GameY+40, 128, 1, 1, 0, 0.6);
+  if gwin_has_stencil and g_playerLight then g_AddDynLight(plr.GameX+32, plr.GameY+40, 128, 1, 1, 0, 0.6);
 end;
 
 procedure g_Game_Update();
@@ -3632,6 +3639,7 @@ var
   State: Byte;
   OuterLoop: Boolean;
   newResPath: string;
+  Len: Word;
 begin
   g_Game_Free();
 
@@ -3681,6 +3689,7 @@ begin
         Ptr := NetEvent.packet^.data;
         e_Raw_Seek(0);
 
+        Len := e_Raw_Read_Word(Ptr);
         MID := e_Raw_Read_Byte(Ptr);
 
         if (MID = NET_MSG_INFO) and (State = 0) then
@@ -3787,7 +3796,7 @@ begin
 
   g_Player_Init();
   NetState := NET_STATE_GAME;
-  MC_SEND_FullStateRequest;
+  MC_SEND_FullStateRequest();
   e_WriteLog('NET: Connection successful.', MSG_NOTIFY);
 end;