summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9abb245)
raw | patch | inline | side by side (parent: 9abb245)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 15 Apr 2016 17:40:40 +0000 (20:40 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 15 Apr 2016 17:48:21 +0000 (20:48 +0300) |
src/engine/e_fixedbuffer.pas | patch | blob | history | |
src/game/g_netmaster.pas | patch | blob | history | |
src/game/g_netmsg.pas | patch | blob | history |
index 63570f7ec541a652724ba2421c59114b9986a6ec..833fd05b8fc8908b13691f35f96e73ea5fe0bb15 100644 (file)
function e_Buffer_Read_ShortInt(B: pTBuffer): ShortInt;
function e_Buffer_Read_SmallInt(B: pTBuffer): SmallInt;
function e_Buffer_Read_LongInt(B: pTBuffer): LongInt;
+function e_Buffer_Read_Int64(B: pTBuffer): Int64;
function e_Buffer_Read_String(B: pTBuffer): string;
begin
e_Buffer_Read_Generic(B, Result, 4);
end;
+function e_Buffer_Read_Int64(B: pTBuffer): Int64;
+begin
+ e_Buffer_Read_Generic(B, Result, 8);
+end;
function e_Buffer_Read_String(B: pTBuffer): string;
var
index e0eed50cdb6668dae4b2fd19671556f3cd92325c..b05c6d434946e4c9b76c461dc37bcf3a7eae9dac 100644 (file)
--- a/src/game/g_netmaster.pas
+++ b/src/game/g_netmaster.pas
Port: Word;
Map: string;
Players, MaxPlayers, LocalPl, Bots: Byte;
- Ping: Integer;
+ Ping: Int64;
GameMode: Byte;
Password: Boolean;
PingAddr: ENetAddress;
slFetched: Boolean = False;
slDirPressed: Boolean = False;
-function GetTimerMS(): Integer;
+function GetTimerMS(): Int64;
begin
Result := GetTimer() {div 1000};
end;
procedure PingServer(var S: TNetServer; Sock: ENetSocket);
var
Buf: ENetBuffer;
- Ping: array [0..5] of Byte;
- ClTime: Integer;
+ Ping: array [0..9] of Byte;
+ ClTime: Int64;
begin
ClTime := GetTimerMS();
Buf.data := Addr(Ping[0]);
- Buf.dataLength := 6;
+ Buf.dataLength := 2+8;
Ping[0] := Ord('D');
Ping[1] := Ord('F');
- LongInt(Addr(Ping[2])^) := ClTime;
+ Int64(Addr(Ping[2])^) := ClTime;
enet_socket_send(Sock, Addr(S.PingAddr), @Buf, 1);
end;
Cnt: Byte;
P: pENetPacket;
MID: Byte;
- I, T, RX: Integer;
+ I, RX: Integer;
+ T: Int64;
Sock: ENetSocket;
Buf: ENetBuffer;
SvAddr: ENetAddress;
begin
with SL[I] do
begin
- Ping := e_Buffer_Read_LongInt(@NetIn);
+ Ping := e_Buffer_Read_Int64(@NetIn);
Ping := GetTimerMS() - Ping;
Name := e_Buffer_Read_String(@NetIn);
Map := e_Buffer_Read_String(@NetIn);
diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas
index a88513acac78c6a4f5bcb799c91af45f2588e739..b24022f26280c1101adf89242f7ca0cfb0f2d1a9 100644 (file)
--- a/src/game/g_netmsg.pas
+++ b/src/game/g_netmsg.pas
uses g_net, g_triggers, Classes, SysUtils, md5;
const
+ NET_PROTO_VERSION = 1;
+
NET_MSG_INFO = 100;
NET_MSG_CHAT = 101;
PID: Word;
Color: TRGB;
I: Integer;
+ ProtoVer, Zero: Byte;
begin
+ Zero := e_Raw_Read_Byte(P);
+ ProtoVer := e_Raw_Read_Byte(P);
Ver := e_Raw_Read_String(P);
Pw := e_Raw_Read_String(P);
PName := e_Raw_Read_String(P);
B := e_Raw_Read_Byte(P);
T := e_Raw_Read_Byte(P);
- if Ver <> GAME_VERSION then
+ if (Ver <> GAME_VERSION) or (ProtoVer <> NET_PROTO_VERSION) or (Zero <> 0) then
begin
g_Console_Add(_lc[I_NET_MSG] + _lc[I_NET_MSG_HOST_REJECT] +
_lc[I_NET_DISC_VERSION]);
e_Buffer_Clear(@NetOut);
e_Buffer_Write(@NetOut, Byte(NET_MSG_INFO));
+ e_Buffer_Write(@NetOut, Byte(0)); // to kill old clients
+ e_Buffer_Write(@NetOut, Byte(NET_PROTO_VERSION));
e_Buffer_Write(@NetOut, GAME_VERSION);
e_Buffer_Write(@NetOut, Password);
e_Buffer_Write(@NetOut, gPlayer1Settings.Name);