[General] Fix PlayerJournal logic by sending only refIds for its actors

Additionally, make the refIds for actors usable in script functions.
pull/249/merge
David Cernat 8 years ago
parent 48c63dbce9
commit 78f29302ef

@ -14,7 +14,7 @@ unsigned int QuestFunctions::GetJournalChangesSize(unsigned short pid) noexcept
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;
GET_PLAYER(pid, player, );
@ -23,6 +23,7 @@ void QuestFunctions::AddJournalEntry(unsigned short pid, const char* quest, unsi
journalItem.type = JournalItem::ENTRY;
journalItem.quest = quest;
journalItem.index = index;
journalItem.actorRefId = actorRefId;
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;
}
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
{
Player *player;

@ -2,16 +2,17 @@
#define OPENMW_QUESTAPI_HPP
#define QUESTAPI \
{"GetJournalChangesSize", QuestFunctions::GetJournalChangesSize},\
{"GetJournalChangesSize", QuestFunctions::GetJournalChangesSize},\
\
{"AddJournalEntry", QuestFunctions::AddJournalEntry},\
{"AddJournalIndex", QuestFunctions::AddJournalIndex},\
{"AddJournalEntry", QuestFunctions::AddJournalEntry},\
{"AddJournalIndex", QuestFunctions::AddJournalIndex},\
\
{"GetJournalItemQuest", QuestFunctions::GetJournalItemQuest},\
{"GetJournalItemIndex", QuestFunctions::GetJournalItemIndex},\
{"GetJournalItemType", QuestFunctions::GetJournalItemType},\
{"GetJournalItemQuest", QuestFunctions::GetJournalItemQuest},\
{"GetJournalItemIndex", QuestFunctions::GetJournalItemIndex},\
{"GetJournalItemType", QuestFunctions::GetJournalItemType},\
{"GetJournalItemActorRefId", QuestFunctions::GetJournalItemActorRefId},\
\
{"SendJournalChanges", QuestFunctions::SendJournalChanges}
{"SendJournalChanges", QuestFunctions::SendJournalChanges}
class QuestFunctions
{
@ -19,12 +20,13 @@ public:
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 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 const char *GetJournalItemActorRefId(unsigned short pid, unsigned int i) noexcept;
static void SendJournalChanges(unsigned short pid) noexcept;
private:

@ -670,11 +670,7 @@ void LocalPlayer::addJournalItems()
if (journalItem.type == JournalItem::ENTRY)
{
MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCellStore(journalItem.actorCell);
if (!ptrCellStore) continue;
MWWorld::Ptr ptrFound = ptrCellStore->searchExact(journalItem.actorRefNumIndex, journalItem.actorMpNum);
MWWorld::Ptr ptrFound = MWBase::Environment::get().getWorld()->searchPtr(journalItem.actorRefId, false);
if (!ptrFound)
{
@ -1155,13 +1151,7 @@ void LocalPlayer::sendJournalEntry(const std::string& quest, int index, const MW
journalItem.type = JournalItem::ENTRY;
journalItem.quest = quest;
journalItem.index = index;
if (actor.mCell != nullptr)
journalItem.actorCell = *actor.mCell->getCell();
journalItem.actorRefId = actor.getCellRef().getRefId();
journalItem.actorRefNumIndex = actor.getCellRef().getRefNum().mIndex;
journalItem.actorMpNum = actor.getCellRef().getMpNum();
journalChanges.journalItems.push_back(journalItem);

@ -36,10 +36,7 @@ namespace mwmp
INDEX = 1
};
ESM::Cell actorCell;
std::string actorRefId;
int actorRefNumIndex;
int actorMpNum;
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)
{
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)

Loading…
Cancel
Save