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,18 +541,21 @@ 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));
|
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)); });
|
sample_size.installChangeCallback([](settings::VariableBase<int> &, int after) { previous_positions.fill(boost::circular_buffer<Vector>(after)); });
|
||||||
EC::Register(
|
EC::Register(
|
||||||
EC::CreateMove,
|
EC::CreateMove,
|
||||||
[]() {
|
[]()
|
||||||
|
{
|
||||||
for (int i = 1; i < g_GlobalVars->maxClients; i++)
|
for (int i = 1; i < g_GlobalVars->maxClients; i++)
|
||||||
{
|
{
|
||||||
auto ent = ENTITY(i);
|
auto ent = ENTITY(i);
|
||||||
auto &buffer = previous_positions.at(i - 1);
|
auto &buffer = previous_positions.at(i - 1);
|
||||||
|
|
||||||
if (CE_BAD(ent) || !ent->m_bAlivePlayer())
|
if (CE_BAD(LOCAL_E) || CE_BAD(ent) || !ent->m_bAlivePlayer())
|
||||||
{
|
{
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
continue;
|
continue;
|
||||||
@ -569,4 +572,4 @@ static InitRoutine init([]() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cm_prediction", EC::very_early);
|
"cm_prediction", EC::very_early);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user