From 69b59d33dd2d9137ad651fa102c963083ad4bbf2 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 16 Aug 2015 16:45:30 -0700 Subject: [PATCH] prevent writing null items --- Subforms/Garden.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Subforms/Garden.cs b/Subforms/Garden.cs index 823f686..611bc5f 100644 --- a/Subforms/Garden.cs +++ b/Subforms/Garden.cs @@ -388,6 +388,7 @@ private void clickTown(object sender, MouseEventArgs e) choiceTownItem = TownItems[index]; // replace this with updating the item view else // Write { + if (choiceTownItem == null) return; TownItems[index] = choiceTownItem; int zX = (X - 16) / 16; int zY = (Y - 16) / 16; @@ -411,7 +412,8 @@ private void clickIsland(object sender, MouseEventArgs e) choiceIslandItem = IslandItems[index]; // replace this with updating the item view else // Write { - IslandItems[index] = choiceTownItem; + if (choiceIslandItem == null) return; + IslandItems[index] = choiceIslandItem; int zX = (X - 16) / 16; int zY = (Y - 16) / 16; int zAcre = zX + zY * 2; @@ -419,8 +421,8 @@ private void clickIsland(object sender, MouseEventArgs e) } } - private Item choiceTownItem; - private Item choiceIslandItem; + private Item choiceTownItem = new Item(new byte[] {0xFE, 0x7F, 0, 0}); + private Item choiceIslandItem = new Item(new byte[] {0xFE, 0x7F, 0, 0}); private int getItemIndex(int X, int Y, int width) { int zX = (X - 16) / 16;