DEADSOFTWARE

added temporary hack for cyclic switching (remove it after readyweaon&pendinweapon...
[d2df-sdl.git] / src / game / g_game.pas
index 06afe8e3c5190102f67d0ee515b033f128e1dc13..b3c00635e29cf462295f45fcda3138c89d2f9414 100644 (file)
@@ -23,7 +23,7 @@ uses
   MAPDEF,
   g_basic, g_player, e_graphics, g_res_downloader,
   g_sound, g_gui, utils, md5, mempool, xprofiler,
-  g_touch;
+  g_touch, g_weapons;
 
 type
   TGameSettings = record
@@ -325,6 +325,7 @@ var
   gDelayedEvents: Array of TDelayedEvent;
   gUseChatSounds: Boolean = True;
   gChatSounds: Array of TChatSound;
+  gSelectWeapon: Array [0..1, WP_FIRST..WP_LAST] of Boolean; // [player, weapon]
 
   g_dbg_ignore_bounds: Boolean = false;
   r_smallmap_h: Integer = 0; // 0: left; 1: center; 2: right
@@ -372,7 +373,7 @@ uses
 {$ENDIF}
   e_texture, g_textures, g_main, g_window, g_menu,
   e_input, e_log, g_console, g_items, g_map, g_panel,
-  g_playermodel, g_gfx, g_options, g_weapons, Math,
+  g_playermodel, g_gfx, g_options, Math,
   g_triggers, g_monsters, e_sound, CONFIG,
   g_language, g_net,
   ENet, e_msg, g_netmsg, g_netmaster,
@@ -381,7 +382,6 @@ uses
 
 var
   hasPBarGfx: Boolean = false;
-  nextQueueWeapon: Array [0..1] of Integer = (-1, -1); // [player]
 
 
 // ////////////////////////////////////////////////////////////////////////// //
@@ -1504,6 +1504,7 @@ procedure ProcessPlayerControls (plr: TPlayer; p: Integer; var MoveButton: Byte)
   var
     time: Word;
     strafeDir: Byte;
+    i: Integer;
 begin
   if (plr = nil) then exit;
   if (p = 2) then time := 1000 else time := 1;
@@ -1561,10 +1562,16 @@ begin
   if gPlayerAction[p, ACTION_WEAPPREV] then plr.PressKey(KEY_PREVWEAPON);
   if gPlayerAction[p, ACTION_ACTIVATE] then plr.PressKey(KEY_OPEN);
 
-  if nextQueueWeapon[p] >= 0 then
+  gPlayerAction[p, ACTION_WEAPNEXT] := False; // HACK, remove after readyweaon&pendinweapon implementation
+  gPlayerAction[p, ACTION_WEAPPREV] := False; // HACK, remove after readyweaon&pendinweapon implementation
+
+  for i := WP_FIRST to WP_LAST do
   begin
-    plr.QueueWeaponSwitch(nextQueueWeapon[p]);
-    nextQueueWeapon[p] := -1
+    if gSelectWeapon[p, i] then
+    begin
+      plr.QueueWeaponSwitch(i); // all choices are passed there, and god will take the best
+      gSelectWeapon[p, i] := False
+    end
   end;
 
   // HACK: add dynlight here
@@ -1668,7 +1675,9 @@ begin
           (
             (
               e_KeyPressed(IK_RETURN) or e_KeyPressed(IK_KPRETURN) or e_KeyPressed(IK_SPACE) or
-              e_KeyPressed(VK_FIRE) or e_KeyPressed(VK_OPEN)
+              e_KeyPressed(VK_FIRE) or e_KeyPressed(VK_OPEN) or
+              e_KeyPressed(JOY0_ATTACK) or e_KeyPressed(JOY1_ATTACK) or
+              e_KeyPressed(JOY2_ATTACK) or e_KeyPressed(JOY3_ATTACK)
             )
             and (not gJustChatted) and (not gConsoleShow) and (not gChatShow)
             and (g_ActiveWindow = nil)
@@ -4640,7 +4649,7 @@ begin
 
     ProcessLoading(true);
 
-    if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) or e_KeyPressed(VK_ESCAPE) then
+    if e_KeyPressed(IK_SPACE) or e_KeyPressed(VK_ESCAPE) then
     begin
       State := 0;
       break;
@@ -5154,18 +5163,7 @@ var
 begin
   stat := nil;
   cmd := LowerCase(P[0]);
-  if cmd = 'r_showfps' then
-  begin
-    if (Length(P) > 1) and
-       ((P[1] = '1') or (P[1] = '0')) then
-      gShowFPS := (P[1][1] = '1');
-
-    if gShowFPS then
-      g_Console_Add(_lc[I_MSG_SHOW_FPS_ON])
-    else
-      g_Console_Add(_lc[I_MSG_SHOW_FPS_OFF]);
-  end
-  else if (cmd = 'g_friendlyfire') and not g_Game_IsClient then
+  if (cmd = 'g_friendlyfire') and not g_Game_IsClient then
   begin
     with gGameSettings do
     begin
@@ -5813,11 +5811,6 @@ begin
 
       g_Console_Add(Format(cmd + ' is %d', [Byte(g_Debug_Player)]));
     end
-    else if (cmd = 'd_joy') then
-    begin
-      for a := 1 to 8 do
-        g_Console_Add(e_JoystickStateToString(a));
-    end
     else if (cmd = 'd_mem') then
     begin
       PrintHeapStats();
@@ -6834,7 +6827,7 @@ begin
     begin
       a := WP_FIRST + StrToInt(p[1]) - 1;
       if (a >= WP_FIRST) and (a <= WP_LAST) then
-        nextQueueWeapon[0] := a
+        gSelectWeapon[0, a] := True
     end
   end
   else if (cmd = 'p1_weapon') or (cmd = 'p2_weapon') then
@@ -6844,7 +6837,7 @@ begin
       a := WP_FIRST + StrToInt(p[1]) - 1;
       b := ord(cmd[2]) - ord('1');
       if (a >= WP_FIRST) and (a <= WP_LAST) then
-        nextQueueWeapon[b] := a
+        gSelectWeapon[b, a] := True
     end
   end
 // Êîìàíäû Ñâîåé èãðû:
@@ -7863,4 +7856,6 @@ begin
 
   conRegVar('r_smallmap_align_h', @r_smallmap_h, 'halign: 0: left; 1: center; 2: right', 'horizontal aligning of small maps');
   conRegVar('r_smallmap_align_v', @r_smallmap_v, 'valign: 0: top; 1: center; 2: bottom', 'vertial aligning of small maps');
+
+  conRegVar('r_showfps', @gShowFPS, 'draw fps counter', 'draw fps counter');
 end.