mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
Fix potential memory leaks (clang-tidy)
This commit is contained in:
parent
74b3fe9d61
commit
47c9182ba3
162
zone/client.cpp
162
zone/client.cpp
@ -2568,25 +2568,25 @@ void Client::LogMerchant(Client* player, Mob* merchant, uint32 quantity, uint32
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::BindWound(Mob* bindmob, bool start, bool fail){
|
bool Client::BindWound(Mob *bindmob, bool start, bool fail)
|
||||||
EQApplicationPacket* outapp = 0;
|
{
|
||||||
if(!fail)
|
EQApplicationPacket *outapp = nullptr;
|
||||||
{
|
if (!fail) {
|
||||||
outapp = new EQApplicationPacket(OP_Bind_Wound, sizeof(BindWound_Struct));
|
outapp = new EQApplicationPacket(OP_Bind_Wound, sizeof(BindWound_Struct));
|
||||||
BindWound_Struct* bind_out = (BindWound_Struct*) outapp->pBuffer;
|
BindWound_Struct *bind_out = (BindWound_Struct *)outapp->pBuffer;
|
||||||
// Start bind
|
// Start bind
|
||||||
if(!bindwound_timer.Enabled())
|
if (!bindwound_timer.Enabled()) {
|
||||||
{
|
// make sure we actually have a bandage... and consume it.
|
||||||
//make sure we actually have a bandage... and consume it.
|
int16 bslot = m_inv.HasItemByUse(ItemTypeBandage, 1, invWhereWorn | invWherePersonal);
|
||||||
int16 bslot = m_inv.HasItemByUse(ItemTypeBandage, 1, invWhereWorn|invWherePersonal);
|
|
||||||
if (bslot == INVALID_INDEX) {
|
if (bslot == INVALID_INDEX) {
|
||||||
bind_out->type = 3;
|
bind_out->type = 3;
|
||||||
QueuePacket(outapp);
|
QueuePacket(outapp);
|
||||||
bind_out->type = 7; //this is the wrong message, dont know the right one.
|
bind_out->type = 7; // this is the wrong message, dont know the right one.
|
||||||
QueuePacket(outapp);
|
QueuePacket(outapp);
|
||||||
return(true);
|
safe_delete(outapp);
|
||||||
|
return (true);
|
||||||
}
|
}
|
||||||
DeleteItemInInventory(bslot, 1, true); //do we need client update?
|
DeleteItemInInventory(bslot, 1, true); // do we need client update?
|
||||||
|
|
||||||
// start complete timer
|
// start complete timer
|
||||||
bindwound_timer.Start(10000);
|
bindwound_timer.Start(10000);
|
||||||
@ -2597,51 +2597,46 @@ bool Client::BindWound(Mob* bindmob, bool start, bool fail){
|
|||||||
QueuePacket(outapp);
|
QueuePacket(outapp);
|
||||||
bind_out->type = 0;
|
bind_out->type = 0;
|
||||||
// Client Unlocked
|
// Client Unlocked
|
||||||
if(!bindmob) {
|
if (!bindmob) {
|
||||||
// send "bindmob dead" to client
|
// send "bindmob dead" to client
|
||||||
bind_out->type = 4;
|
bind_out->type = 4;
|
||||||
QueuePacket(outapp);
|
QueuePacket(outapp);
|
||||||
bind_out->type = 0;
|
bind_out->type = 0;
|
||||||
bindwound_timer.Disable();
|
bindwound_timer.Disable();
|
||||||
bindwound_target = 0;
|
bindwound_target = 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// send bindmob "stand still"
|
// send bindmob "stand still"
|
||||||
if(!bindmob->IsAIControlled() && bindmob != this ) {
|
if (!bindmob->IsAIControlled() && bindmob != this) {
|
||||||
bindmob->CastToClient()->Message_StringID(clientMessageYellow, YOU_ARE_BEING_BANDAGED);
|
bindmob->CastToClient()->Message_StringID(clientMessageYellow,
|
||||||
}
|
YOU_ARE_BEING_BANDAGED);
|
||||||
else if (bindmob->IsAIControlled() && bindmob != this ){
|
} else if (bindmob->IsAIControlled() && bindmob != this) {
|
||||||
; // Tell IPC to stand still?
|
; // Tell IPC to stand still?
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
; // Binding self
|
; // Binding self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (bindwound_timer.Check()) // Did the timer finish?
|
||||||
else if (bindwound_timer.Check()) // Did the timer finish?
|
|
||||||
{
|
{
|
||||||
// finish bind
|
// finish bind
|
||||||
// disable complete timer
|
// disable complete timer
|
||||||
bindwound_timer.Disable();
|
bindwound_timer.Disable();
|
||||||
bindwound_target = 0;
|
bindwound_target = 0;
|
||||||
if(!bindmob){
|
if (!bindmob) {
|
||||||
// send "bindmob gone" to client
|
// send "bindmob gone" to client
|
||||||
bind_out->type = 5; // not in zone
|
bind_out->type = 5; // not in zone
|
||||||
QueuePacket(outapp);
|
QueuePacket(outapp);
|
||||||
bind_out->type = 0;
|
bind_out->type = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
if (!GetFeigned() && (DistanceSquared(bindmob->GetPosition(), m_Position) <= 400)) {
|
if (!GetFeigned() && (DistanceSquared(bindmob->GetPosition(), m_Position) <= 400)) {
|
||||||
// send bindmob bind done
|
// send bindmob bind done
|
||||||
if(!bindmob->IsAIControlled() && bindmob != this ) {
|
if (!bindmob->IsAIControlled() && bindmob != this) {
|
||||||
|
|
||||||
}
|
} else if (bindmob->IsAIControlled() && bindmob != this) {
|
||||||
else if(bindmob->IsAIControlled() && bindmob != this ) {
|
// Tell IPC to resume??
|
||||||
// Tell IPC to resume??
|
} else {
|
||||||
}
|
// Binding self
|
||||||
else {
|
|
||||||
// Binding self
|
|
||||||
}
|
}
|
||||||
// Send client bind done
|
// Send client bind done
|
||||||
|
|
||||||
@ -2650,58 +2645,61 @@ bool Client::BindWound(Mob* bindmob, bool start, bool fail){
|
|||||||
bind_out->type = 0;
|
bind_out->type = 0;
|
||||||
CheckIncreaseSkill(SkillBindWound, nullptr, 5);
|
CheckIncreaseSkill(SkillBindWound, nullptr, 5);
|
||||||
|
|
||||||
int maxHPBonus = spellbonuses.MaxBindWound + itembonuses.MaxBindWound + aabonuses.MaxBindWound;
|
int maxHPBonus = spellbonuses.MaxBindWound + itembonuses.MaxBindWound +
|
||||||
|
aabonuses.MaxBindWound;
|
||||||
|
|
||||||
int max_percent = 50 + 10 * maxHPBonus;
|
int max_percent = 50 + 10 * maxHPBonus;
|
||||||
|
|
||||||
if(GetClass() == MONK && GetSkill(SkillBindWound) > 200) {
|
if (GetClass() == MONK && GetSkill(SkillBindWound) > 200) {
|
||||||
max_percent = 70 + 10 * maxHPBonus;
|
max_percent = 70 + 10 * maxHPBonus;
|
||||||
}
|
}
|
||||||
|
|
||||||
max_percent = mod_bindwound_percent(max_percent, bindmob);
|
max_percent = mod_bindwound_percent(max_percent, bindmob);
|
||||||
|
|
||||||
int max_hp = bindmob->GetMaxHP()*max_percent/100;
|
int max_hp = bindmob->GetMaxHP() * max_percent / 100;
|
||||||
|
|
||||||
// send bindmob new hp's
|
// send bindmob new hp's
|
||||||
if (bindmob->GetHP() < bindmob->GetMaxHP() && bindmob->GetHP() <= (max_hp)-1){
|
if (bindmob->GetHP() < bindmob->GetMaxHP() && bindmob->GetHP() <= (max_hp)-1) {
|
||||||
// 0.120 per skill point, 0.60 per skill level, minimum 3 max 30
|
// 0.120 per skill point, 0.60 per skill level, minimum 3 max 30
|
||||||
int bindhps = 3;
|
int bindhps = 3;
|
||||||
|
|
||||||
|
|
||||||
if (GetSkill(SkillBindWound) > 200) {
|
if (GetSkill(SkillBindWound) > 200) {
|
||||||
bindhps += GetSkill(SkillBindWound)*4/10;
|
bindhps += GetSkill(SkillBindWound) * 4 / 10;
|
||||||
} else if (GetSkill(SkillBindWound) >= 10) {
|
} else if (GetSkill(SkillBindWound) >= 10) {
|
||||||
bindhps += GetSkill(SkillBindWound)/4;
|
bindhps += GetSkill(SkillBindWound) / 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Implementation of aaMithanielsBinding is a guess (the multiplier)
|
// Implementation of aaMithanielsBinding is a guess (the multiplier)
|
||||||
int bindBonus = spellbonuses.BindWound + itembonuses.BindWound + aabonuses.BindWound;
|
int bindBonus = spellbonuses.BindWound + itembonuses.BindWound +
|
||||||
|
aabonuses.BindWound;
|
||||||
|
|
||||||
bindhps += bindhps*bindBonus / 100;
|
bindhps += bindhps * bindBonus / 100;
|
||||||
|
|
||||||
bindhps = mod_bindwound_hp(bindhps, bindmob);
|
bindhps = mod_bindwound_hp(bindhps, bindmob);
|
||||||
|
|
||||||
//if the bind takes them above the max bindable
|
// if the bind takes them above the max bindable
|
||||||
//cap it at that value. Dont know if live does it this way
|
// cap it at that value. Dont know if live does it this way
|
||||||
//but it makes sense to me.
|
// but it makes sense to me.
|
||||||
int chp = bindmob->GetHP() + bindhps;
|
int chp = bindmob->GetHP() + bindhps;
|
||||||
if(chp > max_hp)
|
if (chp > max_hp)
|
||||||
chp = max_hp;
|
chp = max_hp;
|
||||||
|
|
||||||
bindmob->SetHP(chp);
|
bindmob->SetHP(chp);
|
||||||
bindmob->SendHPUpdate();
|
bindmob->SendHPUpdate();
|
||||||
}
|
} else {
|
||||||
else {
|
// I dont have the real, live
|
||||||
//I dont have the real, live
|
Message(15, "You cannot bind wounds above %d%% hitpoints.",
|
||||||
Message(15, "You cannot bind wounds above %d%% hitpoints.", max_percent);
|
max_percent);
|
||||||
if(bindmob != this && bindmob->IsClient())
|
if (bindmob != this && bindmob->IsClient())
|
||||||
bindmob->CastToClient()->Message(15, "You cannot have your wounds bound above %d%% hitpoints.", max_percent);
|
bindmob->CastToClient()->Message(
|
||||||
|
15,
|
||||||
|
"You cannot have your wounds bound above %d%% hitpoints.",
|
||||||
|
max_percent);
|
||||||
// Too many hp message goes here.
|
// Too many hp message goes here.
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Send client bind failed
|
// Send client bind failed
|
||||||
if(bindmob != this)
|
if (bindmob != this)
|
||||||
bind_out->type = 6; // They moved
|
bind_out->type = 6; // They moved
|
||||||
else
|
else
|
||||||
bind_out->type = 7; // Bandager moved
|
bind_out->type = 7; // Bandager moved
|
||||||
@ -2711,11 +2709,10 @@ bool Client::BindWound(Mob* bindmob, bool start, bool fail){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (bindwound_timer.Enabled()) {
|
||||||
else if (bindwound_timer.Enabled()) {
|
|
||||||
// You moved
|
// You moved
|
||||||
outapp = new EQApplicationPacket(OP_Bind_Wound, sizeof(BindWound_Struct));
|
outapp = new EQApplicationPacket(OP_Bind_Wound, sizeof(BindWound_Struct));
|
||||||
BindWound_Struct* bind_out = (BindWound_Struct*) outapp->pBuffer;
|
BindWound_Struct *bind_out = (BindWound_Struct *)outapp->pBuffer;
|
||||||
bindwound_timer.Disable();
|
bindwound_timer.Disable();
|
||||||
bindwound_target = 0;
|
bindwound_target = 0;
|
||||||
bind_out->type = 7;
|
bind_out->type = 7;
|
||||||
@ -3649,19 +3646,25 @@ void Client::SetEndurance(int32 newEnd)
|
|||||||
SendManaUpdatePacket();
|
SendManaUpdatePacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::SacrificeConfirm(Client *caster) {
|
void Client::SacrificeConfirm(Client *caster)
|
||||||
|
{
|
||||||
|
EQApplicationPacket *outapp = new EQApplicationPacket(OP_Sacrifice, sizeof(Sacrifice_Struct));
|
||||||
|
Sacrifice_Struct *ss = (Sacrifice_Struct *)outapp->pBuffer;
|
||||||
|
|
||||||
EQApplicationPacket* outapp = new EQApplicationPacket(OP_Sacrifice, sizeof(Sacrifice_Struct));
|
if (!caster || PendingSacrifice) {
|
||||||
Sacrifice_Struct *ss = (Sacrifice_Struct*)outapp->pBuffer;
|
safe_delete(outapp);
|
||||||
|
|
||||||
if(!caster || PendingSacrifice) return;
|
|
||||||
|
|
||||||
if(GetLevel() < RuleI(Spells, SacrificeMinLevel)){
|
|
||||||
caster->Message_StringID(13, SAC_TOO_LOW); //This being is not a worthy sacrifice.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GetLevel() < RuleI(Spells, SacrificeMinLevel)) {
|
||||||
|
caster->Message_StringID(13, SAC_TOO_LOW); // This being is not a worthy sacrifice.
|
||||||
|
safe_delete(outapp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (GetLevel() > RuleI(Spells, SacrificeMaxLevel)) {
|
if (GetLevel() > RuleI(Spells, SacrificeMaxLevel)) {
|
||||||
caster->Message_StringID(13, SAC_TOO_HIGH);
|
caster->Message_StringID(13, SAC_TOO_HIGH);
|
||||||
|
safe_delete(outapp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3803,20 +3806,23 @@ void Client::SetHoTT(uint32 mobid) {
|
|||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::SendPopupToClient(const char *Title, const char *Text, uint32 PopupID, uint32 Buttons, uint32 Duration) {
|
void Client::SendPopupToClient(const char *Title, const char *Text, uint32 PopupID, uint32 Buttons, uint32 Duration)
|
||||||
|
{
|
||||||
|
|
||||||
EQApplicationPacket *outapp = new EQApplicationPacket(OP_OnLevelMessage, sizeof(OnLevelMessage_Struct));
|
EQApplicationPacket *outapp = new EQApplicationPacket(OP_OnLevelMessage, sizeof(OnLevelMessage_Struct));
|
||||||
OnLevelMessage_Struct *olms = (OnLevelMessage_Struct *) outapp->pBuffer;
|
OnLevelMessage_Struct *olms = (OnLevelMessage_Struct *)outapp->pBuffer;
|
||||||
|
|
||||||
if((strlen(Title) > (sizeof(olms->Title)-1)) ||
|
if ((strlen(Title) > (sizeof(olms->Title) - 1)) || (strlen(Text) > (sizeof(olms->Text) - 1))) {
|
||||||
(strlen(Text) > (sizeof(olms->Text)-1))) return;
|
safe_delete(outapp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(olms->Title, Title);
|
strcpy(olms->Title, Title);
|
||||||
strcpy(olms->Text, Text);
|
strcpy(olms->Text, Text);
|
||||||
|
|
||||||
olms->Buttons = Buttons;
|
olms->Buttons = Buttons;
|
||||||
|
|
||||||
if(Duration > 0)
|
if (Duration > 0)
|
||||||
olms->Duration = Duration * 1000;
|
olms->Duration = Duration * 1000;
|
||||||
else
|
else
|
||||||
olms->Duration = 0xffffffff;
|
olms->Duration = 0xffffffff;
|
||||||
@ -3843,8 +3849,10 @@ void Client::SendWindow(uint32 PopupID, uint32 NegativeID, uint32 Buttons, const
|
|||||||
EQApplicationPacket* app = new EQApplicationPacket(OP_OnLevelMessage, sizeof(OnLevelMessage_Struct));
|
EQApplicationPacket* app = new EQApplicationPacket(OP_OnLevelMessage, sizeof(OnLevelMessage_Struct));
|
||||||
OnLevelMessage_Struct* olms=(OnLevelMessage_Struct*)app->pBuffer;
|
OnLevelMessage_Struct* olms=(OnLevelMessage_Struct*)app->pBuffer;
|
||||||
|
|
||||||
if(strlen(Text) > (sizeof(olms->Text)-1))
|
if(strlen(Text) > (sizeof(olms->Text)-1)) {
|
||||||
|
safe_delete(app);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(!target)
|
if(!target)
|
||||||
title_type = 0;
|
title_type = 0;
|
||||||
|
|||||||
@ -13691,6 +13691,7 @@ void Client::Handle_OP_TraderShop(const EQApplicationPacket *app)
|
|||||||
else {
|
else {
|
||||||
Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderShop: entity_list.GetClientByID(tcs->traderid)"
|
Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderShop: entity_list.GetClientByID(tcs->traderid)"
|
||||||
" returned a nullptr pointer");
|
" returned a nullptr pointer");
|
||||||
|
safe_delete(outapp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3171,6 +3171,7 @@ void command_equipitem(Client *c, const Seperator *sep)
|
|||||||
if (partialmove) { // remove this con check if someone can figure out removing charges from cursor stack issue below
|
if (partialmove) { // remove this con check if someone can figure out removing charges from cursor stack issue below
|
||||||
// mi->number_in_stack is always from_inst->GetCharges() when partialmove is false
|
// mi->number_in_stack is always from_inst->GetCharges() when partialmove is false
|
||||||
c->Message(13, "Error: Partial stack added to existing stack exceeds allowable stacksize");
|
c->Message(13, "Error: Partial stack added to existing stack exceeds allowable stacksize");
|
||||||
|
safe_delete(outapp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(c->SwapItem(mi)) {
|
else if(c->SwapItem(mi)) {
|
||||||
|
|||||||
@ -4567,6 +4567,7 @@ void EntityList::ExpeditionWarning(uint32 minutes_left)
|
|||||||
it->second->QueuePacket(outapp);
|
it->second->QueuePacket(outapp);
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
safe_delete(outapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mob *EntityList::GetClosestMobByBodyType(Mob *sender, bodyType BodyType)
|
Mob *EntityList::GetClosestMobByBodyType(Mob *sender, bodyType BodyType)
|
||||||
|
|||||||
@ -383,6 +383,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower,
|
|||||||
"ORDER BY RAND() LIMIT 1", zone->GetShortName());
|
"ORDER BY RAND() LIMIT 1", zone->GetShortName());
|
||||||
auto results = database.QueryDatabase(query);
|
auto results = database.QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
|
safe_delete(npc_type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -139,90 +139,97 @@ bool SpawnGroupList::RemoveSpawnGroup(uint32 in_id) {
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::LoadSpawnGroups(const char* zone_name, uint16 version, SpawnGroupList* spawn_group_list) {
|
bool ZoneDatabase::LoadSpawnGroups(const char *zone_name, uint16 version, SpawnGroupList *spawn_group_list)
|
||||||
|
{
|
||||||
std::string query = StringFormat("SELECT DISTINCT(spawngroupID), spawngroup.name, spawngroup.spawn_limit, "
|
std::string query = StringFormat("SELECT DISTINCT(spawngroupID), spawngroup.name, spawngroup.spawn_limit, "
|
||||||
"spawngroup.dist, spawngroup.max_x, spawngroup.min_x, "
|
"spawngroup.dist, spawngroup.max_x, spawngroup.min_x, "
|
||||||
"spawngroup.max_y, spawngroup.min_y, spawngroup.delay, "
|
"spawngroup.max_y, spawngroup.min_y, spawngroup.delay, "
|
||||||
"spawngroup.despawn, spawngroup.despawn_timer, spawngroup.mindelay "
|
"spawngroup.despawn, spawngroup.despawn_timer, spawngroup.mindelay "
|
||||||
"FROM spawn2, spawngroup WHERE spawn2.spawngroupID = spawngroup.ID "
|
"FROM spawn2, spawngroup WHERE spawn2.spawngroupID = spawngroup.ID "
|
||||||
"AND spawn2.version = %u and zone = '%s'", version, zone_name);
|
"AND spawn2.version = %u and zone = '%s'",
|
||||||
auto results = QueryDatabase(query);
|
version, zone_name);
|
||||||
if (!results.Success()) {
|
auto results = QueryDatabase(query);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
|
||||||
SpawnGroup* newSpawnGroup = new SpawnGroup(atoi(row[0]), row[1], atoi(row[2]), atof(row[3]),
|
|
||||||
atof(row[4]), atof(row[5]), atof(row[6]), atof(row[7]),
|
|
||||||
atoi(row[8]), atoi(row[9]), atoi(row[10]), atoi(row[11]));
|
|
||||||
spawn_group_list->AddSpawnGroup(newSpawnGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
query = StringFormat("SELECT DISTINCT spawnentry.spawngroupID, npcid, chance, "
|
|
||||||
"npc_types.spawn_limit AS sl "
|
|
||||||
"FROM spawnentry, spawn2, npc_types "
|
|
||||||
"WHERE spawnentry.npcID=npc_types.id "
|
|
||||||
"AND spawnentry.spawngroupID = spawn2.spawngroupID "
|
|
||||||
"AND zone = '%s'", zone_name);
|
|
||||||
results = QueryDatabase(query);
|
|
||||||
if (!results.Success()) {
|
|
||||||
Log.Out(Logs::General, Logs::Error, "Error2 in PopulateZoneLists query '%'", query.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
|
||||||
SpawnEntry* newSpawnEntry = new SpawnEntry( atoi(row[1]), atoi(row[2]), row[3]?atoi(row[3]):0);
|
|
||||||
SpawnGroup *sg = spawn_group_list->GetSpawnGroup(atoi(row[0]));
|
|
||||||
|
|
||||||
if (!sg) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
sg->AddSpawnEntry(newSpawnEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ZoneDatabase::LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList* spawn_group_list) {
|
|
||||||
|
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT DISTINCT(spawngroup.id), spawngroup.name, spawngroup.spawn_limit, "
|
|
||||||
"spawngroup.dist, spawngroup.max_x, spawngroup.min_x, "
|
|
||||||
"spawngroup.max_y, spawngroup.min_y, spawngroup.delay, "
|
|
||||||
"spawngroup.despawn, spawngroup.despawn_timer, spawngroup.mindelay "
|
|
||||||
"FROM spawngroup WHERE spawngroup.ID = '%i'", spawngroupid);
|
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
if (!results.Success()) {
|
|
||||||
Log.Out(Logs::General, Logs::Error, "Error2 in PopulateZoneLists query %s", query.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
|
||||||
SpawnGroup* newSpawnGroup = new SpawnGroup(atoi(row[0]), row[1], atoi(row[2]), atof(row[3]), atof(row[4]), atof(row[5]), atof(row[6]), atof(row[7]), atoi(row[8]), atoi(row[9]), atoi(row[10]), atoi(row[11]));
|
|
||||||
spawn_group_list->AddSpawnGroup(newSpawnGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
query = StringFormat("SELECT DISTINCT(spawnentry.spawngroupID), spawnentry.npcid, "
|
|
||||||
"spawnentry.chance, spawngroup.spawn_limit FROM spawnentry, spawngroup "
|
|
||||||
"WHERE spawnentry.spawngroupID = '%i' AND spawngroup.spawn_limit = '0' "
|
|
||||||
"ORDER BY chance", spawngroupid);
|
|
||||||
results = QueryDatabase(query);
|
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
Log.Out(Logs::General, Logs::Error, "Error3 in PopulateZoneLists query '%s'", query.c_str());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
SpawnEntry* newSpawnEntry = new SpawnEntry( atoi(row[1]), atoi(row[2]), row[3]?atoi(row[3]):0);
|
SpawnGroup *newSpawnGroup = new SpawnGroup(atoi(row[0]), row[1], atoi(row[2]), atof(row[3]),
|
||||||
SpawnGroup *sg = spawn_group_list->GetSpawnGroup(atoi(row[0]));
|
atof(row[4]), atof(row[5]), atof(row[6]), atof(row[7]),
|
||||||
if (!sg) {
|
atoi(row[8]), atoi(row[9]), atoi(row[10]), atoi(row[11]));
|
||||||
continue;
|
spawn_group_list->AddSpawnGroup(newSpawnGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
sg->AddSpawnEntry(newSpawnEntry);
|
query = StringFormat("SELECT DISTINCT spawnentry.spawngroupID, npcid, chance, "
|
||||||
}
|
"npc_types.spawn_limit AS sl "
|
||||||
|
"FROM spawnentry, spawn2, npc_types "
|
||||||
|
"WHERE spawnentry.npcID=npc_types.id "
|
||||||
|
"AND spawnentry.spawngroupID = spawn2.spawngroupID "
|
||||||
|
"AND zone = '%s'",
|
||||||
|
zone_name);
|
||||||
|
results = QueryDatabase(query);
|
||||||
|
if (!results.Success()) {
|
||||||
|
Log.Out(Logs::General, Logs::Error, "Error2 in PopulateZoneLists query '%'", query.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
SpawnEntry *newSpawnEntry = new SpawnEntry(atoi(row[1]), atoi(row[2]), row[3] ? atoi(row[3]) : 0);
|
||||||
|
SpawnGroup *sg = spawn_group_list->GetSpawnGroup(atoi(row[0]));
|
||||||
|
|
||||||
|
if (!sg) {
|
||||||
|
safe_delete(newSpawnEntry);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
sg->AddSpawnEntry(newSpawnEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZoneDatabase::LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList *spawn_group_list)
|
||||||
|
{
|
||||||
|
std::string query = StringFormat("SELECT DISTINCT(spawngroup.id), spawngroup.name, spawngroup.spawn_limit, "
|
||||||
|
"spawngroup.dist, spawngroup.max_x, spawngroup.min_x, "
|
||||||
|
"spawngroup.max_y, spawngroup.min_y, spawngroup.delay, "
|
||||||
|
"spawngroup.despawn, spawngroup.despawn_timer, spawngroup.mindelay "
|
||||||
|
"FROM spawngroup WHERE spawngroup.ID = '%i'",
|
||||||
|
spawngroupid);
|
||||||
|
auto results = QueryDatabase(query);
|
||||||
|
if (!results.Success()) {
|
||||||
|
Log.Out(Logs::General, Logs::Error, "Error2 in PopulateZoneLists query %s", query.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
SpawnGroup *newSpawnGroup = new SpawnGroup(atoi(row[0]), row[1], atoi(row[2]), atof(row[3]),
|
||||||
|
atof(row[4]), atof(row[5]), atof(row[6]), atof(row[7]),
|
||||||
|
atoi(row[8]), atoi(row[9]), atoi(row[10]), atoi(row[11]));
|
||||||
|
spawn_group_list->AddSpawnGroup(newSpawnGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
query = StringFormat("SELECT DISTINCT(spawnentry.spawngroupID), spawnentry.npcid, "
|
||||||
|
"spawnentry.chance, spawngroup.spawn_limit FROM spawnentry, spawngroup "
|
||||||
|
"WHERE spawnentry.spawngroupID = '%i' AND spawngroup.spawn_limit = '0' "
|
||||||
|
"ORDER BY chance",
|
||||||
|
spawngroupid);
|
||||||
|
results = QueryDatabase(query);
|
||||||
|
if (!results.Success()) {
|
||||||
|
Log.Out(Logs::General, Logs::Error, "Error3 in PopulateZoneLists query '%s'", query.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
SpawnEntry *newSpawnEntry = new SpawnEntry(atoi(row[1]), atoi(row[2]), row[3] ? atoi(row[3]) : 0);
|
||||||
|
SpawnGroup *sg = spawn_group_list->GetSpawnGroup(atoi(row[0]));
|
||||||
|
if (!sg) {
|
||||||
|
safe_delete(newSpawnEntry);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
sg->AddSpawnEntry(newSpawnEntry);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2401,8 +2401,10 @@ void Client::SendBuyerResults(char* searchString, uint32 searchID) {
|
|||||||
|
|
||||||
const Item_Struct* item = database.GetItem(itemID);
|
const Item_Struct* item = database.GetItem(itemID);
|
||||||
|
|
||||||
if(!item)
|
if(!item) {
|
||||||
|
safe_delete(outapp);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Save having to scan the client list when dealing with multiple buylines for the same Character.
|
// Save having to scan the client list when dealing with multiple buylines for the same Character.
|
||||||
if(charID != lastCharID) {
|
if(charID != lastCharID) {
|
||||||
@ -2410,8 +2412,10 @@ void Client::SendBuyerResults(char* searchString, uint32 searchID) {
|
|||||||
lastCharID = charID;
|
lastCharID = charID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!buyer)
|
if(!buyer) {
|
||||||
|
safe_delete(outapp);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
VARSTRUCT_ENCODE_TYPE(uint32, buf, Barter_BuyerSearchResults); // Command
|
VARSTRUCT_ENCODE_TYPE(uint32, buf, Barter_BuyerSearchResults); // Command
|
||||||
VARSTRUCT_ENCODE_TYPE(uint32, buf, searchID); // Match up results with the request
|
VARSTRUCT_ENCODE_TYPE(uint32, buf, searchID); // Match up results with the request
|
||||||
@ -2493,8 +2497,10 @@ void Client::ShowBuyLines(const EQApplicationPacket *app) {
|
|||||||
|
|
||||||
const Item_Struct* item = database.GetItem(ItemID);
|
const Item_Struct* item = database.GetItem(ItemID);
|
||||||
|
|
||||||
if(!item)
|
if(!item) {
|
||||||
|
safe_delete(outapp);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
VARSTRUCT_ENCODE_TYPE(uint32, Buf, Barter_BuyerInspectWindow);
|
VARSTRUCT_ENCODE_TYPE(uint32, Buf, Barter_BuyerInspectWindow);
|
||||||
VARSTRUCT_ENCODE_TYPE(uint32, Buf, BuySlot);
|
VARSTRUCT_ENCODE_TYPE(uint32, Buf, BuySlot);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user