Skip to content

Commit a7a17b1

Browse files
committed
Reset forwarded cmds when character switches to distant vehicle.
1 parent 14dcfe6 commit a7a17b1

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

source/main/GameContext.cpp

+17-10
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,7 @@ void GameContext::UpdateSimInputEvents(float dt)
11391139
}
11401140

11411141
// forward commands from character
1142+
ActorPtr actor_to_reset_commandkeys;
11421143
if (!m_player_actor)
11431144
{
11441145
// Find nearest actor
@@ -1155,16 +1156,14 @@ void GameContext::UpdateSimInputEvents(float dt)
11551156
}
11561157
}
11571158

1158-
ActorPtr actor_to_reset_inputs;
1159-
11601159
// Evaluate
11611160
if (nearest_actor != nullptr &&
11621161
nearest_actor->ar_import_commands &&
11631162
min_squared_distance < (nearest_actor->getMinCameraRadius()*nearest_actor->getMinCameraRadius()))
11641163
{
11651164
if (nearest_actor != m_actor_remotely_receiving_commands)
11661165
{
1167-
actor_to_reset_inputs = m_actor_remotely_receiving_commands;
1166+
actor_to_reset_commandkeys = m_actor_remotely_receiving_commands;
11681167
}
11691168
m_actor_remotely_receiving_commands = nearest_actor;
11701169

@@ -1189,18 +1188,26 @@ void GameContext::UpdateSimInputEvents(float dt)
11891188
{
11901189
if (m_actor_remotely_receiving_commands)
11911190
{
1192-
actor_to_reset_inputs = m_actor_remotely_receiving_commands;
1191+
// Just left the vicinity of the actor, but still on foot
1192+
actor_to_reset_commandkeys = m_actor_remotely_receiving_commands;
1193+
m_actor_remotely_receiving_commands = nullptr;
11931194
}
1194-
m_actor_remotely_receiving_commands = nullptr;
11951195
}
1196+
}
1197+
else if (m_actor_remotely_receiving_commands)
1198+
{
1199+
// Just left the vicinity of the actor by entering vehicle
1200+
actor_to_reset_commandkeys = m_actor_remotely_receiving_commands;
1201+
m_actor_remotely_receiving_commands = nullptr;
1202+
}
11961203

1197-
if (actor_to_reset_inputs)
1204+
if (actor_to_reset_commandkeys)
1205+
{
1206+
for (int i = 1; i <= MAX_COMMANDS; i++) // BEWARE: commandkeys are indexed 1-MAX_COMMANDS!
11981207
{
1199-
for (int i = 1; i <= MAX_COMMANDS; i++) // BEWARE: commandkeys are indexed 1-MAX_COMMANDS!
1200-
{
1201-
actor_to_reset_inputs->ar_command_key[i].playerInputValue = 0.f;
1202-
}
1208+
actor_to_reset_commandkeys->ar_command_key[i].playerInputValue = 0.f;
12031209
}
1210+
actor_to_reset_commandkeys = nullptr;
12041211
}
12051212

12061213
// AI waypoint recording

0 commit comments

Comments
 (0)