Two crash fixes reported on the forums are hopefully fixed.

This commit is contained in:
SecretsOTheP 2013-03-20 10:46:09 -04:00
parent 925ba2199e
commit 56825e9ed0
10 changed files with 24 additions and 14 deletions

View File

@ -3015,7 +3015,8 @@ ENCODE(OP_ReadBook) {
eq->window = emu->window;
OUT(type);
eq->invslot = 0; // Set to hard 0 since it's not required for the structure to work
memcpy(eq->txtfile, emu->booktext, sizeof(eq->txtfile));
if(sizeof(emu->booktext) > 0 && sizeof(emu->booktext) < 8194)
strncpy(eq->txtfile, emu->booktext, sizeof(eq->txtfile));
FINISH_ENCODE();
}

View File

@ -1721,7 +1721,7 @@ void Mob::AI_Event_Engaged(Mob* attacker, bool iYellForHelp) {
if(!CastToNPC()->GetCombatEvent() && GetHP() > 0)
{
parse->EventNPC(EVENT_COMBAT, CastToNPC(), attacker, "1", 0);
uint16 emoteid = CastToNPC()->GetNPCEmoteID();
uint16 emoteid = GetEmoteID();
if(emoteid != 0)
CastToNPC()->DoNPCEmote(ENTERCOMBAT,emoteid);
CastToNPC()->SetCombatEvent(true);
@ -1754,11 +1754,14 @@ void Mob::AI_Event_NoLongerEngaged() {
{
if(CastToNPC()->GetCombatEvent() && GetHP() > 0)
{
uint16 emoteid = CastToNPC()->GetNPCEmoteID();
if(entity_list.GetNPCByID(this->GetID()))
{
uint16 emoteid = CastToNPC()->GetEmoteID();
parse->EventNPC(EVENT_COMBAT, CastToNPC(), NULL, "0", 0);
if(emoteid != 0)
CastToNPC()->DoNPCEmote(LEAVECOMBAT,emoteid);
CastToNPC()->SetCombatEvent(false);
}
}
}
}

View File

@ -1451,7 +1451,7 @@ void Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_
{
if (killerMob->IsNPC()) {
parse->EventNPC(EVENT_SLAY, killerMob->CastToNPC(), this, "", 0);
uint16 emoteid = killerMob->CastToNPC()->GetNPCEmoteID();
uint16 emoteid = killerMob->GetEmoteID();
if(emoteid != 0)
killerMob->CastToNPC()->DoNPCEmote(KILLEDPC,emoteid);
killerMob->TrySpellOnKill(killed_level,spell);
@ -2209,7 +2209,7 @@ void NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_ski
this->CheckMinMaxLevel(killer);
}
entity_list.RemoveFromAutoXTargets(this);
uint16 emoteid = this->GetNPCEmoteID();
uint16 emoteid = this->GetEmoteID();
Corpse* corpse = new Corpse(this, &itemlist, GetNPCTypeID(), &NPCTypedata,level>54?RuleI(NPC,MajorNPCCorpseDecayTimeMS):RuleI(NPC,MinorNPCCorpseDecayTimeMS));
entity_list.LimitRemoveNPC(this);
entity_list.AddCorpse(corpse, this->GetID());
@ -2302,13 +2302,13 @@ void NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_ski
if(killerMob) {
Mob *oos = killerMob->GetOwnerOrSelf();
parse->EventNPC(EVENT_DEATH, this, oos, "", 0);
uint16 emoteid = this->GetNPCEmoteID();
uint16 emoteid = this->GetEmoteID();
if(emoteid != 0)
this->DoNPCEmote(ONDEATH,emoteid);
if(oos->IsNPC())
{
parse->EventNPC(EVENT_NPC_SLAY, oos->CastToNPC(), this, "", 0);
uint16 emoteid = oos->CastToNPC()->GetNPCEmoteID();
uint16 emoteid = oos->GetEmoteID();
if(emoteid != 0)
oos->CastToNPC()->DoNPCEmote(KILLEDNPC,emoteid);
killerMob->TrySpellOnKill(killed_level,spell);

View File

@ -5915,7 +5915,7 @@ void Client::CheckEmoteHail(Mob *target, const char* message)
{
return;
}
uint16 emoteid = target->CastToNPC()->GetNPCEmoteID();
uint16 emoteid = target->GetEmoteID();
if(emoteid != 0)
target->CastToNPC()->DoNPCEmote(HAILED,emoteid);
}

View File

@ -1867,7 +1867,7 @@ void command_npcstats(Client *c, const Seperator *sep)
c->Message(0, "Gender: %i Size: %f Bodytype: %d", c->GetTarget()->GetGender(), c->GetTarget()->GetSize(), c->GetTarget()->GetBodyType());
c->Message(0, "Runspeed: %f Walkspeed: %f", c->GetTarget()->GetRunspeed(), c->GetTarget()->GetWalkspeed());
c->Message(0, "Spawn Group: %i Grid: %i", c->GetTarget()->CastToNPC()->GetSp2(), c->GetTarget()->CastToNPC()->GetGrid());
c->Message(0, "EmoteID: %i", c->GetTarget()->CastToNPC()->GetNPCEmoteID());
c->Message(0, "EmoteID: %i", c->GetTarget()->CastToNPC()->GetEmoteID());
c->GetTarget()->CastToNPC()->QueryLoot(c);
}
}
@ -11031,7 +11031,7 @@ void command_emoteview(Client *c, const Seperator *sep)
if(c->GetTarget() && c->GetTarget()->IsNPC())
{
int count=0;
int emoteid = c->GetTarget()->CastToNPC()->GetNPCEmoteID();
int emoteid = c->GetTarget()->CastToNPC()->GetEmoteID();
LinkedListIterator<NPC_Emote_Struct*> iterator(zone->NPCEmoteList);
iterator.Reset();

View File

@ -621,7 +621,7 @@ void EntityList::AddNPC(NPC* npc, bool SendSpawnPacket, bool dontqueue) {
npc->SetID(GetFreeID());
parse->EventNPC(EVENT_SPAWN, npc, NULL, "", 0);
uint16 emoteid = npc->GetNPCEmoteID();
uint16 emoteid = npc->GetEmoteID();
if(emoteid != 0)
npc->DoNPCEmote(ONSPAWN,emoteid);

View File

@ -378,6 +378,8 @@ Mob::Mob(const char* in_name,
m_DisableMelee = false;
for (int i = 0; i < HIGHEST_SKILL+2; i++) { SkillDmgTaken_Mod[i] = 0; }
for (int i = 0; i < HIGHEST_RESIST+2; i++) { Vulnerability_Mod[i] = 0; }
emoteid = 0;
}
Mob::~Mob()
@ -1194,7 +1196,7 @@ void Mob::ShowStats(Client* client)
if(n->respawn2 != 0)
spawngroupid = n->respawn2->SpawnGroupID();
client->Message(0, " NPCID: %u SpawnGroupID: %u Grid: %i LootTable: %u FactionID: %i SpellsID: %u ", GetNPCTypeID(),spawngroupid, n->GetGrid(), n->GetLoottableID(), n->GetNPCFactionID(), n->GetNPCSpellsID());
client->Message(0, " Accuracy: %i MerchantID: %i EmoteID: %i Runspeed: %f Walkspeed: %f", n->GetAccuracyRating(), n->MerchantType, n->GetNPCEmoteID(), n->GetRunspeed(), n->GetWalkspeed());
client->Message(0, " Accuracy: %i MerchantID: %i EmoteID: %i Runspeed: %f Walkspeed: %f", n->GetAccuracyRating(), n->MerchantType, n->GetEmoteID(), n->GetRunspeed(), n->GetWalkspeed());
n->QueryLoot(client);
}
if (IsAIControlled()) {

View File

@ -784,6 +784,9 @@ public:
void TarGlobal(const char *varname, const char *value, const char *duration, int npcid, int charid, int zoneid);
void DelGlobal(const char *varname);
inline void SetEmoteID(uint16 emote) { emoteid = emote; }
inline uint16 GetEmoteID() { return emoteid; }
protected:
void CommonDamage(Mob* other, int32 &damage, const uint16 spell_id, const SkillType attack_skill, bool &avoidable, const int8 buffslot, const bool iBuffTic);
static uint16 GetProcID(uint16 spell_id, uint8 effect_index);
@ -1110,6 +1113,7 @@ protected:
bool m_targetable;
int QGVarDuration(const char *fmt);
void InsertQuestGlobal(int charid, int npcid, int zoneid, const char *name, const char *value, int expdate);
uint16 emoteid;
private:
void _StopSong(); //this is not what you think it is

View File

@ -350,6 +350,7 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float
guard_y_saved = 0;
guard_z_saved = 0;
guard_heading_saved = 0;
SetEmoteID(d->emoteid);
InitializeBuffSlots();
CalcBonuses();
}
@ -734,7 +735,7 @@ void NPC::DumpLoot(uint32 npcdump_index, ZSDump_NPC_Loot* npclootdump, uint32* N
}
void NPC::Depop(bool StartSpawnTimer) {
uint16 emoteid = this->GetNPCEmoteID();
uint16 emoteid = this->GetEmoteID();
if(emoteid != 0)
this->DoNPCEmote(ONDESPAWN,emoteid);
p_depop = true;

View File

@ -327,7 +327,6 @@ public:
//The corpse we make can only be looted by people who got credit for the kill
const bool HasPrivateCorpse() const { return NPCTypedata->private_corpse; }
const bool IsUnderwaterOnly() const { return NPCTypedata->underwater; }
const uint32 GetNPCEmoteID() const { return NPCTypedata->emoteid; }
const char* GetRawNPCTypeName() const { return NPCTypedata->name; }
bool GetDepop() { return p_depop; }