Renamed DoLog to Out as the aggregate logging function for simplicity of use and shortened syntax of Log.Out

This commit is contained in:
Akkadius
2015-01-18 02:00:15 -06:00
parent 1c048cb1d1
commit c025765283
119 changed files with 2653 additions and 2653 deletions
+76 -76
View File
@@ -153,13 +153,13 @@ bool Spawn2::Process() {
if (timer.Check()) {
timer.Disable();
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Timer has triggered", spawn2_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Timer has triggered", spawn2_id);
//first check our spawn condition, if this isnt active
//then we reset the timer and try again next time.
if(condition_id != SC_AlwaysEnabled
&& !zone->spawn_conditions.Check(condition_id, condition_min_value)) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: spawning prevented by spawn condition %d", spawn2_id, condition_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: spawning prevented by spawn condition %d", spawn2_id, condition_id);
Reset();
return(true);
}
@@ -170,14 +170,14 @@ bool Spawn2::Process() {
}
if (sg == nullptr) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Unable to locate spawn group %d. Disabling.", spawn2_id, spawngroup_id_);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Unable to locate spawn group %d. Disabling.", spawn2_id, spawngroup_id_);
return false;
}
//have the spawn group pick an NPC for us
uint32 npcid = sg->GetNPCType();
if (npcid == 0) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn group %d did not yeild an NPC! not spawning.", spawn2_id, spawngroup_id_);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn group %d did not yeild an NPC! not spawning.", spawn2_id, spawngroup_id_);
Reset(); //try again later (why?)
return(true);
}
@@ -185,7 +185,7 @@ bool Spawn2::Process() {
//try to find our NPC type.
const NPCType* tmp = database.GetNPCType(npcid);
if (tmp == nullptr) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn group %d yeilded an invalid NPC type %d", spawn2_id, spawngroup_id_, npcid);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn group %d yeilded an invalid NPC type %d", spawn2_id, spawngroup_id_, npcid);
Reset(); //try again later
return(true);
}
@@ -194,7 +194,7 @@ bool Spawn2::Process() {
{
if(!entity_list.LimitCheckName(tmp->name))
{
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn group %d yeilded NPC type %d, which is unique and one already exists.", spawn2_id, spawngroup_id_, npcid);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn group %d yeilded NPC type %d, which is unique and one already exists.", spawn2_id, spawngroup_id_, npcid);
timer.Start(5000); //try again in five seconds.
return(true);
}
@@ -202,7 +202,7 @@ bool Spawn2::Process() {
if(tmp->spawn_limit > 0) {
if(!entity_list.LimitCheckType(npcid, tmp->spawn_limit)) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn group %d yeilded NPC type %d, which is over its spawn limit (%d)", spawn2_id, spawngroup_id_, npcid, tmp->spawn_limit);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn group %d yeilded NPC type %d, which is over its spawn limit (%d)", spawn2_id, spawngroup_id_, npcid, tmp->spawn_limit);
timer.Start(5000); //try again in five seconds.
return(true);
}
@@ -233,10 +233,10 @@ bool Spawn2::Process() {
if(sg->roamdist && sg->roambox[0] && sg->roambox[1] && sg->roambox[2] && sg->roambox[3] && sg->delay && sg->min_delay)
npc->AI_SetRoambox(sg->roamdist,sg->roambox[0],sg->roambox[1],sg->roambox[2],sg->roambox[3],sg->delay,sg->min_delay);
if(zone->InstantGrids()) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Group %d spawned %s (%d) at (%.3f, %.3f, %.3f).", spawn2_id, spawngroup_id_, npc->GetName(), npcid, x, y, z);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Group %d spawned %s (%d) at (%.3f, %.3f, %.3f).", spawn2_id, spawngroup_id_, npc->GetName(), npcid, x, y, z);
LoadGrid();
} else {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Group %d spawned %s (%d) at (%.3f, %.3f, %.3f). Grid loading delayed.", spawn2_id, spawngroup_id_, tmp->name, npcid, x, y, z);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Group %d spawned %s (%d) at (%.3f, %.3f, %.3f). Grid loading delayed.", spawn2_id, spawngroup_id_, tmp->name, npcid, x, y, z);
}
}
return true;
@@ -261,7 +261,7 @@ void Spawn2::LoadGrid() {
//dont set an NPC's grid until its loaded for them.
npcthis->SetGrid(grid_);
npcthis->AssignWaypoints(grid_);
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Loading grid %d for %s", spawn2_id, grid_, npcthis->GetName());
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Loading grid %d for %s", spawn2_id, grid_, npcthis->GetName());
}
@@ -272,21 +272,21 @@ void Spawn2::LoadGrid() {
void Spawn2::Reset() {
timer.Start(resetTimer());
npcthis = nullptr;
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn reset, repop in %d ms", spawn2_id, timer.GetRemainingTime());
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn reset, repop in %d ms", spawn2_id, timer.GetRemainingTime());
}
void Spawn2::Depop() {
timer.Disable();
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn reset, repop disabled", spawn2_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn reset, repop disabled", spawn2_id);
npcthis = nullptr;
}
void Spawn2::Repop(uint32 delay) {
if (delay == 0) {
timer.Trigger();
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn reset, repop immediately.", spawn2_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn reset, repop immediately.", spawn2_id);
} else {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn reset for repop, repop in %d ms", spawn2_id, delay);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn reset for repop, repop in %d ms", spawn2_id, delay);
timer.Start(delay);
}
npcthis = nullptr;
@@ -328,7 +328,7 @@ void Spawn2::ForceDespawn()
cur = despawnTimer(dtimer);
}
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn group %d set despawn timer to %d ms.", spawn2_id, spawngroup_id_, cur);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn group %d set despawn timer to %d ms.", spawn2_id, spawngroup_id_, cur);
timer.Start(cur);
}
@@ -349,7 +349,7 @@ void Spawn2::DeathReset(bool realdeath)
if(spawn2_id)
{
database.UpdateSpawn2Timeleft(spawn2_id, zone->GetInstanceID(), (cur/1000));
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn reset by death, repop in %d ms", spawn2_id, timer.GetRemainingTime());
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Spawn reset by death, repop in %d ms", spawn2_id, timer.GetRemainingTime());
//store it to database too
}
}
@@ -364,7 +364,7 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spa
zone_name, version);
auto results = QueryDatabase(query);
if (!results.Success()) {
Log.DoLog(EQEmuLogSys::General, EQEmuLogSys::Error, "Error in PopulateZoneLists query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
Log.Out(EQEmuLogSys::General, EQEmuLogSys::Error, "Error in PopulateZoneLists query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return false;
}
@@ -392,12 +392,12 @@ Spawn2* ZoneDatabase::LoadSpawn2(LinkedList<Spawn2*> &spawn2_list, uint32 spawn2
"WHERE id = %i", spawn2id);
auto results = QueryDatabase(query);
if (!results.Success()) {
Log.DoLog(EQEmuLogSys::General, EQEmuLogSys::Error, "Error in LoadSpawn2 query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
Log.Out(EQEmuLogSys::General, EQEmuLogSys::Error, "Error in LoadSpawn2 query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return nullptr;
}
if (results.RowCount() != 1) {
Log.DoLog(EQEmuLogSys::General, EQEmuLogSys::Error, "Error in LoadSpawn2 query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
Log.Out(EQEmuLogSys::General, EQEmuLogSys::Error, "Error in LoadSpawn2 query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return nullptr;
}
@@ -424,7 +424,7 @@ bool ZoneDatabase::CreateSpawn2(Client *client, uint32 spawngroup, const char* z
respawn, variance, condition, cond_value);
auto results = QueryDatabase(query);
if (!results.Success()) {
Log.DoLog(EQEmuLogSys::General, EQEmuLogSys::Error, "Error in CreateSpawn2 query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
Log.Out(EQEmuLogSys::General, EQEmuLogSys::Error, "Error in CreateSpawn2 query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return false;
}
@@ -466,12 +466,12 @@ void Spawn2::SpawnConditionChanged(const SpawnCondition &c, int16 old_value) {
if(GetSpawnCondition() != c.condition_id)
return;
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Notified that our spawn condition %d has changed from %d to %d. Our min value is %d.", spawn2_id, c.condition_id, old_value, c.value, condition_min_value);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Notified that our spawn condition %d has changed from %d to %d. Our min value is %d.", spawn2_id, c.condition_id, old_value, c.value, condition_min_value);
bool old_state = (old_value >= condition_min_value);
bool new_state = (c.value >= condition_min_value);
if(old_state == new_state) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Our threshold for this condition was not crossed. Doing nothing.", spawn2_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Our threshold for this condition was not crossed. Doing nothing.", spawn2_id);
return; //no change
}
@@ -479,50 +479,50 @@ void Spawn2::SpawnConditionChanged(const SpawnCondition &c, int16 old_value) {
switch(c.on_change) {
case SpawnCondition::DoNothing:
//that was easy.
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Our condition is now %s. Taking no action on existing spawn.", spawn2_id, new_state?"enabled":"disabled");
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Our condition is now %s. Taking no action on existing spawn.", spawn2_id, new_state?"enabled":"disabled");
break;
case SpawnCondition::DoDepop:
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Our condition is now %s. Depoping our mob.", spawn2_id, new_state?"enabled":"disabled");
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Our condition is now %s. Depoping our mob.", spawn2_id, new_state?"enabled":"disabled");
if(npcthis != nullptr)
npcthis->Depop(false); //remove the current mob
Reset(); //reset our spawn timer
break;
case SpawnCondition::DoRepop:
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Our condition is now %s. Forcing a repop.", spawn2_id, new_state?"enabled":"disabled");
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Our condition is now %s. Forcing a repop.", spawn2_id, new_state?"enabled":"disabled");
if(npcthis != nullptr)
npcthis->Depop(false); //remove the current mob
Repop(); //repop
break;
case SpawnCondition::DoRepopIfReady:
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Our condition is now %s. Forcing a repop if repsawn timer is expired.", spawn2_id, new_state?"enabled":"disabled");
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Our condition is now %s. Forcing a repop if repsawn timer is expired.", spawn2_id, new_state?"enabled":"disabled");
if(npcthis != nullptr) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Our npcthis is currently not null. The zone thinks it is %s. Forcing a depop.", spawn2_id, npcthis->GetName());
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Our npcthis is currently not null. The zone thinks it is %s. Forcing a depop.", spawn2_id, npcthis->GetName());
npcthis->Depop(false); //remove the current mob
npcthis = nullptr;
}
if(new_state) { // only get repawn timer remaining when the SpawnCondition is enabled.
timer_remaining = database.GetSpawnTimeLeft(spawn2_id,zone->GetInstanceID());
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns,"Spawn2 %d: Our condition is now %s. The respawn timer_remaining is %d. Forcing a repop if it is <= 0.", spawn2_id, new_state?"enabled":"disabled", timer_remaining);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns,"Spawn2 %d: Our condition is now %s. The respawn timer_remaining is %d. Forcing a repop if it is <= 0.", spawn2_id, new_state?"enabled":"disabled", timer_remaining);
if(timer_remaining <= 0)
Repop();
} else {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns,"Spawn2 %d: Our condition is now %s. Not checking respawn timer.", spawn2_id, new_state?"enabled":"disabled");
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns,"Spawn2 %d: Our condition is now %s. Not checking respawn timer.", spawn2_id, new_state?"enabled":"disabled");
}
break;
default:
if(c.on_change < SpawnCondition::DoSignalMin) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Our condition is now %s. Invalid on-change action %d.", spawn2_id, new_state?"enabled":"disabled", c.on_change);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Our condition is now %s. Invalid on-change action %d.", spawn2_id, new_state?"enabled":"disabled", c.on_change);
return; //unknown onchange action
}
int signal_id = c.on_change - SpawnCondition::DoSignalMin;
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Our condition is now %s. Signaling our mob with %d.", spawn2_id, new_state?"enabled":"disabled", signal_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn2 %d: Our condition is now %s. Signaling our mob with %d.", spawn2_id, new_state?"enabled":"disabled", signal_id);
if(npcthis != nullptr)
npcthis->SignalNPC(signal_id);
}
}
void Zone::SpawnConditionChanged(const SpawnCondition &c, int16 old_value) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Zone notified that spawn condition %d has changed from %d to %d. Notifying all spawn points.", c.condition_id, old_value, c.value);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Zone notified that spawn condition %d has changed from %d to %d. Notifying all spawn points.", c.condition_id, old_value, c.value);
LinkedListIterator<Spawn2*> iterator(spawn2_list);
@@ -592,7 +592,7 @@ void SpawnConditionManager::Process() {
EQTime::AddMinutes(cevent.period, &cevent.next);
std::string t;
EQTime::ToString(&cevent.next, t);
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Will trigger again in %d EQ minutes at %s.", cevent.id, cevent.period, t.c_str());
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Will trigger again in %d EQ minutes at %s.", cevent.id, cevent.period, t.c_str());
//save the next event time in the DB
UpdateDBEvent(cevent);
//find the next closest event timer.
@@ -611,7 +611,7 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) {
std::map<uint16, SpawnCondition>::iterator condi;
condi = spawn_conditions.find(event.condition_id);
if(condi == spawn_conditions.end()) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Unable to find condition %d to execute on.", event.id, event.condition_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Unable to find condition %d to execute on.", event.id, event.condition_id);
return; //unable to find the spawn condition to operate on
}
@@ -619,7 +619,7 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) {
zone->zone_time.getEQTimeOfDay(&tod);
if(event.strict && (event.next.hour != tod.hour || event.next.day != tod.day || event.next.month != tod.month || event.next.year != tod.year))
{
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Unable to execute. Condition is strict, and event time has already passed.", event.id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Unable to execute. Condition is strict, and event time has already passed.", event.id);
return;
}
@@ -631,26 +631,26 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) {
switch(event.action) {
case SpawnEvent::ActionSet:
new_value = event.argument;
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Executing. Setting condition %d to %d.", event.id, event.condition_id, event.argument);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Executing. Setting condition %d to %d.", event.id, event.condition_id, event.argument);
break;
case SpawnEvent::ActionAdd:
new_value += event.argument;
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Executing. Adding %d to condition %d, yeilding %d.", event.id, event.argument, event.condition_id, new_value);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Executing. Adding %d to condition %d, yeilding %d.", event.id, event.argument, event.condition_id, new_value);
break;
case SpawnEvent::ActionSubtract:
new_value -= event.argument;
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Executing. Subtracting %d from condition %d, yeilding %d.", event.id, event.argument, event.condition_id, new_value);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Executing. Subtracting %d from condition %d, yeilding %d.", event.id, event.argument, event.condition_id, new_value);
break;
case SpawnEvent::ActionMultiply:
new_value *= event.argument;
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Executing. Multiplying condition %d by %d, yeilding %d.", event.id, event.condition_id, event.argument, new_value);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Executing. Multiplying condition %d by %d, yeilding %d.", event.id, event.condition_id, event.argument, new_value);
break;
case SpawnEvent::ActionDivide:
new_value /= event.argument;
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Executing. Dividing condition %d by %d, yeilding %d.", event.id, event.condition_id, event.argument, new_value);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Executing. Dividing condition %d by %d, yeilding %d.", event.id, event.condition_id, event.argument, new_value);
break;
default:
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Invalid event action type %d", event.id, event.action);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Event %d: Invalid event action type %d", event.id, event.action);
return;
}
@@ -674,7 +674,7 @@ void SpawnConditionManager::UpdateDBEvent(SpawnEvent &event) {
event.strict? 1: 0, event.id);
auto results = database.QueryDatabase(query);
if(!results.Success())
Log.DoLog(EQEmuLogSys::General, EQEmuLogSys::Error, "Unable to update spawn event '%s': %s\n", query.c_str(), results.ErrorMessage().c_str());
Log.Out(EQEmuLogSys::General, EQEmuLogSys::Error, "Unable to update spawn event '%s': %s\n", query.c_str(), results.ErrorMessage().c_str());
}
@@ -686,7 +686,7 @@ void SpawnConditionManager::UpdateDBCondition(const char* zone_name, uint32 inst
cond_id, value, zone_name, instance_id);
auto results = database.QueryDatabase(query);
if(!results.Success())
Log.DoLog(EQEmuLogSys::General, EQEmuLogSys::Error, "Unable to update spawn condition '%s': %s\n", query.c_str(), results.ErrorMessage().c_str());
Log.Out(EQEmuLogSys::General, EQEmuLogSys::Error, "Unable to update spawn condition '%s': %s\n", query.c_str(), results.ErrorMessage().c_str());
}
@@ -699,7 +699,7 @@ bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std:
"FROM spawn_events WHERE id = %d", event_id);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
Log.DoLog(EQEmuLogSys::General, EQEmuLogSys::Error, "Error in LoadDBEvent query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
Log.Out(EQEmuLogSys::General, EQEmuLogSys::Error, "Error in LoadDBEvent query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return false;
}
@@ -727,7 +727,7 @@ bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std:
std::string timeAsString;
EQTime::ToString(&event.next, timeAsString);
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "(LoadDBEvent) Loaded %s spawn event %d on condition %d with period %d, action %d, argument %d, strict %d. Will trigger at %s", event.enabled? "enabled": "disabled", event.id, event.condition_id, event.period, event.action, event.argument, event.strict, timeAsString.c_str());
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "(LoadDBEvent) Loaded %s spawn event %d on condition %d with period %d, action %d, argument %d, strict %d. Will trigger at %s", event.enabled? "enabled": "disabled", event.id, event.condition_id, event.period, event.action, event.argument, event.strict, timeAsString.c_str());
return true;
}
@@ -742,7 +742,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
"WHERE zone = '%s'", zone_name);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
Log.DoLog(EQEmuLogSys::General, EQEmuLogSys::Error, "Error in LoadSpawnConditions query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
Log.Out(EQEmuLogSys::General, EQEmuLogSys::Error, "Error in LoadSpawnConditions query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return false;
}
@@ -755,7 +755,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
cond.on_change = (SpawnCondition::OnChange) atoi(row[1]);
spawn_conditions[cond.condition_id] = cond;
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Loaded spawn condition %d with value %d and on_change %d", cond.condition_id, cond.value, cond.on_change);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Loaded spawn condition %d with value %d and on_change %d", cond.condition_id, cond.value, cond.on_change);
}
//load values
@@ -764,7 +764,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
zone_name, instance_id);
results = database.QueryDatabase(query);
if (!results.Success()) {
Log.DoLog(EQEmuLogSys::General, EQEmuLogSys::Error, "Error in LoadSpawnConditions query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
Log.Out(EQEmuLogSys::General, EQEmuLogSys::Error, "Error in LoadSpawnConditions query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
spawn_conditions.clear();
return false;
}
@@ -782,7 +782,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
"FROM spawn_events WHERE zone = '%s'", zone_name);
results = database.QueryDatabase(query);
if (!results.Success()) {
Log.DoLog(EQEmuLogSys::General, EQEmuLogSys::Error, "Error in LoadSpawnConditions events query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
Log.Out(EQEmuLogSys::General, EQEmuLogSys::Error, "Error in LoadSpawnConditions events query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return false;
}
@@ -794,7 +794,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
event.period = atoi(row[2]);
if(event.period == 0) {
Log.DoLog(EQEmuLogSys::General, EQEmuLogSys::Error, "Refusing to load spawn event #%d because it has a period of 0\n", event.id);
Log.Out(EQEmuLogSys::General, EQEmuLogSys::Error, "Refusing to load spawn event #%d because it has a period of 0\n", event.id);
continue;
}
@@ -811,7 +811,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
spawn_events.push_back(event);
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "(LoadSpawnConditions) Loaded %s spawn event %d on condition %d with period %d, action %d, argument %d, strict %d", event.enabled? "enabled": "disabled", event.id, event.condition_id, event.period, event.action, event.argument, event.strict);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "(LoadSpawnConditions) Loaded %s spawn event %d on condition %d with period %d, action %d, argument %d, strict %d", event.enabled? "enabled": "disabled", event.id, event.condition_id, event.period, event.action, event.argument, event.strict);
}
//now we need to catch up on events that happened while we were away
@@ -846,7 +846,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
//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 && cevent.next.minute == 0) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Initial next trigger time set for spawn event %d", cevent.id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Initial next trigger time set for spawn event %d", cevent.id);
memcpy(&cevent.next, &tod, sizeof(cevent.next));
//add one period
EQTime::AddMinutes(cevent.period, &cevent.next);
@@ -857,7 +857,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
bool ran = false;
while(EQTime::IsTimeBefore(&tod, &cevent.next)) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Catch up triggering on event %d", cevent.id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Catch up triggering on event %d", cevent.id);
//this event has been triggered.
//execute the event
if(!cevent.strict || StrictCheck)
@@ -900,9 +900,9 @@ void SpawnConditionManager::FindNearestEvent() {
}
}
if(next_id == -1)
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "No spawn events enabled. Disabling next event.");
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "No spawn events enabled. Disabling next event.");
else
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Next event determined to be event %d", next_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Next event determined to be event %d", next_id);
}
void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance_id, uint16 condition_id, int16 new_value, bool world_update)
@@ -914,14 +914,14 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance
std::map<uint16, SpawnCondition>::iterator condi;
condi = spawn_conditions.find(condition_id);
if(condi == spawn_conditions.end()) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Condition update received from world for %d, but we do not have that conditon.", condition_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Condition update received from world for %d, but we do not have that conditon.", condition_id);
return; //unable to find the spawn condition
}
SpawnCondition &cond = condi->second;
if(cond.value == new_value) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Condition update received from world for %d with value %d, which is what we already have.", condition_id, new_value);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Condition update received from world for %d with value %d, which is what we already have.", condition_id, new_value);
return;
}
@@ -930,7 +930,7 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance
//set our local value
cond.value = new_value;
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Condition update received from world for %d with value %d", condition_id, new_value);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Condition update received from world for %d with value %d", condition_id, new_value);
//now we have to test each spawn point to see if it changed.
zone->SpawnConditionChanged(cond, old_value);
@@ -941,14 +941,14 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance
std::map<uint16, SpawnCondition>::iterator condi;
condi = spawn_conditions.find(condition_id);
if(condi == spawn_conditions.end()) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Local Condition update requested for %d, but we do not have that conditon.", condition_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Local Condition update requested for %d, but we do not have that conditon.", condition_id);
return; //unable to find the spawn condition
}
SpawnCondition &cond = condi->second;
if(cond.value == new_value) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Local Condition update requested for %d with value %d, which is what we already have.", condition_id, new_value);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Local Condition update requested for %d with value %d, which is what we already have.", condition_id, new_value);
return;
}
@@ -959,7 +959,7 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance
//save it in the DB too
UpdateDBCondition(zone_short, instance_id, condition_id, new_value);
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Local Condition update requested for %d with value %d", condition_id, new_value);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Local Condition update requested for %d with value %d", condition_id, new_value);
//now we have to test each spawn point to see if it changed.
zone->SpawnConditionChanged(cond, old_value);
@@ -969,7 +969,7 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance
//this is a remote spawn condition, update the DB and send
//an update packet to the zone if its up
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Remote spawn condition %d set to %d. Updating DB and notifying world.", condition_id, new_value);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Remote spawn condition %d set to %d. Updating DB and notifying world.", condition_id, new_value);
UpdateDBCondition(zone_short, instance_id, condition_id, new_value);
@@ -989,7 +989,7 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance
void SpawnConditionManager::ReloadEvent(uint32 event_id) {
std::string zone_short_name;
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Requested to reload event %d from the database.", event_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Requested to reload event %d from the database.", event_id);
//first look for the event in our local event list
std::vector<SpawnEvent>::iterator cur,end;
@@ -1002,7 +1002,7 @@ void SpawnConditionManager::ReloadEvent(uint32 event_id) {
//load the event into the old event slot
if(!LoadDBEvent(event_id, cevent, zone_short_name)) {
//unable to find the event in the database...
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Failed to reload event %d from the database.", event_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Failed to reload event %d from the database.", event_id);
return;
}
//sync up our nearest event
@@ -1015,7 +1015,7 @@ void SpawnConditionManager::ReloadEvent(uint32 event_id) {
SpawnEvent e;
if(!LoadDBEvent(event_id, e, zone_short_name)) {
//unable to find the event in the database...
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Failed to reload event %d from the database.", event_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Failed to reload event %d from the database.", event_id);
return;
}
@@ -1032,7 +1032,7 @@ void SpawnConditionManager::ReloadEvent(uint32 event_id) {
void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool strict, bool reset_base) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Request to %s spawn event %d %sresetting trigger time", enabled?"enable":"disable", event_id, reset_base?"":"without ");
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Request to %s spawn event %d %sresetting trigger time", enabled?"enable":"disable", event_id, reset_base?"":"without ");
//first look for the event in our local event list
std::vector<SpawnEvent>::iterator cur,end;
@@ -1047,13 +1047,13 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri
cevent.enabled = enabled;
cevent.strict = strict;
if(reset_base) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn event %d located in this zone. State set. Trigger time reset (period %d).", event_id, cevent.period);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn event %d located in this zone. State set. Trigger time reset (period %d).", event_id, cevent.period);
//start with the time now
zone->zone_time.getEQTimeOfDay(&cevent.next);
//advance the next time by our period
EQTime::AddMinutes(cevent.period, &cevent.next);
} else {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn event %d located in this zone. State changed.", event_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn event %d located in this zone. State changed.", event_id);
}
//save the event in the DB
@@ -1062,7 +1062,7 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri
//sync up our nearest event
FindNearestEvent();
} else {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn event %d located in this zone but no change was needed.", event_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn event %d located in this zone but no change was needed.", event_id);
}
//even if we dont change anything, we still found it
return;
@@ -1081,24 +1081,24 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri
SpawnEvent e;
std::string zone_short_name;
if(!LoadDBEvent(event_id, e, zone_short_name)) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Unable to find spawn event %d in the database.", event_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Unable to find spawn event %d in the database.", event_id);
//unable to find the event in the database...
return;
}
if(e.enabled == enabled && !reset_base) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn event %d is not located in this zone but no change was needed.", event_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn event %d is not located in this zone but no change was needed.", event_id);
return; //no changes.
}
e.enabled = enabled;
if(reset_base) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn event %d is in zone %s. State set. Trigger time reset (period %d). Notifying world.", event_id, zone_short_name.c_str(), e.period);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn event %d is in zone %s. State set. Trigger time reset (period %d). Notifying world.", event_id, zone_short_name.c_str(), e.period);
//start with the time now
zone->zone_time.getEQTimeOfDay(&e.next);
//advance the next time by our period
EQTime::AddMinutes(e.period, &e.next);
} else {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn event %d is in zone %s. State changed. Notifying world.", event_id, zone_short_name.c_str(), e.period);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Spawn event %d is in zone %s. State changed. Notifying world.", event_id, zone_short_name.c_str(), e.period);
}
//save the event in the DB
UpdateDBEvent(e);
@@ -1123,7 +1123,7 @@ int16 SpawnConditionManager::GetCondition(const char *zone_short, uint32 instanc
condi = spawn_conditions.find(condition_id);
if(condi == spawn_conditions.end())
{
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Unable to find local condition %d in Get request.", condition_id);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Unable to find local condition %d in Get request.", condition_id);
return(0); //unable to find the spawn condition
}
@@ -1138,12 +1138,12 @@ int16 SpawnConditionManager::GetCondition(const char *zone_short, uint32 instanc
zone_short, instance_id, condition_id);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Unable to query remote condition %d from zone %s in Get request.", condition_id, zone_short);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Unable to query remote condition %d from zone %s in Get request.", condition_id, zone_short);
return 0; //dunno a better thing to do...
}
if (results.RowCount() == 0) {
Log.DoLog(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Unable to load remote condition %d from zone %s in Get request.", condition_id, zone_short);
Log.Out(EQEmuLogSys::Detail, EQEmuLogSys::Spawns, "Unable to load remote condition %d from zone %s in Get request.", condition_id, zone_short);
return 0; //dunno a better thing to do...
}