From ed0d65211308e1646f6dea5065ae73837facebad Mon Sep 17 00:00:00 2001 From: csnv Date: Sat, 25 Nov 2023 04:59:03 +0100 Subject: [PATCH] Fix sc statuses not loaded on time when under heavy load --- src/map/clif.c | 4 ++++ src/map/pc.c | 13 +++++++++---- src/map/pc.h | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index 3ff3ed96477..2936bbf0825 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -11161,6 +11161,10 @@ static void clif_parse_LoadEndAck(int fd, struct map_session_data *sd) return; } + if (sd->state.scloaded == 0) { // SC data was not received yet. pc->scdata_received will reinvoke + return; + } + if (sd->state.rewarp != 0) { // Rewarp character. sd->state.rewarp = 0; clif->changemap(sd, sd->bl.m, sd->bl.x, sd->bl.y); diff --git a/src/map/pc.c b/src/map/pc.c index c1394ea59dd..16818524bfd 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -12260,14 +12260,19 @@ static void pc_scdata_received(struct map_session_data *sd) pc->expire_check(sd); } - if( sd->state.standalone ) { + + if (sd->sc.data[SC_SOULENERGY] != NULL) + sd->soulball = sd->sc.data[SC_SOULENERGY]->val1; + + sd->state.scloaded = 1; + if (sd->state.standalone) { clif->pLoadEndAck(0,sd); pc->autotrade_populate(sd); pc->autotrade_start(sd); + } else { + clif->pLoadEndAck(sd->fd, sd); } - - if (sd->sc.data[SC_SOULENERGY] != NULL) - sd->soulball = sd->sc.data[SC_SOULENERGY]->val1; + } static int pc_expiration_timer(int tid, int64 tick, int id, intptr_t data) { diff --git a/src/map/pc.h b/src/map/pc.h index 759991611b8..0a9bd6f833f 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -209,6 +209,7 @@ struct map_session_data { //status_calc_pc, while special_state is recalculated in each call. [Skotlex] struct { unsigned int active : 1; //Marks active player (not active is logging in/out, or changing map servers) + unsigned int scloaded : 1; // Marks sc related data has been loaded for player unsigned int menu_or_input : 1;// if a script is waiting for feedback from the player unsigned int dead_sit : 2; unsigned int lr_flag : 3;//1: left h. weapon; 2: arrow; 3: shield