1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 22:53:50 +00:00

[Client] Improve logging for Container packets

This commit is contained in:
David Cernat 2020-01-16 10:32:48 +02:00
parent b0b51dc4d5
commit 51f0acbaf5
3 changed files with 61 additions and 14 deletions

View file

@ -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
*/

View file

@ -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();

View file

@ -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)