Tweaks to log.out to filter messages at detail level not just cat level before formatting the message, tweaks to pathing, nearly where i want it but not entirely there.

This commit is contained in:
KimLS 2016-01-15 14:32:00 -08:00
parent 14d8683227
commit 1d055b5364
4 changed files with 62 additions and 64 deletions

View File

@ -123,26 +123,21 @@ void EQEmuLogSys::LoadLogSettingsDefaults()
std::string EQEmuLogSys::FormatOutMessageString(uint16 log_category, const std::string &in_message) std::string EQEmuLogSys::FormatOutMessageString(uint16 log_category, const std::string &in_message)
{ {
std::string category_string; std::string ret;
if (log_category > 0 && Logs::LogCategoryName[log_category]) ret.push_back('[');
category_string = StringFormat("[%s] ", Logs::LogCategoryName[log_category]); ret.append(Logs::LogCategoryName[log_category]);
return StringFormat("%s%s", category_string.c_str(), in_message.c_str()); ret.push_back(']');
ret.push_back(' ');
ret.append(in_message);
return ret;
} }
void EQEmuLogSys::ProcessGMSay(uint16 debug_level, uint16 log_category, const std::string &message) void EQEmuLogSys::ProcessGMSay(uint16 debug_level, uint16 log_category, const std::string &message)
{ {
/* Check if category enabled for process */
if (log_settings[log_category].log_to_gmsay == 0)
return;
/* Enabling Netcode based GMSay output creates a feedback loop that ultimately ends in a crash */ /* Enabling Netcode based GMSay output creates a feedback loop that ultimately ends in a crash */
if (log_category == Logs::LogCategory::Netcode) if (log_category == Logs::LogCategory::Netcode)
return; return;
/* Make sure the message inbound is at a debug level we're set at */
if (log_settings[log_category].log_to_gmsay < debug_level)
return;
/* Check to see if the process that actually ran this is zone */ /* Check to see if the process that actually ran this is zone */
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone) if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone)
on_log_gmsay_hook(log_category, message); on_log_gmsay_hook(log_category, message);
@ -160,14 +155,6 @@ void EQEmuLogSys::ProcessLogWrite(uint16 debug_level, uint16 log_category, const
crash_log.close(); crash_log.close();
} }
/* Check if category enabled for process */
if (log_settings[log_category].log_to_file == 0)
return;
/* Make sure the message inbound is at a debug level we're set at */
if (log_settings[log_category].log_to_file < debug_level)
return;
char time_stamp[80]; char time_stamp[80];
EQEmuLogSys::SetCurrentTimeStamp(time_stamp); EQEmuLogSys::SetCurrentTimeStamp(time_stamp);
@ -246,13 +233,6 @@ uint16 EQEmuLogSys::GetGMSayColorFromCategory(uint16 log_category) {
void EQEmuLogSys::ProcessConsoleMessage(uint16 debug_level, uint16 log_category, const std::string &message) void EQEmuLogSys::ProcessConsoleMessage(uint16 debug_level, uint16 log_category, const std::string &message)
{ {
/* Check if category enabled for process */
if (log_settings[log_category].log_to_console == 0)
return;
/* Make sure the message inbound is at a debug level we're set at */
if (log_settings[log_category].log_to_console < debug_level)
return;
#ifdef _WINDOWS #ifdef _WINDOWS
HANDLE console_handle; HANDLE console_handle;
@ -273,20 +253,32 @@ void EQEmuLogSys::ProcessConsoleMessage(uint16 debug_level, uint16 log_category,
void EQEmuLogSys::Out(Logs::DebugLevel debug_level, uint16 log_category, std::string message, ...) void EQEmuLogSys::Out(Logs::DebugLevel debug_level, uint16 log_category, std::string message, ...)
{ {
const bool log_to_console = log_settings[log_category].log_to_console > 0; bool log_to_console = true;
const bool log_to_file = log_settings[log_category].log_to_file > 0; if (log_settings[log_category].log_to_console < debug_level) {
const bool log_to_gmsay = log_settings[log_category].log_to_gmsay > 0; log_to_console = false;
const bool nothing_to_log = !log_to_console && !log_to_file && !log_to_gmsay; }
if (nothing_to_log) return; bool log_to_file = true;
if (log_settings[log_category].log_to_file < debug_level) {
log_to_file = false;
}
bool log_to_gmsay = true;
if (log_settings[log_category].log_to_gmsay < debug_level) {
log_to_gmsay = false;
}
const bool nothing_to_log = !log_to_console && !log_to_file && !log_to_gmsay;
if (nothing_to_log)
return;
va_list args; va_list args;
va_start(args, message); va_start(args, message);
std::string output_message = vStringFormat(message.c_str(), args); std::string output_message = vStringFormat(message.c_str(), args);
va_end(args); va_end(args);
std::string output_debug_message = EQEmuLogSys::FormatOutMessageString(log_category, output_message); std::string output_debug_message = EQEmuLogSys::FormatOutMessageString(log_category, output_message);
if (log_to_console) EQEmuLogSys::ProcessConsoleMessage(debug_level, log_category, output_debug_message); if (log_to_console) EQEmuLogSys::ProcessConsoleMessage(debug_level, log_category, output_debug_message);
if (log_to_gmsay) EQEmuLogSys::ProcessGMSay(debug_level, log_category, output_debug_message); if (log_to_gmsay) EQEmuLogSys::ProcessGMSay(debug_level, log_category, output_debug_message);
if (log_to_file) EQEmuLogSys::ProcessLogWrite(debug_level, log_category, output_debug_message); if (log_to_file) EQEmuLogSys::ProcessLogWrite(debug_level, log_category, output_debug_message);

View File

@ -108,7 +108,8 @@ Mob::Mob(const char* in_name,
m_TargetLocation(glm::vec3()), m_TargetLocation(glm::vec3()),
m_TargetV(glm::vec3()), m_TargetV(glm::vec3()),
flee_timer(FLEE_CHECK_TIMER), flee_timer(FLEE_CHECK_TIMER),
m_Position(position) m_Position(position),
m_pos_update_timer(3000)
{ {
targeted = 0; targeted = 0;
tar_ndx=0; tar_ndx=0;
@ -119,7 +120,8 @@ Mob::Mob(const char* in_name,
SetMoving(false); SetMoving(false);
moved=false; moved=false;
m_RewindLocation = glm::vec3(); m_RewindLocation = glm::vec3();
move_tic_count = 0; m_pos_update_heading = INVALID_POS_HEADING;
m_pos_update_speed = 0;
_egnode = nullptr; _egnode = nullptr;
name[0]=0; name[0]=0;
@ -1372,39 +1374,34 @@ void Mob::SendPosition()
EQApplicationPacket* app = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); EQApplicationPacket* app = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
PlayerPositionUpdateServer_Struct* spu = (PlayerPositionUpdateServer_Struct*)app->pBuffer; PlayerPositionUpdateServer_Struct* spu = (PlayerPositionUpdateServer_Struct*)app->pBuffer;
MakeSpawnUpdateNoDelta(spu); MakeSpawnUpdateNoDelta(spu);
move_tic_count = 0; m_pos_update_heading = INVALID_POS_HEADING;
m_pos_update_speed = 0;
entity_list.QueueClients(this, app, true); entity_list.QueueClients(this, app, true);
safe_delete(app); safe_delete(app);
} }
// this one is for mobs on the move, with deltas - this makes them walk // this one is for mobs on the move, with deltas - this makes them walk
void Mob::SendPosUpdate(uint8 iSendToSelf) { void Mob::SendPosUpdate(uint8 iSendToSelf) {
EQApplicationPacket* app = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); EQApplicationPacket app(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
PlayerPositionUpdateServer_Struct* spu = (PlayerPositionUpdateServer_Struct*)app->pBuffer; PlayerPositionUpdateServer_Struct* spu = (PlayerPositionUpdateServer_Struct*)app.pBuffer;
MakeSpawnUpdate(spu); MakeSpawnUpdate(spu);
if (iSendToSelf == 2) { if (IsClient() && iSendToSelf) {
if (IsClient()) { CastToClient()->QueuePacket(&app,false);
CastToClient()->FastQueuePacket(&app,false);
}
} }
else else
{ {
if(move_tic_count == RuleI(Zone, NPCPositonUpdateTicCount)) if (m_pos_update_heading == INVALID_POS_HEADING ||
m_pos_update_timer.Check() ||
m_pos_update_speed != pRunAnimSpeed ||
abs(m_pos_update_heading - GetHeading()) > INVALID_POS_HEADING_EPS)
{ {
entity_list.QueueClients(this, app, (iSendToSelf == 0), false); m_pos_update_speed = pRunAnimSpeed;
move_tic_count = 0; m_pos_update_heading = GetHeading();
} entity_list.QueueCloseClients(this, &app, (iSendToSelf == 0), 1000, nullptr, false);
else if(move_tic_count % 2 == 0) m_pos_update_timer.Start();
{
entity_list.QueueCloseClients(this, app, (iSendToSelf == 0), 700, nullptr, false);
move_tic_count++;
}
else {
move_tic_count++;
} }
} }
safe_delete(app);
} }
// this is for SendPosition() // this is for SendPosition()
@ -1444,7 +1441,7 @@ void Mob::MakeSpawnUpdate(PlayerPositionUpdateServer_Struct* spu) {
if(this->IsClient()) if(this->IsClient())
spu->animation = animation; spu->animation = animation;
else else
spu->animation = pRunAnimSpeed;//animation; spu->animation = pRunAnimSpeed;
spu->delta_heading = NewFloatToEQ13(m_Delta.w); spu->delta_heading = NewFloatToEQ13(m_Delta.w);
} }

View File

@ -32,6 +32,8 @@
char* strn0cpy(char* dest, const char* source, uint32 size); char* strn0cpy(char* dest, const char* source, uint32 size);
#define MAX_SPECIAL_ATTACK_PARAMS 8 #define MAX_SPECIAL_ATTACK_PARAMS 8
#define INVALID_POS_HEADING -99999.0
#define INVALID_POS_HEADING_EPS 0.01
class EGNode; class EGNode;
class Client; class Client;
@ -1286,12 +1288,13 @@ protected:
int32 GetItemFactionBonus(uint32 pFactionID); int32 GetItemFactionBonus(uint32 pFactionID);
void ClearItemFactionBonuses(); void ClearItemFactionBonuses();
void CalculateFearPosition();
uint32 move_tic_count;
bool flee_mode; bool flee_mode;
Timer flee_timer; Timer flee_timer;
Timer m_pos_update_timer;
float m_pos_update_heading;
uint8 m_pos_update_speed;
bool pAIControlled; bool pAIControlled;
bool roamer; bool roamer;
bool logging_enabled; bool logging_enabled;

View File

@ -19,18 +19,24 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa
if (to == from) if (to == from)
return to; return to;
if (DistanceSquaredNoZ(m_Position, glm::vec4(ToX, ToY, ToZ, 0.0f)) < 100.0f) {
return to;
}
if (!m_pathing_route.Active() || !m_pathing_route.DestinationValid(to)) { if (!m_pathing_route.Active() || !m_pathing_route.DestinationValid(to)) {
m_pathing_route = zone->pathing.FindRoute(from, to); m_pathing_route = zone->pathing.FindRoute(from, to);
auto &nodes = m_pathing_route.GetNodesEdit(); auto &nodes = m_pathing_route.GetNodesEdit();
auto &last_node = nodes[nodes.size() - 1]; auto &last_node = nodes[nodes.size() - 1];
if (DistanceSquared(glm::vec4(last_node.position, 1.0f), glm::vec4(ToX, ToY, ToZ, 0.0f)) > 100.0f) { auto dist = DistanceSquared(glm::vec4(last_node.position, 1.0f), glm::vec4(ToX, ToY, ToZ, 0.0f));
if (dist > 10000.0f) {
auto flag_temp = last_node.flag;
last_node.flag = NavigationPolyFlagPortal; last_node.flag = NavigationPolyFlagPortal;
PathfindingNode end;
end.position.x = ToX;
end.position.y = ToY;
end.position.z = ToZ;
end.flag = flag_temp;
nodes.push_back(end);
}
else if (dist > 100.0f) {
PathfindingNode end; PathfindingNode end;
end.position.x = ToX; end.position.x = ToX;
end.position.y = ToY; end.position.y = ToY;