Exemplo n.º 1
0
        /// <summary>
        /// ED_WriteGlobals
        /// </summary>
        public unsafe static void WriteGlobals(StreamWriter writer)
        {
            writer.WriteLine("{");
            for (int i = 0; i < _Progs.numglobaldefs; i++)
            {
                ddef_t  def  = _GlobalDefs[i];
                etype_t type = (etype_t)def.type;
                if ((def.type & DEF_SAVEGLOBAL) == 0)
                {
                    continue;
                }

                type &= (etype_t) ~DEF_SAVEGLOBAL;

                if (type != etype_t.ev_string && type != etype_t.ev_float && type != etype_t.ev_entity)
                {
                    continue;
                }

                writer.Write("\"");
                writer.Write(GetString(def.s_name));
                writer.Write("\" \"");
                writer.Write(UglyValueString(type, (eval_t *)Get(def.ofs)));
                writer.WriteLine("\"");
            }
            writer.WriteLine("}");
        }
Exemplo n.º 2
0
        /// <summary>
        /// PR_ValueString
        /// </summary>
        static unsafe string ValueString(etype_t type, void *val)
        {
            string result;

            type &= (etype_t) ~DEF_SAVEGLOBAL;

            switch (type)
            {
            case etype_t.ev_string:
                result = GetString(*(int *)val);
                break;

            case etype_t.ev_entity:
                result = "entity " + Server.NumForEdict(Server.ProgToEdict(*(int *)val));
                break;

            case etype_t.ev_function:
                dfunction_t f = _Functions[*(int *)val];
                result = GetString(f.s_name) + "()";
                break;

            case etype_t.ev_field:
                ddef_t def = FindField(*(int *)val);
                result = "." + GetString(def.s_name);
                break;

            case etype_t.ev_void:
                result = "void";
                break;

            case etype_t.ev_float:
                result = (*(float *)val).ToString("F1", CultureInfo.InvariantCulture.NumberFormat);
                break;

            case etype_t.ev_vector:
                result = String.Format(CultureInfo.InvariantCulture.NumberFormat,
                                       "{0,5:F1} {1,5:F1} {2,5:F1}", ((float *)val)[0], ((float *)val)[1], ((float *)val)[2]);
                break;

            case etype_t.ev_pointer:
                result = "pointer";
                break;

            default:
                result = "bad type " + type.ToString();
                break;
            }

            return(result);
        }
Exemplo n.º 3
0
    static unsafe string PR_ValueString(etype_t type, void *val)
    {
        string result;

        type &= (etype_t) ~q_shared.DEF_SAVEGLOBAL;

        switch (type)
        {
        case etype_t.ev_string:
            result = GetString(*(int *)val);
            break;

        case etype_t.ev_entity:
            result = "entity " + NUM_FOR_EDICT(PROG_TO_EDICT(*(int *)val));
            break;

        case etype_t.ev_function:
            dfunction_t f = pr_functions[*(int *)val];
            result = GetString(f.s_name) + "()";
            break;

        case etype_t.ev_field:
            ddef_t def = ED_FieldAtOfs(*(int *)val);
            result = "." + GetString(def.s_name);
            break;

        case etype_t.ev_void:
            result = "void";
            break;

        case etype_t.ev_float:
            result = (*(float *)val).ToString("F1", CultureInfo.InvariantCulture.NumberFormat);
            break;

        case etype_t.ev_vector:
            result = String.Format(CultureInfo.InvariantCulture.NumberFormat,
                                   "{0,5:F1} {1,5:F1} {2,5:F1}", ((float *)val)[0], ((float *)val)[1], ((float *)val)[2]);
            break;

        case etype_t.ev_pointer:
            result = "pointer";
            break;

        default:
            result = "bad type " + type.ToString();
            break;
        }

        return(result);
    }
Exemplo n.º 4
0
        /// <summary>
        /// PR_UglyValueString
        /// Returns a string describing *data in a type specific manner
        /// Easier to parse than PR_ValueString
        /// </summary>
        static unsafe string UglyValueString(etype_t type, eval_t *val)
        {
            type &= (etype_t) ~DEF_SAVEGLOBAL;
            string result;

            switch (type)
            {
            case etype_t.ev_string:
                result = GetString(val->_string);
                break;

            case etype_t.ev_entity:
                result = Server.NumForEdict(Server.ProgToEdict(val->edict)).ToString();
                break;

            case etype_t.ev_function:
                dfunction_t f = _Functions[val->function];
                result = GetString(f.s_name);
                break;

            case etype_t.ev_field:
                ddef_t def = FindField(val->_int);
                result = GetString(def.s_name);
                break;

            case etype_t.ev_void:
                result = "void";
                break;

            case etype_t.ev_float:
                result = val->_float.ToString("F6", CultureInfo.InvariantCulture.NumberFormat);
                break;

            case etype_t.ev_vector:
                result = String.Format(CultureInfo.InvariantCulture.NumberFormat,
                                       "{0:F6} {1:F6} {2:F6}", val->vector[0], val->vector[1], val->vector[2]);
                break;

            default:
                result = "bad type " + type.ToString();
                break;
            }

            return(result);
        }
Exemplo n.º 5
0
    static unsafe string PR_UglyValueString(etype_t type, eval_t *val)
    {
        type &= (etype_t) ~q_shared.DEF_SAVEGLOBAL;
        string result;

        switch (type)
        {
        case etype_t.ev_string:
            result = GetString(val->_string);
            break;

        case etype_t.ev_entity:
            result = NUM_FOR_EDICT(PROG_TO_EDICT(val->edict)).ToString();
            break;

        case etype_t.ev_function:
            dfunction_t f = pr_functions[val->function];
            result = GetString(f.s_name);
            break;

        case etype_t.ev_field:
            ddef_t def = ED_FieldAtOfs(val->_int);
            result = GetString(def.s_name);
            break;

        case etype_t.ev_void:
            result = "void";
            break;

        case etype_t.ev_float:
            result = val->_float.ToString("F6", CultureInfo.InvariantCulture.NumberFormat);
            break;

        case etype_t.ev_vector:
            result = String.Format(CultureInfo.InvariantCulture.NumberFormat,
                                   "{0:F6} {1:F6} {2:F6}", val->vector[0], val->vector[1], val->vector[2]);
            break;

        default:
            result = "bad type " + type.ToString();
            break;
        }

        return(result);
    }
Exemplo n.º 6
0
        /// <summary>
        /// PR_ValueString
        /// </summary>
        static unsafe string ValueString(etype_t type, void* val)
        {
            string result;
            type &= (etype_t)~DEF_SAVEGLOBAL;

            switch (type)
            {
                case etype_t.ev_string:
                    result = GetString(*(int*)val);
                    break;

                case etype_t.ev_entity:
                    result = "entity " + Server.NumForEdict(Server.ProgToEdict(*(int*)val));
                    break;

                case etype_t.ev_function:
                    dfunction_t f = _Functions[*(int*)val];
                    result = GetString(f.s_name) + "()";
                    break;

                case etype_t.ev_field:
                    ddef_t def = FindField(*(int*)val);
                    result = "." + GetString(def.s_name);
                    break;

                case etype_t.ev_void:
                    result = "void";
                    break;

                case etype_t.ev_float:
                    result = (*(float*)val).ToString("F1", CultureInfo.InvariantCulture.NumberFormat);
                    break;

                case etype_t.ev_vector:
                    result = String.Format(CultureInfo.InvariantCulture.NumberFormat,
                        "{0,5:F1} {1,5:F1} {2,5:F1}", ((float*)val)[0], ((float*)val)[1], ((float*)val)[2]);
                    break;

                case etype_t.ev_pointer:
                    result = "pointer";
                    break;

                default:
                    result = "bad type " + type.ToString();
                    break;
            }

            return result;
        }
Exemplo n.º 7
0
        /// <summary>
        /// PR_UglyValueString
        /// Returns a string describing *data in a type specific manner
        /// Easier to parse than PR_ValueString
        /// </summary>
        static unsafe string UglyValueString(etype_t type, eval_t* val)
        {
            type &= (etype_t)~DEF_SAVEGLOBAL;
            string result;

            switch (type)
            {
                case etype_t.ev_string:
                    result = GetString(val->_string);
                    break;

                case etype_t.ev_entity:
                    result = Server.NumForEdict(Server.ProgToEdict(val->edict)).ToString();
                    break;

                case etype_t.ev_function:
                    dfunction_t f = _Functions[val->function];
                    result = GetString(f.s_name);
                    break;

                case etype_t.ev_field:
                    ddef_t def = FindField(val->_int);
                    result = GetString(def.s_name);
                    break;

                case etype_t.ev_void:
                    result = "void";
                    break;

                case etype_t.ev_float:
                    result = val->_float.ToString("F6", CultureInfo.InvariantCulture.NumberFormat);
                    break;

                case etype_t.ev_vector:
                    result = String.Format(CultureInfo.InvariantCulture.NumberFormat,
                        "{0:F6} {1:F6} {2:F6}", val->vector[0], val->vector[1], val->vector[2]);
                    break;

                default:
                    result = "bad type " + type.ToString();
                    break;
            }

            return result;
        }