Go Back   EQEmulator Home > EQEmulator Forums > Support > Spell Support

Spell Support Broken Spells? Want them Fixed? Request it here.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 12-01-2015, 07:49 PM
Charles082986
Sarnak
 
Join Date: Dec 2010
Posts: 46
Default

So I could put the race check in either the class/level check section on line 1135 or in the scribing section of the switch statement. I have no clue what coding standards or practices you guys like to follow here. I work as a full stack web developer (though primarily using C# and .NET technologies instead of open source alternatives), so our approaches may be a little different.

Code:
case memSpellScribing:	{	// scribing spell to book
	const ItemInst* inst = m_inv[MainCursor];

	if(inst && inst->IsType(ItemClassCommon))
	{
		const Item_Struct* item = inst->GetItem();
                
		if(item && item->Scroll.Effect == (int32)(memspell->spell_id))
		{
                        // new code
                        bool raceAllowed = false;
                        uint32 Race_ = GetArrayRace(GetRace());
                        uint32 Races_ = item->Races;
                        Race_ = (Race_ == 18 ? 16 : Race_);
                        for(unsigned int CurrentRace = 1; CurrentRace <= PLAYER_RACE_COUNT; ++CurrentRace){
                                if(Races_ & 1){
                                        if(Race_ == CurrentRace){
                                                raceAllowed = true;
                                                break;
                                        }
                                }
                                Races_ >>= 1;
                        }
                        if(!raceAllowed){
                                Message(0,"Your class/race/deity cannot use this spell.");
                                break;
                        }
                        // end new code
			ScribeSpell(memspell->spell_id, memspell->slot);
			DeleteItemInInventory(MainCursor, 1, true);
		}
		else
			Message(0,"Scribing spell: inst exists but item does not or spell ids do not match.");
	}
	else
		Message(0,"Scribing a spell without an inst on your cursor?");
	break;
}
I opted to put it in the scribing section because there's already a reference to the item on the cursor and it involves a loop, which for performance reasons I'd only like to hit in the event someone is actually scribing a spell instead of every time someone tries to memorize OR scribe a spell.

I pulled the race check from here: https://github.com/EQEmu/Server/blob...item.cpp#L2356

If there's a simpler or more efficient way of checking the race against the spell scroll race slot, I'm not sure where it would be. Also, this is my first time working with C++, so I made most of my assumptions based on my knowledge of C#. If someone could review it I would be very appreciative.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 02:13 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3