Rename `command` to avoid ghosting

It's curious that gcc complains about ghosting here, since the lambda has its own stack pointer, and doesn't capture the outer `command`.
This commit is contained in:
Hielke Morsink 2022-06-21 23:07:16 +02:00
parent 8e439b9895
commit 79ae03fc5e
No known key found for this signature in database
GPG Key ID: FE0B343DF883E7F2
2 changed files with 16 additions and 16 deletions

View File

@ -69,44 +69,44 @@ namespace OpenRCT2::Scripting
using namespace OpenRCT2::Title;
DukObject obj(ctx);
std::visit(
[&obj](auto&& value) {
using T = std::decay_t<decltype(value)>;
[&obj](auto&& command) {
using T = std::decay_t<decltype(command)>;
obj.Set("type", T::ScriptingName);
if constexpr (std::is_same_v<T, LoadParkCommand>)
{
obj.Set("index", value.SaveIndex);
obj.Set("index", command.SaveIndex);
}
else if constexpr (std::is_same_v<T, SetLocationCommand>)
{
obj.Set("x", value.Location.X);
obj.Set("y", value.Location.Y);
obj.Set("x", command.Location.X);
obj.Set("y", command.Location.Y);
}
else if constexpr (std::is_same_v<T, RotateViewCommand>)
{
obj.Set("rotations", value.Rotations);
obj.Set("rotations", command.Rotations);
}
else if constexpr (std::is_same_v<T, SetZoomCommand>)
{
obj.Set("zoom", value.Zoom);
obj.Set("zoom", command.Zoom);
}
else if constexpr (std::is_same_v<T, FollowEntityCommand>)
{
if (value.Follow.SpriteIndex.IsNull())
if (command.Follow.SpriteIndex.IsNull())
obj.Set("id", nullptr);
else
obj.Set("id", value.Follow.SpriteIndex.ToUnderlying());
obj.Set("id", command.Follow.SpriteIndex.ToUnderlying());
}
else if constexpr (std::is_same_v<T, SetSpeedCommand>)
{
obj.Set("speed", value.Speed);
obj.Set("speed", command.Speed);
}
else if constexpr (std::is_same_v<T, WaitCommand>)
{
obj.Set("duration", value.Milliseconds);
obj.Set("duration", command.Milliseconds);
}
else if constexpr (std::is_same_v<T, LoadScenarioCommand>)
{
obj.Set("scenario", String::ToStringView(value.Scenario, sizeof(value.Scenario)));
obj.Set("scenario", String::ToStringView(command.Scenario, sizeof(command.Scenario)));
}
},
value);

View File

@ -275,7 +275,7 @@ namespace OpenRCT2::Title
seq.Saves.erase(seq.Saves.begin() + index);
// Update load commands
for (auto& command : seq.Commands)
for (auto& seqCommand : seq.Commands)
{
std::visit(
[index](auto&& command) {
@ -293,7 +293,7 @@ namespace OpenRCT2::Title
}
}
},
command);
seqCommand);
}
return true;
@ -507,7 +507,7 @@ namespace OpenRCT2::Title
sb.Append("# SCRIPT FOR ");
sb.Append(seq.Name.c_str());
sb.Append("\n");
for (const auto& command : seq.Commands)
for (const auto& seqCommand : seq.Commands)
{
std::visit(
[&buffer, &seq, &sb](auto&& command) {
@ -576,7 +576,7 @@ namespace OpenRCT2::Title
sb.Append("END");
}
},
command);
seqCommand);
sb.Append("\n");
}