mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-14 07:21:48 +00:00
Cleaner way to handle out of range and swaps
This commit is contained in:
parent
771279128d
commit
51958b991c
@ -968,4 +968,6 @@ namespace legacy {
|
|||||||
} InventorySlot;
|
} InventorySlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const uint32 MAX_SPELL_DB_ID_VAL = 65535;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -12928,8 +12928,13 @@ void Client::Handle_OP_SwapSpell(const EQApplicationPacket *app)
|
|||||||
m_pp.spell_book[swapspell->from_slot] = m_pp.spell_book[swapspell->to_slot];
|
m_pp.spell_book[swapspell->from_slot] = m_pp.spell_book[swapspell->to_slot];
|
||||||
m_pp.spell_book[swapspell->to_slot] = swapspelltemp;
|
m_pp.spell_book[swapspell->to_slot] = swapspelltemp;
|
||||||
|
|
||||||
database.SaveCharacterSpell(this->CharacterID(), m_pp.spell_book[swapspell->from_slot], swapspell->from_slot);
|
/* Save Spell Swaps */
|
||||||
database.SaveCharacterSpell(this->CharacterID(), swapspelltemp, swapspell->to_slot);
|
if (!database.SaveCharacterSpell(this->CharacterID(), m_pp.spell_book[swapspell->from_slot], swapspell->from_slot)){
|
||||||
|
database.DeleteCharacterSpell(this->CharacterID(), m_pp.spell_book[swapspell->from_slot], swapspell->from_slot);
|
||||||
|
}
|
||||||
|
if (!database.SaveCharacterSpell(this->CharacterID(), swapspelltemp, swapspell->to_slot)){
|
||||||
|
database.DeleteCharacterSpell(this->CharacterID(), swapspelltemp, swapspell->to_slot);
|
||||||
|
}
|
||||||
|
|
||||||
QueuePacket(app);
|
QueuePacket(app);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -966,7 +966,7 @@ bool ZoneDatabase::LoadCharacterMemmedSpells(uint32 character_id, PlayerProfile_
|
|||||||
}
|
}
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
i = atoi(row[0]);
|
i = atoi(row[0]);
|
||||||
if (i < MAX_PP_MEMSPELL){
|
if (i < MAX_PP_MEMSPELL && atoi(row[1]) <= SPDAT_RECORDS){
|
||||||
pp->mem_spells[i] = atoi(row[1]);
|
pp->mem_spells[i] = atoi(row[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -989,7 +989,7 @@ bool ZoneDatabase::LoadCharacterSpellBook(uint32 character_id, PlayerProfile_Str
|
|||||||
}
|
}
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
i = atoi(row[0]);
|
i = atoi(row[0]);
|
||||||
if (i < MAX_PP_SPELLBOOK){
|
if (i < MAX_PP_SPELLBOOK && atoi(row[1]) <= SPDAT_RECORDS){
|
||||||
pp->spell_book[i] = atoi(row[1]);
|
pp->spell_book[i] = atoi(row[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1655,14 +1655,14 @@ bool ZoneDatabase::SaveCharacterAA(uint32 character_id, uint32 aa_id, uint32 cur
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::SaveCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){
|
bool ZoneDatabase::SaveCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){
|
||||||
if (spell_id == 65535 || spell_id == 4294967295){ return false; }
|
if (spell_id > SPDAT_RECORDS){ return false; }
|
||||||
std::string query = StringFormat("REPLACE INTO `character_memmed_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, slot_id, spell_id);
|
std::string query = StringFormat("REPLACE INTO `character_memmed_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, slot_id, spell_id);
|
||||||
QueryDatabase(query);
|
QueryDatabase(query);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::SaveCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){
|
bool ZoneDatabase::SaveCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){
|
||||||
if (spell_id == 65535 || spell_id == 4294967295){ return false; }
|
if (spell_id > SPDAT_RECORDS){ return false; }
|
||||||
std::string query = StringFormat("REPLACE INTO `character_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, slot_id, spell_id);
|
std::string query = StringFormat("REPLACE INTO `character_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, slot_id, spell_id);
|
||||||
QueryDatabase(query);
|
QueryDatabase(query);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user