summaryrefslogtreecommitdiff
path: root/src/map/chrif.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-11-22 23:52:58 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-11-22 23:52:58 +0000
commit2b2dbf43f11aecf778ff118dd1da1af9726f36e6 (patch)
tree890231641c122da8ef8664471be4a008041c6349 /src/map/chrif.c
parent78dcaf513236ab7736a84deff5820b71cf6a76fb (diff)
downloadhercules-2b2dbf43f11aecf778ff118dd1da1af9726f36e6.tar.gz
hercules-2b2dbf43f11aecf778ff118dd1da1af9726f36e6.tar.bz2
hercules-2b2dbf43f11aecf778ff118dd1da1af9726f36e6.tar.xz
hercules-2b2dbf43f11aecf778ff118dd1da1af9726f36e6.zip
- Changed the status_change structure to use dynamic rather than static memory to hold the individual status changes, this should have a noticeable impact on the server's memory consumption.
- Had to add a few 'ugly' flags to status_change since now you can't track SC related information while said SC is not active (happens only for Storm Gust, Joint Beat and Magic Power). - Since I am unable to fully test, watch out for any bugs~ git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11786 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/chrif.c')
-rw-r--r--src/map/chrif.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 0f4df2544..03bed41b1 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -1022,6 +1022,7 @@ int chrif_save_scdata(struct map_session_data *sd)
int i, count=0;
unsigned int tick;
struct status_change_data data;
+ struct status_change *sc = &sd->sc;
const struct TimerData *timer;
if (sd->state.finalsave) //Character was already saved?
@@ -1036,17 +1037,21 @@ int chrif_save_scdata(struct map_session_data *sd)
WFIFOL(char_fd,8) = sd->status.char_id;
for (i = 0; i < SC_MAX; i++)
{
- if (sd->sc.data[i].timer == -1)
+ if (!sc->data[i])
continue;
- timer = get_timer(sd->sc.data[i].timer);
- if (timer == NULL || timer->func != status_change_timer || DIFF_TICK(timer->tick,tick) < 0)
- continue;
- data.tick = DIFF_TICK(timer->tick,tick); //Duration that is left before ending.
+ if (sc->data[i]->timer != -1)
+ {
+ timer = get_timer(sc->data[i]->timer);
+ if (timer == NULL || timer->func != status_change_timer || DIFF_TICK(timer->tick,tick) < 0)
+ continue;
+ data.tick = DIFF_TICK(timer->tick,tick); //Duration that is left before ending.
+ } else
+ data.tick = -1; //Infinite duration
data.type = i;
- data.val1 = sd->sc.data[i].val1;
- data.val2 = sd->sc.data[i].val2;
- data.val3 = sd->sc.data[i].val3;
- data.val4 = sd->sc.data[i].val4;
+ data.val1 = sc->data[i]->val1;
+ data.val2 = sc->data[i]->val2;
+ data.val3 = sc->data[i]->val3;
+ data.val4 = sc->data[i]->val4;
memcpy(WFIFOP(char_fd,14 +count*sizeof(struct status_change_data)),
&data, sizeof(struct status_change_data));
count++;
@@ -1086,11 +1091,6 @@ int chrif_load_scdata(int fd)
for (i = 0; i < count; i++)
{
data = (struct status_change_data*)RFIFOP(fd,14 + i*sizeof(struct status_change_data));
- if (data->tick < 1)
- { //Protection against invalid tick values. [Skotlex]
- ShowWarning("chrif_load_scdata: Received invalid duration (%d ms) for status change %d (character %s)\n", data->tick, data->type, sd->status.name);
- continue;
- }
status_change_start(&sd->bl, data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, 15);
}
#endif