fix: resend CaptureInf packet on reconnect and for new players

This commit is contained in:
Robin C. Ladiges 2023-06-24 02:42:54 +02:00
parent 4835692672
commit 2bef6f796e
No known key found for this signature in database
GPG Key ID: B494D3DF92661B99
2 changed files with 10 additions and 0 deletions

View File

@ -230,6 +230,7 @@ class Client {
GameInf emptyGameInfPacket = GameInf();
CostumeInf lastCostumeInfPacket = CostumeInf();
TagInf lastTagInfPacket = TagInf();
CaptureInf lastCaptureInfPacket = CaptureInf();
Keyboard* mKeyboard = nullptr; // keyboard for setting server IP

View File

@ -363,6 +363,8 @@ void Client::readFunc() {
mSocket->send(&lastCostumeInfPacket);
if (lastTagInfPacket.mUserID == mUserID)
mSocket->send(&lastTagInfPacket);
if (lastCaptureInfPacket.mUserID == mUserID)
mSocket->send(&lastCaptureInfPacket);
break;
case PacketType::COSTUMEINF:
@ -677,12 +679,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;
}
}
@ -705,6 +709,11 @@ void Client::resendInitPackets() {
if (lastTagInfPacket.mUserID == mUserID) {
mSocket->queuePacket(&lastTagInfPacket);
}
// CaptureInfPacket
if (lastCaptureInfPacket.mUserID == mUserID) {
mSocket->queuePacket(&lastCaptureInfPacket);
}
}
/**