mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 06:21:28 +00:00
[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:
parent
d59531b16f
commit
f1d5e3eedf
@ -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
|
||||
/*0728*/ uint32 lava_damage; // Seen 50
|
||||
/*0732*/ uint32 min_lava_damage; // Seen 10
|
||||
/*0736*/
|
||||
/*0736*/ float safe_heading;
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@ -357,9 +357,10 @@ void SetZoneData(Client *c, const Seperator *sep)
|
||||
database.QueryDatabase(query);
|
||||
}
|
||||
|
||||
zone->newzone_data.safe_x = x;
|
||||
zone->newzone_data.safe_y = y;
|
||||
zone->newzone_data.safe_z = z;
|
||||
zone->newzone_data.safe_x = x;
|
||||
zone->newzone_data.safe_y = y;
|
||||
zone->newzone_data.safe_z = z;
|
||||
zone->newzone_data.safe_heading = heading;
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_NewZone, sizeof(NewZone_Struct));
|
||||
memcpy(outapp->pBuffer, &zone->newzone_data, outapp->size);
|
||||
|
||||
@ -100,10 +100,11 @@ void ShowZoneData(Client *c, const Seperator *sep)
|
||||
DialogueWindow::TableCell("Safe Coordinates") +
|
||||
DialogueWindow::TableCell(
|
||||
fmt::format(
|
||||
"{:.2f}, {:.2f}, {:.2f}",
|
||||
"{:.2f}, {:.2f}, {:.2f} Heading: {:.2f}",
|
||||
zone->newzone_data.safe_x,
|
||||
zone->newzone_data.safe_y,
|
||||
zone->newzone_data.safe_z
|
||||
zone->newzone_data.safe_z,
|
||||
zone->newzone_data.safe_heading
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@ -3817,71 +3817,73 @@ std::string QuestManager::GetEncounter() const {
|
||||
}
|
||||
|
||||
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);
|
||||
else if (strcasecmp(type.c_str(), "fog_red") == 0) {
|
||||
else if (!strcasecmp(type.c_str(), "fog_red")) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
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++) {
|
||||
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++) {
|
||||
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++) {
|
||||
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++) {
|
||||
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);
|
||||
} 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);
|
||||
} else if (strcasecmp(type.c_str(), "rain_chance") == 0) {
|
||||
} else if (!strcasecmp(type.c_str(), "rain_chance")) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
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++) {
|
||||
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++) {
|
||||
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++) {
|
||||
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);
|
||||
} 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);
|
||||
} 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);
|
||||
} 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);
|
||||
} 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);
|
||||
} else if (strcasecmp(type.c_str(), "underworld") == 0) {
|
||||
} else if (!strcasecmp(type.c_str(), "underworld")) {
|
||||
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);
|
||||
} else if (strcasecmp(type.c_str(), "maxclip") == 0) {
|
||||
} else if (!strcasecmp(type.c_str(), "maxclip")) {
|
||||
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);
|
||||
} else if (strcasecmp(type.c_str(), "suspendbuffs") == 0) {
|
||||
} else if (!strcasecmp(type.c_str(), "suspendbuffs")) {
|
||||
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);
|
||||
} else if (strcasecmp(type.c_str(), "minlavadamage") == 0) {
|
||||
} else if (!strcasecmp(type.c_str(), "minlavadamage")) {
|
||||
zone->newzone_data.min_lava_damage = Strings::ToInt(value);
|
||||
}
|
||||
|
||||
|
||||
@ -1360,6 +1360,7 @@ bool Zone::LoadZoneCFG(const char* filename, uint16 instance_version)
|
||||
newzone_data.safe_x = z->safe_x;
|
||||
newzone_data.safe_y = z->safe_y;
|
||||
newzone_data.safe_z = z->safe_z;
|
||||
newzone_data.safe_heading = z->safe_heading;
|
||||
newzone_data.underworld = z->underworld;
|
||||
newzone_data.minclip = z->minclip;
|
||||
newzone_data.maxclip = z->maxclip;
|
||||
|
||||
@ -85,37 +85,40 @@ ZoneDatabase::~ZoneDatabase() {
|
||||
}
|
||||
}
|
||||
|
||||
bool ZoneDatabase::SaveZoneCFG(uint32 zoneid, uint16 instance_version, NewZone_Struct* zd) {
|
||||
std::string query = fmt::format(
|
||||
"UPDATE zone SET underworld = {:.2f}, minclip = {:.2f}, "
|
||||
"maxclip = {:.2f}, fog_minclip = {:.2f}, fog_maxclip = {:.2f}, "
|
||||
"fog_blue = {}, fog_red = {}, fog_green = {}, "
|
||||
"sky = {}, ztype = {}, zone_exp_multiplier = {:.2f}, "
|
||||
"safe_x = {:.2f}, safe_y = {:.2f}, safe_z = {:.2f} "
|
||||
"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
|
||||
bool ZoneDatabase::SaveZoneCFG(uint32 zone_id, uint16 instance_version, NewZone_Struct* zd)
|
||||
{
|
||||
const auto& l = ZoneRepository::GetWhere(
|
||||
*this,
|
||||
fmt::format(
|
||||
"`zoneidnumber` = {} AND `version` = {}",
|
||||
zone_id,
|
||||
instance_version
|
||||
)
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
|
||||
if (l.empty()) {
|
||||
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)
|
||||
|
||||
@ -519,7 +519,7 @@ public:
|
||||
bool LoadAlternateAdvancement(Client *c);
|
||||
|
||||
/* 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);
|
||||
int getZoneShutDownDelay(uint32 zoneID, uint32 version);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user