From 66027680356416134aaa6e3564f3b11330323aca Mon Sep 17 00:00:00 2001 From: csnv Date: Sun, 4 Feb 2024 01:53:21 +0100 Subject: [PATCH 1/4] Fixed aCalloc order warnings --- src/char/int_party.c | 2 +- src/char/int_pet.c | 2 +- src/map/instance.c | 4 ++-- src/map/map.c | 4 ++-- src/map/mob.c | 4 ++-- src/map/npc_chat.c | 6 +++--- src/map/script.c | 8 ++++---- src/map/storage.c | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/char/int_party.c b/src/char/int_party.c index 83ab22343e..dc005948c7 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -363,7 +363,7 @@ static int inter_party_sql_init(void) { //memory alloc inter_party->db = idb_alloc(DB_OPT_RELEASE_DATA); - inter_party->pt = (struct party_data*)aCalloc(sizeof(struct party_data), 1); + inter_party->pt = (struct party_data*)aCalloc(1, sizeof(struct party_data)); if (!inter_party->pt) { ShowFatalError("inter_party->sql_init: Out of Memory!\n"); exit(EXIT_FAILURE); diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 5529e6f7cb..1c7c515a57 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -206,7 +206,7 @@ static int inter_pet_fromsql(int pet_id, struct s_pet *p) static int inter_pet_sql_init(void) { //memory alloc - inter_pet->pt = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1); + inter_pet->pt = (struct s_pet*)aCalloc(1, sizeof(struct s_pet)); return 0; } diff --git a/src/map/instance.c b/src/map/instance.c index d6a5cf7a5e..b5d547ba71 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -259,8 +259,8 @@ static int instance_add_map(const char *name, int instance_id, bool usebasename, } size = map->list[im].bxs * map->list[im].bys * sizeof(struct block_list*); - map->list[im].block = (struct block_list**)aCalloc(size, 1); - map->list[im].block_mob = (struct block_list**)aCalloc(size, 1); + map->list[im].block = (struct block_list**)aCalloc(1, size); + map->list[im].block_mob = (struct block_list**)aCalloc(1, size); memset(map->list[im].npc, 0x00, sizeof(map->list[i].npc)); map->list[im].npc_num = 0; diff --git a/src/map/map.c b/src/map/map.c index d80975aac7..c1788d5723 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -4031,8 +4031,8 @@ static int map_readallmaps(void) map->list[i].bys = (map->list[i].ys + BLOCK_SIZE - 1) / BLOCK_SIZE; size = map->list[i].bxs * map->list[i].bys * sizeof(struct block_list*); - map->list[i].block = (struct block_list**)aCalloc(size, 1); - map->list[i].block_mob = (struct block_list**)aCalloc(size, 1); + map->list[i].block = (struct block_list**)aCalloc(1, size); + map->list[i].block_mob = (struct block_list**)aCalloc(1, size); map->list[i].getcellp = map->sub_getcellp; map->list[i].setcell = map->sub_setcell; diff --git a/src/map/mob.c b/src/map/mob.c index 513cd75217..00c1107eb6 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -4377,7 +4377,7 @@ static bool mob_read_optdrops_optslot(struct config_setting_t *optslot, int n, i } struct optdrop_group_optslot *entry = &(mob->opt_drop_groups[group_id].optslot[n]); - entry->options = aCalloc(sizeof(struct optdrop_group_option), count); + entry->options = aCalloc(count, sizeof(struct optdrop_group_option)); int idx = 0; int i = 0; @@ -4458,7 +4458,7 @@ static bool mob_read_optdrops_db(void) int i = 0; if (its != NULL && (groups = libconfig->setting_get_elem(its, 0)) != NULL) { int count = libconfig->setting_length(groups); - mob->opt_drop_groups = aCalloc(sizeof(struct optdrop_group), count); + mob->opt_drop_groups = aCalloc(count, sizeof(struct optdrop_group)); mob->opt_drop_groups_count = count; // maximum size (used by assertions) struct config_setting_t *group = NULL; diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index 752a71719f..08e73ad97c 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -118,7 +118,7 @@ static struct pcrematch_set *lookup_pcreset(struct npc_data *nd, int setid) nullpo_retr(NULL, nd); npcParse = nd->chatdb; if (npcParse == NULL) - nd->chatdb = npcParse = (struct npc_parse *)aCalloc(sizeof(struct npc_parse), 1); + nd->chatdb = npcParse = (struct npc_parse *)aCalloc(1, sizeof(struct npc_parse)); pcreset = npcParse->active; @@ -137,7 +137,7 @@ static struct pcrematch_set *lookup_pcreset(struct npc_data *nd, int setid) } if (pcreset == NULL) { - pcreset = (struct pcrematch_set *)aCalloc(sizeof(struct pcrematch_set), 1); + pcreset = (struct pcrematch_set *)aCalloc(1, sizeof(struct pcrematch_set)); pcreset->next = npcParse->inactive; if (pcreset->next != NULL) pcreset->next->prev = pcreset; @@ -284,7 +284,7 @@ static struct pcrematch_entry *create_pcrematch_entry(struct pcrematch_set *set) struct pcrematch_entry *last; nullpo_retr(NULL, set); - e = (struct pcrematch_entry *)aCalloc(sizeof(struct pcrematch_entry), 1); + e = (struct pcrematch_entry *)aCalloc(1, sizeof(struct pcrematch_entry)); last = set->head; // Normally we would have just stuck it at the end of the list but diff --git a/src/map/script.c b/src/map/script.c index 843cd81746..774cdd2168 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -7050,7 +7050,7 @@ static BUILDIN(callfunc) return false; } - ref = (struct reg_db *)aCalloc(sizeof(struct reg_db), 2); + ref = (struct reg_db *)aCalloc(2, sizeof(struct reg_db)); ref[0].vars = st->stack->scope.vars; if (!st->stack->scope.arrays) st->stack->scope.arrays = idb_alloc(DB_OPT_BASE); // TODO: Can this happen? when? @@ -7145,7 +7145,7 @@ static BUILDIN(callfunctionofnpc) { } // alloc a reg_db reference of the current scope for the new scope - struct reg_db *ref = (struct reg_db *)aCalloc(sizeof(struct reg_db), 2); + struct reg_db *ref = (struct reg_db *)aCalloc(2, sizeof(struct reg_db)); // scope variables (.@var) ref[0].vars = st->stack->scope.vars; ref[0].arrays = st->stack->scope.arrays; @@ -7214,7 +7214,7 @@ static BUILDIN(callsub) return false; } - ref = (struct reg_db *)aCalloc(sizeof(struct reg_db), 1); + ref = (struct reg_db *)aCalloc(1, sizeof(struct reg_db)); ref[0].vars = st->stack->scope.vars; if (!st->stack->scope.arrays) st->stack->scope.arrays = idb_alloc(DB_OPT_BASE); // TODO: Can this happen? when? @@ -7312,7 +7312,7 @@ static BUILDIN(return) // npc variable if( !data->ref ) { // npc variable without a reference set, link to current script - data->ref = (struct reg_db *)aCalloc(sizeof(struct reg_db), 1); + data->ref = (struct reg_db *)aCalloc(1, sizeof(struct reg_db)); script->add_pending_ref(st, data->ref); data->ref->vars = st->script->local.vars; if( !st->script->local.arrays ) diff --git a/src/map/storage.c b/src/map/storage.c index fc5eaf0ad8..f1267a6216 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -457,7 +457,7 @@ static void storage_storage_quit(struct map_session_data *sd, int flag) static struct DBData create_guildstorage(union DBKey key, va_list args) { struct guild_storage *gs = NULL; - gs = (struct guild_storage *) aCalloc(sizeof(struct guild_storage), 1); + gs = (struct guild_storage *) aCalloc(1, sizeof(struct guild_storage)); gs->guild_id=key.i; return DB->ptr2data(gs); } From 59914fbc7a69650cf698feb74208d91b8b7f55f6 Mon Sep 17 00:00:00 2001 From: csnv Date: Sun, 4 Feb 2024 01:54:28 +0100 Subject: [PATCH 2/4] Removed undocumented crit bonus under cloak status --- src/map/status.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/map/status.c b/src/map/status.c index dd1a926c9e..9b8a35c955 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -4626,8 +4626,6 @@ static int status_calc_critical(struct block_list *bl, struct status_change *sc, critical += sc->data[SC_FORTUNE]->val2; if (sc->data[SC_TRUESIGHT]) critical += sc->data[SC_TRUESIGHT]->val2; - if (sc->data[SC_CLOAKING]) - critical += critical; if (sc->data[SC_STRIKING]) critical += sc->data[SC_STRIKING]->val1; #ifdef RENEWAL From 78229c4c1bfbe68f27124d02f4f7bef581804058 Mon Sep 17 00:00:00 2001 From: csnv Date: Sun, 4 Feb 2024 01:55:14 +0100 Subject: [PATCH 3/4] Fixed overweight not being correctly updated in some scenarios --- src/map/pc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/map/pc.c b/src/map/pc.c index 975a9e719f..312f5760ee 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2002,6 +2002,9 @@ static int pc_updateweightstatus(struct map_session_data *sd) old_overweight = (sd->sc.data[SC_WEIGHTOVER90]) ? 2 : (sd->sc.data[SC_WEIGHTOVER50]) ? 1 : 0; new_overweight = (pc_is90overweight(sd)) ? 2 : (pc_isoverhealweight(sd)) ? 1 : 0; + // update overweight status + sd->regen.state.overweight = new_overweight; + if( old_overweight == new_overweight ) return 0; // no change @@ -2017,8 +2020,6 @@ static int pc_updateweightstatus(struct map_session_data *sd) else if( new_overweight == 2 ) sc_start(NULL, &sd->bl, SC_WEIGHTOVER90, 100, 0, 0, 0); - // update overweight status - sd->regen.state.overweight = new_overweight; return 0; } From 1e309bd0bd8e6440191ea52d329af1ef5952e619 Mon Sep 17 00:00:00 2001 From: csnv Date: Sun, 4 Feb 2024 01:55:58 +0100 Subject: [PATCH 4/4] Fixed some scenarios were server didnt allow client to update position --- src/map/clif.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/map/clif.c b/src/map/clif.c index 7e6081f23f..d6d0686250 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -11840,6 +11840,7 @@ static void clif_parse_WalkToXY(int fd, struct map_session_data *sd) // Do not allow one cell move commands if the target cell is not free if (battle_config.official_cell_stack_limit > 0 + && (sd->bl.x != x || sd->bl.y != y) // Allow current cell && check_distance_blxy(&sd->bl, x, y, 1) && map->count_oncell(sd->bl.m, x, y, BL_CHAR | BL_NPC, 0x1 | 0x2) >= battle_config.official_cell_stack_limit) return;