Skip to content

Commit

Permalink
raspberry simple adaptation
Browse files Browse the repository at this point in the history
added a new version of itemdb_group_free at map/itemdb.c.
  • Loading branch information
johnfercher authored and lighta committed Jan 8, 2017
1 parent 14b79ea commit 755329f
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/map/itemdb.c
Expand Up @@ -571,6 +571,7 @@ static bool itemdb_read_itemavail(char* str[], int columns, int current) {
}

static int itemdb_group_free(DBKey key, DBData *data, va_list ap);
static int itemdb_group_free2(DBKey key, DBData *data);

static bool itemdb_read_group(char* str[], int columns, int current) {
int group_id = -1;
Expand Down Expand Up @@ -603,7 +604,7 @@ static bool itemdb_read_group(char* str[], int columns, int current) {
DBData data;

if( itemdb_group->remove( itemdb_group, db_ui2key(group_id), &data ) ){
itemdb_group_free( db_ui2key(group_id), &data, 0 );
itemdb_group_free2(db_ui2key(group_id), &data);
ShowNotice( "itemdb_read_group: Item Group '%s' has been cleared.\n", str[0] );
return true;
}else{
Expand Down Expand Up @@ -1774,6 +1775,10 @@ static int itemdb_final_sub(DBKey key, DBData *data, va_list ap)
return 0;
}

/** NOTE:
* In some OSs, like Raspbian, we aren't allowed to pass 0 in va_list.
* So, itemdb_group_free2 is useful in some cases.
*/
static int itemdb_group_free(DBKey key, DBData *data, va_list ap) {
struct s_item_group_db *group = (struct s_item_group_db *)db_data2ptr(data);
uint8 j;
Expand All @@ -1792,6 +1797,27 @@ static int itemdb_group_free(DBKey key, DBData *data, va_list ap) {
return 0;
}

/** (Raspberry PI)
* Adaptation of itemdb_group_free. This function enables to run rAthena on Raspbian OS.
*/
static int itemdb_group_free2(DBKey key, DBData *data) {
struct s_item_group_db *group = (struct s_item_group_db *)db_data2ptr(data);
uint8 j;
if (!group)
return 0;
if (group->must_qty)
aFree(group->must);
group->must_qty = 0;
for (j = 0; j < MAX_ITEMGROUP_RANDGROUP; j++) {
if (!group->random[j].data_qty || !(&group->random[j]))
continue;
aFree(group->random[j].data);
group->random[j].data_qty = 0;
}
aFree(group);
return 0;
}

static int itemdb_randomopt_free(DBKey key, DBData *data, va_list ap) {
struct s_random_opt_data *opt = (struct s_random_opt_data *)db_data2ptr(data);
if (!opt)
Expand Down

0 comments on commit 755329f

Please sign in to comment.