Merge branch 'master' into bot-rewrite

This commit is contained in:
nytmyr
2025-01-31 00:24:05 -06:00
15 changed files with 140 additions and 147 deletions
+19
View File
@@ -1,3 +1,22 @@
## [22.62.1] 1/27/2025
### Memory Leak
* Revert "Change raw pointer to unique_ptr to avoid potential leak in dbg stream" ([#4616](https://github.com/EQEmu/Server/pull/4616)) @Akkadius 2025-01-27
### Performance
* Re-use ClientUpdate packet memory ([#4619](https://github.com/EQEmu/Server/pull/4619)) @Akkadius 2025-01-27
* Re-use OP_Animation packet ([#4621](https://github.com/EQEmu/Server/pull/4621)) @Akkadius 2025-01-27
* Re-use OP_Damage packet memory ([#4625](https://github.com/EQEmu/Server/pull/4625)) @Akkadius 2025-01-27
* Re-use OP_HPUpdate packet memory ([#4622](https://github.com/EQEmu/Server/pull/4622)) @Akkadius 2025-01-27
* Re-use OP_PlayerStateAdd packet memory ([#4626](https://github.com/EQEmu/Server/pull/4626)) @Akkadius 2025-01-27
* Re-use OP_SendFindableNPCs packet memory ([#4623](https://github.com/EQEmu/Server/pull/4623)) @Akkadius 2025-01-27
### Repop
* Make #repop instant ([#4620](https://github.com/EQEmu/Server/pull/4620)) @Akkadius 2025-01-27
## [22.62.0] 1/26/2025 ## [22.62.0] 1/26/2025
### Bazaar ### Bazaar
+5 -3
View File
@@ -500,9 +500,10 @@ void EQ::Net::DaybreakConnection::ProcessQueue()
break; break;
} }
auto &packet = iter->second; auto packet = iter->second;
stream->packet_queue.erase(iter); stream->packet_queue.erase(iter);
ProcessDecodedPacket(*packet); ProcessDecodedPacket(*packet);
delete packet;
} }
} }
} }
@@ -512,8 +513,9 @@ void EQ::Net::DaybreakConnection::RemoveFromQueue(int stream, uint16_t seq)
auto s = &m_streams[stream]; auto s = &m_streams[stream];
auto iter = s->packet_queue.find(seq); auto iter = s->packet_queue.find(seq);
if (iter != s->packet_queue.end()) { if (iter != s->packet_queue.end()) {
auto &packet = iter->second; auto packet = iter->second;
s->packet_queue.erase(iter); s->packet_queue.erase(iter);
delete packet;
} }
} }
@@ -525,7 +527,7 @@ void EQ::Net::DaybreakConnection::AddToQueue(int stream, uint16_t seq, const Pac
DynamicPacket *out = new DynamicPacket(); DynamicPacket *out = new DynamicPacket();
out->PutPacket(0, p); out->PutPacket(0, p);
s->packet_queue.emplace(std::make_pair(seq, std::unique_ptr<Packet>(out))); s->packet_queue.emplace(std::make_pair(seq, out));
} }
} }
+1 -1
View File
@@ -201,7 +201,7 @@ namespace EQ
uint16_t sequence_in; uint16_t sequence_in;
uint16_t sequence_out; uint16_t sequence_out;
std::map<uint16_t, std::unique_ptr<Packet>> packet_queue; std::map<uint16_t, Packet*> packet_queue;
DynamicPacket fragment_packet; DynamicPacket fragment_packet;
uint32_t fragment_current_bytes; uint32_t fragment_current_bytes;
+1 -1
View File
@@ -25,7 +25,7 @@
// Build variables // Build variables
// these get injected during the build pipeline // these get injected during the build pipeline
#define CURRENT_VERSION "22.62.0-dev" // always append -dev to the current version for custom-builds #define CURRENT_VERSION "22.62.1-dev" // always append -dev to the current version for custom-builds
#define LOGIN_VERSION "0.8.0" #define LOGIN_VERSION "0.8.0"
#define COMPILE_DATE __DATE__ #define COMPILE_DATE __DATE__
#define COMPILE_TIME __TIME__ #define COMPILE_TIME __TIME__
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "eqemu-server", "name": "eqemu-server",
"version": "22.62.0", "version": "22.62.1",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/EQEmu/Server.git" "url": "https://github.com/EQEmu/Server.git"
+20 -26
View File
@@ -2564,16 +2564,12 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
const uint8 killed_level = GetLevel(); const uint8 killed_level = GetLevel();
if (GetClass() == Class::LDoNTreasure) { // open chest if (GetClass() == Class::LDoNTreasure) { // open chest
auto outapp = new EQApplicationPacket(OP_Animation, sizeof(Animation_Struct)); static EQApplicationPacket p(OP_Animation, sizeof(Animation_Struct));
auto a = (Animation_Struct*) p.pBuffer;
auto a = (Animation_Struct*) outapp->pBuffer;
a->spawnid = GetID(); a->spawnid = GetID();
a->action = 0x0F; a->action = 0x0F;
a->speed = 10; a->speed = 10;
entity_list.QueueCloseClients(this, &p);
entity_list.QueueCloseClients(this, outapp);
safe_delete(outapp);
} }
auto app = new EQApplicationPacket(OP_Death, sizeof(Death_Struct)); auto app = new EQApplicationPacket(OP_Death, sizeof(Death_Struct));
@@ -3412,15 +3408,15 @@ void Mob::DamageShield(Mob* attacker, bool spell_ds) {
attacker->Damage(this, -DS, spellid, EQ::skills::SkillAbjuration/*hackish*/, false); attacker->Damage(this, -DS, spellid, EQ::skills::SkillAbjuration/*hackish*/, false);
//we can assume there is a spell now //we can assume there is a spell now
auto outapp = new EQApplicationPacket(OP_Damage, sizeof(CombatDamage_Struct));
CombatDamage_Struct* cds = (CombatDamage_Struct*)outapp->pBuffer; static EQApplicationPacket p(OP_Damage, sizeof(CombatDamage_Struct));
cds->target = attacker->GetID(); auto b = (CombatDamage_Struct *) p.pBuffer;
cds->source = GetID(); b->target = attacker->GetID();
cds->type = spellbonuses.DamageShieldType; b->source = GetID();
cds->spellid = 0x0; b->type = spellbonuses.DamageShieldType;
cds->damage = DS; b->spellid = 0x0;
entity_list.QueueCloseClients(this, outapp); b->damage = DS;
safe_delete(outapp); entity_list.QueueCloseClients(this, &p);
} }
else if (DS > 0 && !spell_ds) { else if (DS > 0 && !spell_ds) {
//we are healing the attacker... //we are healing the attacker...
@@ -4537,8 +4533,8 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
//send damage packet... //send damage packet...
if (!iBuffTic) { //buff ticks do not send damage, instead they just call SendHPUpdate(), which is done above if (!iBuffTic) { //buff ticks do not send damage, instead they just call SendHPUpdate(), which is done above
auto outapp = new EQApplicationPacket(OP_Damage, sizeof(CombatDamage_Struct)); static EQApplicationPacket p(OP_Damage, sizeof(CombatDamage_Struct));
CombatDamage_Struct* a = (CombatDamage_Struct*)outapp->pBuffer; auto a = (CombatDamage_Struct *) p.pBuffer;
a->target = GetID(); a->target = GetID();
if (!attacker) { if (!attacker) {
@@ -4619,7 +4615,7 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
if (!FromDamageShield) { if (!FromDamageShield) {
entity_list.QueueCloseClients( entity_list.QueueCloseClients(
attacker, /* Sender */ attacker, /* Sender */
outapp, /* packet */ &p, /* packet */
false, /* Skip Sender */ false, /* Skip Sender */
((IsValidSpell(spell_id)) ? RuleI(Range, SpellMessages) : RuleI(Range, DamageMessages)), ((IsValidSpell(spell_id)) ? RuleI(Range, SpellMessages) : RuleI(Range, DamageMessages)),
0, /* don't skip anyone on spell */ 0, /* don't skip anyone on spell */
@@ -4693,11 +4689,11 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
filter = FilterMyMisses; filter = FilterMyMisses;
if (attacker->IsClient()) { if (attacker->IsClient()) {
attacker->CastToClient()->QueuePacket(outapp, true, CLIENT_CONNECTED, filter); attacker->CastToClient()->QueuePacket(&p, true, CLIENT_CONNECTED, filter);
} else { } else {
entity_list.QueueCloseClients( entity_list.QueueCloseClients(
attacker, /* Sender */ attacker, /* Sender */
outapp, /* packet */ &p, /* packet */
false, /* Skip Sender */ false, /* Skip Sender */
( (
IsValidSpell(spell_id) ? IsValidSpell(spell_id) ?
@@ -4752,7 +4748,7 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
a->type = DamageTypeSpell; a->type = DamageTypeSpell;
entity_list.QueueCloseClients( entity_list.QueueCloseClients(
this, /* Sender */ this, /* Sender */
outapp, /* packet */ &p, /* packet */
false, /* Skip Sender */ false, /* Skip Sender */
range, /* distance packet travels at the speed of sound */ range, /* distance packet travels at the speed of sound */
0, /* don't skip anyone on spell */ 0, /* don't skip anyone on spell */
@@ -4763,7 +4759,7 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
else { else {
//I dont think any filters apply to damage affecting us //I dont think any filters apply to damage affecting us
if (IsClient()) { if (IsClient()) {
CastToClient()->QueuePacket(outapp); CastToClient()->QueuePacket(&p);
} }
// Send normal message to observers // Send normal message to observers
@@ -4773,7 +4769,7 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
if (!owner || (owner && !owner->IsClient())) { if (!owner || (owner && !owner->IsClient())) {
entity_list.QueueCloseClients( entity_list.QueueCloseClients(
this, /* Sender */ this, /* Sender */
outapp, /* packet */ &p, /* packet */
true, /* Skip Sender */ true, /* Skip Sender */
range, /* distance packet travels at the speed of sound */ range, /* distance packet travels at the speed of sound */
(IsValidSpell(spell_id) && skill_used != EQ::skills::SkillTigerClaw) ? 0 : skip, (IsValidSpell(spell_id) && skill_used != EQ::skills::SkillTigerClaw) ? 0 : skip,
@@ -4783,8 +4779,6 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
} }
} }
} }
safe_delete(outapp);
} }
else { else {
//else, it is a buff tic... //else, it is a buff tic...
+5 -4
View File
@@ -735,21 +735,22 @@ bool Aura::Process()
if (movement_type == AuraMovement::Follow && GetPosition() != owner->GetPosition() && movement_timer.Check()) { if (movement_type == AuraMovement::Follow && GetPosition() != owner->GetPosition() && movement_timer.Check()) {
m_Position = owner->GetPosition(); m_Position = owner->GetPosition();
auto app = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
auto spu = (PlayerPositionUpdateServer_Struct *) app->pBuffer; static EQApplicationPacket packet(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
auto spu = (PlayerPositionUpdateServer_Struct *) packet.pBuffer;
MakeSpawnUpdate(spu); MakeSpawnUpdate(spu);
auto it = spawned_for.begin(); auto it = spawned_for.begin();
while (it != spawned_for.end()) { while (it != spawned_for.end()) {
auto client = entity_list.GetClientByID(*it); auto client = entity_list.GetClientByID(*it);
if (client) { if (client) {
client->QueuePacket(app); client->QueuePacket(&packet);
++it; ++it;
} }
else { else {
it = spawned_for.erase(it); it = spawned_for.erase(it);
} }
} }
safe_delete(app);
} }
// TODO: waypoints? // TODO: waypoints?
+12 -16
View File
@@ -4856,11 +4856,10 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) {
auto boat_delta = glm::vec4(ppu->delta_x, ppu->delta_y, ppu->delta_z, EQ10toFloat(ppu->delta_heading)); auto boat_delta = glm::vec4(ppu->delta_x, ppu->delta_y, ppu->delta_z, EQ10toFloat(ppu->delta_heading));
cmob->SetDelta(boat_delta); cmob->SetDelta(boat_delta);
auto outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); static EQApplicationPacket outapp(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
PlayerPositionUpdateServer_Struct *ppus = (PlayerPositionUpdateServer_Struct *) outapp->pBuffer; auto *ppus = (PlayerPositionUpdateServer_Struct *) outapp.pBuffer;
cmob->MakeSpawnUpdate(ppus); cmob->MakeSpawnUpdate(ppus);
entity_list.QueueCloseClients(cmob, outapp, true, 300, this, false); entity_list.QueueCloseClients(cmob, &outapp, true, 300, this, false);
safe_delete(outapp);
/* Update the boat's position on the server, without sending an update */ /* Update the boat's position on the server, without sending an update */
cmob->GMMove(ppu->x_pos, ppu->y_pos, ppu->z_pos, EQ12toFloat(ppu->heading)); cmob->GMMove(ppu->x_pos, ppu->y_pos, ppu->z_pos, EQ12toFloat(ppu->heading));
@@ -5034,15 +5033,15 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) {
m_Position.w = new_heading; m_Position.w = new_heading;
/* Broadcast update to other clients */ /* Broadcast update to other clients */
auto outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); static EQApplicationPacket outapp(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
PlayerPositionUpdateServer_Struct *position_update = (PlayerPositionUpdateServer_Struct *) outapp->pBuffer; PlayerPositionUpdateServer_Struct *position_update = (PlayerPositionUpdateServer_Struct *) outapp.pBuffer;
MakeSpawnUpdate(position_update); MakeSpawnUpdate(position_update);
if (gm_hide_me) { if (gm_hide_me) {
entity_list.QueueClientsStatus(this, outapp, true, Admin(), AccountStatus::Max); entity_list.QueueClientsStatus(this, &outapp, true, Admin(), AccountStatus::Max);
} else { } else {
entity_list.QueueCloseClients(this, outapp, true, RuleI(Range, ClientPositionUpdates), nullptr, true); entity_list.QueueCloseClients(this, &outapp, true, RuleI(Range, ClientPositionUpdates), nullptr, true);
} }
@@ -5051,12 +5050,10 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) {
Raid *raid = GetRaid(); Raid *raid = GetRaid();
if (raid) { if (raid) {
raid->QueueClients(this, outapp, true, true, (RuleI(Range, ClientPositionUpdates) * -1)); raid->QueueClients(this, &outapp, true, true, (RuleI(Range, ClientPositionUpdates) * -1));
} else if (group) { } else if (group) {
group->QueueClients(this, outapp, true, true, (RuleI(Range, ClientPositionUpdates) * -1)); group->QueueClients(this, &outapp, true, true, (RuleI(Range, ClientPositionUpdates) * -1));
} }
safe_delete(outapp);
} }
if (zone->watermap) { if (zone->watermap) {
@@ -16776,13 +16773,12 @@ bool Client::CanTradeFVNoDropItem()
void Client::SendMobPositions() void Client::SendMobPositions()
{ {
auto p = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); static EQApplicationPacket p(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
auto *s = (PlayerPositionUpdateServer_Struct *) p->pBuffer; auto *s = (PlayerPositionUpdateServer_Struct *) p.pBuffer;
for (auto &m: entity_list.GetMobList()) { for (auto &m: entity_list.GetMobList()) {
m.second->MakeSpawnUpdate(s); m.second->MakeSpawnUpdate(s);
QueuePacket(p, false); QueuePacket(&p, false);
} }
safe_delete(p);
} }
struct RecordKillCheck { struct RecordKillCheck {
+28 -34
View File
@@ -5312,15 +5312,12 @@ void EntityList::SendFindableNPCList(Client *c)
return; return;
} }
auto outapp = new EQApplicationPacket(OP_SendFindableNPCs, sizeof(FindableNPC_Struct)); static EQApplicationPacket p(OP_SendFindableNPCs, sizeof(FindableNPC_Struct));
auto b = (FindableNPC_Struct*) p.pBuffer;
FindableNPC_Struct *fnpcs = (FindableNPC_Struct *)outapp->pBuffer; b->Unknown109 = 0x16;
b->Unknown110 = 0x06;
fnpcs->Unknown109 = 0x16; b->Unknown111 = 0x24;
fnpcs->Unknown110 = 0x06; b->Action = 0;
fnpcs->Unknown111 = 0x24;
fnpcs->Action = 0;
auto it = npc_list.begin(); auto it = npc_list.begin();
while (it != npc_list.end()) { while (it != npc_list.end()) {
@@ -5328,50 +5325,47 @@ void EntityList::SendFindableNPCList(Client *c)
NPC *n = it->second; NPC *n = it->second;
if (n->IsFindable()) { if (n->IsFindable()) {
fnpcs->EntityID = n->GetID(); b->EntityID = n->GetID();
strn0cpy(fnpcs->Name, n->GetCleanName(), sizeof(fnpcs->Name)); strn0cpy(b->Name, n->GetCleanName(), sizeof(b->Name));
strn0cpy(fnpcs->LastName, n->GetLastName(), sizeof(fnpcs->LastName)); strn0cpy(b->LastName, n->GetLastName(), sizeof(b->LastName));
fnpcs->Race = n->GetRace(); b->Race = n->GetRace();
fnpcs->Class = n->GetClass(); b->Class = n->GetClass();
c->QueuePacket(outapp); c->QueuePacket(&p);
} }
} }
++it; ++it;
} }
safe_delete(outapp);
} }
void EntityList::UpdateFindableNPCState(NPC *n, bool Remove) void EntityList::UpdateFindableNPCState(NPC *n, bool Remove)
{ {
if (!n || !n->IsFindable()) if (!n || !n->IsFindable()) {
return; return;
}
auto outapp = new EQApplicationPacket(OP_SendFindableNPCs, sizeof(FindableNPC_Struct)); static EQApplicationPacket p(OP_SendFindableNPCs, sizeof(FindableNPC_Struct));
auto b = (FindableNPC_Struct *) p.pBuffer;
b->Unknown109 = 0x16;
b->Unknown110 = 0x06;
b->Unknown111 = 0x24;
FindableNPC_Struct *fnpcs = (FindableNPC_Struct *)outapp->pBuffer; b->Action = Remove ? 1 : 0;
b->EntityID = n->GetID();
fnpcs->Unknown109 = 0x16; strn0cpy(b->Name, n->GetCleanName(), sizeof(b->Name));
fnpcs->Unknown110 = 0x06; strn0cpy(b->LastName, n->GetLastName(), sizeof(b->LastName));
fnpcs->Unknown111 = 0x24; b->Race = n->GetRace();
b->Class = n->GetClass();
fnpcs->Action = Remove ? 1: 0;
fnpcs->EntityID = n->GetID();
strn0cpy(fnpcs->Name, n->GetCleanName(), sizeof(fnpcs->Name));
strn0cpy(fnpcs->LastName, n->GetLastName(), sizeof(fnpcs->LastName));
fnpcs->Race = n->GetRace();
fnpcs->Class = n->GetClass();
auto it = client_list.begin(); auto it = client_list.begin();
while (it != client_list.end()) { while (it != client_list.end()) {
Client *c = it->second; Client *c = it->second;
if (c && (c->ClientVersion() >= EQ::versions::ClientVersion::SoD)) if (c && (c->ClientVersion() >= EQ::versions::ClientVersion::SoD)) {
c->QueuePacket(outapp); c->QueuePacket(&p);
}
++it; ++it;
} }
safe_delete(outapp);
} }
void EntityList::HideCorpses(Client *c, uint8 CurrentMode, uint8 NewMode) void EntityList::HideCorpses(Client *c, uint8 CurrentMode, uint8 NewMode)
+22 -31
View File
@@ -125,7 +125,7 @@ Mob::Mob(
tmHidden(-1), tmHidden(-1),
mitigation_ac(0), mitigation_ac(0),
m_specialattacks(eSpecialAttacks::None), m_specialattacks(eSpecialAttacks::None),
attack_anim_timer(500), attack_anim_timer(100),
position_update_melee_push_timer(500), position_update_melee_push_timer(500),
hate_list_cleanup_timer(6000), hate_list_cleanup_timer(6000),
m_scan_close_mobs_timer(6000), m_scan_close_mobs_timer(6000),
@@ -1522,16 +1522,12 @@ void Mob::SendHPUpdate(bool force_update_all)
last_hp last_hp
); );
auto client_packet = new EQApplicationPacket(OP_HPUpdate, sizeof(SpawnHPUpdate_Struct)); static EQApplicationPacket p(OP_HPUpdate, sizeof(SpawnHPUpdate_Struct));
auto *hp_packet_client = (SpawnHPUpdate_Struct *) client_packet->pBuffer; auto b = (SpawnHPUpdate_Struct*) p.pBuffer;
b->cur_hp = static_cast<uint32>(CastToClient()->GetHP() - itembonuses.HP);
hp_packet_client->cur_hp = static_cast<uint32>(CastToClient()->GetHP() - itembonuses.HP); b->spawn_id = GetID();
hp_packet_client->spawn_id = GetID(); b->max_hp = CastToClient()->GetMaxHP() - itembonuses.HP;
hp_packet_client->max_hp = CastToClient()->GetMaxHP() - itembonuses.HP; CastToClient()->QueuePacket(&p);
CastToClient()->QueuePacket(client_packet);
safe_delete(client_packet);
ResetHPUpdateTimer(); ResetHPUpdateTimer();
@@ -3545,24 +3541,21 @@ void Mob::DoAnim(const int animation_id, int animation_speed, bool ackreq, eqFil
return; return;
} }
auto outapp = new EQApplicationPacket(OP_Animation, sizeof(Animation_Struct)); static EQApplicationPacket p(OP_Animation, sizeof(Animation_Struct));
auto *a = (Animation_Struct *) outapp->pBuffer; auto a = (Animation_Struct*) p.pBuffer;
a->spawnid = GetID(); a->spawnid = GetID();
a->action = animation_id; a->action = animation_id;
a->speed = animation_speed ? animation_speed : 10; a->speed = animation_speed ? animation_speed : 10;
entity_list.QueueCloseClients( entity_list.QueueCloseClients(
this, /* Sender */ this, /* Sender */
outapp, /* Packet */ &p, /* Packet */
false, /* Ignore Sender */ false, /* Ignore Sender */
RuleI(Range, Anims), RuleI(Range, Anims),
0, /* Skip this mob */ 0, /* Skip this mob */
ackreq, /* Packet ACK */ ackreq, /* Packet ACK */
filter /* eqFilterType filter */ filter /* eqFilterType filter */
); );
safe_delete(outapp);
} }
void Mob::ShowBuffs(Client* c) { void Mob::ShowBuffs(Client* c) {
@@ -7725,28 +7718,26 @@ bool Mob::CanRaceEquipItem(uint32 item_id)
void Mob::SendAddPlayerState(PlayerState new_state) void Mob::SendAddPlayerState(PlayerState new_state)
{ {
auto app = new EQApplicationPacket(OP_PlayerStateAdd, sizeof(PlayerState_Struct)); static EQApplicationPacket p(OP_PlayerStateAdd, sizeof(PlayerState_Struct));
auto ps = (PlayerState_Struct *)app->pBuffer; auto b = (PlayerState_Struct *) p.pBuffer;
ps->spawn_id = GetID(); b->spawn_id = GetID();
ps->state = static_cast<uint32>(new_state); b->state = static_cast<uint32>(new_state);
AddPlayerState(ps->state); AddPlayerState(b->state);
entity_list.QueueClients(nullptr, app); entity_list.QueueClients(nullptr, &p);
safe_delete(app);
} }
void Mob::SendRemovePlayerState(PlayerState old_state) void Mob::SendRemovePlayerState(PlayerState old_state)
{ {
auto app = new EQApplicationPacket(OP_PlayerStateRemove, sizeof(PlayerState_Struct)); static EQApplicationPacket p(OP_PlayerStateRemove, sizeof(PlayerState_Struct));
auto ps = (PlayerState_Struct *)app->pBuffer; auto b = (PlayerState_Struct *) p.pBuffer;
ps->spawn_id = GetID(); b->spawn_id = GetID();
ps->state = static_cast<uint32>(old_state); b->state = static_cast<uint32>(old_state);
RemovePlayerState(ps->state); RemovePlayerState(b->state);
entity_list.QueueClients(nullptr, app); entity_list.QueueClients(nullptr, &p);
safe_delete(app);
} }
int32 Mob::GetMeleeMitigation() { int32 Mob::GetMeleeMitigation() {
+4 -4
View File
@@ -824,8 +824,8 @@ void MobMovementManager::SendCommandToClients(
return; return;
} }
EQApplicationPacket outapp(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); static EQApplicationPacket p(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
auto *spu = (PlayerPositionUpdateServer_Struct *) outapp.pBuffer; auto *spu = (PlayerPositionUpdateServer_Struct *) p.pBuffer;
FillCommandStruct(spu, mob, delta_x, delta_y, delta_z, delta_heading, anim); FillCommandStruct(spu, mob, delta_x, delta_y, delta_z, delta_heading, anim);
@@ -862,7 +862,7 @@ void MobMovementManager::SendCommandToClients(
} }
} }
c->QueuePacket(&outapp, false); c->QueuePacket(&p, false);
c->m_last_seen_mob_position[mob->GetID()] = mob->GetPosition(); c->m_last_seen_mob_position[mob->GetID()] = mob->GetPosition();
} }
} }
@@ -924,7 +924,7 @@ void MobMovementManager::SendCommandToClients(
} }
} }
c->QueuePacket(&outapp, false); c->QueuePacket(&p, false);
c->m_last_seen_mob_position[mob->GetID()] = mob->GetPosition(); c->m_last_seen_mob_position[mob->GetID()] = mob->GetPosition();
} }
} }
+3 -4
View File
@@ -3824,13 +3824,12 @@ int NPC::GetRolledItemCount(uint32 item_id)
void NPC::SendPositionToClients() void NPC::SendPositionToClients()
{ {
auto p = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); static EQApplicationPacket p(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
auto *s = (PlayerPositionUpdateServer_Struct *) p->pBuffer; auto *s = (PlayerPositionUpdateServer_Struct *) p.pBuffer;
for (auto &c: entity_list.GetClientList()) { for (auto &c: entity_list.GetClientList()) {
MakeSpawnUpdate(s); MakeSpawnUpdate(s);
c.second->QueuePacket(p, false); c.second->QueuePacket(&p, false);
} }
safe_delete(p);
} }
void NPC::HandleRoambox() void NPC::HandleRoambox()
+1
View File
@@ -533,6 +533,7 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spa
); );
spawn2_list.Insert(new_spawn); spawn2_list.Insert(new_spawn);
new_spawn->Process();
} }
LogInfo("Loaded [{}] spawn2 entries", Strings::Commify(l.size())); LogInfo("Loaded [{}] spawn2 entries", Strings::Commify(l.size()));
+15 -18
View File
@@ -953,9 +953,9 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
auto action_packet = auto action_packet =
new EQApplicationPacket(OP_Action, sizeof(Action_Struct)); new EQApplicationPacket(OP_Action, sizeof(Action_Struct));
Action_Struct* action = (Action_Struct*) action_packet->pBuffer; Action_Struct* action = (Action_Struct*) action_packet->pBuffer;
auto message_packet =
new EQApplicationPacket(OP_Damage, sizeof(CombatDamage_Struct)); static EQApplicationPacket p(OP_Damage, sizeof(CombatDamage_Struct));
CombatDamage_Struct *cd = (CombatDamage_Struct *)message_packet->pBuffer; auto cd = (CombatDamage_Struct *) p.pBuffer;
action->target = GetID(); action->target = GetID();
action->source = caster ? caster->GetID() : GetID(); action->source = caster ? caster->GetID() : GetID();
@@ -978,16 +978,15 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
caster->CastToClient()->QueuePacket(action_packet); caster->CastToClient()->QueuePacket(action_packet);
} }
CastToClient()->QueuePacket(message_packet); CastToClient()->QueuePacket(&p);
if (caster && caster->IsClient() && caster != this) { if (caster && caster->IsClient() && caster != this) {
caster->CastToClient()->QueuePacket(message_packet); caster->CastToClient()->QueuePacket(&p);
} }
CastToClient()->SetBindPoint(spells[spell_id].base_value[i] - 1); CastToClient()->SetBindPoint(spells[spell_id].base_value[i] - 1);
Save(); Save();
safe_delete(action_packet); safe_delete(action_packet);
safe_delete(message_packet);
} else { } else {
if (!zone->CanBind()) { if (!zone->CanBind()) {
MessageString(Chat::SpellFailure, CANNOT_BIND); MessageString(Chat::SpellFailure, CANNOT_BIND);
@@ -1002,9 +1001,9 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
auto action_packet = new EQApplicationPacket( auto action_packet = new EQApplicationPacket(
OP_Action, sizeof(Action_Struct)); OP_Action, sizeof(Action_Struct));
Action_Struct* action = (Action_Struct*) action_packet->pBuffer; Action_Struct* action = (Action_Struct*) action_packet->pBuffer;
auto message_packet = new EQApplicationPacket(
OP_Damage, sizeof(CombatDamage_Struct)); static EQApplicationPacket p(OP_Damage, sizeof(CombatDamage_Struct));
CombatDamage_Struct *cd = (CombatDamage_Struct *)message_packet->pBuffer; auto cd = (CombatDamage_Struct *) p.pBuffer;
action->target = GetID(); action->target = GetID();
action->source = caster ? caster->GetID() : GetID(); action->source = caster ? caster->GetID() : GetID();
@@ -1027,24 +1026,23 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
caster->CastToClient()->QueuePacket(action_packet); caster->CastToClient()->QueuePacket(action_packet);
} }
CastToClient()->QueuePacket(message_packet); CastToClient()->QueuePacket(&p);
if (caster->IsClient() && caster != this) { if (caster->IsClient() && caster != this) {
caster->CastToClient()->QueuePacket(message_packet); caster->CastToClient()->QueuePacket(&p);
} }
CastToClient()->SetBindPoint(spells[spell_id].base_value[i] - 1); CastToClient()->SetBindPoint(spells[spell_id].base_value[i] - 1);
Save(); Save();
safe_delete(action_packet); safe_delete(action_packet);
safe_delete(message_packet);
} }
} else { } else {
auto action_packet = auto action_packet =
new EQApplicationPacket(OP_Action, sizeof(Action_Struct)); new EQApplicationPacket(OP_Action, sizeof(Action_Struct));
Action_Struct* action = (Action_Struct*) action_packet->pBuffer; Action_Struct* action = (Action_Struct*) action_packet->pBuffer;
auto message_packet = new EQApplicationPacket(
OP_Damage, sizeof(CombatDamage_Struct)); static EQApplicationPacket p(OP_Damage, sizeof(CombatDamage_Struct));
CombatDamage_Struct *cd = (CombatDamage_Struct *)message_packet->pBuffer; auto cd = (CombatDamage_Struct *) p.pBuffer;
action->target = GetID(); action->target = GetID();
action->source = caster ? caster->GetID() : GetID(); action->source = caster ? caster->GetID() : GetID();
@@ -1067,16 +1065,15 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
caster->CastToClient()->QueuePacket(action_packet); caster->CastToClient()->QueuePacket(action_packet);
} }
CastToClient()->QueuePacket(message_packet); CastToClient()->QueuePacket(&p);
if (caster->IsClient() && caster != this) { if (caster->IsClient() && caster != this) {
caster->CastToClient()->QueuePacket(message_packet); caster->CastToClient()->QueuePacket(&p);
} }
CastToClient()->SetBindPoint(spells[spell_id].base_value[i] - 1); CastToClient()->SetBindPoint(spells[spell_id].base_value[i] - 1);
Save(); Save();
safe_delete(action_packet); safe_delete(action_packet);
safe_delete(message_packet);
} }
} }
} }
+3 -4
View File
@@ -4713,8 +4713,8 @@ bool Mob::SpellOnTarget(
} }
} }
message_packet = new EQApplicationPacket(OP_Damage, sizeof(CombatDamage_Struct)); static EQApplicationPacket p(OP_Damage, sizeof(CombatDamage_Struct));
CombatDamage_Struct *cd = (CombatDamage_Struct *)message_packet->pBuffer; auto cd = (CombatDamage_Struct *) p.pBuffer;
cd->target = action->target; cd->target = action->target;
cd->source = action->source; cd->source = action->source;
cd->type = action->type; cd->type = action->type;
@@ -4732,7 +4732,7 @@ bool Mob::SpellOnTarget(
) { ) {
entity_list.QueueCloseClients( entity_list.QueueCloseClients(
spelltar, /* Sender */ spelltar, /* Sender */
message_packet, /* Packet */ &p, /* Packet */
false, /* Ignore Sender */ false, /* Ignore Sender */
RuleI(Range, SpellMessages), RuleI(Range, SpellMessages),
0, /* Skip this mob */ 0, /* Skip this mob */
@@ -4742,7 +4742,6 @@ bool Mob::SpellOnTarget(
} }
safe_delete(action_packet); safe_delete(action_packet);
safe_delete(message_packet);
/* /*
Bug: When an HP buff with a heal effect is applied for first time, the heal portion of the effect heals the client and Bug: When an HP buff with a heal effect is applied for first time, the heal portion of the effect heals the client and