Beispiel #1
0
        public static Parser.Error finish_parse_r(Parser p)
        {
            Misc.r_info = new Monster_Race[Misc.z_info.r_max];
            for (Monster_Race r = p.priv as Monster_Race; r != null; r = r.Next) {
                if (r.ridx >= Misc.z_info.r_max)
                    continue;
                Misc.r_info[r.ridx] = r;
            }
            Eval.r_power(Misc.r_info);

            p.Destroy();
            return 0;
        }
Beispiel #2
0
 public static Parser.Error finish_parse_rb(Parser p)
 {
     Misc.rb_info = p.priv as Monster_Base;
     p.Destroy();
     return 0;
 }
Beispiel #3
0
 public static Parser.Error finish_parse_p(Parser p)
 {
     Misc.races = p.priv as Player_Race;
     p.Destroy();
     return 0;
 }
Beispiel #4
0
        public static Parser.Error finish_parse_pit(Parser p)
        {
            Pit_Profile pit;

            Misc.pit_info = new Pit_Profile[Misc.z_info.pit_max];
            for (pit = p.priv as Pit_Profile; pit != null; pit = pit.next) {
                if (pit.pit_idx >= Misc.z_info.pit_max)
                    continue;
                Misc.pit_info[pit.pit_idx] = pit;
            }

            //pit = p.priv;
            //while (pit) {
            //    n = pit.next;
            //    mem_free(pit);
            //    pit = n;
            //}

            p.Destroy();
            return 0;
        }
Beispiel #5
0
 public static Parser.Error finish_parse_c(Parser p)
 {
     Misc.classes = p.priv as Player_Class;
     p.Destroy();
     return 0;
 }
Beispiel #6
0
 public static Parser.Error finish_parse_names(Parser p)
 {
     int i;
     uint j;
     names_parse n = p.priv as names_parse;
     name nm;
     RandomName.name_sections = new string[(int)RandomName.randname_type.RANDNAME_NUM_TYPES][];
     for (i = 0; i < (int)RandomName.randname_type.RANDNAME_NUM_TYPES; i++) {
         RandomName.name_sections[i] = new string[(n.nnames[i] + 1)];
         for (nm = n.names[i], j = 0; nm != null && j < n.nnames[i]; nm = nm.next, j++) {
             RandomName.name_sections[i][j] = nm.str;
         }
         RandomName.name_sections[i][n.nnames[i]] = null;
         //while(n.names[i]) {
         //    nm = n.names[i].next;
         //    mem_free(n.names[i]);
         //    n.names[i] = nm;
         //}
     }
     //mem_free(n);
     p.Destroy();
     return 0;
 }
Beispiel #7
0
        public static Parser.Error finish_parse_k(Parser p)
        {
            Misc.k_info = new Object_Kind[Misc.z_info.k_max];
            for (Object_Kind k = p.priv as Object_Kind; k != null; k = k.next) {
                if (k.kidx >= Misc.z_info.k_max)
                    continue;
                Misc.k_info[k.kidx] = k;
            }

            Misc.objkinds = p.priv as Object_Kind;
            p.Destroy();
            return 0;
        }
Beispiel #8
0
 public static Parser.Error finish_parse_z(Parser p)
 {
     Misc.z_info = (Maxima)p.priv;
     p.Destroy();
     return 0;
 }
Beispiel #9
0
        public static Parser.Error finish_parse_h(Parser p)
        {
            History_Chart c;
            History_Entry e, prev, next;
            Misc.histories = p.priv as History_Chart;

            /* Go fix up the entry successor pointers. We can't compute them at
             * load-time since we may not have seen the successor history yet. Also,
             * we need to put the entries in the right order; the parser actually
             * stores them backwards, which is not desirable.
             */
            for (c = Misc.histories; c != null; c = c.next) {
                e = c.entries;
                prev = null;
                while (e != null) {
                    next = e.next;
                    e.next = prev;
                    prev = e;
                    e = next;
                }
                c.entries = prev;
                for (e = c.entries; e != null; e = e.next) {
                    if (e.isucc == 0)
                        continue;
                    e.succ = findchart(Misc.histories, (uint)e.isucc);
                    if (e.succ == null) {
                        return Parser.Error.GENERIC;
                    }
                }
            }

            p.Destroy();
            return 0;
        }
Beispiel #10
0
 public static Parser.Error finish_parse_hints(Parser p)
 {
     Misc.hints = p.priv as Hint;
     p.Destroy();
     return 0;
 }
Beispiel #11
0
 public static Parser.Error finish_parse_flavor(Parser p)
 {
     Misc.flavors = p.priv as Flavor;
     p.Destroy();
     return 0;
 }
Beispiel #12
0
        public static Parser.Error finish_parse_f(Parser p)
        {
            Feature f, n;

            Misc.f_info = new Feature[Misc.z_info.f_max];
            for (f = (Feature)p.priv; f != null ; f = f.next) {
                if (f.fidx >= Misc.z_info.f_max)
                    continue;
                Misc.f_info[f.fidx] = f;
            }

            //f = (Feature)p.priv;
            //while (f != null) {
            //    n = f.next;
            //    //free(f);
            //    f = n;
            //}

            p.Destroy();
            return 0;
        }
Beispiel #13
0
        public static Parser.Error finish_parse_e(Parser p)
        {
            Ego_Item e;

            Misc.e_info = new Ego_Item[Misc.z_info.e_max];
            for (e = p.priv as Ego_Item; e != null; e = e.next) {
                if (e.eidx >= Misc.z_info.e_max)
                    continue;
                Misc.e_info[e.eidx] =  e;
            }

            Slay.create_slay_cache(Misc.e_info);

            p.Destroy();
            return 0;
        }
Beispiel #14
0
        public static Parser.Error finish_parse_s(Parser p)
        {
            Spell s;
            Object_Kind k;

            Misc.s_info = new Spell[Misc.z_info.s_max];
            for (s = p.priv as Spell; s != null; s = s.next) {
                if (s.sidx >= Misc.z_info.s_max)
                    continue;
                Misc.s_info[s.sidx] = s;
                k = Object_Kind.objkind_get(s.tval, s.sval);
                if (k != null) {
                    Misc.s_info[s.sidx].next = k.spells;
                    k.spells = Misc.s_info[s.sidx];
                }
            }

            p.Destroy();
            return 0;
        }
Beispiel #15
0
        public static Parser.Error finish_parse_kb(Parser p)
        {
            kb_parsedata d = p.priv as kb_parsedata;

            Misc.assert(d != null);

            Misc.kb_info = new Object.Object_Base[Object.TVal.TV_MAX];

            for (Object.Object_Base kb = d.kb; kb != null; kb = kb.Next) {
                if (kb.tval >= Object.TVal.TV_MAX)
                    continue;
                Misc.kb_info[kb.tval] = kb;
            }

            p.Destroy();
            return Parser.Error.NONE;
        }
Beispiel #16
0
 public static Parser.Error finish_parse_v(Parser p)
 {
     Misc.vaults = p.priv as Vault;
     p.Destroy();
     return 0;
 }
Beispiel #17
0
        public static Parser.Error finish_parse_mp(Parser p)
        {
            Misc.pain_messages = new Monster_Pain[Misc.z_info.mp_max];
            for (Monster_Pain mp = p.priv as Monster_Pain; mp != null; mp = mp.Next) {
                if (mp.pain_idx >= Misc.z_info.mp_max)
                    continue;
                Misc.pain_messages[mp.pain_idx] = mp;
            }

            //C Cleanup
            /*mp = p.priv;
            while (mp) {
                n = mp.next;
                mem_free(mp);
                mp = n;
            }*/

            p.Destroy();
            return 0;
        }
Beispiel #18
0
        /*
         * Process the user pref file with the given name.
         * "quiet" means "don't complain about not finding the file.
         *
         * 'user' should be true if the pref file loaded is user-specific and not
         * a game default.
         *
         * Returns true if everything worked OK, false otherwise
         */
        public static bool process_pref_file(string name, bool quiet, bool user)
        {
            //Nick: Rewritten from scratch, since io is so different from C
            string path = Misc.path_build(Misc.ANGBAND_DIR_PREF, name);

            if (!File.Exists(path))
            {
                path = Misc.path_build(Misc.ANGBAND_DIR_USER, name);
                if (!File.Exists(path))
                {
                    if (!quiet)
                    {
                        Utilities.msg("Can not open " + path + ".");
                    }
                    return(false);
                }
            }

            FileStream f = null;

            try {
                f = File.OpenRead(path);
            } catch {
                if (!quiet)
                {
                    Utilities.msg("Can not open " + path + ".");
                }
                return(false);
            } finally {
                if (f != null)
                {
                    f.Close();                     //Just wanted to see if we could open it before proceeding...
                }
            }


            Parser p = init_parse_prefs(user);

            Parser.Error e = p.parse_file(path, false);

            finish_parse_prefs(p);
            p.Destroy();

            return(e == Parser.Error.NONE);

            //Below I wrote until I realized that there exists a Parser.ParseFile...
            //StreamReader sr = new StreamReader(f);


            //while (!sr.EndOfStream)
            //{
            //    line_no++;

            //    e = p.Parse(line);
            //    if (e != Parser.Error.NONE)
            //    {
            //        print_error(buf, p);
            //        break;
            //    }
            //}
            //finish_parse_prefs(p);

            //f.Close();
            //p.Destroy();

            ///* Result */
            //return e == Parser.Error.NONE;


            //======================Original below for comparison
            //char buf[1024];

            //ang_file *f;
            //Parser p;
            //int e = 0;

            //int line_no = 0;

            ///* Build the filename */
            //path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, name);
            //if (!file_exists(buf))
            //    path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);

            //f = file_open(buf, MODE_READ, -1);
            //if (!f)
            //{
            //    if (!quiet)
            //        msg("Cannot open '%s'.", buf);
            //}
            //else
            //{
            //    char line[1024];

            //    p = init_parse_prefs(user);
            //    while (file_getl(f, line, sizeof line))
            //    {
            //        line_no++;

            //        e = parser_parse(p, line);
            //        if (e != Parser.Error.NONE)
            //        {
            //            print_error(buf, p);
            //            break;
            //        }
            //    }
            //    finish_parse_prefs(p);

            //    file_close(f);
            //    mem_free(p.priv);
            //    parser_destroy(p);
            //}

            ///* Result */
            //return e == Parser.Error.NONE;
        }
Beispiel #19
0
        public static Parser.Error finish_parse_a(Parser p)
        {
            Misc.a_info = new Artifact[Misc.z_info.a_max];
            for (Artifact a = p.priv as Artifact; a != null; a = a.Next) {
                if (a.aidx >= Misc.z_info.a_max)
                    continue;

                Misc.a_info[a.aidx] = a;
            }

            //Old C cleanup stuff
            /*a = p.priv as Artifact;
            while (a) {
                n = a.next;
                mem_free(a);
                a = n;
            }*/

            p.Destroy();
            return 0;
        }