mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 17:51:28 +00:00
[Pets] Convert Load of Pets Beastlord Data to Repositories (#3995)
* [Pets] Convert Load of Pets Beastlord Data to Repositories # Notes - Convert `GetBeastlordPetData()` to repositories. - Add support for `unsigned` versions of `float`, `double`, and `decimal`, without this we defaulted to `std::string`, such as with `pets_beastlord_data`. * Update repository-generator.pl --------- Co-authored-by: Chris Miles <akkadius1@gmail.com>
This commit is contained in:
parent
a1f2a21c99
commit
b89772ca91
@ -24,7 +24,7 @@ public:
|
|||||||
uint8_t texture;
|
uint8_t texture;
|
||||||
uint8_t helm_texture;
|
uint8_t helm_texture;
|
||||||
uint8_t gender;
|
uint8_t gender;
|
||||||
std::string size_modifier;
|
float size_modifier;
|
||||||
uint8_t face;
|
uint8_t face;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -566,9 +566,12 @@ sub translate_mysql_data_type_to_c
|
|||||||
elsif ($mysql_data_type =~ /int/) {
|
elsif ($mysql_data_type =~ /int/) {
|
||||||
$struct_data_type = 'uint32_t';
|
$struct_data_type = 'uint32_t';
|
||||||
}
|
}
|
||||||
elsif ($mysql_data_type =~ /float|decimal/) {
|
elsif ($mysql_data_type =~ /float|decimal/i) {
|
||||||
$struct_data_type = 'float';
|
$struct_data_type = 'float';
|
||||||
}
|
}
|
||||||
|
elsif ($mysql_data_type =~ /double/i) {
|
||||||
|
$struct_data_type = 'double';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elsif ($mysql_data_type =~ /bigint/) {
|
elsif ($mysql_data_type =~ /bigint/) {
|
||||||
$struct_data_type = 'int64_t';
|
$struct_data_type = 'int64_t';
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
#include "../common/strings.h"
|
#include "../common/strings.h"
|
||||||
|
|
||||||
#include "../common/repositories/pets_repository.h"
|
#include "../common/repositories/pets_repository.h"
|
||||||
|
#include "../common/repositories/pets_beastlord_data_repository.h"
|
||||||
|
|
||||||
#include "entity.h"
|
#include "entity.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
@ -198,13 +199,16 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower,
|
|||||||
// Beastlord Pets
|
// Beastlord Pets
|
||||||
if (record.petnaming == 2) {
|
if (record.petnaming == 2) {
|
||||||
uint16 race_id = GetBaseRace();
|
uint16 race_id = GetBaseRace();
|
||||||
auto beastlord_pet_data = content_db.GetBeastlordPetData(race_id);
|
|
||||||
npc_type->race = beastlord_pet_data.race_id;
|
auto d = content_db.GetBeastlordPetData(race_id);
|
||||||
npc_type->texture = beastlord_pet_data.texture;
|
|
||||||
npc_type->helmtexture = beastlord_pet_data.helm_texture;
|
npc_type->race = d.race_id;
|
||||||
npc_type->gender = beastlord_pet_data.gender;
|
npc_type->texture = d.texture;
|
||||||
npc_type->size *= beastlord_pet_data.size_modifier;
|
npc_type->helmtexture = d.helm_texture;
|
||||||
npc_type->luclinface = beastlord_pet_data.face;
|
npc_type->gender = d.gender;
|
||||||
|
npc_type->luclinface = d.face;
|
||||||
|
|
||||||
|
npc_type->size *= d.size_modifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle monster summoning pet appearance
|
// handle monster summoning pet appearance
|
||||||
@ -655,27 +659,20 @@ bool Pet::CheckSpellLevelRestriction(Mob *caster, uint16 spell_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BeastlordPetData::PetStruct ZoneDatabase::GetBeastlordPetData(uint16 race_id) {
|
BeastlordPetData::PetStruct ZoneDatabase::GetBeastlordPetData(uint16 race_id) {
|
||||||
BeastlordPetData::PetStruct beastlord_pet_data;
|
BeastlordPetData::PetStruct d;
|
||||||
std::string query = fmt::format(
|
|
||||||
SQL(
|
const auto& e = PetsBeastlordDataRepository::FindOne(*this, race_id);
|
||||||
SELECT
|
|
||||||
`pet_race`, `texture`, `helm_texture`, `gender`, `size_modifier`, `face`
|
if (!e.player_race) {
|
||||||
FROM `pets_beastlord_data`
|
return d;
|
||||||
WHERE `player_race` = {}
|
|
||||||
),
|
|
||||||
race_id
|
|
||||||
);
|
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
if (!results.Success() || results.RowCount() != 1) {
|
|
||||||
return beastlord_pet_data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto row = results.begin();
|
d.race_id = e.pet_race;
|
||||||
beastlord_pet_data.race_id = Strings::ToInt(row[0]);
|
d.texture = e.texture;
|
||||||
beastlord_pet_data.texture = Strings::ToInt(row[1]);
|
d.helm_texture = e.helm_texture;
|
||||||
beastlord_pet_data.helm_texture = Strings::ToInt(row[2]);
|
d.gender = e.gender;
|
||||||
beastlord_pet_data.gender = Strings::ToInt(row[3]);
|
d.size_modifier = e.size_modifier;
|
||||||
beastlord_pet_data.size_modifier = Strings::ToFloat(row[4]);
|
d.face = e.face;
|
||||||
beastlord_pet_data.face = Strings::ToInt(row[5]);
|
|
||||||
return beastlord_pet_data;
|
return d;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,8 +15,6 @@
|
|||||||
|
|
||||||
#include "bot_database.h"
|
#include "bot_database.h"
|
||||||
|
|
||||||
#define WOLF 42
|
|
||||||
|
|
||||||
class Client;
|
class Client;
|
||||||
class Corpse;
|
class Corpse;
|
||||||
class Merc;
|
class Merc;
|
||||||
@ -337,7 +335,7 @@ struct CharacterCorpseEntry
|
|||||||
|
|
||||||
namespace BeastlordPetData {
|
namespace BeastlordPetData {
|
||||||
struct PetStruct {
|
struct PetStruct {
|
||||||
uint16 race_id = WOLF;
|
uint16 race_id = Race::Wolf;
|
||||||
uint8 texture = 0;
|
uint8 texture = 0;
|
||||||
uint8 helm_texture = 0;
|
uint8 helm_texture = 0;
|
||||||
uint8 gender = Gender::Neuter;
|
uint8 gender = Gender::Neuter;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user