From 51f0acbaf5ea6989db2fa03f62bf0aaac7902214 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Thu, 16 Jan 2020 10:32:48 +0200 Subject: [PATCH] [Client] Improve logging for Container packets --- apps/openmw/mwgui/container.cpp | 12 ------ apps/openmw/mwmp/ObjectList.cpp | 37 ++++++++++++++++++- .../processors/object/ProcessorContainer.hpp | 26 ++++++++++++- 3 files changed, 61 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 31042db54..540e2b544 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -128,10 +128,6 @@ namespace MWGui objectList->addContainerItem(baseObject, itemPtr, count); objectList->addObject(baseObject); objectList->sendContainer(); - - LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i", - baseObject.refId.c_str(), baseObject.refNum, objectList->cell.getDescription().c_str(), - itemPtr.getCellRef().getRefId().c_str(), itemPtr.getRefData().getCount()); /* End of tes3mp addition */ @@ -186,10 +182,6 @@ namespace MWGui baseObject.containerItems.push_back(containerItem); objectList->addObject(baseObject); objectList->sendContainer(); - - LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s %i-%i\n- cell: %s\n- item: %s %i, %i", - baseObject.refId.c_str(), baseObject.refNum, baseObject.mpNum, objectList->cell.getDescription().c_str(), - containerItem.refId.c_str(), containerItem.count, containerItem.charge); } /* End of tes3mp addition @@ -327,10 +319,6 @@ namespace MWGui objectList->containerSubAction = mwmp::BaseObjectList::TAKE_ALL; objectList->addEntireContainer(mPtr); objectList->sendContainer(); - - LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i-%i\n- cell: %s", - mPtr.getCellRef().getRefId().c_str(), mPtr.getCellRef().getRefNum().mIndex, mPtr.getCellRef().getMpNum(), - objectList->cell.getDescription().c_str()); /* End of tes3mp addition */ diff --git a/apps/openmw/mwmp/ObjectList.cpp b/apps/openmw/mwmp/ObjectList.cpp index 42ee82b98..8ba18ee8f 100644 --- a/apps/openmw/mwmp/ObjectList.cpp +++ b/apps/openmw/mwmp/ObjectList.cpp @@ -1365,7 +1365,42 @@ void ObjectList::sendScriptMemberShort() void ObjectList::sendContainer() { - LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Sending ID_CONTAINER"); + std::string debugMessage = "Sending ID_CONTAINER with action "; + + if (action == mwmp::BaseObjectList::SET) + debugMessage += "SET"; + else if (action == mwmp::BaseObjectList::ADD) + debugMessage += "ADD"; + else if (action == mwmp::BaseObjectList::REMOVE) + debugMessage += "REMOVE"; + + debugMessage += " and subaction "; + + if (containerSubAction == mwmp::BaseObjectList::NONE) + debugMessage += "NONE"; + else if (containerSubAction == mwmp::BaseObjectList::DRAG) + debugMessage += "DRAG"; + else if (containerSubAction == mwmp::BaseObjectList::DROP) + debugMessage += "DROP"; + else if (containerSubAction == mwmp::BaseObjectList::TAKE_ALL) + debugMessage += "TAKE_ALL"; + else if (containerSubAction == mwmp::BaseObjectList::REPLY_TO_REQUEST) + debugMessage += "REPLY_TO_REQUEST"; + + debugMessage += "\n- cell " + cell.getDescription(); + + for (const auto &baseObject : baseObjects) + { + debugMessage += "\n- container " + baseObject.refId + " " + std::to_string(baseObject.refNum) + "-" + std::to_string(baseObject.mpNum); + + for (const auto &containerItem : baseObject.containerItems) + { + debugMessage += "\n-- item " + containerItem.refId + ", count " + std::to_string(containerItem.count) + + ", actionCount " + std::to_string(containerItem.actionCount); + } + } + + LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "%s", debugMessage.c_str()); mwmp::Main::get().getNetworking()->getObjectPacket(ID_CONTAINER)->setObjectList(this); mwmp::Main::get().getNetworking()->getObjectPacket(ID_CONTAINER)->Send(); diff --git a/apps/openmw/mwmp/processors/object/ProcessorContainer.hpp b/apps/openmw/mwmp/processors/object/ProcessorContainer.hpp index 8ebb6d577..62c8daec3 100644 --- a/apps/openmw/mwmp/processors/object/ProcessorContainer.hpp +++ b/apps/openmw/mwmp/processors/object/ProcessorContainer.hpp @@ -17,7 +17,31 @@ namespace mwmp { BaseObjectProcessor::Do(packet, objectList); - LOG_APPEND(TimedLog::LOG_VERBOSE, "- action: %i, containerSubAction: %i", objectList.action, objectList.containerSubAction); + std::string debugMessage = "- action "; + unsigned char action = objectList.action; + unsigned char containerSubAction = objectList.containerSubAction; + + if (action == mwmp::BaseObjectList::SET) + debugMessage += "SET"; + else if (action == mwmp::BaseObjectList::ADD) + debugMessage += "ADD"; + else if (action == mwmp::BaseObjectList::REMOVE) + debugMessage += "REMOVE"; + + debugMessage += " and subaction "; + + if (containerSubAction == mwmp::BaseObjectList::NONE) + debugMessage += "NONE"; + else if (containerSubAction == mwmp::BaseObjectList::DRAG) + debugMessage += "DRAG"; + else if (containerSubAction == mwmp::BaseObjectList::DROP) + debugMessage += "DROP"; + else if (containerSubAction == mwmp::BaseObjectList::TAKE_ALL) + debugMessage += "TAKE_ALL"; + else if (containerSubAction == mwmp::BaseObjectList::REPLY_TO_REQUEST) + debugMessage += "REPLY_TO_REQUEST"; + + LOG_APPEND(TimedLog::LOG_VERBOSE, "%s", debugMessage.c_str()); // If we've received a request for information, comply with it if (objectList.action == mwmp::BaseObjectList::REQUEST)