View Single Post
  #2  
Old 07-03-2005, 03:31 AM
ffchung
Fire Beetle
 
Join Date: May 2005
Location: HK
Posts: 3
Default Code Explain

That is code in eqemu
commom\item.cpp

I have optimize the code. And I think there was a bug that BERSERKER always return false.

Function : ItemCommonInst::IsEquipable

Code:
bool ItemCommonInst::IsEquipable(int16 race, int16 class_) const
{
	if (!m_item)
		return false;
	
	bool israce = false;
	bool isclass = false;
	
	if (m_item->Slots == 0) {
		return false;
	}
	
	uint32 classes_ = m_item->Common.Classes;
	uint32 races_ = m_item->Common.Races;
	int32 race_ = 0;
	#ifndef PACKETCOLLECTOR
	race_ = GetArrayRace(race);
	#endif
	
	// Changed by ffchung
             // new code start
	if( ((1<<(class_-1)) & classes_) > 0 )
	{
		isclass = true;
	}
	if( ((1<<(race-1)) & races_) > 0 )
	{
		isclass = true;
	}
             // new code end

             // old code start
	/*
	// @merth: can this be optimized?  i.e., will (race & common->Races) suffice?
	for (int cur_class = 1; cur_class<=15; cur_class++) {
		if (classes_ % 2 == 1) {
    		if (cur_class == class_) {
    			isclass = true;
			}
		}
		classes_ >>= 1;
	}
	
	for (unsigned int cur_race = 1; cur_race <= 15; cur_race++) {
		
		if (races_ % 2 == 1) {
    		if (cur_race == race_) {
    			israce = true;
   			}
		}
		races_ >>= 1;
	}
	*/
             // old code end

	return (israce && isclass);
}

Last edited by ffchung; 07-03-2005 at 03:08 PM..
Reply With Quote