Support itemids up to ~2 billion (#5141)

Co-authored-by: aleos89 <aleos89@users.noreply.github.com>
Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
This commit is contained in:
Vincent Stumpf
2020-08-08 03:06:07 -07:00
committed by GitHub
parent fd148a6783
commit 3776bfbaa3
71 changed files with 1012 additions and 777 deletions

View File

@@ -87,7 +87,7 @@ struct mob_chat *mob_chat(short id) {
//Dynamic item drop ratio database for per-item drop ratio modifiers overriding global drop ratios.
#define MAX_ITEMRATIO_MOBS 10
struct s_mob_item_drop_ratio {
unsigned short nameid;
t_itemid nameid;
int drop_ratio;
unsigned short mob_id[MAX_ITEMRATIO_MOBS];
};
@@ -2814,7 +2814,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if(sd) {
// process script-granted extra drop bonuses
uint16 dropid = 0;
t_itemid dropid = 0;
for (const auto &it : sd->add_drop) {
struct s_mob_drop mobdrop;
@@ -4111,7 +4111,7 @@ static unsigned int mob_drop_adjust(int baserate, int rate_adjust, unsigned shor
* @param mob_id ID of the monster
* @param rate_adjust pointer to store ratio if found
*/
static void item_dropratio_adjust(unsigned short nameid, int mob_id, int *rate_adjust)
static void item_dropratio_adjust(t_itemid nameid, int mob_id, int *rate_adjust)
{
struct s_mob_item_drop_ratio *item_ratio = (struct s_mob_item_drop_ratio *)idb_get(mob_item_drop_ratio, nameid);
if( item_ratio) {
@@ -4269,7 +4269,7 @@ static bool mob_parse_dbrow(char** str)
// MVP Drops: MVP1id,MVP1per,MVP2id,MVP2per,MVP3id,MVP3per
for(i = 0; i < MAX_MVP_DROP; i++) {
entry.mvpitem[i].nameid = atoi(str[31+i*2]);
entry.mvpitem[i].nameid = strtoul(str[31+i*2], nullptr, 10);
if( entry.mvpitem[i].nameid ){
if( itemdb_search(entry.mvpitem[i].nameid) ){
@@ -4288,7 +4288,7 @@ static bool mob_parse_dbrow(char** str)
for(i = 0; i < MAX_MOB_DROP; i++) {
int k = 31 + MAX_MVP_DROP*2 + i*2;
entry.dropitem[i].nameid = atoi(str[k]);
entry.dropitem[i].nameid = strtoul(str[k], nullptr, 10);
if( entry.dropitem[i].nameid ){
if( itemdb_search( entry.dropitem[i].nameid ) ){
@@ -5152,13 +5152,13 @@ static bool mob_readdb_race2(char* fields[], int columns, int current)
*/
static bool mob_readdb_itemratio(char* str[], int columns, int current)
{
unsigned short nameid;
t_itemid nameid;
int ratio, i;
struct s_mob_item_drop_ratio *item_ratio;
nameid = atoi(str[0]);
nameid = strtoul(str[0], nullptr, 10);
if (itemdb_exists(nameid) == NULL) {
ShowWarning("mob_readdb_itemratio: Invalid item id %hu.\n", nameid);
ShowWarning("mob_readdb_itemratio: Invalid item id %u.\n", nameid);
return false;
}
@@ -5172,7 +5172,7 @@ static bool mob_readdb_itemratio(char* str[], int columns, int current)
for (i = 0; i < columns-2; i++) {
uint16 mob_id = atoi(str[i+2]);
if (mob_db(mob_id) == NULL)
ShowError("mob_readdb_itemratio: Invalid monster with ID %hu (Item:%hu Col:%d).\n", mob_id, nameid, columns);
ShowError("mob_readdb_itemratio: Invalid monster with ID %hu (Item:%u Col:%d).\n", mob_id, nameid, columns);
else
item_ratio->mob_id[i] = atoi(str[i+2]);
}
@@ -5190,7 +5190,8 @@ static bool mob_readdb_itemratio(char* str[], int columns, int current)
* @author [Cydh]
**/
static bool mob_readdb_drop(char* str[], int columns, int current) {
unsigned short mobid, nameid;
unsigned short mobid;
t_itemid nameid;
int rate, i, size, flag = 0;
struct mob_db *mob;
struct s_mob_drop *drop;
@@ -5201,7 +5202,7 @@ static bool mob_readdb_drop(char* str[], int columns, int current) {
return false;
}
nameid = atoi(str[1]);
nameid = strtoul(str[1], nullptr, 10);
if (itemdb_exists(nameid) == NULL) {
ShowWarning("mob_readdb_drop: Invalid item ID %s.\n", str[1]);
return false;
@@ -5221,7 +5222,7 @@ static bool mob_readdb_drop(char* str[], int columns, int current) {
for (i = 0; i < size; i++) {
if (drop[i].nameid == nameid) {
memset(&drop[i], 0, sizeof(struct s_mob_drop));
ShowInfo("mob_readdb_drop: Removed item '%hu' from monster '%hu'.\n", nameid, mobid);
ShowInfo("mob_readdb_drop: Removed item '%u' from monster '%hu'.\n", nameid, mobid);
return true;
}
}
@@ -5231,7 +5232,7 @@ static bool mob_readdb_drop(char* str[], int columns, int current) {
if (i == size) { // Item is not dropped at all (search all item slots)
ARR_FIND(0, size, i, drop[i].nameid == 0);
if (i == size) { // No empty slots
ShowError("mob_readdb_drop: Cannot add item '%hu' to monster '%hu'. Max drop reached (%d).\n", nameid, mobid, size);
ShowError("mob_readdb_drop: Cannot add item '%u' to monster '%hu'. Max drop reached (%d).\n", nameid, mobid, size);
return true;
}
}
@@ -5279,7 +5280,7 @@ static void mob_drop_ratio_adjust(void){
for( auto &pair : mob_db_data ){
struct mob_db *mob;
struct item_data *id;
unsigned short nameid;
t_itemid nameid;
int j, rate, rate_adjust = 0, mob_id;
mob_id = pair.first;
@@ -5311,7 +5312,7 @@ static void mob_drop_ratio_adjust(void){
// Item is not known anymore(should never happen)
if( !id ){
ShowWarning( "Monster \"%s\"(id:%hu) is dropping an unknown item(id: %d)\n", mob->name, mob_id, nameid );
ShowWarning( "Monster \"%s\"(id:%hu) is dropping an unknown item(id: %u)\n", mob->name, mob_id, nameid );
mob->mvpitem[j].nameid = 0;
mob->mvpitem[j].p = 0;
continue;
@@ -5341,7 +5342,7 @@ static void mob_drop_ratio_adjust(void){
// Item is not known anymore(should never happen)
if( !id ){
ShowWarning( "Monster \"%s\"(id:%hu) is dropping an unknown item(id: %d)\n", mob->name, mob_id, nameid );
ShowWarning( "Monster \"%s\"(id:%hu) is dropping an unknown item(id: %u)\n", mob->name, mob_id, nameid );
mob->dropitem[j].nameid = 0;
mob->dropitem[j].p = 0;
continue;