Fix for special_abilities crash dealing with std::string in struct that was then memcpyed

This commit is contained in:
KimLS 2013-07-18 00:24:43 -07:00
parent 2331678312
commit 1f2145a45d
8 changed files with 17 additions and 27 deletions

View File

@ -1,5 +1,8 @@
EQEMu Changelog (Started on Sept 24, 2003 15:50)
-------------------------------------------------------
== 07/18/2013 ==
KLS: Fix for crash in special_abilities code due to existing use of some dangerous code we didn't catch before.
== 07/15/2013 ==
Sorvani: fix for lua_general.cpp funtion get_spawn_condition
Uleat: added non-extensioned wildcard filter to \\...\dependencies\.gitignore to fix tortoisegit inclusion errors (fixes commit and display overlay issues.)

View File

@ -838,50 +838,50 @@ void Mob::WakeTheDead(uint16 spell_id, Mob *target, uint32 duration)
break;
case PALADIN:
//SPECATK_TRIPLE
make_npc->special_abilities = "6,1";
strcpy(make_npc->special_abilities, "6,1");
make_npc->cur_hp = make_npc->cur_hp * 150 / 100;
make_npc->max_hp = make_npc->max_hp * 150 / 100;
make_npc->npc_spells_id = 8;
break;
case SHADOWKNIGHT:
make_npc->special_abilities = "6,1";
strcpy(make_npc->special_abilities, "6,1");
make_npc->cur_hp = make_npc->cur_hp * 150 / 100;
make_npc->max_hp = make_npc->max_hp * 150 / 100;
make_npc->npc_spells_id = 9;
break;
case RANGER:
make_npc->special_abilities = "7,1";
strcpy(make_npc->special_abilities, "7,1");
make_npc->cur_hp = make_npc->cur_hp * 135 / 100;
make_npc->max_hp = make_npc->max_hp * 135 / 100;
make_npc->npc_spells_id = 10;
break;
case BARD:
make_npc->special_abilities = "6,1";
strcpy(make_npc->special_abilities, "6,1");
make_npc->cur_hp = make_npc->cur_hp * 110 / 100;
make_npc->max_hp = make_npc->max_hp * 110 / 100;
make_npc->npc_spells_id = 11;
break;
case BEASTLORD:
make_npc->special_abilities = "7,1";
strcpy(make_npc->special_abilities, "7,1");
make_npc->cur_hp = make_npc->cur_hp * 110 / 100;
make_npc->max_hp = make_npc->max_hp * 110 / 100;
make_npc->npc_spells_id = 12;
break;
case ROGUE:
make_npc->special_abilities = "7,1";
strcpy(make_npc->special_abilities, "7,1");
make_npc->max_dmg = make_npc->max_dmg * 150 /100;
make_npc->cur_hp = make_npc->cur_hp * 110 / 100;
make_npc->max_hp = make_npc->max_hp * 110 / 100;
break;
case MONK:
make_npc->special_abilities = "7,1";
strcpy(make_npc->special_abilities, "7,1");
make_npc->max_dmg = make_npc->max_dmg * 150 /100;
make_npc->cur_hp = make_npc->cur_hp * 135 / 100;
make_npc->max_hp = make_npc->max_hp * 135 / 100;
break;
case WARRIOR:
case BERSERKER:
make_npc->special_abilities = "7,1";
strcpy(make_npc->special_abilities, "7,1");
make_npc->max_dmg = make_npc->max_dmg * 150 /100;
make_npc->cur_hp = make_npc->cur_hp * 175 / 100;
make_npc->max_hp = make_npc->max_hp * 175 / 100;

View File

@ -3373,7 +3373,7 @@ void command_viewnpctype(Client *c, const Seperator *sep)
c->Message(0, " Class: %i", npct->class_);
c->Message(0, " MinDmg: %i", npct->min_dmg);
c->Message(0, " MaxDmg: %i", npct->max_dmg);
c->Message(0, " Special Abilities: %s", npct->special_abilities.c_str());
c->Message(0, " Special Abilities: %s", npct->special_abilities);
c->Message(0, " Spells: %i", npct->npc_spells_id);
c->Message(0, " Loot Table: %i", npct->loottable_id);
c->Message(0, " NPCFactionID: %i", npct->npc_faction_id);

View File

@ -87,12 +87,7 @@ const NPCType *Horse::BuildHorseType(uint16 spell_id) {
memset(npc_type, 0, sizeof(NPCType));
strcpy(npc_type->name,"Unclaimed_Mount"); //this should never get used
npc_type->special_abilities = itoa(IMMUNE_MELEE);
npc_type->special_abilities += std::string(",1^");
npc_type->special_abilities += itoa(IMMUNE_MAGIC);
npc_type->special_abilities += std::string(",1^");
npc_type->special_abilities += itoa(IMMUNE_AGGRO);
npc_type->special_abilities += std::string(",1");
strcpy(npc_type->special_abilities, "19,1^20,1^24,1");
npc_type->cur_hp = 1;
npc_type->max_hp = 1;
npc_type->race = atoi(row[0]);

View File

@ -1850,7 +1850,6 @@ void Merc::AI_Start(int32 iMoveDelay) {
}
if (NPCTypedata_ours) {
//AI_AddNPCSpells(ourNPCData->npc_spells_id);
ProcessSpecialAbilities(NPCTypedata_ours->special_abilities);
}

View File

@ -330,14 +330,7 @@ void Trap::CreateHiddenTrigger()
make_npc->d_meele_texture2 = 0;
make_npc->trackable = 0;
make_npc->level = level;
make_npc->special_abilities = itoa(IMMUNE_MELEE);
make_npc->special_abilities += std::string(",1^");
make_npc->special_abilities += itoa(IMMUNE_MAGIC);
make_npc->special_abilities += std::string(",1^");
make_npc->special_abilities += itoa(IMMUNE_AGGRO);
make_npc->special_abilities += std::string(",1^");
make_npc->special_abilities += itoa(IMMUNE_AGGRO_ON);
make_npc->special_abilities += std::string(",1");
strcpy(make_npc->special_abilities, "19,1^20,1^24,1^25,1");
NPC* npca = new NPC(make_npc, 0, x, y, z, 0, FlyMode3);
npca->GiveNPCTypeData(make_npc);
entity_list.AddNPC(npca);

View File

@ -1130,7 +1130,7 @@ const NPCType* ZoneDatabase::GetNPCType (uint32 id) {
tmpNPCType->min_dmg = atoi(row[r++]);
tmpNPCType->max_dmg = atoi(row[r++]);
tmpNPCType->attack_count = atoi(row[r++]);
tmpNPCType->special_abilities = row[r++];
strn0cpy(tmpNPCType->special_abilities, row[r++], 512);
tmpNPCType->npc_spells_id = atoi(row[r++]);
tmpNPCType->d_meele_texture1 = atoi(row[r++]);
tmpNPCType->d_meele_texture2 = atoi(row[r++]);
@ -1440,7 +1440,7 @@ const NPCType* ZoneDatabase::GetMercType(uint32 id, uint16 raceid, uint32 client
tmpNPCType->min_dmg = atoi(row[r++]);
tmpNPCType->max_dmg = atoi(row[r++]);
tmpNPCType->attack_count = atoi(row[r++]);
tmpNPCType->special_abilities = row[r++];
strn0cpy(tmpNPCType->special_abilities, row[r++], 512);
//tmpNPCType->npc_spells_id = atoi(row[r++]);
tmpNPCType->d_meele_texture1 = atoi(row[r++]);
tmpNPCType->d_meele_texture2 = atoi(row[r++]);

View File

@ -89,7 +89,7 @@ struct NPCType
uint32 min_dmg;
uint32 max_dmg;
int16 attack_count;
std::string special_abilities;
char special_abilities[512];
uint16 d_meele_texture1;
uint16 d_meele_texture2;
uint8 prim_melee_type;