]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Predict conveyors
authorMario <zacjardine@y7mail.com>
Mon, 5 Jan 2015 08:56:19 +0000 (19:56 +1100)
committerMario <zacjardine@y7mail.com>
Mon, 5 Jan 2015 08:56:19 +0000 (19:56 +1100)
15 files changed:
qcsrc/client/Main.qc
qcsrc/client/autocvars.qh
qcsrc/client/main.qh
qcsrc/client/progs.src
qcsrc/common/constants.qh
qcsrc/common/physics.qc
qcsrc/common/physics.qh
qcsrc/common/stats.qh
qcsrc/dpdefs/csprogsdefs.qc
qcsrc/server/defs.qh
qcsrc/server/miscfunctions.qc
qcsrc/server/t_plats.qc
qcsrc/warpzonelib/common.qc
qcsrc/warpzonelib/common.qh
qcsrc/warpzonelib/util_server.qc

index 5985c34e22b4f0568a0ec11f3ce4d62c999445c5..aff71b806b3f0f51c5db53bb447f8359764e2786 100644 (file)
@@ -745,6 +745,7 @@ void Ent_ScoresInfo();
 void ent_func_ladder();
 void ent_trigger_push();
 void ent_target_push();
+void ent_conveyor();
 void CSQC_Ent_Update(float bIsNewEntity)
 {
        float t;
@@ -832,6 +833,7 @@ void CSQC_Ent_Update(float bIsNewEntity)
                case ENT_CLIENT_LADDER: ent_func_ladder(); break;
                case ENT_CLIENT_TRIGGER_PUSH: ent_trigger_push(); break;
                case ENT_CLIENT_TARGET_PUSH: ent_target_push(); break;
+               case ENT_CLIENT_CONVEYOR: ent_conveyor(); break;
 
                default:
                        //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
index f06c5bfb3bd0f66e6dbc25ad67f201587b50a7c0..adc587764aeb5bd88a0b6b760845658100b05770 100644 (file)
@@ -463,3 +463,4 @@ var vector autocvar_crosshair_rpc_color = '0.2 1.0 0.2';
 var float autocvar_crosshair_rpc_alpha = 1;
 var float autocvar_crosshair_rpc_size = 1;
 float autocvar_cl_nade_timer;
+float autocvar_speedmeter;
index c9aa2fb40f8a9e86b105dcf317edc9a49cd63f1d..ca211274b5b0fa244cf160dc6ac7009a9f80b19f 100644 (file)
@@ -148,3 +148,5 @@ entity entcs_receiver[255]; // 255 is the engine limit on maxclients
 float hud;
 float view_quality;
 float framecount;
+
+.float jumppadcount;
index 4fa79022936295edfc5b949176cccdd668de1aa8..e414576c364d7745a8820bb58aec0dfedd366442 100644 (file)
@@ -125,6 +125,7 @@ command/cl_cmd.qc
 ../server/mutators/mutator_multijump.qc
 ../server/t_halflife.qc
 ../server/t_jumppads.qc
+../server/t_plats.qc
 
 ../common/nades.qc
 ../common/buffs.qc
index 8392d1dadd158783a1533191f3c12925922e8abf..28cf97f5d7e5e5dfc0fc195fbefe6acedd8e9c4f 100644 (file)
@@ -103,6 +103,7 @@ const float ENT_CLIENT_VEHICLE = 60;
 const float ENT_CLIENT_LADDER = 61;
 const float ENT_CLIENT_TRIGGER_PUSH = 62;
 const float ENT_CLIENT_TARGET_PUSH = 63;
+const float ENT_CLIENT_CONVEYOR = 64;
 
 const float ENT_CLIENT_HEALING_ORB = 80;
 
index ad2e97944b15860a422d7622655bbba91ea06a0f..233e3c33d30e9fe70c86f7216ca767b8e83fcf9e 100644 (file)
@@ -513,21 +513,19 @@ float PlayerJump (void)
                }
        }
 
-#ifdef SVQC
-       if (!(self.lastflags & FL_ONGROUND))
+       if (!WAS_ONGROUND(self))
        {
-               if (autocvar_speedmeter)
+               if(autocvar_speedmeter)
                        dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
-               if (self.lastground < time - 0.3)
+               if(self.lastground < time - 0.3)
                {
-                       self.velocity_x *= (1 - autocvar_sv_friction_on_land);
-                       self.velocity_y *= (1 - autocvar_sv_friction_on_land);
+                       self.velocity_x *= (1 - PHYS_FRICTION_ONLAND);
+                       self.velocity_y *= (1 - PHYS_FRICTION_ONLAND);
                }
-               if (self.jumppadcount > 1)
+               if(self.jumppadcount > 1)
                        dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
                self.jumppadcount = 0;
        }
-#endif
 
        self.velocity_z += mjumpheight;
 
@@ -1572,18 +1570,16 @@ void SV_WalkMove ()
 #endif
 void PM_walk(float buttons_prev, float maxspd_mod)
 {
-#ifdef SVQC
-       if (!(self.lastflags & FL_ONGROUND))
+       if (!WAS_ONGROUND(self))
        {
                if (autocvar_speedmeter)
                        dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n"));
                if (self.lastground < time - 0.3)
-                       self.velocity *= (1 - autocvar_sv_friction_on_land);
+                       self.velocity *= (1 - PHYS_FRICTION_ONLAND);
                if (self.jumppadcount > 1)
                        dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n"));
                self.jumppadcount = 0;
        }
-#endif
        // walking
        makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0');
        vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x
@@ -1844,11 +1840,9 @@ void PM_Main()
        }
 #endif
 
-#ifdef SVQC
        // conveyors: first fix velocity
        if (self.conveyor.state)
                self.velocity -= self.conveyor.movedir;
-#endif
 
 #ifdef SVQC
        MUTATOR_CALLHOOK(PlayerPhysics);
@@ -1984,12 +1978,16 @@ void PM_Main()
        if (IS_ONGROUND(self))
                self.lastground = time;
 
-#ifdef SVQC
        // conveyors: then break velocity again
        if (self.conveyor.state)
                self.velocity += self.conveyor.movedir;
-#endif
+
+#ifdef SVQC
        self.lastflags = self.flags;
+#elif defined(CSQC)
+       self.lastflags = self.pmove_flags;
+#endif
+       
        self.lastclassname = self.classname;
 }
 
index 7a9bd3c5456e7f698ed7e86fba21323891dfb8ed..3ddb24486632fb1c5f6dd401440d8c99301a4099 100644 (file)
@@ -1,5 +1,7 @@
 // Client/server mappings
 
+.entity conveyor;
+
 #ifdef CSQC
 
        float player_multijump;
@@ -10,6 +12,7 @@
        #define PHYS_WORLD_ANGLES(s)                            input_angles
 
        #define PHYS_INPUT_TIMELENGTH                           input_timelength
+       #define PHYS_INPUT_FRAMETIME                            serverdeltatime
 
        #define PHYS_INPUT_MOVEVALUES(s)                        input_movevalues
 
@@ -45,6 +48,8 @@
        #define SET_ONGROUND(s)                                         s.pmove_flags |= PMF_ONGROUND
        #define UNSET_ONGROUND(s)                                       s.pmove_flags &= ~PMF_ONGROUND
 
+       #define WAS_ONGROUND(s)                                         !!(s.lastflags & PMF_ONGROUND)
+
        #define ITEMS(s)                                                        getstati(STAT_ITEMS, 0, 24)
 
        #define PHYS_AMMO_FUEL(s)                                       getstati(STAT_FUEL)
@@ -72,6 +77,7 @@
        #define PHYS_AIRSTRAFEACCELERATE                        getstatf(STAT_MOVEVARS_AIRSTRAFEACCELERATE)
        #define PHYS_ENTGRAVITY(s)                                      getstatf(STAT_MOVEVARS_ENTGRAVITY)
        #define PHYS_FRICTION                                           getstatf(STAT_MOVEVARS_FRICTION)
+       #define PHYS_FRICTION_ONLAND                            getstatf(STAT_MOVEVARS_FRICTION_ONLAND)
        #define PHYS_GRAVITY                                            getstatf(STAT_MOVEVARS_GRAVITY)
        #define PHYS_HIGHSPEED                                          getstatf(STAT_MOVEVARS_HIGHSPEED)
        #define PHYS_JUMPVELOCITY                                       getstatf(STAT_MOVEVARS_JUMPVELOCITY)
        #define PHYS_WORLD_ANGLES(s)                            s.angles
 
        #define PHYS_INPUT_TIMELENGTH                           frametime
+       #define PHYS_INPUT_FRAMETIME                            sys_frametime
 
        #define PHYS_INPUT_MOVEVALUES(s)                        s.movement
        // TODO: cache
        #define SET_ONGROUND(s)                                         s.flags |= FL_ONGROUND
        #define UNSET_ONGROUND(s)                                       s.flags &= ~FL_ONGROUND
 
+       #define WAS_ONGROUND(s)                                         !!((s).lastflags & FL_ONGROUND)
+
        #define ITEMS(s)                                                        s.items
 
        #define PHYS_AMMO_FUEL(s)                                       s.ammo_fuel
        #define PHYS_AIRSTRAFEACCELERATE                        autocvar_sv_airstrafeaccelerate
        #define PHYS_ENTGRAVITY(s)                                      s.gravity
        #define PHYS_FRICTION                                           autocvar_sv_friction
+       #define PHYS_FRICTION_ONLAND                            autocvar_sv_friction_on_land
        #define PHYS_GRAVITY                                            autocvar_sv_gravity
        #define PHYS_HIGHSPEED                                          autocvar_g_movement_highspeed
        #define PHYS_JUMPVELOCITY                                       autocvar_sv_jumpvelocity
index 9b383fa92e999f60dc660d37dbf54783be68bee5..ef4472d9f17b543414ae037219721671f652b6a8 100644 (file)
@@ -224,7 +224,7 @@ const float STAT_REVIVE_PROGRESS        = 106;
 // 189 empty?
 // 190 empty?
 // 191 empty?
-// 192 empty?
+const float STAT_MOVEVARS_FRICTION_ONLAND               = 192;
 const float STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS  = 193;
 const float STAT_MOVEVARS_JUMPSPEEDCAP_MAX              = 194;
 const float STAT_MOVEVARS_JUMPSPEEDCAP_MIN              = 195;
index 8f4ec8b414f34fc2a42177f15cda496f59aa1a9b..d7ae8c3bb78e6b4fb8c793b95bf5a92b17c4c225 100644 (file)
@@ -420,6 +420,7 @@ float( float a, ... ) min = #94;
 float( float b, ... ) max = #95;
 float(float minimum, float val, float maximum) bound = #96;
 float(float f, float f) pow = #97;
+entity(entity start, .entity fld, entity match) findentity = #98;
 entity(entity start, .float fld, float match) findfloat = #98;
 float(string s) checkextension = #99;
 // FrikaC and Telejano range #100-#199
index fd217f0ab4a2678153771306542debeb900609cc..870c61c75b6f5bc00747dc9a0510d0db163bd3c6 100644 (file)
@@ -584,8 +584,6 @@ void PlayerUseKey();
 typedef vector(entity player, entity spot, vector current) spawn_evalfunc_t;
 .spawn_evalfunc_t spawn_evalfunc;
 
-.entity conveyor;
-
 string modname;
 
 .float missile_flags;
index e6fda399e27eb0427e90a241964f623843a54feb..22fa4e3a435bc5718d81f8b4818c2f4b3291bc10 100644 (file)
@@ -77,8 +77,6 @@ float DistributeEvenly_GetRandomized(float weight)
     return f;
 }
 
-#define move_out_of_solid(e) WarpZoneLib_MoveOutOfSolid(e)
-
 const string STR_PLAYER = "player";
 const string STR_SPECTATOR = "spectator";
 const string STR_OBSERVER = "observer";
index 315abe152f50b2d9074b28d1e214fa8d1f199053..7bf3c70a8022189253ba90cce1756ecdabd0a2af 100644 (file)
@@ -1,3 +1,5 @@
+#ifdef SVQC
+
 .float dmgtime2;
 void generic_plat_blocked()
 {
@@ -2169,8 +2171,15 @@ void spawnfunc_func_vectormamamam()
        InitializeEntity(self, func_vectormamamam_findtarget, INITPRIO_FINDTARGET);
 }
 
+#endif
+
 void conveyor_think()
 {
+#ifdef CSQC
+       float dt = time - self.move_time;
+       self.move_time = time;
+       if(dt <= 0) { return; }
+#endif
        entity e;
 
        // set myself as current conveyor where possible
@@ -2181,7 +2190,11 @@ void conveyor_think()
        {
                for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5 + 1); e; e = e.chain)
                        if(!e.conveyor.state)
+#ifdef SVQC
                                if(isPushable(e))
+#elif defined(CSQC)
+                               if(e.isplayermodel)
+#endif
                                {
                                        vector emin = e.absmin;
                                        vector emax = e.absmax;
@@ -2197,12 +2210,19 @@ void conveyor_think()
 
                for(e = world; (e = findentity(e, conveyor, self)); )
                {
+#ifdef SVQC
                        if(IS_CLIENT(e)) // doing it via velocity has quite some advantages
                                continue; // done in SV_PlayerPhysics
+#elif defined(CSQC)
+                       if(e.isplayermodel)
+                               continue;
+#endif
 
-                       setorigin(e, e.origin + self.movedir * sys_frametime);
+                       setorigin(e, e.origin + self.movedir * PHYS_INPUT_FRAMETIME);
                        move_out_of_solid(e);
+#ifdef SVQC
                        UpdateCSQCProjectile(e);
+#endif
                        /*
                        // stupid conveyor code
                        tracebox(e.origin, e.mins, e.maxs, e.origin + self.movedir * sys_frametime, MOVE_NORMAL, e);
@@ -2212,17 +2232,61 @@ void conveyor_think()
                }
        }
 
+#ifdef SVQC
        self.nextthink = time;
+#endif
 }
 
+#ifdef SVQC
+
 void conveyor_use()
 {
        self.state = !self.state;
+
+       self.SendFlags |= 2;
 }
 
 void conveyor_reset()
 {
        self.state = (self.spawnflags & 1);
+
+       self.SendFlags |= 2;
+}
+
+float conveyor_send(entity to, float sf)
+{
+       WriteByte(MSG_ENTITY, ENT_CLIENT_CONVEYOR);
+       WriteByte(MSG_ENTITY, sf);
+
+       if(sf & 1)
+       {
+               WriteByte(MSG_ENTITY, self.warpzone_isboxy);
+               WriteCoord(MSG_ENTITY, self.origin_x);
+               WriteCoord(MSG_ENTITY, self.origin_y);
+               WriteCoord(MSG_ENTITY, self.origin_z);
+
+               WriteCoord(MSG_ENTITY, self.mins_x);
+               WriteCoord(MSG_ENTITY, self.mins_y);
+               WriteCoord(MSG_ENTITY, self.mins_z);
+               WriteCoord(MSG_ENTITY, self.maxs_x);
+               WriteCoord(MSG_ENTITY, self.maxs_y);
+               WriteCoord(MSG_ENTITY, self.maxs_z);
+
+               WriteCoord(MSG_ENTITY, self.movedir_x);
+               WriteCoord(MSG_ENTITY, self.movedir_y);
+               WriteCoord(MSG_ENTITY, self.movedir_z);
+
+               WriteByte(MSG_ENTITY, self.speed);
+               WriteByte(MSG_ENTITY, self.state);
+
+               WriteString(MSG_ENTITY, self.targetname);
+               WriteString(MSG_ENTITY, self.target);
+       }
+
+       if(sf & 2)
+               WriteByte(MSG_ENTITY, self.state);
+
+       return TRUE;
 }
 
 void conveyor_init()
@@ -2240,6 +2304,10 @@ void conveyor_init()
        }
        else
                self.state = 1;
+
+       Net_LinkEntity(self, 0, FALSE, conveyor_send);
+
+       self.SendFlags |= 1;
 }
 
 void spawnfunc_trigger_conveyor()
@@ -2256,3 +2324,56 @@ void spawnfunc_func_conveyor()
        self.movetype = MOVETYPE_NONE;
        conveyor_init();
 }
+
+#elif defined(CSQC)
+
+void conveyor_init()
+{
+       self.draw = conveyor_think;
+       self.drawmask = MASK_NORMAL;
+
+       self.movetype = MOVETYPE_NONE;
+       self.model = "";
+       self.solid = SOLID_TRIGGER;
+       self.move_origin = self.origin;
+       self.move_time = time;
+}
+
+void ent_conveyor()
+{
+       float sf = ReadByte();
+
+       if(sf & 1)
+       {
+               self.warpzone_isboxy = ReadByte();
+               self.origin_x = ReadCoord();
+               self.origin_y = ReadCoord();
+               self.origin_z = ReadCoord();
+               setorigin(self, self.origin);
+
+               self.mins_x = ReadCoord();
+               self.mins_y = ReadCoord();
+               self.mins_z = ReadCoord();
+               self.maxs_x = ReadCoord();
+               self.maxs_y = ReadCoord();
+               self.maxs_z = ReadCoord();
+               setsize(self, self.mins, self.maxs);
+
+               self.movedir_x = ReadCoord();
+               self.movedir_y = ReadCoord();
+               self.movedir_z = ReadCoord();
+
+               self.speed = ReadByte();
+               self.state = ReadByte();
+
+               self.targetname = strzone(ReadString());
+               self.target = strzone(ReadString());
+
+               conveyor_init();
+       }
+
+       if(sf & 2)
+               self.state = ReadByte();
+}
+
+#endif
index 3f98359592383f494cf38f189003b571e936aa22..521cf343b3efa6b32dae20181218cce6a3224104 100644 (file)
@@ -768,3 +768,59 @@ float WarpZoneLib_ExactTrigger_Touch()
 {
        return !WarpZoneLib_BoxTouchesBrush(other.absmin, other.absmax, self, other);
 }
+
+
+void WarpZoneLib_MoveOutOfSolid_Expand(entity e, vector by)
+{
+       float eps = 0.0625;
+       tracebox(e.origin, e.mins - '1 1 1' * eps, e.maxs + '1 1 1' * eps, e.origin + by, MOVE_WORLDONLY, e);
+       if (trace_startsolid)
+               return;
+       if (trace_fraction < 1)
+       {
+               // hit something
+               // adjust origin in the other direction...
+               setorigin(e,e.origin - by * (1 - trace_fraction));
+       }
+}
+
+float WarpZoneLib_MoveOutOfSolid(entity e)
+{
+       vector o, m0, m1;
+
+       o = e.origin;
+       traceline(o, o, MOVE_WORLDONLY, e);
+       if (trace_startsolid)
+               return FALSE;
+
+       tracebox(o, e.mins, e.maxs, o, MOVE_WORLDONLY, e);
+       if (!trace_startsolid)
+               return TRUE;
+
+       m0 = e.mins;
+       m1 = e.maxs;
+       e.mins = '0 0 0';
+       e.maxs = '0 0 0';
+       WarpZoneLib_MoveOutOfSolid_Expand(e, '1 0 0' * m0_x);
+       e.mins_x = m0_x;
+       WarpZoneLib_MoveOutOfSolid_Expand(e, '1 0 0' * m1_x);
+       e.maxs_x = m1_x;
+       WarpZoneLib_MoveOutOfSolid_Expand(e, '0 1 0' * m0_y);
+       e.mins_y = m0_y;
+       WarpZoneLib_MoveOutOfSolid_Expand(e, '0 1 0' * m1_y);
+       e.maxs_y = m1_y;
+       WarpZoneLib_MoveOutOfSolid_Expand(e, '0 0 1' * m0_z);
+       e.mins_z = m0_z;
+       WarpZoneLib_MoveOutOfSolid_Expand(e, '0 0 1' * m1_z);
+       e.maxs_z = m1_z;
+       setorigin(e, e.origin);
+
+       tracebox(e.origin, e.mins, e.maxs, e.origin, MOVE_WORLDONLY, e);
+       if (trace_startsolid)
+       {
+               setorigin(e, o);
+               return FALSE;
+       }
+
+       return TRUE;
+}
index c79ee95d6e02d2d2062b8a35a987de07f0aca3cb..8a8cfb227f5e7a6d5ab351a6316909cb543b4ff4 100644 (file)
@@ -100,3 +100,6 @@ entity WarpZone_RefSys_SpawnSameRefSys(entity me); // spawn().R = me.R
 #ifndef BITXOR_ASSIGN
 # define BITXOR_ASSIGN(a,b) ((a) = ((a) | (b)) - ((a) & (b)))
 #endif
+
+float WarpZoneLib_MoveOutOfSolid(entity e);
+#define move_out_of_solid(e) WarpZoneLib_MoveOutOfSolid(e)
index eafe2d47c0541dfcf7de17baacde6d3e985e408d..87f737a464dc78df2b8e441d43fd77695ab8c04f 100644 (file)
@@ -1,58 +1,3 @@
-void WarpZoneLib_MoveOutOfSolid_Expand(entity e, vector by)
-{
-       float eps = 0.0625;
-       tracebox(e.origin, e.mins - '1 1 1' * eps, e.maxs + '1 1 1' * eps, e.origin + by, MOVE_WORLDONLY, e);
-       if (trace_startsolid)
-               return;
-       if (trace_fraction < 1)
-       {
-               // hit something
-               // adjust origin in the other direction...
-               setorigin(e,e.origin - by * (1 - trace_fraction));
-       }
-}
-
-float WarpZoneLib_MoveOutOfSolid(entity e)
-{
-       vector o, m0, m1;
-
-       o = e.origin;
-       traceline(o, o, MOVE_WORLDONLY, e);
-       if (trace_startsolid)
-               return FALSE;
-
-       tracebox(o, e.mins, e.maxs, o, MOVE_WORLDONLY, e);
-       if (!trace_startsolid)
-               return TRUE;
-
-       m0 = e.mins;
-       m1 = e.maxs;
-       e.mins = '0 0 0';
-       e.maxs = '0 0 0';
-       WarpZoneLib_MoveOutOfSolid_Expand(e, '1 0 0' * m0_x);
-       e.mins_x = m0_x;
-       WarpZoneLib_MoveOutOfSolid_Expand(e, '1 0 0' * m1_x);
-       e.maxs_x = m1_x;
-       WarpZoneLib_MoveOutOfSolid_Expand(e, '0 1 0' * m0_y);
-       e.mins_y = m0_y;
-       WarpZoneLib_MoveOutOfSolid_Expand(e, '0 1 0' * m1_y);
-       e.maxs_y = m1_y;
-       WarpZoneLib_MoveOutOfSolid_Expand(e, '0 0 1' * m0_z);
-       e.mins_z = m0_z;
-       WarpZoneLib_MoveOutOfSolid_Expand(e, '0 0 1' * m1_z);
-       e.maxs_z = m1_z;
-       setorigin(e, e.origin);
-
-       tracebox(e.origin, e.mins, e.maxs, e.origin, MOVE_WORLDONLY, e);
-       if (trace_startsolid)
-       {
-               setorigin(e, o);
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
 void WarpZoneLib_ExactTrigger_Init()
 {
        vector mi, ma;