[Zones] Convert SaveZoneCFG to Repositories (#3950)

* [Zones] Convert SaveZoneCFG to Repositories

# Notes
- Convert `SaveZoneCFG()` to repositories.

* Comment

* safe_heading

* Update zone_data.cpp
This commit is contained in:
Alex King 2024-01-13 00:28:16 -05:00 committed by GitHub
parent d59531b16f
commit f1d5e3eedf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 67 additions and 59 deletions

View File

@ -392,7 +392,7 @@ struct NewZone_Struct {
/*0724*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, if this value is 0, it prevents you from running off edges that would end up underworld /*0724*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, if this value is 0, it prevents you from running off edges that would end up underworld
/*0728*/ uint32 lava_damage; // Seen 50 /*0728*/ uint32 lava_damage; // Seen 50
/*0732*/ uint32 min_lava_damage; // Seen 10 /*0732*/ uint32 min_lava_damage; // Seen 10
/*0736*/ /*0736*/ float safe_heading;
}; };
/* /*

View File

@ -360,6 +360,7 @@ void SetZoneData(Client *c, const Seperator *sep)
zone->newzone_data.safe_x = x; zone->newzone_data.safe_x = x;
zone->newzone_data.safe_y = y; zone->newzone_data.safe_y = y;
zone->newzone_data.safe_z = z; zone->newzone_data.safe_z = z;
zone->newzone_data.safe_heading = heading;
auto outapp = new EQApplicationPacket(OP_NewZone, sizeof(NewZone_Struct)); auto outapp = new EQApplicationPacket(OP_NewZone, sizeof(NewZone_Struct));
memcpy(outapp->pBuffer, &zone->newzone_data, outapp->size); memcpy(outapp->pBuffer, &zone->newzone_data, outapp->size);

View File

@ -100,10 +100,11 @@ void ShowZoneData(Client *c, const Seperator *sep)
DialogueWindow::TableCell("Safe Coordinates") + DialogueWindow::TableCell("Safe Coordinates") +
DialogueWindow::TableCell( DialogueWindow::TableCell(
fmt::format( fmt::format(
"{:.2f}, {:.2f}, {:.2f}", "{:.2f}, {:.2f}, {:.2f} Heading: {:.2f}",
zone->newzone_data.safe_x, zone->newzone_data.safe_x,
zone->newzone_data.safe_y, zone->newzone_data.safe_y,
zone->newzone_data.safe_z zone->newzone_data.safe_z,
zone->newzone_data.safe_heading
) )
) )
); );

View File

@ -3817,71 +3817,73 @@ std::string QuestManager::GetEncounter() const {
} }
void QuestManager::UpdateZoneHeader(std::string type, std::string value) { void QuestManager::UpdateZoneHeader(std::string type, std::string value) {
if (strcasecmp(type.c_str(), "ztype") == 0) if (!strcasecmp(type.c_str(), "ztype"))
zone->newzone_data.ztype = Strings::ToInt(value); zone->newzone_data.ztype = Strings::ToInt(value);
else if (strcasecmp(type.c_str(), "fog_red") == 0) { else if (!strcasecmp(type.c_str(), "fog_red")) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
zone->newzone_data.fog_red[i] = Strings::ToInt(value); zone->newzone_data.fog_red[i] = Strings::ToInt(value);
} }
} else if (strcasecmp(type.c_str(), "fog_green") == 0) { } else if (!strcasecmp(type.c_str(), "fog_green")) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
zone->newzone_data.fog_green[i] = Strings::ToInt(value); zone->newzone_data.fog_green[i] = Strings::ToInt(value);
} }
} else if (strcasecmp(type.c_str(), "fog_blue") == 0) { } else if (!strcasecmp(type.c_str(), "fog_blue")) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
zone->newzone_data.fog_blue[i] = Strings::ToInt(value); zone->newzone_data.fog_blue[i] = Strings::ToInt(value);
} }
} else if (strcasecmp(type.c_str(), "fog_minclip") == 0) { } else if (!strcasecmp(type.c_str(), "fog_minclip")) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
zone->newzone_data.fog_minclip[i] = Strings::ToFloat(value); zone->newzone_data.fog_minclip[i] = Strings::ToFloat(value);
} }
} else if (strcasecmp(type.c_str(), "fog_maxclip") == 0) { } else if (!strcasecmp(type.c_str(), "fog_maxclip")) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
zone->newzone_data.fog_maxclip[i] = Strings::ToFloat(value); zone->newzone_data.fog_maxclip[i] = Strings::ToFloat(value);
} }
} else if (strcasecmp(type.c_str(), "gravity") == 0) { } else if (!strcasecmp(type.c_str(), "gravity")) {
zone->newzone_data.gravity = Strings::ToFloat(value); zone->newzone_data.gravity = Strings::ToFloat(value);
} else if (strcasecmp(type.c_str(), "time_type") == 0) { } else if (!strcasecmp(type.c_str(), "time_type")) {
zone->newzone_data.time_type = Strings::ToInt(value); zone->newzone_data.time_type = Strings::ToInt(value);
} else if (strcasecmp(type.c_str(), "rain_chance") == 0) { } else if (!strcasecmp(type.c_str(), "rain_chance")) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
zone->newzone_data.rain_chance[i] = Strings::ToInt(value); zone->newzone_data.rain_chance[i] = Strings::ToInt(value);
} }
} else if (strcasecmp(type.c_str(), "rain_duration") == 0) { } else if (!strcasecmp(type.c_str(), "rain_duration")) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
zone->newzone_data.rain_duration[i] = Strings::ToInt(value); zone->newzone_data.rain_duration[i] = Strings::ToInt(value);
} }
} else if (strcasecmp(type.c_str(), "snow_chance") == 0) { } else if (!strcasecmp(type.c_str(), "snow_chance")) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
zone->newzone_data.snow_chance[i] = Strings::ToInt(value); zone->newzone_data.snow_chance[i] = Strings::ToInt(value);
} }
} else if (strcasecmp(type.c_str(), "snow_duration") == 0) { } else if (!strcasecmp(type.c_str(), "snow_duration")) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
zone->newzone_data.snow_duration[i] = Strings::ToInt(value); zone->newzone_data.snow_duration[i] = Strings::ToInt(value);
} }
} else if (strcasecmp(type.c_str(), "sky") == 0) { } else if (!strcasecmp(type.c_str(), "sky")) {
zone->newzone_data.sky = Strings::ToInt(value); zone->newzone_data.sky = Strings::ToInt(value);
} else if (strcasecmp(type.c_str(), "safe_x") == 0) { } else if (!strcasecmp(type.c_str(), "safe_x")) {
zone->newzone_data.safe_x = Strings::ToFloat(value); zone->newzone_data.safe_x = Strings::ToFloat(value);
} else if (strcasecmp(type.c_str(), "safe_y") == 0) { } else if (!strcasecmp(type.c_str(), "safe_y")) {
zone->newzone_data.safe_y = Strings::ToFloat(value); zone->newzone_data.safe_y = Strings::ToFloat(value);
} else if (strcasecmp(type.c_str(), "safe_z") == 0) { } else if (!strcasecmp(type.c_str(), "safe_z")) {
zone->newzone_data.safe_z = Strings::ToFloat(value); zone->newzone_data.safe_z = Strings::ToFloat(value);
} else if (strcasecmp(type.c_str(), "max_z") == 0) { } else if (!strcasecmp(type.c_str(), "safe_heading")) {
zone->newzone_data.safe_heading = Strings::ToFloat(value);
} else if (!strcasecmp(type.c_str(), "max_z")) {
zone->newzone_data.max_z = Strings::ToFloat(value); zone->newzone_data.max_z = Strings::ToFloat(value);
} else if (strcasecmp(type.c_str(), "underworld") == 0) { } else if (!strcasecmp(type.c_str(), "underworld")) {
zone->newzone_data.underworld = Strings::ToFloat(value); zone->newzone_data.underworld = Strings::ToFloat(value);
} else if (strcasecmp(type.c_str(), "minclip") == 0) { } else if (!strcasecmp(type.c_str(), "minclip")) {
zone->newzone_data.minclip = Strings::ToFloat(value); zone->newzone_data.minclip = Strings::ToFloat(value);
} else if (strcasecmp(type.c_str(), "maxclip") == 0) { } else if (!strcasecmp(type.c_str(), "maxclip")) {
zone->newzone_data.maxclip = Strings::ToFloat(value); zone->newzone_data.maxclip = Strings::ToFloat(value);
} else if (strcasecmp(type.c_str(), "fog_density") == 0) { } else if (!strcasecmp(type.c_str(), "fog_density")) {
zone->newzone_data.fog_density = Strings::ToFloat(value); zone->newzone_data.fog_density = Strings::ToFloat(value);
} else if (strcasecmp(type.c_str(), "suspendbuffs") == 0) { } else if (!strcasecmp(type.c_str(), "suspendbuffs")) {
zone->newzone_data.suspend_buffs = Strings::ToInt(value); zone->newzone_data.suspend_buffs = Strings::ToInt(value);
} else if (strcasecmp(type.c_str(), "lavadamage") == 0) { } else if (!strcasecmp(type.c_str(), "lavadamage")) {
zone->newzone_data.lava_damage = Strings::ToInt(value); zone->newzone_data.lava_damage = Strings::ToInt(value);
} else if (strcasecmp(type.c_str(), "minlavadamage") == 0) { } else if (!strcasecmp(type.c_str(), "minlavadamage")) {
zone->newzone_data.min_lava_damage = Strings::ToInt(value); zone->newzone_data.min_lava_damage = Strings::ToInt(value);
} }

View File

@ -1360,6 +1360,7 @@ bool Zone::LoadZoneCFG(const char* filename, uint16 instance_version)
newzone_data.safe_x = z->safe_x; newzone_data.safe_x = z->safe_x;
newzone_data.safe_y = z->safe_y; newzone_data.safe_y = z->safe_y;
newzone_data.safe_z = z->safe_z; newzone_data.safe_z = z->safe_z;
newzone_data.safe_heading = z->safe_heading;
newzone_data.underworld = z->underworld; newzone_data.underworld = z->underworld;
newzone_data.minclip = z->minclip; newzone_data.minclip = z->minclip;
newzone_data.maxclip = z->maxclip; newzone_data.maxclip = z->maxclip;

View File

@ -85,37 +85,40 @@ ZoneDatabase::~ZoneDatabase() {
} }
} }
bool ZoneDatabase::SaveZoneCFG(uint32 zoneid, uint16 instance_version, NewZone_Struct* zd) { bool ZoneDatabase::SaveZoneCFG(uint32 zone_id, uint16 instance_version, NewZone_Struct* zd)
std::string query = fmt::format( {
"UPDATE zone SET underworld = {:.2f}, minclip = {:.2f}, " const auto& l = ZoneRepository::GetWhere(
"maxclip = {:.2f}, fog_minclip = {:.2f}, fog_maxclip = {:.2f}, " *this,
"fog_blue = {}, fog_red = {}, fog_green = {}, " fmt::format(
"sky = {}, ztype = {}, zone_exp_multiplier = {:.2f}, " "`zoneidnumber` = {} AND `version` = {}",
"safe_x = {:.2f}, safe_y = {:.2f}, safe_z = {:.2f} " zone_id,
"WHERE zoneidnumber = {} AND version = {}",
zd->underworld,
zd->minclip,
zd->maxclip,
zd->fog_minclip[0],
zd->fog_maxclip[0],
zd->fog_blue[0],
zd->fog_red[0],
zd->fog_green[0],
zd->sky,
zd->ztype,
zd->zone_exp_multiplier,
zd->safe_x,
zd->safe_y,
zd->safe_z,
zoneid,
instance_version instance_version
)
); );
auto results = QueryDatabase(query);
if (!results.Success()) { if (l.empty()) {
return false; return false;
} }
return true; auto e = l.front();
e.underworld = zd->underworld;
e.minclip = zd->minclip;
e.maxclip = zd->maxclip;
e.fog_minclip = zd->fog_minclip[0];
e.fog_maxclip = zd->fog_maxclip[0];
e.fog_blue = zd->fog_blue[0];
e.fog_red = zd->fog_red[0];
e.fog_green = zd->fog_green[0];
e.sky = zd->sky;
e.ztype = zd->ztype;
e.zone_exp_multiplier = zd->zone_exp_multiplier;
e.safe_x = zd->safe_x;
e.safe_y = zd->safe_y;
e.safe_z = zd->safe_z;
e.safe_heading = zd->safe_heading;
return ZoneRepository::UpdateOne(*this, e);
} }
void ZoneDatabase::UpdateRespawnTime(uint32 spawn2_id, uint16 instance_id, uint32 time_left) void ZoneDatabase::UpdateRespawnTime(uint32 spawn2_id, uint16 instance_id, uint32 time_left)

View File

@ -519,7 +519,7 @@ public:
bool LoadAlternateAdvancement(Client *c); bool LoadAlternateAdvancement(Client *c);
/* Zone related */ /* Zone related */
bool SaveZoneCFG(uint32 zoneid, uint16 instance_version, NewZone_Struct* zd); bool SaveZoneCFG(uint32 zone_id, uint16 instance_version, NewZone_Struct* zd);
bool LoadStaticZonePoints(LinkedList<ZonePoint*>* zone_point_list,const char* zonename, uint32 version); bool LoadStaticZonePoints(LinkedList<ZonePoint*>* zone_point_list,const char* zonename, uint32 version);
int getZoneShutDownDelay(uint32 zoneID, uint32 version); int getZoneShutDownDelay(uint32 zoneID, uint32 version);