예제 #1
0
 public static void DeleteCharacter(
     AsyncRPGDataContext context,
     int character_id)
 {
     context.Characters.DeleteOnSubmit(context.Characters.Single(c => c.CharacterID == character_id));
     context.SubmitChanges();
 }
예제 #2
0
        public static void CreateCharacter(
            AsyncRPGDataContext context,
            int account_id,
            string name,
            GameConstants.eGender gender,
            GameConstants.eArchetype archetype,
            int picture_id)
        {
            Characters newCharacter = new Characters
            {
                AccountID= account_id,
                GameID= -1,
                RoomX = 0,
                RoomY = 0,
                RoomZ = 0,
                LastPingTime = DateTime.Now,
                LastSentEventID = -1,
                NewEventsPosted = false,
                X= 0.0f,
                Y= 0.0f,
                Z= 0.0f,
                Angle= 0.0f,
                Name= name,
                Gender = (gender == GameConstants.eGender.Male),
                Archetype = (int)archetype,
                PictureID = picture_id,
                PowerLevel= 1,
                Energy= 0
            };

            context.Characters.InsertOnSubmit(newCharacter);
            context.SubmitChanges();
        }
예제 #3
0
        public static void BindCharacterToGame(
            AsyncRPGDataContext context,
            int character_id,
            int new_game_id)
        {
            // Get the most recent event that occurred in the new game
            int last_game_event_id = GameEventQueries.GetLastGameEvent(context, new_game_id);

            // Tell the character which game they are bound to
            // and set an initial location
            var dbCharacter =
                (from c in context.Characters
                 where c.CharacterID == character_id
                 select c).Single();

            dbCharacter.GameID = new_game_id;
            dbCharacter.RoomX = 0;
            dbCharacter.RoomY = 0;
            dbCharacter.RoomZ = 0;
            dbCharacter.X = 0;
            dbCharacter.Y = 0;
            dbCharacter.Z = 0;
            dbCharacter.Angle = 0;
            dbCharacter.LastSentEventID = last_game_event_id;
            dbCharacter.NewEventsPosted = false;

            context.SubmitChanges();
        }
예제 #4
0
        public static void UpdateEnergyTankEnergy(
            AsyncRPGDataContext db_context,
            int energyTankID,
            int newEnergy)
        {
            var energyTankQuery =
                (from e in db_context.EnergyTanks
                where e.EnergyTankID == energyTankID
                select e).SingleOrDefault();

            db_context.SubmitChanges();
        }
예제 #5
0
        public static void ClearCharacterNewEventFlag(
            AsyncRPGDataContext context,
            int character_id)
        {
            var query = (from c in context.Characters
                         where c.CharacterID == character_id
                         select c).Single();

            query.NewEventsPosted = false;

            context.SubmitChanges();
        }
예제 #6
0
        public static void UpdateEnergyTank(
            AsyncRPGDataContext db_context,
            EnergyTank energyTank)
        {
            var dbEnergyTank =
                (from e in db_context.EnergyTanks
                 where e.EnergyTankID == energyTank.ID
                 select e).SingleOrDefault();

            dbEnergyTank.GameID = energyTank.RoomKey.game_id;
            dbEnergyTank.RoomX = energyTank.RoomKey.x;
            dbEnergyTank.RoomY = energyTank.RoomKey.y;
            dbEnergyTank.RoomZ = energyTank.RoomKey.z;
            dbEnergyTank.X = energyTank.Position.x;
            dbEnergyTank.Y = energyTank.Position.y;
            dbEnergyTank.Z = energyTank.Position.z;
            dbEnergyTank.Ownership = (int)energyTank.Faction;
            dbEnergyTank.Energy = energyTank.Energy;

            db_context.SubmitChanges();
        }
예제 #7
0
        public static void UpdateEnergyTankOwnership(
            AsyncRPGDataContext db_context,
            EnergyTank energyTank,
            GameConstants.eFaction newOwnership)
        {
            var energyTankQuery =
                (from e in db_context.EnergyTanks
                    where e.EnergyTankID == energyTank.ID
                    select e).SingleOrDefault();

            energyTankQuery.Ownership = (int)newOwnership;

            db_context.SubmitChanges();

            energyTank.Faction = newOwnership;
        }
예제 #8
0
        public void ParseRoomTemplates(
            AsyncRPGDataContext db_context,
            string template_path)
        {
            MobTypeSet mobTypeSet = new MobTypeSet();
            MobSpawnTableSet mobSpawnTableSet = new MobSpawnTableSet();

            // Clear out any existing room templates
            db_context.ExecuteCommand("DELETE FROM room_templates");

            // Get the mob type set from the DB
            mobTypeSet.Initialize(db_context);

            // Get the mob spawn templates from the DB
            mobSpawnTableSet.Initialize(db_context, mobTypeSet);

            // Read in each XML file and save it into the room templates table
            string[] templateFiles = Directory.GetFiles(template_path, "*.oel");

            if (templateFiles == null || templateFiles.Length == 0)
            {
                throw new Exception("RoomTemplateParser: No room template files (*.oel) found in directory: " + template_path);
            }

            {
                Dictionary<TypedFlags<MathConstants.eSignedDirection>, int> portalLayoutCounts =
                    new Dictionary<TypedFlags<MathConstants.eSignedDirection>, int>();
                bool anyRoomParsingErrors = false;

                foreach (string templateFile in templateFiles)
                {
                    string templateName = Path.GetFileNameWithoutExtension(templateFile);

                    RoomTemplate roomTemplate = null;
                    byte[] compressedNavCells = null;
                    byte[] compressedPVS = null;

                    // Parse the XML template from the file
                    XmlDocument doc = new XmlDocument();
                    doc.Load(templateFile);

                    // Parse the room template xml into a room template object
                    roomTemplate = new RoomTemplate(templateName, doc);

                    // Keep track of all of the unique portal layouts we encounter
                    if (portalLayoutCounts.ContainsKey(roomTemplate.PortalRoomSideBitmask))
                    {
                        portalLayoutCounts[roomTemplate.PortalRoomSideBitmask] += 1;
                    }
                    else
                    {
                        portalLayoutCounts.Add(roomTemplate.PortalRoomSideBitmask, 1);
                    }

                    // Extract the nav-mesh and visibility data in compressed form to save into the DB
                    roomTemplate.NavMeshTemplate.ToCompressedData(out compressedNavCells, out compressedPVS);

                    // Remove everything from the template XML that we wont care about at runtime
                    RemoveXmlNodeByXPath(doc, "/level/Floor");
                    RemoveXmlNodeByXPath(doc, "/level/Walls");
                    RemoveXmlNodeByXPath(doc, "/level/BackgroundObjects");
                    RemoveXmlNodeByXPath(doc, "/level/ForegroundObjects");
                    RemoveXmlNodeByXPath(doc, "/level/NavMesh");

                    if (ValidateRoomTemplate(
                            templateName,
                            roomTemplate,
                            mobSpawnTableSet,
                            compressedNavCells,
                            compressedPVS))
                    {
                        // Save the XML back into string
                        StringWriter stringWriter = new StringWriter();
                        XmlTextWriter xmlWriter = new XmlTextWriter(stringWriter);
                        doc.WriteTo(xmlWriter);

                        RoomTemplates dbRoomTemplate =
                            new RoomTemplates
                            {
                                Name = templateName,
                                XML = stringWriter.ToString(),
                                CompressedNavMesh = compressedNavCells,
                                CompressedVisibility = compressedPVS
                            };

                        db_context.RoomTemplates.InsertOnSubmit(dbRoomTemplate);
                        db_context.SubmitChanges();

                        _logger.LogInfo("RoomTemplateParser: Added Room Template:");
                        _logger.LogInfo(templateFile);
                    }
                    else
                    {
                        anyRoomParsingErrors = true;
                    }
                }

                // Verify all possible door-side combinations are represented in the template file set
                if (portalLayoutCounts.Keys.Count < k_expectedRoomLayouts.Length)
                {
                    foreach (TypedFlags<MathConstants.eSignedDirection> expectedLayout in k_expectedRoomLayouts)
                    {
                        if (!portalLayoutCounts.ContainsKey(expectedLayout))
                        {
                            _logger.LogError(
                                string.Format(
                                "RoomTemplateParser: Missing expected room layout: {0}{1}{2}{3}{4}{5}",
                                expectedLayout.Test(MathConstants.eSignedDirection.positive_x) ? "X+" : "",
                                expectedLayout.Test(MathConstants.eSignedDirection.negative_x) ? "X-" : "",
                                expectedLayout.Test(MathConstants.eSignedDirection.positive_y) ? "Y+" : "",
                                expectedLayout.Test(MathConstants.eSignedDirection.negative_y) ? "Y-" : "",
                                expectedLayout.Test(MathConstants.eSignedDirection.positive_z) ? "Z+" : "",
                                expectedLayout.Test(MathConstants.eSignedDirection.negative_z) ? "Z-" : ""));

                            anyRoomParsingErrors = true;
                        }
                    }
                }

                if (anyRoomParsingErrors)
                {
                    throw new Exception("RoomTemplateParser: Failed to parse all room templates");
                }
            }
        }
예제 #9
0
        // Database Config Interface
        //--------------------------
        public static void InitializeConfig(
            AsyncRPGDataContext context,
            int version,
            string appUrl,
            string appDebugUrl,
            string clientUrl,
            string emailAddress,
            string emailHost,
            int emailPort,
            string emailUsername,
            string emailPassword,
            string ircServer,
            int ircPort)
        {
            Config config = new Config
            {
                Version = version,
                AppURL = appUrl,
                AppDebugURL = appDebugUrl,
                ClientURL = clientUrl,
                EmailAddress = emailAddress,
                EmailHost = emailHost,
                EmailPort = emailPort,
                EmailUserName = emailUsername,
                EmailPassword = emailPassword,
                IrcServer = ircServer,
                IrcPort = ircPort
            };

            context.Configs.InsertOnSubmit(config);
            context.SubmitChanges();
        }
예제 #10
0
        public static int CreateGame(
            AsyncRPGDataContext context,
            int account_id,
            string game_name,
            GameConstants.eDungeonSize dungeonSize,
            GameConstants.eDungeonDifficulty dungeonDifficulty,
            bool irc_enabled,
            string irc_server,
            int irc_port,
            bool irc_encryption_enabled)
        {
            int new_game_id = -1;

            // Create a random 256-bit (32 byte) encryption key for encrypting chat
            string irc_encryption_key = RNGUtilities.CreateNonDeterministicRandomBase64String(256);
            Debug.Assert(irc_encryption_key.Length == 44);

            if (irc_server.Length == 0)
            {
                irc_server = IrcConstants.DEFAULT_IRC_SERVER;
            }

            if (irc_port < IrcConstants.LOWEST_VALID_IRC_PORT || irc_port > IrcConstants.HIGHEST_VALID_IRC_PORT)
            {
                irc_port = IrcConstants.DEFAULT_IRC_PORT;
            }

            {
                Games newGame = new Games
                {
                    OwnerAccountID = account_id,
                    Name = game_name,
                    DungeonSize = (int)dungeonSize,
                    DungeonDifficulty = (int)dungeonDifficulty,
                    IrcEnabed = irc_enabled,
                    IrcServer = irc_server,
                    IrcPort = irc_port,
                    IrcEncryptionKey = irc_encryption_key,
                    IrcEncryptionEnabed = irc_encryption_enabled
                };

                context.Games.InsertOnSubmit(newGame);
                context.SubmitChanges();

                new_game_id = newGame.GameID;
            }

            return new_game_id;
        }
예제 #11
0
        public static void UpdateCharacterLastPingTime(
            AsyncRPGDataContext context,
            int character_id)
        {
            var query = (from c in context.Characters
                         where c.CharacterID == character_id
                         select c).Single();

            query.LastPingTime = DateTime.Now;

            context.SubmitChanges();
        }
예제 #12
0
        public static void UpdateCharacterLastEventId(
            AsyncRPGDataContext context,
            int character_id,
            int last_event_id)
        {
            var query =
                (from c in context.Characters
                 where c.CharacterID == character_id
                 select c).Single();

            query.LastSentEventID = last_event_id;

            context.SubmitChanges();
        }
예제 #13
0
        public static void UpdateCharacterEnergy(
            AsyncRPGDataContext context,
            int character_id,
            int energy)
        {
            var dbCharacter =
                (from c in context.Characters
                 where c.CharacterID == character_id
                 select c).SingleOrDefault();

            dbCharacter.Energy = energy;

            context.SubmitChanges();
        }
예제 #14
0
        public static void InsertWorld(
            AsyncRPGDataContext db_context,
            World world)
        {
            Dictionary<int, Portal> portalIdMap = new Dictionary<int, Portal>();
            Dictionary<int, int> portalIdRemapping = new Dictionary<int, int>();
            Dictionary<int, int> reversePortalIdRemapping = new Dictionary<int, int>();

            // Insert all the rooms and portals with their initial IDs
            {
                foreach (Room room in world.Rooms)
                {
                    // Save each room into the database
                    {
                        Rooms dbRoom = new Rooms
                        {
                            X = room.room_key.x,
                            Y = room.room_key.y,
                            Z = room.room_key.z,
                            GameID = world.GameID,
                            RandomSeed = room.random_seed,
                            StaticData = JsonMapper.ToJson(room.static_room_data)
                        };

                        db_context.Rooms.InsertOnSubmit(dbRoom);
                        db_context.SubmitChanges();
                    }

                    // Save each portal into the database
                    foreach (Portal portal in room.portals)
                    {
                        Portals dbPortal = new Portals
                        {
                            PortalType = (int)portal.portal_type,
                            TargetPortalID = -1,
                            GameID = world.GameID,
                            RoomX = portal.room_x,
                            RoomY = portal.room_y,
                            RoomZ = portal.room_z,
                            RoomSide = (int)portal.room_side,
                            BboxX0 = portal.bounding_box.Min.x,
                            BboxY0 = portal.bounding_box.Min.y,
                            BboxX1 = portal.bounding_box.Max.x,
                            BboxY1 = portal.bounding_box.Max.y
                        };

                        db_context.Portals.InsertOnSubmit(dbPortal);
                        db_context.SubmitChanges();

                        portalIdMap.Add(portal.portal_id, portal);
                        portalIdRemapping.Add(portal.portal_id, dbPortal.PortalID);
                        reversePortalIdRemapping.Add(dbPortal.PortalID, portal.portal_id);

                        // Portal ID assignment has to happen after all the portals are inserted
                    }

                    // Save each mob spawner to the database
                    foreach (MobSpawner spawner in room.mobSpawners)
                    {
                        MobSpawners dbMobSpawner = new MobSpawners
                        {
                            GameID = world.GameID,
                            RoomX = room.room_key.x,
                            RoomY = room.room_key.y,
                            RoomZ = room.room_key.z,
                            X = spawner.Position.x,
                            Y = spawner.Position.y,
                            Z = spawner.Position.z,
                            MobSpawnerTableID = spawner.SpawnTable.ID,
                            RemainingSpawnCount = spawner.RemainingSpawnCount,
                            RandomSeed = spawner.RandomSeed
                        };

                        db_context.MobSpawners.InsertOnSubmit(dbMobSpawner);
                        db_context.SubmitChanges();

                        // Assign an id once the spawner has been inserted into the DB
                        spawner.ID = dbMobSpawner.MobSpawnerID;
                    }

                    // Save each energy tank to the database
                    if (room is RoomLayout)
                    {
                        RoomLayout roomLayout = (RoomLayout)room;

                        foreach (EnergyTank energyTank in roomLayout.energyTanks)
                        {
                            EnergyTanks dbEnergyTank = new EnergyTanks
                            {
                                GameID = world.GameID,
                                RoomX = room.room_key.x,
                                RoomY = room.room_key.y,
                                RoomZ = room.room_key.z,
                                X = energyTank.Position.x,
                                Y = energyTank.Position.y,
                                Z = energyTank.Position.z,
                                Ownership = (int)energyTank.Faction,
                                Energy = energyTank.Energy
                            };

                            db_context.EnergyTanks.InsertOnSubmit(dbEnergyTank);
                            db_context.SubmitChanges();

                            // Assign an id once the energy tank has been inserted into the DB
                            energyTank.ID = dbEnergyTank.EnergyTankID;
                        }

                        // Drop the energy tanks now that we've saved them
                        roomLayout.energyTanks = null;
                    }
                }
            }

            // Fix up portal IDs
            {
                // Fixed the cached portal ids to match the ids in the database
                var query =
                    from dbPortal in db_context.Portals
                    where dbPortal.GameID == world.GameID
                    select dbPortal;

                foreach (Portals dbPortal in query)
                {
                    // Find the cache portal id from the db portal id using the reverse mapping
                    int cachePortalId = reversePortalIdRemapping[dbPortal.PortalID];

                    // Get the cached portal using the cached portal
                    Portal cachePortal = portalIdMap[cachePortalId];

                    // Remap the cached portal's target id to be a db portal id
                    int dbTargetPortalId = portalIdRemapping[cachePortal.target_portal_id];

                    // Set the target portal id in the database
                    dbPortal.TargetPortalID = dbTargetPortalId;

                    // Fix-up the portal ids on the cached portal
                    cachePortal.portal_id = dbPortal.PortalID;
                    cachePortal.target_portal_id = dbTargetPortalId;
                }

                db_context.SubmitChanges();
            }
        }
예제 #15
0
        public static void UpdateRoomRandomSeed(
            AsyncRPGDataContext db_context,
            RoomKey roomKey,
            int random_seed)
        {
            var room=
                (from r in db_context.Rooms
                where r.GameID == roomKey.game_id && r.X == roomKey.x && r.Y == roomKey.y && r.Z == roomKey.z
                select r).Single();

            room.RandomSeed = random_seed;

            db_context.SubmitChanges();
        }
예제 #16
0
        public static void UpdateCharacterPosition(
            AsyncRPGDataContext context,
            int character_id,
            RoomKey roomKey,
            Point3d position,
            float angle)
        {
            var dbCharacter =
                (from c in context.Characters
                 where c.CharacterID == character_id
                 select c).SingleOrDefault();

            dbCharacter.RoomX = roomKey.x;
            dbCharacter.RoomY = roomKey.y;
            dbCharacter.RoomZ = roomKey.z;
            dbCharacter.X = position.x;
            dbCharacter.Y = position.y;
            dbCharacter.Z = position.z;
            dbCharacter.Angle = angle;

            context.SubmitChanges();
        }
예제 #17
0
        public static void UnBindCharacterFromGame(
            AsyncRPGDataContext context,
            int character_id)
        {
            var dbCharacter =
                (from c in context.Characters
                 where c.CharacterID == character_id
                 select c).Single();

            dbCharacter.GameID = -1;
            dbCharacter.RoomX = 0;
            dbCharacter.RoomY = 0;
            dbCharacter.RoomZ = 0;
            dbCharacter.X = 0;
            dbCharacter.Y = 0;
            dbCharacter.Z = 0;
            dbCharacter.Angle = 0;

            context.SubmitChanges();
        }
예제 #18
0
        public static void UpdatePlayer(
            AsyncRPGDataContext db_context,
            Player player)
        {
            var dbCharacter =
                (from p in db_context.Characters
                 where p.CharacterID == player.ID
                 select p).Single();

            dbCharacter.CharacterID = player.ID;
            dbCharacter.Name = player.Name;
            dbCharacter.Archetype = (int)player.Archetype;
            dbCharacter.Gender = (player.Gender == GameConstants.eGender.Male);
            dbCharacter.PictureID = player.PictureID;
            dbCharacter.PowerLevel = player.PowerLevel;
            dbCharacter.Energy = player.Energy;
            //TODO: dbCharacter.Health = this.Health;
            dbCharacter.GameID = player.RoomKey.game_id;
            dbCharacter.RoomX = player.RoomKey.x;
            dbCharacter.RoomY = player.RoomKey.y;
            dbCharacter.RoomZ = player.RoomKey.z;
            dbCharacter.X = player.Position.x;
            dbCharacter.Y = player.Position.y;
            dbCharacter.Z = player.Position.z;
            dbCharacter.Angle = player.Angle;

            db_context.SubmitChanges();
        }
예제 #19
0
        public static void DeleteGame(
            AsyncRPGDataContext context,
            int gameid)
        {
            // Detach all of the Characters from the game
            {
                var query =
                    from character in context.Characters
                    where character.GameID == gameid
                    select character;

                foreach (Characters character in query)
                {
                    character.GameID = -1;
                    character.RoomX = 0;
                    character.RoomY = 0;
                    character.RoomZ = 0;
                    character.X = 0;
                    character.Y = 0;
                    character.Z = 0;
                    character.Angle = 0;
                }

                context.SubmitChanges();
            }

            // Free all of the portals
            {
                var query =
                    from portal in context.Portals
                    where portal.GameID == gameid
                    select portal;

                foreach (Portals portal in query)
                {
                    context.Portals.DeleteOnSubmit(portal);
                }

                context.SubmitChanges();
            }

            // Free all of the mobs
            {
                var query =
                    from mob in context.Mobs
                    where mob.GameID == gameid
                    select mob;

                foreach (Mobs mob in query)
                {
                    context.Mobs.DeleteOnSubmit(mob);
                }

                context.SubmitChanges();
            }

            // Free all of the mob spawners
            {
                var query =
                    from mobSpawner in context.MobSpawners
                    where mobSpawner.GameID == gameid
                    select mobSpawner;

                foreach (MobSpawners mobSpawner in query)
                {
                    context.MobSpawners.DeleteOnSubmit(mobSpawner);
                }

                context.SubmitChanges();
            }

            // TODO DeleteGame: Delete loot

            // Free all of the rooms
            {
                var query =
                    from room in context.Rooms
                    where room.GameID == gameid
                    select room;

                foreach (Rooms room in query)
                {
                    context.Rooms.DeleteOnSubmit(room);
                }

                context.SubmitChanges();
            }

            // Free all of the game_events associated from the game
            GameEventQueries.DeleteAllEventsForGame(context, gameid);

            // Finally, Free the game itself
            {
                var query =
                    from game in context.Games
                    where game.GameID == gameid
                    select game;

                foreach (Games game in query)
                {
                    context.Games.DeleteOnSubmit(game);
                }

                context.SubmitChanges();
            }
        }
예제 #20
0
        public void ParseMobSpawnTables(
            AsyncRPGDataContext db_context,
            string mob_spawn_tables_file_path)
        {
            MobTypeSet mobTypeSet = new MobTypeSet();

            // Load the mob spawn types from the DB
            mobTypeSet.Initialize(db_context);

            // Clear out any existing room templates
            db_context.ExecuteCommand("DELETE FROM mob_spawn_table_entries");
            db_context.ExecuteCommand("DELETE FROM mob_spawn_tables");

            // Read in the given JSON file and save it into the mob spawn table db table
            string jsonString = "";
            JSONMobSpawnTableSet jsonMobSpawnTableSet = null;

            // Read the spawn table file into a string
            using (StreamReader streamReader = new StreamReader(mob_spawn_tables_file_path))
            {
                jsonString = streamReader.ReadToEnd();

                if (jsonString.Length == 0)
                {
                    throw new Exception("MobSpawnTableParser: Mob spawn table file empty:" + mob_spawn_tables_file_path);
                }
            }

            // Parse the JSON into an object
            jsonMobSpawnTableSet = JsonMapper.ToObject<JSONMobSpawnTableSet>(jsonString);

            // Parse and verify each spawn table given
            {
                Dictionary<string, JSONMobSpawnTable> validMobSpawnTables = new Dictionary<string, JSONMobSpawnTable>();
                Dictionary<string, int> spawnTableNameToId = new Dictionary<string, int>();

                foreach (JSONMobSpawnTable jsonMobSpawnTable in jsonMobSpawnTableSet.mob_spawn_table_set)
                {
                    if (ValidateMobSpawnTable(jsonMobSpawnTable, validMobSpawnTables))
                    {
                        bool validTable = true;

                        // Verify each entry references either a valid spawn table or mob type
                        // and has a valid weight
                        foreach (JSONMobSpawnTableEntry jsonSpawnTableEntry in jsonMobSpawnTable.entries)
                        {
                            if (!ValidateMobSpawnTableEntry(
                                    jsonSpawnTableEntry,
                                    mobTypeSet,
                                    validMobSpawnTables))
                            {
                                validTable = false;
                            }
                        }

                        // If all the table entries look good, add the spawn table to the DB
                        if (validTable)
                        {
                            // Insert the spawn table first
                            MobSpawnTables dbMobSpawnTable = new MobSpawnTables
                            {
                                MobSpawnTableName = jsonMobSpawnTable.mob_spawn_table_name,
                            };

                            db_context.MobSpawnTables.InsertOnSubmit(dbMobSpawnTable);
                            db_context.SubmitChanges();

                            // Then insert all the entries associated with the table
                            foreach (JSONMobSpawnTableEntry jsonEntry in jsonMobSpawnTable.entries)
                            {
                                MobSpawnTableEntries dbMobSpawnTableEntry = null;

                                if (jsonEntry.mob_spawn_table_name.Length > 0)
                                {
                                    dbMobSpawnTableEntry = new MobSpawnTableEntries
                                    {
                                        MobSpawnTableID = dbMobSpawnTable.MobSpawnTableID,
                                        ReferenceID = spawnTableNameToId[jsonEntry.mob_spawn_table_name],
                                        ReferenceIsMobType = false,
                                        Weight = jsonEntry.weight
                                    };
                                }
                                else
                                {
                                    dbMobSpawnTableEntry = new MobSpawnTableEntries
                                    {
                                        MobSpawnTableID = dbMobSpawnTable.MobSpawnTableID,
                                        ReferenceID = mobTypeSet.GetMobTypeByName(jsonEntry.mob_type_name).ID,
                                        ReferenceIsMobType = true,
                                        Weight = jsonEntry.weight
                                    };
                                }

                                db_context.MobSpawnTableEntries.InsertOnSubmit(dbMobSpawnTableEntry);
                                db_context.SubmitChanges();
                            }

                            _logger.LogInfo("MobSpawnTableParser: Added Mob Spawn Table:");
                            _logger.LogInfo(jsonMobSpawnTable.mob_spawn_table_name);

                            // Keep track of each valid table added and what it's DB id is
                            validMobSpawnTables.Add(
                                jsonMobSpawnTable.mob_spawn_table_name,
                                jsonMobSpawnTable);
                            spawnTableNameToId.Add(
                                jsonMobSpawnTable.mob_spawn_table_name,
                                dbMobSpawnTable.MobSpawnTableID);
                        }
                        else
                        {
                            throw new Exception("MobSpawnTableParser: Problem(s) validating mob spawn table entries: " + jsonMobSpawnTable.mob_spawn_table_name);
                        }
                    }
                    else
                    {
                        throw new Exception("MobSpawnTableParser: Problem(s) validating mob spawn table: " + jsonMobSpawnTable.mob_spawn_table_name);
                    }
                }
            }
        }