You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.7 KiB
C++
69 lines
1.7 KiB
C++
#include "Books.hpp"
|
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
|
#include <apps/openmw-mp/Networking.hpp>
|
|
|
|
using namespace mwmp;
|
|
|
|
extern "C" void BookFunctions::ClearBookChanges(unsigned short pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, );
|
|
|
|
player->bookChanges.books.clear();
|
|
}
|
|
|
|
extern "C" unsigned int BookFunctions::GetBookChangesSize(unsigned short pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
return player->bookChanges.count;
|
|
}
|
|
|
|
extern "C" void BookFunctions::AddBook(unsigned short pid, const char* bookId) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, );
|
|
|
|
mwmp::Book book;
|
|
book.bookId = bookId;
|
|
|
|
player->bookChanges.books.push_back(book);
|
|
}
|
|
|
|
extern "C" const char *BookFunctions::GetBookId(unsigned short pid, unsigned int index) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, "");
|
|
|
|
if (index >= player->bookChanges.count)
|
|
return "invalid";
|
|
|
|
return player->bookChanges.books.at(index).bookId.c_str();
|
|
}
|
|
|
|
extern "C" void BookFunctions::SendBookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, );
|
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_BOOK);
|
|
|
|
packet->setPlayer(player);
|
|
|
|
if (!skipAttachedPlayer)
|
|
packet->Send(false);
|
|
if (sendToOtherPlayers)
|
|
packet->Send(true);
|
|
}
|
|
|
|
// All methods below are deprecated versions of methods from above
|
|
|
|
extern "C" void BookFunctions::InitializeBookChanges(unsigned short pid) noexcept
|
|
{
|
|
ClearBookChanges(pid);
|
|
}
|