Skip to content

Implement pedantic shutdown options for gamelogic processes#3327

Merged
slipher merged 2 commits intoUnvanquished:masterfrom
slipher:pedanticshutdown
Mar 1, 2025
Merged

Implement pedantic shutdown options for gamelogic processes#3327
slipher merged 2 commits intoUnvanquished:masterfrom
slipher:pedanticshutdown

Conversation

@slipher
Copy link
Copy Markdown
Contributor

@slipher slipher commented Feb 26, 2025

When g_pedanticShutdown/cg_pedanticShutdown is off (default) and the gamelogic is running in a separate process, skip shutdown code whose only purpose is to deallocate memory. This saves time and avoids spamming anyone with shutdown errors in production for cleanup issues like with Lua (#3078) or RmlUi (#1693).

@illwieckz
Copy link
Copy Markdown
Member

Just a style remark, for this kind of code:

#ifndef BUILD_VM_IN_PROCESS
static Cvar::Cvar<bool> cg_pedanticShutdown("cg_pedanticShutdown",
	"run useless shutdown procedures in cgame process",
	Cvar::NONE,
#ifdef USING_SANITIZER
	true);
#else
	false);
#endif
#endif

I prefer it written this way (no preprocessor in the middle of something):

#ifndef BUILD_VM_IN_PROCESS
#ifdef USING_SANITIZER
static const bool defaultPedanticShutdown = true;
#else
static const bool defaultPedanticShutdown = false;
#endif
static Cvar::Cvar<bool> cg_pedanticShutdown("cg_pedanticShutdown",
	"run useless shutdown procedures in cgame process",
	Cvar::NONE, defaultPedanticShutdown);
#endif

…and even GitHub syntax coloring prefers it as well.

See also:

At the time I also noticed that VIM also prefers it that way.

And outside of coloring, this makes easier to read the code.

@slipher
Copy link
Copy Markdown
Contributor Author

slipher commented Feb 27, 2025

Personally my reaction is that those syntax highlighters should git gud. But I will do it if you give me LGTM modulo the style comment 😛

@illwieckz
Copy link
Copy Markdown
Member

Personally my reaction is that those syntax highlighters should git gud. But I will do it if you give me LGTM modulo the style comment 😛

Is this blackmail? 😛

LGTM modulo the style comment anyway, that syntax is the only thing I have something to say against.

Copy link
Copy Markdown
Member

@illwieckz illwieckz left a comment

Choose a reason for hiding this comment

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

LGTM modulo the style.

@illwieckz
Copy link
Copy Markdown
Member

illwieckz commented Feb 27, 2025

Note that my new lines in my examples are not part of my recommendation, it's just to workaroud GitHub not wrapping lines and keep my comments readable.

This is fine:

#ifndef BUILD_VM_IN_PROCESS
#ifdef USING_SANITIZER
static const bool defaultPedanticShutdown = true;
#else
static const bool defaultPedanticShutdown = false;
#endif
static Cvar::Cvar<bool> cg_pedanticShutdown("cg_pedanticShutdown", "run useless shutdown procedures in cgame process", Cvar::NONE, defaultPedanticShutdown);
#endif // !BUILD_VM_IN_PROCESS

@sweet235
Copy link
Copy Markdown

I guess every second spent on thinking about Github's current code rendering is a waste of human resources.

@DolceTriade
Copy link
Copy Markdown
Member

fwiw, my human brain also prefers:

#ifndef BUILD_VM_IN_PROCESS
#ifdef USING_SANITIZER
static const bool defaultPedanticShutdown = true;
#else
static const bool defaultPedanticShutdown = false;
#endif
static Cvar::Cvar<bool> cg_pedanticShutdown("cg_pedanticShutdown",
	"run useless shutdown procedures in cgame process",
	Cvar::NONE, defaultPedanticShutdown);
#endif

otherwise, lgtm % style nit

When g_pedanticShutdown/cg_pedanticShutdown is off (default) and the
gamelogic is running in a separate process, skip shutdown code whose
only purpose is to deallocate memory. This saves time and avoids
spamming anyone with shutdown errors in production for cleanup issues
like with Lua (Unvanquished#3078) or RmlUi (Unvanquished#1693).
@slipher slipher force-pushed the pedanticshutdown branch from 4e18630 to 528ca06 Compare March 1, 2025 06:32
@slipher slipher merged commit a445860 into Unvanquished:master Mar 1, 2025
@slipher slipher deleted the pedanticshutdown branch March 1, 2025 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants