From: Ketmar Dark Date: Sun, 30 Sep 2018 14:48:50 +0000 (+0300) Subject: Revert "no more delay between weapon switching: now player should release switching... X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=commitdiff_plain;h=aea87456d131c418ed632d30b57280dfeefe16de Revert "no more delay between weapon switching: now player should release switching key and press it again -- look ma no pause!" This reverts commit a3827aae6da362e100e614fb008fe410e22d0f64. --- diff --git a/src/game/g_game.pas b/src/game/g_game.pas index de729fa..1dcbcd2 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -1504,18 +1504,11 @@ begin 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; @@ -1559,42 +1552,13 @@ begin 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 fa2dcfc..980aec7 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -163,7 +163,7 @@ type FSecrets: Integer; FCurrWeap: Byte; FNextWeap: WORD; - FNextWeapDelay: Byte; // frames (unused) + FNextWeapDelay: Byte; // frames FBFGFireCounter: SmallInt; FLastSpawnerUID: Word; FLastHit: Byte; @@ -200,9 +200,6 @@ type 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; @@ -336,10 +333,6 @@ type 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; @@ -2135,38 +2128,8 @@ begin 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; @@ -3696,7 +3659,7 @@ begin 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; @@ -3763,7 +3726,7 @@ begin // 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; @@ -3793,9 +3756,7 @@ var 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 8336ea9..3958d24 100644 --- a/src/game/g_window.pas +++ b/src/game/g_window.pas @@ -314,8 +314,6 @@ begin 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); @@ -404,8 +402,6 @@ begin 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;