summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: efadc1f)
raw | patch | inline | side by side (parent: efadc1f)
author | fgsfds <pvt.fgsfds@gmail.com> | |
Wed, 1 May 2019 20:12:58 +0000 (23:12 +0300) | ||
committer | fgsfds <pvt.fgsfds@gmail.com> | |
Wed, 1 May 2019 20:12:58 +0000 (23:12 +0300) |
src/game/g_game.pas | patch | blob | history | |
src/game/g_net.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_game.pas b/src/game/g_game.pas
index 081d97e892b2af312e668557e532308f8cbfed02..4282e66642f47be224e827ff0cefef9c2f894a3e 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
gUseChatSounds: Boolean = True;
gChatSounds: Array of TChatSound;
gSelectWeapon: Array [0..1, WP_FIRST..WP_LAST] of Boolean; // [player, weapon]
+ gInterReadyCount: Integer = 0;
g_dbg_ignore_bounds: Boolean = false;
r_smallmap_h: Integer = 0; // 0: left; 1: center; 2: right
MessageLineLength: Integer = 80;
MapList: SSArray = nil;
MapIndex: Integer = -1;
+ InterReadyTime: Integer = -1;
MegaWAD: record
info: TMegaWADInfo;
endpic: String;
SetLength(CustomStat.PlayerStat, Length(CustomStat.PlayerStat)+1);
with CustomStat.PlayerStat[High(CustomStat.PlayerStat)] do
begin
+ Num := a;
Name := gPlayers[a].Name;
Frags := gPlayers[a].Frags;
Deaths := gPlayers[a].Death;
end;
g_Game_ExecuteEvent('onmapend');
+ if not g_Game_IsClient then g_Player_ResetReady;
+ gInterReadyCount := 0;
// Çàòóõàþùèé ýêðàí:
EndingGameCounter := 255;
if gwin_has_stencil and g_playerLight then g_AddDynLight(plr.GameX+32, plr.GameY+40, 128, 1, 1, 0, 0.6);
end;
+// HACK: don't have a "key was pressed" function
+procedure InterReady();
+begin
+ if InterReadyTime > gTime then Exit;
+ InterReadyTime := gTime + 3000;
+ MC_SEND_CheatRequest(NET_CHEAT_READY);
+end;
+
procedure g_Game_Update();
var
Msg: g_gui.TMessage;
and (not gJustChatted) and (not gConsoleShow) and (not gChatShow)
and (g_ActiveWindow = nil)
)
- or (g_Game_IsNet and (gInterTime > gInterEndTime))
+ or (g_Game_IsNet and ((gInterTime > gInterEndTime) or (gInterReadyCount >= NetClientCount)))
)
then
begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
end;
Exit;
+ end
+ else if g_Game_IsClient and
+ (
+ (
+ e_KeyPressed(IK_RETURN) or e_KeyPressed(IK_KPRETURN) or e_KeyPressed(IK_SPACE) or
+ e_KeyPressed(VK_FIRE) or e_KeyPressed(VK_OPEN) or
+ e_KeyPressed(JOY0_ATTACK) or e_KeyPressed(JOY1_ATTACK) or
+ e_KeyPressed(JOY2_ATTACK) or e_KeyPressed(JOY3_ATTACK)
+ )
+ and (not gJustChatted) and (not gConsoleShow) and (not gChatShow)
+ and (g_ActiveWindow = nil)
+ )
+ then
+ begin
+ // ready / unready
+ InterReady();
end;
if gState = STATE_INTERTEXT then
// Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
if gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT] then
begin
+ InterReadyTime := -1;
if gLastMap and (gGameSettings.GameMode = GM_COOP) then
begin
g_Game_ExecuteEvent('onwadend');
gg := g;
bb := b;
end;
- e_TextureFontPrintEx(x+8, _y, Name, gStdFont, rr, gg, bb, 1);
- e_TextureFontPrintEx(x+w1+8, _y, IntToStr(Frags), gStdFont, rr, gg, bb, 1);
- e_TextureFontPrintEx(x+w1+w2+8, _y, IntToStr(Deaths), gStdFont, rr, gg, bb, 1);
+ if (gPlayers[Num] <> nil) and (gPlayers[Num].FReady) then
+ e_TextureFontPrintEx(x+16, _y, Name + ' *', gStdFont, rr, gg, bb, 1)
+ else
+ e_TextureFontPrintEx(x+16, _y, Name, gStdFont, rr, gg, bb, 1);
+ e_TextureFontPrintEx(x+w1+16, _y, IntToStr(Frags), gStdFont, rr, gg, bb, 1);
+ e_TextureFontPrintEx(x+w1+w2+16, _y, IntToStr(Deaths), gStdFont, rr, gg, bb, 1);
_y := _y+24;
end;
else
r := 255;
- e_TextureFontPrintEx(x+8+16+8, _y+4, Name, gStdFont, r, r, r, 1, True);
+ if (gPlayers[Num] <> nil) and (gPlayers[Num].FReady) then
+ e_TextureFontPrintEx(x+8+16+8, _y+4, Name + ' *', gStdFont, r, r, r, 1, True)
+ else
+ e_TextureFontPrintEx(x+8+16+8, _y+4, Name, gStdFont, r, r, r, 1, True);
e_TextureFontPrintEx(x+w1+8+16+8, _y+4, IntToStr(Frags), gStdFont, r, r, r, 1, True);
e_TextureFontPrintEx(x+w1+w2+8+16+8, _y+4, IntToStr(Deaths), gStdFont, r, r, r, 1, True);
_y := _y+24;
diff --git a/src/game/g_net.pas b/src/game/g_net.pas
index 7e0f44d6eea0db1206c622dd7df555c4711a5ffe..b21ae1995d3e077298f9598d9edf40abe0a6e7ff 100644 (file)
--- a/src/game/g_net.pas
+++ b/src/game/g_net.pas
e_log, e_msg, ENet, Classes, MAPDEF{$IFDEF USE_MINIUPNPC}, miniupnpc;{$ELSE};{$ENDIF}
const
- NET_PROTOCOL_VER = 179;
+ NET_PROTOCOL_VER = 180;
NET_MAXCLIENTS = 24;
NET_CHANS = 11;
diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas
index 0ea771329dbf0358acd332b70e85d8e4fe24e90c..0ad3894b0e0af831c28d1178f79b748d8fa7e852 100644 (file)
--- a/src/game/g_netmsg.pas
+++ b/src/game/g_netmsg.pas
NET_EV_KILLCOMBO = 17;
NET_EV_PLAYER_TOUCH = 18;
NET_EV_SECRET = 19;
+ NET_EV_INTER_READY = 20;
NET_VE_STARTED = 1;
NET_VE_PASSED = 2;
NET_CHEAT_SUICIDE = 1;
NET_CHEAT_SPECTATE = 2;
+ NET_CHEAT_READY = 3;
NET_MAX_DIFFTIME = 5000 div 36;
else
Pl.Spectate;
end;
+ NET_CHEAT_READY:
+ begin
+ if gState <> STATE_INTERCUSTOM then Exit;
+ Pl.FReady := not Pl.FReady;
+ if Pl.FReady then
+ begin
+ MH_SEND_GameEvent(NET_EV_INTER_READY, Pl.UID, 'Y');
+ Inc(gInterReadyCount);
+ end
+ else
+ begin
+ MH_SEND_GameEvent(NET_EV_INTER_READY, Pl.UID, 'N');
+ Dec(gInterReadyCount);
+ end;
+ end;
end;
end;
end;
end;
+ NET_EV_INTER_READY:
+ begin
+ pl := g_Player_Get(EvNum);
+ if pl <> nil then pl.FReady := (EvStr = 'Y');
+ end;
end;
end;
if gPlayerAction[0, ACTION_STRAFE] then
begin
// new strafe mechanics
- if (strafeDir = 0) then strafeDir := P1MoveButton; // start strafing
+ if (strafeDir = 0) then
+ strafeDir := P1MoveButton; // start strafing
// now set direction according to strafe (reversed)
- if (strafeDir = 2) then gPlayer1.SetDirection(TDirection.D_LEFT)
- else if (strafeDir = 1) then gPlayer1.SetDirection(TDirection.D_RIGHT);
+ if (strafeDir = 2) then
+ gPlayer1.SetDirection(TDirection.D_LEFT)
+ else if (strafeDir = 1) then
+ gPlayer1.SetDirection(TDirection.D_RIGHT)
end
else
begin
+ strafeDir := 0; // not strafing anymore
if (P1MoveButton = 2) and gPlayerAction[0, ACTION_MOVELEFT] then
gPlayer1.SetDirection(TDirection.D_LEFT)
else if (P1MoveButton = 1) and gPlayerAction[0, ACTION_MOVERIGHT] then
diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index f644d6b7d863fc2d2f59a7f25da74670f9762c59..da4c43a84e12561afef525e41c84ce7eb8e04d4a 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
type
TPlayerStat = record
+ Num: Integer;
Ping: Word;
Loss: Byte;
Name: String;
FClientID: SmallInt;
FPing: Word;
FLoss: Byte;
+ FReady: Boolean;
FDummy: Boolean;
FFireTime: Integer;
procedure g_Player_RemoveAllCorpses();
procedure g_Player_Corpses_SaveState (st: TStream);
procedure g_Player_Corpses_LoadState (st: TStream);
+procedure g_Player_ResetReady();
procedure g_Bot_Add(Team, Difficult: Byte);
procedure g_Bot_AddList(Team: Byte; lname: ShortString; num: Integer = -1);
procedure g_Bot_MixNames();
SetLength(Result, Length(Result)+1);
with Result[High(Result)] do
begin
+ Num := a;
Ping := gPlayers[a].FPing;
Loss := gPlayers[a].FLoss;
Name := gPlayers[a].FName;
end;
end;
+procedure g_Player_ResetReady();
+var
+ a: Integer;
+begin
+ if not g_Game_IsServer then Exit;
+ if gPlayers = nil then Exit;
+
+ for a := 0 to High(gPlayers) do
+ if gPlayers[a] <> nil then
+ begin
+ gPlayers[a].FReady := False;
+ if g_Game_IsNet then
+ MH_SEND_GameEvent(NET_EV_INTER_READY, gPlayers[a].UID, 'N');
+ end;
+end;
+
procedure g_Player_RememberAll;
var
i: Integer;
FMonsterKills := 0;
FDeath := 0;
FSecrets := 0;
+ FReady := False;
if FNoRespawn then
begin
FSpectator := False;