[Spawn2] Convert Spawn2 Methods to Repositories (#4014)

* [Spawn2] Convert Spawn2 Methods to Repositories

# Notes
- Convert `CreateSpawn2()`, `GetCondition()`, `LoadSpawnConditions()`, `LoadSpawnEvent()`, `UpdateSpawnCondition()`, and `UpdateSpawnEvent()` to repositories.

# Images

* Update spawn2.cpp
This commit is contained in:
Alex King 2024-01-28 21:24:33 -05:00 committed by GitHub
parent ce907c9519
commit c09a3a5bba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 232 additions and 195 deletions

View File

@ -27,6 +27,9 @@
#include "zone.h" #include "zone.h"
#include "zonedb.h" #include "zonedb.h"
#include "../common/repositories/criteria/content_filter_criteria.h" #include "../common/repositories/criteria/content_filter_criteria.h"
#include "../common/repositories/spawn_conditions_repository.h"
#include "../common/repositories/spawn_condition_values_repository.h"
#include "../common/repositories/spawn_events_repository.h"
#include "../common/repositories/spawn2_repository.h" #include "../common/repositories/spawn2_repository.h"
#include "../common/repositories/spawn2_disabled_repository.h" #include "../common/repositories/spawn2_disabled_repository.h"
#include "../common/repositories/respawn_times_repository.h" #include "../common/repositories/respawn_times_repository.h"
@ -539,23 +542,31 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spa
return true; return true;
} }
bool ZoneDatabase::CreateSpawn2(Client *client, uint32 spawngroup, const char* zone, const glm::vec4& position, uint32 respawn, uint32 variance, uint16 condition, int16 cond_value) bool ZoneDatabase::CreateSpawn2(
Client* c,
uint32 spawngroup_id,
const std::string& zone_short_name,
const glm::vec4& position,
uint32 respawn,
uint32 variance,
uint16 condition,
int16 condition_value
)
{ {
auto e = Spawn2Repository::NewEntity();
std::string query = StringFormat("INSERT INTO spawn2 (spawngroupID, zone, x, y, z, heading, " e.spawngroupID = spawngroup_id;
"respawntime, variance, _condition, cond_value) " e.zone = zone_short_name;
"VALUES (%i, '%s', %f, %f, %f, %f, %i, %i, %u, %i)", e.x = position.x;
spawngroup, zone, position.x, position.y, position.z, position.w, e.y = position.y;
respawn, variance, condition, cond_value); e.z = position.z;
auto results = QueryDatabase(query); e.heading = position.w;
if (!results.Success()) { e.respawntime = respawn;
return false; e.variance = variance;
} e._condition = condition;
e.cond_value = condition_value;
if (results.RowsAffected() != 1) return Spawn2Repository::InsertOne(*this, e).id;
return false;
return true;
} }
uint32 Zone::CountSpawn2() { uint32 Zone::CountSpawn2() {
@ -718,7 +729,7 @@ void SpawnConditionManager::Process() {
EQTime::ToString(&cevent.next, t); EQTime::ToString(&cevent.next, t);
LogSpawns("Event [{}]: Will trigger again in [{}] EQ minutes at [{}]", cevent.id, cevent.period, t.c_str()); LogSpawns("Event [{}]: Will trigger again in [{}] EQ minutes at [{}]", cevent.id, cevent.period, t.c_str());
//save the next event time in the DB //save the next event time in the DB
UpdateDBEvent(cevent); UpdateSpawnEvent(cevent);
//find the next closest event timer. //find the next closest event timer.
FindNearestEvent(); FindNearestEvent();
//minor optimization, if theres no more possible events, //minor optimization, if theres no more possible events,
@ -786,147 +797,175 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) {
cond.value = new_value; cond.value = new_value;
} }
void SpawnConditionManager::UpdateDBEvent(SpawnEvent &event) { void SpawnConditionManager::UpdateSpawnEvent(SpawnEvent &event)
{
auto e = SpawnEventsRepository::FindOne(database, event.id);
std::string query = StringFormat("UPDATE spawn_events SET " e.next_minute = event.next.minute;
"next_minute = %d, next_hour = %d, " e.next_hour = event.next.hour;
"next_day = %d, next_month = %d, " e.next_day = event.next.day;
"next_year = %d, enabled = %d, " e.next_month = event.next.month;
"strict = %d WHERE id = %d", e.next_year = event.next.year;
event.next.minute, event.next.hour, e.enabled = event.enabled ? 1 : 0;
event.next.day, event.next.month, e.next_minute = event.strict;
event.next.year, event.enabled? 1: 0,
event.strict? 1: 0, event.id); SpawnEventsRepository::UpdateOne(database, e);
database.QueryDatabase(query);
} }
void SpawnConditionManager::UpdateDBCondition(const char* zone_name, uint32 instance_id, uint16 cond_id, int16 value) { void SpawnConditionManager::UpdateSpawnCondition(
const std::string& zone_short_name,
std::string query = StringFormat("REPLACE INTO spawn_condition_values " uint32 instance_id,
"(id, value, zone, instance_id) " uint16 condition,
"VALUES( %u, %u, '%s', %u)", int16 condition_value
cond_id, value, zone_name, instance_id); )
database.QueryDatabase(query); {
SpawnConditionValuesRepository::ReplaceOne(
database,
SpawnConditionValuesRepository::SpawnConditionValues{
.id = condition,
.value = static_cast<uint8_t>(condition_value),
.zone = zone_short_name,
.instance_id = instance_id
}
);
} }
bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std::string &zone_name) { bool SpawnConditionManager::LoadSpawnEvent(
uint32 event_id,
SpawnEvent& event,
std::string& zone_short_name
)
{
const auto& e = SpawnEventsRepository::FindOne(database, event_id);
std::string query = StringFormat("SELECT id, cond_id, period, " if (!e.id) {
"next_minute, next_hour, next_day, "
"next_month, next_year, enabled, "
"action, argument, strict, zone "
"FROM spawn_events WHERE id = %d", event_id);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
return false; return false;
} }
if (results.RowCount() == 0) event.id = e.id;
return false; event.condition_id = e.cond_id;
event.period = e.period;
event.next.minute = e.next_minute;
event.next.hour = e.next_hour;
event.next.day = e.next_day;
event.next.month = e.next_month;
event.next.year = e.next_year;
event.enabled = e.enabled;
event.action = static_cast<SpawnEvent::Action>(e.action);
event.argument = e.argument;
event.strict = e.strict;
auto row = results.begin(); zone_short_name = e.zone;
event.id = Strings::ToInt(row[0]); std::string time_string;
event.condition_id = Strings::ToInt(row[1]); EQTime::ToString(&event.next, time_string);
event.period = Strings::ToInt(row[2]);
event.next.minute = Strings::ToInt(row[3]); LogSpawns(
event.next.hour = Strings::ToInt(row[4]); "Loaded [{}] event_id [{}] condition [{}] period [{}] action [{}] argument [{}] strict [{}] time [{}]",
event.next.day = Strings::ToInt(row[5]); event.enabled ? "enabled" : "disabled",
event.next.month = Strings::ToInt(row[6]); event.id,
event.next.year = Strings::ToInt(row[7]); event.condition_id,
event.period,
event.enabled = Strings::ToInt(row[8]) != 0; event.action,
event.action = (SpawnEvent::Action) Strings::ToInt(row[9]); event.argument,
event.argument = Strings::ToInt(row[10]); event.strict,
event.strict = Strings::ToInt(row[11]) != 0; time_string
zone_name = row[12]; );
std::string timeAsString;
EQTime::ToString(&event.next, timeAsString);
LogSpawns("(LoadDBEvent) Loaded [{}] spawn event [{}] on condition [{}] with period [{}] action [{}] argument [{}] strict [{}]. Will trigger at [{}]", event.enabled? "enabled": "disabled", event.id, event.condition_id, event.period, event.action, event.argument, event.strict, timeAsString.c_str());
return true; return true;
} }
bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 instance_id) bool SpawnConditionManager::LoadSpawnConditions(const std::string& zone_short_name, uint32 instance_id)
{ {
//clear out old stuff..
spawn_conditions.clear(); spawn_conditions.clear();
std::string query = StringFormat("SELECT id, onchange, value " const auto& conditions = SpawnConditionsRepository::GetWhere(
"FROM spawn_conditions " content_db,
"WHERE zone = '%s'", zone_name); fmt::format(
auto results = content_db.QueryDatabase(query); "`zone` = '{}'",
if (!results.Success()) { Strings::Escape(zone_short_name)
)
);
if (conditions.empty()) {
return false; return false;
} }
for (auto row = results.begin(); row != results.end(); ++row) { for (const auto& e : conditions) {
//load spawn conditions SpawnCondition c;
SpawnCondition cond;
cond.condition_id = Strings::ToInt(row[0]); c.condition_id = e.id;
cond.value = Strings::ToInt(row[2]); c.value = e.value;
cond.on_change = (SpawnCondition::OnChange) Strings::ToInt(row[1]); c.on_change = static_cast<SpawnCondition::OnChange>(e.onchange);
spawn_conditions[cond.condition_id] = cond;
LogSpawns("Loaded spawn condition [{}] with value [{}] and on_change [{}]", cond.condition_id, cond.value, cond.on_change); spawn_conditions[c.condition_id] = c;
LogSpawns(
"Loaded spawn condition [{}] with value [{}] and on_change [{}]",
c.condition_id,
c.value,
c.on_change
);
} }
LogInfo("Loaded [{}] spawn_conditions", Strings::Commify(std::to_string(results.RowCount()))); LogInfo("Loaded [{}] spawn_conditions", Strings::Commify(std::to_string(conditions.size())));
//load values const auto& condition_values = SpawnConditionValuesRepository::GetWhere(
query = StringFormat("SELECT id, value FROM spawn_condition_values " database,
"WHERE zone = '%s' AND instance_id = %u", fmt::format(
zone_name, instance_id); "`zone` = '{}' AND `instance_id` = {}",
results = database.QueryDatabase(query); Strings::Escape(zone_short_name),
if (!results.Success()) { instance_id
)
);
if (condition_values.empty()) {
spawn_conditions.clear(); spawn_conditions.clear();
return false; return false;
} }
for (auto row = results.begin(); row != results.end(); ++row) { for (const auto& e : condition_values) {
auto iter = spawn_conditions.find(Strings::ToInt(row[0])); auto i = spawn_conditions.find(e.id);
if (i != spawn_conditions.end()) {
if(iter != spawn_conditions.end()) i->second.value = e.value;
iter->second.value = Strings::ToInt(row[1]); }
} }
//load spawn events const auto& events = SpawnEventsRepository::GetWhere(
query = StringFormat("SELECT id, cond_id, period, next_minute, next_hour, " database,
"next_day, next_month, next_year, enabled, action, argument, strict " fmt::format(
"FROM spawn_events WHERE zone = '%s'", zone_name); "`zone` = '{}'",
results = database.QueryDatabase(query); Strings::Escape(zone_short_name)
if (!results.Success()) { )
);
if (events.empty()) {
return false; return false;
} }
LogInfo("Loaded [{}] spawn_events", Strings::Commify(std::to_string(results.RowCount()))); LogInfo("Loaded [{}] spawn_events", Strings::Commify(std::to_string(events.size())));
for (auto row = results.begin(); row != results.end(); ++row) { for (const auto& e : events) {
SpawnEvent event; SpawnEvent event;
event.id = Strings::ToInt(row[0]); event.id = e.id;
event.condition_id = Strings::ToInt(row[1]); event.condition_id = e.cond_id;
event.period = Strings::ToInt(row[2]); event.period = e.period;
if (event.period == 0) { if (!event.period) {
LogError("Refusing to load spawn event #[{}] because it has a period of 0\n", event.id); LogError("Refusing to load spawn event #[{}] because it has a period of 0\n", event.id);
continue; continue;
} }
event.next.minute = Strings::ToInt(row[3]); event.next.minute = e.next_minute;
event.next.hour = Strings::ToInt(row[4]); event.next.hour = e.next_hour;
event.next.day = Strings::ToInt(row[5]); event.next.day = e.next_day;
event.next.month = Strings::ToInt(row[6]); event.next.month = e.next_month;
event.next.year = Strings::ToInt(row[7]); event.next.year = e.next_year;
event.enabled = e.enabled;
event.enabled = Strings::ToInt(row[8]) == 0 ? false : true; event.action = static_cast<SpawnEvent::Action>(e.action);
event.action = (SpawnEvent::Action) Strings::ToInt(row[9]); event.argument = e.argument;
event.argument = Strings::ToInt(row[10]); event.strict = e.strict;
event.strict = Strings::ToInt(row[11]) == 0 ? false : true;
spawn_events.push_back(event); spawn_events.push_back(event);
@ -945,68 +984,70 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
//now we need to catch up on events that happened while we were away //now we need to catch up on events that happened while we were away
//and use them to alter just the condition variables. //and use them to alter just the condition variables.
//each spawn2 will then use its correct condition value when
//it decides what to do. This essentially forces a 'depop' action
//on spawn points which are turned off, and a 'repop' action on
//spawn points which get turned on. Im too lazy to figure out a
//better solution, and I just dont care thats much.
//get our current time //get our current time
TimeOfDay_Struct tod{}; TimeOfDay_Struct tod{};
zone->zone_time.GetCurrentEQTimeOfDay(&tod); zone->zone_time.GetCurrentEQTimeOfDay(&tod);
for(auto cur = spawn_events.begin(); cur != spawn_events.end(); ++cur) { for (auto& e : spawn_events) {
SpawnEvent &cevent = *cur; bool is_strict = false;
bool StrictCheck = false; if (
if(cevent.strict && e.strict &&
cevent.next.hour == tod.hour && e.next.hour == tod.hour &&
cevent.next.day == tod.day && e.next.day == tod.day &&
cevent.next.month == tod.month && e.next.month == tod.month &&
cevent.next.year == tod.year) e.next.year == tod.year
StrictCheck = true; ) {
is_strict = true;
}
//If event is disabled, or we failed the strict check, set initial spawn_condition to default startup value from spawn_conditions. //If event is disabled, or we failed the strict check, set initial spawn_condition to default startup value from spawn_conditions.
if(!cevent.enabled || !StrictCheck) { if (!e.enabled || !is_strict) {
SetCondition( SetCondition(
zone->GetShortName(), zone->GetShortName(),
zone->GetInstanceID(), zone->GetInstanceID(),
cevent.condition_id, e.condition_id,
spawn_conditions[cevent.condition_id].value spawn_conditions[e.condition_id].value
); );
} }
if(!cevent.enabled) if (!e.enabled) {
continue; continue;
}
//watch for special case of all 0s, which means to reset next to now //watch for special case of all 0s, which means to reset next to now
if (cevent.next.year == 0 && cevent.next.month == 0 && cevent.next.day == 0 && cevent.next.hour == 0 && if (
cevent.next.minute == 0) { e.next.year == 0 &&
LogSpawns("Initial next trigger time set for spawn event [{}]", cevent.id); e.next.month == 0 &&
memcpy(&cevent.next, &tod, sizeof(cevent.next)); e.next.day == 0 &&
//add one period e.next.hour == 0 &&
EQTime::AddMinutes(cevent.period, &cevent.next); e.next.minute == 0
//save it in the db. ) {
UpdateDBEvent(cevent); LogSpawns("Initial next trigger time set for spawn event [{}]", e.id);
continue; //were done with this event. memcpy(&e.next, &tod, sizeof(e.next));
EQTime::AddMinutes(e.period, &e.next);
UpdateSpawnEvent(e);
continue;
} }
bool ran = false; bool ran = false;
while (EQTime::IsTimeBefore(&tod, &cevent.next)) { while (EQTime::IsTimeBefore(&tod, &e.next)) {
LogSpawns("Catch up triggering on event [{}]", cevent.id); LogSpawns("Catch up triggering on event [{}]", e.id);
//this event has been triggered. //this event has been triggered.
//execute the event //execute the event
if (!cevent.strict || StrictCheck) { if (!e.strict || is_strict) {
ExecEvent(cevent, false); ExecEvent(e, false);
} }
//add the period of the event to the trigger time //add the period of the event to the trigger time
EQTime::AddMinutes(cevent.period, &cevent.next); EQTime::AddMinutes(e.period, &e.next);
ran = true; ran = true;
} }
//only write it out if the event actually ran //only write it out if the event actually ran
if(ran) if (ran) {
UpdateDBEvent(cevent); //save the event in the DB UpdateSpawnEvent(e);
}
} }
//now our event timers are all up to date, find our closest event. //now our event timers are all up to date, find our closest event.
@ -1095,7 +1136,7 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance
//set our local value //set our local value
cond.value = new_value; cond.value = new_value;
//save it in the DB too //save it in the DB too
UpdateDBCondition(zone_short, instance_id, condition_id, new_value); UpdateSpawnCondition(zone_short, instance_id, condition_id, new_value);
LogSpawns("Local Condition update requested for [{}] with value [{}]", condition_id, new_value); LogSpawns("Local Condition update requested for [{}] with value [{}]", condition_id, new_value);
@ -1109,7 +1150,7 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance
LogSpawns("Remote spawn condition [{}] set to [{}]. Updating DB and notifying world", condition_id, new_value); LogSpawns("Remote spawn condition [{}] set to [{}]. Updating DB and notifying world", condition_id, new_value);
UpdateDBCondition(zone_short, instance_id, condition_id, new_value); UpdateSpawnCondition(zone_short, instance_id, condition_id, new_value);
auto pack = new ServerPacket(ServerOP_SpawnCondition, sizeof(ServerSpawnCondition_Struct)); auto pack = new ServerPacket(ServerOP_SpawnCondition, sizeof(ServerSpawnCondition_Struct));
ServerSpawnCondition_Struct* ssc = (ServerSpawnCondition_Struct*)pack->pBuffer; ServerSpawnCondition_Struct* ssc = (ServerSpawnCondition_Struct*)pack->pBuffer;
@ -1138,7 +1179,7 @@ void SpawnConditionManager::ReloadEvent(uint32 event_id) {
if(cevent.id == event_id) { if(cevent.id == event_id) {
//load the event into the old event slot //load the event into the old event slot
if(!LoadDBEvent(event_id, cevent, zone_short_name)) { if(!LoadSpawnEvent(event_id, cevent, zone_short_name)) {
//unable to find the event in the database... //unable to find the event in the database...
LogSpawns("Failed to reload event [{}] from the database", event_id); LogSpawns("Failed to reload event [{}] from the database", event_id);
return; return;
@ -1151,7 +1192,7 @@ void SpawnConditionManager::ReloadEvent(uint32 event_id) {
//if we get here, it is a new event... //if we get here, it is a new event...
SpawnEvent e; SpawnEvent e;
if(!LoadDBEvent(event_id, e, zone_short_name)) { if(!LoadSpawnEvent(event_id, e, zone_short_name)) {
//unable to find the event in the database... //unable to find the event in the database...
LogSpawns("Failed to reload event [{}] from the database", event_id); LogSpawns("Failed to reload event [{}] from the database", event_id);
return; return;
@ -1195,7 +1236,7 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri
} }
//save the event in the DB //save the event in the DB
UpdateDBEvent(cevent); UpdateSpawnEvent(cevent);
//sync up our nearest event //sync up our nearest event
FindNearestEvent(); FindNearestEvent();
@ -1218,7 +1259,7 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri
//update its in-memory event list //update its in-memory event list
SpawnEvent e; SpawnEvent e;
std::string zone_short_name; std::string zone_short_name;
if(!LoadDBEvent(event_id, e, zone_short_name)) { if(!LoadSpawnEvent(event_id, e, zone_short_name)) {
LogSpawns("Unable to find spawn event [{}] in the database", event_id); LogSpawns("Unable to find spawn event [{}] in the database", event_id);
//unable to find the event in the database... //unable to find the event in the database...
return; return;
@ -1239,7 +1280,7 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri
LogSpawns("Spawn event [{}] is in zone [{}]. State changed. Notifying world", event_id, zone_short_name.c_str(), e.period); LogSpawns("Spawn event [{}] is in zone [{}]. State changed. Notifying world", event_id, zone_short_name.c_str(), e.period);
} }
//save the event in the DB //save the event in the DB
UpdateDBEvent(e); UpdateSpawnEvent(e);
//now notify the zone //now notify the zone
@ -1253,43 +1294,39 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri
safe_delete(pack); safe_delete(pack);
} }
int16 SpawnConditionManager::GetCondition(const char *zone_short, uint32 instance_id, uint16 condition_id) { int16 SpawnConditionManager::GetCondition(const std::string& zone_short_name, uint32 instance_id, uint16 condition)
if(!strcasecmp(zone_short, zone->GetShortName()) && instance_id == zone->GetInstanceID()) {
{ if (
//this is a local spawn condition Strings::EqualFold(zone_short_name, zone->GetShortName()) &&
std::map<uint16, SpawnCondition>::iterator condi; instance_id == zone->GetInstanceID()
condi = spawn_conditions.find(condition_id); ) {
if(condi == spawn_conditions.end()) auto i = spawn_conditions.find(condition);
{ if (i == spawn_conditions.end()) {
LogSpawns("Unable to find local condition [{}] in Get request", condition_id); LogSpawns("Unable to find local condition [{}] in Get request", condition);
return(0); //unable to find the spawn condition return (0); //unable to find the spawn condition
} }
SpawnCondition &cond = condi->second; return i->second.value;
return cond.value;
} }
//this is a remote spawn condition, grab it from the DB const auto& l = SpawnConditionValuesRepository::GetWhere(
//load spawn conditions database,
std::string query = StringFormat( fmt::format(
"SELECT value FROM spawn_condition_values " "`zone` = '{}' AND `instance_id` = {} AND `id` = {}",
"WHERE zone = '%s' AND instance_id = %u AND id = %d", Strings::Escape(zone_short_name),
zone_short, instance_id, condition_id instance_id,
condition
)
); );
auto results = database.QueryDatabase(query);
if (!results.Success()) { if (l.empty()) {
LogSpawns("Unable to query remote condition [{}] from zone [{}] in Get request", condition_id, zone_short); LogSpawns("Unable to query remote condition [{}] from zone [{}] in Get request", condition, zone_short_name);
return 0; //dunno a better thing to do... return 0;
} }
if (results.RowCount() == 0) { const auto& e = l.front();
LogSpawns("Unable to load remote condition [{}] from zone [{}] in Get request", condition_id, zone_short);
return 0; //dunno a better thing to do...
}
auto row = results.begin(); return e.value;
return Strings::ToInt(row[0]);
} }
bool SpawnConditionManager::Check(uint16 condition, int16 min_value) { bool SpawnConditionManager::Check(uint16 condition, int16 min_value) {

View File

@ -147,9 +147,9 @@ public:
SpawnConditionManager(); SpawnConditionManager();
void Process(); void Process();
bool LoadSpawnConditions(const char* zone_name, uint32 instance_id); bool LoadSpawnConditions(const std::string& zone_short_name, uint32 instance_id);
int16 GetCondition(const char *zone_short, uint32 instance_id, uint16 condition_id); int16 GetCondition(const std::string& zone_short_name, uint32 instance_id, uint16 condition);
void SetCondition(const char *zone_short, uint32 instance_id, uint16 condition_id, int16 new_value, bool world_update = false); void SetCondition(const char *zone_short, uint32 instance_id, uint16 condition_id, int16 new_value, bool world_update = false);
void ToggleEvent(uint32 event_id, bool enabled, bool strict, bool reset_base); void ToggleEvent(uint32 event_id, bool enabled, bool strict, bool reset_base);
bool Check(uint16 condition, int16 min_value); bool Check(uint16 condition, int16 min_value);
@ -160,9 +160,9 @@ protected:
std::vector<SpawnEvent> spawn_events; std::vector<SpawnEvent> spawn_events;
void ExecEvent(SpawnEvent &e, bool send_update); void ExecEvent(SpawnEvent &e, bool send_update);
void UpdateDBEvent(SpawnEvent &e); void UpdateSpawnEvent(SpawnEvent &e);
bool LoadDBEvent(uint32 event_id, SpawnEvent &e, std::string &zone_name); bool LoadSpawnEvent(uint32 event_id, SpawnEvent& event, std::string& zone_short_name);
void UpdateDBCondition(const char* zone_name, uint32 instance_id, uint16 cond_id, int16 value); void UpdateSpawnCondition(const std::string& zone_short_name, uint32 instance_id, uint16 condition, int16 condition_value);
void FindNearestEvent(); void FindNearestEvent();
Timer minute_timer; Timer minute_timer;

View File

@ -530,7 +530,7 @@ public:
bool LoadSpawnGroups(const char* zone_name, uint16 version, SpawnGroupList* spawn_group_list); bool LoadSpawnGroups(const char* zone_name, uint16 version, SpawnGroupList* spawn_group_list);
bool LoadSpawnGroupsByID(int spawn_group_id, SpawnGroupList* spawn_group_list); bool LoadSpawnGroupsByID(int spawn_group_id, SpawnGroupList* spawn_group_list);
bool PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spawn2_list, int16 version); bool PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spawn2_list, int16 version);
bool CreateSpawn2(Client *c, uint32 spawngroup, const char* zone, const glm::vec4& position, uint32 respawn, uint32 variance, uint16 condition, int16 cond_value); bool CreateSpawn2(Client* c, uint32 spawngroup_id, const std::string& zone_short_name, const glm::vec4& position, uint32 respawn, uint32 variance, uint16 condition, int16 condition_value);
void UpdateRespawnTime(uint32 spawn2_id, uint16 instance_id,uint32 timeleft); void UpdateRespawnTime(uint32 spawn2_id, uint16 instance_id,uint32 timeleft);
uint32 GetSpawnTimeLeft(uint32 spawn2_id, uint16 instance_id); uint32 GetSpawnTimeLeft(uint32 spawn2_id, uint16 instance_id);
void UpdateSpawn2Status(uint32 id, uint8 new_status, uint32 instance_id); void UpdateSpawn2Status(uint32 id, uint8 new_status, uint32 instance_id);