浏览代码

Fixes item production with high item IDs (#5315)

* Fixes #5312.
* Fixes general item production skills not consuming catalyst items with high IDs.
* Adjusts item searching functions to use t_itemid instead of uint32.
* Adjusts script command makeitem2 to use t_itemid isntead of uint32.
* Fixes output and lookups for atcommands idsearch, autolootitem, iteminfo, whodrops, makeegg, and itemlist.
* Fixes signed vs unsigned checks.
* Fixes MVP logging.
* Fixes item drop ratio storage.
* Fixes CSV2YAML conversion checks.
Thanks to @idk-whoami and @Lemongrass3110!
Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
Aleos 4 年之前
父节点
当前提交
5c5c6839a0

+ 1 - 1
conf/msg_conf/map_msg.conf

@@ -92,7 +92,7 @@
 75: War of Emperium is currently not in progress.
 76: All skills have been added to your skill tree.
 77: The reference result of '%s' (name: id):
-78: - %s: %d
+78: - %s: %u
 79: It is %d affair above.
 80: Give the display name or monster name/id please.
 81: Your GM level doesn't authorize you to perform this action on the specified player.

+ 1 - 1
conf/msg_conf/map_msg_chn.conf

@@ -96,7 +96,7 @@
 75: 公會戰還沒開始
 76: 您學會了所有技能
 77: 委託 '%s' (名字: 編號):
-78: %s: %d
+78: %s: %u
 79: 查詢到 %d 個符合條件的結果
 80: 重新讀取任務資料庫
 81: 您的GM 等級並沒有權限在這位玩家上執行這個動作

+ 1 - 1
conf/msg_conf/map_msg_frn.conf

@@ -96,7 +96,7 @@
 75: La War of Emperium n'est pas en cours.
 76: Toutes les compétences sont ajoutées à votre arbre de compétence.
 77: Résultat de '%s' (nom: id):
-78: %s: %d
+78: %s: %u
 79: %d résultats sont affichés.
 80: Veuillez donner le nom/id du montre.
 81: Votre niveau de GM ne vous autorise pas à effectuer cette action sur le Joueur spécifié.

+ 1 - 1
conf/msg_conf/map_msg_grm.conf

@@ -95,7 +95,7 @@
 75: War of Emperium ist zur Zeit nicht im Gange.
 76: Alle Fähigkeiten wurden deinem Fähigkeitenbaum hinzugefügt.
 77: Das Ergebnis der Suche nach '%s' lautet (Name: ID):
-78: %s: %d
+78: %s: %u
 79: Es wurden %d Gegenstände gefunden.
 80: Gib bitte den Anzeige-Namen oder die Monster-ID an.
 81: Dein GM-Level berechtigt dich nicht, diese Aktion auf dem angegebenen Spieler auszuführen.

+ 1 - 1
conf/msg_conf/map_msg_idn.conf

@@ -92,7 +92,7 @@
 75: War of Emperium saat ini tidak sedang berjalan.
 76: Semua skill telah ditambahkan ke skill tree.
 77: Hasil referensi dari '%s' (nama: id):
-78: - %s: %d
+78: - %s: %u
 79: Terdapat %d hal di atas.
 80: Harap berikan nama tampilan atau nama/id monster.
 81: Level GM kamu tidak diizinkan untuk untuk melakukan aksi ini pada pemain tertentu.

+ 1 - 1
conf/msg_conf/map_msg_por.conf

@@ -102,7 +102,7 @@
 75: A Guerra do Emperium ainda não foi iniciada.
 76: Todas as habilidades foram adicionadas à sua árvore de habilidades.
 77: O resultado da referência à '%s' (nome: id):
-78: %s: %d
+78: %s: %u
 79: Encontrado %d acima.
 80: Entre com o nome de exibição ou nome/id do monstro.
 81: Seu nível de Game Master não autoriza a realização desta ação neste personagem.

+ 1 - 1
conf/msg_conf/map_msg_rus.conf

@@ -94,7 +94,7 @@
 75: Война за Империум в настоящее время не идёт.
 76: Все навыки добавлены в дерево умений.
 77: Результаты поиска '%s' (название: ID):
-78: %s: %d
+78: %s: %u
 79: Всего найдено %d результатов.
 80: Введите отображаемое имя или ID/название монстра.
 81: Ваши права Администратора не позволяют выполнять данное действие на указанного игрока.

+ 1 - 1
conf/msg_conf/map_msg_spn.conf

@@ -92,7 +92,7 @@
 75: En estos momentos no hay ninguna guerra de clanes.
 76: Se han añadido todas las habilidades a tu árbol de habilidades.
 77: Estos son los resultados de la búsqueda de '%s' (nombre: ID):
-78: %s: %d
+78: %s: %u
 79: Total de resultados: %d
 80: Debes introducir el nombre del monstruo o su ID.
 81: Tu nivel de GM no te permite utilizar este comando en ese jugador.

+ 1 - 1
conf/msg_conf/map_msg_tha.conf

@@ -96,7 +96,7 @@
 75: War of Emperium ה�טה´י·�§�¹���טד¹¢³�¹�י.
 76: ·�� Skill ה´י¶��א¾�ט�÷¹µ����¤�¤�³א���÷�י��ב�י�.
 77: ¼���¾¸ל���¤י¹��ג´��י�§��§¨�� '%s' (×�ט�: ����):
-78: %s: %d
+78: %s: %u
 79: ¼���¾¸ל %d ¢י�§µי¹.
 80: ���³���÷�×�ט� Monster ���� ���� Monster.
 81: ��´�÷ GM ¢�§¤�³ ה�טה´י��÷�¹�­�µד�י¤�³�����¶´�א¹�¹�����÷µ����¤�·�ט��÷�ה´י.

+ 1 - 1
src/char/int_storage.cpp

@@ -356,7 +356,7 @@ bool mapif_parse_itembound_retrieve(int fd)
 	}
 
 	SqlStmt_BindColumn(stmt, 0, SQLDT_INT,       &item.id,          0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 1, SQLDT_UINT,    &item.nameid,      0, NULL, NULL);
+	SqlStmt_BindColumn(stmt, 1, SQLDT_UINT,      &item.nameid,      0, NULL, NULL);
 	SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT,     &item.amount,      0, NULL, NULL);
 	SqlStmt_BindColumn(stmt, 3, SQLDT_UINT,      &item.equip,       0, NULL, NULL);
 	SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR,      &item.identify,    0, NULL, NULL);

+ 22 - 14
src/map/atcommand.cpp

@@ -2827,10 +2827,9 @@ ACMD_FUNC(makeegg) {
 		return -1;
 	}
 
-	if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
-		id = item_data->nameid;
-	else
-	if ((id = mobdb_searchname(message)) != 0) // for monster name
+
+	// for monster name
+	if ((id = mobdb_searchname(message)) != 0)
 		;
 	else
 		id = atoi(message);
@@ -2838,7 +2837,16 @@ ACMD_FUNC(makeegg) {
 	std::shared_ptr<s_pet_db> pet = pet_db.find(id);
 
 	if( pet == nullptr ){
-		pet = pet_db_search(id, PET_EGG);
+		t_itemid nameid;
+
+		// for egg name
+		if( ( item_data = itemdb_searchname( message ) ) != nullptr ){
+			nameid = item_data->nameid;
+		}else{
+			nameid = strtoul( message, nullptr, 10 );
+		}
+
+		pet = pet_db_search( nameid, PET_EGG );
 	}
 
 	if (pet != nullptr) {
@@ -3723,7 +3731,7 @@ ACMD_FUNC(idsearch)
 		clif_displaymessage(fd, atcmd_output);
 	}
 	for(i = 0; i < match; i++) {
-		sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
+		sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %u
 		clif_displaymessage(fd, atcmd_output);
 	}
 	sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
@@ -6293,7 +6301,7 @@ ACMD_FUNC(autolootitem)
 
 	if (action < 3) // add or remove
 	{
-		if ((item_data = itemdb_exists(atoi(message))) == NULL)
+		if ((item_data = itemdb_exists(strtoul(message, nullptr, 10))) == nullptr)
 			item_data = itemdb_searchname(message);
 		if (!item_data) {
 			// No items founds in the DB with Id or Name
@@ -7391,7 +7399,7 @@ ACMD_FUNC(mobinfo)
 		j = 0;
 		for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
 			int droprate;
-			if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
+			if (mob->dropitem[i].nameid == 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
 				continue;
 			droprate = mob->dropitem[i].p;
 
@@ -7427,7 +7435,7 @@ ACMD_FUNC(mobinfo)
 			mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
 			j = 0;
 			for (i = 0; i < MAX_MVP_DROP_TOTAL; i++) {
-				if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
+				if (mob->mvpitem[i].nameid == 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
 					continue;
 				//Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
 				mvppercent = (float)mob->mvpitem[i].p * mvpremain / 10000.0f;
@@ -7855,7 +7863,7 @@ ACMD_FUNC(iteminfo)
 		clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
 		return -1;
 	}
-	if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
+	if ((item_array[0] = itemdb_exists(strtoul(message, nullptr, 10))) == nullptr)
 		count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
 
 	if (!count) {
@@ -7906,7 +7914,7 @@ ACMD_FUNC(whodrops)
 		clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
 		return -1;
 	}
-	if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
+	if ((item_array[0] = itemdb_exists(strtoul(message, nullptr, 10))) == nullptr)
 		count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
 
 	if (!count) {
@@ -8886,9 +8894,9 @@ ACMD_FUNC(itemlist)
 		}
 
 		if( it->refine )
-			StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
+			StringBuf_Printf(&buf, "%d %s %+d (%s, id: %u)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
 		else
-			StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
+			StringBuf_Printf(&buf, "%d %s (%s, id: %u)", it->amount, itd->jname, itd->name, it->nameid);
 
 		if( it->equip ) {
 			char equipstr[CHAT_SIZE_MAX];
@@ -8988,7 +8996,7 @@ ACMD_FUNC(itemlist)
 				if( counter2 != 1 )
 					StringBuf_AppendStr(&buf, ", ");
 
-				StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
+				StringBuf_Printf(&buf, "#%d %s (id: %u)", counter2, card->jname, card->nameid);
 			}
 
 			if( counter2 > 0 )

+ 27 - 46
src/map/clif.cpp

@@ -849,17 +849,15 @@ void clif_charselectok(int id, uint8 ok)
 void clif_dropflooritem( struct flooritem_data* fitem, bool canShowEffect ){
 	nullpo_retv(fitem);
 
-	if( fitem->item.nameid <= 0 ){
+	if( fitem->item.nameid == 0 ){
 		return;
 	}
 
-	int view = itemdb_viewid( fitem->item.nameid );
-
 	struct packet_dropflooritem p;
 
 	p.PacketType = dropflooritemType;
 	p.ITAID = fitem->bl.id;
-	p.ITID = ( view > 0 ) ? view : fitem->item.nameid;
+	p.ITID = client_nameid( fitem->item.nameid );
 #if PACKETVER >= 20130000 /* not sure date */
 	p.type = itemtype( fitem->item.nameid );
 #endif
@@ -2650,28 +2648,12 @@ static void clif_addcards( struct EQUIPSLOTINFO* buf, struct item* item ){
 	}
 
 	// Normal items.
-	if( item->card[i] > 0 && ( j = itemdb_viewid( item->card[i] ) ) > 0 ){
-		buf->card[0] = j;
-	}else{
-		buf->card[0] = item->card[i];
-	}
-
-	if( item->card[++i] > 0 && ( j = itemdb_viewid( item->card[i] ) ) > 0 ){
-		buf->card[1] = j;
-	}else{
-		buf->card[1] = item->card[i];
-	}
-
-	if( item->card[++i] > 0 && ( j = itemdb_viewid( item->card[i] ) ) > 0 ){
-		buf->card[2] = j;
-	}else{
-		buf->card[2] = item->card[i];
-	}
-
-	if( item->card[++i] > 0 && ( j = itemdb_viewid( item->card[i] ) ) > 0 ){
-		buf->card[3] = j;
-	}else{
-		buf->card[3] = item->card[i];
+	for( int k = 0; k < 4; k++, i++ ){
+		if( item->card[i] > 0 ){
+			buf->card[k] = client_nameid( item->card[i] );
+		}else{
+			buf->card[k] = 0;
+		}
 	}
 }
 
@@ -2727,7 +2709,7 @@ void clif_additem( struct map_session_data *sd, int n, int amount, unsigned char
 	if( fail ){
 		p = {};
 	}else{
-		if( n < 0 || n >= MAX_INVENTORY || sd->inventory.u.items_inventory[n].nameid <= 0 || sd->inventory_data[n] == nullptr ){
+		if( n < 0 || n >= MAX_INVENTORY || sd->inventory.u.items_inventory[n].nameid == 0 || sd->inventory_data[n] == nullptr ){
 			return;
 		}
 
@@ -2952,7 +2934,7 @@ void clif_inventorylist( struct map_session_data *sd ){
 	int normal = 0;
 
 	for( int i = 0; i < MAX_INVENTORY; i++ ){
-		if( sd->inventory.u.items_inventory[i].nameid <= 0 || sd->inventory_data[i] == nullptr ){
+		if( sd->inventory.u.items_inventory[i].nameid == 0 || sd->inventory_data[i] == nullptr ){
 			continue;
 		}
 
@@ -3018,7 +3000,7 @@ void clif_inventorylist( struct map_session_data *sd ){
 /* on 20120925 onwards this is a field on clif_item_equip/normal */
 #if PACKETVER >= 20111122 && PACKETVER < 20120925
 	for( int i = 0; i < MAX_INVENTORY; i++ ){
-		if( sd->inventory.u.items_inventory[i].nameid <= 0 || sd->inventory_data[i] == NULL )
+		if( sd->inventory.u.items_inventory[i].nameid == 0 || sd->inventory_data[i] == NULL )
 			continue;
 
 		if ( sd->inventory.u.items_inventory[i].favorite )
@@ -3045,7 +3027,7 @@ void clif_storagelist(struct map_session_data* sd, struct item* items, int items
 	int normal = 0;
 
 	for( int i = 0; i < items_length; i++ ){
-		if( items[i].nameid <= 0 ){
+		if( items[i].nameid == 0 ){
 			continue;
 		}
 
@@ -3131,7 +3113,7 @@ void clif_cartlist( struct map_session_data *sd ){
 	int equip = 0;
 
 	for( int i = 0; i < MAX_CART; i++ ){
-		if( sd->cart.u.items_cart[i].nameid <= 0 ){
+		if( sd->cart.u.items_cart[i].nameid == 0 ){
 			continue;
 		}
 
@@ -3698,7 +3680,7 @@ void clif_changelook(struct block_list *bl, int type, int val) {
 #if PACKETVER > 3
 				if (sd) {
 					int n;
-					if((n = sd->equip_index[2]) >= 0 && sd->inventory_data[n]) {
+					if((n = sd->equip_index[EQI_SHOES]) >= 0 && sd->inventory_data[n]) {
 						if(sd->inventory_data[n]->view_id > 0)
 							val = sd->inventory_data[n]->view_id;
 						else
@@ -4155,7 +4137,7 @@ void clif_useitemack( struct map_session_data *sd, int index, int amount, bool o
 		return;
 	}
 
-	if( index < 0 || index >= MAX_INVENTORY || sd->inventory.u.items_inventory[index].nameid <= 0 || sd->inventory_data[index] == nullptr ){
+	if( index < 0 || index >= MAX_INVENTORY || sd->inventory.u.items_inventory[index].nameid == 0 || sd->inventory_data[index] == nullptr ){
 		return;
 	}
 
@@ -4490,7 +4472,7 @@ void clif_tradeadditem( struct map_session_data* sd, struct map_session_data* ts
 	if( index ){
 		index = server_index( index );
 
-		if( index >= MAX_INVENTORY || sd->inventory.u.items_inventory[index].nameid <= 0 || sd->inventory_data[index] == nullptr ){
+		if( index >= MAX_INVENTORY || sd->inventory.u.items_inventory[index].nameid == 0 || sd->inventory_data[index] == nullptr ){
 			return;
 		}
 
@@ -5093,11 +5075,10 @@ void clif_getareachar_item( struct map_session_data* sd,struct flooritem_data* f
 	nullpo_retv( fitem );
 
 	struct PACKET_ZC_ITEM_ENTRY p;
-	int view = itemdb_viewid( fitem->item.nameid );
 
 	p.packetType = HEADER_ZC_ITEM_ENTRY;
 	p.AID = fitem->bl.id;
-	p.itemId = view > 0 ? view : fitem->item.nameid;
+	p.itemId = client_nameid( fitem->item.nameid );
 	p.identify = fitem->item.identify;
 	p.x = fitem->bl.x;
 	p.y = fitem->bl.y;
@@ -6840,7 +6821,7 @@ void clif_item_identify_list(struct map_session_data *sd)
 	WFIFOW(fd,0)=0x177;
 	for(i=c=0;i<MAX_INVENTORY;i++){
 		if(sd->inventory.u.items_inventory[i].nameid > 0 && !sd->inventory.u.items_inventory[i].identify){
-			WFIFOW(fd,c*2+4)=i+2;
+			WFIFOW(fd,c*2+4)=client_index(i);
 			c++;
 		}
 	}
@@ -6895,7 +6876,7 @@ void clif_item_repair_list( struct map_session_data *sd,struct map_session_data
 	for( int i = 0; i < MAX_INVENTORY; i++ ){
 		if( dstsd->inventory.u.items_inventory[i].nameid > 0 && dstsd->inventory.u.items_inventory[i].attribute != 0 && !itemdb_ishatched_egg( &dstsd->inventory.u.items_inventory[i] ) ){ // && skill_can_repair(sd,nameid)){
 			p->items[c].index = i;
-			p->items[c].itemId = dstsd->inventory.u.items_inventory[i].nameid;
+			p->items[c].itemId = client_nameid( dstsd->inventory.u.items_inventory[i].nameid );
 			p->items[c].refine = dstsd->inventory.u.items_inventory[i].refine;
 			clif_addcards( &p->items[c].slot, &dstsd->inventory.u.items_inventory[i] );
 			c++;
@@ -7041,7 +7022,7 @@ void clif_cart_additem( struct map_session_data *sd, int n, int amount ){
 		return;
 	}
 
-	if( n < 0 || n >= MAX_CART || sd->cart.u.items_cart[n].nameid <= 0 ){
+	if( n < 0 || n >= MAX_CART || sd->cart.u.items_cart[n].nameid == 0 ){
 		return;
 	}
 
@@ -8067,11 +8048,11 @@ void clif_sendegg(struct map_session_data *sd)
 	WFIFOHEAD(fd, MAX_INVENTORY * 2 + 4);
 	WFIFOW(fd,0)=0x1a6;
 	for(i=0,n=0;i<MAX_INVENTORY;i++){
-		if(sd->inventory.u.items_inventory[i].nameid <= 0 || sd->inventory_data[i] == NULL ||
+		if(sd->inventory.u.items_inventory[i].nameid == 0 || sd->inventory_data[i] == NULL ||
 		   sd->inventory_data[i]->type != IT_PETEGG ||
 		   sd->inventory.u.items_inventory[i].amount <= 0)
 			continue;
-		WFIFOW(fd,n*2+4)=i+2;
+		WFIFOW(fd,n*2+4)=client_index(i);
 		n++;
 	}
 	WFIFOW(fd,2)=4+n*2;
@@ -10096,7 +10077,7 @@ void clif_viewequip_ack( struct map_session_data* sd, struct map_session_data* t
 		int k = tsd->equip_index[i];
 
 		if( k >= 0 ){
-			if( tsd->inventory.u.items_inventory[k].nameid <= 0 || tsd->inventory_data[k] == NULL ){ // Item doesn't exist
+			if( tsd->inventory.u.items_inventory[k].nameid == 0 || tsd->inventory_data[k] == NULL ){ // Item doesn't exist
 				continue;
 			}
 
@@ -13028,7 +13009,7 @@ void clif_parse_ItemIdentify(int fd,struct map_session_data *sd) {
 	// - Invalid item ID or item doesn't exist
 	// - Item is already identified
 	if (idx < 0 || idx >= MAX_INVENTORY ||
-		sd->inventory.u.items_inventory[idx].nameid <= 0 || sd->inventory_data[idx] == NULL ||
+		sd->inventory.u.items_inventory[idx].nameid == 0 || sd->inventory_data[idx] == NULL ||
 		sd->inventory.u.items_inventory[idx].identify) {// cancel pressed
 			sd->state.workinprogress = WIP_DISABLE_NONE;
 			clif_menuskill_clear(sd);
@@ -18229,7 +18210,7 @@ void clif_party_show_picker( struct map_session_data* sd, struct item* item_data
 
 	p.packetType = HEADER_ZC_ITEM_PICKUP_PARTY;
 	p.AID = sd->status.account_id;
-	p.itemId = item_data->nameid;
+	p.itemId = client_nameid( item_data->nameid );
 	p.identified = item_data->identify;
 	p.damaged = item_data->attribute;
 	p.refine = item_data->refine;
@@ -20019,7 +20000,7 @@ void clif_roulette_info( struct map_session_data* sd ){
 		for( int j = 0; j < MAX_ROULETTE_COLUMNS - i; j++ ){
 			p.ItemInfo[count].Row = i;
 			p.ItemInfo[count].Position = j;
-			p.ItemInfo[count].ItemId = rd.nameid[i][j];
+			p.ItemInfo[count].ItemId = client_nameid( rd.nameid[i][j] );
 			p.ItemInfo[count].Count = rd.qty[i][j];
 #if PACKETVER >= 20180511
 			p.ItemInfo[count].unused = 0;
@@ -20507,7 +20488,7 @@ void clif_parse_Oneclick_Itemidentify(int fd, struct map_session_data *sd) {
 	// - Invalid item ID or item doesn't exist
 	// - Item is already identified
 	if (idx < 0 || idx >= MAX_INVENTORY ||
-		sd->inventory.u.items_inventory[idx].nameid <= 0 || sd->inventory_data[idx] == NULL ||
+		sd->inventory.u.items_inventory[idx].nameid == 0 || sd->inventory_data[idx] == NULL ||
 		sd->inventory.u.items_inventory[idx].identify)
 			return;
 

+ 2 - 2
src/map/itemdb.cpp

@@ -692,7 +692,7 @@ static bool itemdb_read_group(char* str[], int columns, int current) {
 	str[1] = trim(str[1]);
 
 	// Check if the item can be found by id
-	if( ( entry.nameid = strtoul(str[1], nullptr, 10) ) <= 0 || !itemdb_exists( entry.nameid ) ){
+	if( ( entry.nameid = strtoul(str[1], nullptr, 10) ) == 0 || !itemdb_exists( entry.nameid ) ){
 		// Otherwise look it up by name
 		struct item_data *id = itemdb_searchname(str[1]);
 
@@ -781,7 +781,7 @@ static bool itemdb_read_itemtrade(char* str[], int columns, int current) {
 
 	if( ( id = itemdb_exists(nameid) ) == NULL )
 	{
-		//ShowWarning("itemdb_read_itemtrade: Invalid item id %d.\n", nameid);
+		//ShowWarning("itemdb_read_itemtrade: Invalid item id %u.\n", nameid);
 		//return false;
 		// FIXME: item_trade.txt contains items, which are commented in item database.
 		return true;

+ 2 - 2
src/map/itemdb.hpp

@@ -907,8 +907,8 @@ struct s_random_opt_group {
 struct item_data* itemdb_searchname(const char *name);
 struct item_data* itemdb_search_aegisname( const char *str );
 int itemdb_searchname_array(struct item_data** data, int size, const char *str);
-struct item_data* itemdb_search(uint32 nameid);
-struct item_data* itemdb_exists(uint32 nameid);
+struct item_data* itemdb_search(t_itemid nameid);
+struct item_data* itemdb_exists(t_itemid nameid);
 #define itemdb_name(n) itemdb_search(n)->name
 #define itemdb_jname(n) itemdb_search(n)->jname
 #define itemdb_type(n) itemdb_search(n)->type

+ 4 - 4
src/map/log.cpp

@@ -305,7 +305,7 @@ void log_zeny(struct map_session_data* sd, e_log_pick_type type, struct map_sess
 
 
 /// logs MVP monster rewards
-void log_mvpdrop(struct map_session_data* sd, int monster_id, unsigned int* log_mvp)
+void log_mvpdrop(struct map_session_data* sd, int monster_id, t_itemid nameid, t_exp exp )
 {
 	nullpo_retv(sd);
 
@@ -314,8 +314,8 @@ void log_mvpdrop(struct map_session_data* sd, int monster_id, unsigned int* log_
 
 	if( log_config.sql_logs )
 	{
-		if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%u', '%u', '%s') ",
-			log_config.log_mvpdrop, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex)) )
+		if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%u', '%" PRIu64 "', '%s') ",
+			log_config.log_mvpdrop, sd->status.char_id, monster_id, nameid, exp, mapindex_id2name(sd->mapindex)) )
 		{
 			Sql_ShowDebug(logmysql_handle);
 			return;
@@ -331,7 +331,7 @@ void log_mvpdrop(struct map_session_data* sd, int monster_id, unsigned int* log_
 			return;
 		time(&curtime);
 		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
-		fprintf(logfp,"%s - %s[%d:%d]\t%d\t%hu,%u\n", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, monster_id, (unsigned short)log_mvp[0], log_mvp[1]);
+		fprintf(logfp,"%s - %s[%d:%d]\t%d\t%u,%" PRIu64 "\n", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, monster_id, nameid, exp);
 		fclose(logfp);
 	}
 }

+ 1 - 1
src/map/log.hpp

@@ -82,7 +82,7 @@ void log_feeding(struct map_session_data *sd, e_log_feeding_type type, t_itemid
 
 /// old, but useful logs
 void log_branch(struct map_session_data* sd);
-void log_mvpdrop(struct map_session_data* sd, int monster_id, unsigned int* log_mvp);
+void log_mvpdrop(struct map_session_data* sd, int monster_id, t_itemid nameid, t_exp exp);
 
 int log_config_read(const char* cfgName);
 

+ 11 - 10
src/map/mob.cpp

@@ -2719,7 +2719,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 		dlist->item = NULL;
 
 		for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
-			if (md->db->dropitem[i].nameid <= 0)
+			if (md->db->dropitem[i].nameid == 0)
 				continue;
 			if ( !(it = itemdb_exists(md->db->dropitem[i].nameid)) )
 				continue;
@@ -2877,7 +2877,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 	}
 
 	if(mvp_sd && md->db->mexp > 0 && !md->special_state.ai) {
-		unsigned int log_mvp[2] = {0};
+		t_itemid log_mvp_nameid = 0;
+		t_exp log_mvp_exp = 0;
 		unsigned int mexp;
 		struct item item;
 		double exp;
@@ -2896,7 +2897,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 		clif_mvp_effect(mvp_sd);
 		clif_mvp_exp(mvp_sd,mexp);
 		pc_gainexp(mvp_sd, &md->bl, mexp,0, 0);
-		log_mvp[1] = mexp;
+		log_mvp_exp = mexp;
 
 		if( !(map_getmapflag(m, MF_NOMVPLOOT) || type&1) ) {
 			//Order might be random depending on item_drop_mvp_mode config setting
@@ -2927,7 +2928,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 			for(i = 0; i < MAX_MVP_DROP_TOTAL; i++) {
 				struct item_data *i_data;
 
-				if(mdrop[i].nameid <= 0 || !(i_data = itemdb_exists(mdrop[i].nameid)))
+				if(mdrop[i].nameid == 0 || !(i_data = itemdb_exists(mdrop[i].nameid)))
 					continue;
 
 				temp = mdrop[i].p;
@@ -2942,7 +2943,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 				item.nameid=mdrop[i].nameid;
 				item.identify= itemdb_isidentified(item.nameid);
 				clif_mvp_item(mvp_sd,item.nameid);
-				log_mvp[0] = item.nameid;
+				log_mvp_nameid = item.nameid;
 
 				//A Rare MVP Drop Global Announce by Lupus
 				if(temp<=battle_config.rare_drop_announce) {
@@ -2971,7 +2972,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 			}
 		}
 
-		log_mvpdrop(mvp_sd, md->mob_id, log_mvp);
+		log_mvpdrop(mvp_sd, md->mob_id, log_mvp_nameid, log_mvp_exp);
 	}
 
 	if (type&2 && !sd && md->mob_id == MOBID_EMPERIUM)
@@ -4113,7 +4114,7 @@ static unsigned int mob_drop_adjust(int baserate, int rate_adjust, unsigned shor
  */
 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);
+	struct s_mob_item_drop_ratio *item_ratio = (struct s_mob_item_drop_ratio *)uidb_get(mob_item_drop_ratio, nameid);
 	if( item_ratio) {
 		if( item_ratio->mob_id[0] ) { // only for listed mobs
 			int i;
@@ -5164,7 +5165,7 @@ static bool mob_readdb_itemratio(char* str[], int columns, int current)
 
 	ratio = atoi(str[1]);
 
-	if (!(item_ratio = (struct s_mob_item_drop_ratio *)idb_get(mob_item_drop_ratio,nameid)))
+	if (!(item_ratio = (struct s_mob_item_drop_ratio *)uidb_get(mob_item_drop_ratio,nameid)))
 		CREATE(item_ratio, struct s_mob_item_drop_ratio, 1);
 
 	item_ratio->drop_ratio = ratio;
@@ -5179,7 +5180,7 @@ static bool mob_readdb_itemratio(char* str[], int columns, int current)
 
 	if (!item_ratio->nameid) {
 		item_ratio->nameid = nameid;
-		idb_put(mob_item_drop_ratio, nameid, item_ratio);
+		uidb_put(mob_item_drop_ratio, nameid, item_ratio);
 	}
 
 	return true;
@@ -5612,7 +5613,7 @@ void mob_db_load(bool is_reload){
 		item_drop_ers = ers_new(sizeof(struct item_drop),"mob.cpp::item_drop_ers",ERS_OPT_CLEAN);
 		item_drop_list_ers = ers_new(sizeof(struct item_drop_list),"mob.cpp::item_drop_list_ers",ERS_OPT_NONE);
 	}
-	mob_item_drop_ratio = idb_alloc(DB_OPT_BASE);
+	mob_item_drop_ratio = uidb_alloc(DB_OPT_BASE);
 	mob_skill_db = idb_alloc(DB_OPT_BASE);
 	mob_summon_db = idb_alloc(DB_OPT_BASE);
 	mob_load();

+ 4 - 4
src/map/pc.cpp

@@ -1074,7 +1074,7 @@ void pc_setequipindex(struct map_session_data *sd)
 	}
 
 	for (i = 0; i < MAX_INVENTORY; i++) {
-		if (sd->inventory.u.items_inventory[i].nameid <= 0)
+		if (sd->inventory.u.items_inventory[i].nameid == 0)
 			continue;
 		if (sd->inventory.u.items_inventory[i].equip) {
 			uint8 j;
@@ -4632,9 +4632,9 @@ int pc_insert_card(struct map_session_data* sd, int idx_card, int idx_equip)
 		return 0; //Invalid item index.
 	if(item_card == nullptr)
 		return 0; //Invalid card index.
-	if( sd->inventory.u.items_inventory[idx_equip].nameid <= 0 || sd->inventory.u.items_inventory[idx_equip].amount < 1 )
+	if( sd->inventory.u.items_inventory[idx_equip].nameid == 0 || sd->inventory.u.items_inventory[idx_equip].amount < 1 )
 		return 0; // target item missing
-	if( sd->inventory.u.items_inventory[idx_card].nameid <= 0 || sd->inventory.u.items_inventory[idx_card].amount < 1 )
+	if( sd->inventory.u.items_inventory[idx_card].nameid == 0 || sd->inventory.u.items_inventory[idx_card].amount < 1 )
 		return 0; // target card missing
 	if( item_eq->type != IT_WEAPON && item_eq->type != IT_ARMOR )
 		return 0; // only weapons and armor are allowed
@@ -5154,7 +5154,7 @@ bool pc_dropitem(struct map_session_data *sd,int n,int amount)
 	if(amount <= 0)
 		return false;
 
-	if(sd->inventory.u.items_inventory[n].nameid <= 0 ||
+	if(sd->inventory.u.items_inventory[n].nameid == 0 ||
 		sd->inventory.u.items_inventory[n].amount <= 0 ||
 		sd->inventory.u.items_inventory[n].amount < amount ||
 		sd->state.trading || sd->state.vending ||

+ 1 - 1
src/map/pet.cpp

@@ -1196,7 +1196,7 @@ int pet_select_egg(struct map_session_data *sd,short egg_index)
 
 	std::shared_ptr<s_pet_db> pet = pet_db_search(sd->inventory.u.items_inventory[egg_index].nameid, PET_EGG);
 	if (!pet) {
-		ShowError("pet does not exist, egg id %d\n", sd->inventory.u.items_inventory[egg_index].nameid);
+		ShowError("pet does not exist, egg id %u\n", sd->inventory.u.items_inventory[egg_index].nameid);
 		return 0;
 	}
 

+ 2 - 2
src/map/script.cpp

@@ -7933,7 +7933,7 @@ BUILDIN_FUNC(makeitem) {
  * makeitem3 "<item name>",<amount>,"<map name>",<X>,<Y>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<RandomIDArray>,<RandomValueArray>,<RandomParamArray>;
  */
 BUILDIN_FUNC(makeitem2) {
-	uint32 nameid;
+	t_itemid nameid;
 	uint16 amount, x, y;
 	const char *mapname;
 	int m;
@@ -10619,7 +10619,7 @@ BUILDIN_FUNC(getmobdrops)
 
 	for( i = 0; i < MAX_MOB_DROP_TOTAL; i++ )
 	{
-		if( mob->dropitem[i].nameid < 1 )
+		if( mob->dropitem[i].nameid == 0 )
 			continue;
 		if( itemdb_exists(mob->dropitem[i].nameid) == NULL )
 			continue;

+ 3 - 2
src/map/skill.cpp

@@ -19848,7 +19848,8 @@ bool skill_produce_mix(struct map_session_data *sd, uint16 skill_id, t_itemid na
 	}
 
 	for (i = 0; i < MAX_PRODUCE_RESOURCE; i++) {
-		short id, x, j;
+		short x, j;
+		t_itemid id;
 
 		if (!(id = skill_produce_db[idx].mat_id[i]) || !itemdb_exists(id))
 			continue;
@@ -22683,7 +22684,7 @@ uint64 ReadingSpellbookDatabase::parseBodyNode(const YAML::Node &node) {
  * @return Spell data or nullptr otherwise
  */
 std::shared_ptr<s_skill_spellbook_db> ReadingSpellbookDatabase::findBook(t_itemid nameid) {
-	if (nameid < 1 || !itemdb_exists(nameid) || reading_spellbook_db.size() == 0)
+	if (nameid == 0 || !itemdb_exists(nameid) || reading_spellbook_db.size() == 0)
 		return nullptr;
 
 	for (const auto &spell : reading_spellbook_db) {

+ 29 - 28
src/tool/csv2yaml.cpp

@@ -104,7 +104,7 @@ static bool quest_read_db(char *split[], int columns, int current);
 static bool instance_readdb_sub(char* str[], int columns, int current);
 
 // Constants for conversion
-std::unordered_map<uint16, std::string> aegis_itemnames;
+std::unordered_map<t_itemid, std::string> aegis_itemnames;
 std::unordered_map<uint16, uint16> aegis_itemviewid;
 std::unordered_map<uint16, std::string> aegis_mobnames;
 std::unordered_map<uint16, std::string> aegis_skillnames;
@@ -770,49 +770,49 @@ static bool pet_read_db( const char* file ){
 		body << YAML::BeginMap;
 		body << YAML::Key << "Mob" << YAML::Value << *mob_name;
 
-		uint16 tame_item_id = (uint16)atoi( str[3] );
+		t_itemid tame_item_id = strtoul( str[3], nullptr, 10 );
 
 		if( tame_item_id > 0 ){
 			std::string* tame_item_name = util::umap_find( aegis_itemnames, tame_item_id );
 
 			if( tame_item_name == nullptr ){
-				ShowError( "Item name for item id %hu is not known.\n", tame_item_id );
+				ShowError( "Item name for item id %u is not known.\n", tame_item_id );
 				return false;
 			}
 
 			body << YAML::Key << "TameItem" << YAML::Value << *tame_item_name;
 		}
 
-		uint16 egg_item_id = (uint16)atoi( str[4] );
+		t_itemid egg_item_id = strtoul( str[4], nullptr, 10 );
 		std::string* egg_item_name = util::umap_find( aegis_itemnames, egg_item_id );
 
 		if( egg_item_name == nullptr ){
-			ShowError( "Item name for item id %hu is not known.\n", egg_item_id );
+			ShowError( "Item name for item id %u is not known.\n", egg_item_id );
 			return false;
 		}
 
 		body << YAML::Key << "EggItem" << YAML::Value << *egg_item_name;
 
-		uint16 equip_item_id = (uint16)atoi( str[5] );
+		t_itemid equip_item_id = strtoul( str[5], nullptr, 10 );
 
 		if( equip_item_id > 0 ){
 			std::string* equip_item_name = util::umap_find( aegis_itemnames, equip_item_id );
 
 			if( equip_item_name == nullptr ){
-				ShowError( "Item name for item id %hu is not known.\n", equip_item_id );
+				ShowError( "Item name for item id %u is not known.\n", equip_item_id );
 				return false;
 			}
 
 			body << YAML::Key << "EquipItem" << YAML::Value << *equip_item_name;
 		}
 
-		uint16 food_item_id = (uint16)atoi( str[6] );
+		t_itemid food_item_id = strtoul( str[6], nullptr, 10 );
 
 		if( food_item_id > 0 ){
 			std::string* food_item_name = util::umap_find( aegis_itemnames, food_item_id );
 
 			if( food_item_name == nullptr ){
-				ShowError( "Item name for item id %hu is not known.\n", food_item_id );
+				ShowError( "Item name for item id %u is not known.\n", food_item_id );
 				return false;
 			}
 
@@ -936,11 +936,11 @@ static bool skill_parse_row_spellbookdb(char* split[], int columns, int current)
 		return false;
 	}
 
-	uint16 nameid = atoi(split[2]);
+	t_itemid nameid = strtoul(split[2], nullptr, 10);
 	std::string *book_name = util::umap_find(aegis_itemnames, nameid);
 
 	if (book_name == nullptr) {
-		ShowError("Book name for item ID %hu is not known.\n", nameid);
+		ShowError("Book name for item ID %u is not known.\n", nameid);
 		return false;
 	}
 
@@ -998,11 +998,11 @@ static bool mob_readdb_mobavail(char* str[], int columns, int current) {
 			body << YAML::Key << "ClothColor" << YAML::Value << atoi(str[11]);
 
 		if (atoi(str[5]) != 0) {
-			uint16 weapon_item_id = atoi(str[5]);
+			t_itemid weapon_item_id = strtoul( str[5], nullptr, 10 );
 			std::string *weapon_item_name = util::umap_find(aegis_itemnames, weapon_item_id);
 
 			if (weapon_item_name == nullptr) {
-				ShowError("Item name for item ID %hu (weapon) is not known.\n", weapon_item_id);
+				ShowError("Item name for item ID %u (weapon) is not known.\n", weapon_item_id);
 				return false;
 			}
 
@@ -1010,11 +1010,11 @@ static bool mob_readdb_mobavail(char* str[], int columns, int current) {
 		}
 
 		if (atoi(str[6]) != 0) {
-			uint16 shield_item_id = atoi(str[6]);
+			t_itemid shield_item_id = strtoul( str[6], nullptr, 10 );
 			std::string *shield_item_name = util::umap_find(aegis_itemnames, shield_item_id);
 
 			if (shield_item_name == nullptr) {
-				ShowError("Item name for item ID %hu (shield) is not known.\n", shield_item_id);
+				ShowError("Item name for item ID %u (shield) is not known.\n", shield_item_id);
 				return false;
 			}
 
@@ -1029,7 +1029,7 @@ static bool mob_readdb_mobavail(char* str[], int columns, int current) {
 				return false;
 			}
 
-			std::string *headtop_item_name = util::umap_find(aegis_itemnames, *headtop_item_id);
+			std::string *headtop_item_name = util::umap_find(aegis_itemnames, (t_itemid)*headtop_item_id);
 
 			if (headtop_item_name == nullptr) {
 				ShowError("Item name for item ID %hu (head top) is not known.\n", *headtop_item_id);
@@ -1047,7 +1047,7 @@ static bool mob_readdb_mobavail(char* str[], int columns, int current) {
 				return false;
 			}
 
-			std::string *headmid_item_name = util::umap_find(aegis_itemnames, *headmid_item_id);
+			std::string *headmid_item_name = util::umap_find(aegis_itemnames, (t_itemid)*headmid_item_id);
 
 			if (headmid_item_name == nullptr) {
 				ShowError("Item name for item ID %hu (head mid) is not known.\n", *headmid_item_id);
@@ -1065,7 +1065,7 @@ static bool mob_readdb_mobavail(char* str[], int columns, int current) {
 				return false;
 			}
 
-			std::string *headlow_item_name = util::umap_find(aegis_itemnames, *headlow_item_id);
+			std::string *headlow_item_name = util::umap_find(aegis_itemnames, (t_itemid)*headlow_item_id);
 
 			if (headlow_item_name == nullptr) {
 				ShowError("Item name for item ID %hu (head low) is not known.\n", *headlow_item_id);
@@ -1167,11 +1167,11 @@ static bool mob_readdb_mobavail(char* str[], int columns, int current) {
 		}
 	} else if (columns == 3) {
 		if (atoi(str[5]) != 0) {
-			uint16 peteq_item_id = atoi(str[5]);
+			t_itemid peteq_item_id = strtoul( str[5], nullptr, 10 );
 			std::string *peteq_item_name = util::umap_find(aegis_itemnames, peteq_item_id);
 
 			if (peteq_item_name == nullptr) {
-				ShowError("Item name for item ID %hu (pet equip) is not known.\n", peteq_item_id);
+				ShowError("Item name for item ID %u (pet equip) is not known.\n", peteq_item_id);
 				return false;
 			}
 
@@ -1268,11 +1268,11 @@ static bool skill_parse_row_requiredb(char* split[], int columns, int current)
 
 	for (int i = 0; i < MAX_SKILL_ITEM_REQUIRE; i++) {
 		if (atoi(split[13 + 2 * i]) > 0) {
-			uint16 item_id = atoi(split[13 + 2 * i]);
+			t_itemid item_id = strtoul( split[13 + 2 * i], nullptr, 10 );
 			std::string *item_name = util::umap_find(aegis_itemnames, item_id);
 
 			if (item_name == nullptr) {
-				ShowError("Item name for item id %hu is not known.\n", item_id);
+				ShowError("Item name for item id %u is not known.\n", item_id);
 				return false;
 			}
 
@@ -2224,7 +2224,7 @@ static bool skill_parse_row_skilldb(char* split[], int columns, int current) {
 				if (it_req->second.itemid[i] > 0) {
 					body << YAML::BeginMap;
 
-					std::string *item_name = util::umap_find(aegis_itemnames, static_cast<uint16>(it_req->second.itemid[i]));
+					std::string *item_name = util::umap_find(aegis_itemnames, it_req->second.itemid[i]);
 
 					if (item_name == nullptr) {
 						ShowError("Item name for item id %hu is not known (itemcost).\n", it_req->second.itemid[i]);
@@ -2245,10 +2245,10 @@ static bool skill_parse_row_skilldb(char* split[], int columns, int current) {
 			body << YAML::BeginMap;
 
 			for (const auto &it : it_req->second.eqItem) {
-				std::string *item_name = util::umap_find(aegis_itemnames, static_cast<uint16>(it));
+				std::string *item_name = util::umap_find(aegis_itemnames, it);
 
 				if (item_name == nullptr) {
-					ShowError("Item name for item id %hu is not known (equipment).\n", it);
+					ShowError("Item name for item id %u is not known (equipment).\n", it);
 					return false;
 				}
 
@@ -2490,7 +2490,8 @@ static bool quest_read_db(char *split[], int columns, int current) {
 		body << YAML::BeginSeq;
 
 		for (size_t i = 0; i < MAX_QUEST_DROPS; i++) {
-			int32 mob_id = (int32)atoi(split[3 * i + (2 * MAX_QUEST_OBJECTIVES + 2)]), nameid = (uint16)atoi(split[3 * i + (2 * MAX_QUEST_OBJECTIVES + 3)]);
+			int32 mob_id = (int32)atoi(split[3 * i + (2 * MAX_QUEST_OBJECTIVES + 2)]);
+			t_itemid nameid = strtoul(split[3 * i + (2 * MAX_QUEST_OBJECTIVES + 3)], nullptr, 10);
 
 			if (!mob_id || !nameid)
 				continue;
@@ -2502,10 +2503,10 @@ static bool quest_read_db(char *split[], int columns, int current) {
 				continue;
 			}
 
-			std::string *item_name = util::umap_find(aegis_itemnames, static_cast<uint16>(nameid));
+			std::string *item_name = util::umap_find(aegis_itemnames, nameid);
 
 			if (!item_name) {
-				ShowError("quest_read_db: Invalid item name %hu, drop not read.\n", nameid);
+				ShowError("quest_read_db: Invalid item name %u, drop not read.\n", nameid);
 				return false;
 			}