aliens

Author Topic: [FIXED] Triton wall bug  (Read 3167 times)

Offline Xilmi

  • Commander
  • *****
  • Posts: 642
    • View Profile
[FIXED] Triton wall bug
« on: February 11, 2023, 12:39:58 am »
Hi!

This wednesday I was testing Brutal-AI together with a streamer who is an avid TFTD-player.
He immediately pointed out something wrong with being able to look through the walls of the Triton.
I think you can see terrain through it but not enemies.

I wasn't sure because it was something that was my fault (I did mess around a bit with TileEngine). But now I tested it. And the same bug is present in OXCE 7.8.5 too.
OXC, however doesn't have this bug.

See the reference screenshots.

To reproduce just turn around one of the soldiers at the NE and the NW-walls to face the wall. Happens 100% of the time in OXCE and my OXCE-fork.

I wanted to look at the difference in calculateLineTile between OXC and OXCE to see a potential reason. But OXC doesn't even have a calculateLineTile function and thus must do this stuff in a completely different way. :o

Attached are screenshots with (OXCE) and without (OXC) the bug.
« Last Edit: March 11, 2023, 07:04:34 pm by Meridian »

Offline Xilmi

  • Commander
  • *****
  • Posts: 642
    • View Profile
Re: Triton wall bug
« Reply #1 on: February 11, 2023, 01:05:18 am »
When I comment this code, it works.

Can you explain what this is for? It almost looks like it was deliberately put there to provoke precisely the kind of bug I've reported here. I read it as: "If you are less than 2 steps away from a wall ignore the wall for the purpose of whether your line of tile-vision is blocked by it."

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3347
    • View Profile
Re: Triton wall bug
« Reply #2 on: February 11, 2023, 01:35:44 am »
Most of this code is black magic, multiple of corner cases to handle, and its look like fix in one place break some thing elsewhere.
I will look on this but I dount if I could give answer, beside check if original game (not OXC!) had same behavior, if it was then this glitch will probably stay.

(btw DO NOT post code as screenshots this is completely unproductive, post link to github or even copy-paste this sniped)


[ps]
https://github.com/OpenXcom/OpenXcom/blob/master/src/Battlescape/TileEngine.cpp#L1820
Same logic should be in OXC, if I did not make error in refactor both should give same answer.
« Last Edit: February 11, 2023, 01:50:13 am by Yankes »

Offline Xilmi

  • Commander
  • *****
  • Posts: 642
    • View Profile
Re: Triton wall bug
« Reply #3 on: February 11, 2023, 02:45:38 am »
beside check if original game (not OXC!) had same behavior, if it was then this glitch will probably stay.
I just did that. In the OG TFTD you can't look through the Triton-wall either.

And there's something else you can't do: Climb on the Triton with your soldiers. This is possible in both OXC and OXCE but not the original game. There you can only step on the lower part of the wing. But not on the higher one or the roof.

https://github.com/OpenXcom/OpenXcom/blob/master/src/Battlescape/TileEngine.cpp#L1820
Same logic should be in OXC, if I did not make error in refactor both should give same answer.
I can't see the same logic there. This code looks completely different from calculateLineTile and I cannot recognize what in that code is supposed to be the equivalent for "if (steps<2)".

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3347
    • View Profile
Re: Triton wall bug
« Reply #4 on: February 11, 2023, 03:25:13 am »
It should be same code, but logic is split by function argument:
https://github.com/OpenXcom/OpenXcom/blob/master/src/Battlescape/TileEngine.cpp#L2314
I think I could incorrectly flip condition but probably need dig bit more to see what is wrong with it.

Offline Xilmi

  • Commander
  • *****
  • Posts: 642
    • View Profile
Re: Triton wall bug
« Reply #5 on: February 12, 2023, 01:03:58 am »
Just a small heads up: I've been playing all day with the change I proposed and didn't see any negative side-effect.

Offline kevL

  • Colonel
  • ****
  • Posts: 482
  • pitchforks and torches
    • View Profile
Re: Triton wall bug
« Reply #6 on: February 12, 2023, 01:24:58 am »
Just a small heads up: I've been playing all day with the change I proposed and didn't see any negative side-effect.

just an aside: beware diagonal bigwalls (eg. some UFO hull-tiles) because that step<2 *might* be there to prevent blast propagation through them.

eg. with your change, try hitting one with an incendiary ... see if the fire spreads inside the UFO
« Last Edit: February 12, 2023, 01:28:56 am by kevL »

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3347
    • View Profile
Re: Triton wall bug
« Reply #7 on: February 12, 2023, 02:39:10 am »
just an aside: beware diagonal bigwalls (eg. some UFO hull-tiles) because that step<2 *might* be there to prevent blast propagation through them.

eg. with your change, try hitting one with an incendiary ... see if the fire spreads inside the UFO
Probably some thing like this, condition we consider here only was used in tile "visibility" but bigwalls had lot of special code in every aspect of engine.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9078
    • View Profile
Re: Triton wall bug
« Reply #8 on: February 13, 2023, 04:04:10 pm »
The issue started appearing in one of the blue highlighted commits.
Probably the one in red rectangle.

Not appearing: https://lxnt.wtf/oxem/builds//Extended/Extended-6.2-7c85456c1-2019-12-28-win64.7z
Appearing: https://lxnt.wtf/oxem/builds//Extended/Extended-6.2-4b74ab3bf-2019-12-29-win64.7z
« Last Edit: February 13, 2023, 04:06:54 pm by Meridian »

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3347
    • View Profile
Re: Triton wall bug
« Reply #9 on: March 10, 2023, 02:50:56 am »
After digging in code I can confirm that was error on my part, it look like this condition should be removed.

Overall fix will look like:
Code: [Select]
bool result = getBlockDir(cache, dir, difference.z);
if (result && difference.z == 0 && getBigWallDir(cache, dir))
{
if (point == target)
{
result = false;
}
}
This is probably more accurate what algorithm do and same logic is used in light propagation.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9078
    • View Profile