public bool room_type_match(string t1, Room.Room_Type t2)
        {
            if (String.Compare(t1, "Gorehound Kennels") == 0 && t2 == Room.Room_Type.GHound_Kennel)
                return true;
            else if(String.Compare(t1, "Library") == 0 && t2 == Room.Room_Type.Library)
                return true;
            else if(String.Compare(t1, "Darkroom") == 0 && t2 == Room.Room_Type.DarkRoom)
                return true;
            else if(String.Compare(t1, "Corpse Storage") == 0 && t2 == Room.Room_Type.CorpseStorage)
                return true;
            else if(String.Compare(t1, "Sewer") == 0 && t2 == Room.Room_Type.SewerRoom)
                return true;
            else if(String.Compare(t1, "Rubble Room") == 0 && t2 == Room.Room_Type.Destroyed)
                return true;
            else if(String.Compare(t1, "Knight Armory") == 0 && t2 == Room.Room_Type.KnightArmory)
                return true;
            else if(String.Compare(t1, "Sewer Shaft") == 0 && t2 == Room.Room_Type.SewerShaft)
                return true;
            else if(String.Compare(t1, "Jail") == 0 && t2 == Room.Room_Type.Jail)
                return true;
            else if(String.Compare(t1, "Mine Shaft") == 0 && t2 == Room.Room_Type.MineShaft)
                return true;

            return false;
        }
        private void parse_room_instructions(Cronkpit.CronkPit.Dungeon c_dungeon, RoomDC[] room_list, List<Room.Room_Type> roomTypes, 
                                                   Tile.Tile_Type generic_room_floor, bool allow_room_overlap)
        {
            List<RoomDC> valid_rooms = new List<RoomDC>();

            for (int i = 0; i < roomTypes.Count; i++)
            {
                switch (roomTypes[i])
                {
                    case Room.Room_Type.SewerShaft:
                    case Room.Room_Type.MineShaft:
                        Room.Room_Type shaft_type = roomTypes[i];
                        bool shaft_placed = false;
                        while (!shaft_placed)
                        {
                            bool horizontal_shaft = false;
                            if (randGen.Next(2) == 0)
                                horizontal_shaft = true;

                            int xSize = 3;
                            int ySize = 3;
                            if (horizontal_shaft)
                                ySize = randGen.Next(10, 21);
                            else
                                xSize = randGen.Next(10, 21);

                            int nextX = randGen.Next(1, ((current_floorsize - 1) - xSize));
                            int nextY = randGen.Next(1, ((current_floorsize - 1) - ySize));

                            Room shaft_room = new Room(ySize, xSize, nextX, nextY, shaft_type, Tile.Tile_Type.StoneFloor, false, false);
                            if (room_position_OK(shaft_room))
                            {
                                shaft_placed = true;
                                roomlayout.Add(shaft_room);
                            }
                        }
                        break;
                    case Room.Room_Type.Destroyed:
                    case Room.Room_Type.DarkRoom:
                        Room.Room_Type r_typ = roomTypes[i];
                        bool rm_placed = false;
                        while (!rm_placed)
                        {
                            int next_room_height = randGen.Next(4, 10);
                            int next_room_width = randGen.Next(4, 10);
                            int next_room_startX = randGen.Next(1, ((current_floorsize - 1) - next_room_width));
                            int next_room_startY = randGen.Next(1, ((current_floorsize - 1) - next_room_height));

                            if (r_typ == Room.Room_Type.DarkRoom)
                            {
                                if (next_room_height > next_room_width)
                                    next_room_width = next_room_height;
                                else
                                    next_room_height = next_room_width;
                            }

                            //Create generic room templates
                            Room.Room_Type r_type = Room.Room_Type.Generic;
                            Tile.Tile_Type f_type = generic_room_floor;

                            if (r_typ == Room.Room_Type.Destroyed)
                                f_type = Tile.Tile_Type.Rubble_Floor;

                            //Assumes that the room will not have doors.
                            //Addendum: again, only occurs on normal type floors

                            bool door_room = false;
                            if (randGen.Next(4) == 0 || r_typ == Room.Room_Type.DarkRoom)
                                door_room = true;

                            bool room_columns = false;
                            if (r_type != Room.Room_Type.GenericCircular && randGen.Next(4) == 0) //Square room
                                room_columns = true; //25% chance to have columns in these rooms.
                            //Column pattern is picked at random when the room is initialized.

                            //Initialize the room.
                            Room rm = new Room(next_room_height,
                                                next_room_width,
                                                next_room_startX,
                                                next_room_startY,
                                                r_type,
                                                f_type,
                                                door_room,
                                                room_columns);

                            if (r_type == Room.Room_Type.DarkRoom)
                                rm.set_allowed_overlap(false);
                            //Since we're in the necropolis, set whether the room has corpses in it or not.
                            if (c_dungeon == CronkPit.Dungeon.Necropolis)
                            {
                                int corpse_chance = current_floordepth * 7;
                                rm.set_corpses(corpse_chance);
                                rm.set_allowed_overlap(allow_room_overlap);
                            }

                            //Now, if rooms are not allowed to overlap, we check to make sure there's no overlap
                            //with other rooms.
                            //first: we assume that the position of the room is valid.
                            rm_placed = room_position_OK(rm);

                            //If the room is good, we place it.
                            //Otherwise the loop starts again.
                            if (rm_placed)
                            {
                                roomlayout.Add(rm);
                                //We add a special event if the room is a darkroom.
                                if (r_typ == Room.Room_Type.DarkRoom)
                                    events.Add(new Fl_Special_Event(Fl_Special_Event.event_triggers.player_in_area, Fl_Special_Event.event_type.darkness_rad_2, 64000, (int)Math.Ceiling((double)(next_room_width/2)), false, rm.findCenter()));
                            }
                        }
                        break;
                    default:
                        if (valid_rooms.Count == 0)
                            for (int j = 0; j < room_list.Count(); j++)
                                if (room_type_match(room_list[j].RoomType, roomTypes[i]))
                                    valid_rooms.Add(room_list[j]);

                        if (valid_rooms.Count > 0)
                        {
                            bool room_placed = false;
                            int tries = 0;
                            int chosen_room = randGen.Next(valid_rooms.Count);
                            while (!room_placed)
                            {
                                if (tries > 9)
                                {
                                    chosen_room = randGen.Next(valid_rooms.Count);
                                    tries = 0;
                                }
                                Room next_room = new Room(valid_rooms[chosen_room], spawn_manager);

                                int nextX = randGen.Next(1, ((current_floorsize - 1) - next_room.roomWidth));
                                int nextY = randGen.Next(1, ((current_floorsize - 1) - next_room.roomHeight));

                                next_room.reset_starting_position(nextX, nextY);
                                room_placed = room_position_OK(next_room);

                                if (room_placed)
                                    roomlayout.Add(next_room);
                                tries++;
                            }
                        }
                        break;
                }

                if (roomTypes[i] != roomTypes[Math.Min(roomTypes.Count - 1, i + 1)])
                    valid_rooms.Clear();
            }
        }
        private bool room_position_OK(Room target_room)
        {
            int padding = 3;
            //Needed to change how this works. A room cannot be placed if it is A) Not allowed to overlap other rooms
            //Or B) If it's overlapping a room that is not allowed to overlap other rooms.
            //The previous methodology only applied to A.
            for (int i = 0; i < roomlayout.Count; i++)
                if (!roomlayout[i].is_allowed_overlap() || !target_room.is_allowed_overlap())
                {
                    Rectangle target_rect = new Rectangle(target_room.startXPos, target_room.startYPos,
                                                          target_room.roomWidth + padding,
                                                          target_room.roomHeight + padding);
                    Rectangle c_room_rect = new Rectangle(roomlayout[i].startXPos,
                                                          roomlayout[i].startYPos,
                                                          roomlayout[i].roomWidth + padding,
                                                          roomlayout[i].roomHeight + padding);
                    if(target_rect.Intersects(c_room_rect))
                        return false;
                }

            return true;
        }
        private void add_random_generic_rooms(Cronkpit.CronkPit.Dungeon c_dungeon, int predtermined_rooms, bool allow_room_overlap)
        {
            //Randomly generate generic rooms
            int number_of_rooms = 0;
            Tile.Tile_Type generic_room_floor = Tile.Tile_Type.Void;

            switch(fl_type)
            {
                case Floor.floor_type.Normal:
                    number_of_rooms = 5 + randGen.Next(4) - predtermined_rooms;
                    generic_room_floor = Tile.Tile_Type.StoneFloor;
                    break;
                case Floor.floor_type.Cavern:
                    number_of_rooms = 3 + randGen.Next(2);
                    generic_room_floor = Tile.Tile_Type.Natural_Stone_Floor;
                    break;
            }

            //50% chance to make a dirt room on floor 0. This decreases by 2% per floor
            //Until it bottoms out at 20%. This occurs on floor 15 and lower.
            int dirt_threshold = Math.Max((50 - ((current_floordepth - 1) * 2)), 20);
            for (int i = 0; i < number_of_rooms; i++)
            {
                bool room_placed = false;
                while (!room_placed)
                {
                    //Create new room dimensions
                    int next_room_height = randGen.Next(4, 10);
                    int next_room_width = randGen.Next(4, 10);
                    int next_room_startX = randGen.Next(1, ((current_floorsize - 1) - next_room_width));
                    int next_room_startY = randGen.Next(1, ((current_floorsize - 1) - next_room_height));

                    int lower_room_x_edge = next_room_startX + next_room_width;
                    int lower_room_y_edge = next_room_startY + next_room_height;
                    int upper_room_x_edge = next_room_startX - next_room_width;
                    int upper_room_y_edge = next_room_startY - next_room_height;

                    //Create generic room templates
                    Room.Room_Type r_type = Room.Room_Type.Generic;
                    Tile.Tile_Type f_type = generic_room_floor;

                    //Dirt rooms are kept towards the outer edges of the dungeon.
                    //See above for % chance of creating a dirt room. The only thing that
                    //differs is the floor type + wall type.
                    int dirt_dice_roll = randGen.Next(100);
                    if (dirt_dice_roll < dirt_threshold &&
                        (lower_room_x_edge < 15 || upper_room_x_edge > 35 ||
                        lower_room_y_edge < 15 || upper_room_y_edge > 35))
                        f_type = Tile.Tile_Type.DirtFloor;

                    //If the room is square and the width is an odd number (so 3x3, 5x5, 7x7)
                    //It has a 66% chance of becoming a roughly circular shaped room.
                    //Addendum: only occurs on normal type floors
                    if (fl_type == Floor.floor_type.Normal)
                    {
                        if (next_room_height == next_room_width && next_room_width % 2 == 1)
                            if (randGen.Next(3) < 2)
                                r_type = Room.Room_Type.GenericCircular;
                    }

                    //Assumes that the room will not have doors.
                    //Addendum: again, only occurs on normal type floors
                    bool door_room = false;
                    if (fl_type == Floor.floor_type.Normal)
                    {
                        //If the room type is _not_ circular, there is a 25% chance of there being doors
                        if (r_type != Room.Room_Type.GenericCircular && randGen.Next(4) == 0)
                            door_room = true;
                    }

                    bool room_columns = false;
                    if (r_type != Room.Room_Type.GenericCircular && randGen.Next(10) < 6) //Square room
                        room_columns = true; //60% chance to have columns
                    //Column pattern is picked at random when the room is initialized.

                    //Initialize the room.
                    Room rm = new Room(next_room_height,
                                        next_room_width,
                                        next_room_startX,
                                        next_room_startY,
                                        r_type,
                                        f_type,
                                        door_room,
                                        room_columns);
                    //Since we're in the necropolis, set whether the room has corpses in it or not.
                    if (c_dungeon == CronkPit.Dungeon.Necropolis)
                    {
                        int corpse_chance = current_floordepth * 5;
                        rm.set_corpses(corpse_chance);
                        rm.set_allowed_overlap(allow_room_overlap);
                    }

                    //Now, if rooms are not allowed to overlap, we check to make sure there's no overlap
                    //with other rooms.
                    //first: we assume that the position of the room is valid.
                    room_placed = room_position_OK(rm);

                    //If the room is good, we place it.
                    //Otherwise the loop starts again.
                    if (room_placed)
                        roomlayout.Add(rm);
                }
            }
        }