Fix Windows server crash caused by printing event->CellRef()->mRefID

coverity_scan^2
David Cernat 8 years ago
parent 8080cceac6
commit 92463c4a03

@ -370,6 +370,7 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet)
WorldPacket *myPacket = worldController->GetPacket(packet->data[0]);
WorldEvent *event = new WorldEvent(player->guid);
event->cellRef.blank();
switch (packet->data[0])
{
@ -392,9 +393,8 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet)
myPacket->Read(event);
LOG_APPEND(Log::LOG_WARN, "- %s", event->CellRef()->mRefID.c_str());
LOG_APPEND(Log::LOG_WARN, "- %i", event->CellRef()->mRefNum);
LOG_APPEND(Log::LOG_WARN, "- %s", event->cellRef.mRefID.c_str());
LOG_APPEND(Log::LOG_WARN, "- %i", event->cellRef.mRefNum);
myPacket->Send(event, true);

@ -639,9 +639,9 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet)
{
case ID_WORLD_OBJECT_CREATION:
{
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), event->CellRef()->mRefID, 1);
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), event->cellRef.mRefID, 1);
MWBase::Environment::get().getWorld()->placeObject(ref.getPtr(), ptrCellStore, event->CellRef()->mPos);
MWBase::Environment::get().getWorld()->placeObject(ref.getPtr(), ptrCellStore, event->cellRef.mPos);
break;
}
@ -651,10 +651,10 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet)
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", "Received ID_WORLD_OBJECT_REMOVAL");
LOG_APPEND(Log::LOG_WARN, "- cellRefId: %s, %i",
event->CellRef()->mRefID.c_str(),
event->CellRef()->mRefNum);
event->cellRef.mRefID.c_str(),
event->cellRef.mRefNum);
//MWWorld::Ptr object = ptrCellStore->search(event->CellRef()->mRefID);
//MWWorld::Ptr object = ptrCellStore->search(event->cellRef.mRefID);
//MWBase::Environment::get().getWorld()->deleteObject(object);

@ -1108,15 +1108,16 @@ namespace MWWorld
{
// Added by tes3mp
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->cellRef.blank();
event->CellRef()->mRefID = ptr.getCellRef().getRefId();
event->CellRef()->mRefNum = ptr.getCellRef().getRefNum();
event->cellRef.mRefID = ptr.getCellRef().getRefId();
event->cellRef.mRefNum = ptr.getCellRef().getRefNum();
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_WORLD_OBJECT_REMOVAL)->Send(event);
printf("Sending ID_WORLD_OBJECT_REMOVAL about\n%s\n%s\n%i\n",
ptr.getCellRef().getRefId().c_str(),
event->CellRef()->mRefID.c_str(),
event->CellRef()->mRefNum);
event->cellRef.mRefID.c_str(),
event->cellRef.mRefNum);
mWorldScene->removeObjectFromScene (ptr);
mLocalScripts.remove (ptr);

@ -20,17 +20,8 @@ namespace mwmp
}
virtual ESM::CellRef *CellRef()
{
return &ref;
}
RakNet::RakNetGUID guid;
protected:
ESM::CellRef ref;
ESM::CellRef cellRef;
};
}

@ -12,5 +12,6 @@ void PacketObjectCreation::Packet(RakNet::BitStream *bs, WorldEvent *event, bool
{
WorldPacket::Packet(bs, event, send);
RW(*event->CellRef(), send);
RW(event->cellRef.mRefID, send);
RW(event->cellRef.mRefNum, send);
}

@ -12,5 +12,6 @@ void PacketObjectRemoval::Packet(RakNet::BitStream *bs, WorldEvent *event, bool
{
WorldPacket::Packet(bs, event, send);
RW(*event->CellRef(), send);
RW(event->cellRef.mRefID, send);
RW(event->cellRef.mRefNum, send);
}

Loading…
Cancel
Save