|
|
@ -8,6 +8,7 @@
|
|
|
|
#include "Cell.hpp"
|
|
|
|
#include "Cell.hpp"
|
|
|
|
#include "Main.hpp"
|
|
|
|
#include "Main.hpp"
|
|
|
|
#include "Networking.hpp"
|
|
|
|
#include "Networking.hpp"
|
|
|
|
|
|
|
|
#include "LocalPlayer.hpp"
|
|
|
|
#include "CellController.hpp"
|
|
|
|
#include "CellController.hpp"
|
|
|
|
#include "MechanicsHelper.hpp"
|
|
|
|
#include "MechanicsHelper.hpp"
|
|
|
|
|
|
|
|
|
|
|
@ -16,6 +17,7 @@ using namespace mwmp;
|
|
|
|
mwmp::Cell::Cell(MWWorld::CellStore* cellStore)
|
|
|
|
mwmp::Cell::Cell(MWWorld::CellStore* cellStore)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
store = cellStore;
|
|
|
|
store = cellStore;
|
|
|
|
|
|
|
|
shouldInitializeActors = false;
|
|
|
|
|
|
|
|
|
|
|
|
std::map<std::string, LocalActor *> localActors;
|
|
|
|
std::map<std::string, LocalActor *> localActors;
|
|
|
|
std::map<std::string, DedicatedActor *> dedicatedActors;
|
|
|
|
std::map<std::string, DedicatedActor *> dedicatedActors;
|
|
|
@ -44,10 +46,7 @@ void Cell::updateLocal(bool forceUpdate)
|
|
|
|
|
|
|
|
|
|
|
|
Main::get().getCellController()->removeLocalActorRecord(it->first);
|
|
|
|
Main::get().getCellController()->removeLocalActorRecord(it->first);
|
|
|
|
|
|
|
|
|
|
|
|
// If the cell this actor has moved to is active, initialize them in it
|
|
|
|
delete actor;
|
|
|
|
if (Main::get().getCellController()->isInitializedCell(*newStore->getCell()))
|
|
|
|
|
|
|
|
Main::get().getCellController()->getCell(*newStore->getCell())->initializeLocalActor(actor->getPtr());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
localActors.erase(it++);
|
|
|
|
localActors.erase(it++);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -242,7 +241,7 @@ void Cell::readCellChange(ActorList& actorList)
|
|
|
|
actor->setCell(newStore);
|
|
|
|
actor->setCell(newStore);
|
|
|
|
|
|
|
|
|
|
|
|
Main::get().getCellController()->removeDedicatedActorRecord(mapIndex);
|
|
|
|
Main::get().getCellController()->removeDedicatedActorRecord(mapIndex);
|
|
|
|
|
|
|
|
|
|
|
|
// If the cell this actor has moved to is active, initialize them in it
|
|
|
|
// If the cell this actor has moved to is active, initialize them in it
|
|
|
|
if (Main::get().getCellController()->isInitializedCell(actor->cell))
|
|
|
|
if (Main::get().getCellController()->isInitializedCell(actor->cell))
|
|
|
|
Main::get().getCellController()->getCell(actor->cell)->initializeDedicatedActor(actor->getPtr());
|
|
|
|
Main::get().getCellController()->getCell(actor->cell)->initializeDedicatedActor(actor->getPtr());
|
|
|
@ -280,7 +279,11 @@ void Cell::initializeLocalActors()
|
|
|
|
// If this Ptr is lacking a unique index, ignore it
|
|
|
|
// If this Ptr is lacking a unique index, ignore it
|
|
|
|
if (ptr.getCellRef().getRefNum().mIndex == 0 && ptr.getCellRef().getMpNum() == 0) continue;
|
|
|
|
if (ptr.getCellRef().getRefNum().mIndex == 0 && ptr.getCellRef().getMpNum() == 0) continue;
|
|
|
|
|
|
|
|
|
|
|
|
initializeLocalActor(ptr);
|
|
|
|
std::string mapIndex = Main::get().getCellController()->generateMapIndex(ptr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Only initialize this actor if it isn't already initialized
|
|
|
|
|
|
|
|
if (localActors.count(mapIndex) == 0)
|
|
|
|
|
|
|
|
initializeLocalActor(ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -352,6 +355,16 @@ DedicatedActor *Cell::getDedicatedActor(std::string actorIndex)
|
|
|
|
return dedicatedActors.at(actorIndex);
|
|
|
|
return dedicatedActors.at(actorIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Cell::hasLocalAuthority()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return authorityGuid == Main::get().getLocalPlayer()->guid;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Cell::setAuthority(const RakNet::RakNetGUID& guid)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
authorityGuid = guid;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MWWorld::CellStore *Cell::getCellStore()
|
|
|
|
MWWorld::CellStore *Cell::getCellStore()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return store;
|
|
|
|
return store;
|
|
|
|