jessefreeman / GameCreator

A public project to share Game Creator tools, resources, documentation and log bugs.
Microsoft Public License
32 stars 3 forks source link

Drawing tiles outside of the tilemap bounds throws an error #30

Closed PixelVision8 closed 7 years ago

PixelVision8 commented 7 years ago

Ran into an error where trying to draw tiles outside of the tilemap's bounds throws an error.

image

Here is the full output from Unity:

IndexOutOfRangeException: Array index is out of range.
PixelVisionSDK.Chips.TilemapChip.ReadDataAt (int,int,int) (at Assets/UnityRunner/Assets/PixelVisionSDK/Engine/Chips/Graphics/TileMapChip.cs:294)
PixelVisionSDK.Chips.TilemapChip.ReadDataAt (PixelVisionSDK.Chips.TilemapChip/Layer,int,int) (at Assets/UnityRunner/Assets/PixelVisionSDK/Engine/Chips/Graphics/TileMapChip.cs:287)
PixelVisionSDK.Chips.TilemapChip.ReadSpriteAt (int,int) (at Assets/UnityRunner/Assets/PixelVisionSDK/Engine/Chips/Graphics/TileMapChip.cs:349)
PixelVisionSDK.Chips.GameChip.Tile (int,int,System.Nullable`1<int>,System.Nullable`1<int>,System.Nullable`1<int>) (at Assets/UnityRunner/Assets/PixelVisionSDK/Engine/Chips/Game/GameChip.cs:1310)
PixelVisionSDK.Chips.GameChip.UpdateTiles (int,int,int,int[],System.Nullable`1<int>,System.Nullable`1<int>) (at Assets/UnityRunner/Assets/PixelVisionSDK/Engine/Chips/Game/GameChip.cs:1412)
(wrapper dynamic-method) System.Runtime.CompilerServices.ExecutionScope.lambda_method (System.Runtime.CompilerServices.ExecutionScope,object,object[]) <IL 0x00089, 0x00300>
MoonSharp.Interpreter.Interop.MethodMemberDescriptor.Execute (MoonSharp.Interpreter.Script,object,MoonSharp.Interpreter.ScriptExecutionContext,MoonSharp.Interpreter.CallbackArguments) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/MethodMemberDescriptor.cs:195)
MoonSharp.Interpreter.Interop.FunctionMemberDescriptorBase/<GetCallback>c__AnonStorey0.<>m__0 (MoonSharp.Interpreter.ScriptExecutionContext,MoonSharp.Interpreter.CallbackArguments) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Interop/StandardDescriptors/MemberDescriptors/FunctionMemberDescriptorBase.cs:83)
MoonSharp.Interpreter.CallbackFunction.Invoke (MoonSharp.Interpreter.ScriptExecutionContext,System.Collections.Generic.IList`1<MoonSharp.Interpreter.DynValue>,bool) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/DataTypes/CallbackFunction.cs:58)
MoonSharp.Interpreter.Execution.VM.Processor.Internal_ExecCall (int,int,MoonSharp.Interpreter.CallbackFunction,MoonSharp.Interpreter.CallbackFunction,bool,string,MoonSharp.Interpreter.DynValue) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Execution/VM/Processor/Processor_InstructionLoop.cs:720)
MoonSharp.Interpreter.Execution.VM.Processor.Processing_Loop (int) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Execution/VM/Processor/Processor_InstructionLoop.cs:115)
MoonSharp.Interpreter.Execution.VM.Processor.Call (MoonSharp.Interpreter.DynValue,MoonSharp.Interpreter.DynValue[]) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Execution/VM/Processor/Processor.cs:67)
MoonSharp.Interpreter.Script.Call (MoonSharp.Interpreter.DynValue,MoonSharp.Interpreter.DynValue[]) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Script.cs:483)
MoonSharp.Interpreter.Script.Call (MoonSharp.Interpreter.DynValue) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Script.cs:442)
MoonSharp.Interpreter.Script.Call (object) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Script.cs:513)
PixelVisionRunner.Chips.LuaGameChip.Init () (at Assets/UnityRunner/Assets/Runner/Scripts/Chips/LuaGameChip.cs:44)
PixelVisionSDK.Chips.ChipManager.Init () (at Assets/UnityRunner/Assets/PixelVisionSDK/Engine/Chips/ChipManager.cs:96)
PixelVisionSDK.PixelVisionEngine.RunGame () (at Assets/UnityRunner/Assets/PixelVisionSDK/Engine/PixelVisionEngine.cs:173)
GameCreator.GameCreatorRunner.RunGame () (at Assets/GameCreator/Scripts/GameCreator/GameCreatorRunner.cs:649)
GameCreator.GameCreatorRunner.RunLoadedGame () (at Assets/GameCreator/Scripts/GameCreator/GameCreatorRunner.cs:605)
GameCreator.GameCreatorRunner.PreloaderComplete () (at Assets/GameCreator/Scripts/GameCreator/GameCreatorRunner.cs:341)
GameCreator.Services.RunnerService.PreloaderComplete () (at Assets/GameCreator/Scripts/GameCreator/Services/RunnerService.cs:141)
GameCreator.Bridges.EditorBridge.PreloaderComplete () (at Assets/GameCreator/Scripts/GameCreator/Bridges/EditorBridge.cs:422)
(wrapper dynamic-method) System.Runtime.CompilerServices.ExecutionScope.lambda_method (System.Runtime.CompilerServices.ExecutionScope,object,object[]) <IL 0x0000b, 0x0009d>
MoonSharp.Interpreter.Interop.MethodMemberDescriptor.Execute (MoonSharp.Interpreter.Script,object,MoonSharp.Interpreter.ScriptExecutionContext,MoonSharp.Interpreter.CallbackArguments) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/MethodMemberDescriptor.cs:195)
MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor.PerformOverloadedCall (MoonSharp.Interpreter.Script,object,MoonSharp.Interpreter.ScriptExecutionContext,MoonSharp.Interpreter.CallbackArguments) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/OverloadedMethodMemberDescriptor.cs:153)
MoonSharp.Interpreter.Interop.OverloadedMethodMemberDescriptor/<GetCallback>c__AnonStorey0.<>m__0 (MoonSharp.Interpreter.ScriptExecutionContext,MoonSharp.Interpreter.CallbackArguments) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/OverloadedMethodMemberDescriptor.cs:425)
MoonSharp.Interpreter.CallbackFunction.Invoke (MoonSharp.Interpreter.ScriptExecutionContext,System.Collections.Generic.IList`1<MoonSharp.Interpreter.DynValue>,bool) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/DataTypes/CallbackFunction.cs:58)
MoonSharp.Interpreter.Execution.VM.Processor.Internal_ExecCall (int,int,MoonSharp.Interpreter.CallbackFunction,MoonSharp.Interpreter.CallbackFunction,bool,string,MoonSharp.Interpreter.DynValue) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Execution/VM/Processor/Processor_InstructionLoop.cs:720)
MoonSharp.Interpreter.Execution.VM.Processor.Processing_Loop (int) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Execution/VM/Processor/Processor_InstructionLoop.cs:115)
MoonSharp.Interpreter.Execution.VM.Processor.Call (MoonSharp.Interpreter.DynValue,MoonSharp.Interpreter.DynValue[]) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Execution/VM/Processor/Processor.cs:67)
MoonSharp.Interpreter.Script.Call (MoonSharp.Interpreter.DynValue,MoonSharp.Interpreter.DynValue[]) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Script.cs:483)
MoonSharp.Interpreter.Script.Call (MoonSharp.Interpreter.DynValue,object[]) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Script.cs:502)
MoonSharp.Interpreter.Script.Call (object,object[]) (at Assets/UnityRunner/Assets/Plugins/MoonSharp/Interpreter/Script.cs:525)
PixelVisionRunner.Chips.LuaGameChip.Update (single) (at Assets/UnityRunner/Assets/Runner/Scripts/Chips/LuaGameChip.cs:55)
PixelVisionSDK.Chips.ChipManager.Update (single) (at Assets/UnityRunner/Assets/PixelVisionSDK/Engine/Chips/ChipManager.cs:112)
PixelVisionSDK.PixelVisionEngine.Update (single) (at Assets/UnityRunner/Assets/PixelVisionSDK/Engine/PixelVisionEngine.cs:190)
BaseRunner.Update () (at Assets/UnityRunner/Assets/Runner/Scripts/BaseRunner.cs:331)
GameCreator.GameCreatorRunner.Update () (at Assets/GameCreator/Scripts/GameCreator/GameCreatorRunner.cs:838)
PixelVision8 commented 7 years ago

Basically, this is happening when trying to read tile data in the TilemapChip on line 249. The error can be reproduced by loading the File Picker Tool and changing the open button x value off the screen (or any button).

This should fail silently and just not draw the tiles to the map.

PixelVision8 commented 7 years ago

This is now fixed. Out of bounds tiles will no longer throw and error and should wrap around like other texture data does in the renderer.

image