Compare commits

..

3 Commits

Author SHA1 Message Date
02c1c681dd
Merge 225515ec21 into 47dbc6d35e 2024-06-26 22:18:54 +00:00
gsemaj
225515ec21
Fix comment 2024-06-26 15:18:49 -07:00
gsemaj
f436108d24
Don't send unnecessary nano book subsets pre-enter 2024-06-26 15:15:11 -07:00

View File

@ -155,7 +155,7 @@ void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z) {
* Nanos the player hasn't unlocked will (and should) be greyed out. Thus, all nanos should be accounted
* for in these packets, even if the player hasn't unlocked them.
*/
static void sendNanoBookSubset(CNSocket *sock, Player *plr) {
static void sendNanoBook(CNSocket *sock, Player *plr, bool resizeOnly) {
#ifdef ACADEMY
int16_t id = 0;
INITSTRUCT(sP_FE2CL_REP_NANO_BOOK_SUBSET, pkt);
@ -163,6 +163,13 @@ static void sendNanoBookSubset(CNSocket *sock, Player *plr) {
pkt.PCUID = plr->iID;
pkt.bookSize = NANO_COUNT;
if (resizeOnly) {
// triggers nano array resizing without
// actually sending nanos
sock->sendPacket(pkt, P_FE2CL_REP_NANO_BOOK_SUBSET);
return;
}
while (id < NANO_COUNT) {
pkt.elementOffset = id;
@ -293,14 +300,14 @@ static void enterPlayer(CNSocket* sock, CNPacketData* data) {
sock->setFEKey(lm->FEKey);
sock->setActiveKey(SOCKETKEY_FE); // send all packets using the FE key from now on
// Academy builds receive nanos in a separate packet. These need to be sent
// before P_FE2CL_REP_PC_ENTER_SUCC as well as after
// due to a race condition in the client :(
sendNanoBookSubset(sock, plr);
// Academy builds receive nanos in a separate packet. An initial one with the size of the
// nano book needs to be sent before PC_ENTER_SUCC so the client can resize its nano arrays,
// and then proper packets with the nanos included must be sent after, while the game is loading.
sendNanoBook(sock, plr, true);
sock->sendPacket(response, P_FE2CL_REP_PC_ENTER_SUCC);
sendNanoBookSubset(sock, plr);
sendNanoBook(sock, plr, false);
// transfer ownership of Player object into the shard (still valid in this function though)
addPlayer(sock, plr);