Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out of map orders leniency #1769

Merged
merged 9 commits into from
Nov 24, 2024
14 changes: 10 additions & 4 deletions rts/Game/UI/GuiHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2376,8 +2376,11 @@ Command CGuiHandler::GetCommand(int mouseX, int mouseY, int buttonHint, bool pre
const float3 camTraceDir = mouse->buttons[button].dir;

const float traceDist = camera->GetFarPlaneDist() * 1.4f;
const float innerDist = CGround::LineGroundCol(camTracePos, camTracePos + camTraceDir * traceDist, false);
float outerDist = -1.0f;
float innerDist = CGround::LineGroundCol(camTracePos, camTracePos + camTraceDir * traceDist, false);
float outerDist = -1.0f;

if (innerDist < 0.0f)
saurtron marked this conversation as resolved.
Show resolved Hide resolved
innerDist = CGround::LinePlaneCol(camTracePos, camTraceDir, traceDist, CGround::GetWaterPlaneLevel());

if (innerDist < 0.0f)
return defaultRet;
Expand Down Expand Up @@ -3592,8 +3595,11 @@ void CGuiHandler::DrawMapStuff(bool onMiniMap)
const float3 camTraceDir = mouse->buttons[button].dir;

const float traceDist = camera->GetFarPlaneDist() * 1.4f;
const float innerDist = CGround::LineGroundCol(camTracePos, camTracePos + camTraceDir * traceDist, false);
float outerDist = -1.0f;
float innerDist = CGround::LineGroundCol(camTracePos, camTracePos + camTraceDir * traceDist, false);
float outerDist = -1.0f;

if (innerDist < 0.0f)
innerDist = CGround::LinePlaneCol(camTracePos, camTraceDir, traceDist, CGround::GetWaterPlaneLevel());

if (innerDist < 0.0f)
break;
Expand Down
8 changes: 2 additions & 6 deletions rts/Sim/Units/CommandAI/CommandAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,6 @@ bool CCommandAI::AllowedCommand(const Command& c, bool fromSynced)
// TODO check if the command is in the map first, for more commands
switch (cmdID) {
case CMD_MOVE:
case CMD_ATTACK:
saurtron marked this conversation as resolved.
Show resolved Hide resolved
case CMD_AREA_ATTACK:
case CMD_RECLAIM:
case CMD_REPAIR:
Expand Down Expand Up @@ -701,8 +700,6 @@ bool CCommandAI::AllowedCommand(const Command& c, bool fromSynced)

if (attackee == nullptr)
return false;
if (!attackee->pos.IsInBounds())
return false;
} else {
AdjustGroundAttackCommand(c, fromSynced, aiOrder);
}
Expand All @@ -721,9 +718,8 @@ bool CCommandAI::AllowedCommand(const Command& c, bool fromSynced)

if (!ud->canGuard)
return false;
if (owner && !owner->pos.IsInBounds())
return false;
if (guardee && !guardee->pos.IsInBounds())
// Allow guarding out of map units only if both are builders to avoid plane hacks.
if (guardee && !(guardee->unitDef->IsBuilderUnit() && ud->IsBuilderUnit()) && !guardee->pos.IsInBounds())
Copy link
Collaborator

@sprunk sprunk Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for a game to decide. IMO either keep the limit as-is or remove wholesale, don't instate a different limit. In general that applies to every command whose limitation isn't for technical reasons.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, just did it like this because it's what ppl requested at beyond-all-reason/Beyond-All-Reason#763 but we can just remove the check here and then make it stricter in some lua gadget.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok removed the check here and prepared a PR for BAR doing the same check.

return false;
} break;

Expand Down