The code snippets and the explanation in the post seem consistent with the described functionality. Let's break down the code and compare it to the provided information:
Applying Legacy Input (CMD_MODEL_SUBJECT_TO_GRAVITY):
c
case CMD_MODEL_SUBJECT_TO_GRAVITY:
if (GET_INT_ARG(1) > 0)
{
newchar->move_config_flags |= MOVE_CONFIG_SUBJECT_TO_GRAVITY;
}
else
{
newchar->move_config_flags &= ~MOVE_CONFIG_SUBJECT_TO_GRAVITY;
}
break;
This code is consistent with the description in the post. If GET_INT_ARG(1) (presumably an argument from some input source) is greater than 0, it sets the MOVE_CONFIG_SUBJECT_TO_GRAVITY flag in newchar->move_config_flags. Otherwise, it ensures the flag is unset.
Applying Gravity:
c
self->position.y += self->velocity.y * 100.0 / GAME_SPEED;
if(!(self->animation->move_config_flags & MOVE_CONFIG_SUBJECT_TO_GRAVITY))
{
gravity = 0;
}
else
{
gravity = (level ? level->gravity : default_level_gravity) * (1.0 - self->modeldata.antigravity);
}
if(self->modeldata.move_config_flags & MOVE_CONFIG_SUBJECT_TO_GRAVITY)
{
self->velocity.y += gravity * 100.0 / GAME_SPEED;
}
This code aligns with the explanation. It calculates the gravity based on certain conditions. If the animation's move_config_flags for gravity is not set, it sets gravity to 0. If the model's move_config_flags for gravity is set, it applies the calculated gravity to the entity's velocity.
Legacy Manual Entry for subject_to_gravity:
The provided manual entry for subject_to_gravity:
- 0: Gravity doesn't have any effect.
- 1: Gravity has effects. Default for most entities.
This matches with the logic in the code where, if the legacy input is greater than 0, the MOVE_CONFIG_SUBJECT_TO_GRAVITY flag is set, and if it's not greater than 0, the flag is unset.
Overall, based on the information provided, the code snippets appear to be correctly implementing the described logic for applying gravity and the legacy input for subject_to_gravity.