Dwarf Fortress Bug Tracker - Dwarf Fortress
View Issue Details
0011871Dwarf FortressTechnical -- Renderingpublic2022-05-29 09:192022-06-01 19:09
PCWindows 1021H2
0011871: Too high FPS displayed as negative.
If your FPS (computational frames per second) are higher than 210000 something, it starts to display as negative and goes to lover absolute value. I got about -47500 FPS.
1) In init.txt options set FPS_CAP to 0 to remove the cap.
2) Start the game.
3) Skip the intro since it's always capped.
4) As soon as the main menu shows up, look at your FPS counter go up to about 210000 and then going negative.
I'm sure it have something to do with displaying FPS counter as a signed integer. Though 210000 is a strange boundary. What integer size gives you 210000 boundary? The closest I've got is 19 bits, with maximum positive of 262143. But who stores integer in 19 bits?
No tags attached.
Issue History
2022-05-29 09:19S0ZDATELNew Issue
2022-06-01 18:54lethosorSummaryToo high UPS displayed as negative. => Too high FPS displayed as negative.
2022-06-01 18:54lethosorDescription Updatedbug_revision_view_page.php?rev_id=16790#r16790
2022-06-01 18:54lethosorSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=16792#r16792
2022-06-01 18:54lethosorAdditional Information Updatedbug_revision_view_page.php?rev_id=16794#r16794
2022-06-01 19:09lethosorNote Added: 0041260
2022-06-01 19:09lethosorAssigned To => lethosor
2022-06-01 19:09lethosorStatusnew => acknowledged
2022-06-28 11:28lethosorNote Edited: 0041260bug_revision_view_page.php?bugnote_id=0041260#r16796
2022-06-28 11:28lethosorNote Edited: 0041260bug_revision_view_page.php?bugnote_id=0041260#r16797
2022-06-28 11:28lethosorNote Edited: 0041260bug_revision_view_page.php?bugnote_id=0041260#r16798

2022-06-01 19:09   
(edited on: 2022-06-28 11:28)
(Replaced with "FPS" per standard DF terminology.)

I was able to reproduce on Linux by editing the FPS and GFPS caps in-memory with DFHack - I also needed to increase my GFPS cap to 363 or higher to see this overflow.

This part of DF actually has its source code included in the g_src folder on Linux. The relevant calculation:

void enablerst::do_update_fps(queue<int> &q, int &sum, int &last, int &calc) {
while (q.size() > 50 && sum > 10000) {
    sum -= q.front();
  const int now = SDL_GetTicks();
  const int interval = now - last;
  sum += interval;
  last = now;
  if (sum)
    calc = (int)q.size() * 1000 / sum;

where "calc" is the output parameter that gets displayed on-screen. It's not a single integer that's tracked, so the conditions that cause an overflow are more complicated (but it is not due to being stored as a 19-bit integer or anything like that).