Phobos icon indicating copy to clipboard operation
Phobos copied to clipboard

[Vanilla Fix] Fix BalloonHover incorrectly considering ground factors when pathfinding

Open TaranDahl opened this issue 7 months ago • 20 comments

Fixed the bug where technos with BalloonHover=yes incorrectly considered ground factors when setting the destination and distributing moving commands. Use [General]->BalloonHoverPathingFix=true to enable this fix.

TaranDahl avatar May 09 '25 15:05 TaranDahl

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

github-actions[bot] avatar May 09 '25 16:05 github-actions[bot]

What does this impact? Maybe the fix could be on by default?

Metadorius avatar May 09 '25 20:05 Metadorius

What did this fix

NetsuNegi avatar May 10 '25 02:05 NetsuNegi

image In vanilla, this is not allowed. image In vanilla, these commands will be distributed only on the bridge, because the clicked cell is on the bridge. This makes sense on the ground technos, but not for BalloonHovers. Also happens on cliff.

TaranDahl avatar May 10 '25 05:05 TaranDahl

New commit: 27d25c11525cddf1ed6fe4f40ee8bfdb Vanilla behavior👆 cb7b6a8178d67811ac1973331d79d676 New behavior👆 Pay attention to how BalloonHovers selects the destination when attacking the target.

TaranDahl avatar May 10 '25 11:05 TaranDahl

Looks to me like the fix could be on by default, and would just have to add migration notice to disable it if undesired.

Metadorius avatar May 10 '25 12:05 Metadorius

image

These hooks didn't perform very well during performance test with profiler. But I guess there's no much options to optimize the code logic since it still needs to go through the hooks and check no matter if BalloonHoverPathingFix is enabled or not

Is it possible to move the hooks to another places that BalloonHover has already been checked?

Coronia avatar May 14 '25 05:05 Coronia

image These hooks didn't perform very well during performance test with profiler. But I guess there's no much options to optimize the code logic since it still needs to go through the hooks and check no matter if BalloonHoverPathingFix is enabled or not Is it possible to move the hooks to another places that BalloonHover has already been checked?-----------谷歌翻译-----------是否可以将钩子移至已经检查过BalloonHover的另一个地方?

It seems unlikely because vanilla doesn't check for BalloonHover in these functions.

TaranDahl avatar May 14 '25 06:05 TaranDahl

I placed the IsInAir check at the end, which may slightly improve performance.

TaranDahl avatar May 14 '25 06:05 TaranDahl

using a naked hook may improve the situation

Metadorius avatar May 14 '25 06:05 Metadorius

using a naked hook may improve the situation-----------谷歌翻译-----------使用裸钩可能会改善情况

Dunno how to do it. Any example?

TaranDahl avatar May 14 '25 07:05 TaranDahl

Dunno how to do it. Any example?

Search for DEFINE_NAKED_HOOK in code.

Metadorius avatar May 14 '25 10:05 Metadorius

Dunno how to do it. Any example?

Search for DEFINE_NAKED_HOOK in code.-----------谷歌翻译-----------在代码中搜索Define_naked_hook。

Only one use case:

DEFINE_NAKED_HOOK(0x7CD8EA, _ExeTerminate) { // Call WinMain SET_REG32(EAX, 0x6BB9A0); CALL(EAX); PUSH_REG(EAX);

__asm {call Phobos::ExeTerminate};

// Jump back
POP_REG(EAX);
SET_REG32(EBX, 0x7CD8EF);
__asm {jmp ebx};

}

Should I write asm like that?

TaranDahl avatar May 14 '25 10:05 TaranDahl

Should I write asm like that?

You're not really limited to assembly. You should just keep in mind that a naked hook is simply a jump to the code you write, no prolog, epilog or anything like that, so you should care to not mess up the stack, registers etc.

Metadorius avatar May 14 '25 10:05 Metadorius

If you want to look at naked hooks, you could look at Vinifera. It's all naked hooks there :P

ZivDero avatar May 14 '25 11:05 ZivDero

Too stupid to write asm. Can't finish it myself. Everything I can do is in the commit that was reverted and just submitted. Let it be. If it doesn't meet the requirements, I'll close this PR.

TaranDahl avatar May 27 '25 07:05 TaranDahl

there's another way if the calculation can't be optimized: instead of checking the toggle inside the hooks, we can make it patch down these hooks directly if disabled. See https://github.com/Phobos-developers/Phobos/commit/2ff45a0a4b120b7980104b1280de04d588dbd59b for reference

Coronia avatar Jun 09 '25 02:06 Coronia

now that this is proven to have impact on performance, it's not really good to enable it by default. Also this fix will change the behavior of aircrafts which might affect players who's getting used to current behavior

Coronia avatar Jun 13 '25 10:06 Coronia

@ZivDero maybe you could assist with a naked hook?

Metadorius avatar Jun 13 '25 10:06 Metadorius