Browse Source

raspberry simple adaptation

added a new version of itemdb_group_free at map/itemdb.c.
Johnathan Fercher 8 years ago
parent
commit
755329fe11
1 changed files with 27 additions and 1 deletions
  1. 27 1
      src/map/itemdb.c

+ 27 - 1
src/map/itemdb.c

@@ -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;
@@ -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{
@@ -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;
@@ -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)