mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
[Pets] Convert Pets to Repositories (#3968)
* [Pets] Convert Pets to Repositories # Notes - Convert `GetPoweredPetEntry()` to repositories. * Update pets.cpp
This commit is contained in:
parent
eb33e5a064
commit
8cb15f9357
@ -20,6 +20,8 @@
|
|||||||
#include "../common/spdat.h"
|
#include "../common/spdat.h"
|
||||||
#include "../common/strings.h"
|
#include "../common/strings.h"
|
||||||
|
|
||||||
|
#include "../common/repositories/pets_repository.h"
|
||||||
|
|
||||||
#include "entity.h"
|
#include "entity.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "mob.h"
|
#include "mob.h"
|
||||||
@ -369,38 +371,35 @@ Pet::Pet(NPCType *type_data, Mob *owner, PetType type, uint16 spell_id, int16 po
|
|||||||
// Class should use npc constructor to set light properties
|
// Class should use npc constructor to set light properties
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::GetPetEntry(const char *pet_type, PetRecord *into) {
|
bool ZoneDatabase::GetPetEntry(const std::string& pet_type, PetRecord *p)
|
||||||
return GetPoweredPetEntry(pet_type, 0, into);
|
{
|
||||||
|
return GetPoweredPetEntry(pet_type, 0, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::GetPoweredPetEntry(const char *pet_type, int16 petpower, PetRecord *into) {
|
bool ZoneDatabase::GetPoweredPetEntry(const std::string& pet_type, int16 pet_power, PetRecord* r)
|
||||||
std::string query;
|
{
|
||||||
|
const auto& l = PetsRepository::GetWhere(
|
||||||
|
*this,
|
||||||
|
fmt::format(
|
||||||
|
"`type` = '{}' AND `petpower` <= {} ORDER BY `petpower` DESC LIMIT 1",
|
||||||
|
pet_type,
|
||||||
|
pet_power <= 0 ? 0 : pet_power
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if (petpower <= 0)
|
if (l.empty()) {
|
||||||
query = StringFormat("SELECT npcID, temp, petpower, petcontrol, petnaming, monsterflag, equipmentset "
|
|
||||||
"FROM pets WHERE type='%s' AND petpower<=0", pet_type);
|
|
||||||
else
|
|
||||||
query = StringFormat("SELECT npcID, temp, petpower, petcontrol, petnaming, monsterflag, equipmentset "
|
|
||||||
"FROM pets WHERE type='%s' AND petpower<=%d ORDER BY petpower DESC LIMIT 1",
|
|
||||||
pet_type, petpower);
|
|
||||||
|
|
||||||
auto results = content_db.QueryDatabase(query);
|
|
||||||
if (!results.Success()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results.RowCount() != 1)
|
auto e = l.front();
|
||||||
return false;
|
|
||||||
|
|
||||||
auto row = results.begin();
|
r->npc_type = e.npcID;
|
||||||
|
r->temporary = e.temp;
|
||||||
into->npc_type = Strings::ToInt(row[0]);
|
r->petpower = e.petpower;
|
||||||
into->temporary = Strings::ToInt(row[1]);
|
r->petcontrol = e.petcontrol;
|
||||||
into->petpower = Strings::ToInt(row[2]);
|
r->petnaming = e.petnaming;
|
||||||
into->petcontrol = Strings::ToInt(row[3]);
|
r->monsterflag = e.monsterflag;
|
||||||
into->petnaming = Strings::ToInt(row[4]);
|
r->equipmentset = e.equipmentset;
|
||||||
into->monsterflag = Strings::ToInt(row[5]);
|
|
||||||
into->equipmentset = Strings::ToInt(row[6]);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -560,8 +560,8 @@ public:
|
|||||||
uint32 AddNPCTypes(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 spawnGroupID);
|
uint32 AddNPCTypes(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 spawnGroupID);
|
||||||
uint32 UpdateNPCTypeAppearance(Client *client, NPC* spawn);
|
uint32 UpdateNPCTypeAppearance(Client *client, NPC* spawn);
|
||||||
bool SetSpecialAttkFlag(uint8 id, const char* flag);
|
bool SetSpecialAttkFlag(uint8 id, const char* flag);
|
||||||
bool GetPetEntry(const char *pet_type, PetRecord *into);
|
bool GetPetEntry(const std::string& pet_type, PetRecord* r);
|
||||||
bool GetPoweredPetEntry(const char *pet_type, int16 petpower, PetRecord *into);
|
bool GetPoweredPetEntry(const std::string& pet_type, int16 pet_power, PetRecord* r);
|
||||||
bool GetBasePetItems(int32 equipmentset, uint32 *items);
|
bool GetBasePetItems(int32 equipmentset, uint32 *items);
|
||||||
BeastlordPetData::PetStruct GetBeastlordPetData(uint16 race_id);
|
BeastlordPetData::PetStruct GetBeastlordPetData(uint16 race_id);
|
||||||
void AddLootTableToNPC(NPC* npc, uint32 loottable_id, ItemList* itemlist, uint32* copper, uint32* silver, uint32* gold, uint32* plat);
|
void AddLootTableToNPC(NPC* npc, uint32 loottable_id, ItemList* itemlist, uint32* copper, uint32* silver, uint32* gold, uint32* plat);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user