bonkmaykr

@bonkmaykr@canithesis.org

19 Male
CEO Canithesis Interactive, sysadmin Worlio LLC
wipEout and THE FINALS fan
Linux enthusiast, Java / C# / C++ Dev
Old computer freak, FSF donor
Missouri, United States

I made the Firestar Mod Manager for Playstation Vita. Currently working on a danmaku shooter game called "Time Falcon". My posts can range anywhere from deep nerd thoughts to brainless shitposting.

Followers of all kinds welcome - just be respectful. We respect the first amendment here. That being said, I do not get along well with Nazis or weird conspiracy theorists so be nice.
XMPP/Jabberbonkmaykr@worlio.com
Embark IDmadaraosenpai#5926

40 following 24 followers

1 ★ 0 ↺
in reply to »

bonkmaykr »
@bonkmaykr@canithesis.org

Sorry, I tried to specify it but it got blocked by the filters since it has the > brackets.

The vector stores o_worldObjectGeneric*, with the asterisk. So there should be no slicing.

    ...

    Coyote »
    @Coyote@social.singing.dog

    @bonkmaykr My next hunch would be if you're doing any kind of multithreading or maybe accidentally using static_cast instead of dynamic_cast.

      ...
      1 ★ 0 ↺

      bonkmaykr »
      @bonkmaykr@canithesis.org

      I haven't used either of those but I should look them up to see what the difference is

      I managed to figure it out, IDK the low-level specifics but basically since updating world objects happens in the middle of a for() that reads the vector, it would see the new object get added to the end of the vector and try to call it's updateMe() while the vector was getting shifted around. Adding a lag of one game tick before each new object spawns by giving them a queue to wait in helped work around the issue. So I just do this before each tick:

      for (globals::objects::o_worldObjectGeneric* o : w_contentQueue) w_content.push_back(o); w_contentQueue.clear();

      ...

      Coyote »
      @Coyote@social.singing.dog

      @bonkmaykr You should generally avoid adding to a vector while iterating over it, especially if you're using the for(auto x : y) syntax. What can happen is that when you try to push onto the vector and there's no more space, the vector allocates a new buffer and moves all the objects into it. This doesn't change the for loop iterators, so your for loop continues to loop over the destructed and freed objects.

        History