mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 13:15:32 +00:00
[Server] Rework script functons by removing unnecessary vector buffers
Add new initialization script functions to allow clearing all player changes vectors in a manner consistent with Actor and World functions Add toOthers boolean to all methods that send packets with player changes vectors
This commit is contained in:
parent
2c05b7f747
commit
6dde0ca9c9
15 changed files with 188 additions and 140 deletions
|
@ -70,16 +70,6 @@ public:
|
|||
|
||||
void forEachLoaded(std::function<void(Player *pl, Player *other)> func);
|
||||
|
||||
public:
|
||||
mwmp::InventoryChanges inventoryChangesBuffer;
|
||||
mwmp::SpellbookChanges spellbookChangesBuffer;
|
||||
mwmp::JournalChanges journalChangesBuffer;
|
||||
mwmp::FactionChanges factionChangesBuffer;
|
||||
mwmp::TopicChanges topicChangesBuffer;
|
||||
mwmp::KillChanges killChangesBuffer;
|
||||
mwmp::BookChanges bookChangesBuffer;
|
||||
mwmp::MapChanges mapChangesBuffer;
|
||||
|
||||
private:
|
||||
CellController::TContainer cells;
|
||||
bool handshakeState;
|
||||
|
|
|
@ -5,6 +5,14 @@
|
|||
|
||||
using namespace mwmp;
|
||||
|
||||
void BookFunctions::InitializeBookChanges(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
return player->bookChanges.books.clear();
|
||||
}
|
||||
|
||||
unsigned int BookFunctions::GetBookChangesSize(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
|
@ -21,7 +29,7 @@ void BookFunctions::AddBook(unsigned short pid, const char* bookId) noexcept
|
|||
mwmp::Book book;
|
||||
book.bookId = bookId;
|
||||
|
||||
player->bookChangesBuffer.books.push_back(book);
|
||||
player->bookChanges.books.push_back(book);
|
||||
}
|
||||
|
||||
const char *BookFunctions::GetBookId(unsigned short pid, unsigned int i) noexcept
|
||||
|
@ -35,14 +43,11 @@ const char *BookFunctions::GetBookId(unsigned short pid, unsigned int i) noexcep
|
|||
return player->bookChanges.books.at(i).bookId.c_str();
|
||||
}
|
||||
|
||||
void BookFunctions::SendBookChanges(unsigned short pid) noexcept
|
||||
void BookFunctions::SendBookChanges(unsigned short pid, bool toOthers) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
std::swap(player->bookChanges, player->bookChangesBuffer);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_BOOK)->setPlayer(player);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_BOOK)->Send(false);
|
||||
player->bookChanges = std::move(player->bookChangesBuffer);
|
||||
player->bookChangesBuffer.books.clear();
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_BOOK)->Send(toOthers);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#define OPENMW_BOOKAPI_HPP
|
||||
|
||||
#define BOOKAPI \
|
||||
{"InitializeBookChanges", BookFunctions::InitializeBookChanges},\
|
||||
\
|
||||
{"GetBookChangesSize", BookFunctions::GetBookChangesSize},\
|
||||
\
|
||||
{"AddBook", BookFunctions::AddBook},\
|
||||
|
@ -14,13 +16,15 @@ class BookFunctions
|
|||
{
|
||||
public:
|
||||
|
||||
static void InitializeBookChanges(unsigned short pid) noexcept;
|
||||
|
||||
static unsigned int GetBookChangesSize(unsigned short pid) noexcept;
|
||||
|
||||
static void AddBook(unsigned short pid, const char* bookId) noexcept;
|
||||
|
||||
static const char *GetBookId(unsigned short pid, unsigned int i) noexcept;
|
||||
|
||||
static void SendBookChanges(unsigned short pid) noexcept;
|
||||
static void SendBookChanges(unsigned short pid, bool toOthers = false) noexcept;
|
||||
private:
|
||||
|
||||
};
|
||||
|
|
|
@ -10,6 +10,14 @@ using namespace std;
|
|||
|
||||
static std::string tempCellDescription;
|
||||
|
||||
void CellFunctions::InitializeMapChanges(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->mapChanges.cellsExplored.clear();
|
||||
}
|
||||
|
||||
unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
|
@ -119,7 +127,7 @@ void CellFunctions::AddCellExplored(unsigned short pid, const char* cellDescript
|
|||
GET_PLAYER(pid, player, );
|
||||
|
||||
ESM::Cell cellExplored = Utils::getCellFromDescription(cellDescription);
|
||||
player->mapChangesBuffer.cellsExplored.push_back(cellExplored);
|
||||
player->mapChanges.cellsExplored.push_back(cellExplored);
|
||||
}
|
||||
|
||||
void CellFunctions::SendCell(unsigned short pid) noexcept
|
||||
|
@ -131,14 +139,11 @@ void CellFunctions::SendCell(unsigned short pid) noexcept
|
|||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CELL_CHANGE)->Send(false);
|
||||
}
|
||||
|
||||
void CellFunctions::SendMapChanges(unsigned short pid) noexcept
|
||||
void CellFunctions::SendMapChanges(unsigned short pid, bool toOthers) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
std::swap(player->mapChanges, player->mapChangesBuffer);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MAP)->setPlayer(player);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MAP)->Send(false);
|
||||
player->mapChanges = std::move(player->mapChangesBuffer);
|
||||
player->mapChangesBuffer.cellsExplored.clear();
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MAP)->Send(toOthers);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include "../Types.hpp"
|
||||
|
||||
#define CELLAPI \
|
||||
{"InitializeMapChanges", CellFunctions::InitializeMapChanges},\
|
||||
\
|
||||
{"GetCellStateChangesSize", CellFunctions::GetCellStateChangesSize},\
|
||||
\
|
||||
{"GetCellStateType", CellFunctions::GetCellStateType},\
|
||||
|
@ -28,6 +30,9 @@
|
|||
class CellFunctions
|
||||
{
|
||||
public:
|
||||
|
||||
static void InitializeMapChanges(unsigned short pid) noexcept;
|
||||
|
||||
static unsigned int GetCellStateChangesSize(unsigned short pid) noexcept;
|
||||
|
||||
static unsigned int GetCellStateType(unsigned short pid, unsigned int i) noexcept;
|
||||
|
@ -46,7 +51,7 @@ public:
|
|||
static void AddCellExplored(unsigned short pid, const char* cellDescription) noexcept;
|
||||
|
||||
static void SendCell(unsigned short pid) noexcept;
|
||||
static void SendMapChanges(unsigned short pid) noexcept;
|
||||
static void SendMapChanges(unsigned short pid, bool toOthers = false) noexcept;
|
||||
};
|
||||
|
||||
#endif //OPENMW_CELLAPI_HPP
|
||||
|
|
|
@ -5,6 +5,22 @@
|
|||
|
||||
using namespace mwmp;
|
||||
|
||||
void DialogueFunctions::InitializeTopicChanges(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->topicChanges.topics.clear();
|
||||
}
|
||||
|
||||
void DialogueFunctions::InitializeKillChanges(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->killChanges.kills.clear();
|
||||
}
|
||||
|
||||
unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
|
@ -29,7 +45,7 @@ void DialogueFunctions::AddTopic(unsigned short pid, const char* topicId) noexce
|
|||
mwmp::Topic topic;
|
||||
topic.topicId = topicId;
|
||||
|
||||
player->topicChangesBuffer.topics.push_back(topic);
|
||||
player->topicChanges.topics.push_back(topic);
|
||||
}
|
||||
|
||||
void DialogueFunctions::AddKill(unsigned short pid, const char* refId, int number) noexcept
|
||||
|
@ -41,7 +57,7 @@ void DialogueFunctions::AddKill(unsigned short pid, const char* refId, int numbe
|
|||
kill.refId = refId;
|
||||
kill.number = number;
|
||||
|
||||
player->killChangesBuffer.kills.push_back(kill);
|
||||
player->killChanges.kills.push_back(kill);
|
||||
}
|
||||
|
||||
const char *DialogueFunctions::GetTopicId(unsigned short pid, unsigned int i) noexcept
|
||||
|
@ -74,26 +90,20 @@ int DialogueFunctions::GetKillNumber(unsigned short pid, unsigned int i) noexcep
|
|||
return player->killChanges.kills.at(i).number;
|
||||
}
|
||||
|
||||
void DialogueFunctions::SendTopicChanges(unsigned short pid) noexcept
|
||||
void DialogueFunctions::SendTopicChanges(unsigned short pid, bool toOthers) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
std::swap(player->topicChanges, player->topicChangesBuffer);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_TOPIC)->setPlayer(player);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_TOPIC)->Send(false);
|
||||
player->topicChanges = std::move(player->topicChangesBuffer);
|
||||
player->topicChangesBuffer.topics.clear();
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_TOPIC)->Send(toOthers);
|
||||
}
|
||||
|
||||
void DialogueFunctions::SendKillChanges(unsigned short pid) noexcept
|
||||
void DialogueFunctions::SendKillChanges(unsigned short pid, bool toOthers) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
std::swap(player->killChanges, player->killChangesBuffer);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_KILL_COUNT)->setPlayer(player);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_KILL_COUNT)->Send(false);
|
||||
player->killChanges = std::move(player->killChangesBuffer);
|
||||
player->killChangesBuffer.kills.clear();
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_KILL_COUNT)->Send(toOthers);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
#define OPENMW_DIALOGUEAPI_HPP
|
||||
|
||||
#define DIALOGUEAPI \
|
||||
{"InitializeTopicChanges", DialogueFunctions::InitializeTopicChanges},\
|
||||
{"InitializeKillChanges", DialogueFunctions::InitializeKillChanges},\
|
||||
\
|
||||
{"GetTopicChangesSize", DialogueFunctions::GetTopicChangesSize},\
|
||||
{"GetKillChangesSize", DialogueFunctions::GetKillChangesSize},\
|
||||
\
|
||||
|
@ -19,6 +22,9 @@ class DialogueFunctions
|
|||
{
|
||||
public:
|
||||
|
||||
static void InitializeTopicChanges(unsigned short pid) noexcept;
|
||||
static void InitializeKillChanges(unsigned short pid) noexcept;
|
||||
|
||||
static unsigned int GetTopicChangesSize(unsigned short pid) noexcept;
|
||||
static unsigned int GetKillChangesSize(unsigned short pid) noexcept;
|
||||
|
||||
|
@ -29,8 +35,8 @@ public:
|
|||
static const char *GetKillRefId(unsigned short pid, unsigned int i) noexcept;
|
||||
static int GetKillNumber(unsigned short pid, unsigned int i) noexcept;
|
||||
|
||||
static void SendTopicChanges(unsigned short pid) noexcept;
|
||||
static void SendKillChanges(unsigned short pid) noexcept;
|
||||
static void SendTopicChanges(unsigned short pid, bool toOthers = false) noexcept;
|
||||
static void SendKillChanges(unsigned short pid, bool toOthers = false) noexcept;
|
||||
private:
|
||||
|
||||
};
|
||||
|
|
|
@ -6,6 +6,14 @@
|
|||
|
||||
using namespace mwmp;
|
||||
|
||||
void FactionFunctions::InitializeFactionChanges(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->factionChanges.factions.clear();
|
||||
}
|
||||
|
||||
unsigned int FactionFunctions::GetFactionChangesSize(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
|
@ -22,19 +30,6 @@ unsigned char FactionFunctions::GetFactionChangesAction(unsigned short pid) noex
|
|||
return player->factionChanges.action;
|
||||
}
|
||||
|
||||
void FactionFunctions::AddFaction(unsigned short pid, const char* factionId, unsigned int rank, bool isExpelled) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
mwmp::Faction faction;
|
||||
faction.factionId = factionId;
|
||||
faction.rank = rank;
|
||||
faction.isExpelled = isExpelled;
|
||||
|
||||
player->factionChangesBuffer.factions.push_back(faction);
|
||||
}
|
||||
|
||||
const char *FactionFunctions::GetFactionId(unsigned short pid, unsigned int i) noexcept
|
||||
{
|
||||
Player *player;
|
||||
|
@ -62,16 +57,32 @@ bool FactionFunctions::GetFactionExpelledState(unsigned short pid, unsigned int
|
|||
return player->factionChanges.factions.at(i).isExpelled;
|
||||
}
|
||||
|
||||
void FactionFunctions::SendFactionChanges(unsigned short pid) noexcept
|
||||
void FactionFunctions::SetFactionChangesAction(unsigned short pid, unsigned char action) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->factionChangesBuffer.action = mwmp::FactionChanges::BOTH;
|
||||
|
||||
std::swap(player->factionChanges, player->factionChangesBuffer);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_FACTION)->setPlayer(player);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_FACTION)->Send(false);
|
||||
player->factionChanges = std::move(player->factionChangesBuffer);
|
||||
player->factionChangesBuffer.factions.clear();
|
||||
player->factionChanges.action = action;
|
||||
}
|
||||
|
||||
void FactionFunctions::AddFaction(unsigned short pid, const char* factionId, unsigned int rank, bool isExpelled) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
mwmp::Faction faction;
|
||||
faction.factionId = factionId;
|
||||
faction.rank = rank;
|
||||
faction.isExpelled = isExpelled;
|
||||
|
||||
player->factionChanges.factions.push_back(faction);
|
||||
}
|
||||
|
||||
void FactionFunctions::SendFactionChanges(unsigned short pid, bool toOthers) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_FACTION)->setPlayer(player);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_FACTION)->Send(toOthers);
|
||||
}
|
||||
|
|
|
@ -2,31 +2,37 @@
|
|||
#define OPENMW_FACTIONAPI_HPP
|
||||
|
||||
#define FACTIONAPI \
|
||||
{"GetFactionChangesSize", FactionFunctions::GetFactionChangesSize},\
|
||||
{"GetFactionChangesAction", FactionFunctions::GetFactionChangesAction},\
|
||||
{"InitializeFactionChanges", FactionFunctions::InitializeFactionChanges},\
|
||||
\
|
||||
{"AddFaction", FactionFunctions::AddFaction},\
|
||||
{"GetFactionChangesSize", FactionFunctions::GetFactionChangesSize},\
|
||||
{"GetFactionChangesAction", FactionFunctions::GetFactionChangesAction},\
|
||||
\
|
||||
{"GetFactionId", FactionFunctions::GetFactionId},\
|
||||
{"GetFactionRank", FactionFunctions::GetFactionRank},\
|
||||
{"GetFactionExpelledState", FactionFunctions::GetFactionExpelledState},\
|
||||
{"GetFactionId", FactionFunctions::GetFactionId},\
|
||||
{"GetFactionRank", FactionFunctions::GetFactionRank},\
|
||||
{"GetFactionExpelledState", FactionFunctions::GetFactionExpelledState},\
|
||||
\
|
||||
{"SendFactionChanges", FactionFunctions::SendFactionChanges}
|
||||
{"SetFactionChangesAction", FactionFunctions::SetFactionChangesAction},\
|
||||
{"AddFaction", FactionFunctions::AddFaction},\
|
||||
\
|
||||
{"SendFactionChanges", FactionFunctions::SendFactionChanges}
|
||||
|
||||
class FactionFunctions
|
||||
{
|
||||
public:
|
||||
|
||||
static void InitializeFactionChanges(unsigned short pid) noexcept;
|
||||
|
||||
static unsigned int GetFactionChangesSize(unsigned short pid) noexcept;
|
||||
static unsigned char GetFactionChangesAction(unsigned short pid) noexcept;
|
||||
|
||||
static void AddFaction(unsigned short pid, const char* factionId, unsigned int rank, bool isExpelled) noexcept;
|
||||
|
||||
static const char *GetFactionId(unsigned short pid, unsigned int i) noexcept;
|
||||
static int GetFactionRank(unsigned short pid, unsigned int i) noexcept;
|
||||
static bool GetFactionExpelledState(unsigned short pid, unsigned int i) noexcept;
|
||||
|
||||
static void SendFactionChanges(unsigned short pid) noexcept;
|
||||
static void SetFactionChangesAction(unsigned short pid, unsigned char action) noexcept;
|
||||
static void AddFaction(unsigned short pid, const char* factionId, unsigned int rank, bool isExpelled) noexcept;
|
||||
|
||||
static void SendFactionChanges(unsigned short pid, bool toOthers = false) noexcept;
|
||||
private:
|
||||
|
||||
};
|
||||
|
|
|
@ -11,6 +11,15 @@
|
|||
|
||||
using namespace mwmp;
|
||||
|
||||
void ItemFunctions::InitializeInventoryChanges(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->inventoryChanges.items.clear();
|
||||
player->inventoryChanges.action = InventoryChanges::SET;
|
||||
}
|
||||
|
||||
int ItemFunctions::GetEquipmentSize() noexcept
|
||||
{
|
||||
return MWWorld::InventoryStore::Slots;
|
||||
|
@ -52,8 +61,8 @@ void ItemFunctions::AddItem(unsigned short pid, const char* refId, unsigned int
|
|||
item.count = count;
|
||||
item.charge = charge;
|
||||
|
||||
player->inventoryChangesBuffer.items.push_back(item);
|
||||
player->inventoryChangesBuffer.action = InventoryChanges::ADD;
|
||||
player->inventoryChanges.items.push_back(item);
|
||||
player->inventoryChanges.action = InventoryChanges::ADD;
|
||||
}
|
||||
|
||||
void ItemFunctions::RemoveItem(unsigned short pid, const char* refId, unsigned short count) noexcept
|
||||
|
@ -65,17 +74,8 @@ void ItemFunctions::RemoveItem(unsigned short pid, const char* refId, unsigned s
|
|||
item.refId = refId;
|
||||
item.count = count;
|
||||
|
||||
player->inventoryChangesBuffer.items.push_back(item);
|
||||
player->inventoryChangesBuffer.action = InventoryChanges::REMOVE;
|
||||
}
|
||||
|
||||
void ItemFunctions::ClearInventory(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->inventoryChangesBuffer.items.clear();
|
||||
player->inventoryChangesBuffer.action = InventoryChanges::SET;
|
||||
player->inventoryChanges.items.push_back(item);
|
||||
player->inventoryChanges.action = InventoryChanges::REMOVE;
|
||||
}
|
||||
|
||||
bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* refId)
|
||||
|
@ -150,14 +150,11 @@ void ItemFunctions::SendEquipment(unsigned short pid) noexcept
|
|||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_EQUIPMENT)->Send(true);
|
||||
}
|
||||
|
||||
void ItemFunctions::SendInventoryChanges(unsigned short pid) noexcept
|
||||
void ItemFunctions::SendInventoryChanges(unsigned short pid, bool toOthers) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
std::swap(player->inventoryChanges, player->inventoryChangesBuffer);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_INVENTORY)->setPlayer(player);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_INVENTORY)->Send(false);
|
||||
player->inventoryChanges = std::move(player->inventoryChangesBuffer);
|
||||
player->inventoryChangesBuffer.items.clear();
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_INVENTORY)->Send(toOthers);
|
||||
}
|
||||
|
|
|
@ -6,33 +6,36 @@
|
|||
#define OPENMW_ITEMAPI_HPP
|
||||
|
||||
#define ITEMAPI \
|
||||
{"GetEquipmentSize", ItemFunctions::GetEquipmentSize},\
|
||||
{"GetInventoryChangesSize", ItemFunctions::GetInventoryChangesSize},\
|
||||
{"InitializeInventoryChanges", ItemFunctions::InitializeInventoryChanges},\
|
||||
\
|
||||
{"EquipItem", ItemFunctions::EquipItem},\
|
||||
{"UnequipItem", ItemFunctions::UnequipItem},\
|
||||
{"GetEquipmentSize", ItemFunctions::GetEquipmentSize},\
|
||||
{"GetInventoryChangesSize", ItemFunctions::GetInventoryChangesSize},\
|
||||
\
|
||||
{"AddItem", ItemFunctions::AddItem},\
|
||||
{"RemoveItem", ItemFunctions::RemoveItem},\
|
||||
{"ClearInventory", ItemFunctions::ClearInventory},\
|
||||
{"EquipItem", ItemFunctions::EquipItem},\
|
||||
{"UnequipItem", ItemFunctions::UnequipItem},\
|
||||
\
|
||||
{"HasItemEquipped", ItemFunctions::HasItemEquipped},\
|
||||
{"AddItem", ItemFunctions::AddItem},\
|
||||
{"RemoveItem", ItemFunctions::RemoveItem},\
|
||||
\
|
||||
{"GetEquipmentItemRefId", ItemFunctions::GetEquipmentItemRefId},\
|
||||
{"GetEquipmentItemCount", ItemFunctions::GetEquipmentItemCount},\
|
||||
{"GetEquipmentItemCharge", ItemFunctions::GetEquipmentItemCharge},\
|
||||
{"HasItemEquipped", ItemFunctions::HasItemEquipped},\
|
||||
\
|
||||
{"GetInventoryItemRefId", ItemFunctions::GetInventoryItemRefId},\
|
||||
{"GetInventoryItemCount", ItemFunctions::GetInventoryItemCount},\
|
||||
{"GetInventoryItemCharge", ItemFunctions::GetInventoryItemCharge},\
|
||||
{"GetEquipmentItemRefId", ItemFunctions::GetEquipmentItemRefId},\
|
||||
{"GetEquipmentItemCount", ItemFunctions::GetEquipmentItemCount},\
|
||||
{"GetEquipmentItemCharge", ItemFunctions::GetEquipmentItemCharge},\
|
||||
\
|
||||
{"SendEquipment", ItemFunctions::SendEquipment},\
|
||||
{"SendInventoryChanges", ItemFunctions::SendInventoryChanges}
|
||||
{"GetInventoryItemRefId", ItemFunctions::GetInventoryItemRefId},\
|
||||
{"GetInventoryItemCount", ItemFunctions::GetInventoryItemCount},\
|
||||
{"GetInventoryItemCharge", ItemFunctions::GetInventoryItemCharge},\
|
||||
\
|
||||
{"SendEquipment", ItemFunctions::SendEquipment},\
|
||||
{"SendInventoryChanges", ItemFunctions::SendInventoryChanges}
|
||||
|
||||
class ItemFunctions
|
||||
{
|
||||
public:
|
||||
|
||||
static void InitializeInventoryChanges(unsigned short pid) noexcept;
|
||||
|
||||
static int GetEquipmentSize() noexcept;
|
||||
static unsigned int GetInventoryChangesSize(unsigned short pid) noexcept;
|
||||
|
||||
|
@ -41,7 +44,6 @@ public:
|
|||
|
||||
static void AddItem(unsigned short pid, const char* refId, unsigned int count, int charge) noexcept;
|
||||
static void RemoveItem(unsigned short pid, const char* refId, unsigned short count) noexcept;
|
||||
static void ClearInventory(unsigned short pid) noexcept;
|
||||
|
||||
static bool HasItemEquipped(unsigned short pid, const char* refId);
|
||||
|
||||
|
@ -54,7 +56,7 @@ public:
|
|||
static int GetInventoryItemCharge(unsigned short pid, unsigned int i) noexcept;
|
||||
|
||||
static void SendEquipment(unsigned short pid) noexcept;
|
||||
static void SendInventoryChanges(unsigned short pid) noexcept;
|
||||
static void SendInventoryChanges(unsigned short pid, bool toOthers = false) noexcept;
|
||||
private:
|
||||
|
||||
};
|
||||
|
|
|
@ -6,6 +6,14 @@
|
|||
|
||||
using namespace mwmp;
|
||||
|
||||
void QuestFunctions::InitializeJournalChanges(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->journalChanges.journalItems.clear();
|
||||
}
|
||||
|
||||
unsigned int QuestFunctions::GetJournalChangesSize(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
|
@ -25,7 +33,7 @@ void QuestFunctions::AddJournalEntry(unsigned short pid, const char* quest, unsi
|
|||
journalItem.index = index;
|
||||
journalItem.actorRefId = actorRefId;
|
||||
|
||||
player->journalChangesBuffer.journalItems.push_back(journalItem);
|
||||
player->journalChanges.journalItems.push_back(journalItem);
|
||||
}
|
||||
|
||||
void QuestFunctions::AddJournalIndex(unsigned short pid, const char* quest, unsigned int index) noexcept
|
||||
|
@ -38,7 +46,7 @@ void QuestFunctions::AddJournalIndex(unsigned short pid, const char* quest, unsi
|
|||
journalItem.quest = quest;
|
||||
journalItem.index = index;
|
||||
|
||||
player->journalChangesBuffer.journalItems.push_back(journalItem);
|
||||
player->journalChanges.journalItems.push_back(journalItem);
|
||||
}
|
||||
|
||||
const char *QuestFunctions::GetJournalItemQuest(unsigned short pid, unsigned int i) noexcept
|
||||
|
@ -76,14 +84,11 @@ const char *QuestFunctions::GetJournalItemActorRefId(unsigned short pid, unsigne
|
|||
return player->journalChanges.journalItems.at(i).actorRefId.c_str();
|
||||
}
|
||||
|
||||
void QuestFunctions::SendJournalChanges(unsigned short pid) noexcept
|
||||
void QuestFunctions::SendJournalChanges(unsigned short pid, bool toOthers) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
std::swap(player->journalChanges, player->journalChangesBuffer);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_JOURNAL)->setPlayer(player);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_JOURNAL)->Send(false);
|
||||
player->journalChanges = std::move(player->journalChangesBuffer);
|
||||
player->journalChangesBuffer.journalItems.clear();
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_JOURNAL)->Send(toOthers);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#define OPENMW_QUESTAPI_HPP
|
||||
|
||||
#define QUESTAPI \
|
||||
{"InitializeJournalChanges", QuestFunctions::InitializeJournalChanges},\
|
||||
\
|
||||
{"GetJournalChangesSize", QuestFunctions::GetJournalChangesSize},\
|
||||
\
|
||||
{"AddJournalEntry", QuestFunctions::AddJournalEntry},\
|
||||
|
@ -17,6 +19,7 @@
|
|||
class QuestFunctions
|
||||
{
|
||||
public:
|
||||
static void InitializeJournalChanges(unsigned short pid) noexcept;
|
||||
|
||||
static unsigned int GetJournalChangesSize(unsigned short pid) noexcept;
|
||||
|
||||
|
@ -28,7 +31,7 @@ public:
|
|||
static int GetJournalItemType(unsigned short pid, unsigned int i) noexcept;
|
||||
static const char *GetJournalItemActorRefId(unsigned short pid, unsigned int i) noexcept;
|
||||
|
||||
static void SendJournalChanges(unsigned short pid) noexcept;
|
||||
static void SendJournalChanges(unsigned short pid, bool toOthers = false) noexcept;
|
||||
private:
|
||||
|
||||
};
|
||||
|
|
|
@ -6,6 +6,15 @@
|
|||
|
||||
using namespace mwmp;
|
||||
|
||||
void SpellFunctions::InitializeSpellbookChanges(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->spellbookChanges.spells.clear();
|
||||
player->spellbookChanges.action = SpellbookChanges::SET;
|
||||
}
|
||||
|
||||
unsigned int SpellFunctions::GetSpellbookChangesSize(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
|
@ -30,8 +39,8 @@ void SpellFunctions::AddSpell(unsigned short pid, const char* spellId) noexcept
|
|||
ESM::Spell spell;
|
||||
spell.mId = spellId;
|
||||
|
||||
player->spellbookChangesBuffer.spells.push_back(spell);
|
||||
player->spellbookChangesBuffer.action = SpellbookChanges::ADD;
|
||||
player->spellbookChanges.spells.push_back(spell);
|
||||
player->spellbookChanges.action = SpellbookChanges::ADD;
|
||||
}
|
||||
|
||||
void SpellFunctions::RemoveSpell(unsigned short pid, const char* spellId) noexcept
|
||||
|
@ -42,17 +51,8 @@ void SpellFunctions::RemoveSpell(unsigned short pid, const char* spellId) noexce
|
|||
ESM::Spell spell;
|
||||
spell.mId = spellId;
|
||||
|
||||
player->spellbookChangesBuffer.spells.push_back(spell);
|
||||
player->spellbookChangesBuffer.action = SpellbookChanges::REMOVE;
|
||||
}
|
||||
|
||||
void SpellFunctions::ClearSpellbook(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->spellbookChangesBuffer.spells.clear();
|
||||
player->spellbookChangesBuffer.action = SpellbookChanges::SET;
|
||||
player->spellbookChanges.spells.push_back(spell);
|
||||
player->spellbookChanges.action = SpellbookChanges::REMOVE;
|
||||
}
|
||||
|
||||
const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned int i) noexcept
|
||||
|
@ -66,14 +66,11 @@ const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned int i) noexc
|
|||
return player->spellbookChanges.spells.at(i).mId.c_str();
|
||||
}
|
||||
|
||||
void SpellFunctions::SendSpellbookChanges(unsigned short pid) noexcept
|
||||
void SpellFunctions::SendSpellbookChanges(unsigned short pid, bool toOthers) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
std::swap(player->spellbookChanges, player->spellbookChangesBuffer);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SPELLBOOK)->setPlayer(player);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SPELLBOOK)->Send(false);
|
||||
player->spellbookChanges = std::move(player->spellbookChangesBuffer);
|
||||
player->spellbookChangesBuffer.spells.clear();
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SPELLBOOK)->Send(toOthers);
|
||||
}
|
||||
|
|
|
@ -2,31 +2,33 @@
|
|||
#define OPENMW_SPELLAPI_HPP
|
||||
|
||||
#define SPELLAPI \
|
||||
{"GetSpellbookChangesSize", SpellFunctions::GetSpellbookChangesSize},\
|
||||
{"GetSpellbookAction", SpellFunctions::GetSpellbookAction},\
|
||||
{"InitializeSpellbookChanges", SpellFunctions::InitializeSpellbookChanges},\
|
||||
\
|
||||
{"AddSpell", SpellFunctions::AddSpell},\
|
||||
{"RemoveSpell", SpellFunctions::RemoveSpell},\
|
||||
{"ClearSpellbook", SpellFunctions::ClearSpellbook},\
|
||||
{"GetSpellbookChangesSize", SpellFunctions::GetSpellbookChangesSize},\
|
||||
{"GetSpellbookAction", SpellFunctions::GetSpellbookAction},\
|
||||
\
|
||||
{"GetSpellId", SpellFunctions::GetSpellId},\
|
||||
{"AddSpell", SpellFunctions::AddSpell},\
|
||||
{"RemoveSpell", SpellFunctions::RemoveSpell},\
|
||||
\
|
||||
{"SendSpellbookChanges", SpellFunctions::SendSpellbookChanges}
|
||||
{"GetSpellId", SpellFunctions::GetSpellId},\
|
||||
\
|
||||
{"SendSpellbookChanges", SpellFunctions::SendSpellbookChanges}
|
||||
|
||||
class SpellFunctions
|
||||
{
|
||||
public:
|
||||
|
||||
static void InitializeSpellbookChanges(unsigned short pid) noexcept;
|
||||
|
||||
static unsigned int GetSpellbookChangesSize(unsigned short pid) noexcept;
|
||||
static unsigned int GetSpellbookAction(unsigned short pid) noexcept;
|
||||
|
||||
static void AddSpell(unsigned short pid, const char* spellId) noexcept;
|
||||
static void RemoveSpell(unsigned short pid, const char* spellId) noexcept;
|
||||
static void ClearSpellbook(unsigned short pid) noexcept;
|
||||
|
||||
static const char *GetSpellId(unsigned short pid, unsigned int i) noexcept;
|
||||
|
||||
static void SendSpellbookChanges(unsigned short pid) noexcept;
|
||||
static void SendSpellbookChanges(unsigned short pid, bool toOthers = false) noexcept;
|
||||
private:
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue