summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 85f0d06)
raw | patch | inline | side by side (parent: 85f0d06)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Mon, 1 Oct 2018 10:01:27 +0000 (13:01 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Mon, 1 Oct 2018 10:01:52 +0000 (13:01 +0300) |
src/game/g_console.pas | patch | blob | history | |
src/game/g_netmsg.pas | patch | blob | history | |
src/game/g_player.pas | patch | blob | history |
diff --git a/src/game/g_console.pas b/src/game/g_console.pas
index 7b68cce099b4130ca24d2a779501b32caecef2be..f91bc624495dbbf29073904eb7ede60a3be7d8b7 100644 (file)
--- a/src/game/g_console.pas
+++ b/src/game/g_console.pas
begin
if (Length(Line) = 0) then
begin
+ if (g_Game_IsNet and g_Game_IsServer) or (g_Game_IsClient) then exit;
g_Console_Add('');
for i := 0 to High(commands) do
begin
diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas
index 6d1f430e5509196b9212f1535b1baedf3658e8af..e884e9b91054550e815ce2ff5e89d9e9fae787a4 100644 (file)
--- a/src/game/g_netmsg.pas
+++ b/src/game/g_netmsg.pas
{$INCLUDE ../shared/a_modes.inc}
unit g_netmsg;
+{.$DEFINE K8_XXX_WEAPON_DEBUG}
+
interface
uses e_msg, g_net, g_triggers, Classes, SysUtils, md5;
kByte: Word;
Pl: TPlayer;
GT: LongWord;
+ newweapon: Byte;
begin
Result := 0;
if not gGameOn then Exit;
kByte := M.ReadWord();
Dir := M.ReadByte();
//WeaponSelect := M.ReadWord();
- SetWeapon(M.ReadByte());
+ newweapon := M.ReadByte();
+ if (newweapon <> CurrWeap) then
+ begin
+{$IFDEF K8_XXX_WEAPON_DEBUG}
+ writeln('HOST PLRPOS: got: currweap=', CurrWeap, '; curfrm=', gTime, '; netweap=', newweapon, '; oldweap=', CurrWeap);
+{$ENDIF}
+ //NetForceWeap := newweapon;
+ SetWeapon(newweapon);
+ end;
//e_WriteLog(Format('R:ws=%d', [WeaponSelect]), MSG_WARNING);
if Direction <> TDirection(Dir) then
JustTeleported := False;
NetOut.Write(Frags);
NetOut.Write(Death);
- NetOut.Write(CurrWeap);
+ //NetOut.Write(CurrWeap);
+ NetOut.Write(Byte(CurrWeap));
// other flags
ww := 0;
OldJet: Boolean;
NewTeam: Byte;
ww: Word;
+ newweapon: Byte;
begin
PID := M.ReadWord();
Pl := g_Player_Get(PID);
Frags := M.ReadLongInt();
Death := M.ReadLongInt();
- SetWeapon(M.ReadByte());
+ newweapon := M.ReadByte();
+{$IFDEF K8_XXX_WEAPON_DEBUG}
+ writeln('CLIENT PLRSTATS: got: currweap=', CurrWeap, '; curfrm=', gTime, '; netweap=', newweapon, '; lastnwfrm=', NetForceWeapFIdx);
+{$ENDIF}
+ if (gTime >= NetForceWeapFIdx) then
+ begin
+ //NetForceWeap := newweapon;
+ SetWeapon(newweapon);
+ end;
+ //SetWeapon(M.ReadByte());
// other flags
ww := M.ReadByte();
NetOut.Write(kByte);
NetOut.Write(Byte(gPlayer1.Direction));
NetOut.Write(Byte(gPlayer1.CurrWeap));
+{$IFDEF K8_XXX_WEAPON_DEBUG}
+ if (kByte and NET_KEY_FIRE) <> 0 then writeln('FIRE: CurrWeap=', gPlayer1.CurrWeap);
+{$ENDIF}
+ //e_WriteLog(Format('S:nwp=%d; nwfidx=%d', [Integer(gPlayer1.NetForceWeap), Integer(gPlayer1.NetForceWeapFIdx)]), TMsgType.Warning);
//NetOut.Write(WeaponSelect);
//e_WriteLog(Format('S:ws=%d', [WeaponSelect]), MSG_WARNING);
g_Net_Client_Send(True, NET_CHAN_PLAYERPOS);
+ // force player weapon
+ //{if (gPlayer1.NetForceWeapFIdx < gTime) then} gPlayer1.SetWeapon(gPlayer1.NetForceWeap);
+
//kBytePrev := kByte;
//kDirPrev := gPlayer1.Direction;
end;
diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index f9de6195596b43fa555a80dcbff9ba1d6c241388..897ece3dfc10bb11996e6ebe4df8e0d36fa54819 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
FFlag: Byte;
FSecrets: Integer;
FCurrWeap: Byte;
+ //FNetForceWeap: Byte; // spam server with this -- this is new weapon we want to use
+ FNetForceWeapFIdx: LongWord; // frame index; ignore weapon change if it is lesser than this
+ //FCurrFrameIdx: LongWord; // increased in each `Update()`
FNextWeap: WORD;
FNextWeapDelay: Byte; // frames (unused)
FBFGFireCounter: SmallInt;
property Death: Integer read FDeath write FDeath;
property Kills: Integer read FKills write FKills;
property CurrWeap: Byte read FCurrWeap write FCurrWeap;
+ //property NetForceWeap: Byte read FNetForceWeap write FNetForceWeap;
+ property NetForceWeapFIdx: LongWord read FNetForceWeapFIdx write FNetForceWeapFIdx;
+ //property CurrFrameIdx: LongWord read FCurrFrameIdx write FCurrFrameIdx;
property MonsterKills: Integer read FMonsterKills write FMonsterKills;
property Secrets: Integer read FSecrets;
property GodMode: Boolean read FGodMode write FGodMode;
gPlayers[a].FSecrets := utils.readLongInt(st);
// Òåêóùåå îðóæèå
gPlayers[a].FCurrWeap := utils.readByte(st);
+ //gPlayers[a].FNetForceWeap := gPlayers[a].FCurrWeap;
// Ñëåäóþùåå æåëàåìîå îðóæèå
gPlayers[a].FNextWeap := utils.readWord(st);
// ...è ïàóçà
if gPlayers[i] is TPlayer then
begin
gPlayers[i].Update();
- gPlayers[i].RealizeCurrentWeapon(); // WARNING! DO NOT MOVE THIS INTO `Update()`!
+ if g_Game_IsClient or not g_Game_IsNet then
+ begin
+ gPlayers[i].RealizeCurrentWeapon(); // WARNING! DO NOT MOVE THIS INTO `Update()`!
+ end;
end
else
begin
FJustTeleported := False;
FNetTime := 0;
+ //FNetForceWeap := FCurrWeap;
+ FNetForceWeapFIdx := 0;
+ //FCurrFrameIdx := 0;
+
resetWeaponQueue();
releaseAllWeaponSwitchKeys();
end;
if FWeapon[nw] then
begin
+ //k8: emulate this on client immediately, or wait for server confirmation?
+ {
+ if g_Game_IsClient then
+ begin
+ FNetForceWeap := nw;
+ //FNetForceWeapFIdx := FCurrFrameIdx+5; // force for ~5 frames
+ FNetForceWeapFIdx := gTime+5; // force for ~5 frames
+ writeln('NETWEAPONSWITCH: fw=', NetForceWeap, '; fwfidx=', NetForceWeapFIdx, '; cfrm=', gTime);
+ end;
+ }
+ FNetForceWeapFIdx := gTime+5; // force for ~5 frames
FCurrWeap := nw;
+ if nw = WEAPON_SAW then FSawSoundSelect.PlayAt(FObj.X, FObj.Y);
+ FModel.SetWeapon(nw);
FTime[T_SWITCH] := gTime+156;
- if FCurrWeap = WEAPON_SAW then FSawSoundSelect.PlayAt(FObj.X, FObj.Y);
- FModel.SetWeapon(FCurrWeap);
if g_Game_IsNet then MH_SEND_PlayerStats(FUID);
+ //if g_Game_IsNet and g_Game_IsClient then
end;
end;
FNextWeap := $4000;
end;
+// used by network layer
procedure TPlayer.SetWeapon(W: Byte);
begin
if FCurrWeap <> W then
- if W = WEAPON_SAW then
+ if (W = WEAPON_SAW) then
FSawSoundSelect.PlayAt(FObj.X, FObj.Y);
FCurrWeap := W;
FModel.SetWeapon(CurrWeap);
- resetWeaponQueue();
+ //if g_Game_IsClient then resetWeaponQueue();
end;
function TPlayer.PickItem(ItemType: Byte; arespawn: Boolean; var remove: Boolean): Boolean;
if allowBerserkSwitching then
begin
FCurrWeap := WEAPON_KASTET;
+ //FNetForceWeap := FCurrWeap;
resetWeaponQueue();
FModel.SetWeapon(WEAPON_KASTET);
end;
FMonsterKills := 0;
FDeath := 0;
FSecrets := 0;
+ //FCurrFrameIdx := 0;
+ //FNetForceWeap := FCurrWeap;
+ //FNetForceWeapFIdx := 0;
if FNoRespawn then
begin
FSpectator := False;
FShellTimer := -1;
FPain := 0;
FLastHit := 0;
+ //FNetForceWeap := FCurrWeap;
if not g_Game_IsServer then
Exit;
FWeapon[WEAPON_PISTOL] := True;
FWeapon[WEAPON_KASTET] := True;
FCurrWeap := WEAPON_PISTOL;
+ //FNetForceWeap := FCurrWeap;
resetWeaponQueue();
FModel.SetWeapon(FCurrWeap);
if (gPlayer2 = nil) and (gLMSPID2 = FUID) then
gPlayer2 := self;
+ //FNetForceWeap := FCurrWeap;
+
if g_Game_IsNet then
begin
MH_SEND_PlayerPos(True, FUID, NET_EVERYONE);
AnyServer: Boolean;
SetSpect: Boolean;
begin
+ //Inc(FCurrFrameIdx);
+
NetServer := g_Game_IsNet and g_Game_IsServer;
AnyServer := g_Game_IsServer;
FAir := FSavedState.Air;
FJetFuel := FSavedState.JetFuel;
FCurrWeap := FSavedState.CurrWeap;
+ //FNetForceWeap := FCurrWeap;
FNextWeap := FSavedState.NextWeap;
FNextWeapDelay := FSavedState.NextWeapDelay;
FSecrets := utils.readLongInt(st);
// Òåêóùåå îðóæèå
FCurrWeap := utils.readByte(st);
+ //FNetForceWeap := FCurrWeap;
// Æåëàåìîå îðóæèå
FNextWeap := utils.readWord(st);
// ...è ïàóçà
if FBFGFireCounter < 1 then
begin
FCurrWeap := WEAPON_KASTET;
+ //FNetForceWeap := FCurrWeap;
resetWeaponQueue();
FModel.SetWeapon(WEAPON_KASTET);
end;