actor: Free old shells and bazooka remainings #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
make: Build debugging symbols
It is very hard to debug issues like segfaults without debugging
symbols and also creating a debug package is not possible this way.
So add the gcc '-g' option to build them.
actor: Fix a segfault in movebullet() ricochet handling
In the ricochet handling in movebullet() sptr is the return value
of spawnactor(). It is dereferenced directly but might be NULL.
The check for NULL is missing and this causes a segfault when
reaching MAX_ACTOR (2048) by shooting a lot of bullets with the
Uzi with unlimited ammo. So return if spawnactor() returns NULL.
actor: Free old shells and bazooka remainings
All actors are stored in an array in static memory. MAX_ACTOR is at
2048. Shells and bazooka remainings are also actors and remain for
the time of the current game. If shooting around two minutes
continuously with the Uzi with unlimited ammo, MAX_ACTOR can be
reached. This makes all weapons ineffective as no more actors can
be spawned.
So free the 200 oldest shells and bazooka remainings if the actor
array is completely filled. Iterate the actors and shift left all
subsequent actors by one if a shell or bazooka remaining is found.
This might segfault if actors are still accessed. So only do that
if further shells or bazooka remainings have to be spawned as these
aren't accessed afterwards. Reserve the last 100 actors for
temporary actors.
Fixes: GitHub issue #2