Ejemplo n.º 1
0
        static Object readptr(int address)
        {
            entvars_t entvars = server.sv.edicts[address / pr_edict_size].v;
            int       offset  = ((address % pr_edict_size) - 96) / 4;

            return(readentvar(entvars, offset));
        }
Ejemplo n.º 2
0
 static Object readentvar(entvars_t entvars, int offset)
 {
     if (offset > 104)
         return entvars.variables[offset - 105];
     switch (offset)
     {
         case 0: return entvars.modelindex;
         case 7: return entvars.ltime;
         case 8: return entvars.movetype;
         case 9: return entvars.solid;
         case 10: return entvars.origin[0];
         case 11: return entvars.origin[1];
         case 12: return entvars.origin[2];
         case 16: return entvars.velocity[0];
         case 17: return entvars.velocity[1];
         case 18: return entvars.velocity[2];
         case 19: return entvars.angles[0];
         case 20: return entvars.angles[1];
         case 21: return entvars.angles[2];
         case 28: return entvars.classname;
         case 29: return entvars.model;
         case 33: return entvars.mins[0];
         case 34: return entvars.mins[1];
         case 35: return entvars.mins[2];
         case 36: return entvars.maxs[0];
         case 37: return entvars.maxs[1];
         case 38: return entvars.maxs[2];
         case 39: return entvars.size[0];
         case 40: return entvars.size[1];
         case 41: return entvars.size[2];
         case 48: return entvars.health;
         case 49: return entvars.frags;
         case 50: return entvars.weapon;
         case 52: return entvars.weaponframe;
         case 53: return entvars.currentammo;
         case 54: return entvars.ammo_shells;
         case 55: return entvars.ammo_nails;
         case 56: return entvars.ammo_rockets;
         case 57: return entvars.ammo_cells;
         case 58: return entvars.items;
         case 59: return entvars.takedamage;
         case 61: return entvars.deadflag;
         case 62: return entvars.view_ofs[0];
         case 63: return entvars.view_ofs[1];
         case 64: return entvars.view_ofs[2];
         case 65: return entvars.button0;
         case 66: return entvars.button1;
         case 67: return entvars.button2;
         case 68: return entvars.impulse;
         case 70: return entvars.v_angle[0];
         case 71: return entvars.v_angle[1];
         case 72: return entvars.v_angle[2];
         case 74: return entvars.netname;
         case 76: return entvars.flags;
         case 78: return entvars.team;
         case 79: return entvars.max_health;
         case 81: return entvars.armortype;
         case 82: return entvars.armorvalue;
         case 83: return entvars.waterlevel;
         case 84: return entvars.watertype;
         case 89: return entvars.spawnflags;
         case 90: return entvars.target;
         case 91: return entvars.targetname;
         case 92: return entvars.dmg_take;
         case 93: return entvars.dmg_save;
         case 95: return entvars.owner;
         case 96: return entvars.movedir[0];
         case 97: return entvars.movedir[1];
         case 98: return entvars.movedir[2];
         case 100: return entvars.sounds;
         case 101: return entvars.noise;
     }
     return null;
 }
Ejemplo n.º 3
0
        static void writeptr(int address, Object value)
        {
            entvars_t entvars = server.sv.edicts[address / pr_edict_size].v;
            int       offset  = ((address % pr_edict_size) - 96) / 4;

            if (offset > 104)
            {
                entvars.variables[offset - 105] = value;
                return;
            }
            switch (offset)
            {
            case 0: entvars.modelindex = cast_float(value); break;

            case 8: entvars.movetype = cast_float(value); break;

            case 9: entvars.solid = cast_float(value); break;

            case 10: entvars.origin[0] = cast_float(value); break;

            case 11: entvars.origin[1] = cast_float(value); break;

            case 12: entvars.origin[2] = cast_float(value); break;

            case 19: entvars.angles[0] = cast_float(value); break;

            case 20: entvars.angles[1] = cast_float(value); break;

            case 21: entvars.angles[2] = cast_float(value); break;

            case 28: entvars.classname = cast_int(value); break;

            case 29: entvars.model = cast_int(value); break;

            case 30: entvars.frame = cast_float(value); break;

            case 32: entvars.effects = cast_float(value); break;

            case 39: entvars.size[0] = cast_float(value); break;

            case 40: entvars.size[1] = cast_float(value); break;

            case 41: entvars.size[2] = cast_float(value); break;

            case 42: entvars.touch = cast_int(value); break;

            case 43: entvars.use = cast_int(value); break;

            case 44: entvars.think = cast_int(value); break;

            case 45: entvars.blocked = cast_int(value); break;

            case 46: entvars.nextthink = cast_float(value); break;

            case 48: entvars.health = cast_float(value); break;

            case 50: entvars.weapon = cast_float(value); break;

            case 51: entvars.weaponmodel = cast_int(value); break;

            case 52: entvars.weaponframe = cast_float(value); break;

            case 53: entvars.currentammo = cast_float(value); break;

            case 54: entvars.ammo_shells = cast_float(value); break;

            case 55: entvars.ammo_nails = cast_float(value); break;

            case 56: entvars.ammo_rockets = cast_float(value); break;

            case 57: entvars.ammo_cells = cast_float(value); break;

            case 58: entvars.items = cast_float(value); break;

            case 59: entvars.takedamage = cast_float(value); break;

            case 61: entvars.deadflag = cast_float(value); break;

            case 62: entvars.view_ofs[0] = cast_float(value); break;

            case 63: entvars.view_ofs[1] = cast_float(value); break;

            case 64: entvars.view_ofs[2] = cast_float(value); break;

            case 69: entvars.fixangle = cast_float(value); break;

            case 76: entvars.flags = cast_float(value); break;

            case 79: entvars.max_health = cast_float(value); break;

            case 81: entvars.armortype = cast_float(value); break;

            case 82: entvars.armorvalue = cast_float(value); break;

            case 89: entvars.spawnflags = cast_float(value); break;

            case 95: entvars.owner = cast_int(value); break;

            case 96: entvars.movedir[0] = cast_float(value); break;

            case 97: entvars.movedir[1] = cast_float(value); break;

            case 98: entvars.movedir[2] = cast_float(value); break;

            case 100: entvars.sounds = cast_float(value); break;

            case 101: entvars.noise = cast_int(value); break;

            case 102: entvars.noise1 = cast_int(value); break;

            case 103: entvars.noise2 = cast_int(value); break;

            case 104: entvars.noise3 = cast_int(value); break;

            default: break;
            }
        }
Ejemplo n.º 4
0
        static Object readentvar(entvars_t entvars, int offset)
        {
            if (offset > 104)
            {
                return(entvars.variables[offset - 105]);
            }
            switch (offset)
            {
            case 0: return(entvars.modelindex);

            case 7: return(entvars.ltime);

            case 8: return(entvars.movetype);

            case 9: return(entvars.solid);

            case 10: return(entvars.origin[0]);

            case 11: return(entvars.origin[1]);

            case 12: return(entvars.origin[2]);

            case 16: return(entvars.velocity[0]);

            case 17: return(entvars.velocity[1]);

            case 18: return(entvars.velocity[2]);

            case 19: return(entvars.angles[0]);

            case 20: return(entvars.angles[1]);

            case 21: return(entvars.angles[2]);

            case 28: return(entvars.classname);

            case 29: return(entvars.model);

            case 33: return(entvars.mins[0]);

            case 34: return(entvars.mins[1]);

            case 35: return(entvars.mins[2]);

            case 36: return(entvars.maxs[0]);

            case 37: return(entvars.maxs[1]);

            case 38: return(entvars.maxs[2]);

            case 39: return(entvars.size[0]);

            case 40: return(entvars.size[1]);

            case 41: return(entvars.size[2]);

            case 48: return(entvars.health);

            case 49: return(entvars.frags);

            case 50: return(entvars.weapon);

            case 52: return(entvars.weaponframe);

            case 53: return(entvars.currentammo);

            case 54: return(entvars.ammo_shells);

            case 55: return(entvars.ammo_nails);

            case 56: return(entvars.ammo_rockets);

            case 57: return(entvars.ammo_cells);

            case 58: return(entvars.items);

            case 59: return(entvars.takedamage);

            case 61: return(entvars.deadflag);

            case 62: return(entvars.view_ofs[0]);

            case 63: return(entvars.view_ofs[1]);

            case 64: return(entvars.view_ofs[2]);

            case 65: return(entvars.button0);

            case 66: return(entvars.button1);

            case 67: return(entvars.button2);

            case 68: return(entvars.impulse);

            case 70: return(entvars.v_angle[0]);

            case 71: return(entvars.v_angle[1]);

            case 72: return(entvars.v_angle[2]);

            case 74: return(entvars.netname);

            case 76: return(entvars.flags);

            case 78: return(entvars.team);

            case 79: return(entvars.max_health);

            case 81: return(entvars.armortype);

            case 82: return(entvars.armorvalue);

            case 83: return(entvars.waterlevel);

            case 84: return(entvars.watertype);

            case 89: return(entvars.spawnflags);

            case 90: return(entvars.target);

            case 91: return(entvars.targetname);

            case 92: return(entvars.dmg_take);

            case 93: return(entvars.dmg_save);

            case 95: return(entvars.owner);

            case 96: return(entvars.movedir[0]);

            case 97: return(entvars.movedir[1]);

            case 98: return(entvars.movedir[2]);

            case 100: return(entvars.sounds);

            case 101: return(entvars.noise);
            }
            return(null);
        }
Ejemplo n.º 5
0
 static globalval readentvar(entvars_t entvars, int offset)
 {
     if (offset > 104)
         return entvars.variables[offset - 105];
     switch (offset)
     {
         case 0: return entvars.modelindex;
         case 1: return entvars.absmin[0];
         case 2: return entvars.absmin[1];
         case 3: return entvars.absmin[2];
         case 4: return entvars.absmax[0];
         case 5: return entvars.absmax[1];
         case 6: return entvars.absmax[2];
         case 7: return entvars.ltime;
         case 8: return entvars.movetype;
         case 9: return entvars.solid;
         case 10: return entvars.origin[0];
         case 11: return entvars.origin[1];
         case 12: return entvars.origin[2];
         case 13: return entvars.oldorigin[0];
         case 14: return entvars.oldorigin[1];
         case 15: return entvars.oldorigin[2];
         case 16: return entvars.velocity[0];
         case 17: return entvars.velocity[1];
         case 18: return entvars.velocity[2];
         case 19: return entvars.angles[0];
         case 20: return entvars.angles[1];
         case 21: return entvars.angles[2];
         case 22: return entvars.avelocity[0];
         case 23: return entvars.avelocity[1];
         case 24: return entvars.avelocity[2];
         case 25: return entvars.punchangle[0];
         case 26: return entvars.punchangle[1];
         case 27: return entvars.punchangle[2];
         case 28: return entvars.classname;
         case 29: return entvars.model;
         case 30: return entvars.frame;
         case 31: return entvars.skin;
         case 32: return entvars.effects;
         case 33: return entvars.mins[0];
         case 34: return entvars.mins[1];
         case 35: return entvars.mins[2];
         case 36: return entvars.maxs[0];
         case 37: return entvars.maxs[1];
         case 38: return entvars.maxs[2];
         case 39: return entvars.size[0];
         case 40: return entvars.size[1];
         case 41: return entvars.size[2];
         case 42: return entvars.touch;
         case 43: return entvars.use;
         case 44: return entvars.think;
         case 45: return entvars.blocked;
         case 46: return entvars.nextthink;
         case 47: return entvars.groundentity;
         case 48: return entvars.health;
         case 49: return entvars.frags;
         case 50: return entvars.weapon;
         case 51: return entvars.weaponmodel;
         case 52: return entvars.weaponframe;
         case 53: return entvars.currentammo;
         case 54: return entvars.ammo_shells;
         case 55: return entvars.ammo_nails;
         case 56: return entvars.ammo_rockets;
         case 57: return entvars.ammo_cells;
         case 58: return entvars.items;
         case 59: return entvars.takedamage;
         case 60: return entvars.chain;
         case 61: return entvars.deadflag;
         case 62: return entvars.view_ofs[0];
         case 63: return entvars.view_ofs[1];
         case 64: return entvars.view_ofs[2];
         case 65: return entvars.button0;
         case 66: return entvars.button1;
         case 67: return entvars.button2;
         case 68: return entvars.impulse;
         case 69: return entvars.fixangle;
         case 70: return entvars.v_angle[0];
         case 71: return entvars.v_angle[1];
         case 72: return entvars.v_angle[2];
         case 73: return entvars.idealpitch;
         case 74: return entvars.netname;
         case 75: return entvars.enemy;
         case 76: return entvars.flags;
         case 77: return entvars.colormap;
         case 78: return entvars.team;
         case 79: return entvars.max_health;
         case 80: return entvars.teleport_time;
         case 81: return entvars.armortype;
         case 82: return entvars.armorvalue;
         case 83: return entvars.waterlevel;
         case 84: return entvars.watertype;
         case 85: return entvars.ideal_yaw;
         case 86: return entvars.yaw_speed;
         case 87: return entvars.aiment;
         case 88: return entvars.goalentity;
         case 89: return entvars.spawnflags;
         case 90: return entvars.target;
         case 91: return entvars.targetname;
         case 92: return entvars.dmg_take;
         case 93: return entvars.dmg_save;
         case 94: return entvars.dmg_inflictor;
         case 95: return entvars.owner;
         case 96: return entvars.movedir[0];
         case 97: return entvars.movedir[1];
         case 98: return entvars.movedir[2];
         case 99: return entvars.message;
         case 100: return entvars.sounds;
         case 101: return entvars.noise;
         case 102: return entvars.noise1;
         case 103: return entvars.noise2;
         case 104: return entvars.noise3;
     }
     Debug.WriteLine("cant read offset " + offset);
     return null;
 }
Ejemplo n.º 6
0
        /*
        =============
        ED_ParseEval

        Can parse either fields or globals
        returns false if error
        =============
        */
        public static bool ED_ParseEpair(entvars_t @base, ddef_t key, string keyname, string s)
        {
            int i;
            /*ddef_t	*def;
            char	*v, *w;*/
            FieldInfo d;
            //dfunction_t	*func;
            globalval[] variables = null;
            double[] values = new double[3] {0, 0, 0};

            //d = (void *)((int *)base + key->ofs);
            d = typeof(entvars_t).GetField(keyname, BindingFlags.Public | BindingFlags.Instance);
            if (d == null)
                variables = ((entvars_t)@base).variables;

            switch ((etype_t)(key.type & ~DEF_SAVEGLOBAL))
            {
                case etype_t.ev_string:
                    if (d != null) d.SetValue(@base, getStringIndex(ED_NewString(s)) - prog.stringPoolOffset);
                    else variables[key.ofs - 105] = getStringIndex(ED_NewString(s)) - prog.stringPoolOffset;
                    break;

                case etype_t.ev_float:
                    if (d != null) d.SetValue(@base, common.Q_atof(s));
                    else variables[key.ofs - 105] = common.Q_atof(s);
                    break;

                case etype_t.ev_vector:
                    int w = 0;
                    int v = 0;
                    for (i = 0; i < 3; i++)
                    {
                        while (v < s.Length && s[v] != ' ') v++;

                        values[i] = common.Q_atof(s.Substring(w, v - w));
                        w = v = v + 1;
                    }
                    if (d != null) d.SetValue(@base, values);
                    else
                    {
                        for (i = 0; i < 3; i++) variables[key.ofs - 105 + i] = values[i];
                    }
                    break;

                case etype_t.ev_entity:
                    throw new NotImplementedException();
                    //*(int *)d = EDICT_TO_PROG(EDICT_NUM(atoi (s)));
                    break;

                case etype_t.ev_field:
                    throw new NotImplementedException();
                    //def = ED_FindField (s);
                    //if (!def)
                    //{
                    //    Con_Printf ("Can't find field %s\n", s);
                    //    return false;
                    //}
                    //*(int *)d = G_INT(def->ofs);
                    break;

                case etype_t.ev_function:
                    throw new NotImplementedException();
                    //func = ED_FindFunction (s);
                    //if (!func)
                    //{
                    //    Con_Printf ("Can't find function %s\n", s);
                    //    return false;
                    //}
                    //*(func_t *)d = func - pr_functions;
                    break;

                default:
                    sys_linux.Sys_Error("ERROR");
                    break;
            }
            return true;
        }