forked from teamnwah/openmw-tes3coop
[General] Sketch out most of functionality for journal saving/loading
parent
c3c3c57a98
commit
35e453dec3
@ -0,0 +1,79 @@
|
||||
#include "Quests.hpp"
|
||||
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
#include <apps/openmw-mp/Networking.hpp>
|
||||
#include <components/misc/stringops.hpp>
|
||||
|
||||
using namespace mwmp;
|
||||
|
||||
unsigned int QuestFunctions::GetJournalChangesSize(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, 0);
|
||||
|
||||
return player->journalChanges.count;
|
||||
}
|
||||
|
||||
void QuestFunctions::AddJournalEntry(unsigned short pid, const char* quest, unsigned int index) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
mwmp::JournalItem journalItem;
|
||||
journalItem.type = JournalItem::ENTRY;
|
||||
journalItem.quest = quest;
|
||||
journalItem.index = index;
|
||||
|
||||
player->journalChangesBuffer.journalItems.push_back(journalItem);
|
||||
}
|
||||
|
||||
void QuestFunctions::AddJournalIndex(unsigned short pid, const char* quest, unsigned int index) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
mwmp::JournalItem journalItem;
|
||||
journalItem.type = JournalItem::INDEX;
|
||||
journalItem.quest = quest;
|
||||
journalItem.index = index;
|
||||
|
||||
player->journalChangesBuffer.journalItems.push_back(journalItem);
|
||||
}
|
||||
|
||||
const char *QuestFunctions::GetJournalItemQuest(unsigned short pid, unsigned int i) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, "");
|
||||
|
||||
if (i >= player->journalChanges.count)
|
||||
return "invalid";
|
||||
|
||||
return player->journalChanges.journalItems.at(i).quest.c_str();
|
||||
}
|
||||
|
||||
int QuestFunctions::GetJournalItemIndex(unsigned short pid, unsigned int i) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, 0);
|
||||
|
||||
return player->journalChanges.journalItems.at(i).index;
|
||||
}
|
||||
|
||||
int QuestFunctions::GetJournalItemType(unsigned short pid, unsigned int i) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, 0);
|
||||
|
||||
return player->journalChanges.journalItems.at(i).type;
|
||||
}
|
||||
|
||||
void QuestFunctions::SendJournalChanges(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
std::swap(player->journalChanges, player->journalChangesBuffer);
|
||||
mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_JOURNAL)->Send(player, false);
|
||||
player->journalChanges = std::move(player->journalChangesBuffer);
|
||||
player->journalChangesBuffer.journalItems.clear();
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
#ifndef OPENMW_QUESTS_HPP
|
||||
#define OPENMW_QUESTS_HPP
|
||||
|
||||
#define QUESTAPI \
|
||||
{"GetJournalChangesSize", QuestFunctions::GetJournalChangesSize},\
|
||||
\
|
||||
{"AddJournalIndex", QuestFunctions::AddJournalIndex},\
|
||||
\
|
||||
{"GetJournalItemQuest", QuestFunctions::GetJournalItemQuest},\
|
||||
{"GetJournalItemIndex", QuestFunctions::GetJournalItemIndex},\
|
||||
{"GetJournalItemType", QuestFunctions::GetJournalItemType},\
|
||||
\
|
||||
{"SendJournalChanges", QuestFunctions::SendJournalChanges}
|
||||
|
||||
class QuestFunctions
|
||||
{
|
||||
public:
|
||||
|
||||
static unsigned int GetJournalChangesSize(unsigned short pid) noexcept;
|
||||
|
||||
static void AddJournalEntry(unsigned short pid, const char* quest, unsigned int index) noexcept;
|
||||
static void AddJournalIndex(unsigned short pid, const char* quest, unsigned int index) noexcept;
|
||||
|
||||
static const char *GetJournalItemQuest(unsigned short pid, unsigned int i) noexcept;
|
||||
static int GetJournalItemIndex(unsigned short pid, unsigned int i) noexcept;
|
||||
static int GetJournalItemType(unsigned short pid, unsigned int i) noexcept;
|
||||
|
||||
static void SendJournalChanges(unsigned short pid) noexcept;
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif //OPENMW_QUESTS_HPP
|
Loading…
Reference in New Issue