Adjust structs to classes

* Adjust to class to avoid duplication of definitions.
* Rename prefix to match "class".
This commit is contained in:
aleos 2024-05-03 15:46:38 -04:00
parent 849f1ec477
commit 060629bd17
2 changed files with 14 additions and 18 deletions

View File

@ -218,11 +218,11 @@ uint64 MapZoneDatabase::parseBodyNode(const ryml::NodeRef& node) {
} }
uint16 zone_id = static_cast<uint16>(zone_id_const); uint16 zone_id = static_cast<uint16>(zone_id_const);
std::shared_ptr<s_map_zone> zone = this->find(zone_id); std::shared_ptr<c_map_zone> zone = this->find(zone_id);
bool exists = zone != nullptr; bool exists = zone != nullptr;
if (!exists) { if (!exists) {
zone = std::make_shared<s_map_zone>(); zone = std::make_shared<c_map_zone>();
zone->id = zone_id; zone->id = zone_id;
} }
@ -564,7 +564,7 @@ bool MapZoneDatabase::setZone(int16 map_id, e_map_type zone) {
return false; return false;
} }
mapdata->zone = std::make_shared<s_map_zone_data>(); mapdata->zone = std::make_shared<c_map_zone_data>();
mapdata->zone->id = zonedata->id; mapdata->zone->id = zonedata->id;
mapdata->zone->disabled_commands = zonedata->disabled_commands; mapdata->zone->disabled_commands = zonedata->disabled_commands;
mapdata->zone->disabled_items = zonedata->disabled_items; mapdata->zone->disabled_items = zonedata->disabled_items;
@ -594,7 +594,7 @@ MapZoneDatabase map_zone_db;
* @param group_lv: Group level * @param group_lv: Group level
* @return True when command is disabled or false otherwise * @return True when command is disabled or false otherwise
*/ */
bool s_map_zone_data::isCommandDisabled(std::string name, uint16 group_lv) { bool c_map_zone_data::isCommandDisabled(std::string name, uint16 group_lv) {
if (this->disabled_commands.empty()) if (this->disabled_commands.empty())
return false; return false;
@ -616,7 +616,7 @@ bool s_map_zone_data::isCommandDisabled(std::string name, uint16 group_lv) {
* @param group_lv: Group level * @param group_lv: Group level
* @return True when skill is disabled or false otherwise * @return True when skill is disabled or false otherwise
*/ */
bool s_map_zone_data::isSkillDisabled(uint16 skill_id, uint16 type, uint16 group_lv) { bool c_map_zone_data::isSkillDisabled(uint16 skill_id, uint16 type, uint16 group_lv) {
if (this->disabled_skills.empty()) if (this->disabled_skills.empty())
return false; return false;
@ -637,7 +637,7 @@ bool s_map_zone_data::isSkillDisabled(uint16 skill_id, uint16 type, uint16 group
* @param group_lv: Group level * @param group_lv: Group level
* @return True when item is disabled or false otherwise * @return True when item is disabled or false otherwise
*/ */
bool s_map_zone_data::isItemDisabled(t_itemid nameid, uint16 group_lv) { bool c_map_zone_data::isItemDisabled(t_itemid nameid, uint16 group_lv) {
if (this->disabled_items.empty()) if (this->disabled_items.empty())
return false; return false;
@ -659,7 +659,7 @@ bool s_map_zone_data::isItemDisabled(t_itemid nameid, uint16 group_lv) {
* @param group_lv: Group level * @param group_lv: Group level
* @return True when status is disabled or false otherwise * @return True when status is disabled or false otherwise
*/ */
bool s_map_zone_data::isStatusDisabled(sc_type sc, uint16 type, uint16 group_lv) { bool c_map_zone_data::isStatusDisabled(sc_type sc, uint16 type, uint16 group_lv) {
if (this->disabled_statuses.empty()) if (this->disabled_statuses.empty())
return false; return false;
@ -680,7 +680,7 @@ bool s_map_zone_data::isStatusDisabled(sc_type sc, uint16 type, uint16 group_lv)
* @param group_lv: Group level * @param group_lv: Group level
* @return True when job is restricted or false otherwise * @return True when job is restricted or false otherwise
*/ */
bool s_map_zone_data::isJobRestricted(int32 job_id, uint16 group_lv) { bool c_map_zone_data::isJobRestricted(int32 job_id, uint16 group_lv) {
if (this->restricted_jobs.empty()) if (this->restricted_jobs.empty())
return false; return false;

View File

@ -808,7 +808,8 @@ struct iwall_data {
bool shootable; bool shootable;
}; };
struct s_map_zone_data { class c_map_zone_data {
public:
uint16 id; uint16 id;
std::unordered_map<std::string, uint16> disabled_commands; std::unordered_map<std::string, uint16> disabled_commands;
std::unordered_map<uint16, std::pair<uint16, uint16>> disabled_skills; std::unordered_map<uint16, std::pair<uint16, uint16>> disabled_skills;
@ -846,7 +847,7 @@ struct map_data {
std::unordered_map<uint16, s_skill_damage> skill_damage; // Used for single skill damage adjustment std::unordered_map<uint16, s_skill_damage> skill_damage; // Used for single skill damage adjustment
std::unordered_map<uint16, int> skill_duration; std::unordered_map<uint16, int> skill_duration;
std::shared_ptr<s_map_zone_data> zone; std::shared_ptr<c_map_zone_data> zone;
struct npc_data *npc[MAX_NPC_PER_MAP]; struct npc_data *npc[MAX_NPC_PER_MAP];
struct spawn_data *moblist[MAX_MOB_LIST_PER_MAP]; // [Wizputer] struct spawn_data *moblist[MAX_MOB_LIST_PER_MAP]; // [Wizputer]
@ -881,18 +882,13 @@ private:
std::vector<int> flags; std::vector<int> flags;
}; };
struct s_map_zone { class c_map_zone : public c_map_zone_data {
uint16 id; public:
std::unordered_map<std::string, uint16> disabled_commands;
std::unordered_map<uint16, std::pair<uint16, uint16>> disabled_skills;
std::unordered_map<t_itemid, uint16> disabled_items;
std::unordered_map<sc_type, uint16> disabled_statuses;
std::unordered_map<int32, uint16> restricted_jobs;
std::vector<int16> maps; std::vector<int16> maps;
std::multimap<int16, std::string> mapflags; std::multimap<int16, std::string> mapflags;
}; };
class MapZoneDatabase : public TypesafeYamlDatabase<uint16, s_map_zone> { class MapZoneDatabase : public TypesafeYamlDatabase<uint16, c_map_zone> {
public: public:
MapZoneDatabase() : TypesafeYamlDatabase("MAP_ZONES", 1) { MapZoneDatabase() : TypesafeYamlDatabase("MAP_ZONES", 1) {