Kurosu a écrit : > Kurosu a écrit : >> Maybe this cache is storing twice something. > > Yes, this is what happens. I have found at least 3 such risky situations. > > I've added something to track duplicated entries in > Map::ToRedrawOnScreen. It has spotted the following contexts when this > duplicate insertion occurs: > 1) GameLoop::Draw() -> ExplosionSmoke::Draw() -> Sprite::Draw() -> > Sprite::DrawXY -> Sprite::Blit (several) -> Map::ToRedrawOnScreen() > 2) Game::MessageEndOfGame() -> Menu::Display() -> WidgetList::Update() > -> Widget::Update() -> Label::Draw() -> Text::DrawCenterTop() -> > Text::DrawTopLeft(int, int) -> Text::DrawTopLeft(const Point2i&) > 3) ButtonText::Draw -> Text::DrawCenter() > > The attached patch removes all of the asserts in std::sort for MSVC, > but the solution is hardly better (having to go through a list and > matching rectangles). Instead, determining the source of the > duplication above might be better...
I'm not sure it's always possible to remove the duplicates. It should be possible if on each layer (4 layers: sky, wind particles, ground, all other objects), 2 objects of the same size can not be at a same position => collisions between all objects of a same layer. I'm pretty sure that not all particles collides, so... Calling the SDL Blit function costs a lot. The purpose of method Map::OptimizeCache() is to identify duplicate entries and more generally, useless entries. For instance, it's useless to redraw the sky for a rectangle A (10, 10, 40, 40) and a rectangle B (5, 5, 60, 60), redrawing for rectangle B is sufficient. So, in my opinion, the detection of duplicated rectangles must be done in Map::OptimizeCache(). Methods Map::ToRedrawOnScreen() and Map::ToRedrawOnMap() should stay silly methods. Regards, Matt (gentildemon) _______________________________________________ Wormux-dev mailing list Wormux-dev@gna.org https://mail.gna.org/listinfo/wormux-dev