prime31 / Nez

Nez is a free 2D focused framework that works with MonoGame and FNA
MIT License
1.81k stars 362 forks source link

Tilemap crash after PR #291 #333

Closed Vanit closed 6 years ago

Vanit commented 6 years ago

I've recently got around to pulling the latest Nez version (its been a while) and now my Tilemaps are crashing while being parsed by TiledMapReader. After going back through the git log I can definitely blame the changes that came through in PR #291. For whatever reason the new tilecount and column fields aren't coming through the ContentReader (and they are present in the tmx), such that if I remove the lines that reads those ints (TiledMapReader:58/59) and comment out the new column check in TiledTileSet:49-51 the issue is resolved.

At first I figured I might have some stale content somewhere preventing tilecount/column from coming through, but cleaning the solution and rebuilding the Tilemaps in the pipeline doesn't help so I'm at a bit of a loss here.

Tileset.zip

Vanit commented 6 years ago

@gmantaos As this is your PR I'd appreciate it you had any insight here :)

haath commented 6 years ago

I'm on it. Could you post the exception you're getting?

Also this may be a wild guess but, since you just updated, did you try cleaning and re-building the Nez.PipelineImporter project? If those attributes are in your XML but are not in the .xnb tileset then there's a good chance your Content.mgcb considers the file to be up-to-date (since the .tmx itself didn't change) and did not automatically build it again with the new version of the importer.

Vanit commented 6 years ago

@gmantaos Thanks for the quick follow up :)

Exception (the duplicate key is ""):

System.ArgumentException was unhandled
  HResult=-2147024809
  Message=An item with the same key has already been added.
  Source=mscorlib
  StackTrace:
       at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
       at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
       at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
       at Nez.Tiled.TiledMapReader.readCustomProperties(ContentReader reader, Dictionary`2 properties) in C:\Users\lucas\Documents\Laputa\Nez\Nez.Portable\PipelineRuntime\Tiled\TiledMapReader.cs:line 115
       at Nez.Tiled.TiledMapReader.Read(ContentReader reader, TiledMap existingInstance) in C:\Users\lucas\Documents\Laputa\Nez\Nez.Portable\PipelineRuntime\Tiled\TiledMapReader.cs:line 60
       at Microsoft.Xna.Framework.Content.ContentTypeReader`1.Read(ContentReader input, Object existingInstance)
       at Microsoft.Xna.Framework.Content.ContentReader.InnerReadObject[T](T existingInstance)
       at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T](T existingInstance)
       at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T]()
       at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]()
       at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject)
       at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)
       at Game2.GameScene.initialize() in C:\Users\lucas\Documents\Laputa\Laputa\GameScene.cs:line 34
       at Nez.Scene..ctor() in C:\Users\lucas\Documents\Laputa\Nez\Nez.Portable\ECS\Scene.cs:line 317
       at Game2.Scene3..ctor() in C:\Users\lucas\Documents\Laputa\Laputa\ECS\Scene3.cs:line 22
       at Game2.GameScene..ctor() in C:\Users\lucas\Documents\Laputa\Laputa\GameScene.cs:line 21
       at Game2.Game1.Initialize() in C:\Users\lucas\Documents\Laputa\Laputa\Game1.cs:line 17
       at Microsoft.Xna.Framework.Game.DoInitialize()
       at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
       at Microsoft.Xna.Framework.Game.Run()
       at Game2.Program.Main() in C:\Users\lucas\Documents\Laputa\Laputa\Program.cs:line 17
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

Rebuilding Pipeline Importer had no effect, and I've tried removing the items from the content manager, as well as cleaning the build and it still fails with the rebuilt files sadly.

Not sure if this will be of use to you, but here's the generated xnb: untitled_xnb.zip

haath commented 6 years ago

Well I just got an opportunity to load your map into a dummy project of mine and it seems to work fine...

screenshot_1

Any chance I could get a clone of your project so I can see the issue reproduced?

Vanit commented 6 years ago

Ahah! I found the issue, and like all good bugs, its dumb user error. When I first created my project I copied the Pipeline Importer dlls to my Content dir instead of directly referencing them at their build location, so obviously I've been running an old version without realising. With that fixed the whole thing works fine, le sigh.

Appreciate your help, gave me just the nudge I needed. Was going to send you a sample project with the issue, but in setting it up I realised my mistake. :)