Page 1 of 1

BUG:FIX is included here, AddSpellBookEntry not working

Posted: Sat Nov 11, 2017 4:41 pm
by Ememjr
The LUA Function AddSpellBookEntry is not adding spells for Spell ID's larger than an unsigned int16,
my example was spell id # 110012, and it was returning a number in the 40k range

through hard work and dedication i single handedly drove through the code and was able to Squash this beast of a bug, with the following change
the function was using an int16 for spell id instead of an int32

change the line

Code: Select all

int16 spellid = lua_interface->GetInt16Value(state, 2);
to

Code: Select all

int32 spellid = lua_interface->GetInt32Value(state, 2);
this is the fixed code

Code: Select all

int EQ2Emu_lua_AddSpellBookEntry(lua_State* state) {
	if(!lua_interface)
		return 0;
	Spawn* player = lua_interface->GetSpawn(state);
	int32 spellid = lua_interface->GetInt32Value(state, 2);
	int16 tier = lua_interface->GetInt16Value(state, 3);
	Spell* spell = master_spell_list.GetSpell(spellid, tier);
	if (player && spell && player->IsPlayer()) {
		Client* client = player->GetZone()->GetClientBySpawn(player);
		if (client ) {
			((Player*)player)->AddSpellBookEntry(spell->GetSpellID(), spell->GetSpellTier(), ((Player*)player)->GetFreeSpellBookSlot(spell->GetSpellData()->spell_book_type), spell->GetSpellData()->spell_book_type, spell->GetSpellData()->linked_timer, true);
			EQ2Packet* outapp = ((Player*)player)->GetSpellBookUpdatePacket(client->GetVersion());
			if (outapp)
				client->QueuePacket(outapp);
		}
	}
	return 0;
}

Re: BUG:FIX is included here, AddSpellBookEntry not working

Posted: Sat Nov 11, 2017 9:16 pm
by Zcoretri
Nice find

Re: BUG:FIX is included here, AddSpellBookEntry not working

Posted: Sun Nov 12, 2017 8:55 am
by Cynnar
Commited to SVN.
Thanks [mention]Ememjr[/mention]