瀏覽代碼

Fix Arrow Crafting db with high item ids (#5307)

Fixes #5306
Fixes arrow crafting db and produce db, changed atoi and shorts to strtoul and t_nameid
Vincent Stumpf 4 年之前
父節點
當前提交
223153116e
共有 1 個文件被更改,包括 8 次插入7 次删除
  1. 8 7
      src/map/skill.cpp

+ 8 - 7
src/map/skill.cpp

@@ -22773,7 +22773,7 @@ static bool skill_parse_row_producedb(char* split[], int columns, int current)
 	}
 	}
 
 
 	if (!itemdb_exists(nameid)) {
 	if (!itemdb_exists(nameid)) {
-		ShowError("skill_parse_row_producedb: Invalid item %d.\n", nameid);
+		ShowError("skill_parse_row_producedb: Invalid item %u.\n", nameid);
 		return false;
 		return false;
 	}
 	}
 
 
@@ -22783,7 +22783,7 @@ static bool skill_parse_row_producedb(char* split[], int columns, int current)
 	skill_produce_db[id].req_skill_lv = atoi(split[4]);
 	skill_produce_db[id].req_skill_lv = atoi(split[4]);
 
 
 	for (x = 5, y = 0; x+1 < columns && split[x] && split[x+1] && y < MAX_PRODUCE_RESOURCE; x += 2, y++) {
 	for (x = 5, y = 0; x+1 < columns && split[x] && split[x+1] && y < MAX_PRODUCE_RESOURCE; x += 2, y++) {
-		skill_produce_db[id].mat_id[y] = atoi(split[x]);
+		skill_produce_db[id].mat_id[y] = strtoul(split[x], nullptr, 10);
 		skill_produce_db[id].mat_amount[y] = atoi(split[x+1]);
 		skill_produce_db[id].mat_amount[y] = atoi(split[x+1]);
 	}
 	}
 
 
@@ -22798,10 +22798,11 @@ static bool skill_parse_row_producedb(char* split[], int columns, int current)
  */
  */
 static bool skill_parse_row_createarrowdb(char* split[], int columns, int current)
 static bool skill_parse_row_createarrowdb(char* split[], int columns, int current)
 {
 {
-	unsigned short x, y, i, material_id = atoi(split[0]);
+	unsigned short x, y, i;
+	t_itemid material_id = strtoul(split[0], nullptr, 10);
 
 
 	if (!(itemdb_exists(material_id))) {
 	if (!(itemdb_exists(material_id))) {
-		ShowError("skill_parse_row_createarrowdb: Invalid item %d.\n", material_id);
+		ShowError("skill_parse_row_createarrowdb: Invalid item %u.\n", material_id);
 		return false;
 		return false;
 	}
 	}
 
 
@@ -22813,15 +22814,15 @@ static bool skill_parse_row_createarrowdb(char* split[], int columns, int curren
 	}
 	}
 
 
 	// Import just for clearing/disabling from original data
 	// Import just for clearing/disabling from original data
-	if (atoi(split[1]) == 0) {
+	if (strtoul(split[1], nullptr, 10) == 0) {
 		memset(&skill_arrow_db[i], 0, sizeof(skill_arrow_db[i]));
 		memset(&skill_arrow_db[i], 0, sizeof(skill_arrow_db[i]));
-		//ShowInfo("skill_parse_row_createarrowdb: Arrow creation with Material ID %d removed from list.\n", material_id);
+		//ShowInfo("skill_parse_row_createarrowdb: Arrow creation with Material ID %u removed from list.\n", material_id);
 		return true;
 		return true;
 	}
 	}
 
 
 	skill_arrow_db[i].nameid = material_id;
 	skill_arrow_db[i].nameid = material_id;
 	for (x = 1, y = 0; x+1 < columns && split[x] && split[x+1] && y < MAX_ARROW_RESULT; x += 2, y++) {
 	for (x = 1, y = 0; x+1 < columns && split[x] && split[x+1] && y < MAX_ARROW_RESULT; x += 2, y++) {
-		skill_arrow_db[i].cre_id[y] = atoi(split[x]);
+		skill_arrow_db[i].cre_id[y] = strtoul(split[x], nullptr, 10);
 		skill_arrow_db[i].cre_amount[y] = atoi(split[x+1]);
 		skill_arrow_db[i].cre_amount[y] = atoi(split[x+1]);
 	}
 	}
 	if (i == skill_arrow_count)
 	if (i == skill_arrow_count)