Ejemplo n.º 1
0
        public static Single VariableValue(String var_name)
        {
            cvar_t var = Cvar.FindVar(var_name);

            if (var == null)
            {
                return(0);
            }
            return(Lib.Atof(var.string_renamed));
        }
Ejemplo n.º 2
0
        public static cvar_t Get(String var_name, String var_value, Int32 flags)
        {
            cvar_t var;

            if ((flags & (CVAR_USERINFO | CVAR_SERVERINFO)) != 0)
            {
                if (!InfoValidate(var_name))
                {
                    Com.Printf("invalid info cvar name\\n");
                    return(null);
                }
            }

            var = Cvar.FindVar(var_name);
            if (var != null)
            {
                var.flags |= flags;
                return(var);
            }

            if (var_value == null)
            {
                return(null);
            }
            if ((flags & (CVAR_USERINFO | CVAR_SERVERINFO)) != 0)
            {
                if (!InfoValidate(var_value))
                {
                    Com.Printf("invalid info cvar value\\n");
                    return(null);
                }
            }

            var                = new cvar_t();
            var.name           = new String(var_name);
            var.string_renamed = new String(var_value);
            var.modified       = true;
            var.value          = Lib.Atof(var.string_renamed);
            var.next           = Globals.cvar_vars;
            Globals.cvar_vars  = var;
            var.flags          = flags;
            return(var);
        }
Ejemplo n.º 3
0
        public static cvar_t FullSet(String var_name, String value, Int32 flags)
        {
            cvar_t var;

            var = Cvar.FindVar(var_name);
            if (null == var)
            {
                return(Cvar.Get(var_name, value, flags));
            }

            var.modified = true;
            if ((var.flags & CVAR_USERINFO) != 0)
            {
                Globals.userinfo_modified = true;
            }
            var.string_renamed = value;
            var.value          = Lib.Atof(var.string_renamed);
            var.flags          = flags;
            return(var);
        }
Ejemplo n.º 4
0
        public static void GetLatchedVars( )
        {
            cvar_t var;

            for (var = Globals.cvar_vars; var != null; var = var.next)
            {
                if (var.latched_string == null || var.latched_string.Length == 0)
                {
                    continue;
                }
                var.string_renamed = var.latched_string;
                var.latched_string = null;
                var.value          = Lib.Atof(var.string_renamed);
                if (var.name.Equals("game"))
                {
                    FS.SetGamedir(var.string_renamed);
                    FS.ExecAutoexec();
                }
            }
        }
Ejemplo n.º 5
0
        public static void PredictMovement()
        {
            if (Globals.cls.state != Defines.ca_active)
            {
                return;
            }
            if (Globals.cl_paused.value != 0F)
            {
                return;
            }
            if (Globals.cl_predict.value == 0F || (Globals.cl.frame.playerstate.pmove.pm_flags & pmove_t.PMF_NO_PREDICTION) != 0)
            {
                for (int i = 0; i < 3; i++)
                {
                    Globals.cl.predicted_angles[i] = Globals.cl.viewangles[i] + Math3D.SHORT2ANGLE(Globals.cl.frame.playerstate.pmove.delta_angles[i]);
                }

                return;
            }

            int ack     = Globals.cls.netchan.incoming_acknowledged;
            int current = Globals.cls.netchan.outgoing_sequence;

            if (current - ack >= Defines.CMD_BACKUP)
            {
                if (Globals.cl_showmiss.value != 0F)
                {
                    Com.Printf("exceeded CMD_BACKUP\\n");
                }
                return;
            }

            pmove_t pm = new pmove_t();

            pm.trace               = new AnonymousTraceAdapter();
            pm.pointcontents       = new AnonymousPointContentsAdapter();
            PMove.pm_airaccelerate = Lib.Atof(Globals.cl.configstrings[Defines.CS_AIRACCEL]);
            pm.s.Set(Globals.cl.frame.playerstate.pmove);
            int       frame = 0;
            usercmd_t cmd;

            while (++ack < current)
            {
                frame = ack & (Defines.CMD_BACKUP - 1);
                cmd   = Globals.cl.cmds[frame];
                pm.cmd.Set(cmd);
                PMove.Pmove(pm);
                Math3D.VectorCopy(pm.s.origin, Globals.cl.predicted_origins[frame]);
            }

            int oldframe = (ack - 2) & (Defines.CMD_BACKUP - 1);
            int oldz     = Globals.cl.predicted_origins[oldframe][2];
            int step     = pm.s.origin[2] - oldz;

            if (step > 63 && step < 160 && (pm.s.pm_flags & pmove_t.PMF_ON_GROUND) != 0)
            {
                Globals.cl.predicted_step      = step * 0.125F;
                Globals.cl.predicted_step_time = (int)(Globals.cls.realtime - Globals.cls.frametime * 500);
            }

            Globals.cl.predicted_origin[0] = pm.s.origin[0] * 0.125F;
            Globals.cl.predicted_origin[1] = pm.s.origin[1] * 0.125F;
            Globals.cl.predicted_origin[2] = pm.s.origin[2] * 0.125F;
            Math3D.VectorCopy(pm.viewangles, Globals.cl.predicted_angles);
        }
Ejemplo n.º 6
0
        static cvar_t Set2(String var_name, String value, Boolean force)
        {
            cvar_t var = Cvar.FindVar(var_name);

            if (var == null)
            {
                return(Cvar.Get(var_name, value, 0));
            }

            if ((var.flags & (CVAR_USERINFO | CVAR_SERVERINFO)) != 0)
            {
                if (!InfoValidate(value))
                {
                    Com.Printf("invalid info cvar value\\n");
                    return(var);
                }
            }

            if (!force)
            {
                if ((var.flags & CVAR_NOSET) != 0)
                {
                    Com.Printf(var_name + " is write protected.\\n");
                    return(var);
                }

                if ((var.flags & CVAR_LATCH) != 0)
                {
                    if (var.latched_string != null)
                    {
                        if (value.Equals(var.latched_string))
                        {
                            return(var);
                        }
                        var.latched_string = null;
                    }
                    else
                    {
                        if (value.Equals(var.string_renamed))
                        {
                            return(var);
                        }
                    }

                    if (Globals.server_state != 0)
                    {
                        Com.Printf(var_name + " will be changed for next game.\\n");
                        var.latched_string = value;
                    }
                    else
                    {
                        var.string_renamed = value;
                        var.value          = Lib.Atof(var.string_renamed);
                        if (var.name.Equals("game"))
                        {
                            FS.SetGamedir(var.string_renamed);
                            FS.ExecAutoexec();
                        }
                    }

                    return(var);
                }
            }
            else
            {
                if (var.latched_string != null)
                {
                    var.latched_string = null;
                }
            }

            if (value.Equals(var.string_renamed))
            {
                return(var);
            }
            var.modified = true;
            if ((var.flags & CVAR_USERINFO) != 0)
            {
                Globals.userinfo_modified = true;
            }
            var.string_renamed = value;
            try
            {
                var.value = Single.Parse(var.string_renamed);
            }
            catch (Exception e)
            {
                var.value = 0F;
            }

            return(var);
        }
Ejemplo n.º 7
0
        public virtual bool Set(string key, string value)
        {
            if (key.Equals("lip"))
            {
                lip = Lib.Atoi(value);
                return(true);
            }

            if (key.Equals("distance"))
            {
                distance = Lib.Atoi(value);
                return(true);
            }

            if (key.Equals("height"))
            {
                height = Lib.Atoi(value);
                return(true);
            }

            if (key.Equals("noise"))
            {
                noise = GameSpawn.ED_NewString(value);
                return(true);
            }

            if (key.Equals("pausetime"))
            {
                pausetime = Lib.Atof(value);
                return(true);
            }

            if (key.Equals("item"))
            {
                item = GameSpawn.ED_NewString(value);
                return(true);
            }

            if (key.Equals("gravity"))
            {
                gravity = GameSpawn.ED_NewString(value);
                return(true);
            }

            if (key.Equals("sky"))
            {
                sky = GameSpawn.ED_NewString(value);
                return(true);
            }

            if (key.Equals("skyrotate"))
            {
                skyrotate = Lib.Atof(value);
                return(true);
            }

            if (key.Equals("skyaxis"))
            {
                skyaxis = Lib.Atov(value);
                return(true);
            }

            if (key.Equals("minyaw"))
            {
                minyaw = Lib.Atof(value);
                return(true);
            }

            if (key.Equals("maxyaw"))
            {
                maxyaw = Lib.Atof(value);
                return(true);
            }

            if (key.Equals("minpitch"))
            {
                minpitch = Lib.Atof(value);
                return(true);
            }

            if (key.Equals("maxpitch"))
            {
                maxpitch = Lib.Atof(value);
                return(true);
            }

            if (key.Equals("nextmap"))
            {
                nextmap = GameSpawn.ED_NewString(value);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 8
0
        public virtual Boolean SetField(String key, String value)
        {
            if (key.Equals("classname"))
            {
                classname = GameSpawn.ED_NewString(value);
                return(true);
            }

            if (key.Equals("model"))
            {
                model = GameSpawn.ED_NewString(value);
                return(true);
            }

            if (key.Equals("spawnflags"))
            {
                spawnflags = Lib.Atoi(value);
                return(true);
            }

            if (key.Equals("speed"))
            {
                speed = Lib.Atof(value);
                return(true);
            }

            if (key.Equals("accel"))
            {
                accel = Lib.Atof(value);
                return(true);
            }

            if (key.Equals("decel"))
            {
                decel = Lib.Atof(value);
                return(true);
            }

            if (key.Equals("target"))
            {
                target = GameSpawn.ED_NewString(value);
                return(true);
            }

            if (key.Equals("targetname"))
            {
                targetname = GameSpawn.ED_NewString(value);
                return(true);
            }

            if (key.Equals("pathtarget"))
            {
                pathtarget = GameSpawn.ED_NewString(value);
                return(true);
            }

            if (key.Equals("deathtarget"))
            {
                deathtarget = GameSpawn.ED_NewString(value);
                return(true);
            }

            if (key.Equals("killtarget"))
            {
                killtarget = GameSpawn.ED_NewString(value);
                return(true);
            }

            if (key.Equals("combattarget"))
            {
                combattarget = GameSpawn.ED_NewString(value);
                return(true);
            }

            if (key.Equals("message"))
            {
                message = GameSpawn.ED_NewString(value);
                return(true);
            }

            if (key.Equals("team"))
            {
                team = GameSpawn.ED_NewString(value);
                Com.Dprintln("Monster Team:" + team);
                return(true);
            }

            if (key.Equals("wait"))
            {
                wait = Lib.Atof(value);
                return(true);
            }

            if (key.Equals("delay"))
            {
                delay = Lib.Atof(value);
                return(true);
            }

            if (key.Equals("random"))
            {
                random = Lib.Atof(value);
                return(true);
            }

            if (key.Equals("move_origin"))
            {
                move_origin = Lib.Atov(value);
                return(true);
            }

            if (key.Equals("move_angles"))
            {
                move_angles = Lib.Atov(value);
                return(true);
            }

            if (key.Equals("style"))
            {
                style = Lib.Atoi(value);
                return(true);
            }

            if (key.Equals("count"))
            {
                count = Lib.Atoi(value);
                return(true);
            }

            if (key.Equals("health"))
            {
                health = Lib.Atoi(value);
                return(true);
            }

            if (key.Equals("sounds"))
            {
                sounds = Lib.Atoi(value);
                return(true);
            }

            if (key.Equals("light"))
            {
                return(true);
            }

            if (key.Equals("dmg"))
            {
                dmg = Lib.Atoi(value);
                return(true);
            }

            if (key.Equals("mass"))
            {
                mass = Lib.Atoi(value);
                return(true);
            }

            if (key.Equals("volume"))
            {
                volume = Lib.Atof(value);
                return(true);
            }

            if (key.Equals("attenuation"))
            {
                attenuation = Lib.Atof(value);
                return(true);
            }

            if (key.Equals("map"))
            {
                map = GameSpawn.ED_NewString(value);
                return(true);
            }

            if (key.Equals("origin"))
            {
                s.origin = Lib.Atov(value);
                return(true);
            }

            if (key.Equals("angles"))
            {
                s.angles = Lib.Atov(value);
                return(true);
            }

            if (key.Equals("angle"))
            {
                s.angles = new Single[] { 0, Lib.Atof(value), 0 };
                return(true);
            }

            if (key.Equals("item"))
            {
                GameBase.gi.Error("ent.set(\\\"item\\\") called.");
                return(true);
            }

            return(false);
        }