Browse Source

Added ID field to mob_db structure (#6069)

Fixes #6055

Thanks to @k1ngJ
Lemongrass3110 3 years ago
parent
commit
af97f7f9bd
7 changed files with 18 additions and 19 deletions
  1. 1 1
      src/map/achievement.cpp
  2. 2 2
      src/map/atcommand.cpp
  3. 9 7
      src/map/mob.cpp
  4. 1 0
      src/map/mob.hpp
  5. 2 2
      src/map/pet.cpp
  6. 2 2
      src/map/quest.cpp
  7. 1 5
      src/map/unit.hpp

+ 1 - 1
src/map/achievement.cpp

@@ -167,7 +167,7 @@ uint64 AchievementDatabase::parseBodyNode(const YAML::Node &node){
 					return 0;
 					return 0;
 				}
 				}
 
 
-				uint32 mob_id = mob->vd.class_;
+				uint32 mob_id = mob->id;
 
 
 				if( !this->mobexists( mob_id ) ){
 				if( !this->mobexists( mob_id ) ){
 					this->achievement_mobs.push_back( mob_id );
 					this->achievement_mobs.push_back( mob_id );

+ 2 - 2
src/map/atcommand.cpp

@@ -7431,9 +7431,9 @@ ACMD_FUNC(mobinfo)
 #endif
 #endif
 		// stats
 		// stats
 		if( mob->get_bosstype() == BOSSTYPE_MVP )
 		if( mob->get_bosstype() == BOSSTYPE_MVP )
-			sprintf(atcmd_output, msg_txt(sd,1240), mob->name.c_str(), mob->jname.c_str(), mob->sprite.c_str(), mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
+			sprintf(atcmd_output, msg_txt(sd,1240), mob->name.c_str(), mob->jname.c_str(), mob->sprite.c_str(), mob->id); // MVP Monster: '%s'/'%s'/'%s' (%d)
 		else
 		else
-			sprintf(atcmd_output, msg_txt(sd,1241), mob->name.c_str(), mob->jname.c_str(), mob->sprite.c_str(), mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
+			sprintf(atcmd_output, msg_txt(sd,1241), mob->name.c_str(), mob->jname.c_str(), mob->sprite.c_str(), mob->id); // Monster: '%s'/'%s'/'%s' (%d)
 		clif_displaymessage(fd, atcmd_output);
 		clif_displaymessage(fd, atcmd_output);
 		sprintf(atcmd_output, msg_txt(sd,1242), mob->lv, mob->status.max_hp, base_exp, job_exp, MOB_HIT(mob), MOB_FLEE(mob)); //  Lv:%d  HP:%d  Base EXP:%llu  Job EXP:%llu  HIT:%d  FLEE:%d
 		sprintf(atcmd_output, msg_txt(sd,1242), mob->lv, mob->status.max_hp, base_exp, job_exp, MOB_HIT(mob), MOB_FLEE(mob)); //  Lv:%d  HP:%d  Base EXP:%llu  Job EXP:%llu  HIT:%d  FLEE:%d
 		clif_displaymessage(fd, atcmd_output);
 		clif_displaymessage(fd, atcmd_output);

+ 9 - 7
src/map/mob.cpp

@@ -4283,7 +4283,8 @@ uint64 MobDatabase::parseBodyNode(const YAML::Node &node) {
 			return 0;
 			return 0;
 
 
 		mob = std::make_shared<s_mob_db>();
 		mob = std::make_shared<s_mob_db>();
-		mob->vd.class_ = static_cast<uint16>(mob_id);
+		mob->id = mob_id;
+		mob->vd.class_ = static_cast<uint16>(mob->id);
 	}
 	}
 
 
 	if (this->nodeExists(node, "AegisName")) {
 	if (this->nodeExists(node, "AegisName")) {
@@ -5191,7 +5192,7 @@ uint64 MobAvailDatabase::parseBodyNode(const YAML::Node &node) {
 				return 0;
 				return 0;
 			}
 			}
 
 
-			constant = sprite_mob->vd.class_;
+			constant = sprite_mob->id;
 		}
 		}
 
 
 		mob->vd.class_ = (unsigned short)constant;
 		mob->vd.class_ = (unsigned short)constant;
@@ -5391,7 +5392,7 @@ uint64 MobAvailDatabase::parseBodyNode(const YAML::Node &node) {
 	}
 	}
 
 
 	if (this->nodeExists(node, "PetEquip")) {
 	if (this->nodeExists(node, "PetEquip")) {
-		std::shared_ptr<s_pet_db> pet_db_ptr = pet_db.find(mob->vd.class_);
+		std::shared_ptr<s_pet_db> pet_db_ptr = pet_db.find(mob->id);
 
 
 		if (pet_db_ptr == nullptr) {
 		if (pet_db_ptr == nullptr) {
 			this->invalidWarning(node["PetEquip"], "PetEquip is only applicable to defined pets.\n");
 			this->invalidWarning(node["PetEquip"], "PetEquip is only applicable to defined pets.\n");
@@ -5500,7 +5501,8 @@ uint64 MobSummonDatabase::parseBodyNode(const YAML::Node &node) {
 			this->invalidWarning(node["Default"], "Unknown mob %s.\n", mob_name.c_str());
 			this->invalidWarning(node["Default"], "Unknown mob %s.\n", mob_name.c_str());
 			return 0;
 			return 0;
 		}
 		}
-		summon->default_mob_id = mob->vd.class_;
+
+		summon->default_mob_id = mob->id;
 	}
 	}
 
 
 	if (this->nodeExists(node, "Summon")) {
 	if (this->nodeExists(node, "Summon")) {
@@ -5528,7 +5530,7 @@ uint64 MobSummonDatabase::parseBodyNode(const YAML::Node &node) {
 			if (!this->asUInt32(mobit, "Rate", rate))
 			if (!this->asUInt32(mobit, "Rate", rate))
 				continue;
 				continue;
 
 
-			uint16 mob_id = mob->vd.class_;
+			uint16 mob_id = mob->id;
 
 
 			if (rate == 0) {
 			if (rate == 0) {
 				if (summon->list.erase(mob_id) == 0)
 				if (summon->list.erase(mob_id) == 0)
@@ -5540,7 +5542,7 @@ uint64 MobSummonDatabase::parseBodyNode(const YAML::Node &node) {
 
 
 			if (entry == nullptr) {
 			if (entry == nullptr) {
 				entry = std::make_shared<s_randomsummon_entry>();
 				entry = std::make_shared<s_randomsummon_entry>();
-				entry->mob_id = mob->vd.class_;
+				entry->mob_id = mob_id;
 				summon->list[mob_id] = entry;
 				summon->list[mob_id] = entry;
 			}
 			}
 			entry->rate = rate;
 			entry->rate = rate;
@@ -6153,7 +6155,7 @@ static void mob_skill_db_set_single_sub(std::shared_ptr<s_mob_db> mob, struct s_
 	}
 	}
 
 
 	if (i < skill->skill.size())
 	if (i < skill->skill.size())
-		ShowWarning("Monster '%s' (%d, src:%d) reaches max skill limit %d. Ignores '%zu' skills left.\n", mob->sprite.c_str(), mob->vd.class_, skill->mob_id, MAX_MOBSKILL, skill->skill.size() - i);
+		ShowWarning("Monster '%s' (%d, src:%d) reaches max skill limit %d. Ignores '%zu' skills left.\n", mob->sprite.c_str(), mob->id, skill->mob_id, MAX_MOBSKILL, skill->skill.size() - i);
 }
 }
 
 
 /**
 /**

+ 1 - 0
src/map/mob.hpp

@@ -226,6 +226,7 @@ struct s_mob_drop {
 };
 };
 
 
 struct s_mob_db {
 struct s_mob_db {
+	uint32 id;
 	std::string sprite, name, jname;
 	std::string sprite, name, jname;
 	t_exp base_exp;
 	t_exp base_exp;
 	t_exp job_exp;
 	t_exp job_exp;

+ 2 - 2
src/map/pet.cpp

@@ -53,7 +53,7 @@ uint64 PetDatabase::parseBodyNode( const YAML::Node &node ){
 		return 0;
 		return 0;
 	}
 	}
 
 
-	uint16 mob_id = mob->vd.class_;
+	uint16 mob_id = mob->id;
 
 
 	std::shared_ptr<s_pet_db> pet = this->find( mob_id );
 	std::shared_ptr<s_pet_db> pet = this->find( mob_id );
 	bool exists = pet != nullptr;
 	bool exists = pet != nullptr;
@@ -419,7 +419,7 @@ uint64 PetDatabase::parseBodyNode( const YAML::Node &node ){
 				return 0;
 				return 0;
 			}
 			}
 
 
-			uint16 targetId = mob->vd.class_;
+			uint16 targetId = mob->id;
 
 
 			if( !this->nodeExists( evolutionNode, "ItemRequirements" ) ){
 			if( !this->nodeExists( evolutionNode, "ItemRequirements" ) ){
 				this->invalidWarning( evolutionNode, "Missing required node \"ItemRequirements\".\n" );
 				this->invalidWarning( evolutionNode, "Missing required node \"ItemRequirements\".\n" );

+ 2 - 2
src/map/quest.cpp

@@ -128,7 +128,7 @@ uint64 QuestDatabase::parseBodyNode(const YAML::Node &node) {
 					return 0;
 					return 0;
 				}
 				}
 
 
-				mob_id = mob->vd.class_;
+				mob_id = mob->id;
 
 
 				it = std::find_if(quest->objectives.begin(), quest->objectives.end(), [&](std::shared_ptr<s_quest_objective> const &v) {
 				it = std::find_if(quest->objectives.begin(), quest->objectives.end(), [&](std::shared_ptr<s_quest_objective> const &v) {
 					return (*v).mob_id == mob_id;
 					return (*v).mob_id == mob_id;
@@ -338,7 +338,7 @@ uint64 QuestDatabase::parseBodyNode(const YAML::Node &node) {
 					continue;
 					continue;
 				}
 				}
 
 
-				mob_id = mob->vd.class_;
+				mob_id = mob->id;
 			}
 			}
 
 
 			//std::shared_ptr<s_quest_dropitem> target = util::vector_find(quest->dropitem, mob_id);
 			//std::shared_ptr<s_quest_dropitem> target = util::vector_find(quest->dropitem, mob_id);

+ 1 - 5
src/map/unit.hpp

@@ -64,11 +64,7 @@ struct unit_data {
 };
 };
 
 
 struct view_data {
 struct view_data {
-#ifdef __64BIT__
-	unsigned int class_; //why arch dependant ??? make no sense imo [lighta]
-#else
-	unsigned short class_;
-#endif
+	uint16 class_;
 	t_itemid
 	t_itemid
 		weapon,
 		weapon,
 		shield, //Or left-hand weapon.
 		shield, //Or left-hand weapon.