Merged in GZDB r2476.

This commit is contained in:
MascaraSnake 2016-01-23 09:34:09 +01:00
parent b604dfc4af
commit dbca1989fc

View file

@ -589,71 +589,73 @@ namespace CodeImp.DoomBuilder.ZDoom
// Sprite forced?
if(HasPropertyWithValue("$sprite"))
{
return GetPropertyValueString("$sprite", 0);
}
else
{
// Try the idle state
if(HasState("idle"))
{
StateStructure s = GetState("idle");
string spritename = s.GetSprite(0);
if(!string.IsNullOrEmpty(spritename))
result = spritename;
}
// Try the see state
if(string.IsNullOrEmpty(result) && HasState("see"))
{
StateStructure s = GetState("see");
string spritename = s.GetSprite(0);
if(!string.IsNullOrEmpty(spritename))
result = spritename;
}
// Try the inactive state
if(string.IsNullOrEmpty(result) && HasState("inactive"))
{
StateStructure s = GetState("inactive");
string spritename = s.GetSprite(0);
if(!string.IsNullOrEmpty(spritename))
result = spritename;
}
// Try the spawn state
if(string.IsNullOrEmpty(result) && HasState("spawn"))
{
StateStructure s = GetState("spawn");
string spritename = s.GetSprite(0);
if(!string.IsNullOrEmpty(spritename))
result = spritename;
}
// Still no sprite found? then just pick the first we can find
if(string.IsNullOrEmpty(result))
{
Dictionary<string, StateStructure> list = GetAllStates();
foreach(StateStructure s in list.Values)
{
string spritename = s.GetSprite(0);
if(!string.IsNullOrEmpty(spritename))
{
result = spritename;
break;
}
}
}
if(!string.IsNullOrEmpty(result))
{
// The sprite name is not actually complete, we still have to append
// the direction characters to it. Find an existing sprite with direction.
foreach(string postfix in SPRITE_POSTFIXES)
{
if(General.Map.Data.GetSpriteExists(result + postfix))
return result + postfix;
}
}
string sprite = GetPropertyValueString("$sprite", 0); //mxd
if (General.Map.Data.GetSpriteExists(sprite)) return sprite; //mxd. Added availability check
//mxd. Bitch and moan
General.ErrorLogger.Add(ErrorType.Warning, "DECORATE warning in " + classname + ":" + doomednum + ". The sprite \"" + sprite + "\" assigned by the \"$sprite\" property does not exist.");
}
// Try the idle state
if (HasState("idle"))
{
StateStructure s = GetState("idle");
string spritename = s.GetSprite(0);
if (!string.IsNullOrEmpty(spritename))
result = spritename;
}
// Try the see state
if (string.IsNullOrEmpty(result) && HasState("see"))
{
StateStructure s = GetState("see");
string spritename = s.GetSprite(0);
if (!string.IsNullOrEmpty(spritename))
result = spritename;
}
// Try the inactive state
if (string.IsNullOrEmpty(result) && HasState("inactive"))
{
StateStructure s = GetState("inactive");
string spritename = s.GetSprite(0);
if (!string.IsNullOrEmpty(spritename))
result = spritename;
}
// Try the spawn state
if (string.IsNullOrEmpty(result) && HasState("spawn"))
{
StateStructure s = GetState("spawn");
string spritename = s.GetSprite(0);
if (!string.IsNullOrEmpty(spritename))
result = spritename;
}
// Still no sprite found? then just pick the first we can find
if (string.IsNullOrEmpty(result))
{
Dictionary<string, StateStructure> list = GetAllStates();
foreach (StateStructure s in list.Values)
{
string spritename = s.GetSprite(0);
if (!string.IsNullOrEmpty(spritename))
{
result = spritename;
break;
}
}
}
if (!string.IsNullOrEmpty(result))
{
// The sprite name is not actually complete, we still have to append
// the direction characters to it. Find an existing sprite with direction.
foreach (string postfix in SPRITE_POSTFIXES)
{
if (General.Map.Data.GetSpriteExists(result + postfix))
return result + postfix;
}
}
// No sprite found