summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4de34c0)
raw | patch | inline | side by side (parent: 4de34c0)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 10 Apr 2019 16:03:56 +0000 (19:03 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 10 Apr 2019 16:03:56 +0000 (19:03 +0300) |
src/game/g_game.pas | patch | blob | history | |
src/game/g_netmsg.pas | patch | blob | history |
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index df564347985c186103783938645e2ad44d63e28f..114c692242e50d3b5213bb7639579c7d324540ff 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
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
gDelayedEvents: Array of TDelayedEvent;
gUseChatSounds: Boolean = True;
gChatSounds: Array of TChatSound;
- gSelectWeapon: Array [0..1] of Integer = (-1, -1); // [player]
+ 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
{$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,
@@ -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;
if gPlayerAction[p, ACTION_WEAPPREV] then plr.PressKey(KEY_PREVWEAPON);
if gPlayerAction[p, ACTION_ACTIVATE] then plr.PressKey(KEY_OPEN);
- if gSelectWeapon[p] >= 0 then
+ for i := WP_FIRST to WP_LAST do
begin
- plr.QueueWeaponSwitch(gSelectWeapon[p]);
- gSelectWeapon[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
begin
a := WP_FIRST + StrToInt(p[1]) - 1;
if (a >= WP_FIRST) and (a <= WP_LAST) then
- gSelectWeapon[0] := a
+ gSelectWeapon[0, a] := True
end
end
else if (cmd = 'p1_weapon') or (cmd = 'p2_weapon') then
a := WP_FIRST + StrToInt(p[1]) - 1;
b := ord(cmd[2]) - ord('1');
if (a >= WP_FIRST) and (a <= WP_LAST) then
- gSelectWeapon[b] := a
+ gSelectWeapon[b, a] := True
end
end
// Êîìàíäû Ñâîåé èãðû:
diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas
index e84d82965bcc48850e4d971a28234fb4adbf7a18..1bb60c2d53a4aa234445cb1e56a8090f677b1c35 100644 (file)
--- a/src/game/g_netmsg.pas
+++ b/src/game/g_netmsg.pas
Predict: Boolean;
strafeDir: Byte;
WeaponSelect: Word = 0;
+ i: Integer;
begin
if not gGameOn then Exit;
if gPlayers = nil then Exit;
if gPlayerAction[0, ACTION_WEAPNEXT] then kByte := kByte or NET_KEY_NW;
if gPlayerAction[0, ACTION_WEAPPREV] then kByte := kByte or NET_KEY_PW;
- if gSelectWeapon[0] >= 0 then
+ for i := WP_FIRST to WP_LAST do
begin
- WeaponSelect := gSelectWeapon[0];
- //gSelectWeapon[0] := -1
+ if gSelectWeapon[0, i] then
+ begin
+ WeaponSelect := WeaponSelect or Word(1 shl i);
+ gSelectWeapon[0, i] := False
+ end
end;
// fix movebutton state