Author Topic: [Solved] Vanishing country names  (Read 8269 times)

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
[Solved] Vanishing country names
« 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:



Now you don't:



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:
Code: [Select]
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.
« Last Edit: July 28, 2010, 05:42:48 pm by SupSuper »

Offline pmprog

  • Commander
  • *****
  • Posts: 647
  • Contributor
    • View Profile
    • Polymath Programming
Re: [Task] Vanishing country names
« Reply #1 on: July 28, 2010, 09:33:39 am »
If you use this line
Code: [Select]
label->blit(this);instead of
Code: [Select]
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

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: [Task] Vanishing country names
« Reply #2 on: July 28, 2010, 05:52:03 pm »
If you use this line
Code: [Select]
label->blit(this);instead of
Code: [Select]
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