[aquaria] crash :/

Mathias Panzenböck grosser.meister.morti at gmx.net
Mon Apr 25 18:38:41 EDT 2011


I think I know what causes the crash and I found a comment of yours about this in Aquaria/Game.cpp 
in Game::onCook:

// FIXME: It _looks_ like *ing should be the actual inventory
// object, but playing it safe because I'm not sure.  --achurch

The thing is, various methods[1] take pointers of Continuity::ingredients elements. But the method 
Continuity::removeEmptyIngredients[2] copies the IngredientData instances in this vector around, so 
the old pointers will be invalidated!

Is IngredientData::held a simple form of refcounter or has it any semantics inside the game logic?

Anyway, I propose IngredientData should be always put in a recfounting smartpointer and not 
referenced by a normal pointer[3], which would eliminate all problems.

Also, there are much to many public fields in all the classes, if you ask me.

	-panzi

[1] Continuity::getIngredientHeldByName and Continuity::getIngredientByIndex
[2] Also this method can be simplified a lot, changing it from runtime O(n^2) and memory O(n) to 
runtime O(n) and memory O(1).
[3] In cases where a reference and not a copy is needed.


On 04/24/2011 05:04 AM, Andrew Church wrote:
>> Just wanted to report a segmentation fault. I wasn't running in a debugger so I don't have a stack
>> trace. It did happen during cooking. Cooking seems strange lately. When I combine two things these
>> things don't go away and I have to click around until I can combine other things. This was exactly
>> the moment of the crash.
>
> That's designed behavior (except the crash, of course), to speed up cooking
> of the same item multiple times.  If you can reproduce the crash, please
> post a backtrace.
>
>    --Andrew Church
>      achurch at achurch.org
>      http://achurch.org/
> _______________________________________________
> aquaria mailing list
> aquaria at icculus.org
> http://icculus.org/mailman/listinfo/aquaria
>



More information about the aquaria mailing list