[Server] Use correct cells in "send" functions

Remove unused return type from ON_PLAYER_SENDMESSAGE
new-script-api
Koncord 7 years ago
parent 2d0840cb3a
commit fe2dd1bad4

@ -91,21 +91,21 @@ void ActorController::Init(LuaState &lua)
});
playersTable.set_function("sendActors", [&lua](shared_ptr<Player> player, vector<shared_ptr<Actor>> actors,
bool sendToAll) {
lua.getActorCtrl().sendActors(player, actors, sendToAll);
const std::string &cellDescription, bool sendToAll) {
lua.getActorCtrl().sendActors(player, actors, Utils::getCellFromDescription(cellDescription), sendToAll);
});
playersTable.set_function("sendList", [&lua](shared_ptr<Player> player, vector<shared_ptr<Actor>> actors,
bool sendToAll) {
lua.getActorCtrl().sendList(player, actors, sendToAll);
const std::string &cellDescription, bool sendToAll) {
lua.getActorCtrl().sendList(player, actors, Utils::getCellFromDescription(cellDescription), sendToAll);
});
playersTable.set_function("requestList", [&lua](shared_ptr<Player> player){
lua.getActorCtrl().requestList(player);
playersTable.set_function("requestList", [&lua](shared_ptr<Player> player, const std::string &cellDescription){
lua.getActorCtrl().requestList(player, Utils::getCellFromDescription(cellDescription));
});
playersTable.set_function("getActors", [&lua](shared_ptr<Player> player){
lua.getActorCtrl().getActors(player);
playersTable.set_function("getActors", [&lua](shared_ptr<Player> player, const std::string &cellDescription){
lua.getActorCtrl().getActors(player, Utils::getCellFromDescription(cellDescription));
});
}
@ -127,9 +127,10 @@ std::shared_ptr<Actor> ActorController::createActor()
return shared_ptr<Actor>(actor);
}
void ActorController::sendActors(std::shared_ptr<Player> player, std::vector<std::shared_ptr<Actor>> actors, bool sendToAll)
void ActorController::sendActors(std::shared_ptr<Player> player, std::vector<std::shared_ptr<Actor>> actors,
const ESM::Cell &cell, bool sendToAll)
{
actorList.cell = player->cell;
actorList.cell = cell;
actorList.guid = player->guid;
bool positionChanged = false;
@ -231,7 +232,8 @@ void ActorController::sendActors(std::shared_ptr<Player> player, std::vector<std
}
}
void ActorController::sendList(std::shared_ptr<Player> player, std::vector<std::shared_ptr<Actor>> actors, bool sendToAll)
void ActorController::sendList(std::shared_ptr<Player> player, std::vector<std::shared_ptr<Actor>> actors,
const ESM::Cell &cell, bool sendToAll)
{
actorList.cell = player->cell;
actorList.guid = player->guid;
@ -242,7 +244,7 @@ void ActorController::sendList(std::shared_ptr<Player> player, std::vector<std::
packet->Send(actorList.guid);
}
void ActorController::requestList(std::shared_ptr<Player> player)
void ActorController::requestList(std::shared_ptr<Player> player, const ESM::Cell &cell)
{
actorList.cell = player->cell;
actorList.guid = player->guid;
@ -253,7 +255,7 @@ void ActorController::requestList(std::shared_ptr<Player> player)
packet->Send(actorList.guid);
}
std::vector<std::shared_ptr<Actor>> ActorController::getActors(std::shared_ptr<Player> player)
std::vector<std::shared_ptr<Actor>> ActorController::getActors(std::shared_ptr<Player> player, const ESM::Cell &cell)
{
Cell *serverCell = CellController::get()->getCell(&player->cell);

@ -41,12 +41,12 @@ public:
~ActorController();
std::shared_ptr<Actor> createActor();
void sendActors(std::shared_ptr<Player> player, std::vector<std::shared_ptr<Actor>> actors, bool sendToAll = false);
void sendList(std::shared_ptr<Player> player, std::vector<std::shared_ptr<Actor>> actors, bool sendToAll = false);
void sendActors(std::shared_ptr<Player> player, std::vector<std::shared_ptr<Actor>> actors, const ESM::Cell &cell, bool sendToAll = false);
void sendList(std::shared_ptr<Player> player, std::vector<std::shared_ptr<Actor>> actors, const ESM::Cell &cell, bool sendToAll = false);
void requestList(std::shared_ptr<Player> player);
void requestList(std::shared_ptr<Player> player, const ESM::Cell &cell);
std::vector<std::shared_ptr<Actor>> getActors(std::shared_ptr<Player> player);
std::vector<std::shared_ptr<Actor>> getActors(std::shared_ptr<Player> player, const ESM::Cell &cell);
private:
mwmp::BaseActorList actorList;

@ -257,12 +257,14 @@ void ObjectController::Init(LuaState &lua)
{
sol::table objectCtrl = lua.getState()->create_table("ObjectCtrl");
objectCtrl.set_function("sendObjects", [&lua](shared_ptr<Player> player, shared_ptr<vector<shared_ptr<Object>>> objects) {
return lua.getObjectCtrl().sendObjects(player, objects);
objectCtrl.set_function("sendObjects", [&lua](shared_ptr<Player> player, shared_ptr<vector<shared_ptr<Object>>> objects,
const std::string &cellDescription) {
return lua.getObjectCtrl().sendObjects(player, objects, Utils::getCellFromDescription(cellDescription));
});
objectCtrl.set_function("sendContainers", [&lua](shared_ptr<Player> player, shared_ptr<vector<shared_ptr<Container>>> objects) {
return lua.getObjectCtrl().sendContainers(player, objects);
objectCtrl.set_function("sendContainers", [&lua](shared_ptr<Player> player, shared_ptr<vector<shared_ptr<Container>>> objects,
const std::string &cellDescription) {
return lua.getObjectCtrl().sendContainers(player, objects, Utils::getCellFromDescription(cellDescription));
});
objectCtrl.set_function("requestContainers", [&lua](shared_ptr<Player> player) {
@ -300,7 +302,7 @@ shared_ptr<vector<shared_ptr<Container>>> ObjectController::copyContainers(mwmp:
return containers;
}
void ObjectController::sendObjects(shared_ptr<Player> player, shared_ptr<vector<shared_ptr<Object>>> objects)
void ObjectController::sendObjects(shared_ptr<Player> player, shared_ptr<vector<shared_ptr<Object>>> objects, const ESM::Cell &cell)
{
enum Type
{
@ -321,7 +323,7 @@ void ObjectController::sendObjects(shared_ptr<Player> player, shared_ptr<vector<
{
e.action = mwmp::BaseEvent::SET;
e.guid = player->guid;
e.cell = player->cell;
e.cell = cell;
}
@ -433,11 +435,11 @@ void ObjectController::sendObjects(shared_ptr<Player> player, shared_ptr<vector<
}
}
void ObjectController::sendContainers(shared_ptr<Player> player, shared_ptr<vector<shared_ptr<Container>>> objects)
void ObjectController::sendContainers(shared_ptr<Player> player, shared_ptr<vector<shared_ptr<Container>>> objects, const ESM::Cell &cell)
{
mwmp::BaseEvent event;
event.cell = player->cell;
event.cell = cell;
event.action = mwmp::BaseEvent::SET;
event.guid = player->guid;

@ -112,8 +112,8 @@ public:
std::shared_ptr<std::vector<std::shared_ptr<Object>>> copyObjects(mwmp::BaseEvent &event);
std::shared_ptr<std::vector<std::shared_ptr<Container>>> copyContainers(mwmp::BaseEvent &event);
void sendObjects(std::shared_ptr<Player> player, std::shared_ptr<std::vector<std::shared_ptr<Object>>> objects);
void sendContainers(std::shared_ptr<Player> player, std::shared_ptr<std::vector<std::shared_ptr<Container>>> objects);
void sendObjects(std::shared_ptr<Player> player, std::shared_ptr<std::vector<std::shared_ptr<Object>>> objects, const ESM::Cell &cell);
void sendContainers(std::shared_ptr<Player> player, std::shared_ptr<std::vector<std::shared_ptr<Container>>> objects, const ESM::Cell &cell);
void requestContainers(std::shared_ptr<Player> player);
};

@ -32,7 +32,7 @@ namespace mwmp
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_ACTOR_CELL_CHANGE>(player, actors);
Networking::get().getState().getActorCtrl().sendActors(player, actors, true);
Networking::get().getState().getActorCtrl().sendActors(player, actors, actorList.cell, true);
// Send this to everyone
packet.Send(true);

@ -27,7 +27,7 @@ namespace mwmp
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_ACTOR_EQUIPMENT>(player, actors);
Networking::get().getState().getActorCtrl().sendActors(player, actors, true);
Networking::get().getState().getActorCtrl().sendActors(player, actors, actorList.cell, true);
}
};
}

@ -28,7 +28,7 @@ namespace mwmp
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_ACTOR_LIST>(player, actors);
Networking::get().getState().getActorCtrl().sendActors(player, actors, true);
Networking::get().getState().getActorCtrl().sendActors(player, actors, actorList.cell, true);
}
};
}

@ -26,7 +26,7 @@ namespace mwmp
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_ACTOR_TEST>(player, actors);
Networking::get().getState().getActorCtrl().sendActors(player, actors, true);
Networking::get().getState().getActorCtrl().sendActors(player, actors, actorList.cell, true);
}
};
}

@ -30,7 +30,7 @@ namespace mwmp
player->message("#FF0000Command not found.\n"); // inform player that command not found
break;
case CommandController::ExecResult::NOT_CMD: // cmd length < 2 or message is not cmd
lua.getEventCtrl().Call<CoreEvent::ON_PLAYER_SENDMESSAGE, bool>(player, player->chatMessage);
lua.getEventCtrl().Call<CoreEvent::ON_PLAYER_SENDMESSAGE>(player, player->chatMessage);
break;
case CommandController::ExecResult::SUCCESS: // returned true from function
break;

@ -38,7 +38,7 @@ namespace mwmp
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_CONTAINER>(player, containers);
Networking::get().getState().getObjectCtrl().sendContainers(player, containers);
Networking::get().getState().getObjectCtrl().sendContainers(player, containers, event.cell);
LOG_APPEND(Log::LOG_INFO, "- Finished processing ID_CONTAINER");
}

@ -22,7 +22,7 @@ namespace mwmp
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_DOOR_STATE>(player, objects);
objCtrl.sendObjects(player, objects);
objCtrl.sendObjects(player, objects, event.cell);
}
};
}

@ -24,7 +24,7 @@ namespace mwmp
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_OBJECT_DELETE>(player, objects);
objCtrl.sendObjects(player, objects);
objCtrl.sendObjects(player, objects, event.cell);
}
};
}

@ -24,7 +24,7 @@ namespace mwmp
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_OBJECT_LOCK>(player, objects);
objCtrl.sendObjects(player, objects);
objCtrl.sendObjects(player, objects, event.cell);
}
};
}

@ -33,7 +33,7 @@ namespace mwmp
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_OBJECT_PLACE>(player, objects);
objCtrl.sendObjects(player, objects);
objCtrl.sendObjects(player, objects, event.cell);
}
};
}

@ -24,7 +24,7 @@ namespace mwmp
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_OBJECT_SCALE>(player, objects);
objCtrl.sendObjects(player, objects);
objCtrl.sendObjects(player, objects, event.cell);
}
};
}

@ -33,7 +33,7 @@ namespace mwmp
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_OBJECT_SCALE>(player, objects);
objCtrl.sendObjects(player, objects);
objCtrl.sendObjects(player, objects, event.cell);
}
};
}

@ -24,7 +24,7 @@ namespace mwmp
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_OBJECT_STATE>(player, objects);
objCtrl.sendObjects(player, objects);
objCtrl.sendObjects(player, objects, event.cell);
}
};
}

@ -24,7 +24,7 @@ namespace mwmp
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_OBJECT_TRAP>(player, objects);
objCtrl.sendObjects(player, objects);
objCtrl.sendObjects(player, objects, event.cell);
}
};
}

Loading…
Cancel
Save