summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c1f5ac1)
raw | patch | inline | side by side (parent: c1f5ac1)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 4 Jan 2019 19:58:37 +0000 (22:58 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 4 Jan 2019 19:58:37 +0000 (22:58 +0300) |
src/game/g_game.pas | patch | blob | history | |
src/game/g_player.pas | patch | blob | history | |
src/game/g_window.pas | patch | blob | history |
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 972f268810ca4c5a3fe949186dcb4f78bd760ff2..1fdf62b2ab96e5d7cc16ce0880d91f1078732f43 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
result := false;
end;
-function isOneKeyPressed (key1: Word): Boolean;
-begin
- if (key1 <> 0) and e_KeyPressed(key1) then begin result := true; exit; end;
- result := false;
-end;
-
procedure processPlayerControls (plr: TPlayer; var ctrl: TPlayerControl; var MoveButton: Byte; p2hack: Boolean=false);
var
time: Word;
strafeDir: Byte;
i: Integer;
- rwk: Boolean;
begin
if (plr = nil) then exit;
if (p2hack) then time := 1000 else time := 1;
if isKeyPressed(KeyUp, KeyUp2) then plr.PressKey(KEY_UP, time);
if isKeyPressed(KeyDown, KeyDown2) then plr.PressKey(KEY_DOWN, time);
if isKeyPressed(KeyFire, KeyFire2) then plr.PressKey(KEY_FIRE);
- if isKeyPressed(KeyNextWeapon, KeyNextWeapon2) then
- begin
- rwk := plr.isWeaponSwitchKeyReleased(-1);
- if rwk then plr.PressKey(KEY_NEXTWEAPON);
- plr.weaponSwitchKeysStateChange(-1, true);
- end
- else
- begin
- plr.weaponSwitchKeysStateChange(-1, false);
- end;
- if isKeyPressed(KeyPrevWeapon, KeyPrevWeapon2) then
- begin
- rwk := plr.isWeaponSwitchKeyReleased(-2);
- if rwk then plr.PressKey(KEY_PREVWEAPON);
- plr.weaponSwitchKeysStateChange(-2, true);
- end
- else
- begin
- plr.weaponSwitchKeysStateChange(-2, false);
- end;
+ if isKeyPressed(KeyNextWeapon, KeyNextWeapon2) then plr.PressKey(KEY_NEXTWEAPON);
+ if isKeyPressed(KeyPrevWeapon, KeyPrevWeapon2) then plr.PressKey(KEY_PREVWEAPON);
if isKeyPressed(KeyOpen, KeyOpen2) then plr.PressKey(KEY_OPEN);
for i := 0 to High(KeyWeapon) do
- begin
if isKeyPressed(KeyWeapon[i], KeyWeapon2[i]) then
- begin
- rwk := plr.isWeaponSwitchKeyReleased(i);
- //writeln('rwk:', rwk);
- plr.weaponSwitchKeysStateChange(i, true);
- if rwk then plr.QueueWeaponSwitch(i); // all choices are passed there, and god will take the best
- end
- else
- begin
- plr.weaponSwitchKeysStateChange(i, false);
- end;
- end;
+ plr.QueueWeaponSwitch(i); // all choices are passed there, and god will take the best
end;
// HACK: add dynlight here
diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index 137ab818e6c4d7bbee6ec089ca7abb7c72c12dd5..5dd29a6c4633bd97984551f7f9ae6f93665b5397 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
FSecrets: Integer;
FCurrWeap: Byte;
FNextWeap: WORD;
- FNextWeapDelay: Byte; // frames (unused)
+ FNextWeapDelay: Byte; // frames
FBFGFireCounter: SmallInt;
FLastSpawnerUID: Word;
FLastHit: Byte;
FNetTime: LongWord;
mEDamageType: Integer;
- // client-side only
- weaponSwitchKeyReleased: array[0..16] of Boolean; // true: was release
-
function CollideLevel(XInc, YInc: Integer): Boolean;
function StayOnStep(XInc, YInc: Integer): Boolean;
procedure getMapBox (out x, y, w, h: Integer); inline;
procedure moveBy (dx, dy: Integer); inline;
- procedure releaseAllWeaponSwitchKeys ();
- procedure weaponSwitchKeysStateChange (index: Integer; pressed: Boolean);
- function isWeaponSwitchKeyReleased (index: Integer): Boolean;
-
public
property Vel: TPoint2i read FObj.Vel;
property Obj: TObj read FObj;
FNetTime := 0;
resetWeaponQueue();
- releaseAllWeaponSwitchKeys();
-end;
-
-
-procedure TPlayer.releaseAllWeaponSwitchKeys ();
-var
- f: Integer;
-begin
- for f := 0 to High(weaponSwitchKeyReleased) do weaponSwitchKeyReleased[f] := true;
-end;
-
-procedure TPlayer.weaponSwitchKeysStateChange (index: Integer; pressed: Boolean);
-begin
- Inc(index, 2); // -2: prev; -1: next
- if (index < 0) or (index > High(weaponSwitchKeyReleased)) then exit;
- weaponSwitchKeyReleased[index] := not pressed;
end;
-function TPlayer.isWeaponSwitchKeyReleased (index: Integer): Boolean;
-begin
- Inc(index, 2); // -2: prev; -1: next
- if (index < 0) or (index > High(weaponSwitchKeyReleased)) then
- begin
- result := true;
- end
- else
- begin
- result := weaponSwitchKeyReleased[index];
- end;
-end;
-
-
procedure TPlayer.positionChanged (); inline;
begin
end;
begin
//e_WriteLog(Format(' SWITCH: cur=%d; new=%d (dir=%d; log=%d)', [FCurrWeap, rwidx, dir, cwi]), TMsgType.Warning);
result := Byte(rwidx);
- //FNextWeapDelay := 10; //k8: not needed anymore
+ FNextWeapDelay := 10;
exit;
end;
end;
// i found her!
result := Byte(rwidx);
resetWeaponQueue();
- //FNextWeapDelay := 10; // anyway, 'cause why not; k8: not needed anymore
+ FNextWeapDelay := 10; // anyway, 'cause why not
exit;
end;
end;
begin
//e_WriteLog(Format('***RealizeCurrentWeapon: FNextWeap=%x; FNextWeapDelay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
//FNextWeap := FNextWeap and $1FFF;
- //HACK: alteration delay will be reset when player released any weapon switch key
- FNextWeapDelay := 0; //k8: just in case
- //if FNextWeapDelay > 0 then Dec(FNextWeapDelay); // "alteration delay"
+ if FNextWeapDelay > 0 then Dec(FNextWeapDelay); // "alteration delay"
if not switchAllowed then
begin
diff --git a/src/game/g_window.pas b/src/game/g_window.pas
index 8336ea9b82cb39b11cd0b5b95c8e992e8cc3b0dd..3958d24d12df79b518b6dc351942a53d487acc52 100644 (file)
--- a/src/game/g_window.pas
+++ b/src/game/g_window.pas
SDL_WINDOWEVENT_MINIMIZED:
begin
e_UnpressAllKeys();
- if (gPlayer1 <> nil) then gPlayer1.releaseAllWeaponSwitchKeys();
- if (gPlayer2 <> nil) then gPlayer2.releaseAllWeaponSwitchKeys();
if not wMinimized then
begin
e_ResizeWindow(0, 0);
begin
wDeactivate := true;
e_UnpressAllKeys();
- if (gPlayer1 <> nil) then gPlayer1.releaseAllWeaponSwitchKeys();
- if (gPlayer2 <> nil) then gPlayer2.releaseAllWeaponSwitchKeys();
//e_WriteLog('window lost focus!', MSG_NOTIFY);
end;
end;