BUG:FIX is included here, AddSpellBookEntry not working

Old bugs stored here for reference.
Locked
User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

BUG:FIX is included here, AddSpellBookEntry not working

Post by Ememjr » Sat Nov 11, 2017 4:41 pm

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;
}

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

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

Post by Zcoretri » Sat Nov 11, 2017 9:16 pm

Nice find

User avatar
Cynnar
Project Leader
Posts: 738
Joined: Sat Sep 27, 2014 1:22 am
EQ2Emu Server: Eq2emulator
Characters: Vlash
Veinlash
Taragak
Cynnar

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

Post by Cynnar » Sun Nov 12, 2017 8:55 am

Commited to SVN.
Thanks [mention]Ememjr[/mention]
[ 01000011 01111001 01101110 01101110 01100001 01110010 ]

Follow on:
Twitter Facebook

Contact me:
PM Discord chat email

Hardware: the parts of a computer that can be kicked

Locked

Who is online

Users browsing this forum: No registered users and 0 guests