Skip to content

Commit

Permalink
Convert NPC Spell AI from int16 to uint16.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinglykrab committed Feb 23, 2021
1 parent 6570427 commit e1c3b53
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion common/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
*/

#define CURRENT_BINARY_DATABASE_VERSION 9159
#define CURRENT_BINARY_DATABASE_VERSION 9160

#ifdef BOTS
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9027
Expand Down
1 change: 1 addition & 0 deletions utils/sql/db_update_manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@
9157|2020_09_02_pet_taunting.sql|SHOW COLUMNS from `character_pet_info` LIKE 'taunting'|empty|
9158|2020_12_09_underworld.sql|SHOW COLUMNS from `zone` LIKE 'underworld_teleport_index'|empty|
9159|2020_12_22_expedition_system.sql|SELECT * FROM db_version WHERE version >= 9159|empty|
9160|2021_02_15_npc_spell_entries_unsigned.sql|SELECT * FROM db_version WHERE version >= 9160|empty|

# Upgrade conditions:
# This won't be needed after this system is implemented, but it is used database that are not
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `npc_spell_entries` MODIFY `spellid` UNSIGNED SMALLINT(5) NOT NULL DEFAULT 0;
8 changes: 4 additions & 4 deletions zone/mob_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2489,7 +2489,7 @@ create table npc_spells_entries (
);
*/

bool IsSpellInList(DBnpcspells_Struct* spell_list, int16 iSpellID);
bool IsSpellInList(DBnpcspells_Struct* spell_list, uint16 iSpellID);
bool IsSpellEffectInList(DBnpcspellseffects_Struct* spelleffect_list, uint16 iSpellEffectID, int32 base, int32 limit, int32 max);

bool NPC::AI_AddNPCSpells(uint32 iDBSpellsID) {
Expand Down Expand Up @@ -2761,14 +2761,14 @@ bool IsSpellEffectInList(DBnpcspellseffects_Struct* spelleffect_list, uint16 iSp
return false;
}

bool IsSpellInList(DBnpcspells_Struct* spell_list, int16 iSpellID) {
bool IsSpellInList(DBnpcspells_Struct* spell_list, uint16 iSpellID) {
auto it = std::find_if(spell_list->entries.begin(), spell_list->entries.end(),
[iSpellID](const DBnpcspells_entries_Struct &a) { return a.spellid == iSpellID; });
return it != spell_list->entries.end();
}

// adds a spell to the list, taking into account priority and resorting list as needed.
void NPC::AddSpellToNPCList(int16 iPriority, int16 iSpellID, uint32 iType,
void NPC::AddSpellToNPCList(int16 iPriority, uint16 iSpellID, uint32 iType,
int16 iManaCost, int32 iRecastDelay, int16 iResistAdjust, int8 min_hp, int8 max_hp)
{

Expand All @@ -2795,7 +2795,7 @@ void NPC::AddSpellToNPCList(int16 iPriority, int16 iSpellID, uint32 iType,
AIautocastspell_timer->Start(RandomTimer(0, 300), false);
}

void NPC::RemoveSpellFromNPCList(int16 spell_id)
void NPC::RemoveSpellFromNPCList(uint16 spell_id)
{
auto iter = AIspells.begin();
while(iter != AIspells.end())
Expand Down
4 changes: 2 additions & 2 deletions zone/npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,9 @@ class NPC : public Mob
void NPCSlotTexture(uint8 slot, uint16 texture); // Sets new material values for slots

uint32 GetAdventureTemplate() const { return adventure_template_id; }
void AddSpellToNPCList(int16 iPriority, int16 iSpellID, uint32 iType, int16 iManaCost, int32 iRecastDelay, int16 iResistAdjust, int8 min_hp, int8 max_hp);
void AddSpellToNPCList(int16 iPriority, uint16 iSpellID, uint32 iType, int16 iManaCost, int32 iRecastDelay, int16 iResistAdjust, int8 min_hp, int8 max_hp);
void AddSpellEffectToNPCList(uint16 iSpellEffectID, int32 base, int32 limit, int32 max);
void RemoveSpellFromNPCList(int16 spell_id);
void RemoveSpellFromNPCList(uint16 spell_id);
Timer *GetRefaceTimer() const { return reface_timer; }
const uint32 GetAltCurrencyType() const { return NPCTypedata->alt_currency_type; }

Expand Down
2 changes: 1 addition & 1 deletion zone/zonedb.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct wplist {

#pragma pack(1)
struct DBnpcspells_entries_Struct {
int16 spellid;
uint16 spellid;
uint8 minlevel;
uint8 maxlevel;
uint32 type;
Expand Down

0 comments on commit e1c3b53

Please sign in to comment.