Skip to content

Commit 91038cc

Browse files
Merge branch 'master' into squid-hidden-walls-fix
2 parents caa0229 + f1abee3 commit 91038cc

File tree

6 files changed

+35
-34
lines changed

6 files changed

+35
-34
lines changed

Creatures.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,14 +424,15 @@ void DrawCreatureText(int drawx, int drawy, Stonesense_Unit* creature )
424424
textcol = al_map_rgb(255,255,255);
425425
}
426426

427-
if (!creature->origin->name.nickname.empty() && ssConfig.config.names_use_nick) {
427+
auto name = DFHack::Units::getVisibleName(creature->origin);
428+
if (!name->nickname.empty() && ssConfig.config.names_use_nick) {
428429
draw_textf_border(stonesenseState.font, textcol, drawx, drawy-((WALLHEIGHT*ssConfig.scale)+fontHeight + offsety), 0,
429-
"%s", DF2UTF(creature->origin->name.nickname).c_str());
430+
"%s", DF2UTF(name->nickname).c_str());
430431
}
431-
else if (!creature->origin->name.first_name.empty())
432+
else if (!name->first_name.empty())
432433
{
433434
char buffer[128];
434-
strncpy(buffer,creature->origin->name.first_name.c_str(),127);
435+
strncpy(buffer,name->first_name.c_str(), 127);
435436
buffer[127]=0;
436437
ALLEGRO_USTR* temp = bufferToUstr(buffer, 128);
437438
al_ustr_set_chr(temp, 0, charToUpper(al_ustr_get(temp, 0)));

GUI.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,10 @@ void DoSpriteIndexOverlay()
863863
paintboard();
864864
}
865865

866+
float clockToMs(float clockTicks) {
867+
return clockTicks / (CLOCKS_PER_SEC/1000);
868+
}
869+
866870
void paintboard()
867871
{
868872
DFHack::CoreSuspender suspend;
@@ -939,12 +943,12 @@ void paintboard()
939943

940944
if(ssConfig.config.debug_mode) {
941945
auto& contentLoader = stonesenseState.contentLoader;
942-
draw_textf_border(font, uiColor(1), 10, 3*fontHeight, 0, "Map Read Time: %.2fms", float(stonesenseState.stoneSenseTimers.read_time));
943-
draw_textf_border(font, uiColor(1), 10, 4*fontHeight, 0, "Map Beautification Time: %.2fms", float(stonesenseState.stoneSenseTimers.beautify_time));
944-
draw_textf_border(font, uiColor(1), 10, 5*fontHeight, 0, "Tile Sprite Assembly Time: %.2fms", float(stonesenseState.stoneSenseTimers.assembly_time));
945-
draw_textf_border(font, uiColor(1), 10, 6*fontHeight, 0, "DF Renderer Overlay Time: %.2fms", float(stonesenseState.stoneSenseTimers.overlay_time));
946-
draw_textf_border(font, uiColor(1), 10, 2*fontHeight, 0, "FPS: %.2f", float(1000.0/stonesenseState.stoneSenseTimers.frame_total));
947-
draw_textf_border(font, uiColor(1), 10, 7*fontHeight, 0, "Draw: %.2fms", float(stonesenseState.stoneSenseTimers.draw_time));
946+
draw_textf_border(font, uiColor(1), 10, 3*fontHeight, 0, "Map Read Time: %.2fms", clockToMs(stonesenseState.stoneSenseTimers.read_time));
947+
draw_textf_border(font, uiColor(1), 10, 4*fontHeight, 0, "Map Beautification Time: %.2fms", clockToMs(stonesenseState.stoneSenseTimers.beautify_time));
948+
draw_textf_border(font, uiColor(1), 10, 5*fontHeight, 0, "Tile Sprite Assembly Time: %.2fms", clockToMs(stonesenseState.stoneSenseTimers.assembly_time));
949+
draw_textf_border(font, uiColor(1), 10, 6*fontHeight, 0, "DF Renderer Overlay Time: %.2fms", clockToMs(stonesenseState.stoneSenseTimers.overlay_time));
950+
draw_textf_border(font, uiColor(1), 10, 2*fontHeight, 0, "FPS: %.2f", 1000.0/clockToMs(stonesenseState.stoneSenseTimers.frame_total));
951+
draw_textf_border(font, uiColor(1), 10, 7*fontHeight, 0, "Draw: %.2fms", clockToMs(stonesenseState.stoneSenseTimers.draw_time));
948952
draw_textf_border(font, uiColor(1), 10, 9*fontHeight, 0, "%i/%i/%i, %i:%i", contentLoader->currentDay+1, contentLoader->currentMonth+1, contentLoader->currentYear, contentLoader->currentHour, (contentLoader->currentTickRel*60)/50);
949953

950954
drawDebugInfo(segment);

WorldSegment.cpp

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ const GameState SegmentWrap::zeroState =
1111
{0,0,0},0,{0,0,0},{0,0,0},{0,0,0},0,0
1212
};
1313

14-
ALLEGRO_BITMAP * fog = 0;
15-
1614
void WorldSegment::CorrectTileForSegmentOffset(int32_t& xin, int32_t& yin, int32_t& zin)
1715
{
1816
xin -= segState.Position.x;
@@ -242,24 +240,6 @@ void WorldSegment::DrawAllTiles()
242240
}
243241

244242
auto& ssConfig = stonesenseState.ssConfig;
245-
auto& ssState = stonesenseState.ssState;
246-
247-
if(ssConfig.config.fogenable) {
248-
ALLEGRO_BITMAP* temp = al_get_target_bitmap();
249-
if(!fog) {
250-
fog = al_create_bitmap(ssState.ScreenW, ssState.ScreenH);
251-
al_set_target_bitmap(fog);
252-
al_clear_to_color(premultiply(ssConfig.config.fogcol));
253-
al_set_target_bitmap(temp);
254-
}
255-
if(!((al_get_bitmap_width(fog) == ssState.ScreenW) && (al_get_bitmap_height(fog) == ssState.ScreenH))) {
256-
al_destroy_bitmap(fog);
257-
fog = al_create_bitmap(ssState.ScreenW, ssState.ScreenH);
258-
al_set_target_bitmap(fog);
259-
al_clear_to_color(premultiply(ssConfig.config.fogcol));
260-
al_set_target_bitmap(temp);
261-
}
262-
}
263243

264244
if (ssConfig.config.show_osd) {
265245
DrawCurrentLevelOutline(true);
@@ -291,7 +271,13 @@ void WorldSegment::DrawAllTiles()
291271
}
292272
switch(todraw[i].type) {
293273
case Fog:
294-
DrawBitmap(fog, todraw[i]);
274+
al_draw_filled_rectangle(
275+
todraw[i].dx,
276+
todraw[i].dy,
277+
todraw[i].dx + todraw[i].dw,
278+
todraw[i].dy + todraw[i].dh,
279+
premultiply(ssConfig.config.fogcol)
280+
);
295281
break;
296282
case TintedScaledBitmap:
297283
DrawBitmap(std::get<ALLEGRO_BITMAP*>(todraw[i].drawobject), todraw[i]);
@@ -334,7 +320,7 @@ void WorldSegment::AssembleAllTiles()
334320
int32_t vszmax = segState.Size.z-1; // grabbing one tile +z more than we should for tile rules
335321
for(int32_t vsz=0; vsz < vszmax; vsz++) {
336322
//add the fog to the queue
337-
if(stonesenseState.ssConfig.config.fogenable && fog) {
323+
if(stonesenseState.ssConfig.config.fogenable) {
338324
draw_event d = {
339325
Fog,
340326
std::monostate{},

configs/init.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ performance gains.
123123
[BITMAP_HOLDS:4096]
124124

125125
Stonesense will try to merge all loaded sprites into a single texture, for performance reasons.
126-
if your videocard has low memory, you may want to disable this.
126+
if your videocard has low memory, you may want to disable this. Enabling this feature
127+
will disable mipmapping to prevent sprites from going transparent when zooming out.
127128
[CACHE_IMAGES:NO]
128129

129130
This sets the preferred size of the internal image cache. If your videocard does not support it,

docs/changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,13 @@ Template for new versions:
4747
- `stonesense`: screen dimensions are now properly set when overriden by a window manager
4848
- `stonesense`: fixed glass cabinets and bookcases being misaligned by 1 pixel
4949
- `stonesense`: fixed unrevealed walls being hidden by default
50+
- `stonesense`: vampires no longer show their true name when they shouldn't
51+
- `stonesense`: fixed debug performance timers to show milliseconds as intended
52+
- `stonesense`: ``CACHE_IMAGES`` now disables mipmapping, stopping sprites from going transparent
5053

5154
## Misc Improvements
5255
- `stonesense`: improved the way altars look
56+
- `stonesense`: fog no longer unnecessarily renders to a separate bitmap
5357

5458
## Removed
5559

main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,12 @@ static void* stonesense_thread(ALLEGRO_THREAD* main_thread, void* parms)
399399
if(ssConfig.config.software) {
400400
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP|_ALLEGRO_ALPHA_TEST|ALLEGRO_MIN_LINEAR|ALLEGRO_MIPMAP);
401401
} else {
402-
al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR|ALLEGRO_MIPMAP);
402+
// FIXME: When we have ability to set a maximum mipmap lod,
403+
// do so when cache_images is enabled to prevent sprites going transparent.
404+
// Until then, disable mipmapping when using an image cache.
405+
al_set_new_bitmap_flags(
406+
ALLEGRO_MIN_LINEAR
407+
|(ssConfig.config.cache_images ? 0 : ALLEGRO_MIPMAP));
403408
}
404409

405410
display = al_create_display(stonesenseState.ssState.ScreenW, stonesenseState.ssState.ScreenH);

0 commit comments

Comments
 (0)