mirror of
https://github.com/CraftyBoss/SuperMarioOdysseyOnline.git
synced 2024-11-17 00:45:10 +00:00
Merge pull request #54 from Istador/resend-packets
fix: `TagInf` and `CaptureInf` synchronization issues
This commit is contained in:
commit
8d94cf7856
3 changed files with 35 additions and 0 deletions
|
@ -225,6 +225,8 @@ class Client {
|
|||
GameInf lastGameInfPacket = GameInf();
|
||||
GameInf emptyGameInfPacket = GameInf();
|
||||
CostumeInf lastCostumeInfPacket = CostumeInf();
|
||||
TagInf lastTagInfPacket = TagInf();
|
||||
CaptureInf lastCaptureInfPacket = CaptureInf();
|
||||
|
||||
Keyboard* mKeyboard = nullptr; // keyboard for setting server IP
|
||||
|
||||
|
|
|
@ -348,6 +348,10 @@ void Client::readFunc() {
|
|||
mSocket->send(&lastPlayerInfPacket);
|
||||
if (lastCostumeInfPacket.mUserID == mUserID)
|
||||
mSocket->send(&lastCostumeInfPacket);
|
||||
if (lastTagInfPacket.mUserID == mUserID)
|
||||
mSocket->send(&lastTagInfPacket);
|
||||
if (lastCaptureInfPacket.mUserID == mUserID)
|
||||
mSocket->send(&lastCaptureInfPacket);
|
||||
|
||||
break;
|
||||
case PacketType::COSTUMEINF:
|
||||
|
@ -616,6 +620,8 @@ void Client::sendTagInfPacket() {
|
|||
packet->updateType = static_cast<TagUpdateType>(TagUpdateType::STATE | TagUpdateType::TIME);
|
||||
|
||||
sInstance->mSocket->queuePacket(packet);
|
||||
|
||||
sInstance->lastTagInfPacket = *packet;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -660,12 +666,14 @@ void Client::sendCaptureInfPacket(const PlayerActorHakoniwa* player) {
|
|||
packet->mUserID = sInstance->mUserID;
|
||||
strcpy(packet->hackName, tryConvertName(player->mHackKeeper->getCurrentHackName()));
|
||||
sInstance->mSocket->queuePacket(packet);
|
||||
sInstance->lastCaptureInfPacket = *packet;
|
||||
sInstance->isSentCaptureInf = true;
|
||||
} else if (!sInstance->isClientCaptured && sInstance->isSentCaptureInf) {
|
||||
CaptureInf *packet = new CaptureInf();
|
||||
packet->mUserID = sInstance->mUserID;
|
||||
strcpy(packet->hackName, "");
|
||||
sInstance->mSocket->queuePacket(packet);
|
||||
sInstance->lastCaptureInfPacket = *packet;
|
||||
sInstance->isSentCaptureInf = false;
|
||||
}
|
||||
}
|
||||
|
@ -683,6 +691,16 @@ void Client::resendInitPackets() {
|
|||
if (lastGameInfPacket != emptyGameInfPacket) {
|
||||
mSocket->queuePacket(&lastGameInfPacket);
|
||||
}
|
||||
|
||||
// TagInfPacket
|
||||
if (lastTagInfPacket.mUserID == mUserID) {
|
||||
mSocket->queuePacket(&lastTagInfPacket);
|
||||
}
|
||||
|
||||
// CaptureInfPacket
|
||||
if (lastCaptureInfPacket.mUserID == mUserID) {
|
||||
mSocket->queuePacket(&lastCaptureInfPacket);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -104,6 +104,21 @@ nn::Result SocketClient::init(const char* ip, u16 port) {
|
|||
// on a reconnect, resend some maybe missing packets
|
||||
if (initPacket.conType == ConnectionTypes::RECONNECT) {
|
||||
client->resendInitPackets();
|
||||
} else {
|
||||
// empty TagInf
|
||||
TagInf tagInf;
|
||||
tagInf.mUserID = initPacket.mUserID;
|
||||
tagInf.isIt = false;
|
||||
tagInf.minutes = 0;
|
||||
tagInf.seconds = 0;
|
||||
tagInf.updateType = static_cast<TagUpdateType>(TagUpdateType::STATE | TagUpdateType::TIME);
|
||||
send(&tagInf);
|
||||
|
||||
// empty CaptureInf
|
||||
CaptureInf capInf;
|
||||
capInf.mUserID = initPacket.mUserID;
|
||||
strcpy(capInf.hackName, "");
|
||||
send(&capInf);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
Loading…
Reference in a new issue