(Patch) Eduke32: E4L4, water in "D-cup Ride" area kills Duke instantly
-
In E4L4 "Babe Land", going underwater in the "D-cup Ride" area kills Duke instantly
If you enter the water from above, then any horizontal movement while underwater kills Duke instantly, almost every time. (Sometimes I can running-jump into the water and survive, but not consistently.)
If not submerged, Duke can swim around the surface freely.
If not moving, Duke can submerge and surface freely.
If enter from the fountain in the courtyard and swim through the tunnel into D-cup Ride area, Duke can swim around underwater until surfacing (at which point, you are now enter from above once more and it's just like before.)
...
To reproduce: start any game in Atomic Edition. Warp code for level: dnscotty404. (Optional "no monsters" code: dnskill0.)
Walk forward and drop out the pipe into the admission area. Shoot out the glass and use the button to deactivate the force field. Go through the revolving door and follow the path into the courtyard area. D-cup Ride area is to the right, with the red and blue flashing lights in the entrance. Jump into the water and press Crouch to submerge. Move in any direction to experience death.
...
Bug is present also in Eduke32 Win64 20190908-8090 (r8090 same rev as what RP are using):
https://dukeworld.com/eduke32/synthesis/20190908-8090/
Seems fixed in r8247:
https://dukeworld.com/eduke32/synthesis/20191021-8247/
(Present still in r8240, released immediately prior.)
I think this relates to r8241 commit 7bfa7547 (Band-aid fix for Duke3d E4L4 map "corruption"):
https://voidpoint.io/terminx/eduke32/-/commit/7bfa754762dcedd545e906848e075617c8a497d6
However I made a patch of this, and it don't seem to work on its own; whether I place it first, last, or anywhere in between the existing patches, I always get an error like the following:
Built object obj/build/tiles.o source/build/src/clip.cpp: In function ‘void clipupdatesector(vec2_t, int16_t*, int)’: source/build/src/clip.cpp:957:44: error: expected ‘)’ before string constant OSD_Printf(EDUKE32_PRETTY_FUNCTION ":%d shortest distance between origin point (%d, %d) and sector %d is %d. Sector may be corrupt!\n", ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ source/build/src/clip.cpp:958:59: warning: too many arguments for format [-Wformat-extra-args] __LINE__, pos.x, pos.y, *sectnum, nsecs); ^ Built object obj/build/defs.o Failed building obj/build/clip.o from source/build/src/clip.cpp! make: *** [GNUmakefile:1057: obj/build/clip.o] Error 1 make: *** Waiting for unfinished jobs.... Built object obj/build/2d.o Built object obj/build/engine.o Could not successfully build eduke32 - Duke3D source port (/home/pi/RetroPie-Setup/tmp/build/eduke32/eduke32 not found). /home/pi/RetroPie-Setup Errors: Could not successfully build eduke32 - Duke3D source port (/home/pi/RetroPie-Setup/tmp/build/eduke32/eduke32 not found).
The way I made the patch was:
git clone https://voidpoint.io/terminx/eduke32 cd eduke32 git checkout 7bfa7547 git diff @^ > patch.diff
...and that gave me this
patch.diff
which I used in testing:diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index 24eb02368..65e19acf3 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -945,14 +945,22 @@ static int get_floorspr_clipyou(vec2_t const v1, vec2_t const v2, vec2_t const v return clipyou; } -static void clipupdatesector(vec2_t const pos, int16_t * const sectnum, int const walldist) +static void clipupdatesector(vec2_t const pos, int16_t * const sectnum, int walldist) { if (inside_p(pos.x, pos.y, *sectnum)) return; + int16_t nsecs = min<int16_t>(getsectordist(pos, *sectnum), INT16_MAX); + + if (nsecs > (walldist + 8)) + { + OSD_Printf(EDUKE32_PRETTY_FUNCTION ":%d shortest distance between origin point (%d, %d) and sector %d is %d. Sector may be corrupt!\n", + __LINE__, pos.x, pos.y, *sectnum, nsecs); + walldist = 0x7fff; + } + static int16_t sectlist[MAXSECTORS]; static uint8_t sectbitmap[(MAXSECTORS+7)>>3]; - int16_t nsecs; bfirst_search_init(sectlist, sectbitmap, &nsecs, MAXSECTORS, *sectnum);
...
File
source/build/src/clip.cpp
was also modified again in commit 1ad61337 "r8247":https://voidpoint.io/terminx/eduke32/-/commit/1ad61337a833cd56025a6e13c424fbca51b131c3
Titled "I swear, the amount of trivial differences between toolchain setups drives me up the wall sometimes", it looks like this is correcting some syntax of the previous commit, which explains also why it wasn't working earlier with just the first one. Now:
git checkout 1ad6133 git diff 7bfa754^ -- source/build/src/clip.cpp > patch.diff
This incorporates r8241 and r8247:
diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index 24eb02368..1a7b57bb5 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -945,14 +945,22 @@ static int get_floorspr_clipyou(vec2_t const v1, vec2_t const v2, vec2_t const v return clipyou; } -static void clipupdatesector(vec2_t const pos, int16_t * const sectnum, int const walldist) +static void clipupdatesector(vec2_t const pos, int16_t * const sectnum, int walldist) { if (inside_p(pos.x, pos.y, *sectnum)) return; + int16_t nsecs = min<int16_t>(getsectordist(pos, *sectnum), INT16_MAX); + + if (nsecs > (walldist + 8)) + { + OSD_Printf("%s():%d shortest distance between origin point (%d, %d) and sector %d is %d. Sector may be corrupt!\n", + EDUKE32_FUNCTION, __LINE__, pos.x, pos.y, *sectnum, nsecs); + walldist = 0x7fff; + } + static int16_t sectlist[MAXSECTORS]; static uint8_t sectbitmap[(MAXSECTORS+7)>>3]; - int16_t nsecs; bfirst_search_init(sectlist, sectbitmap, &nsecs, MAXSECTORS, *sectnum);
This time it builds with no error.
And I can enter the water without dying.
...but the moving cups will clip through me if I sit in the water...
...but that still happens even in the current binary, without this patch.
...so I think the patch is good:
Pull request
forthcoming -
@sleve_mcdichael said in (Patch) Eduke32: E4L4, water in "D-cup Ride" area kills Duke instantly:
Merged, thank you for the investigation and solution.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.