mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
[Quest API] Convert all char arrays to strings. (#1612)
* [Quest API] Convert all char arrays to strings. Also change multiple loops for zone controller to one loop. * Remove 'this' keyword'
This commit is contained in:
parent
efab0c4b6b
commit
edf298685e
@ -2211,11 +2211,8 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQ::skills::SkillTy
|
||||
Mob *oos = nullptr;
|
||||
if (killer_mob) {
|
||||
oos = killer_mob->GetOwnerOrSelf();
|
||||
|
||||
char buffer[48] = { 0 };
|
||||
snprintf(buffer, 47, "%d %d %d %d", killer_mob->GetID(), damage, spell, static_cast<int>(attack_skill));
|
||||
|
||||
if (parse->EventNPC(EVENT_DEATH, this, oos, buffer, 0) != 0) {
|
||||
std::string buffer = fmt::format("{} {} {} {}", killer_mob->GetID(), damage, spell, static_cast<int>(attack_skill));
|
||||
if (parse->EventNPC(EVENT_DEATH, this, oos, buffer.c_str(), 0) != 0) {
|
||||
if (GetHP() < 0) {
|
||||
SetHP(0);
|
||||
}
|
||||
@ -2238,10 +2235,8 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQ::skills::SkillTy
|
||||
}
|
||||
}
|
||||
else {
|
||||
char buffer[48] = { 0 };
|
||||
snprintf(buffer, 47, "%d %d %d %d", 0, damage, spell, static_cast<int>(attack_skill));
|
||||
|
||||
if (parse->EventNPC(EVENT_DEATH, this, nullptr, buffer, 0) != 0) {
|
||||
std::string buffer = fmt::format("{} {} {} {}", 0, damage, spell, static_cast<int>(attack_skill));
|
||||
if (parse->EventNPC(EVENT_DEATH, this, nullptr, buffer.c_str(), 0) != 0) {
|
||||
if (GetHP() < 0) {
|
||||
SetHP(0);
|
||||
}
|
||||
@ -2632,16 +2627,15 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQ::skills::SkillTy
|
||||
|
||||
entity_list.UpdateFindableNPCState(this, true);
|
||||
|
||||
char buffer[48] = { 0 };
|
||||
snprintf(buffer, 47, "%d %d %d %d", killer_mob ? killer_mob->GetID() : 0, damage, spell, static_cast<int>(attack_skill));
|
||||
parse->EventNPC(EVENT_DEATH_COMPLETE, this, oos, buffer, 0);
|
||||
std::string buffer = fmt::format("{} {} {} {}", killer_mob ? killer_mob->GetID() : 0, damage, spell, static_cast<int>(attack_skill));
|
||||
parse->EventNPC(EVENT_DEATH_COMPLETE, this, oos, buffer.c_str(), 0);
|
||||
|
||||
/* Zone controller process EVENT_DEATH_ZONE (Death events) */
|
||||
if (RuleB(Zone, UseZoneController)) {
|
||||
if (entity_list.GetNPCByNPCTypeID(ZONE_CONTROLLER_NPC_ID) && this->GetNPCTypeID() != ZONE_CONTROLLER_NPC_ID) {
|
||||
char data_pass[100] = { 0 };
|
||||
snprintf(data_pass, 99, "%d %d %d %d %d", killer_mob ? killer_mob->GetID() : 0, damage, spell, static_cast<int>(attack_skill), this->GetNPCTypeID());
|
||||
parse->EventNPC(EVENT_DEATH_ZONE, entity_list.GetNPCByNPCTypeID(ZONE_CONTROLLER_NPC_ID)->CastToNPC(), nullptr, data_pass, 0);
|
||||
auto controller = entity_list.GetNPCByNPCTypeID(ZONE_CONTROLLER_NPC_ID);
|
||||
if (controller && GetNPCTypeID() != ZONE_CONTROLLER_NPC_ID) {
|
||||
std::string data_pass = fmt::format("{} {} {} {} {}", killer_mob ? killer_mob->GetID() : 0, damage, spell, static_cast<int>(attack_skill), GetNPCTypeID());
|
||||
parse->EventNPC(EVENT_DEATH_ZONE, controller, nullptr, data_pass.c_str(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -11164,14 +11164,13 @@ void Client::Handle_OP_PopupResponse(const EQApplicationPacket *app)
|
||||
break;
|
||||
}
|
||||
|
||||
char buf[16];
|
||||
sprintf(buf, "%d", popup_response->popupid);
|
||||
std::string buf = fmt::format("{}", popup_response->popupid);
|
||||
|
||||
parse->EventPlayer(EVENT_POPUP_RESPONSE, this, buf, 0);
|
||||
parse->EventPlayer(EVENT_POPUP_RESPONSE, this, buf.c_str(), 0);
|
||||
|
||||
Mob *Target = GetTarget();
|
||||
if (Target && Target->IsNPC()) {
|
||||
parse->EventNPC(EVENT_POPUP_RESPONSE, Target->CastToNPC(), this, buf, 0);
|
||||
parse->EventNPC(EVENT_POPUP_RESPONSE, Target->CastToNPC(), this, buf.c_str(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -723,10 +723,10 @@ void EntityList::AddNPC(NPC *npc, bool SendSpawnPacket, bool dontqueue)
|
||||
|
||||
/* Zone controller process EVENT_SPAWN_ZONE */
|
||||
if (RuleB(Zone, UseZoneController)) {
|
||||
if (entity_list.GetNPCByNPCTypeID(ZONE_CONTROLLER_NPC_ID) && npc->GetNPCTypeID() != ZONE_CONTROLLER_NPC_ID){
|
||||
char data_pass[100] = { 0 };
|
||||
snprintf(data_pass, 99, "%d %d", npc->GetID(), npc->GetNPCTypeID());
|
||||
parse->EventNPC(EVENT_SPAWN_ZONE, entity_list.GetNPCByNPCTypeID(ZONE_CONTROLLER_NPC_ID)->CastToNPC(), nullptr, data_pass, 0);
|
||||
auto controller = entity_list.GetNPCByNPCTypeID(ZONE_CONTROLLER_NPC_ID);
|
||||
if (controller && npc->GetNPCTypeID() != ZONE_CONTROLLER_NPC_ID){
|
||||
std::string data_pass = fmt::format("{} {}", npc->GetID(), npc->GetNPCTypeID());
|
||||
parse->EventNPC(EVENT_SPAWN_ZONE, controller, nullptr, data_pass.c_str(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
12
zone/mob.cpp
12
zone/mob.cpp
@ -1334,11 +1334,9 @@ void Mob::CreateHPPacket(EQApplicationPacket* app)
|
||||
{
|
||||
if (ds->hp < GetNextHPEvent())
|
||||
{
|
||||
char buf[10];
|
||||
snprintf(buf, 9, "%i", GetNextHPEvent());
|
||||
buf[9] = '\0';
|
||||
std::string buf = fmt::format("{}", GetNextHPEvent());
|
||||
SetNextHPEvent(-1);
|
||||
parse->EventNPC(EVENT_HP, CastToNPC(), nullptr, buf, 0);
|
||||
parse->EventNPC(EVENT_HP, CastToNPC(), nullptr, buf.c_str(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1346,11 +1344,9 @@ void Mob::CreateHPPacket(EQApplicationPacket* app)
|
||||
{
|
||||
if (ds->hp > GetNextIncHPEvent())
|
||||
{
|
||||
char buf[10];
|
||||
snprintf(buf, 9, "%i", GetNextIncHPEvent());
|
||||
buf[9] = '\0';
|
||||
std::string buf = fmt::format("{}", GetNextIncHPEvent());
|
||||
SetNextIncHPEvent(-1);
|
||||
parse->EventNPC(EVENT_HP, CastToNPC(), nullptr, buf, 1);
|
||||
parse->EventNPC(EVENT_HP, CastToNPC(), nullptr, buf.c_str(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1766,9 +1766,8 @@ void NPC::AI_DoMovement() {
|
||||
}
|
||||
|
||||
//kick off event_waypoint arrive
|
||||
char temp[16];
|
||||
sprintf(temp, "%d", cur_wp);
|
||||
parse->EventNPC(EVENT_WAYPOINT_ARRIVE, CastToNPC(), nullptr, temp, 0);
|
||||
std::string buf = fmt::format("{}", cur_wp);
|
||||
parse->EventNPC(EVENT_WAYPOINT_ARRIVE, CastToNPC(), nullptr, buf.c_str(), 0);
|
||||
// No need to move as we are there. Next loop will
|
||||
// take care of normal grids, even at pause 0.
|
||||
// We do need to call and setup a wp if we're cur_wp=-2
|
||||
@ -1885,9 +1884,8 @@ void NPC::AI_SetupNextWaypoint() {
|
||||
|
||||
if (!DistractedFromGrid) {
|
||||
//kick off event_waypoint depart
|
||||
char temp[16];
|
||||
sprintf(temp, "%d", cur_wp);
|
||||
parse->EventNPC(EVENT_WAYPOINT_DEPART, CastToNPC(), nullptr, temp, 0);
|
||||
std::string buf = fmt::format("{}", cur_wp);
|
||||
parse->EventNPC(EVENT_WAYPOINT_DEPART, CastToNPC(), nullptr, buf.c_str(), 0);
|
||||
|
||||
//setup our next waypoint, if we are still on our normal grid
|
||||
//remember that the quest event above could have done anything it wanted with our grid
|
||||
@ -2470,10 +2468,8 @@ void NPC::CheckSignal() {
|
||||
if (!signal_q.empty()) {
|
||||
int signal_id = signal_q.front();
|
||||
signal_q.pop_front();
|
||||
char buf[32];
|
||||
snprintf(buf, 31, "%d", signal_id);
|
||||
buf[31] = '\0';
|
||||
parse->EventNPC(EVENT_SIGNAL, this, nullptr, buf, 0);
|
||||
std::string buf = fmt::format("{}", signal_id);
|
||||
parse->EventNPC(EVENT_SIGNAL, this, nullptr, buf.c_str(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -289,14 +289,12 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot,
|
||||
}
|
||||
|
||||
if(IsClient()) {
|
||||
char temp[64];
|
||||
sprintf(temp, "%d", spell_id);
|
||||
if (parse->EventPlayer(EVENT_CAST_BEGIN, CastToClient(), temp, 0) != 0)
|
||||
std::string buf = fmt::format("{}", spell_id);
|
||||
if (parse->EventPlayer(EVENT_CAST_BEGIN, CastToClient(), buf.c_str(), 0) != 0)
|
||||
return false;
|
||||
} else if(IsNPC()) {
|
||||
char temp[64];
|
||||
sprintf(temp, "%d", spell_id);
|
||||
parse->EventNPC(EVENT_CAST_BEGIN, CastToNPC(), nullptr, temp, 0);
|
||||
std::string buf = fmt::format("{}", spell_id);
|
||||
parse->EventNPC(EVENT_CAST_BEGIN, CastToNPC(), nullptr, buf.c_str(), 0);
|
||||
}
|
||||
|
||||
//To prevent NPC ghosting when spells are cast from scripts
|
||||
@ -1440,13 +1438,11 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo
|
||||
//
|
||||
|
||||
if(IsClient()) {
|
||||
char temp[64];
|
||||
sprintf(temp, "%d", spell_id);
|
||||
parse->EventPlayer(EVENT_CAST, CastToClient(), temp, 0);
|
||||
std::string buf = fmt::format("{}", spell_id);
|
||||
parse->EventPlayer(EVENT_CAST, CastToClient(), buf.c_str(), 0);
|
||||
} else if(IsNPC()) {
|
||||
char temp[64];
|
||||
sprintf(temp, "%d", spell_id);
|
||||
parse->EventNPC(EVENT_CAST, CastToNPC(), nullptr, temp, 0);
|
||||
std::string buf = fmt::format("{}", spell_id);
|
||||
parse->EventNPC(EVENT_CAST, CastToNPC(), nullptr, buf.c_str(), 0);
|
||||
}
|
||||
|
||||
if(bard_song_mode)
|
||||
@ -3654,15 +3650,13 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, int reflect_effectivenes
|
||||
/* Send the EVENT_CAST_ON event */
|
||||
if(spelltar->IsNPC())
|
||||
{
|
||||
char temp1[100];
|
||||
sprintf(temp1, "%d", spell_id);
|
||||
parse->EventNPC(EVENT_CAST_ON, spelltar->CastToNPC(), this, temp1, 0);
|
||||
std::string buf = fmt::format("{}", spell_id);
|
||||
parse->EventNPC(EVENT_CAST_ON, spelltar->CastToNPC(), this, buf.c_str(), 0);
|
||||
}
|
||||
else if (spelltar->IsClient())
|
||||
{
|
||||
char temp1[100];
|
||||
sprintf(temp1, "%d", spell_id);
|
||||
parse->EventPlayer(EVENT_CAST_ON, spelltar->CastToClient(),temp1, 0);
|
||||
std::string buf = fmt::format("{}", spell_id);
|
||||
parse->EventPlayer(EVENT_CAST_ON, spelltar->CastToClient(), buf.c_str(), 0);
|
||||
}
|
||||
|
||||
mod_spell_cast(spell_id, spelltar, reflect_effectiveness, use_resist_adjust, resist_adjust, isproc);
|
||||
|
||||
@ -138,11 +138,10 @@ void NPC::ResumeWandering()
|
||||
|
||||
if (m_CurrentWayPoint.x == GetX() && m_CurrentWayPoint.y == GetY())
|
||||
{ // are we we at a waypoint? if so, trigger event and start to next
|
||||
char temp[100];
|
||||
itoa(cur_wp, temp, 10); //do this before updating to next waypoint
|
||||
std::string buf = fmt::format("{}", cur_wp);
|
||||
CalculateNewWaypoint();
|
||||
SetAppearance(eaStanding, false);
|
||||
parse->EventNPC(EVENT_WAYPOINT_DEPART, this, nullptr, temp, 0);
|
||||
parse->EventNPC(EVENT_WAYPOINT_DEPART, this, nullptr, buf.c_str(), 0);
|
||||
} // if not currently at a waypoint, we continue on to the one we were headed to before the stop
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user