Exemple #1
0
        public static void wr_monsters()
        {
            int i;
            int j;

            if (Misc.p_ptr.is_dead)
            {
                return;
            }

            /* Total monsters */
            wr_u16b((ushort)Cave.cave_monster_max(Cave.cave));

            /* Dump the monsters */
            for (i = 1; i < Cave.cave_monster_max(Cave.cave); i++)
            {
                byte unaware = 0;

                Monster.Monster m_ptr = Cave.cave_monster(Cave.cave, i);

                wr_s16b(m_ptr.r_idx);
                wr_byte(m_ptr.fy);
                wr_byte(m_ptr.fx);
                wr_s16b(m_ptr.hp);
                wr_s16b(m_ptr.maxhp);
                wr_byte(m_ptr.mspeed);
                wr_byte(m_ptr.energy);
                wr_byte((byte)Misc.MON_TMD.MAX);

                for (j = 0; j < (byte)Misc.MON_TMD.MAX; j++)
                {
                    wr_s16b(m_ptr.m_timed[j]);
                }

                if (m_ptr.unaware)
                {
                    unaware |= 0x01;
                }
                wr_byte(unaware);

                for (j = 0; j < Object.Object_Flag.BYTES && j < Object.Object_Flag.SIZE; j++)
                {
                    wr_byte(m_ptr.known_pflags[j]);
                }
                if (j < Object.Object_Flag.BYTES)
                {
                    Savefile.pad_bytes(Object.Object_Flag.BYTES - j);
                }

                wr_byte(0);
            }
        }
Exemple #2
0
        /*
         * Save the game
         */
        public static void save_game()
        {
            /* Disturb the player */
            Cave.disturb(Misc.p_ptr, 1, 0);

            /* Clear messages */
            Utilities.message_flush();

            /* Handle stuff */
            Misc.p_ptr.handle_stuff();

            /* Message */
            Utilities.prt("Saving game...", 0, 0);

            /* Refresh */
            Term.fresh();

            /* The player is not dead */
            Misc.p_ptr.died_from = "(saved)";

            /* Forbid suspend */
            Signals.ignore_tstp();

            /* Save the player */
            if (Savefile.savefile_save(savefile))
            {
                Utilities.prt("Saving game... done.", 0, 0);
            }
            else
            {
                Utilities.prt("Saving game... failed!", 0, 0);
            }

            /* Allow suspend again */
            Signals.handle_tstp();

            /* Refresh */
            Term.fresh();

            /* Note that the player is not dead */
            Misc.p_ptr.died_from = "(alive and well)";
        }
Exemple #3
0
        /*
         * Write an "item" record
         */
        static void wr_item(Object.Object o_ptr)
        {
            int i, j;

            wr_u16b(0xffff);
            wr_byte(Savefile.ITEM_VERSION);

            wr_s16b(0);

            /* Location */
            wr_byte(o_ptr.iy);
            wr_byte(o_ptr.ix);

            wr_byte(o_ptr.tval);
            wr_byte(o_ptr.sval);

            for (i = 0; i < Misc.MAX_PVALS; i++)
            {
                wr_s16b(o_ptr.pval[i]);
            }
            wr_byte(o_ptr.num_pvals);

            wr_byte(0);

            wr_byte(o_ptr.number);
            wr_s16b(o_ptr.weight);

            if (o_ptr.artifact != null)
            {
                wr_byte((byte)o_ptr.artifact.aidx);
            }
            else
            {
                wr_byte(0);
            }

            if (o_ptr.ego != null)
            {
                wr_byte((byte)o_ptr.ego.eidx);
            }
            else
            {
                wr_byte(0);
            }

            wr_s16b(o_ptr.timeout);

            wr_s16b(o_ptr.to_h);
            wr_s16b(o_ptr.to_d);
            wr_s16b(o_ptr.to_a);
            wr_s16b(o_ptr.ac);
            wr_byte(o_ptr.dd);
            wr_byte(o_ptr.ds);

            wr_u16b((ushort)o_ptr.ident);

            wr_byte(o_ptr.marked);

            wr_byte((byte)o_ptr.origin);
            wr_byte(o_ptr.origin_depth);
            wr_u16b((ushort)o_ptr.origin_xtra);

            for (i = 0; i < Object.Object_Flag.BYTES && i < Object.Object_Flag.SIZE; i++)
            {
                wr_byte(o_ptr.flags[i]);
            }
            if (i < Object.Object_Flag.BYTES)
            {
                Savefile.pad_bytes(Object.Object_Flag.BYTES - i);
            }

            for (i = 0; i < Object.Object_Flag.BYTES && i < Object.Object_Flag.SIZE; i++)
            {
                wr_byte(o_ptr.known_flags[i]);
            }
            if (i < Object.Object_Flag.BYTES)
            {
                Savefile.pad_bytes(Object.Object_Flag.BYTES - i);
            }

            for (j = 0; j < Misc.MAX_PVALS; j++)
            {
                for (i = 0; i < Object.Object_Flag.BYTES && i < Object.Object_Flag.SIZE; i++)
                {
                    wr_byte(o_ptr.pval_flags[j][i]);
                }
                if (i < Object.Object_Flag.BYTES)
                {
                    Savefile.pad_bytes(Object.Object_Flag.BYTES - i);
                }
            }

            /* Held by monster index */
            wr_s16b(o_ptr.held_m_idx);

            wr_s16b(o_ptr.mimicking_m_idx);

            /* Save the inscription (if any) */
            if (o_ptr.note != null)
            {
                wr_string(o_ptr.note.ToString());
            }
            else
            {
                wr_string("");
            }
        }
Exemple #4
0
        /*
         * Dump the random artifacts
         */
        public static void wr_randarts()
        {
            int i, j, k;

            if (!Option.birth_randarts.value)
            {
                return;
            }

            wr_u16b(Misc.z_info.a_max);

            for (i = 0; i < Misc.z_info.a_max; i++)
            {
                Artifact a_ptr = Misc.a_info[i];

                wr_byte(a_ptr.tval);
                wr_byte(a_ptr.sval);
                for (j = 0; j < Misc.MAX_PVALS; j++)
                {
                    wr_s16b(a_ptr.pval[j]);
                }
                wr_byte(a_ptr.num_pvals);

                wr_s16b(a_ptr.to_h);
                wr_s16b(a_ptr.to_d);
                wr_s16b(a_ptr.to_a);
                wr_s16b(a_ptr.ac);

                wr_byte(a_ptr.dd);
                wr_byte(a_ptr.ds);

                wr_s16b(a_ptr.weight);

                wr_s32b(a_ptr.cost);

                for (j = 0; j < Object_Flag.BYTES && j < Object_Flag.SIZE; j++)
                {
                    wr_byte(a_ptr.flags[j]);
                }
                if (j < Object_Flag.BYTES)
                {
                    Savefile.pad_bytes(Object_Flag.BYTES - j);
                }

                for (k = 0; k < Misc.MAX_PVALS; k++)
                {
                    for (j = 0; j < Object_Flag.BYTES && j < Object_Flag.SIZE; j++)
                    {
                        wr_byte(a_ptr.pval_flags[k][j]);
                    }
                    if (j < Object_Flag.BYTES)
                    {
                        Savefile.pad_bytes(Object_Flag.BYTES - j);
                    }
                }

                wr_byte(a_ptr.level);
                wr_byte(a_ptr.rarity);
                wr_byte(a_ptr.alloc_prob);
                wr_byte(a_ptr.alloc_min);
                wr_byte(a_ptr.alloc_max);

                wr_u16b((ushort)a_ptr.effect.value);
                wr_u16b((ushort)a_ptr.time.Base);
                wr_u16b((ushort)a_ptr.time.dice);
                wr_u16b((ushort)a_ptr.time.sides);
            }
        }
Exemple #5
0
 public static void wr_byte(bool val)
 {
     Savefile.BufferAddBytes(new byte[] { (byte)(val ? 0 : 1) });
 }
Exemple #6
0
 public static void wr_byte(byte val)
 {
     Savefile.BufferAddBytes(new byte[] { val });
 }
Exemple #7
0
 private static void wr_s32b(Int32 val)
 {
     Savefile.BufferAddBytes(BitConverter.GetBytes(val));
 }
Exemple #8
0
        public static void wr_monster_memory()
        {
            int i;
            int r_idx;

            wr_u16b(Misc.z_info.r_max);
            for (r_idx = 0; r_idx < Misc.z_info.r_max; r_idx++)
            {
                Monster_Race r_ptr = Misc.r_info[r_idx];
                Monster_Lore l_ptr = Misc.l_list[r_idx];

                if (r_ptr == null)
                {
                    r_ptr = new Monster_Race();
                }

                if (l_ptr == null)
                {
                    l_ptr = new Monster_Lore();
                }

                /* Count sights/deaths/kills */
                wr_s16b(l_ptr.sights);
                wr_s16b(l_ptr.deaths);
                wr_s16b(l_ptr.pkills);
                wr_s16b(l_ptr.tkills);

                /* Count wakes and ignores */
                wr_byte(l_ptr.wake);
                wr_byte(l_ptr.ignore);

                /* Count drops */
                wr_byte(l_ptr.drop_gold);
                wr_byte(l_ptr.drop_item);

                /* Count spells */
                wr_byte(l_ptr.cast_innate);
                wr_byte(l_ptr.cast_spell);

                /* Count blows of each type */
                for (i = 0; i < Monster_Blow.MONSTER_BLOW_MAX; i++)
                {
                    wr_byte(l_ptr.blows[i]);
                }

                /* Memorize flags */
                for (i = 0; i < Monster_Flag.BYTES && i < Monster_Flag.SIZE; i++)
                {
                    wr_byte(l_ptr.flags.data[i]);
                }
                if (i < Monster_Flag.BYTES)
                {
                    Savefile.pad_bytes(Monster_Flag.BYTES - i);
                }

                for (i = 0; i < Monster_Flag.BYTES && i < Monster_Spell_Flag.SIZE; i++)
                {
                    wr_byte(l_ptr.spell_flags[i]);
                }
                if (i < Monster_Flag.BYTES)
                {
                    Savefile.pad_bytes(Monster_Flag.BYTES - i);
                }

                /* Monster limit per level */
                wr_byte(r_ptr.max_num);

                /* XXX */
                wr_byte(0);
                wr_byte(0);
                wr_byte(0);
            }
        }
Exemple #9
0
 private static void wr_u16b(UInt16 val)
 {
     Savefile.BufferAddBytes(BitConverter.GetBytes(val));
 }