Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/localization/localize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ bool *Lcl_unexpected_tstring_check = nullptr;
// NOTE: with map storage of XSTR strings, the indexes no longer need to be contiguous,
// but internal strings should still increment XSTR_SIZE to avoid collisions.
// retail XSTR_SIZE = 1570
// #define XSTR_SIZE 1936 // This is the next available ID
// #define XSTR_SIZE 1939 // This is the next available ID

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line conflicts with master now. The Android build (#6992) took 1936-1939 for the touch overlay options in osapi.cpp, so the next free ID on master is 1940. With the three strings below moved to 1940-1942 this becomes:

Suggested change
// #define XSTR_SIZE 1939 // This is the next available ID
// #define XSTR_SIZE 1943 // This is the next available ID

Heads up: my #7998 also claims 1940-1945, so whichever of the two lands second will need to renumber.


// struct to allow for strings.tbl-determined x offset
// offset is 0 for english, by default
Expand Down
59 changes: 46 additions & 13 deletions freespace2/freespace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@

#include <SDL3/SDL_main.h>

#include <algorithm>
#include <cinttypes>
#include <stdexcept>

Expand Down Expand Up @@ -367,7 +368,9 @@ fix FrametimeOverall = 0;
int Show_framerate = 0;
#endif

int Framerate_cap = 120;
static constexpr int MIN_FRAMERATE_CAP = 15;
static constexpr int MAX_FRAMERATE_CAP = 120;
int Framerate_cap = 120; // Default value

// for the model page in system
extern void model_page_in_start();
Expand Down Expand Up @@ -1911,6 +1914,39 @@ void game_init()

mod_table_init(); // load in all the mod dependent settings

// Keep the old MaxFPS setting as the default when no Graphics.FramerateCap value is saved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thing, not blocking: when a mod sets this option in default_settings.tbl, the parser runs after this and replaces the player's MaxFPS. MaxFPS=30 plus a mod default of 45 ran at 45. If MaxFPS is meant to win, as this comment says, reading it between default_settings_init() and loadInitialValues() would do that.

const auto max_fps = os_config_read_uint(nullptr, NOX("MaxFPS"), 0);
if (max_fps >= MIN_FRAMERATE_CAP && max_fps <= MAX_FRAMERATE_CAP) {
Framerate_cap = static_cast<int>(max_fps);
}

static auto FramerateCapOption __UNUSED = options::OptionBuilder<int>("Graphics.FramerateCap",
std::pair<const char*, int>{"Frame Rate Limit", 1936},
std::pair<const char*, int>{"Maximum frames per second. Vertical sync may lower the actual frame rate.", 1937})
Comment on lines +1924 to +1925

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1936 and 1937 are "Touch Overlay" and its description on master, so a translation would show the wrong text here. Fixing the merge conflict on the localize.cpp comment alone would keep these duplicates without any warning.

Suggested change
std::pair<const char*, int>{"Frame Rate Limit", 1936},
std::pair<const char*, int>{"Maximum frames per second. Vertical sync may lower the actual frame rate.", 1937})
std::pair<const char*, int>{"Frame Rate Limit", 1940},
std::pair<const char*, int>{"Maximum frames per second. Vertical sync may lower the actual frame rate.", 1941})

.category(std::make_pair("Graphics", 1825))
.level(options::ExpertLevel::Advanced)
.range(MIN_FRAMERATE_CAP, MAX_FRAMERATE_CAP)
.default_func([]() { return Framerate_cap; })
.deserializer([](const json_t* value) {
int saved;
json_error_t err;
if (json_unpack_ex(const_cast<json_t*>(value), &err, 0, "i", &saved) != 0) {
throw json_exception(err);
}
// Clamp saved out-of-range values
return std::clamp(saved, MIN_FRAMERATE_CAP, MAX_FRAMERATE_CAP);
})
.display([](int value) { return Cmdline_NoFPSCap ? SCP_string(XSTR("Unlimited", 1938)) : std::to_string(value); })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1938 is "Touch Overlay Opacity" on master.

Suggested change
.display([](int value) { return Cmdline_NoFPSCap ? SCP_string(XSTR("Unlimited", 1938)) : std::to_string(value); })
.display([](int value) { return Cmdline_NoFPSCap ? SCP_string(XSTR("Unlimited", 1942)) : std::to_string(value); })

.parser([]() {
int value;
stuff_int(&value);
Framerate_cap = std::clamp(value, MIN_FRAMERATE_CAP, MAX_FRAMERATE_CAP);
})
.bind_to(&Framerate_cap)
.importance(71)
.flags({options::OptionFlags::RangeTypeInteger})
.finish();

// Must be run after mod table is parsed so we know the value of Using_in_game_options
// Must be run before everything else inits so we can init those with the correct
// default values or user preferences
Expand Down Expand Up @@ -1945,6 +1981,11 @@ void game_init()
std_init_standalone();
}

if (Cmdline_NoFPSCap) {
options::OptionsManager::instance()->setOverride("Graphics.FramerateCap",
std::unique_ptr<json_t>(json_integer(Framerate_cap)), "-no_fps_capping");
}

// verify that he has a valid ships.tbl (will Game_ships_tbl_valid if so)
verify_ships_tbl();

Expand All @@ -1959,15 +2000,7 @@ void game_init()
Use_fullscreen_at_startup = os_config_read_uint( nullptr, NOX("ForceFullscreen"), 1 );
#endif

// change FPS cap if told to do so (for those who can't use vsync or where vsync isn't enough)
uint max_fps = 0;
if ( (max_fps = os_config_read_uint(nullptr, NOX("MaxFPS"), 0)) != 0 ) {
if ( (max_fps > 15) && (max_fps < 120) ) {
Framerate_cap = (int)max_fps;
}
}

Asteroids_enabled = 1;
Asteroids_enabled = 1;

/////////////////////////////
// SOUND INIT START
Expand Down Expand Up @@ -3004,7 +3037,7 @@ DCF(framerate_cap, "Sets the framerate cap")
if (dc_optional_string_either("help", "--help")) {
dc_printf("Usage: framerate_cap [n]\nwhere n is the frames per second to cap framerate at.\n");
dc_printf("If n is 0 or omitted, then the framerate cap is removed\n");
dc_printf("[n] must be from 1 to 120.\n");
dc_printf("[n] must be from 1 to %d.\n", MAX_FRAMERATE_CAP);
process = false;
}

Expand All @@ -3026,8 +3059,8 @@ DCF(framerate_cap, "Sets the framerate cap")
Framerate_cap = 0;
}

if ((Framerate_cap < 0) || (Framerate_cap > 120)) {
dc_printf( "Illegal value for framerate cap. (Must be from 1-120) \n");
if ((Framerate_cap < 0) || (Framerate_cap > MAX_FRAMERATE_CAP)) {
dc_printf("Illegal value for framerate cap. (Must be from 1-%d) \n", MAX_FRAMERATE_CAP);
Framerate_cap = 0;
}

Expand Down
Loading