Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed overweight, removed undocumented critical bonus, fixed position update, aCalloc warnings #2

Merged
merged 4 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/char/int_party.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/char/int_pet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/map/clif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/map/instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/map/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/map/mob.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/map/npc_chat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/map/pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/map/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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 )
Expand Down
2 changes: 0 additions & 2 deletions src/map/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/map/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading