Now sends InputData and WeaponInput only when there are changes
This commit is contained in:
parent
79cc24f39c
commit
55677ea014
@ -297,6 +297,9 @@ namespace spades {
|
||||
peer = NULL;
|
||||
status = NetClientStatusNotConnected;
|
||||
|
||||
lastPlayerInput = 0;
|
||||
lastWeaponInput = 0;
|
||||
|
||||
savedPlayerPos.resize(32);
|
||||
savedPlayerFront.resize(32);
|
||||
}
|
||||
@ -980,8 +983,11 @@ namespace spades {
|
||||
if(!name.empty()) // sometimes becomes empty
|
||||
pers.name = name;
|
||||
|
||||
if(pId == GetWorld()->GetLocalPlayerIndex())
|
||||
if(pId == GetWorld()->GetLocalPlayerIndex()){
|
||||
client->LocalPlayerCreated();
|
||||
lastPlayerInput = 0xffffffff;
|
||||
lastWeaponInput = 0xffffffff;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PacketTypeBlockAction:
|
||||
@ -1467,6 +1473,10 @@ namespace spades {
|
||||
if(inp.sprint) bits |= 1 << 7;
|
||||
wri.Write(bits);
|
||||
|
||||
if((unsigned int)bits == lastPlayerInput)
|
||||
return;
|
||||
lastPlayerInput = bits;
|
||||
|
||||
enet_peer_send(peer, 0, wri.CreatePacket());
|
||||
}
|
||||
|
||||
@ -1480,6 +1490,10 @@ namespace spades {
|
||||
if(inp.secondary) bits |= 1 << 1;
|
||||
wri.Write(bits);
|
||||
|
||||
if((unsigned int)bits == lastWeaponInput)
|
||||
return;
|
||||
lastWeaponInput = bits;
|
||||
|
||||
enet_peer_send(peer, 0, wri.CreatePacket());
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,9 @@ namespace spades {
|
||||
int timeToTryMapLoad;
|
||||
bool tryMapLoadOnPacketType;
|
||||
|
||||
unsigned int lastPlayerInput;
|
||||
unsigned int lastWeaponInput;
|
||||
|
||||
// used for some scripts including Arena by Yourself
|
||||
IntVector3 temporaryPlayerBlockColor;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user