Advertisement Jump to content
Sign in to follow this  

ugh, design problem ... everything problem ...

This topic is 5073 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello! ok im writing a basic framework for a game and have various systems such as a scheduler, a scene manager, a console type system, and a task system. each system has a list of objects that are of some interface. ie objects that are to be rendered inherit from an interface which gives them the ability to draw. same kinda idea for all systems. so objects have refrences in multiple places. so with some help i implemented a polling engine so objects that return false on poll are removed from each system and then finally deleted at the end of the frame. for some insane reason no matter what i did i got run time errors when deleteing the objects. even though it was clearly evident (from logging list sizes etc) that the objects were actually removed from each systems list and the systems were not trying to access dead objects. ok so i cahnged the design a little bit and added the acctual systems into the polling engine and the poller would update and validate each system by passing a list of dead objects to that system and that class could remove those dead objects from their lists. here's some code ... rather ugly ...
void CPollingDevice::update() {
	list<IPEntity*> listNullPEntities;
	ITERATE(IPEntity*, m_listPEntities, i) {
		if (!(*i)->poll()) {
	ITERATE(IPSystem*, m_listPSystems, i) {
	ITERATE(IPEntity*, listNullPEntities, i) {
		delete *i;

... sorry for the hungarian notation and macros :) ... so on validate objects are removed from the system in question. and again when deleteing the objects after they have been removed from every list it all goes to hell. the debugger then points me to some line in the xmemory header that just laughs in my face. what should i do? tear it down start again?! what's going on here? is there any way i can salvage this? any suggestions ideas are very much appreciated becasue im loosing my mind! thanks in advance.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!