InterpolateOrigin_Do();
}
+
+vector player_org, player_vel;
+float player_sequence, player_pmflags;
+float pmoveframe;
+.float pmove_flags;
+void Unpredict()
+{
+ self.origin = player_org;
+ self.velocity = player_vel;
+ pmoveframe = player_sequence+1; //+1 because the recieved frame has the move already done (server side)
+ self.pmove_flags = player_pmflags;
+ if (pmoveframe < clientcommandframe-128)
+ pmoveframe = clientcommandframe-128; // don't want to loop infinitely
+}
+
+void PredictTo(float endframe)
+{
+ if(servercommandframe >= player_sequence+63)
+ {
+ player_sequence = servercommandframe+63; // freeze laggers
+ return;
+ }
+
+ Unpredict();
+
+ if (getstatf(STAT_HEALTH) <= 0)
+ {
+ pmoveframe = clientcommandframe;
+ getinputstate(pmoveframe-1);
+ return;
+ }
+
+ while(pmoveframe < endframe)
+ {
+ if (!getinputstate(pmoveframe))
+ {
+ break;
+ }
+ runstandardplayerphysics(self);
+
+ pmoveframe++;
+ }
+
+ //add in anything that was applied after (for low packet rate protocols)
+ input_angles = view_angles;
+}
+
entity csqcmodel_me;
float autocvar_chase_active;
float autocvar_chase_back;
entity oldself;
oldself = self;
self = csqcmodel_me;
- InterpolateOrigin_Do();
+ PredictTo(clientcommandframe);
self = oldself;
- // TODO run prediction
-
org = csqcmodel_me.origin + csqcmodel_me.view_ofs;
ang = R_SetView3fv(VF_ANGLES);
float sf;
sf = ReadShort();
- InterpolateOrigin_Undo();
+ if(self.entnum == player_localentnum)
+ Unpredict();
+ else
+ InterpolateOrigin_Undo();
#define PROPERTY(flag,r,w,f) \
if(sf & flag) \
#undef PROPERTY_SCALED
#undef PROPERTY
- // is this me?
+ // interpolation
if(self.entnum == player_localentnum)
+ {
+ vector o, v;
+ o = self.origin;
+ v = self.velocity;
csqcmodel_me = self;
-
- // interpolation
- InterpolateOrigin_Note();
+ PredictTo(servercommandframe + 1);
+ player_pmflags = self.pmove_flags;
+ player_org = o;
+ player_vel = v;
+ player_sequence = servercommandframe;
+ Unpredict();
+ }
+ else
+ InterpolateOrigin_Note();
// draw it
- self.renderflags = RF_EXTERNALMODEL;
+ if(self.entnum <= maxclients)
+ self.renderflags = RF_EXTERNALMODEL;
self.drawmask = MASK_NORMAL;
self.predraw = CSQCModel_Draw;
}