1.13 Mac CTD on attack logic (?)

Having trouble with the game? Report issues and get help here. Read this first!

Moderator: Forum Moderators

Forum rules
Before reporting issues in this section, you must read the following topic:
Post Reply
Jozrael
Posts: 1034
Joined: June 2nd, 2006, 1:39 pm
Location: NJ, USA.

1.13 Mac CTD on attack logic (?)

Post by Jozrael »

Playing "2p/3p vs Survival" on 1.13.
2p_-_vs_Survival-Auto-Save7.gz
(42.3 KiB) Downloaded 227 times
^ this autosave at start of turn will not crash.
2p_-_vs_Survival_Turn_7.gz
(42.49 KiB) Downloaded 224 times
^ this save after moving one unit a couple hexes will crash.
Dump.txt
(68.37 KiB) Downloaded 203 times
^ Quick glance looks like attack logic. Haven't debugged wesnoth before, so not sure where I should be starting/what I can ignore.
Jozrael
Posts: 1034
Joined: June 2nd, 2006, 1:39 pm
Location: NJ, USA.

Re: 1.13 Mac CTD on attack logic (?)

Post by Jozrael »

Subsequently it didn't crash, but threw an error in https://github.com/wesnoth/wesnoth/blob ... target.lua on line 23, target was nil. So get_closest_enemy didn't properly return. Is wesnoth coding practice here to catch nils or ensure they're never sent?
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: 1.13 Mac CTD on attack logic (?)

Post by mattsc »

Jozrael wrote:Is wesnoth coding practice here to catch nils or ensure they're never sent?
I'm not sure whether we have a strict coding practice for this, but I think it makes sense that ai_helper.get_closest_enemy() returns nil if it does not find such an enemy. And apparently I thought so 4 years ago too, as I clearly intentionally changed the behavior to that effect here.

So that line 23 should be changed to
if target then
I can change that, or if you want you can put in a change pull request since you found the error. Let me know and thanks for finding this.

PS: Btw, I read 'CTD' in the title as 'chance to die'. Took me a while to figure out what you were talking about. :P
Jozrael
Posts: 1034
Joined: June 2nd, 2006, 1:39 pm
Location: NJ, USA.

Re: 1.13 Mac CTD on attack logic (?)

Post by Jozrael »

https://github.com/wesnoth/wesnoth/pull/2072 submitted. Unsure if it should be changed to the the line in the comment.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: 1.13 Mac CTD on attack logic (?)

Post by mattsc »

Merged. Thanks for finding the problem and fixing it. (And I replied to your question in the comments of the pull request.)
Post Reply