Skip to content

Commit 8d3f43b

Browse files
committed
Added experimental network interruption detection
Conflicts: MTA10/mods/deathmatch/logic/CClientGame.cpp MTA10/mods/deathmatch/logic/CPacketHandler.cpp
1 parent 7b7f8f1 commit 8d3f43b

File tree

15 files changed

+119
-10
lines changed

15 files changed

+119
-10
lines changed

MTA10/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2775,6 +2775,7 @@ void CClientGame::AddBuiltInEvents ( void )
27752775
m_Events.AddEvent ( "onClientPlayerHeliKilled", "heli", NULL, false );
27762776
m_Events.AddEvent ( "onClientPlayerPickupHit", "pickup, matchingDimension", NULL, false );
27772777
m_Events.AddEvent ( "onClientPlayerPickupLeave", "pickup, matchingDimension", NULL, false );
2778+
m_Events.AddEvent ( "onClientPlayerNetworkStatus", "type, ticks", NULL, false );
27782779

27792780
// Ped events
27802781
m_Events.AddEvent ( "onClientPedDamage", "attacker, weapon, bodypart", NULL, false );

MTA10/mods/deathmatch/logic/CPacketHandler.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ bool CPacketHandler::ProcessPacket ( unsigned char ucPacketID, NetBitStreamInter
108108
Packet_PartialPacketInfo ( bitStream );
109109
return true;
110110

111+
case PACKET_ID_PLAYER_NETWORK_STATUS:
112+
Packet_PlayerNetworkStatus( bitStream );
113+
return true;
114+
111115
// Adds a new entity of any type to the world streamer.
112116
case PACKET_ID_ENTITY_ADD:
113117
Packet_EntityAdd ( bitStream );
@@ -2528,6 +2532,24 @@ void CPacketHandler::Packet_PartialPacketInfo ( NetBitStreamInterface& bitStream
25282532
}
25292533

25302534

2535+
void CPacketHandler::Packet_PlayerNetworkStatus ( NetBitStreamInterface& bitStream )
2536+
{
2537+
uchar ucType;
2538+
uint uiTicks;
2539+
2540+
if ( bitStream.Read ( ucType ) &&
2541+
bitStream.Read ( uiTicks ) )
2542+
{
2543+
CLuaArguments Arguments;
2544+
Arguments.PushNumber ( ucType ); // 0-interruption began 1-interruption end
2545+
Arguments.PushNumber ( uiTicks ); // Ticks since interruption start
2546+
CClientPlayer* pLocalPlayer = g_pClientGame->m_pPlayerManager->GetLocalPlayer ();
2547+
if ( pLocalPlayer )
2548+
pLocalPlayer->CallEvent ( "onClientPlayerNetworkStatus", Arguments, false );
2549+
}
2550+
}
2551+
2552+
25312553
void CPacketHandler::Packet_EntityAdd ( NetBitStreamInterface& bitStream )
25322554
{
25332555
// Ensure big packet progress bar is no longer displayed at this point. (It shouldn't be anyway)

MTA10/mods/deathmatch/logic/CPacketHandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class CPacketHandler
7777
void Packet_VehicleTrailer ( NetBitStreamInterface& bitStream );
7878
void Packet_MapInfo ( NetBitStreamInterface& bitStream );
7979
void Packet_PartialPacketInfo ( NetBitStreamInterface& bitStream );
80+
void Packet_PlayerNetworkStatus ( NetBitStreamInterface& bitStream );
8081
void Packet_EntityAdd ( NetBitStreamInterface& bitStream );
8182
void Packet_EntityRemove ( NetBitStreamInterface& bitStream );
8283
void Packet_PickupHideShow ( NetBitStreamInterface& bitStream );

MTA10_Server/mods/deathmatch/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ LOGIC = \
293293
./logic/packets/CPlayerListPacket.cpp \
294294
./logic/packets/CPlayerPuresyncPacket.cpp \
295295
./logic/packets/CPlayerModInfoPacket.cpp \
296+
./logic/packets/CPlayerNetworkStatusPacket.cpp \
296297
./logic/packets/CPlayerScreenShotPacket.cpp \
297298
./logic/packets/CPlayerQuitPacket.cpp \
298299
./logic/packets/CPlayerSpawnPacket.cpp \

MTA10_Server/mods/deathmatch/StdInc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ struct SAclRequest;
8383
#include "packets/CPlayerListPacket.h"
8484
#include "packets/CPlayerPuresyncPacket.h"
8585
#include "packets/CPlayerNoSocketPacket.h"
86+
#include "packets/CPlayerNetworkStatusPacket.h"
8687
#include "packets/CPlayerQuitPacket.h"
8788
#include "packets/CPlayerSpawnPacket.h"
8889
#include "packets/CPlayerStatsPacket.h"

MTA10_Server/mods/deathmatch/_ServerDeathmatch 2008.vcproj

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,10 @@
14351435
RelativePath=".\logic\packets\CPlayerModInfoPacket.cpp"
14361436
>
14371437
</File>
1438+
<File
1439+
RelativePath=".\logic\packets\CPlayerNetworkStatusPacket.cpp"
1440+
>
1441+
</File>
14381442
<File
14391443
RelativePath=".\logic\packets\CPlayerPuresyncPacket.cpp"
14401444
>
@@ -1559,10 +1563,6 @@
15591563
RelativePath=".\logic\lua\CLuaCFunctions.cpp"
15601564
>
15611565
</File>
1562-
<File
1563-
RelativePath=".\logic\lua\CLuaFunctionDefs.cpp"
1564-
>
1565-
</File>
15661566
<File
15671567
RelativePath=".\logic\lua\CLuaFunctionDefs.Account.cpp"
15681568
>
@@ -1587,6 +1587,10 @@
15871587
RelativePath=".\logic\lua\CLuaFunctionDefs.cpp"
15881588
>
15891589
</File>
1590+
<File
1591+
RelativePath=".\logic\lua\CLuaFunctionDefs.cpp"
1592+
>
1593+
</File>
15901594
<File
15911595
RelativePath=".\logic\lua\CLuaFunctionDefs.Crypt.cpp"
15921596
>
@@ -1727,23 +1731,23 @@
17271731
>
17281732
</File>
17291733
<File
1730-
RelativePath=".\logic\lua\oopdefs\CLuaOOPFunctionDefs.Element.cpp"
1734+
RelativePath=".\logic\lua\oopdefs\CLuaOOPFunctionDefs.Connection.cpp"
17311735
>
17321736
</File>
17331737
<File
1734-
RelativePath=".\logic\lua\oopdefs\CLuaOOPFunctionDefs.Ped.cpp"
1738+
RelativePath=".\logic\lua\oopdefs\CLuaOOPFunctionDefs.Element.cpp"
17351739
>
17361740
</File>
17371741
<File
1738-
RelativePath=".\logic\lua\oopdefs\CLuaOOPFunctionDefs.Player.cpp"
1742+
RelativePath=".\logic\lua\oopdefs\CLuaOOPFunctionDefs.Marker.cpp"
17391743
>
17401744
</File>
17411745
<File
1742-
RelativePath=".\logic\lua\oopdefs\CLuaOOPFunctionDefs.Connection.cpp"
1746+
RelativePath=".\logic\lua\oopdefs\CLuaOOPFunctionDefs.Ped.cpp"
17431747
>
17441748
</File>
17451749
<File
1746-
RelativePath=".\logic\lua\oopdefs\CLuaOOPFunctionDefs.Marker.cpp"
1750+
RelativePath=".\logic\lua\oopdefs\CLuaOOPFunctionDefs.Player.cpp"
17471751
>
17481752
</File>
17491753
<File
@@ -3096,6 +3100,10 @@
30963100
RelativePath=".\logic\packets\CPlayerModInfoPacket.h"
30973101
>
30983102
</File>
3103+
<File
3104+
RelativePath=".\logic\packets\CPlayerNetworkStatusPacket.h"
3105+
>
3106+
</File>
30993107
<File
31003108
RelativePath=".\logic\packets\CPlayerNoSocketPacket.h"
31013109
>

MTA10_Server/mods/deathmatch/_ServerDeathmatch 2008.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@
482482
<ClCompile Include="logic\lua\oopdefs\CLuaOOPFunctionDefs.Player.cpp" />
483483
<ClCompile Include="logic\lua\oopdefs\CLuaOOPFunctionDefs.Connection.cpp" />
484484
<ClCompile Include="logic\lua\oopdefs\CLuaOOPFunctionDefs.RadarArea.cpp" />
485+
<ClCompile Include="logic\packets\CPlayerNetworkStatusPacket.cpp" />
485486
<ClCompile Include="Server.cpp" />
486487
<ClCompile Include="StdInc.cpp">
487488
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
@@ -885,6 +886,7 @@
885886
<ClInclude Include="logic\lua\CLuaVector3.h" />
886887
<ClInclude Include="logic\lua\CLuaVector4.h" />
887888
<ClInclude Include="logic\lua\oopdefs\CLuaOOPDefs.h" />
889+
<ClInclude Include="logic\packets\CPlayerNetworkStatusPacket.h" />
888890
<ClInclude Include="utils\CZipMaker.h" />
889891
<ClInclude Include="..\EXECryptor\EXECryptor.h" />
890892
<ClInclude Include="gccHashSupport.h" />

MTA10_Server/mods/deathmatch/_ServerDeathmatch 2008.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,9 @@
10051005
<ClCompile Include="logic\lua\oopdefs\CLuaOOPFunctionDefs.RadarArea.cpp">
10061006
<Filter>Source Files\logic\oopdefs</Filter>
10071007
</ClCompile>
1008+
<ClCompile Include="logic\packets\CPlayerNetworkStatusPacket.cpp">
1009+
<Filter>Source Files\logic\packets</Filter>
1010+
</ClCompile>
10081011
</ItemGroup>
10091012
<ItemGroup>
10101013
<ClInclude Include="logic\CLightsyncManager.h">
@@ -1865,6 +1868,9 @@
18651868
<ClInclude Include="logic\lua\CLuaFunctionDefs.h">
18661869
<Filter>Header Files\logic\lua</Filter>
18671870
</ClInclude>
1871+
<ClInclude Include="logic\packets\CPlayerNetworkStatusPacket.h">
1872+
<Filter>Header Files\logic\packets</Filter>
1873+
</ClInclude>
18681874
</ItemGroup>
18691875
<ItemGroup>
18701876
<Xml Include="acl.xml">

MTA10_Server/mods/deathmatch/logic/CGame.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,12 @@ bool CGame::ProcessPacket ( CPacket& Packet )
11361136
return true;
11371137
}
11381138

1139+
case PACKET_ID_PLAYER_NETWORK_STATUS:
1140+
{
1141+
Packet_PlayerNetworkStatus ( static_cast < CPlayerNetworkStatusPacket& > ( Packet ) );
1142+
return true;
1143+
}
1144+
11391145
default:
11401146
break;
11411147
}
@@ -1449,6 +1455,7 @@ void CGame::AddBuiltInEvents ( void )
14491455
m_Events.AddEvent ( "onPlayerUnmute", "", NULL, false );
14501456
m_Events.AddEvent ( "onPlayerCommand", "command", NULL, false );
14511457
m_Events.AddEvent ( "onPlayerModInfo", "type, ids, names", NULL, false );
1458+
m_Events.AddEvent ( "onPlayerNetworkStatus", "type, ticks", NULL, false );
14521459
m_Events.AddEvent ( "onPlayerScreenShot", "resource, status, file_data, timestamp, tag", NULL, false );
14531460

14541461
// Ped events
@@ -3713,6 +3720,19 @@ void CGame::Packet_PlayerNoSocket ( CPlayerNoSocketPacket & Packet )
37133720
}
37143721

37153722

3723+
void CGame::Packet_PlayerNetworkStatus ( CPlayerNetworkStatusPacket & Packet )
3724+
{
3725+
CPlayer* pPlayer = Packet.GetSourcePlayer ();
3726+
if ( pPlayer )
3727+
{
3728+
CLuaArguments Arguments;
3729+
Arguments.PushNumber ( Packet.m_ucType ); // 0-interruption began 1-interruption end
3730+
Arguments.PushNumber ( Packet.m_uiTicks ); // Ticks since interruption start
3731+
pPlayer->CallEvent ( "onPlayerNetworkStatus", Arguments, NULL );
3732+
}
3733+
}
3734+
3735+
37163736
void CGame::Packet_PlayerModInfo ( CPlayerModInfoPacket & Packet )
37173737
{
37183738
CPlayer* pPlayer = Packet.GetSourcePlayer ();

MTA10_Server/mods/deathmatch/logic/CGame.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ class CGame
438438
void Packet_PlayerModInfo ( class CPlayerModInfoPacket & Packet );
439439
void Packet_PlayerScreenShot ( class CPlayerScreenShotPacket & Packet );
440440
void Packet_PlayerNoSocket ( class CPlayerNoSocketPacket & Packet );
441+
void Packet_PlayerNetworkStatus ( class CPlayerNetworkStatusPacket & Packet );
441442

442443
static void PlayerCompleteConnect ( CPlayer* pPlayer, bool bSuccess, const char* szError );
443444

0 commit comments

Comments
 (0)