[Server] Move functions dealing with PlayerKillCount to QuestFunctions

pull/249/merge
David Cernat 8 years ago
parent 6f6a3ae74d
commit b1b27728e2

@ -13,14 +13,6 @@ void DialogueFunctions::InitializeTopicChanges(unsigned short pid) noexcept
player->topicChanges.topics.clear();
}
void DialogueFunctions::InitializeKillChanges(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
player->killChanges.kills.clear();
}
unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short pid) noexcept
{
Player *player;
@ -29,14 +21,6 @@ unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short pid) noexcept
return player->topicChanges.count;
}
unsigned int DialogueFunctions::GetKillChangesSize(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
return player->killChanges.count;
}
void DialogueFunctions::AddTopic(unsigned short pid, const char* topicId) noexcept
{
Player *player;
@ -48,18 +32,6 @@ void DialogueFunctions::AddTopic(unsigned short pid, const char* topicId) noexce
player->topicChanges.topics.push_back(topic);
}
void DialogueFunctions::AddKill(unsigned short pid, const char* refId, int number) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Kill kill;
kill.refId = refId;
kill.number = number;
player->killChanges.kills.push_back(kill);
}
const char *DialogueFunctions::GetTopicId(unsigned short pid, unsigned int i) noexcept
{
Player *player;
@ -71,25 +43,6 @@ const char *DialogueFunctions::GetTopicId(unsigned short pid, unsigned int i) no
return player->topicChanges.topics.at(i).topicId.c_str();
}
const char *DialogueFunctions::GetKillRefId(unsigned short pid, unsigned int i) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
if (i >= player->killChanges.count)
return "invalid";
return player->killChanges.kills.at(i).refId.c_str();
}
int DialogueFunctions::GetKillNumber(unsigned short pid, unsigned int i) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
return player->killChanges.kills.at(i).number;
}
void DialogueFunctions::SendTopicChanges(unsigned short pid, bool toOthers) noexcept
{
Player *player;
@ -98,12 +51,3 @@ void DialogueFunctions::SendTopicChanges(unsigned short pid, bool toOthers) noex
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_TOPIC)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_TOPIC)->Send(toOthers);
}
void DialogueFunctions::SendKillChanges(unsigned short pid, bool toOthers) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_KILL_COUNT)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_KILL_COUNT)->Send(toOthers);
}

@ -3,40 +3,28 @@
#define DIALOGUEAPI \
{"InitializeTopicChanges", DialogueFunctions::InitializeTopicChanges},\
{"InitializeKillChanges", DialogueFunctions::InitializeKillChanges},\
\
{"GetTopicChangesSize", DialogueFunctions::GetTopicChangesSize},\
{"GetKillChangesSize", DialogueFunctions::GetKillChangesSize},\
\
{"AddTopic", DialogueFunctions::AddTopic},\
{"AddKill", DialogueFunctions::AddKill},\
\
{"GetTopicId", DialogueFunctions::GetTopicId},\
{"GetKillRefId", DialogueFunctions::GetKillRefId},\
{"GetKillNumber", DialogueFunctions::GetKillNumber},\
\
{"SendTopicChanges", DialogueFunctions::SendTopicChanges},\
{"SendKillChanges", DialogueFunctions::SendKillChanges}
{"SendTopicChanges", DialogueFunctions::SendTopicChanges}
class DialogueFunctions
{
public:
static void InitializeTopicChanges(unsigned short pid) noexcept;
static void InitializeKillChanges(unsigned short pid) noexcept;
static unsigned int GetTopicChangesSize(unsigned short pid) noexcept;
static unsigned int GetKillChangesSize(unsigned short pid) noexcept;
static void AddTopic(unsigned short pid, const char* topicId) noexcept;
static void AddKill(unsigned short pid, const char* refId, int number) noexcept;
static const char *GetTopicId(unsigned short pid, unsigned int i) noexcept;
static const char *GetKillRefId(unsigned short pid, unsigned int i) noexcept;
static int GetKillNumber(unsigned short pid, unsigned int i) noexcept;
static void SendTopicChanges(unsigned short pid, bool toOthers = false) noexcept;
static void SendKillChanges(unsigned short pid, bool toOthers = false) noexcept;
private:
};

@ -14,6 +14,14 @@ void QuestFunctions::InitializeJournalChanges(unsigned short pid) noexcept
player->journalChanges.journalItems.clear();
}
void QuestFunctions::InitializeKillChanges(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
player->killChanges.kills.clear();
}
unsigned int QuestFunctions::GetJournalChangesSize(unsigned short pid) noexcept
{
Player *player;
@ -22,6 +30,14 @@ unsigned int QuestFunctions::GetJournalChangesSize(unsigned short pid) noexcept
return player->journalChanges.count;
}
unsigned int QuestFunctions::GetKillChangesSize(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
return player->killChanges.count;
}
void QuestFunctions::AddJournalEntry(unsigned short pid, const char* quest, unsigned int index, const char* actorRefId) noexcept
{
Player *player;
@ -49,6 +65,18 @@ void QuestFunctions::AddJournalIndex(unsigned short pid, const char* quest, unsi
player->journalChanges.journalItems.push_back(journalItem);
}
void QuestFunctions::AddKill(unsigned short pid, const char* refId, int number) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Kill kill;
kill.refId = refId;
kill.number = number;
player->killChanges.kills.push_back(kill);
}
const char *QuestFunctions::GetJournalItemQuest(unsigned short pid, unsigned int i) noexcept
{
Player *player;
@ -84,6 +112,25 @@ const char *QuestFunctions::GetJournalItemActorRefId(unsigned short pid, unsigne
return player->journalChanges.journalItems.at(i).actorRefId.c_str();
}
const char *QuestFunctions::GetKillRefId(unsigned short pid, unsigned int i) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
if (i >= player->killChanges.count)
return "invalid";
return player->killChanges.kills.at(i).refId.c_str();
}
int QuestFunctions::GetKillNumber(unsigned short pid, unsigned int i) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
return player->killChanges.kills.at(i).number;
}
void QuestFunctions::SendJournalChanges(unsigned short pid, bool toOthers) noexcept
{
Player *player;
@ -92,3 +139,12 @@ void QuestFunctions::SendJournalChanges(unsigned short pid, bool toOthers) noexc
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_JOURNAL)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_JOURNAL)->Send(toOthers);
}
void QuestFunctions::SendKillChanges(unsigned short pid, bool toOthers) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_KILL_COUNT)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_KILL_COUNT)->Send(toOthers);
}

@ -3,35 +3,47 @@
#define QUESTAPI \
{"InitializeJournalChanges", QuestFunctions::InitializeJournalChanges},\
{"InitializeKillChanges", QuestFunctions::InitializeKillChanges},\
\
{"GetJournalChangesSize", QuestFunctions::GetJournalChangesSize},\
{"GetKillChangesSize", QuestFunctions::GetKillChangesSize},\
\
{"AddJournalEntry", QuestFunctions::AddJournalEntry},\
{"AddJournalIndex", QuestFunctions::AddJournalIndex},\
{"AddKill", QuestFunctions::AddKill},\
\
{"GetJournalItemQuest", QuestFunctions::GetJournalItemQuest},\
{"GetJournalItemIndex", QuestFunctions::GetJournalItemIndex},\
{"GetJournalItemType", QuestFunctions::GetJournalItemType},\
{"GetJournalItemActorRefId", QuestFunctions::GetJournalItemActorRefId},\
{"GetKillRefId", QuestFunctions::GetKillRefId},\
{"GetKillNumber", QuestFunctions::GetKillNumber},\
\
{"SendJournalChanges", QuestFunctions::SendJournalChanges}
{"SendJournalChanges", QuestFunctions::SendJournalChanges},\
{"SendKillChanges", QuestFunctions::SendKillChanges}
class QuestFunctions
{
public:
static void InitializeJournalChanges(unsigned short pid) noexcept;
static void InitializeKillChanges(unsigned short pid) noexcept;
static unsigned int GetJournalChangesSize(unsigned short pid) noexcept;
static unsigned int GetKillChangesSize(unsigned short pid) 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 AddKill(unsigned short pid, const char* refId, int number) 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 const char *GetKillRefId(unsigned short pid, unsigned int i) noexcept;
static int GetKillNumber(unsigned short pid, unsigned int i) noexcept;
static void SendJournalChanges(unsigned short pid, bool toOthers = false) noexcept;
static void SendKillChanges(unsigned short pid, bool toOthers = false) noexcept;
private:
};

Loading…
Cancel
Save