Loading...   

  • Created By Mackal On: 02:52 PM September 23, 2014
  • Link

diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp
index a7eaaa9..ccb107e 100644
--- a/zone/zonedb.cpp
+++ b/zone/zonedb.cpp
@@ -981,18 +981,18 @@ bool ZoneDatabase::LoadCharacterSpellBook(uint32 character_id, PlayerProfile_Str
 		"FROM					"
 		"`character_spells`		"
 		"WHERE `id` = %u ORDER BY `slot_id`", character_id);
-	auto results = database.QueryDatabase(query); 
-	int i = 0;
+	auto results = database.QueryDatabase(query);
+	int slot = 0;
+	uint32 spell_id = 0;
 	/* Initialize Spells */
-	for (i = 0; i < MAX_PP_SPELLBOOK; i++){
-		pp->spell_book[i] = 0xFFFFFFFF; 
+	memset(pp->spell_boox, 0xFF, sizeof(uint32) * MAX_PP_SPELLBOOK);
+	for (auto row = results.begin(); row != results.end(); ++row) {
+		slot = atoi(row[0]);
+		spell_id = atoi(row[1]);
+		if (i >= MAX_PP_SPELLBOOK || !IsValidSpell(spell_id))
+			continue;
+		pp->spell_book[i] = spell_id;
 	}
-	for (auto row = results.begin(); row != results.end(); ++row) { 
-		i = atoi(row[0]);
-		if (i < MAX_PP_SPELLBOOK){
-			pp->spell_book[i] = atoi(row[1]); 
-		} 
-	} 
 	return true;
 }
 

Raw Paste Data