From: Ketmar Dark Date: Sun, 6 Aug 2017 03:19:41 +0000 (+0300) Subject: network code for weapon queue (and protocol version bump) X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=9721d912b4bde1ba7d3dee7625612f80b73fe924;p=d2df-sdl.git network code for weapon queue (and protocol version bump) --- diff --git a/src/game/g_net.pas b/src/game/g_net.pas index 1b7a503..e935fc9 100644 --- a/src/game/g_net.pas +++ b/src/game/g_net.pas @@ -22,7 +22,7 @@ uses e_log, e_fixedbuffer, ENet, Classes; const - NET_PROTOCOL_VER = 168; + NET_PROTOCOL_VER = 169; NET_MAXCLIENTS = 24; NET_CHANS = 11; diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas index 6e8106f..839e642 100644 --- a/src/game/g_netmsg.pas +++ b/src/game/g_netmsg.pas @@ -430,7 +430,8 @@ end; function MH_RECV_PlayerPos(C: pTNetClient; P: Pointer): Word; var - Dir, WeaponSelect: Byte; + Dir, i: Byte; + WeaponSelect: Word; PID: Word; kByte: Word; Pl: TPlayer; @@ -452,7 +453,7 @@ begin NetTime := GT; kByte := e_Raw_Read_Word(P); Dir := e_Raw_Read_Byte(P); - WeaponSelect := e_Raw_Read_Byte(P); + WeaponSelect := e_Raw_Read_Word(P); if Direction <> TDirection(Dir) then JustTeleported := False; @@ -475,8 +476,7 @@ begin if LongBool(kByte and NET_KEY_NW) then PressKey(KEY_NEXTWEAPON, 10000); if LongBool(kByte and NET_KEY_PW) then PressKey(KEY_PREVWEAPON, 10000); - if WeaponSelect <> 255 then - QueueWeaponSwitch(WeaponSelect); + for i := 0 to 15 do if (WeaponSelect and (1 shl i)) <> 0 then QueueWeaponSwitch(i); end; // MH_SEND_PlayerPos(False, PID, C^.ID); @@ -2787,7 +2787,7 @@ var kByte: Word; Predict: Boolean; strafeDir: Byte; - WeaponSelect: Byte = 255; + WeaponSelect: Word = 0; I: Integer; begin if not gGameOn then Exit; @@ -2855,7 +2855,7 @@ begin if isKeyPressed(KeyPrevWeapon, KeyPrevWeapon2) then kByte := kByte or NET_KEY_PW; for I := 0 to High(KeyWeapon) do if isKeyPressed(KeyWeapon[I], KeyWeapon2[I]) then - WeaponSelect := I; + WeaponSelect := WeaponSelect or Word(1 shl I); end; // fix movebutton state P1MoveButton := P1MoveButton or (strafeDir shl 4);