Пример #1
0
        /// <summary>
        /// ED_Print
        /// For debugging
        /// </summary>
        public unsafe static void Print(edict_t ed)
        {
            if (ed.free)
            {
                Con.Print("FREE\n");
                return;
            }

            Con.Print("\nEDICT {0}:\n", Server.NumForEdict(ed));
            for (int i = 1; i < _Progs.numfielddefs; i++)
            {
                ddef_t d    = _FieldDefs[i];
                string name = GetString(d.s_name);

                if (name.Length > 2 && name[name.Length - 2] == '_')
                {
                    continue; // skip _x, _y, _z vars
                }
                int type = d.type & ~DEF_SAVEGLOBAL;
                int offset;
                if (ed.IsV(d.ofs, out offset))
                {
                    fixed(void *ptr = &ed.v)
                    {
                        int *v = (int *)ptr + offset;

                        if (IsEmptyField(type, v))
                        {
                            continue;
                        }

                        Con.Print("{0,15} ", name);
                        Con.Print("{0}\n", ValueString((etype_t)d.type, (void *)v));
                    }
                }
                else
                {
                    fixed(void *ptr = ed.fields)
                    {
                        int *v = (int *)ptr + offset;

                        if (IsEmptyField(type, v))
                        {
                            continue;
                        }

                        Con.Print("{0,15} ", name);
                        Con.Print("{0}\n", ValueString((etype_t)d.type, (void *)v));
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// ED_Write
        /// </summary>
        public unsafe static void WriteEdict(StreamWriter writer, edict_t ed)
        {
            writer.WriteLine("{");

            if (ed.free)
            {
                writer.WriteLine("}");
                return;
            }

            for (int i = 1; i < _Progs.numfielddefs; i++)
            {
                ddef_t d    = _FieldDefs[i];
                string name = GetString(d.s_name);
                if (name != null && name.Length > 2 && name[name.Length - 2] == '_') // [strlen(name) - 2] == '_')
                {
                    continue;                                                        // skip _x, _y, _z vars
                }
                int type = d.type & ~DEF_SAVEGLOBAL;
                int offset1;
                if (ed.IsV(d.ofs, out offset1))
                {
                    fixed(void *ptr = &ed.v)
                    {
                        int *v = (int *)ptr + offset1;

                        if (IsEmptyField(type, v))
                        {
                            continue;
                        }

                        writer.WriteLine("\"{0}\" \"{1}\"", name, UglyValueString((etype_t)d.type, (eval_t *)v));
                    }
                }
                else
                {
                    fixed(void *ptr = ed.fields)
                    {
                        int *v = (int *)ptr + offset1;

                        if (IsEmptyField(type, v))
                        {
                            continue;
                        }

                        writer.WriteLine("\"{0}\" \"{1}\"", name, UglyValueString((etype_t)d.type, (eval_t *)v));
                    }
                }
            }

            writer.WriteLine("}");
        }
Пример #3
0
        /// <summary>
        /// Since memory block containing original edict_t plus additional data
        /// is split into two fiels - edict_t.v and edict_t.fields we must check key.ofs
        /// to choose between thistwo parts.
        /// Warning: Key offset is in integers not bytes!
        /// </summary>
        static unsafe bool ParsePair(edict_t ent, ddef_t key, string s)
        {
            int offset1;

            if (ent.IsV(key.ofs, out offset1))
            {
                fixed(entvars_t *ptr = &ent.v)
                {
                    return(ParsePair((int *)ptr + offset1, key, s));
                }
            }
            else
                fixed(float *ptr = ent.fields)
                {
                    return(ParsePair(ptr + offset1, key, s));
                }
        }