Jörg Hinrichs wrote:
Hi,

Dragonking sent me a replay some days ago that at the end crashes to
desktop. It does not always do that, though, it crashes about every second
time. That makes it not very likely that the reason for this is directly
found in the replay code. I also looked at stderr.txt and i found some error
messages about missing free channels for sound.
The problem is that we get the current team using teams_[player_number_], where teams_ is 0-based (a vector), while player_number_ is 1-based. We need to replace it with teams_[player_number_-1].

I have committed a fix, and encapsulated this into a private inline function called current_team() for convenience.

The crash occurred inconsistently because sometimes the memory at the end of the vector happened to contain data that would avoid a crash.

Having a mix of 0-based and 1-based containers and indices is one of the worst code-level problems in Wesnoth, especially with the number of coders we now have working on the project. (At least it's something I will look out for next time!)

David


Reply via email to