mirror of
https://github.com/CraftyBoss/SuperMarioOdysseyOnline.git
synced 2024-11-21 18:55:16 +00:00
Client: Sync Player & Costume info on connect
This commit is contained in:
parent
71b4237d84
commit
86de220619
2 changed files with 15 additions and 9 deletions
|
@ -241,10 +241,10 @@ class Client {
|
|||
|
||||
int lastCollectedShine = -1;
|
||||
|
||||
PlayerInf lastPlayerInfPacket =
|
||||
PlayerInf(); // Info struct for storing our currently logged player information
|
||||
|
||||
// Backups for our last player/game packets, used for example to re-send them for newly connected clients
|
||||
PlayerInf lastPlayerInfPacket = PlayerInf();
|
||||
GameInf lastGameInfPacket = GameInf();
|
||||
CostumeInf lastCostumeInfPacket = CostumeInf();
|
||||
|
||||
Keyboard* mKeyboard = nullptr; // keyboard for setting server IP
|
||||
|
||||
|
|
|
@ -435,15 +435,20 @@ void Client::readFunc() {
|
|||
break;
|
||||
case PacketType::PLAYERCON:
|
||||
updatePlayerConnect((PlayerConnect*)curPacket);
|
||||
// send game info packet when client recieves connection
|
||||
|
||||
if (lastGameInfPacket.mUserID != mUserID) {
|
||||
// assume game info packet is empty from first connection
|
||||
// Send relevant info packets when another client is connected
|
||||
|
||||
// Assume game packets are empty from first connection
|
||||
if (lastGameInfPacket.mUserID != mUserID)
|
||||
lastGameInfPacket.mUserID = mUserID;
|
||||
// leave rest blank
|
||||
}
|
||||
|
||||
mSocket->SEND(&lastGameInfPacket);
|
||||
|
||||
// No need to send player/costume packets if they're empty
|
||||
if (lastPlayerInfPacket.mUserID == mUserID)
|
||||
mSocket->SEND(&lastPlayerInfPacket);
|
||||
if (lastCostumeInfPacket.mUserID == mUserID)
|
||||
mSocket->SEND(&lastCostumeInfPacket);
|
||||
|
||||
break;
|
||||
case PacketType::COSTUMEINF:
|
||||
updateCostumeInfo((CostumeInf*)curPacket);
|
||||
|
@ -698,6 +703,7 @@ void Client::sendCostumeInfPacket(const char* body, const char* cap) {
|
|||
CostumeInf packet = CostumeInf(body, cap);
|
||||
packet.mUserID = sInstance->mUserID;
|
||||
sInstance->mSocket->SEND(&packet);
|
||||
sInstance->lastCostumeInfPacket = packet;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue