示例#1
0
        static bool LoadAreaFiles()
        {
            string listContents;

            try
            {
                listContents = Encoding.ASCII.GetString(File.ReadAllBytes(Path.Combine(areaPath, areaList)));
            }
            catch (Exception e)
            {
                log.Error(e.Message);
                return(false);
            }

            using (var sr = new StringReader(listContents))
            {
                for (;;)
                {
                    var curFile = sr.ReadLine().Trim();
                    if (string.IsNullOrWhiteSpace(curFile))
                    {
                        continue;
                    }
                    if (curFile.StartsWith("$"))
                    {
                        break;
                    }

                    if (curFile.StartsWith("-"))
                    {
                        // ??????
                        // fpArea = stdin;
                        continue;
                    }

                    log.Info($"loadding {curFile}");
                    string areaContents;
                    try
                    {
                        areaContents = Encoding.ASCII.GetString(File.ReadAllBytes(Path.Combine(areaPath, curFile)));
                    }
                    catch (Exception e)
                    {
                        log.Error(e.Message);
                        return(false);
                    }


                    using (var ar = new StringReader(areaContents))
                    {
                        AreaData lastArea = null;
                        for (;;)
                        {
                            var word = ar.ReadWord();
                            if (!word.StartsWith("#"))
                            {
                                return(false);
                            }

                            word = word.Substring(1);
                            if (word.StartsWith("$"))
                            {
                                break;
                            }

                            switch (word)
                            {
                            case "AREA":
                                lastArea = AreaData.Load(ar, curFile);
                                break;

                            case "HELPS":
                                HelpData.LoadFromArea(ar);
                                break;

                            case "MOBILES":
                                MobileDef.LoadFromArea(ar, lastArea);
                                break;

                            case "OBJECTS":
                                ObjectDef.LoadFromArea(ar, lastArea);
                                break;

                            case "RESETS":
                                ResetData.LoadFromArea(ar);
                                break;

                            case "ROOMS":
                                RoomDef.LoadFromArea(ar, lastArea);
                                break;

                            case "SHOPS":
                                ShopData.LoadFromArea(ar);
                                break;

                            case "SPECIALS":
                                SpecType.LoadFromArea(ar);
                                break;

                            // OLC
                            case "AREADATA":
                                lastArea = AreaData.NewLoad(ar, curFile);
                                break;

                            // OLC 1.1b
                            case "ROOMDATA":
                                RoomDef.NewLoadFromArea(ar, lastArea);
                                break;

                            default:
                                log.Error($"Boot_db: bad section name '{word}'.");
                                return(false);
                            }
                        }
                    }
                }

                return(true);
            }
        }