mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
[Quest API] Add Key Ring Methods to Perl and Lua (#4719)
This commit is contained in:
parent
7a2d2a0c51
commit
875df8e64a
@ -4626,7 +4626,7 @@ void Client::KeyRingLoad()
|
||||
const auto &l = KeyringRepository::GetWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"`char_id` = {} ORDER BY `item_id`",
|
||||
"`char_id` = {} ORDER BY `item_id` ASC",
|
||||
character_id
|
||||
)
|
||||
);
|
||||
@ -4635,21 +4635,15 @@ void Client::KeyRingLoad()
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (const auto &e : l) {
|
||||
for (const auto& e : l) {
|
||||
keyring.emplace_back(e.item_id);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::KeyRingAdd(uint32 item_id)
|
||||
bool Client::KeyRingAdd(uint32 item_id)
|
||||
{
|
||||
if (!item_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
const bool found = KeyRingCheck(item_id);
|
||||
if (found) {
|
||||
return;
|
||||
if (!item_id || KeyRingCheck(item_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto e = KeyringRepository::NewEntity();
|
||||
@ -4660,14 +4654,14 @@ void Client::KeyRingAdd(uint32 item_id)
|
||||
e = KeyringRepository::InsertOne(database, e);
|
||||
|
||||
if (!e.id) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
keyring.emplace_back(item_id);
|
||||
|
||||
if (!RuleB(World, UseItemLinksForKeyRing)) {
|
||||
Message(Chat::LightBlue, "Added to keyring.");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::string &item_link = database.CreateItemLink(item_id);
|
||||
@ -4679,17 +4673,25 @@ void Client::KeyRingAdd(uint32 item_id)
|
||||
item_link
|
||||
).c_str()
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Client::KeyRingCheck(uint32 item_id)
|
||||
{
|
||||
for (const auto &e : keyring) {
|
||||
if (e == item_id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return std::find(keyring.begin(), keyring.end(), item_id) != keyring.end();
|
||||
}
|
||||
|
||||
return false;
|
||||
bool Client::KeyRingClear()
|
||||
{
|
||||
keyring.clear();
|
||||
|
||||
return KeyringRepository::DeleteWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"`char_id` = {}",
|
||||
CharacterID()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void Client::KeyRingList()
|
||||
@ -4698,16 +4700,40 @@ void Client::KeyRingList()
|
||||
|
||||
const EQ::ItemData *item = nullptr;
|
||||
|
||||
for (const auto &e : keyring) {
|
||||
for (const uint32& e : keyring) {
|
||||
item = database.GetItem(e);
|
||||
if (item) {
|
||||
const std::string &item_string = RuleB(World, UseItemLinksForKeyRing) ? database.CreateItemLink(e) : item->Name;
|
||||
const std::string& item_string = (
|
||||
RuleB(World, UseItemLinksForKeyRing) ?
|
||||
database.CreateItemLink(e) :
|
||||
item->Name
|
||||
);
|
||||
|
||||
Message(Chat::LightBlue, item_string.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Client::KeyRingRemove(uint32 item_id)
|
||||
{
|
||||
keyring.erase(
|
||||
std::remove(
|
||||
keyring.begin(),
|
||||
keyring.end(),
|
||||
item_id
|
||||
)
|
||||
);
|
||||
|
||||
return KeyringRepository::DeleteWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"`char_id` = {} AND `item_id` = {}",
|
||||
CharacterID(),
|
||||
item_id
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
bool Client::IsPetNameChangeAllowed() {
|
||||
if (RuleB(Pets, AlwaysAllowPetRename)) {
|
||||
return true;
|
||||
|
||||
@ -327,8 +327,10 @@ public:
|
||||
// void TraderPriceUpdate(const EQApplicationPacket *app);
|
||||
uint8 WithCustomer(uint16 NewCustomer);
|
||||
void KeyRingLoad();
|
||||
void KeyRingAdd(uint32 item_id);
|
||||
bool KeyRingAdd(uint32 item_id);
|
||||
bool KeyRingCheck(uint32 item_id);
|
||||
bool KeyRingClear();
|
||||
bool KeyRingRemove(uint32 item_id);
|
||||
void KeyRingList();
|
||||
bool IsPetNameChangeAllowed();
|
||||
void GrantPetNameChange();
|
||||
@ -2038,7 +2040,7 @@ private:
|
||||
bool GuildBanker;
|
||||
uint16 duel_target;
|
||||
bool duelaccepted;
|
||||
std::list<uint32> keyring;
|
||||
std::vector<uint32> keyring;
|
||||
bool tellsoff; // GM /toggle
|
||||
bool gm_hide_me;
|
||||
bool LFG;
|
||||
|
||||
@ -1199,16 +1199,6 @@ void Lua_Client::SetStartZone(int zone_id, float x, float y, float z) {
|
||||
self->SetStartZone(zone_id, x, y, z);
|
||||
}
|
||||
|
||||
void Lua_Client::KeyRingAdd(uint32 item) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->KeyRingAdd(item);
|
||||
}
|
||||
|
||||
bool Lua_Client::KeyRingCheck(uint32 item) {
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->KeyRingCheck(item);
|
||||
}
|
||||
|
||||
void Lua_Client::AddPVPPoints(uint32 points) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->AddPVPPoints(points);
|
||||
@ -3548,6 +3538,34 @@ std::string Lua_Client::GetPotionBeltItemName(uint8 slot_id)
|
||||
return self->GetPotionBeltItemName(slot_id);
|
||||
}
|
||||
|
||||
bool Lua_Client::KeyRingAdd(uint32 item) {
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->KeyRingAdd(item);
|
||||
}
|
||||
|
||||
bool Lua_Client::KeyRingCheck(uint32 item) {
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->KeyRingCheck(item);
|
||||
}
|
||||
|
||||
bool Lua_Client::KeyRingClear()
|
||||
{
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->KeyRingClear();
|
||||
}
|
||||
|
||||
void Lua_Client::KeyRingList()
|
||||
{
|
||||
Lua_Safe_Call_Void();
|
||||
self->KeyRingList();
|
||||
}
|
||||
|
||||
bool Lua_Client::KeyRingRemove(uint32 item_id)
|
||||
{
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->KeyRingRemove(item_id);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_client() {
|
||||
return luabind::class_<Lua_Client, Lua_Mob>("Client")
|
||||
.def(luabind::constructor<>())
|
||||
@ -3869,8 +3887,11 @@ luabind::scope lua_register_client() {
|
||||
.def("IsTaskActive", (bool(Lua_Client::*)(int))&Lua_Client::IsTaskActive)
|
||||
.def("IsTaskActivityActive", (bool(Lua_Client::*)(int,int))&Lua_Client::IsTaskActivityActive)
|
||||
.def("IsTaskCompleted", (bool(Lua_Client::*)(int))&Lua_Client::IsTaskCompleted)
|
||||
.def("KeyRingAdd", (void(Lua_Client::*)(uint32))&Lua_Client::KeyRingAdd)
|
||||
.def("KeyRingAdd", (bool(Lua_Client::*)(uint32))&Lua_Client::KeyRingAdd)
|
||||
.def("KeyRingCheck", (bool(Lua_Client::*)(uint32))&Lua_Client::KeyRingCheck)
|
||||
.def("KeyRingClear", (bool(Lua_Client::*)(void))&Lua_Client::KeyRingClear)
|
||||
.def("KeyRingList", (void(Lua_Client::*)(void))&Lua_Client::KeyRingList)
|
||||
.def("KeyRingRemove", (bool(Lua_Client::*)(uint32))&Lua_Client::KeyRingRemove)
|
||||
.def("Kick", (void(Lua_Client::*)(void))&Lua_Client::Kick)
|
||||
.def("LearnDisciplines", (uint16(Lua_Client::*)(uint8,uint8))&Lua_Client::LearnDisciplines)
|
||||
.def("LearnRecipe", (void(Lua_Client::*)(uint32))&Lua_Client::LearnRecipe)
|
||||
|
||||
@ -313,8 +313,6 @@ public:
|
||||
void SetStartZone(int zone_id, float x, float y);
|
||||
void SetStartZone(int zone_id, float x, float y, float z);
|
||||
void SetStartZone(int zone_id, float x, float y, float z, float heading);
|
||||
void KeyRingAdd(uint32 item);
|
||||
bool KeyRingCheck(uint32 item);
|
||||
void AddPVPPoints(uint32 points);
|
||||
void AddCrystals(uint32 radiant_count, uint32 ebon_count);
|
||||
void SetEbonCrystals(uint32 value);
|
||||
@ -518,6 +516,11 @@ public:
|
||||
uint32 GetPotionBeltItemIcon(uint8 slot_id);
|
||||
uint32 GetPotionBeltItemID(uint8 slot_id);
|
||||
std::string GetPotionBeltItemName(uint8 slot_id);
|
||||
bool KeyRingAdd(uint32 item_id);
|
||||
bool KeyRingCheck(uint32 item_id);
|
||||
bool KeyRingClear();
|
||||
void KeyRingList();
|
||||
bool KeyRingRemove(uint32 item_id);
|
||||
|
||||
// account data buckets
|
||||
void SetAccountBucket(std::string bucket_name, std::string bucket_value);
|
||||
|
||||
@ -1142,16 +1142,6 @@ void Perl_Client_SetStartZone(Client* self, uint32 zone_id, float x, float y, fl
|
||||
self->SetStartZone(zone_id, x, y, z, heading);
|
||||
}
|
||||
|
||||
void Perl_Client_KeyRingAdd(Client* self, uint32 item_id) // @categories Account and Character, Inventory and Items
|
||||
{
|
||||
self->KeyRingAdd(item_id);
|
||||
}
|
||||
|
||||
bool Perl_Client_KeyRingCheck(Client* self, uint32 item_id) // @categories Account and Character, Inventory and Items
|
||||
{
|
||||
return self->KeyRingCheck(item_id);
|
||||
}
|
||||
|
||||
void Perl_Client_AddPVPPoints(Client* self, uint32 points) // @categories Currency and Points
|
||||
{
|
||||
self->AddPVPPoints(points);
|
||||
@ -3306,6 +3296,31 @@ std::string Perl_Client_GetPotionBeltItemName(Client* self, uint8 slot_id)
|
||||
return self->GetPotionBeltItemName(slot_id);
|
||||
}
|
||||
|
||||
bool Perl_Client_KeyRingAdd(Client* self, uint32 item_id) // @categories Account and Character, Inventory and Items
|
||||
{
|
||||
return self->KeyRingAdd(item_id);
|
||||
}
|
||||
|
||||
bool Perl_Client_KeyRingCheck(Client* self, uint32 item_id) // @categories Account and Character, Inventory and Items
|
||||
{
|
||||
return self->KeyRingCheck(item_id);
|
||||
}
|
||||
|
||||
bool Perl_Client_KeyRingClear(Client* self)
|
||||
{
|
||||
return self->KeyRingClear();
|
||||
}
|
||||
|
||||
void Perl_Client_KeyRingList(Client* self)
|
||||
{
|
||||
self->KeyRingList();
|
||||
}
|
||||
|
||||
bool Perl_Client_KeyRingRemove(Client* self, uint32 item_id)
|
||||
{
|
||||
return self->KeyRingRemove(item_id);
|
||||
}
|
||||
|
||||
void perl_register_client()
|
||||
{
|
||||
perl::interpreter perl(PERL_GET_THX);
|
||||
@ -3630,6 +3645,9 @@ void perl_register_client()
|
||||
package.add("IsTaskCompleted", &Perl_Client_IsTaskCompleted);
|
||||
package.add("KeyRingAdd", &Perl_Client_KeyRingAdd);
|
||||
package.add("KeyRingCheck", &Perl_Client_KeyRingCheck);
|
||||
package.add("KeyRingClear", &Perl_Client_KeyRingClear);
|
||||
package.add("KeyRingList", &Perl_Client_KeyRingList);
|
||||
package.add("KeyRingRemove", &Perl_Client_KeyRingRemove);
|
||||
package.add("Kick", &Perl_Client_Kick);
|
||||
package.add("LearnDisciplines", &Perl_Client_LearnDisciplines);
|
||||
package.add("LearnRecipe", &Perl_Client_LearnRecipe);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user