mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 13:41:31 +00:00
[Ground Spawns] Convert Ground Spawns to Repositories (#3967)
# Notes - Convert `LoadGroundSpawns()` to repositories.
This commit is contained in:
parent
71f78b757e
commit
eb33e5a064
@ -3445,7 +3445,7 @@ struct Make_Pet_Struct { //Simple struct for getting pet info
|
||||
uint32 min_dmg;
|
||||
uint32 max_dmg;
|
||||
};
|
||||
struct Ground_Spawn{
|
||||
struct GroundSpawn{
|
||||
float max_x;
|
||||
float max_y;
|
||||
float min_x;
|
||||
@ -3457,8 +3457,8 @@ struct Ground_Spawn{
|
||||
uint32 max_allowed;
|
||||
uint32 respawntimer;
|
||||
};
|
||||
struct Ground_Spawns {
|
||||
struct Ground_Spawn spawn[50]; //Assigned max number to allow
|
||||
struct GroundSpawns {
|
||||
struct GroundSpawn spawn[50]; //Assigned max number to allow
|
||||
};
|
||||
|
||||
//struct PetitionBug_Struct{
|
||||
|
||||
@ -3619,7 +3619,7 @@ struct Make_Pet_Struct { //Simple struct for getting pet info
|
||||
uint32 min_dmg;
|
||||
uint32 max_dmg;
|
||||
};
|
||||
struct Ground_Spawn{
|
||||
struct GroundSpawn{
|
||||
float max_x;
|
||||
float max_y;
|
||||
float min_x;
|
||||
@ -3631,8 +3631,8 @@ struct Ground_Spawn{
|
||||
uint32 max_allowed;
|
||||
uint32 respawntimer;
|
||||
};
|
||||
struct Ground_Spawns {
|
||||
struct Ground_Spawn spawn[50]; //Assigned max number to allow
|
||||
struct GroundSpawns {
|
||||
struct GroundSpawn spawn[50]; //Assigned max number to allow
|
||||
};
|
||||
|
||||
//struct PetitionBug_Struct{
|
||||
|
||||
@ -3556,7 +3556,7 @@ struct Make_Pet_Struct { //Simple struct for getting pet info
|
||||
uint32 min_dmg;
|
||||
uint32 max_dmg;
|
||||
};
|
||||
struct Ground_Spawn{
|
||||
struct GroundSpawn{
|
||||
float max_x;
|
||||
float max_y;
|
||||
float min_x;
|
||||
@ -3568,8 +3568,8 @@ struct Ground_Spawn{
|
||||
uint32 max_allowed;
|
||||
uint32 respawntimer;
|
||||
};
|
||||
struct Ground_Spawns {
|
||||
struct Ground_Spawn spawn[50]; //Assigned max number to allow
|
||||
struct GroundSpawns {
|
||||
struct GroundSpawn spawn[50]; //Assigned max number to allow
|
||||
};
|
||||
|
||||
//struct PetitionBug_Struct{
|
||||
|
||||
@ -3026,7 +3026,7 @@ struct Make_Pet_Struct { //Simple struct for getting pet info
|
||||
uint32 min_dmg;
|
||||
uint32 max_dmg;
|
||||
};
|
||||
struct Ground_Spawn{
|
||||
struct GroundSpawn{
|
||||
float max_x;
|
||||
float max_y;
|
||||
float min_x;
|
||||
@ -3038,8 +3038,8 @@ struct Ground_Spawn{
|
||||
uint32 max_allowed;
|
||||
uint32 respawntimer;
|
||||
};
|
||||
struct Ground_Spawns {
|
||||
struct Ground_Spawn spawn[50]; //Assigned max number to allow
|
||||
struct GroundSpawns {
|
||||
struct GroundSpawn spawn[50]; //Assigned max number to allow
|
||||
};
|
||||
|
||||
//struct PetitionBug_Struct{
|
||||
|
||||
@ -2951,7 +2951,7 @@ struct Make_Pet_Struct { //Simple struct for getting pet info
|
||||
uint32 min_dmg;
|
||||
uint32 max_dmg;
|
||||
};
|
||||
struct Ground_Spawn{
|
||||
struct GroundSpawn{
|
||||
float max_x;
|
||||
float max_y;
|
||||
float min_x;
|
||||
@ -2963,8 +2963,8 @@ struct Ground_Spawn{
|
||||
uint32 max_allowed;
|
||||
uint32 respawntimer;
|
||||
};
|
||||
struct Ground_Spawns {
|
||||
struct Ground_Spawn spawn[50]; //Assigned max number to allow
|
||||
struct GroundSpawns {
|
||||
struct GroundSpawn spawn[50]; //Assigned max number to allow
|
||||
};
|
||||
|
||||
//struct PetitionBug_Struct{
|
||||
|
||||
@ -2604,7 +2604,7 @@ struct Make_Pet_Struct { //Simple struct for getting pet info
|
||||
uint32 min_dmg;
|
||||
uint32 max_dmg;
|
||||
};
|
||||
struct Ground_Spawn{
|
||||
struct GroundSpawn{
|
||||
float max_x;
|
||||
float max_y;
|
||||
float min_x;
|
||||
@ -2616,8 +2616,8 @@ struct Ground_Spawn{
|
||||
uint32 max_allowed;
|
||||
uint32 respawntimer;
|
||||
};
|
||||
struct Ground_Spawns {
|
||||
struct Ground_Spawn spawn[50]; //Assigned max number to allow
|
||||
struct GroundSpawns {
|
||||
struct GroundSpawn spawn[50]; //Assigned max number to allow
|
||||
};
|
||||
|
||||
//struct PetitionBug_Struct{
|
||||
|
||||
@ -3078,7 +3078,7 @@ struct Make_Pet_Struct { //Simple struct for getting pet info
|
||||
uint32 min_dmg;
|
||||
uint32 max_dmg;
|
||||
};
|
||||
struct Ground_Spawn{
|
||||
struct GroundSpawn{
|
||||
float max_x;
|
||||
float max_y;
|
||||
float min_x;
|
||||
@ -3090,8 +3090,8 @@ struct Ground_Spawn{
|
||||
uint32 max_allowed;
|
||||
uint32 respawntimer;
|
||||
};
|
||||
struct Ground_Spawns {
|
||||
struct Ground_Spawn spawn[50]; //Assigned max number to allow
|
||||
struct GroundSpawns {
|
||||
struct GroundSpawn spawn[50]; //Assigned max number to allow
|
||||
};
|
||||
|
||||
//struct PetitionBug_Struct{
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include "zonedb.h"
|
||||
#include "../common/repositories/criteria/content_filter_criteria.h"
|
||||
#include "../common/events/player_event_logs.h"
|
||||
#include "../common/repositories/ground_spawns_repository.h"
|
||||
|
||||
|
||||
const char DEFAULT_OBJECT_NAME[] = "IT63_ACTORDEF";
|
||||
@ -748,39 +749,44 @@ void ZoneDatabase::UpdateObject(uint32 id, uint32 type, uint32 icon, const Objec
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Ground_Spawns* ZoneDatabase::LoadGroundSpawns(uint32 zone_id, int16 version, Ground_Spawns* gs) {
|
||||
|
||||
std::string query = StringFormat(
|
||||
"SELECT max_x, max_y, max_z, "
|
||||
"min_x, min_y, heading, name, "
|
||||
"item, max_allowed, respawn_timer "
|
||||
"FROM ground_spawns "
|
||||
"WHERE zoneid = %i AND (version = %u OR version = -1) %s "
|
||||
"LIMIT 50",
|
||||
GroundSpawns* ZoneDatabase::LoadGroundSpawns(
|
||||
uint32 zone_id,
|
||||
int16 instance_version,
|
||||
GroundSpawns* gs
|
||||
)
|
||||
{
|
||||
const auto& l = GroundSpawnsRepository::GetWhere(
|
||||
*this,
|
||||
fmt::format(
|
||||
"`zoneid` = {} AND (`version` = {} OR `version` = -1) {} LIMIT 50",
|
||||
zone_id,
|
||||
version,
|
||||
ContentFilterCriteria::apply().c_str()
|
||||
instance_version,
|
||||
ContentFilterCriteria::apply()
|
||||
)
|
||||
);
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
if (l.empty()) {
|
||||
return gs;
|
||||
}
|
||||
|
||||
int spawnIndex=0;
|
||||
for (auto row = results.begin(); row != results.end(); ++row, ++spawnIndex) {
|
||||
gs->spawn[spawnIndex].max_x=Strings::ToFloat(row[0]);
|
||||
gs->spawn[spawnIndex].max_y=Strings::ToFloat(row[1]);
|
||||
gs->spawn[spawnIndex].max_z=Strings::ToFloat(row[2]);
|
||||
gs->spawn[spawnIndex].min_x=Strings::ToFloat(row[3]);
|
||||
gs->spawn[spawnIndex].min_y=Strings::ToFloat(row[4]);
|
||||
gs->spawn[spawnIndex].heading=Strings::ToFloat(row[5]);
|
||||
strcpy(gs->spawn[spawnIndex].name,row[6]);
|
||||
gs->spawn[spawnIndex].item=Strings::ToInt(row[7]);
|
||||
gs->spawn[spawnIndex].max_allowed=Strings::ToInt(row[8]);
|
||||
gs->spawn[spawnIndex].respawntimer=Strings::ToInt(row[9]);
|
||||
uint32 slot_id = 0;
|
||||
|
||||
for (const auto& e : l) {
|
||||
strcpy(gs->spawn[slot_id].name, e.name.c_str());
|
||||
|
||||
gs->spawn[slot_id].max_x = e.max_x;
|
||||
gs->spawn[slot_id].max_y = e.max_y;
|
||||
gs->spawn[slot_id].max_z = e.max_z;
|
||||
gs->spawn[slot_id].min_x = e.min_x;
|
||||
gs->spawn[slot_id].min_y = e.min_y;
|
||||
gs->spawn[slot_id].heading = e.heading;
|
||||
gs->spawn[slot_id].item = e.item;
|
||||
gs->spawn[slot_id].max_allowed = e.max_allowed;
|
||||
gs->spawn[slot_id].respawntimer = e.respawn_timer;
|
||||
|
||||
slot_id++;
|
||||
}
|
||||
|
||||
return gs;
|
||||
}
|
||||
|
||||
|
||||
@ -349,7 +349,7 @@ bool Zone::IsSpecialBindLocation(const glm::vec4& location)
|
||||
|
||||
//this also just loads into entity_list, not really into zone
|
||||
bool Zone::LoadGroundSpawns() {
|
||||
Ground_Spawns groundspawn;
|
||||
GroundSpawns groundspawn;
|
||||
|
||||
memset(&groundspawn, 0, sizeof(groundspawn));
|
||||
int gsindex=0;
|
||||
|
||||
@ -381,7 +381,7 @@ public:
|
||||
uint32 AddObject(uint32 type, uint32 icon, const Object_Struct& object, const EQ::ItemInstance* inst);
|
||||
void UpdateObject(uint32 id, uint32 type, uint32 icon, const Object_Struct& object, const EQ::ItemInstance* inst);
|
||||
void DeleteObject(uint32 id);
|
||||
Ground_Spawns* LoadGroundSpawns(uint32 zone_id, int16 version, Ground_Spawns* gs);
|
||||
GroundSpawns* LoadGroundSpawns(uint32 zone_id, int16 instance_version, GroundSpawns* gs);
|
||||
|
||||
/* Traders */
|
||||
void SaveTraderItem(uint32 char_id,uint32 itemid,uint32 uniqueid, int32 charges,uint32 itemcost,uint8 slot);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user