Menu

#77 atanks-6.6 crashes on land creation

General
closed-fixed
None
7
2021-08-20
2021-08-20
Sven Eden
No

When trying to actually start a game, atanks crashes with a segmentation fault, because an illegal index in env.slope is accessed.

The following diff fixes the issue.
There were no "distortions" or anything like that in the landscape afterwards, so there doesn't seem to be a bigger underlying issue.

--- src/land.cpp.old 2021-08-20 11:00:25.605198565 +0200
+++ src/land.cpp 2021-08-20 11:01:44.784199236 +0200
@@ -162,7 +162,7 @@
double maxTop = std::max(depthStrip[0][depth],
depthStrip[1][depth]);
double btdiff = maxTop - minBot;
- double i = (y - bot) / btdiff;
+ double i = (y - bot) / ( (btdiff > 1.) ? btdiff : 1. );
double a1 = RAD2DEG(atan2(depthStrip[0][depth - 1]
- depthStrip[1][depth - 1], 1.0))
+ 180.;

Cheers

Sven

Discussion

  • Sven Eden

    Sven Eden - 2021-08-20
    • assigned_to: Jesse Smith
     
  • Jesse Smith

    Jesse Smith - 2021-08-20

    Confirmed. Tested the patch and it's working. Will commit this to the repo.

     
  • Jesse Smith

    Jesse Smith - 2021-08-20
    • status: open --> closed-fixed