From 3e4587cd5785c8c3e609a710ea329a8a6c4693b5 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 2 Sep 2019 04:10:43 -0500 Subject: [PATCH] Logs::Spawns to LogSpawns --- world/login_server.cpp | 4 +- zone/spawn2.cpp | 272 +++++++++++++++++++---------------------- zone/zone.cpp | 2 +- 3 files changed, 130 insertions(+), 148 deletions(-) diff --git a/world/login_server.cpp b/world/login_server.cpp index 025f1e437..d765838f8 100644 --- a/world/login_server.cpp +++ b/world/login_server.cpp @@ -419,7 +419,7 @@ bool LoginServer::Connect() [this](EQ::Net::ServertalkClient *client) { if (client) { LogInfo( - "Connected to Loginserver: {0}:{1}", + "Connected to Loginserver: [{0}:{1}]", LoginServerAddress, LoginServerPort ); @@ -436,7 +436,7 @@ bool LoginServer::Connect() } else { LogInfo( - "Could not connect to Loginserver: {0}:{1}", + "Could not connect to Loginserver: [{0}:{1}]", LoginServerAddress, LoginServerPort ); diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index 6b6a020cb..8e0372824 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -154,17 +154,13 @@ bool Spawn2::Process() { if (timer.Check()) { timer.Disable(); - Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Timer has triggered", spawn2_id); + LogSpawns("Spawn2 [{}]: 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(Logs::Detail, - Logs::Spawns, - "Spawn2 %d: spawning prevented by spawn condition %d", - spawn2_id, - condition_id); + LogSpawns("Spawn2 [{}]: spawning prevented by spawn condition [{}]", spawn2_id, condition_id); Reset(); return (true); } @@ -175,11 +171,7 @@ bool Spawn2::Process() { } if (spawn_group == nullptr) { - Log(Logs::Detail, - Logs::Spawns, - "Spawn2 %d: Unable to locate spawn group %d. Disabling.", - spawn2_id, - spawngroup_id_); + LogSpawns("Spawn2 [{}]: Unable to locate spawn group [{}]. Disabling", spawn2_id, spawngroup_id_); return false; } @@ -187,11 +179,7 @@ bool Spawn2::Process() { //have the spawn group pick an NPC for us uint32 npcid = spawn_group->GetNPCType(); if (npcid == 0) { - Log(Logs::Detail, - Logs::Spawns, - "Spawn2 %d: Spawn group %d did not yeild an NPC! not spawning.", - spawn2_id, - spawngroup_id_); + LogSpawns("Spawn2 [{}]: Spawn group [{}] did not yeild an NPC! not spawning", spawn2_id, spawngroup_id_); Reset(); //try again later (why?) return (true); @@ -200,24 +188,14 @@ bool Spawn2::Process() { //try to find our NPC type. const NPCType *tmp = database.LoadNPCTypesData(npcid); if (tmp == nullptr) { - Log(Logs::Detail, - Logs::Spawns, - "Spawn2 %d: Spawn group %d yeilded an invalid NPC type %d", - spawn2_id, - spawngroup_id_, - npcid); + LogSpawns("Spawn2 [{}]: Spawn group [{}] yeilded an invalid NPC type [{}]", spawn2_id, spawngroup_id_, npcid); Reset(); //try again later return (true); } if (tmp->unique_spawn_by_name) { if (!entity_list.LimitCheckName(tmp->name)) { - Log(Logs::Detail, - Logs::Spawns, - "Spawn2 %d: Spawn group %d yeilded NPC type %d, which is unique and one already exists.", - spawn2_id, - spawngroup_id_, - npcid); + LogSpawns("Spawn2 [{}]: Spawn group [{}] yeilded NPC type [{}], which is unique and one already exists", spawn2_id, spawngroup_id_, npcid); timer.Start(5000); //try again in five seconds. return (true); } @@ -225,13 +203,7 @@ bool Spawn2::Process() { if (tmp->spawn_limit > 0) { if (!entity_list.LimitCheckType(npcid, tmp->spawn_limit)) { - Log(Logs::Detail, - Logs::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); + LogSpawns("Spawn2 [{}]: Spawn group [{}] yeilded NPC type [{}], which is over its spawn limit ([{}])", spawn2_id, spawngroup_id_, npcid, tmp->spawn_limit); timer.Start(5000); //try again in five seconds. return (true); } @@ -287,9 +259,7 @@ bool Spawn2::Process() { } if (zone->InstantGrids()) { - Log(Logs::Detail, - Logs::Spawns, - "Spawn2 %d: Group %d spawned %s (%d) at (%.3f, %.3f, %.3f).", + LogSpawns("Spawn2 [{}]: Group [{}] spawned [{}] ([{}]) at ([{}], [{}], [{}])", spawn2_id, spawngroup_id_, npc->GetName(), @@ -302,16 +272,15 @@ bool Spawn2::Process() { LoadGrid(); } else { - Log(Logs::Detail, - Logs::Spawns, - "Spawn2 %d: Group %d spawned %s (%d) at (%.3f, %.3f, %.3f). Grid loading delayed.", + LogSpawns("Spawn2 [{}]: Group [{}] spawned [{}] ([{}]) at ([{}], [{}], [{}]). Grid loading delayed", spawn2_id, spawngroup_id_, tmp->name, npcid, x, y, - z); + z + ); } } @@ -337,7 +306,7 @@ void Spawn2::LoadGrid() { //dont set an NPC's grid until its loaded for them. npcthis->SetGrid(grid_); npcthis->AssignWaypoints(grid_); - Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Loading grid %d for %s", spawn2_id, grid_, npcthis->GetName()); + LogSpawns("Spawn2 [{}]: Loading grid [{}] for [{}]", spawn2_id, grid_, npcthis->GetName()); } /* @@ -347,21 +316,21 @@ void Spawn2::LoadGrid() { void Spawn2::Reset() { timer.Start(resetTimer()); npcthis = nullptr; - Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn reset, repop in %d ms", spawn2_id, timer.GetRemainingTime()); + LogSpawns("Spawn2 [{}]: Spawn reset, repop in [{}] ms", spawn2_id, timer.GetRemainingTime()); } void Spawn2::Depop() { timer.Disable(); - Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn reset, repop disabled", spawn2_id); + LogSpawns("Spawn2 [{}]: Spawn reset, repop disabled", spawn2_id); npcthis = nullptr; } void Spawn2::Repop(uint32 delay) { if (delay == 0) { timer.Trigger(); - Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn reset, repop immediately.", spawn2_id); + LogSpawns("Spawn2 [{}]: Spawn reset, repop immediately", spawn2_id); } else { - Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn reset for repop, repop in %d ms", spawn2_id, delay); + LogSpawns("Spawn2 [{}]: Spawn reset for repop, repop in [{}] ms", spawn2_id, delay); timer.Start(delay); } npcthis = nullptr; @@ -406,7 +375,7 @@ void Spawn2::ForceDespawn() cur = despawnTimer(dtimer); } - Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn group %d set despawn timer to %d ms.", spawn2_id, spawngroup_id_, cur); + LogSpawns("Spawn2 [{}]: Spawn group [{}] set despawn timer to [{}] ms", spawn2_id, spawngroup_id_, cur); timer.Start(cur); } @@ -427,7 +396,7 @@ void Spawn2::DeathReset(bool realdeath) if(spawn2_id) { database.UpdateRespawnTime(spawn2_id, zone->GetInstanceID(), (cur/1000)); - Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn reset by death, repop in %d ms", spawn2_id, timer.GetRemainingTime()); + LogSpawns("Spawn2 [{}]: Spawn reset by death, repop in [{}] ms", spawn2_id, timer.GetRemainingTime()); //store it to database too } } @@ -712,12 +681,12 @@ void Spawn2::SpawnConditionChanged(const SpawnCondition &c, int16 old_value) { if(GetSpawnCondition() != c.condition_id) return; - Log(Logs::Detail, Logs::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); + LogSpawns("Spawn2 [{}]: Notified that our spawn condition [{}] has changed from [{}] to [{}]. Our min value is [{}]", 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(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our threshold for this condition was not crossed. Doing nothing.", spawn2_id); + LogSpawns("Spawn2 [{}]: Our threshold for this condition was not crossed. Doing nothing", spawn2_id); return; //no change } @@ -725,50 +694,50 @@ void Spawn2::SpawnConditionChanged(const SpawnCondition &c, int16 old_value) { switch(c.on_change) { case SpawnCondition::DoNothing: //that was easy. - Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Taking no action on existing spawn.", spawn2_id, new_state?"enabled":"disabled"); + LogSpawns("Spawn2 [{}]: Our condition is now [{}]. Taking no action on existing spawn", spawn2_id, new_state?"enabled":"disabled"); break; case SpawnCondition::DoDepop: - Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Depoping our mob.", spawn2_id, new_state?"enabled":"disabled"); + LogSpawns("Spawn2 [{}]: Our condition is now [{}]. 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(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Forcing a repop.", spawn2_id, new_state?"enabled":"disabled"); + LogSpawns("Spawn2 [{}]: Our condition is now [{}]. 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(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Forcing a repop if repsawn timer is expired.", spawn2_id, new_state?"enabled":"disabled"); + LogSpawns("Spawn2 [{}]: Our condition is now [{}]. Forcing a repop if repsawn timer is expired", spawn2_id, new_state?"enabled":"disabled"); if(npcthis != nullptr) { - Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our npcthis is currently not null. The zone thinks it is %s. Forcing a depop.", spawn2_id, npcthis->GetName()); + LogSpawns("Spawn2 [{}]: Our npcthis is currently not null. The zone thinks it is [{}]. 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(Logs::Detail, Logs::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); + LogSpawns("Spawn2 [{}]: Our condition is now [{}]. The respawn timer_remaining is [{}]. Forcing a repop if it is <= 0", spawn2_id, new_state?"enabled":"disabled", timer_remaining); if(timer_remaining <= 0) Repop(); } else { - Log(Logs::Detail, Logs::Spawns,"Spawn2 %d: Our condition is now %s. Not checking respawn timer.", spawn2_id, new_state?"enabled":"disabled"); + LogSpawns("Spawn2 [{}]: Our condition is now [{}]. Not checking respawn timer", spawn2_id, new_state?"enabled":"disabled"); } break; default: if(c.on_change < SpawnCondition::DoSignalMin) { - Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Invalid on-change action %d.", spawn2_id, new_state?"enabled":"disabled", c.on_change); + LogSpawns("Spawn2 [{}]: Our condition is now [{}]. Invalid on-change action [{}]", spawn2_id, new_state?"enabled":"disabled", c.on_change); return; //unknown onchange action } int signal_id = c.on_change - SpawnCondition::DoSignalMin; - Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Signaling our mob with %d.", spawn2_id, new_state?"enabled":"disabled", signal_id); + LogSpawns("Spawn2 [{}]: Our condition is now [{}]. Signaling our mob with [{}]", 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(Logs::Detail, Logs::Spawns, "Zone notified that spawn condition %d has changed from %d to %d. Notifying all spawn points.", c.condition_id, old_value, c.value); + LogSpawns("Zone notified that spawn condition [{}] has changed from [{}] to [{}]. Notifying all spawn points", c.condition_id, old_value, c.value); LinkedListIterator iterator(spawn2_list); @@ -838,7 +807,7 @@ void SpawnConditionManager::Process() { EQTime::AddMinutes(cevent.period, &cevent.next); std::string t; EQTime::ToString(&cevent.next, t); - Log(Logs::Detail, Logs::Spawns, "Event %d: Will trigger again in %d EQ minutes at %s.", 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 UpdateDBEvent(cevent); //find the next closest event timer. @@ -857,7 +826,7 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) { std::map::iterator condi; condi = spawn_conditions.find(event.condition_id); if(condi == spawn_conditions.end()) { - Log(Logs::Detail, Logs::Spawns, "Event %d: Unable to find condition %d to execute on.", event.id, event.condition_id); + LogSpawns("Event [{}]: Unable to find condition [{}] to execute on", event.id, event.condition_id); return; //unable to find the spawn condition to operate on } @@ -865,7 +834,7 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) { zone->zone_time.GetCurrentEQTimeOfDay(&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(Logs::Detail, Logs::Spawns, "Event %d: Unable to execute. Condition is strict, and event time has already passed.", event.id); + LogSpawns("Event [{}]: Unable to execute. Condition is strict, and event time has already passed", event.id); return; } @@ -877,26 +846,26 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) { switch(event.action) { case SpawnEvent::ActionSet: new_value = event.argument; - Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Setting condition %d to %d.", event.id, event.condition_id, event.argument); + LogSpawns("Event [{}]: Executing. Setting condition [{}] to [{}]", event.id, event.condition_id, event.argument); break; case SpawnEvent::ActionAdd: new_value += event.argument; - Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Adding %d to condition %d, yeilding %d.", event.id, event.argument, event.condition_id, new_value); + LogSpawns("Event [{}]: Executing. Adding [{}] to condition [{}], yeilding [{}]", event.id, event.argument, event.condition_id, new_value); break; case SpawnEvent::ActionSubtract: new_value -= event.argument; - Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Subtracting %d from condition %d, yeilding %d.", event.id, event.argument, event.condition_id, new_value); + LogSpawns("Event [{}]: Executing. Subtracting [{}] from condition [{}], yeilding [{}]", event.id, event.argument, event.condition_id, new_value); break; case SpawnEvent::ActionMultiply: new_value *= event.argument; - Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Multiplying condition %d by %d, yeilding %d.", event.id, event.condition_id, event.argument, new_value); + LogSpawns("Event [{}]: Executing. Multiplying condition [{}] by [{}], yeilding [{}]", event.id, event.condition_id, event.argument, new_value); break; case SpawnEvent::ActionDivide: new_value /= event.argument; - Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Dividing condition %d by %d, yeilding %d.", event.id, event.condition_id, event.argument, new_value); + LogSpawns("Event [{}]: Executing. Dividing condition [{}] by [{}], yeilding [{}]", event.id, event.condition_id, event.argument, new_value); break; default: - Log(Logs::Detail, Logs::Spawns, "Event %d: Invalid event action type %d", event.id, event.action); + LogSpawns("Event [{}]: Invalid event action type [{}]", event.id, event.action); return; } @@ -966,7 +935,7 @@ bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std: std::string timeAsString; EQTime::ToString(&event.next, timeAsString); - Log(Logs::Detail, Logs::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()); + 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; } @@ -993,7 +962,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(Logs::Detail, Logs::Spawns, "Loaded spawn condition %d with value %d and on_change %d", cond.condition_id, cond.value, cond.on_change); + LogSpawns("Loaded spawn condition [{}] with value [{}] and on_change [{}]", cond.condition_id, cond.value, cond.on_change); } //load values @@ -1022,33 +991,42 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in return false; } - for (auto row = results.begin(); row != results.end(); ++row) { - SpawnEvent event; + for (auto row = results.begin(); row != results.end(); ++row) { + SpawnEvent event; - event.id = atoi(row[0]); - event.condition_id = atoi(row[1]); - event.period = atoi(row[2]); + event.id = atoi(row[0]); + event.condition_id = atoi(row[1]); + event.period = atoi(row[2]); if (event.period == 0) { LogError("Refusing to load spawn event #[{}] because it has a period of 0\n", event.id); continue; } - event.next.minute = atoi(row[3]); - event.next.hour = atoi(row[4]); - event.next.day = atoi(row[5]); - event.next.month = atoi(row[6]); - event.next.year = atoi(row[7]); + event.next.minute = atoi(row[3]); + event.next.hour = atoi(row[4]); + event.next.day = atoi(row[5]); + event.next.month = atoi(row[6]); + event.next.year = atoi(row[7]); - event.enabled = atoi(row[8])==0?false:true; - event.action = (SpawnEvent::Action) atoi(row[9]); - event.argument = atoi(row[10]); - event.strict = atoi(row[11])==0?false:true; + event.enabled = atoi(row[8]) == 0 ? false : true; + event.action = (SpawnEvent::Action) atoi(row[9]); + event.argument = atoi(row[10]); + event.strict = atoi(row[11]) == 0 ? false : true; - spawn_events.push_back(event); + spawn_events.push_back(event); - Log(Logs::Detail, Logs::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); - } + LogSpawns( + "(LoadSpawnConditions) Loaded [{}] spawn event [{}] on condition [{}] with period [{}], action [{}], argument [{}], strict [{}]", + 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 //and use them to alter just the condition variables. @@ -1080,31 +1058,33 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in if(!cevent.enabled) continue; - //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(Logs::Detail, Logs::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); - //save it in the db. - UpdateDBEvent(cevent); - continue; //were done with this event. - } + //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) { + LogSpawns("Initial next trigger time set for spawn event [{}]", cevent.id); + memcpy(&cevent.next, &tod, sizeof(cevent.next)); + //add one period + EQTime::AddMinutes(cevent.period, &cevent.next); + //save it in the db. + UpdateDBEvent(cevent); + continue; //were done with this event. + } - bool ran = false; - while(EQTime::IsTimeBefore(&tod, &cevent.next)) { - Log(Logs::Detail, Logs::Spawns, "Catch up triggering on event %d", cevent.id); - //this event has been triggered. - //execute the event - if(!cevent.strict || StrictCheck) - ExecEvent(cevent, false); + bool ran = false; + while (EQTime::IsTimeBefore(&tod, &cevent.next)) { + LogSpawns("Catch up triggering on event [{}]", cevent.id); + //this event has been triggered. + //execute the event + if (!cevent.strict || StrictCheck) { + ExecEvent(cevent, false); + } - //add the period of the event to the trigger time - EQTime::AddMinutes(cevent.period, &cevent.next); - ran = true; - } + //add the period of the event to the trigger time + EQTime::AddMinutes(cevent.period, &cevent.next); + ran = true; + } - //only write it out if the event actually ran + //only write it out if the event actually ran if(ran) UpdateDBEvent(cevent); //save the event in the DB } @@ -1136,10 +1116,10 @@ void SpawnConditionManager::FindNearestEvent() { } } if (next_id == -1) { - Log(Logs::Detail, Logs::Spawns, "No spawn events enabled. Disabling next event."); + LogSpawns("No spawn events enabled. Disabling next event"); } else { - Log(Logs::Detail, Logs::Spawns, "Next event determined to be event %d", next_id); + LogSpawns("Next event determined to be event [{}]", next_id); } } @@ -1152,14 +1132,14 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance std::map::iterator condi; condi = spawn_conditions.find(condition_id); if(condi == spawn_conditions.end()) { - Log(Logs::Detail, Logs::Spawns, "Condition update received from world for %d, but we do not have that conditon.", condition_id); + LogSpawns("Condition update received from world for [{}], 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(Logs::Detail, Logs::Spawns, "Condition update received from world for %d with value %d, which is what we already have.", condition_id, new_value); + LogSpawns("Condition update received from world for [{}] with value [{}], which is what we already have", condition_id, new_value); return; } @@ -1168,7 +1148,7 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance //set our local value cond.value = new_value; - Log(Logs::Detail, Logs::Spawns, "Condition update received from world for %d with value %d", condition_id, new_value); + LogSpawns("Condition update received from world for [{}] with value [{}]", condition_id, new_value); //now we have to test each spawn point to see if it changed. zone->SpawnConditionChanged(cond, old_value); @@ -1179,14 +1159,14 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance std::map::iterator condi; condi = spawn_conditions.find(condition_id); if(condi == spawn_conditions.end()) { - Log(Logs::Detail, Logs::Spawns, "Local Condition update requested for %d, but we do not have that conditon.", condition_id); + LogSpawns("Local Condition update requested for [{}], 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(Logs::Detail, Logs::Spawns, "Local Condition update requested for %d with value %d, which is what we already have.", condition_id, new_value); + LogSpawns("Local Condition update requested for [{}] with value [{}], which is what we already have", condition_id, new_value); return; } @@ -1197,7 +1177,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(Logs::Detail, Logs::Spawns, "Local Condition update requested for %d with value %d", condition_id, new_value); + LogSpawns("Local Condition update requested for [{}] with value [{}]", condition_id, new_value); //now we have to test each spawn point to see if it changed. zone->SpawnConditionChanged(cond, old_value); @@ -1207,7 +1187,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(Logs::Detail, Logs::Spawns, "Remote spawn condition %d set to %d. 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); @@ -1227,7 +1207,7 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance void SpawnConditionManager::ReloadEvent(uint32 event_id) { std::string zone_short_name; - Log(Logs::Detail, Logs::Spawns, "Requested to reload event %d from the database.", event_id); + LogSpawns("Requested to reload event [{}] from the database", event_id); //first look for the event in our local event list std::vector::iterator cur,end; @@ -1240,7 +1220,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(Logs::Detail, Logs::Spawns, "Failed to reload event %d from the database.", event_id); + LogSpawns("Failed to reload event [{}] from the database", event_id); return; } //sync up our nearest event @@ -1253,7 +1233,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(Logs::Detail, Logs::Spawns, "Failed to reload event %d from the database.", event_id); + LogSpawns("Failed to reload event [{}] from the database", event_id); return; } @@ -1270,7 +1250,7 @@ void SpawnConditionManager::ReloadEvent(uint32 event_id) { void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool strict, bool reset_base) { - Log(Logs::Detail, Logs::Spawns, "Request to %s spawn event %d %sresetting trigger time", enabled?"enable":"disable", event_id, reset_base?"":"without "); + LogSpawns("Request to [{}] spawn event [{}] [{}]resetting trigger time", enabled?"enable":"disable", event_id, reset_base?"":"without "); //first look for the event in our local event list std::vector::iterator cur,end; @@ -1285,13 +1265,13 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri cevent.enabled = enabled; cevent.strict = strict; if(reset_base) { - Log(Logs::Detail, Logs::Spawns, "Spawn event %d located in this zone. State set. Trigger time reset (period %d).", event_id, cevent.period); + LogSpawns("Spawn event [{}] located in this zone. State set. Trigger time reset (period [{}])", event_id, cevent.period); //start with the time now zone->zone_time.GetCurrentEQTimeOfDay(&cevent.next); //advance the next time by our period EQTime::AddMinutes(cevent.period, &cevent.next); } else { - Log(Logs::Detail, Logs::Spawns, "Spawn event %d located in this zone. State changed.", event_id); + LogSpawns("Spawn event [{}] located in this zone. State changed", event_id); } //save the event in the DB @@ -1300,7 +1280,7 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri //sync up our nearest event FindNearestEvent(); } else { - Log(Logs::Detail, Logs::Spawns, "Spawn event %d located in this zone but no change was needed.", event_id); + LogSpawns("Spawn event [{}] located in this zone but no change was needed", event_id); } //even if we dont change anything, we still found it return; @@ -1319,24 +1299,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(Logs::Detail, Logs::Spawns, "Unable to find spawn event %d in the database.", event_id); + LogSpawns("Unable to find spawn event [{}] in the database", event_id); //unable to find the event in the database... return; } if(e.enabled == enabled && !reset_base) { - Log(Logs::Detail, Logs::Spawns, "Spawn event %d is not located in this zone but no change was needed.", event_id); + LogSpawns("Spawn event [{}] is not located in this zone but no change was needed", event_id); return; //no changes. } e.enabled = enabled; if(reset_base) { - Log(Logs::Detail, Logs::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); + LogSpawns("Spawn event [{}] is in zone [{}]. State set. Trigger time reset (period [{}]). Notifying world", event_id, zone_short_name.c_str(), e.period); //start with the time now zone->zone_time.GetCurrentEQTimeOfDay(&e.next); //advance the next time by our period EQTime::AddMinutes(e.period, &e.next); } else { - Log(Logs::Detail, Logs::Spawns, "Spawn event %d is in zone %s. 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 UpdateDBEvent(e); @@ -1361,7 +1341,7 @@ int16 SpawnConditionManager::GetCondition(const char *zone_short, uint32 instanc condi = spawn_conditions.find(condition_id); if(condi == spawn_conditions.end()) { - Log(Logs::Detail, Logs::Spawns, "Unable to find local condition %d in Get request.", condition_id); + LogSpawns("Unable to find local condition [{}] in Get request", condition_id); return(0); //unable to find the spawn condition } @@ -1370,20 +1350,22 @@ int16 SpawnConditionManager::GetCondition(const char *zone_short, uint32 instanc } //this is a remote spawn condition, grab it from the DB - //load spawn conditions - std::string query = StringFormat("SELECT value FROM spawn_condition_values " - "WHERE zone = '%s' AND instance_id = %u AND id = %d", - zone_short, instance_id, condition_id); - auto results = database.QueryDatabase(query); - if (!results.Success()) { - Log(Logs::Detail, Logs::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... - } + //load spawn conditions + std::string query = StringFormat( + "SELECT value FROM spawn_condition_values " + "WHERE zone = '%s' AND instance_id = %u AND id = %d", + zone_short, instance_id, condition_id + ); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogSpawns("Unable to query remote condition [{}] from zone [{}] in Get request", condition_id, zone_short); + return 0; //dunno a better thing to do... + } - if (results.RowCount() == 0) { - Log(Logs::Detail, Logs::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... - } + if (results.RowCount() == 0) { + 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(); diff --git a/zone/zone.cpp b/zone/zone.cpp index 459a055d4..769464d4a 100755 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1203,7 +1203,7 @@ bool Zone::Process() { EQEmu::InventoryProfile::CleanDirty(); - Log(Logs::Detail, Logs::Spawns, "Running Zone::Process -> Spawn2::Process"); + LogSpawns("Running Zone::Process -> Spawn2::Process"); iterator.Reset(); while (iterator.MoreElements()) {