mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
[General] Use BaseActorLists in ActorPackets
This commit is contained in:
parent
1b714fbfa7
commit
c52084a028
31 changed files with 346 additions and 265 deletions
|
@ -5,7 +5,7 @@ using namespace mwmp;
|
|||
|
||||
ActorProcessor::processors_t ActorProcessor::processors;
|
||||
|
||||
void ActorProcessor::Do(ActorPacket &packet, Player &player, BaseEvent &event)
|
||||
void ActorProcessor::Do(ActorPacket &packet, Player &player, BaseActorList &actorList)
|
||||
{
|
||||
packet.Send(true);
|
||||
}
|
||||
|
@ -21,12 +21,12 @@ void ActorProcessor::AddProcessor(mwmp::ActorProcessor *processor) noexcept
|
|||
processors.insert(processors_t::value_type(processor->GetPacketID(), processor));
|
||||
}
|
||||
|
||||
bool ActorProcessor::Process(RakNet::Packet &packet, BaseEvent &event) noexcept
|
||||
bool ActorProcessor::Process(RakNet::Packet &packet, BaseActorList &actorList) noexcept
|
||||
{
|
||||
// Clear our BaseEvent before loading new data in it
|
||||
event.cell.blank();
|
||||
event.objectChanges.objects.clear();
|
||||
event.guid = packet.guid;
|
||||
// Clear our BaseActorList before loading new data in it
|
||||
actorList.cell.blank();
|
||||
actorList.baseActors.clear();
|
||||
actorList.guid = packet.guid;
|
||||
for (auto &processor : processors)
|
||||
{
|
||||
if (processor.first == packet.data[0])
|
||||
|
@ -34,12 +34,12 @@ bool ActorProcessor::Process(RakNet::Packet &packet, BaseEvent &event) noexcept
|
|||
Player *player = Players::getPlayer(packet.guid);
|
||||
ActorPacket *myPacket = Networking::get().getActorPacketController()->GetPacket(packet.data[0]);
|
||||
|
||||
myPacket->setEvent(&event);
|
||||
myPacket->setActorList(&actorList);
|
||||
|
||||
if (!processor.second->avoidReading)
|
||||
myPacket->Read();
|
||||
|
||||
processor.second->Do(*myPacket, *player, event);
|
||||
processor.second->Do(*myPacket, *player, actorList);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ namespace mwmp
|
|||
{
|
||||
public:
|
||||
|
||||
virtual void Do(ActorPacket &packet, Player &player, BaseEvent &event);
|
||||
virtual void Do(ActorPacket &packet, Player &player, BaseActorList &actorList);
|
||||
|
||||
static bool Process(RakNet::Packet &packet, BaseEvent &event) noexcept;
|
||||
static bool Process(RakNet::Packet &packet, BaseActorList &actorList) noexcept;
|
||||
static void AddProcessor(ActorProcessor *processor) noexcept;
|
||||
|
||||
//typedef boost::unordered_map<unsigned char, boost::shared_ptr<ActorProcessor> > processors_t;
|
||||
|
|
|
@ -51,7 +51,7 @@ Cell::TPlayers Cell::getPlayers() const
|
|||
return players;
|
||||
}
|
||||
|
||||
void Cell::sendToLoaded(mwmp::ActorPacket *actorPacket, mwmp::BaseEvent *baseEvent) const
|
||||
void Cell::sendToLoaded(mwmp::ActorPacket *actorPacket, mwmp::BaseActorList *baseActorList) const
|
||||
{
|
||||
if (players.empty())
|
||||
return;
|
||||
|
@ -66,9 +66,9 @@ void Cell::sendToLoaded(mwmp::ActorPacket *actorPacket, mwmp::BaseEvent *baseEve
|
|||
|
||||
for (auto pl : plList)
|
||||
{
|
||||
if (pl->guid == baseEvent->guid) continue;
|
||||
if (pl->guid == baseActorList->guid) continue;
|
||||
|
||||
actorPacket->setEvent(baseEvent);
|
||||
actorPacket->setActorList(baseActorList);
|
||||
|
||||
// Send the packet to this eligible guid
|
||||
actorPacket->Send(pl->guid);
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
void removePlayer(Player *player);
|
||||
|
||||
TPlayers getPlayers() const;
|
||||
void sendToLoaded(mwmp::ActorPacket *actorPacket, mwmp::BaseEvent *baseEvent) const;
|
||||
void sendToLoaded(mwmp::ActorPacket *actorPacket, mwmp::BaseActorList *baseActorList) const;
|
||||
void sendToLoaded(mwmp::WorldPacket *worldPacket, mwmp::BaseEvent *baseEvent) const;
|
||||
|
||||
std::string getDescription() const;
|
||||
|
|
|
@ -164,8 +164,8 @@ void Networking::processActorPacket(RakNet::Packet *packet)
|
|||
if (!player->isHandshaked() || player->getLoadState() != Player::POSTLOADED)
|
||||
return;
|
||||
|
||||
if (!ActorProcessor::Process(*packet, baseEvent))
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled WorldPacket with identifier %i has arrived", packet->data[0]);
|
||||
if (!ActorProcessor::Process(*packet, baseActorList))
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled ActorPacket with identifier %i has arrived", packet->data[0]);
|
||||
|
||||
}
|
||||
|
||||
|
@ -311,6 +311,11 @@ WorldPacketController *Networking::getWorldPacketController() const
|
|||
return worldPacketController;
|
||||
}
|
||||
|
||||
BaseActorList *Networking::getLastActorList()
|
||||
{
|
||||
return &baseActorList;
|
||||
}
|
||||
|
||||
BaseEvent *Networking::getLastEvent()
|
||||
{
|
||||
return &baseEvent;
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace mwmp
|
|||
ActorPacketController *getActorPacketController() const;
|
||||
WorldPacketController *getWorldPacketController() const;
|
||||
|
||||
BaseActorList *getLastActorList();
|
||||
BaseEvent *getLastEvent();
|
||||
|
||||
int getCurrentMpNum();
|
||||
|
@ -57,12 +58,15 @@ namespace mwmp
|
|||
private:
|
||||
std::string serverPassword;
|
||||
static Networking *sThis;
|
||||
BaseEvent baseEvent;
|
||||
|
||||
RakNet::RakPeerInterface *peer;
|
||||
RakNet::BitStream bsOut;
|
||||
TPlayers *players;
|
||||
MasterClient *mclient;
|
||||
|
||||
BaseActorList baseActorList;
|
||||
BaseEvent baseEvent;
|
||||
|
||||
PlayerPacketController *playerPacketController;
|
||||
ActorPacketController *actorPacketController;
|
||||
WorldPacketController *worldPacketController;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
using namespace mwmp;
|
||||
|
||||
ActorList actorList;
|
||||
BaseActorList scriptActorList;
|
||||
BaseActor tempActor;
|
||||
|
||||
void ActorFunctions::InitActorList(unsigned short pid) noexcept
|
||||
|
@ -17,12 +17,25 @@ void ActorFunctions::InitActorList(unsigned short pid) noexcept
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
actorList.cell.blank();
|
||||
actorList.baseActors.clear();
|
||||
actorList.guid = player->guid;
|
||||
scriptActorList.cell.blank();
|
||||
scriptActorList.baseActors.clear();
|
||||
scriptActorList.guid = player->guid;
|
||||
}
|
||||
|
||||
unsigned int ActorFunctions::GetActorListSize() noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.count;
|
||||
}
|
||||
|
||||
void ActorFunctions::SendActorList() noexcept
|
||||
{
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST)->setActorList(&scriptActorList);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST)->Send(scriptActorList.guid);
|
||||
}
|
||||
|
||||
void ActorFunctions::SendActorAuthority() noexcept
|
||||
{
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY)->setActorList(&scriptActorList);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY)->Send(scriptActorList.guid);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
#define ACTORAPI \
|
||||
{"InitActorList", ActorFunctions::InitActorList},\
|
||||
\
|
||||
{"GetActorListSize", ActorFunctions::GetActorListSize}
|
||||
{"GetActorListSize", ActorFunctions::GetActorListSize},\
|
||||
\
|
||||
{"SendActorList", ActorFunctions::SendActorList},\
|
||||
{"SendActorAuthority", ActorFunctions::SendActorAuthority}\
|
||||
|
||||
class ActorFunctions
|
||||
{
|
||||
|
@ -13,6 +16,9 @@ public:
|
|||
static void InitActorList(unsigned short pid) noexcept;
|
||||
|
||||
static unsigned int GetActorListSize() noexcept;
|
||||
|
||||
static void SendActorList() noexcept;
|
||||
static void SendActorAuthority() noexcept;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -271,18 +271,6 @@ void WorldFunctions::AddContainerItem() noexcept
|
|||
tempWorldObject.containerChanges.items.push_back(containerItem);
|
||||
}
|
||||
|
||||
void WorldFunctions::SendActorList() noexcept
|
||||
{
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST)->setEvent(&scriptEvent);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST)->Send(scriptEvent.guid);
|
||||
}
|
||||
|
||||
void WorldFunctions::SendActorAuthority() noexcept
|
||||
{
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY)->setEvent(&scriptEvent);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY)->Send(scriptEvent.guid);
|
||||
}
|
||||
|
||||
void WorldFunctions::SendObjectDelete() noexcept
|
||||
{
|
||||
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_DELETE)->setEvent(&scriptEvent);
|
||||
|
|
|
@ -51,8 +51,6 @@
|
|||
{"AddWorldObject", WorldFunctions::AddWorldObject},\
|
||||
{"AddContainerItem", WorldFunctions::AddContainerItem},\
|
||||
\
|
||||
{"SendActorList", WorldFunctions::SendActorList},\
|
||||
{"SendActorAuthority", WorldFunctions::SendActorAuthority},\
|
||||
{"SendObjectDelete", WorldFunctions::SendObjectDelete},\
|
||||
{"SendObjectPlace", WorldFunctions::SendObjectPlace},\
|
||||
{"SendObjectScale", WorldFunctions::SendObjectScale},\
|
||||
|
@ -118,8 +116,6 @@ public:
|
|||
static void AddWorldObject() noexcept;
|
||||
static void AddContainerItem() noexcept;
|
||||
|
||||
static void SendActorList() noexcept;
|
||||
static void SendActorAuthority() noexcept;
|
||||
static void SendObjectDelete() noexcept;
|
||||
static void SendObjectPlace() noexcept;
|
||||
static void SendObjectScale() noexcept;
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace mwmp
|
|||
BPP_INIT(ID_ACTOR_AUTHORITY)
|
||||
}
|
||||
|
||||
void Do(ActorPacket &packet, Player &player, BaseEvent &event) override
|
||||
void Do(ActorPacket &packet, Player &player, BaseActorList &actorList) override
|
||||
{
|
||||
packet.Send(true);
|
||||
}
|
||||
|
|
|
@ -13,15 +13,15 @@ namespace mwmp
|
|||
BPP_INIT(ID_ACTOR_FRAME)
|
||||
}
|
||||
|
||||
void Do(ActorPacket &packet, Player &player, BaseEvent &event) override
|
||||
void Do(ActorPacket &packet, Player &player, BaseActorList &actorList) override
|
||||
{
|
||||
// Send only to players who have the cell loaded
|
||||
Cell *serverCell = CellController::get()->getCell(&event.cell);
|
||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||
|
||||
if (serverCell != nullptr)
|
||||
serverCell->sendToLoaded(&packet, &event);
|
||||
serverCell->sendToLoaded(&packet, &actorList);
|
||||
|
||||
Script::Call<Script::CallbackIdentity("OnActorFrame")>(player.getId(), event.cell.getDescription().c_str());
|
||||
Script::Call<Script::CallbackIdentity("OnActorFrame")>(player.getId(), actorList.cell.getDescription().c_str());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -13,17 +13,17 @@ namespace mwmp
|
|||
BPP_INIT(ID_ACTOR_LIST)
|
||||
}
|
||||
|
||||
void Do(ActorPacket &packet, Player &player, BaseEvent &event) override
|
||||
void Do(ActorPacket &packet, Player &player, BaseActorList &actorList) override
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
|
||||
|
||||
// Send only to players who have the cell loaded
|
||||
Cell *serverCell = CellController::get()->getCell(&event.cell);
|
||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||
|
||||
if (serverCell != nullptr)
|
||||
serverCell->sendToLoaded(&packet, &event);
|
||||
serverCell->sendToLoaded(&packet, &actorList);
|
||||
|
||||
Script::Call<Script::CallbackIdentity("OnActorList")>(player.getId(), event.cell.getDescription().c_str());
|
||||
Script::Call<Script::CallbackIdentity("OnActorList")>(player.getId(), actorList.cell.getDescription().c_str());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ add_openmw_dir (mwbase
|
|||
inputmanager windowmanager statemanager
|
||||
)
|
||||
|
||||
add_openmw_dir (mwmp Main Networking LocalPlayer DedicatedPlayer LocalActor DedicatedActor WorldEvent Cell CellController GUIChat GUILogin GUIController PlayerMarkerCollection GUIDialogList)
|
||||
add_openmw_dir (mwmp Main Networking LocalPlayer DedicatedPlayer LocalActor DedicatedActor ActorList WorldEvent Cell CellController GUIChat GUILogin GUIController PlayerMarkerCollection GUIDialogList)
|
||||
|
||||
# Main executable
|
||||
|
||||
|
|
109
apps/openmw/mwmp/ActorList.cpp
Normal file
109
apps/openmw/mwmp/ActorList.cpp
Normal file
|
@ -0,0 +1,109 @@
|
|||
#include "ActorList.hpp"
|
||||
#include "Main.hpp"
|
||||
#include "Networking.hpp"
|
||||
#include "LocalPlayer.hpp"
|
||||
|
||||
#include <components/openmw-mp/Log.hpp>
|
||||
|
||||
using namespace mwmp;
|
||||
using namespace std;
|
||||
|
||||
ActorList::ActorList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ActorList::~ActorList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Networking *ActorList::getNetworking()
|
||||
{
|
||||
return mwmp::Main::get().getNetworking();
|
||||
}
|
||||
|
||||
void ActorList::reset()
|
||||
{
|
||||
cell.blank();
|
||||
baseActors.clear();
|
||||
guid = mwmp::Main::get().getNetworking()->getLocalPlayer()->guid;
|
||||
}
|
||||
|
||||
void ActorList::addActor(BaseActor baseActor)
|
||||
{
|
||||
baseActors.push_back(baseActor);
|
||||
}
|
||||
|
||||
void ActorList::addActor(LocalActor localActor)
|
||||
{
|
||||
baseActors.push_back(localActor);
|
||||
}
|
||||
|
||||
// TODO: Finish this
|
||||
void ActorList::editActors(MWWorld::CellStore* cellStore)
|
||||
{
|
||||
BaseActor actor;
|
||||
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
actor = baseActors.at(i);
|
||||
|
||||
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", actor.refId.c_str(), actor.refNumIndex, actor.mpNum);
|
||||
|
||||
return;
|
||||
|
||||
MWWorld::Ptr ptrFound = cellStore->searchExact(actor.refId, actor.refNumIndex, actor.mpNum);
|
||||
|
||||
if (ptrFound)
|
||||
{
|
||||
LOG_APPEND(Log::LOG_VERBOSE, "-- Found %s, %i, %i", ptrFound.getCellRef().getRefId().c_str(),
|
||||
ptrFound.getCellRef().getRefNum(), ptrFound.getCellRef().getMpNum());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "-- Could not find %s, %i, %i", ptrFound.getCellRef().getRefId().c_str(),
|
||||
ptrFound.getCellRef().getRefNum(), ptrFound.getCellRef().getMpNum());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ActorList::sendActors(MWWorld::CellStore* cellStore)
|
||||
{
|
||||
reset();
|
||||
cell = *cellStore->getCell();
|
||||
action = BaseActorList::SET;
|
||||
|
||||
MWWorld::CellRefList<ESM::NPC> *npcList = cellStore->getNpcs();
|
||||
|
||||
for (typename MWWorld::CellRefList<ESM::NPC>::List::iterator listIter(npcList->mList.begin());
|
||||
listIter != npcList->mList.end(); ++listIter)
|
||||
{
|
||||
MWWorld::Ptr ptr(&*listIter, 0);
|
||||
|
||||
BaseActor actor;
|
||||
actor.refId = ptr.getCellRef().getRefId();
|
||||
actor.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
|
||||
actor.mpNum = ptr.getCellRef().getMpNum();
|
||||
|
||||
addActor(actor);
|
||||
}
|
||||
|
||||
MWWorld::CellRefList<ESM::Creature> *creatureList = cellStore->getCreatures();
|
||||
|
||||
for (typename MWWorld::CellRefList<ESM::Creature>::List::iterator listIter(creatureList->mList.begin());
|
||||
listIter != creatureList->mList.end(); ++listIter)
|
||||
{
|
||||
MWWorld::Ptr ptr(&*listIter, 0);
|
||||
|
||||
BaseActor actor;
|
||||
actor.refId = ptr.getCellRef().getRefId();
|
||||
actor.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
|
||||
actor.mpNum = ptr.getCellRef().getMpNum();
|
||||
|
||||
addActor(actor);
|
||||
}
|
||||
|
||||
mwmp::Main::get().getNetworking()->getActorPacket(ID_ACTOR_LIST)->setActorList(this);
|
||||
mwmp::Main::get().getNetworking()->getActorPacket(ID_ACTOR_LIST)->Send();
|
||||
}
|
34
apps/openmw/mwmp/ActorList.hpp
Normal file
34
apps/openmw/mwmp/ActorList.hpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
#ifndef OPENMW_ACTORLIST_HPP
|
||||
#define OPENMW_ACTORLIST_HPP
|
||||
|
||||
#include <components/openmw-mp/Base/BaseActor.hpp>
|
||||
#include "../mwworld/cellstore.hpp"
|
||||
#include <RakNetTypes.h>
|
||||
|
||||
#include "LocalActor.hpp"
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class Networking;
|
||||
class ActorList : public BaseActorList
|
||||
{
|
||||
public:
|
||||
|
||||
ActorList();
|
||||
virtual ~ActorList();
|
||||
|
||||
void reset();
|
||||
void addActor(BaseActor baseActor);
|
||||
void addActor(LocalActor localActor);
|
||||
|
||||
void editActors(MWWorld::CellStore* cellStore);
|
||||
|
||||
void sendActors(MWWorld::CellStore* cellStore);
|
||||
|
||||
private:
|
||||
Networking *getNetworking();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_ACTORLIST_HPP
|
|
@ -27,9 +27,10 @@ void Cell::updateLocal()
|
|||
{
|
||||
if (localActors.empty()) return;
|
||||
|
||||
WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
|
||||
worldEvent->reset();
|
||||
worldEvent->cell = *store->getCell();
|
||||
ActorList *actorList = mwmp::Main::get().getNetworking()->getActorList();
|
||||
actorList->reset();
|
||||
|
||||
actorList->cell = *store->getCell();
|
||||
|
||||
for (std::map<std::string, LocalActor *>::iterator it = localActors.begin(); it != localActors.end();)
|
||||
{
|
||||
|
@ -46,47 +47,17 @@ void Cell::updateLocal()
|
|||
{
|
||||
//LOG_APPEND(Log::LOG_VERBOSE, "- Updating LocalActor %s", it->first.c_str());
|
||||
actor->update();
|
||||
MWWorld::Ptr ptr = actor->getPtr();
|
||||
|
||||
WorldObject worldObject;
|
||||
worldObject.refId = ptr.getCellRef().getRefId();
|
||||
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
|
||||
worldObject.mpNum = ptr.getCellRef().getMpNum();
|
||||
worldObject.pos = actor->position;
|
||||
worldObject.drawState = actor->drawState;
|
||||
|
||||
worldObject.headPitch = actor->headPitch;
|
||||
worldObject.headYaw = actor->headYaw;
|
||||
|
||||
worldObject.hasAnimation = actor->hasAnimation;
|
||||
worldObject.hasAnimStates = actor->hasAnimStates;
|
||||
worldObject.hasMovement = actor->hasMovement;
|
||||
|
||||
if (actor->hasAnimation)
|
||||
{
|
||||
worldObject.animation = actor->animation;
|
||||
}
|
||||
|
||||
if (actor->hasAnimStates)
|
||||
{
|
||||
worldObject.animStates = actor->animStates;
|
||||
}
|
||||
|
||||
if (actor->hasMovement)
|
||||
{
|
||||
worldObject.movement = actor->movement;
|
||||
}
|
||||
|
||||
actorList->addActor(*actor);
|
||||
actor->hasAnimation = false;
|
||||
actor->hasAnimStates = false;
|
||||
actor->hasMovement = false;
|
||||
worldEvent->addObject(worldObject);
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
Main::get().getNetworking()->getActorPacket(ID_ACTOR_FRAME)->setEvent(worldEvent);
|
||||
Main::get().getNetworking()->getActorPacket(ID_ACTOR_FRAME)->setActorList(actorList);
|
||||
Main::get().getNetworking()->getActorPacket(ID_ACTOR_FRAME)->Send();
|
||||
}
|
||||
|
||||
|
@ -102,24 +73,24 @@ void Cell::updateDedicated(float dt)
|
|||
}
|
||||
}
|
||||
|
||||
void Cell::readCellFrame(WorldEvent& worldEvent)
|
||||
void Cell::readCellFrame(ActorList& actorList)
|
||||
{
|
||||
WorldObject worldObject;
|
||||
BaseActor baseActor;
|
||||
|
||||
for (unsigned int i = 0; i < worldEvent.objectChanges.count; i++)
|
||||
for (unsigned int i = 0; i < actorList.count; i++)
|
||||
{
|
||||
worldObject = worldEvent.objectChanges.objects.at(i);
|
||||
std::string mapIndex = Main::get().getCellController()->generateMapIndex(worldObject);
|
||||
baseActor = actorList.baseActors.at(i);
|
||||
std::string mapIndex = Main::get().getCellController()->generateMapIndex(baseActor);
|
||||
|
||||
// If this key doesn't exist, create it
|
||||
if (dedicatedActors.count(mapIndex) == 0)
|
||||
{
|
||||
MWWorld::Ptr ptrFound = store->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
|
||||
MWWorld::Ptr ptrFound = store->searchExact(baseActor.refId, baseActor.refNumIndex, baseActor.mpNum);
|
||||
|
||||
if (!ptrFound) return;
|
||||
|
||||
DedicatedActor *actor = new DedicatedActor();
|
||||
actor->cell = worldEvent.cell;
|
||||
actor->cell = actorList.cell;
|
||||
actor->setPtr(ptrFound);
|
||||
dedicatedActors[mapIndex] = actor;
|
||||
|
||||
|
@ -132,29 +103,29 @@ void Cell::readCellFrame(WorldEvent& worldEvent)
|
|||
if (dedicatedActors.count(mapIndex) > 0)
|
||||
{
|
||||
DedicatedActor *actor = dedicatedActors[mapIndex];
|
||||
actor->position = worldObject.pos;
|
||||
actor->drawState = worldObject.drawState;
|
||||
actor->position = baseActor.pos;
|
||||
actor->drawState = baseActor.drawState;
|
||||
|
||||
actor->headPitch = worldObject.headPitch;
|
||||
actor->headYaw = worldObject.headYaw;
|
||||
actor->headPitch = baseActor.headPitch;
|
||||
actor->headYaw = baseActor.headYaw;
|
||||
|
||||
actor->hasAnimation = worldObject.hasAnimation;
|
||||
actor->hasAnimStates = worldObject.hasAnimStates;
|
||||
actor->hasMovement = worldObject.hasMovement;
|
||||
actor->hasAnimation = baseActor.hasAnimation;
|
||||
actor->hasAnimStates = baseActor.hasAnimStates;
|
||||
actor->hasMovement = baseActor.hasMovement;
|
||||
|
||||
if (actor->hasAnimation)
|
||||
{
|
||||
actor->animation = worldObject.animation;
|
||||
actor->animation = baseActor.animation;
|
||||
}
|
||||
|
||||
if (actor->hasAnimStates)
|
||||
{
|
||||
actor->animStates = worldObject.animStates;
|
||||
actor->animStates = baseActor.animStates;
|
||||
}
|
||||
|
||||
if (actor->hasMovement)
|
||||
{
|
||||
actor->movement = worldObject.movement;
|
||||
actor->movement = baseActor.movement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef OPENMW_CELL_HPP
|
||||
#define OPENMW_CELL_HPP
|
||||
|
||||
#include "WorldEvent.hpp"
|
||||
#include "ActorList.hpp"
|
||||
#include "LocalActor.hpp"
|
||||
#include "DedicatedActor.hpp"
|
||||
#include "../mwworld/cellstore.hpp"
|
||||
|
@ -18,7 +18,7 @@ namespace mwmp
|
|||
void updateLocal();
|
||||
void updateDedicated(float dt);
|
||||
|
||||
void readCellFrame(mwmp::WorldEvent& worldEvent);
|
||||
void readCellFrame(mwmp::ActorList& actorList);
|
||||
|
||||
void initializeLocalActors();
|
||||
void uninitializeLocalActors();
|
||||
|
|
|
@ -89,16 +89,16 @@ void CellController::initializeLocalActors(const ESM::Cell& cell)
|
|||
}
|
||||
}
|
||||
|
||||
void CellController::readCellFrame(WorldEvent& worldEvent)
|
||||
void CellController::readCellFrame(ActorList& actorList)
|
||||
{
|
||||
std::string mapIndex = worldEvent.cell.getDescription();
|
||||
std::string mapIndex = actorList.cell.getDescription();
|
||||
|
||||
initializeCell(worldEvent.cell);
|
||||
initializeCell(actorList.cell);
|
||||
|
||||
// If this now exists, send it the data
|
||||
if (cellsActive.count(mapIndex) > 0)
|
||||
{
|
||||
cellsActive[mapIndex]->readCellFrame(worldEvent);
|
||||
cellsActive[mapIndex]->readCellFrame(actorList);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,12 +161,12 @@ std::string CellController::generateMapIndex(MWWorld::Ptr ptr)
|
|||
return mapIndex;
|
||||
}
|
||||
|
||||
std::string CellController::generateMapIndex(WorldObject object)
|
||||
std::string CellController::generateMapIndex(BaseActor baseActor)
|
||||
{
|
||||
std::string mapIndex = "";
|
||||
mapIndex += object.refId;
|
||||
mapIndex += "-" + Utils::toString(object.refNumIndex);
|
||||
mapIndex += "-" + Utils::toString(object.mpNum);
|
||||
mapIndex += baseActor.refId;
|
||||
mapIndex += "-" + Utils::toString(baseActor.refNumIndex);
|
||||
mapIndex += "-" + Utils::toString(baseActor.mpNum);
|
||||
return mapIndex;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define OPENMW_CELLCONTROLLER_HPP
|
||||
|
||||
#include "Cell.hpp"
|
||||
#include "WorldEvent.hpp"
|
||||
#include "ActorList.hpp"
|
||||
#include "LocalActor.hpp"
|
||||
#include "DedicatedActor.hpp"
|
||||
#include "../mwworld/cellstore.hpp"
|
||||
|
@ -21,7 +21,7 @@ namespace mwmp
|
|||
|
||||
void initializeCell(const ESM::Cell& cell);
|
||||
void initializeLocalActors(const ESM::Cell& cell);
|
||||
void readCellFrame(mwmp::WorldEvent& worldEvent);
|
||||
void readCellFrame(mwmp::ActorList& actorList);
|
||||
|
||||
void setLocalActorRecord(std::string actorIndex, std::string cellIndex);
|
||||
void removeLocalActorRecord(std::string actorIndex);
|
||||
|
@ -34,7 +34,7 @@ namespace mwmp
|
|||
virtual DedicatedActor *getDedicatedActor(MWWorld::Ptr ptr);
|
||||
|
||||
std::string generateMapIndex(MWWorld::Ptr ptr);
|
||||
std::string generateMapIndex(mwmp::WorldObject object);
|
||||
std::string generateMapIndex(mwmp::BaseActor baseActor);
|
||||
|
||||
int getCellSize() const;
|
||||
virtual MWWorld::CellStore *getCell(const ESM::Cell& cell);
|
||||
|
|
|
@ -837,37 +837,37 @@ void Networking::processActorPacket(RakNet::Packet *packet)
|
|||
|
||||
ActorPacket *myPacket = actorPacketController.GetPacket(packet->data[0]);
|
||||
|
||||
myPacket->setEvent(&worldEvent);
|
||||
myPacket->setActorList(&actorList);
|
||||
myPacket->Packet(&bsIn, false);
|
||||
|
||||
switch (packet->data[0])
|
||||
{
|
||||
case ID_ACTOR_LIST:
|
||||
{
|
||||
MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCell(worldEvent.cell);
|
||||
MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCell(actorList.cell);
|
||||
|
||||
if (!ptrCellStore) return;
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received ID_ACTOR_LIST about %s", worldEvent.cell.getDescription().c_str());
|
||||
LOG_APPEND(Log::LOG_VERBOSE, "- action: %i", worldEvent.action);
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received ID_ACTOR_LIST about %s", actorList.cell.getDescription().c_str());
|
||||
LOG_APPEND(Log::LOG_VERBOSE, "- action: %i", actorList.action);
|
||||
|
||||
// If we've received a request for information, comply with it
|
||||
if (worldEvent.action == mwmp::BaseEvent::REQUEST)
|
||||
worldEvent.sendActors(ptrCellStore);
|
||||
if (actorList.action == mwmp::BaseActorList::REQUEST)
|
||||
actorList.sendActors(ptrCellStore);
|
||||
|
||||
break;
|
||||
}
|
||||
case ID_ACTOR_AUTHORITY:
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received ID_ACTOR_AUTHORITY about %s", worldEvent.cell.getDescription().c_str());
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Received ID_ACTOR_AUTHORITY about %s", actorList.cell.getDescription().c_str());
|
||||
|
||||
//Main::get().getCellController()->initializeLocalActors(worldEvent.cell);
|
||||
//Main::get().getCellController()->initializeLocalActors(actorList.cell);
|
||||
|
||||
break;
|
||||
}
|
||||
case ID_ACTOR_FRAME:
|
||||
{
|
||||
//Main::get().getCellController()->readCellFrame(worldEvent);
|
||||
//Main::get().getCellController()->readCellFrame(actorList);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -1105,6 +1105,11 @@ LocalPlayer *Networking::getLocalPlayer()
|
|||
return mwmp::Main::get().getLocalPlayer();
|
||||
}
|
||||
|
||||
ActorList *Networking::getActorList()
|
||||
{
|
||||
return &actorList;
|
||||
}
|
||||
|
||||
WorldEvent *Networking::getWorldEvent()
|
||||
{
|
||||
return &worldEvent;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <BitStream.h>
|
||||
#include <string>
|
||||
|
||||
#include "ActorList.hpp"
|
||||
#include "WorldEvent.hpp"
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
|
||||
|
@ -44,8 +45,9 @@ namespace mwmp
|
|||
|
||||
bool isConnected();
|
||||
|
||||
WorldEvent *getWorldEvent();
|
||||
LocalPlayer *getLocalPlayer();
|
||||
ActorList *getActorList();
|
||||
WorldEvent *getWorldEvent();
|
||||
|
||||
private:
|
||||
bool connected;
|
||||
|
@ -57,6 +59,7 @@ namespace mwmp
|
|||
ActorPacketController actorPacketController;
|
||||
WorldPacketController worldPacketController;
|
||||
|
||||
ActorList actorList;
|
||||
WorldEvent worldEvent;
|
||||
|
||||
void processPlayerPacket(RakNet::Packet *packet);
|
||||
|
|
|
@ -47,33 +47,6 @@ void WorldEvent::addObject(WorldObject worldObject)
|
|||
objectChanges.objects.push_back(worldObject);
|
||||
}
|
||||
|
||||
void WorldEvent::editActors(MWWorld::CellStore* cellStore)
|
||||
{
|
||||
WorldObject worldObject;
|
||||
|
||||
for (unsigned int i = 0; i < objectChanges.count; i++)
|
||||
{
|
||||
worldObject = objectChanges.objects.at(i);
|
||||
|
||||
LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.mpNum);
|
||||
|
||||
return;
|
||||
|
||||
MWWorld::Ptr ptrFound = cellStore->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
|
||||
|
||||
if (ptrFound)
|
||||
{
|
||||
LOG_APPEND(Log::LOG_VERBOSE, "-- Found %s, %i, %i", ptrFound.getCellRef().getRefId().c_str(),
|
||||
ptrFound.getCellRef().getRefNum(), ptrFound.getCellRef().getMpNum());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "-- Could not find %s, %i, %i", ptrFound.getCellRef().getRefId().c_str(),
|
||||
ptrFound.getCellRef().getRefNum(), ptrFound.getCellRef().getMpNum());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WorldEvent::editContainers(MWWorld::CellStore* cellStore)
|
||||
{
|
||||
WorldObject worldObject;
|
||||
|
@ -476,46 +449,6 @@ void WorldEvent::playVideo()
|
|||
}
|
||||
}
|
||||
|
||||
void WorldEvent::sendActors(MWWorld::CellStore* cellStore)
|
||||
{
|
||||
reset();
|
||||
cell = *cellStore->getCell();
|
||||
action = BaseEvent::SET;
|
||||
|
||||
MWWorld::CellRefList<ESM::NPC> *npcList = cellStore->getNpcs();
|
||||
|
||||
for (typename MWWorld::CellRefList<ESM::NPC>::List::iterator listIter(npcList->mList.begin());
|
||||
listIter != npcList->mList.end(); ++listIter)
|
||||
{
|
||||
MWWorld::Ptr ptr(&*listIter, 0);
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.refId = ptr.getCellRef().getRefId();
|
||||
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
|
||||
worldObject.mpNum = ptr.getCellRef().getMpNum();
|
||||
|
||||
addObject(worldObject);
|
||||
}
|
||||
|
||||
MWWorld::CellRefList<ESM::Creature> *creatureList = cellStore->getCreatures();
|
||||
|
||||
for (typename MWWorld::CellRefList<ESM::Creature>::List::iterator listIter(creatureList->mList.begin());
|
||||
listIter != creatureList->mList.end(); ++listIter)
|
||||
{
|
||||
MWWorld::Ptr ptr(&*listIter, 0);
|
||||
|
||||
mwmp::WorldObject worldObject;
|
||||
worldObject.refId = ptr.getCellRef().getRefId();
|
||||
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
|
||||
worldObject.mpNum = ptr.getCellRef().getMpNum();
|
||||
|
||||
addObject(worldObject);
|
||||
}
|
||||
|
||||
mwmp::Main::get().getNetworking()->getActorPacket(ID_ACTOR_LIST)->setEvent(this);
|
||||
mwmp::Main::get().getNetworking()->getActorPacket(ID_ACTOR_LIST)->Send();
|
||||
}
|
||||
|
||||
void WorldEvent::sendContainers(MWWorld::CellStore* cellStore)
|
||||
{
|
||||
reset();
|
||||
|
|
|
@ -18,7 +18,6 @@ namespace mwmp
|
|||
void reset();
|
||||
void addObject(WorldObject worldObject);
|
||||
|
||||
void editActors(MWWorld::CellStore* cellStore);
|
||||
void editContainers(MWWorld::CellStore* cellStore);
|
||||
|
||||
void placeObjects(MWWorld::CellStore* cellStore);
|
||||
|
@ -39,7 +38,6 @@ namespace mwmp
|
|||
void playMusic();
|
||||
void playVideo();
|
||||
|
||||
void sendActors(MWWorld::CellStore* cellStore);
|
||||
void sendContainers(MWWorld::CellStore* cellStore);
|
||||
|
||||
void sendObjectPlace(MWWorld::Ptr ptr);
|
||||
|
|
|
@ -16,6 +16,12 @@ namespace mwmp
|
|||
|
||||
}
|
||||
|
||||
std::string refId;
|
||||
int refNumIndex;
|
||||
int mpNum;
|
||||
|
||||
ESM::Position pos;
|
||||
|
||||
char drawState;
|
||||
bool isFlying;
|
||||
|
||||
|
@ -35,21 +41,31 @@ namespace mwmp
|
|||
bool hasMovement;
|
||||
};
|
||||
|
||||
class ActorList
|
||||
class BaseActorList
|
||||
{
|
||||
public:
|
||||
|
||||
ActorList()
|
||||
BaseActorList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
enum ACTOR_ACTION
|
||||
{
|
||||
SET = 0,
|
||||
ADD = 1,
|
||||
REMOVE = 2,
|
||||
REQUEST = 3
|
||||
};
|
||||
|
||||
RakNet::RakNetGUID guid;
|
||||
|
||||
std::vector<BaseActor> baseActors;
|
||||
unsigned int count;
|
||||
|
||||
ESM::Cell cell;
|
||||
|
||||
unsigned char action; // 0 - Clear and set in entirety, 1 - Add item, 2 - Remove item, 3 - Request items
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -24,4 +24,4 @@ namespace mwmp
|
|||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_WORLDPACKETCONTROLLER_HPP
|
||||
#endif //OPENMW_ACTORPACKETCONTROLLER_HPP
|
||||
|
|
|
@ -18,8 +18,8 @@ ActorPacket::~ActorPacket()
|
|||
|
||||
}
|
||||
|
||||
void ActorPacket::setEvent(BaseEvent *event)
|
||||
void ActorPacket::setActorList(BaseActorList *actorList)
|
||||
{
|
||||
this->event = event;
|
||||
guid = event->guid;
|
||||
this->actorList = actorList;
|
||||
guid = actorList->guid;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <RakNetTypes.h>
|
||||
#include <BitStream.h>
|
||||
#include <PacketPriority.h>
|
||||
#include <components/openmw-mp/Base/BaseEvent.hpp>
|
||||
#include <components/openmw-mp/Base/BaseActor.hpp>
|
||||
|
||||
#include <components/openmw-mp/Packets/BasePacket.hpp>
|
||||
|
||||
|
@ -19,10 +19,10 @@ namespace mwmp
|
|||
|
||||
~ActorPacket();
|
||||
|
||||
void setEvent(BaseEvent *event);
|
||||
void setActorList(BaseActorList *actorList);
|
||||
|
||||
protected:
|
||||
BaseEvent *event;
|
||||
BaseActorList *actorList;
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -13,33 +13,33 @@ void PacketActorAuthority::Packet(RakNet::BitStream *bs, bool send)
|
|||
ActorPacket::Packet(bs, send);
|
||||
|
||||
if (!send)
|
||||
event->objectChanges.objects.clear();
|
||||
actorList->baseActors.clear();
|
||||
else
|
||||
event->objectChanges.count = (unsigned int)(event->objectChanges.objects.size());
|
||||
actorList->count = (unsigned int)(actorList->baseActors.size());
|
||||
|
||||
RW(event->objectChanges.count, send);
|
||||
RW(actorList->count, send);
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
RW(event->cell.mName, send);
|
||||
RW(actorList->cell.mData.mFlags, send);
|
||||
RW(actorList->cell.mData.mX, send);
|
||||
RW(actorList->cell.mData.mY, send);
|
||||
RW(actorList->cell.mName, send);
|
||||
|
||||
WorldObject worldObject;
|
||||
BaseActor actor;
|
||||
|
||||
for (unsigned int i = 0; i < event->objectChanges.count; i++)
|
||||
for (unsigned int i = 0; i < actorList->count; i++)
|
||||
{
|
||||
if (send)
|
||||
{
|
||||
worldObject = event->objectChanges.objects.at(i);
|
||||
actor = actorList->baseActors.at(i);
|
||||
}
|
||||
|
||||
RW(worldObject.refId, send);
|
||||
RW(worldObject.refNumIndex, send);
|
||||
RW(worldObject.mpNum, send);
|
||||
RW(actor.refId, send);
|
||||
RW(actor.refNumIndex, send);
|
||||
RW(actor.mpNum, send);
|
||||
|
||||
if (!send)
|
||||
{
|
||||
event->objectChanges.objects.push_back(worldObject);
|
||||
actorList->baseActors.push_back(actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,65 +14,65 @@ void PacketActorFrame::Packet(RakNet::BitStream *bs, bool send)
|
|||
ActorPacket::Packet(bs, send);
|
||||
|
||||
if (!send)
|
||||
event->objectChanges.objects.clear();
|
||||
actorList->baseActors.clear();
|
||||
else
|
||||
event->objectChanges.count = (unsigned int)(event->objectChanges.objects.size());
|
||||
actorList->count = (unsigned int)(actorList->baseActors.size());
|
||||
|
||||
RW(event->objectChanges.count, send);
|
||||
RW(actorList->count, send);
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
RW(event->cell.mName, send);
|
||||
RW(actorList->cell.mData.mFlags, send);
|
||||
RW(actorList->cell.mData.mX, send);
|
||||
RW(actorList->cell.mData.mY, send);
|
||||
RW(actorList->cell.mName, send);
|
||||
|
||||
WorldObject worldObject;
|
||||
BaseActor actor;
|
||||
|
||||
for (unsigned int i = 0; i < event->objectChanges.count; i++)
|
||||
for (unsigned int i = 0; i < actorList->count; i++)
|
||||
{
|
||||
if (send)
|
||||
{
|
||||
worldObject = event->objectChanges.objects.at(i);
|
||||
actor = actorList->baseActors.at(i);
|
||||
}
|
||||
|
||||
RW(worldObject.refId, send);
|
||||
RW(worldObject.refNumIndex, send);
|
||||
RW(worldObject.mpNum, send);
|
||||
RW(worldObject.pos, send);
|
||||
RW(worldObject.drawState, send);
|
||||
RW(actor.refId, send);
|
||||
RW(actor.refNumIndex, send);
|
||||
RW(actor.mpNum, send);
|
||||
RW(actor.pos, send);
|
||||
RW(actor.drawState, send);
|
||||
|
||||
RW(worldObject.headPitch, send);
|
||||
RW(worldObject.headYaw, send);
|
||||
RW(actor.headPitch, send);
|
||||
RW(actor.headYaw, send);
|
||||
|
||||
RW(worldObject.hasAnimation, send);
|
||||
RW(worldObject.hasAnimStates, send);
|
||||
RW(worldObject.hasMovement, send);
|
||||
RW(actor.hasAnimation, send);
|
||||
RW(actor.hasAnimStates, send);
|
||||
RW(actor.hasMovement, send);
|
||||
|
||||
if (worldObject.hasAnimation)
|
||||
if (actor.hasAnimation)
|
||||
{
|
||||
RW(worldObject.animation.groupname, send);
|
||||
RW(worldObject.animation.mode, send);
|
||||
RW(worldObject.animation.count, send);
|
||||
RW(worldObject.animation.persist, send);
|
||||
RW(actor.animation.groupname, send);
|
||||
RW(actor.animation.mode, send);
|
||||
RW(actor.animation.count, send);
|
||||
RW(actor.animation.persist, send);
|
||||
}
|
||||
|
||||
if (worldObject.hasAnimStates)
|
||||
if (actor.hasAnimStates)
|
||||
{
|
||||
RW(worldObject.animStates.idlestate, send);
|
||||
RW(worldObject.animStates.movestate, send);
|
||||
RW(worldObject.animStates.jumpstate, send);
|
||||
RW(worldObject.animStates.forcestateupdate, send);
|
||||
RW(actor.animStates.idlestate, send);
|
||||
RW(actor.animStates.movestate, send);
|
||||
RW(actor.animStates.jumpstate, send);
|
||||
RW(actor.animStates.forcestateupdate, send);
|
||||
}
|
||||
|
||||
if (worldObject.hasMovement)
|
||||
if (actor.hasMovement)
|
||||
{
|
||||
RW(worldObject.movement.x, send);
|
||||
RW(worldObject.movement.y, send);
|
||||
RW(worldObject.movement.y, send);
|
||||
RW(actor.movement.x, send);
|
||||
RW(actor.movement.y, send);
|
||||
RW(actor.movement.y, send);
|
||||
}
|
||||
|
||||
if (!send)
|
||||
{
|
||||
event->objectChanges.objects.push_back(worldObject);
|
||||
actorList->baseActors.push_back(actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,40 +12,40 @@ void PacketActorList::Packet(RakNet::BitStream *bs, bool send)
|
|||
{
|
||||
ActorPacket::Packet(bs, send);
|
||||
|
||||
RW(event->action, send);
|
||||
RW(actorList->action, send);
|
||||
|
||||
if (send)
|
||||
{
|
||||
event->objectChanges.count = (unsigned int)(event->objectChanges.objects.size());
|
||||
actorList->count = (unsigned int)(actorList->baseActors.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
event->objectChanges.objects.clear();
|
||||
actorList->baseActors.clear();
|
||||
}
|
||||
|
||||
RW(event->objectChanges.count, send);
|
||||
RW(actorList->count, send);
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
RW(event->cell.mName, send);
|
||||
RW(actorList->cell.mData.mFlags, send);
|
||||
RW(actorList->cell.mData.mX, send);
|
||||
RW(actorList->cell.mData.mY, send);
|
||||
RW(actorList->cell.mName, send);
|
||||
|
||||
WorldObject worldObject;
|
||||
BaseActor actor;
|
||||
|
||||
for (unsigned int i = 0; i < event->objectChanges.count; i++)
|
||||
for (unsigned int i = 0; i < actorList->count; i++)
|
||||
{
|
||||
if (send)
|
||||
{
|
||||
worldObject = event->objectChanges.objects.at(i);
|
||||
actor = actorList->baseActors.at(i);
|
||||
}
|
||||
|
||||
RW(worldObject.refId, send);
|
||||
RW(worldObject.refNumIndex, send);
|
||||
RW(worldObject.mpNum, send);
|
||||
RW(actor.refId, send);
|
||||
RW(actor.refNumIndex, send);
|
||||
RW(actor.mpNum, send);
|
||||
|
||||
if (!send)
|
||||
{
|
||||
event->objectChanges.objects.push_back(worldObject);
|
||||
actorList->baseActors.push_back(actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue