#include "Books.h" #include #include #include using namespace mwmp; extern "C" void BookFunctions::ClearBookChanges(PlayerId pid) noexcept { Player *player; GET_PLAYER(pid, player, ); player->bookChanges.books.clear(); } extern "C" unsigned int BookFunctions::GetBookChangesSize(PlayerId pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); return player->bookChanges.count; } extern "C" void BookFunctions::AddBook(PlayerId 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(PlayerId 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(PlayerId 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(PlayerId pid) noexcept { ClearBookChanges(pid); }