1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-01 10:06:42 +00:00

Make GetItemSlot work and add SendEquipment in server item functions

This commit is contained in:
David Cernat 2016-09-30 12:30:05 +03:00
parent 728a09e423
commit 4b96080521
3 changed files with 25 additions and 16 deletions

View file

@ -24,9 +24,6 @@ void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const cha
player->EquipedItem(slot)->refid = itemName; player->EquipedItem(slot)->refid = itemName;
player->EquipedItem(slot)->count = count; player->EquipedItem(slot)->count = count;
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_EQUIPMENT)->Send(player, false);
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_EQUIPMENT)->Send(player, true);
} }
void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcept void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcept
@ -37,12 +34,10 @@ void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcep
const char *ItemFunctions::GetItemSlot(unsigned short pid, unsigned short slot) noexcept const char *ItemFunctions::GetItemSlot(unsigned short pid, unsigned short slot) noexcept
{ {
/*Player *player; Player *player;
GET_PLAYER(pid, player, 0); GET_PLAYER(pid, player, 0);
return player->EquipedItem(slot)->refid.c_str();*/ return player->EquipedItem(slot)->refid.c_str();
LOG_MESSAGE(Log::LOG_WARN, "%s", "stub");
return "";
} }
bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* itemName) bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* itemName)
@ -63,4 +58,13 @@ void ItemFunctions::RemoveItem(unsigned short pid, const char* itemName, unsigne
void ItemFunctions::GetItemCount(unsigned short pid, const char* itemName) noexcept void ItemFunctions::GetItemCount(unsigned short pid, const char* itemName) noexcept
{ {
LOG_MESSAGE(Log::LOG_WARN, "%s", "stub"); LOG_MESSAGE(Log::LOG_WARN, "%s", "stub");
} }
void ItemFunctions::SendEquipment(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_EQUIPMENT)->Send(player, false);
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_EQUIPMENT)->Send(player, true);
}

View file

@ -6,13 +6,16 @@
#define OPENMW_ITEMS_HPP #define OPENMW_ITEMS_HPP
#define ITEMAPI \ #define ITEMAPI \
{"AddItem", ItemFunctions::AddItem},\ {"AddItem", ItemFunctions::AddItem},\
{"RemoveItem", ItemFunctions::RemoveItem},\ {"RemoveItem", ItemFunctions::RemoveItem},\
{"GetItemCount", ItemFunctions::GetItemCount},\ {"GetItemCount", ItemFunctions::GetItemCount},\
{"EquipItem", ItemFunctions::EquipItem},\ {"EquipItem", ItemFunctions::EquipItem},\
{"UnequipItem", ItemFunctions::UnequipItem},\ {"UnequipItem", ItemFunctions::UnequipItem},\
{"GetItemSlot", ItemFunctions::GetItemSlot},\ {"GetItemSlot", ItemFunctions::GetItemSlot},\
{"HasItemEquipped", ItemFunctions::HasItemEquipped}\ {"HasItemEquipped", ItemFunctions::HasItemEquipped},\
\
{"SendEquipment", ItemFunctions::SendEquipment}\
class ItemFunctions class ItemFunctions
{ {
@ -24,6 +27,8 @@ public:
static void UnequipItem(unsigned short pid, unsigned short slot) noexcept; static void UnequipItem(unsigned short pid, unsigned short slot) noexcept;
static bool HasItemEquipped(unsigned short pid, const char* itemName); static bool HasItemEquipped(unsigned short pid, const char* itemName);
static const char *GetItemSlot(unsigned short pid, unsigned short slot) noexcept; static const char *GetItemSlot(unsigned short pid, unsigned short slot) noexcept;
static void SendEquipment(unsigned short pid) noexcept;
}; };
#endif //OPENMW_ITEMS_HPP #endif //OPENMW_ITEMS_HPP

View file

@ -70,7 +70,7 @@
{"Resurrect", StatsFunctions::Resurrect},\ {"Resurrect", StatsFunctions::Resurrect},\
{"SendBaseInfo", StatsFunctions::SendBaseInfo},\ {"SendBaseInfo", StatsFunctions::SendBaseInfo},\
\ \
{"SendDynamicStats", StatsFunctions::SendDynamicStats}, \ {"SendDynamicStats", StatsFunctions::SendDynamicStats},\
{"SendAttributes", StatsFunctions::SendAttributes},\ {"SendAttributes", StatsFunctions::SendAttributes},\
{"SendSkills", StatsFunctions::SendSkills},\ {"SendSkills", StatsFunctions::SendSkills},\
{"SendLevel", StatsFunctions::SendLevel} {"SendLevel", StatsFunctions::SendLevel}