From 9d7d036456ad886c3a60aa73c4db37822923bf60 Mon Sep 17 00:00:00 2001 From: ai4rei Date: Sat, 18 Dec 2010 15:20:31 +0000 Subject: * Fixed character storage no longer being sorted (bugreport:1982, since r12950). - Guild storage is now sorted before being displayed rather than after being saved... - Merged storage_gsortitem into storage_sortitem. - Added option 'client_sort_storage' to control storage sorting. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14605 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 4 ++++ conf/battle/client.conf | 5 +++++ src/map/battle.c | 1 + src/map/battle.h | 1 + src/map/storage.c | 21 ++++++++++----------- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 4f1ceedb2..9e2d86998 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,6 +1,10 @@ Date Added 2010/12/18 + * Fixed character storage no longer being sorted (bugreport:1982, since r12950). [Ai4rei] + - Guild storage is now sorted before being displayed rather than after being saved... + - Merged storage_gsortitem into storage_sortitem. + - Added option 'client_sort_storage' to control storage sorting (disabled by default, like on official servers). * Updates to handling of hair color/style and cloth color of characters. [Ai4rei] - Moved limit shortcut defines from mmo.h to battle.h, as they are only required in files, which include battle.h (since pre-svn 2004/10/15). - Moved hair style/color validation from char-server to map-server. This enables use of non-default limits as specified in battle config, rather than being restricted to hard-coded ones (bugreport:150). diff --git a/conf/battle/client.conf b/conf/battle/client.conf index ab46930f5..143505a36 100644 --- a/conf/battle/client.conf +++ b/conf/battle/client.conf @@ -123,3 +123,8 @@ display_status_timers: yes // Randomizes the dice emoticon server-side, to prevent clients from forging // packets for the desired number. (Note 1) client_reshuffle_dice: no + +// Sorts the character and guild storage before it is sent to the client. +// Official servers do not sort storage. (Note 1) +// NOTE: Enabling this option degrades performance. +client_sort_storage: no diff --git a/src/map/battle.c b/src/map/battle.c index 4feb6d4ce..32def23f3 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -4005,6 +4005,7 @@ static const struct _battle_data { { "mob_slave_keep_target", &battle_config.mob_slave_keep_target, 0, 0, 1, }, { "autospell_check_range", &battle_config.autospell_check_range, 0, 0, 1, }, { "client_reshuffle_dice", &battle_config.client_reshuffle_dice, 0, 0, 1, }, + { "client_sort_storage", &battle_config.client_sort_storage, 0, 0, 1, }, // BattleGround Settings { "bg_update_interval", &battle_config.bg_update_interval, 1000, 100, INT_MAX, }, { "bg_short_attack_damage_rate", &battle_config.bg_short_damage_rate, 80, 0, INT_MAX, }, diff --git a/src/map/battle.h b/src/map/battle.h index 1a879f5b5..3abc6b0a4 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -479,6 +479,7 @@ extern struct Battle_Config int mob_slave_keep_target; int autospell_check_range; //Enable range check for autospell bonus. [L0ne_W0lf] int client_reshuffle_dice; // Reshuffle /dice + int client_sort_storage; // [BattleGround Settings] int bg_update_interval; diff --git a/src/map/storage.c b/src/map/storage.c index 2e668f08d..e2749bfd9 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -42,17 +42,15 @@ static int storage_comp_item(const void *_i1, const void *_i2) return -1; return i1->nameid - i2->nameid; } -/* In case someone wants to use it in the future. -static void storage_sortitem(struct storage_data* stor) -{ - nullpo_retv(stor); - qsort(stor->items, MAX_STORAGE, sizeof(struct item), storage_comp_item); -} -*/ -static void storage_gsortitem(struct guild_storage* gstor) + +static void storage_sortitem(struct item* items, unsigned int size) { - nullpo_retv(gstor); - qsort(gstor->storage_, MAX_GUILD_STORAGE, sizeof(struct item), storage_comp_item); + nullpo_retv(items); + + if( battle_config.client_sort_storage ) + { + qsort(items, size, sizeof(struct item), storage_comp_item); + } } /*========================================== @@ -104,6 +102,7 @@ int storage_storageopen(struct map_session_data *sd) } sd->state.storage_flag = 1; + storage_sortitem(sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items)); clif_storagelist(sd, sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items)); clif_updatestorageamount(sd,sd->status.storage.storage_amount); return 0; @@ -380,6 +379,7 @@ int storage_guild_storageopen(struct map_session_data* sd) gstor->storage_status = 1; sd->state.storage_flag = 2; + storage_sortitem(gstor->storage_, ARRAYLENGTH(gstor->storage_)); clif_storagelist(sd, gstor->storage_, ARRAYLENGTH(gstor->storage_)); clif_updateguildstorageamount(sd,gstor->storage_amount); return 0; @@ -584,7 +584,6 @@ int storage_guild_storagesaved(int guild_id) if (stor->dirty && stor->storage_status == 0) { //Storage has been correctly saved. stor->dirty = 0; - storage_gsortitem(stor); } return 1; } -- cgit v1.2.3-60-g2f50