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

Better debugging for mutable special placement #51504

Merged
merged 1 commit into from
Sep 11, 2021

Conversation

jbytheway
Copy link
Contributor

@jbytheway jbytheway commented Sep 10, 2021

Summary

None

Purpose of change

When placement of mutable overmap specials fails, it's hard to figure out why. The small amount of context previously given in the debugmsg wasn't enough. I did have some further debug printfs in non-compiled code behind a #if, but that's no use to people who can't compile the game themselves, nor does it help debug failures in CI, such as happened in #51494 here.

Describe the solution

Reformulate the code so that these more detailed messages are always saved (rather than printed) and when a placement error occurs, it includes a full history of the placement to allow for debugging.

I also optimized the placement slightly; now it automatically moves to the next phase of placement when one phase is exhausted.

Describe alternatives you've considered

Rather than formatting the string always, but only using it in the event of an error, I considered saving all the info needed to format the string and doing it later, but that would be messier code, and I don't think any of this string formatting is particularly expensive. In particular, there are no translations involved.

Testing

I tweaked the anthill special definition to force a placement error and got the detailed debugmsg as expected.

Additional context

I've been unable to easily reproduce the placement failures locally (I did so once, but it wasn't repeatable), so I'm hoping that by PRing this I can debug the issue via any further CI failures that occur.

Unfortunately this change is going to conflict with the fixes in #51497 and that one is more important, so I'm going to mark this as draft until that's merged and I can rebase this atop it. Now rebased.

When placement of mutable overmap specials fails, it's hard to figure
out why.  The small amount of context previously given in the debugmsg
wasn't enough.  I did have some further debug printfs in non-compiled
code behind a #if, but that's no use to people who can't compile the
game themselves, nor does it help debug failures in CI.

Reformulate the code so that these more detailed messages are always
saved (rather than printed) and when a placement error occurs, it
includes a full history of the placement to allow for debugging.
@jbytheway jbytheway force-pushed the anthill_spawn_failure branch from 8c845bf to cc93cab Compare September 10, 2021 14:54
@jbytheway jbytheway marked this pull request as ready for review September 10, 2021 14:54
@jbytheway
Copy link
Contributor Author

#51497 was merged, so rebased this and marked ready for review.

@actual-nh actual-nh added [C++] Changes (can be) made in C++. Previously named `Code` Code: Debug Debugging and troubleshooting the game, also includes the debug menu Map / Mapgen Overmap, Mapgen, Map extras, Map display labels Sep 10, 2021
@kevingranade kevingranade merged commit 1778ebd into CleverRaven:master Sep 11, 2021
@jbytheway jbytheway deleted the anthill_spawn_failure branch September 11, 2021 10:59
@eltank
Copy link
Contributor

eltank commented Sep 12, 2021

I won the bug lottery and had this trigger in one of my PRs. Here is the log:
testlog.txt

@jbytheway
Copy link
Contributor Author

Thanks for letting me know. I've downloaded it and will take a look when I get the chance.

@jbytheway
Copy link
Contributor Author

I believe I found the problem and will PR a putative fix shortly. Still not sure why it was being non-deterministic locally, though. I might have to do some digging into that at some point...

Venera3 pushed a commit to Venera3/Cataclysm-DDA that referenced this pull request Sep 21, 2021
When placement of mutable overmap specials fails, it's hard to figure
out why.  The small amount of context previously given in the debugmsg
wasn't enough.  I did have some further debug printfs in non-compiled
code behind a #if, but that's no use to people who can't compile the
game themselves, nor does it help debug failures in CI.

Reformulate the code so that these more detailed messages are always
saved (rather than printed) and when a placement error occurs, it
includes a full history of the placement to allow for debugging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Debug Debugging and troubleshooting the game, also includes the debug menu Map / Mapgen Overmap, Mapgen, Map extras, Map display
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants