From 802af495dc587d0c10baf962c766ca3eb67ef4b5 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Fri, 9 Dec 2016 21:02:00 +0000 Subject: [PATCH] silence output by default in release mode for things we can't do much about on a live server... TODO: @cekis can we find a nice way of silencing or outputting java stack dumps into a file instead of the console? --- .../src/shared/ai/AiMovementPatrol.cpp | 2 +- .../controller/AiCreatureController.cpp | 32 +++++++------- .../src/shared/core/ContainerInterface.cpp | 2 +- .../src/shared/object/ObjectFactory.cpp | 10 +++-- .../src/shared/object/ServerObject.cpp | 6 +-- .../src/shared/object/ShipObject.cpp | 4 +- .../src/shared/ConfigServerScript.cpp | 1 + .../src/shared/ConfigServerScript.h | 42 ++++++++++++------- .../serverScript/src/shared/JavaLibrary.cpp | 3 +- .../src/shared/core/FloorManager.cpp | 2 +- .../container/ArrangementDescriptor.cpp | 2 +- .../src/shared/portal/CellProperty.cpp | 4 +- 12 files changed, 64 insertions(+), 46 deletions(-) diff --git a/engine/server/library/serverGame/src/shared/ai/AiMovementPatrol.cpp b/engine/server/library/serverGame/src/shared/ai/AiMovementPatrol.cpp index c4c73b88..45fc3bee 100755 --- a/engine/server/library/serverGame/src/shared/ai/AiMovementPatrol.cpp +++ b/engine/server/library/serverGame/src/shared/ai/AiMovementPatrol.cpp @@ -105,7 +105,7 @@ AiMovementPatrol::AiMovementPatrol( AICreatureController * controller, std::vect else { m_patrolPath.clear(); - WARNING(true, ("AiMovementPatrol unable to find path node %s for object %s", + DEBUG_WARNING(true, ("AiMovementPatrol unable to find path node %s for object %s", Unicode::wideToNarrow(pointName).c_str(), owner->getNetworkId().getValueString().c_str())); break; diff --git a/engine/server/library/serverGame/src/shared/controller/AiCreatureController.cpp b/engine/server/library/serverGame/src/shared/controller/AiCreatureController.cpp index 0cc4bb39..9df8520f 100755 --- a/engine/server/library/serverGame/src/shared/controller/AiCreatureController.cpp +++ b/engine/server/library/serverGame/src/shared/controller/AiCreatureController.cpp @@ -842,7 +842,7 @@ bool AICreatureController::wander( float minDistance, float maxDistance, float m { if (isRetreating()) { - WARNING(true, ("AICreatureController::wander() owner(%s) minDistance(%.2f) maxDistance(%.2f) minAngle(%.2f) maxAngle(%.2f) minDelay(%.2f) maxDelay(%.2f) Trying to wander while retreating, failing request.", getDebugInformation().c_str(), minDistance, maxDistance, minAngle, maxAngle, minDelay, maxDelay)); + DEBUG_WARNING(true, ("AICreatureController::wander() owner(%s) minDistance(%.2f) maxDistance(%.2f) minAngle(%.2f) maxAngle(%.2f) minDelay(%.2f) maxDelay(%.2f) Trying to wander while retreating, failing request.", getDebugInformation().c_str(), minDistance, maxDistance, minAngle, maxAngle, minDelay, maxDelay)); return false; } @@ -876,7 +876,7 @@ void AICreatureController::loiter(CellProperty const * homeCell, Vector const & { if (isRetreating()) { - WARNING(true, ("AICreatureController::loiter() owner(%s) cell(%s) home(%.0f, %.0f, %.0f) distance[%.2f...%.2f] delay[%.0f...%.0f] Trying to loiter while retreating, failing request.", getDebugInformation().c_str(), ((homeCell != nullptr) ? homeCell->getCellName() : "nullptr"), home_p.x, home_p.y, home_p.z, minDistance, maxDistance, minDelay, maxDelay)); + DEBUG_WARNING(true, ("AICreatureController::loiter() owner(%s) cell(%s) home(%.0f, %.0f, %.0f) distance[%.2f...%.2f] delay[%.0f...%.0f] Trying to loiter while retreating, failing request.", getDebugInformation().c_str(), ((homeCell != nullptr) ? homeCell->getCellName() : "nullptr"), home_p.x, home_p.y, home_p.z, minDistance, maxDistance, minDelay, maxDelay)); return; } @@ -892,7 +892,7 @@ void AICreatureController::loiter(NetworkId const & homeId, float const minDista { if (isRetreating()) { - WARNING(true, ("AICreatureController::loiter() owner(%s) home(%s) distance[%.2f...%.2f] delay[%.0f...%.0f] Trying to loiter while retreating, failing request.", getDebugInformation().c_str(), homeId.getValueString().c_str(), minDistance, maxDistance, minDelay, maxDelay)); + DEBUG_WARNING(true, ("AICreatureController::loiter() owner(%s) home(%s) distance[%.2f...%.2f] delay[%.0f...%.0f] Trying to loiter while retreating, failing request.", getDebugInformation().c_str(), homeId.getValueString().c_str(), minDistance, maxDistance, minDelay, maxDelay)); return; } @@ -910,7 +910,7 @@ void AICreatureController::moveTo(CellProperty const * cell, Vector const & targ { if (isRetreating()) { - WARNING(true, ("AICreatureController::moveTo() owner(%s) cell(%s) position(%.0f, %.0f, %.0f) radius(%.2f) Trying to moveTo while retreating, failing request.", getDebugInformation().c_str(), ((cell != nullptr) ? cell->getCellName() : "nullptr"), target_p.x, target_p.y, target_p.z, radius)); + DEBUG_WARNING(true, ("AICreatureController::moveTo() owner(%s) cell(%s) position(%.0f, %.0f, %.0f) radius(%.2f) Trying to moveTo while retreating, failing request.", getDebugInformation().c_str(), ((cell != nullptr) ? cell->getCellName() : "nullptr"), target_p.x, target_p.y, target_p.z, radius)); return; } @@ -949,7 +949,7 @@ void AICreatureController::moveTo(Unicode::String const & targetName) { if (isRetreating()) { - WARNING(true, ("AICreatureController::moveTo() owner(%s) target(%s) Trying to moveTo while retreating, failing request.", getDebugInformation().c_str(), Unicode::wideToNarrow(targetName).c_str())); + DEBUG_WARNING(true, ("AICreatureController::moveTo() owner(%s) target(%s) Trying to moveTo while retreating, failing request.", getDebugInformation().c_str(), Unicode::wideToNarrow(targetName).c_str())); return; } @@ -984,7 +984,7 @@ void AICreatureController::patrol( std::vector const & locations, bool { if (isRetreating()) { - WARNING(true, ("AICreatureController::patrol() owner(%s) Trying to patrol while retreating, failing request.", getDebugInformation().c_str())); + DEBUG_WARNING(true, ("AICreatureController::patrol() owner(%s) Trying to patrol while retreating, failing request.", getDebugInformation().c_str())); return; } @@ -1018,7 +1018,7 @@ void AICreatureController::patrol( std::vector const & location { if (isRetreating()) { - WARNING(true, ("AICreatureController::patrol() owner(%s) Trying to patrol while retreating, failing request.", getDebugInformation().c_str())); + DEBUG_WARNING(true, ("AICreatureController::patrol() owner(%s) Trying to patrol while retreating, failing request.", getDebugInformation().c_str())); return; } @@ -1052,7 +1052,7 @@ void AICreatureController::stop() { if (isRetreating()) { - WARNING(true, ("AICreatureController::stop() owner(%s) Trying to stop while retreating, failing request.", getDebugInformation().c_str())); + DEBUG_WARNING(true, ("AICreatureController::stop() owner(%s) Trying to stop while retreating, failing request.", getDebugInformation().c_str())); return; } @@ -1071,7 +1071,7 @@ bool AICreatureController::faceTo(CellProperty const * targetCell, Vector const { if (isRetreating()) { - WARNING(true, ("AICreatureController::faceTo() owner(%s) cell(%s) position(%.0f, %.0f, %.0f) Trying to faceTo while retreating, failing faceTo request.", getDebugInformation().c_str(), ((targetCell != nullptr) ? targetCell->getCellName() : "nullptr"), target_p.x, target_p.y, target_p.z)); + DEBUG_WARNING(true, ("AICreatureController::faceTo() owner(%s) cell(%s) position(%.0f, %.0f, %.0f) Trying to faceTo while retreating, failing faceTo request.", getDebugInformation().c_str(), ((targetCell != nullptr) ? targetCell->getCellName() : "nullptr"), target_p.x, target_p.y, target_p.z)); return false; } @@ -1110,7 +1110,7 @@ bool AICreatureController::faceTo( NetworkId const & targetId ) { if (isRetreating()) { - WARNING(true, ("AICreatureController::faceTo() owner(%s) Trying to faceTo the target(%s) while retreating, failing request.", getDebugInformation().c_str(), targetId.getValueString().c_str())); + DEBUG_WARNING(true, ("AICreatureController::faceTo() owner(%s) Trying to faceTo the target(%s) while retreating, failing request.", getDebugInformation().c_str(), targetId.getValueString().c_str())); return false; } @@ -1155,7 +1155,7 @@ bool AICreatureController::follow( NetworkId const & targetId, float minDistance { if (isRetreating()) { - WARNING(true, ("AICreatureController::follow() owner(%s) distance[%.2f...%.2f] Trying to follow the target(%s) while retreating, failing request.", getDebugInformation().c_str(), minDistance, maxDistance, targetId.getValueString().c_str())); + DEBUG_WARNING(true, ("AICreatureController::follow() owner(%s) distance[%.2f...%.2f] Trying to follow the target(%s) while retreating, failing request.", getDebugInformation().c_str(), minDistance, maxDistance, targetId.getValueString().c_str())); return false; } @@ -1203,7 +1203,7 @@ bool AICreatureController::follow( NetworkId const & targetId, Vector const & of { if (isRetreating()) { - WARNING(true, ("AICreatureController::follow() owner(%s) offset(%.0f, %.0f, %.0f) Trying to follow the target(%s) while retreating, failing request.", getDebugInformation().c_str(), offset.x, offset.y, offset.z, targetId.getValueString().c_str())); + DEBUG_WARNING(true, ("AICreatureController::follow() owner(%s) offset(%.0f, %.0f, %.0f) Trying to follow the target(%s) while retreating, failing request.", getDebugInformation().c_str(), offset.x, offset.y, offset.z, targetId.getValueString().c_str())); return false; } @@ -1254,7 +1254,7 @@ bool AICreatureController::swarm( NetworkId const & targetId ) { if (isRetreating()) { - WARNING(true, ("AICreatureController::swarm() owner(%s) Trying to flee the target(%s) while retreating, failing request.", getDebugInformation().c_str(), targetId.getValueString().c_str())); + DEBUG_WARNING(true, ("AICreatureController::swarm() owner(%s) Trying to flee the target(%s) while retreating, failing request.", getDebugInformation().c_str(), targetId.getValueString().c_str())); return false; } @@ -1290,7 +1290,7 @@ bool AICreatureController::swarm( NetworkId const & targetId, float offset ) { if (isRetreating()) { - WARNING(true, ("AICreatureController::swarm() owner(%s) offset(%.2f) Trying to flee the target(%s) while retreating, failing request.", getDebugInformation().c_str(), offset, targetId.getValueString().c_str())); + DEBUG_WARNING(true, ("AICreatureController::swarm() owner(%s) offset(%.2f) Trying to flee the target(%s) while retreating, failing request.", getDebugInformation().c_str(), offset, targetId.getValueString().c_str())); return false; } @@ -1314,7 +1314,7 @@ bool AICreatureController::flee( NetworkId const & targetId, float minDistance, { if (isRetreating()) { - WARNING(true, ("AICreatureController::flee() owner(%s) distance[%.2f...%.2f] Trying to flee the target(%s) while retreating, failing request.", getDebugInformation().c_str(), minDistance, maxDistance, targetId.getValueString().c_str(), targetId.getValueString().c_str())); + DEBUG_WARNING(true, ("AICreatureController::flee() owner(%s) distance[%.2f...%.2f] Trying to flee the target(%s) while retreating, failing request.", getDebugInformation().c_str(), minDistance, maxDistance, targetId.getValueString().c_str(), targetId.getValueString().c_str())); return false; } @@ -2411,7 +2411,7 @@ NetworkId AICreatureController::createWeapon(char const * const functionName, Cr { if (required) { - WARNING(required, ("debug_ai: AICreatureController::%s() A required weapon is specified as ""none"" for (%s), defaulting to ""unarmed""", functionName, getDebugInformation().c_str())); + DEBUG_WARNING(required, ("debug_ai: AICreatureController::%s() A required weapon is specified as ""none"" for (%s), defaulting to ""unarmed""", functionName, getDebugInformation().c_str())); result = getUnarmedWeapon(); } else diff --git a/engine/server/library/serverGame/src/shared/core/ContainerInterface.cpp b/engine/server/library/serverGame/src/shared/core/ContainerInterface.cpp index fdd5c6f2..f26b9097 100755 --- a/engine/server/library/serverGame/src/shared/core/ContainerInterface.cpp +++ b/engine/server/library/serverGame/src/shared/core/ContainerInterface.cpp @@ -707,7 +707,7 @@ bool ContainerInterface::transferItemToSlottedContainer(ServerObject &destinatio if (arrangementIndex < 0) { - WARNING_STRICT_FATAL(true, ("Invaid arrangement index in transferItemToSlottedContainer")); + DEBUG_WARNING(true, ("Invaid arrangement index in transferItemToSlottedContainer")); error = Container::CEC_InvalidArrangement; return false; } diff --git a/engine/server/library/serverGame/src/shared/object/ObjectFactory.cpp b/engine/server/library/serverGame/src/shared/object/ObjectFactory.cpp index e23c7d1d..bbe52fe2 100755 --- a/engine/server/library/serverGame/src/shared/object/ObjectFactory.cpp +++ b/engine/server/library/serverGame/src/shared/object/ObjectFactory.cpp @@ -50,9 +50,13 @@ ServerObject * ServerWorld::createObjectFromTemplate(uint32 templateCrc, const N objectTemplate = ObjectTemplateList::fetch(templateCrc); } - WARNING(!objectTemplate, ("Missing Template! Can't create object from " - "template crc %lu(%s), file not found", templateCrc, - ObjectTemplateList::lookUp(templateCrc).getString())); + if (!objectTemplate) { + DEBUG_WARNING(!objectTemplate, ("Missing Template! Can't create object from " + "template crc %lu(%s), file not found", templateCrc, + ObjectTemplateList::lookUp(templateCrc).getString())); + return 0; + } + Object *object = nullptr; if (objectTemplate) diff --git a/engine/server/library/serverGame/src/shared/object/ServerObject.cpp b/engine/server/library/serverGame/src/shared/object/ServerObject.cpp index 55d68b6f..ac399d32 100755 --- a/engine/server/library/serverGame/src/shared/object/ServerObject.cpp +++ b/engine/server/library/serverGame/src/shared/object/ServerObject.cpp @@ -599,8 +599,8 @@ void ServerObject::MoveNotification::checkForGoldObject(const Object &object) co { if (ConfigServerGame::getMaxGoldNetworkId()!=NetworkId::cms_invalid && object.getNetworkId() < ConfigServerGame::getMaxGoldNetworkId()) { - FATAL(ConfigServerGame::getFatalOnMovingGoldObject(),("Attempted to move object %s, which is a gold object that should not be movable.", object.getNetworkId().getValueString().c_str())); - WARNING(true,("Attempted to move object %s, which is a gold object that should not be movable.", object.getNetworkId().getValueString().c_str())); + DEBUG_FATAL(ConfigServerGame::getFatalOnMovingGoldObject(),("Attempted to move object %s, which is a gold object that should not be movable.", object.getNetworkId().getValueString().c_str())); + DEBUG_WARNING(true,("Attempted to move object %s, which is a gold object that should not be movable.", object.getNetworkId().getValueString().c_str())); } } @@ -2528,7 +2528,7 @@ bool ServerObject::serverObjectInitializeFirstTimeObject(ServerObject *cell, Tra Container::ContainerErrorCode tmp = Container::CEC_Success; if (!ContainerInterface::transferItemToCell(*cell, *this, transform, nullptr, tmp)) { - WARNING(true, ("ServerWorld::createNewObjectIntermediate tried to create a new object in a cell, but it failed.")); + DEBUG_WARNING(true, ("ServerWorld::createNewObjectIntermediate tried to create a new object in a cell, but it failed.")); return false; } } diff --git a/engine/server/library/serverGame/src/shared/object/ShipObject.cpp b/engine/server/library/serverGame/src/shared/object/ShipObject.cpp index 2408018b..731fa4f3 100755 --- a/engine/server/library/serverGame/src/shared/object/ShipObject.cpp +++ b/engine/server/library/serverGame/src/shared/object/ShipObject.cpp @@ -1444,7 +1444,7 @@ void ShipObject::constructFromTemplate() ShipChassis const * shipChassis = ShipChassis::findShipChassisByName (TemporaryCrcString (shipType.c_str (), true)); if (shipChassis == nullptr) { - WARNING (true, ("ShipObject::constructFromTemplate failed to find a valid ship chassis for [%s], trying generic", shipType.c_str ())); + DEBUG_WARNING (true, ("ShipObject::constructFromTemplate failed to find a valid ship chassis for [%s], trying generic", shipType.c_str ())); shipChassis = ShipChassis::findShipChassisByName (TemporaryCrcString ("generic", true)); } @@ -1452,7 +1452,7 @@ void ShipObject::constructFromTemplate() m_chassisType = shipChassis->getCrc (); else { - WARNING (true, ("ShipObject::constructFromTemplate failed to find a valid ship chassis for [%s] or generic", shipType.c_str ())); + DEBUG_WARNING (true, ("ShipObject::constructFromTemplate failed to find a valid ship chassis for [%s] or generic", shipType.c_str ())); } //set initial slot targetability from the chassis setttings. Code or script can change these at runtime diff --git a/engine/server/library/serverScript/src/shared/ConfigServerScript.cpp b/engine/server/library/serverScript/src/shared/ConfigServerScript.cpp index 434a64d9..b38fc873 100755 --- a/engine/server/library/serverScript/src/shared/ConfigServerScript.cpp +++ b/engine/server/library/serverScript/src/shared/ConfigServerScript.cpp @@ -73,6 +73,7 @@ void ConfigServerScript::install(void) KEY_BOOL (allowDebugSpeakMessages, true); KEY_BOOL (disableScriptLogs, false); KEY_BOOL (logBalance, false); + KEY_BOOL (printStacks, false); int index = 0; char const * result = 0; diff --git a/engine/server/library/serverScript/src/shared/ConfigServerScript.h b/engine/server/library/serverScript/src/shared/ConfigServerScript.h index b9e98114..f81a0f45 100755 --- a/engine/server/library/serverScript/src/shared/ConfigServerScript.h +++ b/engine/server/library/serverScript/src/shared/ConfigServerScript.h @@ -17,16 +17,17 @@ class ConfigServerScript struct Data { - // script data + // script data const char * scriptPath; // location of scripts const char * javaLibPath; // location of jvm files const char * javaDebugPort; // ip port we connect to for remote debugging - bool useRemoteDebugJava; // flag to use the jvm for remote debugging - bool allowBuildClusterScriptAttach; //used only on the build cluster for attaching scripts without a VM. - bool allowDebugConsoleMessages; //used only on the build cluster for attaching scripts without a VM. - bool allowDebugSpeakMessages; //used to enable/disable the debugSpeakMessage script function - bool disableScriptLogs; - bool logBalance; + bool useRemoteDebugJava; // flag to use the jvm for remote debugging + bool allowBuildClusterScriptAttach; //used only on the build cluster for attaching scripts without a VM. + bool allowDebugConsoleMessages; //used only on the build cluster for attaching scripts without a VM. + bool allowDebugSpeakMessages; //used to enable/disable the debugSpeakMessage script function + bool disableScriptLogs; + bool logBalance; + bool printStacks; }; private: @@ -42,15 +43,17 @@ class ConfigServerScript static const char * getJavaLibPath (void); static const char * getJavaDebugPort (void); static bool getUseRemoteDebugJava (void); - static bool getAllowBuildClusterScriptAttach(); - static bool allowDebugConsoleMessages(); - static bool allowDebugSpeakMessages(); - static bool getDisableScriptLogs(); - static bool getLogBalance(); + static bool getAllowBuildClusterScriptAttach(); + static bool allowDebugConsoleMessages(); + static bool allowDebugSpeakMessages(); + static bool getDisableScriptLogs(); + static bool getLogBalance(); - static bool hasJavaOptions(); - static int getNumberOfJavaOptions(); - static char const * getJavaOptions(int index); + static bool getPrintStacks(); + + static bool hasJavaOptions(); + static int getNumberOfJavaOptions(); + static char const * getJavaOptions(int index); }; inline const char *ConfigServerScript::getScriptPath(void) @@ -112,6 +115,15 @@ inline bool ConfigServerScript::getLogBalance() return data->logBalance; } +inline bool ConfigServerScript::getPrintStacks() +{ +#ifdef _DEBUG + return true; +#else + return data->printStacks; +#endif +} + //----------------------------------------------------------------------- diff --git a/engine/server/library/serverScript/src/shared/JavaLibrary.cpp b/engine/server/library/serverScript/src/shared/JavaLibrary.cpp index 68a652d1..b2b3b8ab 100755 --- a/engine/server/library/serverScript/src/shared/JavaLibrary.cpp +++ b/engine/server/library/serverScript/src/shared/JavaLibrary.cpp @@ -2183,7 +2183,8 @@ jlong JavaLibrary::getFreeJavaMemory() */ void JavaLibrary::printJavaStack() { - ms_env->CallStaticVoidMethod(ms_clsThread, ms_midThreadDumpStack); + if (ConfigServerScript::getPrintStacks()) + ms_env->CallStaticVoidMethod(ms_clsThread, ms_midThreadDumpStack); } /** diff --git a/engine/shared/library/sharedCollision/src/shared/core/FloorManager.cpp b/engine/shared/library/sharedCollision/src/shared/core/FloorManager.cpp index 1ea799b9..53d53db3 100755 --- a/engine/shared/library/sharedCollision/src/shared/core/FloorManager.cpp +++ b/engine/shared/library/sharedCollision/src/shared/core/FloorManager.cpp @@ -71,7 +71,7 @@ Floor * FloorManager::createFloor ( const char * floorMeshFilename, Object const if(!pMesh) { - WARNING(true, ("Could not find floor mesh %s", floorMeshFilename)); + DEBUG_WARNING(true, ("Could not find floor mesh %s", floorMeshFilename)); return nullptr; } diff --git a/engine/shared/library/sharedObject/src/shared/container/ArrangementDescriptor.cpp b/engine/shared/library/sharedObject/src/shared/container/ArrangementDescriptor.cpp index 9ac129fb..3f01a2ef 100755 --- a/engine/shared/library/sharedObject/src/shared/container/ArrangementDescriptor.cpp +++ b/engine/shared/library/sharedObject/src/shared/container/ArrangementDescriptor.cpp @@ -134,7 +134,7 @@ void ArrangementDescriptor::load_0000(Iff &iff) // convert slot name to SlotId const SlotId slotId = SlotIdManager::findSlotId(slotName); if (slotId == SlotId::invalid) - WARNING(true, ("ArrangementDescriptor [%s] specified invalid slot name [%s], ignoring", m_name->getString(), slotName.getString())); + DEBUG_WARNING(true, ("ArrangementDescriptor [%s] specified invalid slot name [%s], ignoring", m_name->getString(), slotName.getString())); else arrangement.push_back(slotId); } diff --git a/engine/shared/library/sharedObject/src/shared/portal/CellProperty.cpp b/engine/shared/library/sharedObject/src/shared/portal/CellProperty.cpp index 21d861bd..f00ca9b3 100755 --- a/engine/shared/library/sharedObject/src/shared/portal/CellProperty.cpp +++ b/engine/shared/library/sharedObject/src/shared/portal/CellProperty.cpp @@ -449,11 +449,11 @@ void CellProperty::initialize(const PortalProperty &portalProperty, int cellInde if (cellTemplate.getFloorName()) { m_floor = FloorManager::createFloor(cellTemplate.getFloorName(),&getOwner(),nullptr,false); - WARNING(!m_floor, ("Cell %s could not load floor %s", cellTemplate.getAppearanceName(), cellTemplate.getFloorName())); + DEBUG_WARNING(!m_floor, ("Cell %s could not load floor %s", cellTemplate.getAppearanceName(), cellTemplate.getFloorName())); } else { - WARNING(true, ("Cell %s has no floor", cellTemplate.getAppearanceName())); + DEBUG_WARNING(true, ("Cell %s has no floor", cellTemplate.getAppearanceName())); } m_cellIndex = cellIndex;