fix a somewhat common projectile prediction crash
This commit is contained in:
parent
12f80f20bf
commit
2c074d5598
@ -267,8 +267,8 @@ Vector EnginePrediction(CachedEntity *entity, float time)
|
|||||||
typedef void (*FinishMoveFn)(IPrediction *, IClientEntity *, CUserCmd *, CMoveData *);
|
typedef void (*FinishMoveFn)(IPrediction *, IClientEntity *, CUserCmd *, CMoveData *);
|
||||||
|
|
||||||
void **predictionVtable = *((void ***) g_IPrediction);
|
void **predictionVtable = *((void ***) g_IPrediction);
|
||||||
SetupMoveFn oSetupMove = (SetupMoveFn)(*(unsigned *) (predictionVtable + 19));
|
SetupMoveFn oSetupMove = (SetupMoveFn) (*(unsigned *) (predictionVtable + 19));
|
||||||
FinishMoveFn oFinishMove = (FinishMoveFn)(*(unsigned *) (predictionVtable + 20));
|
FinishMoveFn oFinishMove = (FinishMoveFn) (*(unsigned *) (predictionVtable + 20));
|
||||||
|
|
||||||
// CMoveData *pMoveData = (CMoveData*)(sharedobj::client->lmap->l_addr +
|
// CMoveData *pMoveData = (CMoveData*)(sharedobj::client->lmap->l_addr +
|
||||||
// 0x1F69C0C); CMoveData movedata {};
|
// 0x1F69C0C); CMoveData movedata {};
|
||||||
@ -541,32 +541,35 @@ float DistanceToGround(Vector origin)
|
|||||||
return std::fabs(origin.z - ground_trace.endpos.z);
|
return std::fabs(origin.z - ground_trace.endpos.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
static InitRoutine init([]() {
|
static InitRoutine init(
|
||||||
previous_positions.fill(boost::circular_buffer<Vector>(*sample_size));
|
[]()
|
||||||
sample_size.installChangeCallback([](settings::VariableBase<int> &, int after) { previous_positions.fill(boost::circular_buffer<Vector>(after)); });
|
{
|
||||||
EC::Register(
|
previous_positions.fill(boost::circular_buffer<Vector>(*sample_size));
|
||||||
EC::CreateMove,
|
sample_size.installChangeCallback([](settings::VariableBase<int> &, int after) { previous_positions.fill(boost::circular_buffer<Vector>(after)); });
|
||||||
[]() {
|
EC::Register(
|
||||||
for (int i = 1; i < g_GlobalVars->maxClients; i++)
|
EC::CreateMove,
|
||||||
|
[]()
|
||||||
{
|
{
|
||||||
auto ent = ENTITY(i);
|
for (int i = 1; i < g_GlobalVars->maxClients; i++)
|
||||||
auto &buffer = previous_positions.at(i - 1);
|
|
||||||
|
|
||||||
if (CE_BAD(ent) || !ent->m_bAlivePlayer())
|
|
||||||
{
|
{
|
||||||
buffer.clear();
|
auto ent = ENTITY(i);
|
||||||
continue;
|
auto &buffer = previous_positions.at(i - 1);
|
||||||
}
|
|
||||||
Vector vel;
|
|
||||||
velocity::EstimateAbsVelocity(RAW_ENT(ent), vel);
|
|
||||||
if (vel.IsZero())
|
|
||||||
{
|
|
||||||
buffer.clear();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer.push_front(ent->m_vecOrigin());
|
if (CE_BAD(LOCAL_E) || CE_BAD(ent) || !ent->m_bAlivePlayer())
|
||||||
}
|
{
|
||||||
},
|
buffer.clear();
|
||||||
"cm_prediction", EC::very_early);
|
continue;
|
||||||
});
|
}
|
||||||
|
Vector vel;
|
||||||
|
velocity::EstimateAbsVelocity(RAW_ENT(ent), vel);
|
||||||
|
if (vel.IsZero())
|
||||||
|
{
|
||||||
|
buffer.clear();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.push_front(ent->m_vecOrigin());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cm_prediction", EC::very_early);
|
||||||
|
});
|
||||||
|
Reference in New Issue
Block a user