ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.72k stars 625 forks source link

Attached Entities Causing Increased Animation Speeds #2376

Open hleVqq opened 5 years ago

hleVqq commented 5 years ago

Attaching an entity (aiment) to a player causes player's certain animations to double in speed (doubles everytime an entity is attached).

It's somewhat fixed by ReHLDS (at least for CS it works), but it's reproducible on other HL mods. ReHLDS cvar description:

sv_rehlds_attachedentities_playeranimationspeed_fix // Fixes bug with gait animation speed increase when player has some attached entities (aiments). Can cause animation lags when cl_updaterate is low. Default: 0

ArmynC commented 5 years ago

This is the code bit:

int attachedEntCount[MAX_CLIENTS + 1] = {};
for (int i = curPack->num_entities - 1; i >= 0; i--)
{
    auto &entityState = curPack->entities[i];
    if (entityState.number > MAX_CLIENTS)
    {
        if (sv_rehlds_attachedentities_playeranimationspeed_fix.string[0] == '1'
            && entityState.movetype == MOVETYPE_FOLLOW
            && 1 <= entityState.aiment && entityState.aiment <= MAX_CLIENTS)
        {
            attachedEntCount[entityState.aiment]++;
        }
    }
    else
    {
        if (attachedEntCount[entityState.number] != 0)
        {
            // Each attached entity causes StudioProcessGait for player
            // But this will slow down normal animation predicting on client
            entityState.framerate /= (1 + attachedEntCount[entityState.number]);
        }
    }
}

Also, it is related in mechanics to Non-sprite set to glow! #2202