Sign in to follow this  

A bottleneck problem

This topic is 1859 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

In my bomberman clone, I want bombs to explode when they get hit by other bombs.
[source lang="cpp"]void Bomb::handleMessage(const Message & msg)
{
if(msg.msg==MessageType::HIT_BY_BOMB)
{
alive=false;
gameWorld->cancelAllMessagesTo(this);
gameWorld->getGameMap().onExit(currentLoc.x, currentLoc.y, this);


//I'm having problem here...
for(Entity * eachEntity : gameWorld->getAllEntitiesWithin(currentLoc.x, currentLoc.y, range);
gameWorld->getPostOffice().sendMessage(this, eachEntity, MessageType::HIT_BY_BOMB);
}
}[/source]

As you can see when a bomb receives a message that it got hit by an another bomb, it sends out messages to every single entities within the range of the bomb.

[attachment=12831:Untitled.png]
This is how messages would get delivered if bomb A explodes
A->C, E
C->A, B, D, E
E->C, A
B-> C, D
D->C, B
...

As you can see, there are many redundant message delivery. This slows down my game so much.
What is a better design to this problem?

Share this post


Link to post
Share on other sites

This topic is 1859 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this