Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 27 Feb 2010
Offline Last Active Aug 25 2014 02:53 PM

Posts I've Made

In Topic: Boost serialization exception problems

06 August 2014 - 09:49 AM

I have limited experience with boost::serialization but I would probably start by reducing the amount of work you do in the serialization function to home in on exactly which type is causing the issues. Once you know what exact type is causing the problems it should be much easier to figure out what goes wrong.


Thanks for the advice - I did this and apparently it was one of the booleans that was causing the problem (the exception code had me looking in all the wrong places!).

My tile factory function creates a Tile object and then sets all its variables depending on what type of tile it is; due to an oversight I was apparently setting a bool to an uninitialised value, and though it wasn't causing any ingame problems, Boost didn't like trying to serialize it. I'm still a bit confused about why it was throwing that particular exception code but all's well that ends well.

In Topic: Segfault upon exiting application

26 July 2014 - 03:56 PM

C++? Check your destructors of global objects, they run after main returns.


Ah, yeah that seems like it would be it. I recently made an abstract class from which the player and the enemies derive so that they can share common functions, and the player object is global for the sake of convenience. What issue with the destructors is this causing? (Despite now knowing where the problem lies I'm still not sure how I can fix it).


Thanks for your help.

In Topic: Management of game objects

23 March 2014 - 01:46 PM

Thanks both for your replies.


If you're using pointers, there isn't anything that stops you from having both a master Entity * container and separate containers for specific types. You can iterate over the master list when you want to batch process everything and over the type containers when you just want projectiles or enemies.


How would I handle deletion of objects in this scenario? Say we update everything in the master list and determine that an enemy's life has reached zero, so we erase it from the vector. Isn't there now a pointer in the Enemies type container which points to an unused memory location? Apologies if there is a simple answer to this that I am not seeing.

In Topic: C++ vector of boost::weak_ptr troubles

04 August 2013 - 07:19 AM

edit: how the hell did I post this twice

In Topic: C++ vector of boost::weak_ptr troubles

04 August 2013 - 07:17 AM

Thanks everyone for your responses. I am still struggling with this, unfortunately.


My first guess is some odd behavior with scoping.  Basically I don't remember for sure the scope rule but I bet if you change the code as follows, it may at least give you some better information on what the problem is:
void Ship::determine_next_target()
    std::vector< boost::weak_ptr >::iterator it = aggro_vector.begin();
    while(it != aggro_vector.end()) {
        boost::shared_ptr this_ship( (*it).lock() );
        if ( this_ship ) {
        } else {
            it = aggro_vector.erase(it);


That's actually the exact code I was using to begin with; I just simplified it for the purpose of posting the thread! It doesn't work in the same way that the original code doesn't work.



shared_ptr might be emtpy,


It isn't, I stuck a call to cout in the if {} block that checks some properties of the object like its XY position (std::cout<<this_ship->x<<":"<<this_ship->y<<std::endl;) and it returned the correct values, so shared_ptr is functioning properly and is pointing at a valid object.



 Where exactly does it crash? In the called function, on the function call itself, next loop iteration?


On the function call itself. I don't really know what to make of that.