OpenXcom Forum
Contributions => Programming => Topic started by: SupSuper on July 28, 2010, 01:21:46 am
-
The latest in the series of weird bugs from another dimension, comes: VANISHING COUNTRY NAMES. So recently I introduced detail on the globe. Regions, country borders, country names, etc. The weird thing is, the country names randomly vanish when the globe is rotated in certain positions.
Now you see them:
(https://i6.photobucket.com/albums/y237/supsuper/OpenXcom/openxcom_texton.png)
Now you don't:
(https://i6.photobucket.com/albums/y237/supsuper/OpenXcom/openxcom_textoff.png)
Amazing! :o
It's probably something stupidly obvious but I'm so blinded that I can't see it. All the math should be right, so should the coordinates. After all the whole globe relies on the same formulas, and only the labels are vanishing, not the whole thing.
The code that renders the labels is in Globe.cpp, lines 462-482:
https:// Draw the country names
if (_zoom >= 2)
{
Sint16 x, y;
for (map<LangString, Country*>::iterator i = _save->getCountries()->begin(); i != _save->getCountries()->end(); i++)
{
https:// Don't draw if label is facing back
if (pointBack(i->second->getLabelLongitude(), i->second->getLabelLatitude()))
continue;
https:// Convert coordinates
polarToCart(i->second->getLabelLongitude(), i->second->getLabelLatitude(), &x, &y);
Text *label = new Text(_res->getFont("BIGLETS.DAT"), _res->getFont("SMALLSET.DAT"), 80, 9, x - 40, y);
label->setPalette(getPalette());
label->setAlign(ALIGN_CENTER);
label->setText(_res->getLanguage()->getString(i->first));
label->setColor(Palette::blockOffset(15)-1);
label->blit(_markers);
}
}
All the labels are centered around single polar points pulled from the country data. As far as I can tell, the problem only seems to happen on the 3 biggest zoom levels.
-
If you use this line
label->blit(this);
instead of
label->blit(_markers);
the problem goes away...
I know it's not the answer at the minute, but it would definately indicate the problem is with blitting to _markers
-
If you use this line
label->blit(this);
instead of
label->blit(_markers);
the problem goes away...
I know it's not the answer at the minute, but it would definately indicate the problem is with blitting to _markers
Thanks, that lead me to the problem at least. I forgot I was locking the surface for the pixel-level operations (drawing lines and stuff) but that stops the blits (drawing the text), so I had to switch it around. The weird thing is the text still working half the time when the surface is locked, but I guess it's one of those "no guarantee" situations. :P