Fix a crash issue when attempting to draw invalid item.
This can happen when using UIItem as interfaces etc.
This commit is contained in:
		
							parent
							
								
									12b3bd4ee0
								
							
						
					
					
						commit
						9f7aafac0b
					
				| 
						 | 
				
			
			@ -1,21 +1,21 @@
 | 
			
		|||
Icons = {}
 | 
			
		||||
Icons[1] = { tooltip = tr('You are poisoned'), path = '/images/game/states/poisoned', id = 'condition_poisoned' }
 | 
			
		||||
Icons[2] = { tooltip = tr('You are burning'), path = '/images/game/states/burning', id = 'condition_burning' }
 | 
			
		||||
Icons[4] = { tooltip = tr('You are electrified'), path = '/images/game/states/electrified', id = 'condition_electrified' }
 | 
			
		||||
Icons[8] = { tooltip = tr('You are drunk'), path = '/images/game/states/drunk', id = 'condition_drunk' }
 | 
			
		||||
Icons[16] = { tooltip = tr('You are protected by a magic shield'), path = '/images/game/states/magic_shield', id = 'condition_magic_shield' }
 | 
			
		||||
Icons[32] = { tooltip = tr('You are paralysed'), path = '/images/game/states/slowed', id = 'condition_slowed' }
 | 
			
		||||
Icons[64] = { tooltip = tr('You are hasted'), path = '/images/game/states/haste', id = 'condition_haste' }
 | 
			
		||||
Icons[128] = { tooltip = tr('You may not logout during a fight'), path = '/images/game/states/logout_block', id = 'condition_logout_block' }
 | 
			
		||||
Icons[256] = { tooltip = tr('You are drowning'), path = '/images/game/states/drowning', id = 'condition_drowning' }
 | 
			
		||||
Icons[512] = { tooltip = tr('You are freezing'), path = '/images/game/states/freezing', id = 'condition_freezing' }
 | 
			
		||||
Icons[1024] = { tooltip = tr('You are dazzled'), path = '/images/game/states/dazzled', id = 'condition_dazzled' }
 | 
			
		||||
Icons[2048] = { tooltip = tr('You are cursed'), path = '/images/game/states/cursed', id = 'condition_cursed' }
 | 
			
		||||
Icons[4096] = { tooltip = tr('You are strengthened'), path = '/images/game/states/strengthened', id = 'condition_strengthened' }
 | 
			
		||||
Icons[8192] = { tooltip = tr('You may not logout or enter a protection zone'), path = '/images/game/states/protection_zone_block', id = 'condition_protection_zone_block' }
 | 
			
		||||
Icons[16384] = { tooltip = tr('You are within a protection zone'), path = '/images/game/states/protection_zone', id = 'condition_protection_zone' }
 | 
			
		||||
Icons[32768] = { tooltip = tr('You are bleeding'), path = '/images/game/states/bleeding', id = 'condition_bleeding' }
 | 
			
		||||
Icons[65536] = { tooltip = tr('You are hungry'), path = '/images/game/states/hungry', id = 'condition_hungry' }
 | 
			
		||||
Icons[PlayerStates.Poison] = { tooltip = tr('You are poisoned'), path = '/images/game/states/poisoned', id = 'condition_poisoned' }
 | 
			
		||||
Icons[PlayerStates.Burn] = { tooltip = tr('You are burning'), path = '/images/game/states/burning', id = 'condition_burning' }
 | 
			
		||||
Icons[PlayerStates.Energy] = { tooltip = tr('You are electrified'), path = '/images/game/states/electrified', id = 'condition_electrified' }
 | 
			
		||||
Icons[PlayerStates.Drunk] = { tooltip = tr('You are drunk'), path = '/images/game/states/drunk', id = 'condition_drunk' }
 | 
			
		||||
Icons[PlayerStates.ManaShield] = { tooltip = tr('You are protected by a magic shield'), path = '/images/game/states/magic_shield', id = 'condition_magic_shield' }
 | 
			
		||||
Icons[PlayerStates.Paralyze] = { tooltip = tr('You are paralysed'), path = '/images/game/states/slowed', id = 'condition_slowed' }
 | 
			
		||||
Icons[PlayerStates.Haste] = { tooltip = tr('You are hasted'), path = '/images/game/states/haste', id = 'condition_haste' }
 | 
			
		||||
Icons[PlayerStates.Swords] = { tooltip = tr('You may not logout during a fight'), path = '/images/game/states/logout_block', id = 'condition_logout_block' }
 | 
			
		||||
Icons[PlayerStates.Drowning] = { tooltip = tr('You are drowning'), path = '/images/game/states/drowning', id = 'condition_drowning' }
 | 
			
		||||
Icons[PlayerStates.Freezing] = { tooltip = tr('You are freezing'), path = '/images/game/states/freezing', id = 'condition_freezing' }
 | 
			
		||||
Icons[PlayerStates.Dazzled] = { tooltip = tr('You are dazzled'), path = '/images/game/states/dazzled', id = 'condition_dazzled' }
 | 
			
		||||
Icons[PlayerStates.Cursed] = { tooltip = tr('You are cursed'), path = '/images/game/states/cursed', id = 'condition_cursed' }
 | 
			
		||||
Icons[PlayerStates.PartyBuff] = { tooltip = tr('You are strengthened'), path = '/images/game/states/strengthened', id = 'condition_strengthened' }
 | 
			
		||||
Icons[PlayerStates.PzBlock] = { tooltip = tr('You may not logout or enter a protection zone'), path = '/images/game/states/protection_zone_block', id = 'condition_protection_zone_block' }
 | 
			
		||||
Icons[PlayerStates.Pz] = { tooltip = tr('You are within a protection zone'), path = '/images/game/states/protection_zone', id = 'condition_protection_zone' }
 | 
			
		||||
Icons[PlayerStates.Bleeding] = { tooltip = tr('You are bleeding'), path = '/images/game/states/bleeding', id = 'condition_bleeding' }
 | 
			
		||||
Icons[PlayerStates.Hungry] = { tooltip = tr('You are hungry'), path = '/images/game/states/hungry', id = 'condition_hungry' }
 | 
			
		||||
 | 
			
		||||
healthInfoWindow = nil
 | 
			
		||||
healthBar = nil
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -133,7 +133,7 @@ function Player:getItemsCount(itemId)
 | 
			
		|||
  return count
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Player:hasState(_state, states)
 | 
			
		||||
function Player:hasState(state, states)
 | 
			
		||||
  if not states then
 | 
			
		||||
    states = self:getStates()
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -143,7 +143,7 @@ function Player:hasState(_state, states)
 | 
			
		|||
    if pow > states then break end
 | 
			
		||||
 | 
			
		||||
    local states = bit32.band(states, pow)
 | 
			
		||||
    if states == _state then
 | 
			
		||||
    if states == state then
 | 
			
		||||
      return true
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -272,6 +272,10 @@ ItemPtr Item::clone()
 | 
			
		|||
 | 
			
		||||
void Item::calculatePatterns(int& xPattern, int& yPattern, int& zPattern)
 | 
			
		||||
{
 | 
			
		||||
    // Avoid crashes with invalid items
 | 
			
		||||
    if(!isValid())
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    if(isStackable() && getNumPatternX() == 4 && getNumPatternY() == 2) {
 | 
			
		||||
        if(m_countOrSubType <= 0) {
 | 
			
		||||
            xPattern = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue