diff --git a/Source/Core/Map/Thing.cs b/Source/Core/Map/Thing.cs index 362662308389151ec6d9868fcc2d6b763cb4ed6b..9e2a0b29ba5567e76299043e16c0af90f0034a49 100755 --- a/Source/Core/Map/Thing.cs +++ b/Source/Core/Map/Thing.cs @@ -570,7 +570,12 @@ namespace CodeImp.DoomBuilder.Map ModelData md = General.Map.Data.ModeldefEntries[type]; if((md.LoadState == ModelLoadState.None && General.Map.Data.ProcessModel(type)) || md.LoadState != ModelLoadState.None) rendermode = (General.Map.Data.ModeldefEntries[type].IsVoxel ? ThingRenderMode.VOXEL : ThingRenderMode.MODEL); - } + } + else // reset rendermode if we SUDDENLY became a sprite out of a model. otherwise it crashes violently. + { + ThingTypeInfo ti = General.Map.Data.GetThingInfo(Type); + rendermode = (ti != null) ? ti.RenderMode : ThingRenderMode.NORMAL; + } // Update radian versions of pitch and roll switch(rendermode) diff --git a/Source/Core/Properties/AssemblyInfo.cs b/Source/Core/Properties/AssemblyInfo.cs index cdd7530c5bbf5edfe591882ec08cf1af411258b1..9008220480644bcd9893c02f4b16acb2aaa5c566 100755 --- a/Source/Core/Properties/AssemblyInfo.cs +++ b/Source/Core/Properties/AssemblyInfo.cs @@ -30,6 +30,6 @@ using CodeImp.DoomBuilder; // Build Number // Revision // -[assembly: AssemblyVersion("2.3.0.2924")] +[assembly: AssemblyVersion("2.3.0.2927")] [assembly: NeutralResourcesLanguageAttribute("en")] -[assembly: AssemblyHash("6108502")] +[assembly: AssemblyHash("f97c15a")] diff --git a/Source/Core/ZDoom/ActorStructure.cs b/Source/Core/ZDoom/ActorStructure.cs index e63e86e48a8a3d0453997cc153b693522d27cf4b..d9d98d0275c7cf7d9ed671ff131525506cf9ff35 100755 --- a/Source/Core/ZDoom/ActorStructure.cs +++ b/Source/Core/ZDoom/ActorStructure.cs @@ -282,23 +282,45 @@ namespace CodeImp.DoomBuilder.ZDoom General.ErrorLogger.Add(ErrorType.Warning, "DECORATE warning in " + classname + ":" + doomednum + ". The sprite \"" + sprite + "\" assigned by the \"$sprite\" property does not exist."); } - //mxd. Try to get a suitable sprite from our hardcoded states list - foreach(string state in SPRITE_CHECK_STATES) + StateStructure.FrameInfo firstNonTntInfo = null; + StateStructure.FrameInfo firstInfo = null; + // Pick the first we can find (including and not including TNT1) + Dictionary<string, StateStructure> list = GetAllStates(); + foreach (StateStructure s in list.Values) + { + StateStructure.FrameInfo info = s.GetSprite(0); + if (string.IsNullOrEmpty(info.Sprite)) continue; + + if (!info.IsEmpty()) firstNonTntInfo = info; + if (firstInfo == null) firstInfo = info; + + if (firstNonTntInfo != null) + break; + } + + //mxd. Try to get a suitable sprite from our hardcoded states list + StateStructure.FrameInfo lastNonTntInfo = null; + StateStructure.FrameInfo lastInfo = null; + foreach (string state in SPRITE_CHECK_STATES) { if(!HasState(state)) continue; StateStructure s = GetState(state); StateStructure.FrameInfo info = s.GetSprite(0); - if(!string.IsNullOrEmpty(info.Sprite)) return info; - } - - // Still no sprite found? then just pick the first we can find - Dictionary<string, StateStructure> list = GetAllStates(); - foreach(StateStructure s in list.Values) - { - StateStructure.FrameInfo info = s.GetSprite(0); - if(!string.IsNullOrEmpty(info.Sprite)) return info; + //if(!string.IsNullOrEmpty(info.Sprite)) return info; + if (string.IsNullOrEmpty(info.Sprite)) continue; + + if (!info.IsEmpty()) lastNonTntInfo = info; + if (lastInfo == null) lastInfo = info; + + if (lastNonTntInfo != null) + break; } + + // [ZZ] return whatever is there by priority. try to pick non-TNT1 frames. + StateStructure.FrameInfo[] infos = new StateStructure.FrameInfo[] { lastNonTntInfo, firstNonTntInfo, lastInfo, firstInfo }; + foreach (StateStructure.FrameInfo info in infos) + if (info != null) return info; //mxd. No dice... return null; diff --git a/Source/Core/ZDoom/DecorateStateStructure.cs b/Source/Core/ZDoom/DecorateStateStructure.cs index 57dcd6924f956219f3f17f6e24f6e88d89556f31..d2184abdea52dccd398ecbca3425054279a19c70 100755 --- a/Source/Core/ZDoom/DecorateStateStructure.cs +++ b/Source/Core/ZDoom/DecorateStateStructure.cs @@ -119,6 +119,19 @@ namespace CodeImp.DoomBuilder.ZDoom if (/*!realspritename.StartsWith("TNT1") && */!spritename.StartsWith("----") && !spritename.Contains("#")) // [ZZ] some actors have only TNT1 state and receive a random image because of this { info.Sprite = spritename; //mxd + int duration = -1; + parser.SkipWhitespace(false); + string durationstr = parser.ReadToken(); + if (durationstr == "-") + durationstr += parser.ReadToken(); + if (string.IsNullOrEmpty(durationstr) || durationstr == "\n") + { + parser.ReportError("Expected frame duration"); + return; + } + if (!int.TryParse(durationstr.Trim(), out duration)) + parser.DataStream.Seek(-(durationstr.Length), SeekOrigin.Current); + info.Duration = duration; sprites.Add(info); } } diff --git a/Source/Core/ZDoom/StateStructure.cs b/Source/Core/ZDoom/StateStructure.cs index dd4a3e799965240cb3d931c7b6b98d12b63e879d..f2e1bf20c8c819eef64d3ae93b41d4cd2ba465cb 100755 --- a/Source/Core/ZDoom/StateStructure.cs +++ b/Source/Core/ZDoom/StateStructure.cs @@ -33,6 +33,12 @@ namespace CodeImp.DoomBuilder.ZDoom public string Sprite; public string LightName; public bool Bright; + public int Duration; // this is used for TrimLeft + + public bool IsEmpty() + { + return (Sprite.StartsWith("TNT1") || Duration == 0); + } } #endregion @@ -78,7 +84,7 @@ namespace CodeImp.DoomBuilder.ZDoom int firstNonEmpty = -1; for (int i = 0; i < sprites.Count; i++) { - if (!sprites[i].Sprite.StartsWith("TNT1")) + if (!sprites[i].IsEmpty()) { firstNonEmpty = i; break; diff --git a/Source/Core/ZDoom/ZScriptStateStructure.cs b/Source/Core/ZDoom/ZScriptStateStructure.cs index 326ca5c0886c9e36daaec428d83df2c22dd7f6ce..a83859a55ca01bd5ffa31273624d9cb4c8fc171d 100755 --- a/Source/Core/ZDoom/ZScriptStateStructure.cs +++ b/Source/Core/ZDoom/ZScriptStateStructure.cs @@ -148,6 +148,7 @@ namespace CodeImp.DoomBuilder.ZDoom token = tokenizer.ExpectToken(ZScriptTokenType.Identifier); if (token != null && token.IsValid) { + duration = -1; tokenizer.SkipWhitespace(); token = tokenizer.ExpectToken(ZScriptTokenType.OpenParen); if (token != null && token.IsValid) @@ -181,6 +182,7 @@ namespace CodeImp.DoomBuilder.ZDoom if (/*!realspritename.StartsWith("TNT1") && */!realspritename.StartsWith("----") && !realspritename.Contains("#")) // [ZZ] some actors have only TNT1 state and receive a random image because of this { info.Sprite = realspritename; //mxd + info.Duration = duration; sprites.Add(info); } diff --git a/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs b/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs index f0cff6afde4adde7f9c97f757b955d884a2238d3..bd22378e7b37798ff0787e78ffcb1560db7f2b80 100755 --- a/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs +++ b/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Resources; // Build Number // Revision // -[assembly: AssemblyVersion("2.3.0.2924")] +[assembly: AssemblyVersion("2.3.0.2927")] [assembly: NeutralResourcesLanguageAttribute("en")]