changeset 289:43a058bd38e0

Robustified DBEntry()
author James D. Callahan III <jcallahan@curse.com>
date Mon, 20 May 2013 10:43:18 -0500
parents d841c44553d5
children 385237bb6ab9
files Main.lua
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Main.lua	Wed May 15 20:15:40 2013 -0500
+++ b/Main.lua	Mon May 20 10:43:18 2013 -0500
@@ -296,11 +296,17 @@
     if not data_type or not unit_id then
         return
     end
-    local unit = global_db[data_type][unit_id]
+    local category = global_db[data_type]
+
+    if not category then
+        category = {}
+        global_db[data_type] = category
+    end
+    local unit = category[unit_id]
 
     if not unit then
         unit = {}
-        global_db[data_type][unit_id] = unit
+        category[unit_id] = unit
     end
     return unit
 end