forked from mirror/openmw-tes3mp
[General] Fix PlayerJournal logic by sending only refIds for its actors
Additionally, make the refIds for actors usable in script functions.
This commit is contained in:
parent
48c63dbce9
commit
78f29302ef
5 changed files with 21 additions and 27 deletions
|
@ -14,7 +14,7 @@ unsigned int QuestFunctions::GetJournalChangesSize(unsigned short pid) noexcept
|
||||||
return player->journalChanges.count;
|
return player->journalChanges.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuestFunctions::AddJournalEntry(unsigned short pid, const char* quest, unsigned int index) noexcept
|
void QuestFunctions::AddJournalEntry(unsigned short pid, const char* quest, unsigned int index, const char* actorRefId) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, );
|
GET_PLAYER(pid, player, );
|
||||||
|
@ -23,6 +23,7 @@ void QuestFunctions::AddJournalEntry(unsigned short pid, const char* quest, unsi
|
||||||
journalItem.type = JournalItem::ENTRY;
|
journalItem.type = JournalItem::ENTRY;
|
||||||
journalItem.quest = quest;
|
journalItem.quest = quest;
|
||||||
journalItem.index = index;
|
journalItem.index = index;
|
||||||
|
journalItem.actorRefId = actorRefId;
|
||||||
|
|
||||||
player->journalChangesBuffer.journalItems.push_back(journalItem);
|
player->journalChangesBuffer.journalItems.push_back(journalItem);
|
||||||
}
|
}
|
||||||
|
@ -67,6 +68,14 @@ int QuestFunctions::GetJournalItemType(unsigned short pid, unsigned int i) noexc
|
||||||
return player->journalChanges.journalItems.at(i).type;
|
return player->journalChanges.journalItems.at(i).type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *QuestFunctions::GetJournalItemActorRefId(unsigned short pid, unsigned int i) noexcept
|
||||||
|
{
|
||||||
|
Player *player;
|
||||||
|
GET_PLAYER(pid, player, 0);
|
||||||
|
|
||||||
|
return player->journalChanges.journalItems.at(i).actorRefId.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
void QuestFunctions::SendJournalChanges(unsigned short pid) noexcept
|
void QuestFunctions::SendJournalChanges(unsigned short pid) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
|
|
|
@ -2,16 +2,17 @@
|
||||||
#define OPENMW_QUESTAPI_HPP
|
#define OPENMW_QUESTAPI_HPP
|
||||||
|
|
||||||
#define QUESTAPI \
|
#define QUESTAPI \
|
||||||
{"GetJournalChangesSize", QuestFunctions::GetJournalChangesSize},\
|
{"GetJournalChangesSize", QuestFunctions::GetJournalChangesSize},\
|
||||||
\
|
\
|
||||||
{"AddJournalEntry", QuestFunctions::AddJournalEntry},\
|
{"AddJournalEntry", QuestFunctions::AddJournalEntry},\
|
||||||
{"AddJournalIndex", QuestFunctions::AddJournalIndex},\
|
{"AddJournalIndex", QuestFunctions::AddJournalIndex},\
|
||||||
\
|
\
|
||||||
{"GetJournalItemQuest", QuestFunctions::GetJournalItemQuest},\
|
{"GetJournalItemQuest", QuestFunctions::GetJournalItemQuest},\
|
||||||
{"GetJournalItemIndex", QuestFunctions::GetJournalItemIndex},\
|
{"GetJournalItemIndex", QuestFunctions::GetJournalItemIndex},\
|
||||||
{"GetJournalItemType", QuestFunctions::GetJournalItemType},\
|
{"GetJournalItemType", QuestFunctions::GetJournalItemType},\
|
||||||
|
{"GetJournalItemActorRefId", QuestFunctions::GetJournalItemActorRefId},\
|
||||||
\
|
\
|
||||||
{"SendJournalChanges", QuestFunctions::SendJournalChanges}
|
{"SendJournalChanges", QuestFunctions::SendJournalChanges}
|
||||||
|
|
||||||
class QuestFunctions
|
class QuestFunctions
|
||||||
{
|
{
|
||||||
|
@ -19,12 +20,13 @@ public:
|
||||||
|
|
||||||
static unsigned int GetJournalChangesSize(unsigned short pid) noexcept;
|
static unsigned int GetJournalChangesSize(unsigned short pid) noexcept;
|
||||||
|
|
||||||
static void AddJournalEntry(unsigned short pid, const char* quest, unsigned int index) noexcept;
|
static void AddJournalEntry(unsigned short pid, const char* quest, unsigned int index, const char* actorRefId) noexcept;
|
||||||
static void AddJournalIndex(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 const char *GetJournalItemQuest(unsigned short pid, unsigned int i) noexcept;
|
||||||
static int GetJournalItemIndex(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 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) noexcept;
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -670,11 +670,7 @@ void LocalPlayer::addJournalItems()
|
||||||
|
|
||||||
if (journalItem.type == JournalItem::ENTRY)
|
if (journalItem.type == JournalItem::ENTRY)
|
||||||
{
|
{
|
||||||
MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCellStore(journalItem.actorCell);
|
MWWorld::Ptr ptrFound = MWBase::Environment::get().getWorld()->searchPtr(journalItem.actorRefId, false);
|
||||||
|
|
||||||
if (!ptrCellStore) continue;
|
|
||||||
|
|
||||||
MWWorld::Ptr ptrFound = ptrCellStore->searchExact(journalItem.actorRefNumIndex, journalItem.actorMpNum);
|
|
||||||
|
|
||||||
if (!ptrFound)
|
if (!ptrFound)
|
||||||
{
|
{
|
||||||
|
@ -1155,13 +1151,7 @@ void LocalPlayer::sendJournalEntry(const std::string& quest, int index, const MW
|
||||||
journalItem.type = JournalItem::ENTRY;
|
journalItem.type = JournalItem::ENTRY;
|
||||||
journalItem.quest = quest;
|
journalItem.quest = quest;
|
||||||
journalItem.index = index;
|
journalItem.index = index;
|
||||||
|
|
||||||
if (actor.mCell != nullptr)
|
|
||||||
journalItem.actorCell = *actor.mCell->getCell();
|
|
||||||
|
|
||||||
journalItem.actorRefId = actor.getCellRef().getRefId();
|
journalItem.actorRefId = actor.getCellRef().getRefId();
|
||||||
journalItem.actorRefNumIndex = actor.getCellRef().getRefNum().mIndex;
|
|
||||||
journalItem.actorMpNum = actor.getCellRef().getMpNum();
|
|
||||||
|
|
||||||
journalChanges.journalItems.push_back(journalItem);
|
journalChanges.journalItems.push_back(journalItem);
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,7 @@ namespace mwmp
|
||||||
INDEX = 1
|
INDEX = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
ESM::Cell actorCell;
|
|
||||||
std::string actorRefId;
|
std::string actorRefId;
|
||||||
int actorRefNumIndex;
|
|
||||||
int actorMpNum;
|
|
||||||
|
|
||||||
int type; // 0 - An entire entry, 1 - An index
|
int type; // 0 - An entire entry, 1 - An index
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,10 +34,6 @@ void PacketPlayerJournal::Packet(RakNet::BitStream *bs, bool send)
|
||||||
if (journalItem.type == JournalItem::ENTRY)
|
if (journalItem.type == JournalItem::ENTRY)
|
||||||
{
|
{
|
||||||
RW(journalItem.actorRefId, send, 1);
|
RW(journalItem.actorRefId, send, 1);
|
||||||
RW(journalItem.actorRefNumIndex, send);
|
|
||||||
RW(journalItem.actorMpNum, send);
|
|
||||||
RW(journalItem.actorCell.mData, send, 1);
|
|
||||||
RW(journalItem.actorCell.mName, send, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!send)
|
if (!send)
|
||||||
|
|
Loading…
Reference in a new issue