Add preliminary structure for journal changes

coverity_scan^2
David Cernat 8 years ago
parent e9b22814b9
commit e2c595fc5d

@ -247,6 +247,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
DEBUG_PRINTF("ID_GAME_JOURNAL\n");
myPacket->Read(player);
Script::Call<Script::CallbackIdentity("OnPlayerChangeJournal")>(player->getId(), player->packetSpells.action);
break;
}

@ -111,6 +111,7 @@ public:
{"OnPlayerChangeEquipment", Function<void, unsigned short>()},
{"OnPlayerChangeInventory", Function<void, unsigned short>()},
{"OnPlayerChangeSpellbook", Function<void, unsigned short, int>()},
{"OnPlayerChangeJournal", Function<void, unsigned short>()},
{"OnPlayerSendMessage", Function<bool, unsigned short, const char*>()},
{"OnPlayerEndCharGen", Function<void, unsigned short>()},
{"OnGUIAction", Function<void, unsigned short, int, const char*>()}

@ -998,6 +998,16 @@ void LocalPlayer::sendSpellRemoval(const ESM::Spell &spell)
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Not implemented.");
}
void LocalPlayer::sendJournalEntry(const std::string& id, int index, const MWWorld::Ptr& actor)
{
Main::get().getNetworking()->getPlayerPacket(ID_GAME_JOURNAL)->Send(this);
}
void LocalPlayer::sendJournalIndex(const std::string& id, int index)
{
Main::get().getNetworking()->getPlayerPacket(ID_GAME_JOURNAL)->Send(this);
}
void LocalPlayer::sendAttack(Attack::TYPE type)
{
MWMechanics::DrawState_ state = getPlayerPtr().getClass().getNpcStats(getPlayerPtr()).getDrawState();

@ -60,6 +60,8 @@ namespace mwmp
void sendSpellAddition(const ESM::Spell &spell);
void sendSpellRemoval(std::string id);
void sendSpellRemoval(const ESM::Spell &spell);
void sendJournalEntry(const std::string& id, int index, const MWWorld::Ptr& actor);
void sendJournalIndex(const std::string& id, int index);
void sendAttack(Attack::TYPE type);
void prepareAttack(Attack::TYPE type, bool state);

@ -323,7 +323,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
{
if (packet->length == myPacket->headerSize())
{
getLocalPlayer()->sendSpellbook();
}
else
{

@ -1,5 +1,8 @@
#include "dialogueextensions.hpp"
#include "../mwmp/Main.hpp"
#include "../mwmp/LocalPlayer.hpp"
#include <components/compiler/extensions.hpp>
#include <components/compiler/opcodes.hpp>
@ -43,6 +46,11 @@ namespace MWScript
try
{
MWBase::Environment::get().getJournal()->addEntry (quest, index, ptr);
// Added by tes3mp
//
// LocalPlayer has gained a journal entry, so send a packet with it
mwmp::Main::get().getLocalPlayer()->sendJournalEntry(quest, index, ptr);
}
catch (...)
{
@ -65,6 +73,11 @@ namespace MWScript
runtime.pop();
MWBase::Environment::get().getJournal()->setJournalIndex (quest, index);
// Added by tes3mp
//
// LocalPlayer has gained a journal index, so send a packet with it
mwmp::Main::get().getLocalPlayer()->sendJournalIndex(quest, index);
}
};

@ -46,6 +46,24 @@ namespace mwmp
}
};
struct JournalItem
{
std::string quest;
int index;
enum JOURNAL_ITEM_TYPE
{
ENTRY = 0,
INDEX = 1
};
int type; // 0 - An entire entry, 1 - An index
};
struct JournalChanges
{
std::vector<JournalItem> journalItems;
unsigned int count;
};
struct PacketItems
{
std::vector<Item> items;

Loading…
Cancel
Save