Skip to content

Read game information from daemon.ini file#588

Draft
illwieckz wants to merge 1 commit intomasterfrom
gameinfo/sync
Draft

Read game information from daemon.ini file#588
illwieckz wants to merge 1 commit intomasterfrom
gameinfo/sync

Conversation

@illwieckz
Copy link
Copy Markdown
Member

@illwieckz illwieckz commented Feb 27, 2022

Read game information from daemon.conf file, fix Unvanquished/Unvanquished#817:

See also Unvanquished/Unvanquished#1777 on Unvanquished side:

This makes the engine truly repurposable without recompilation.

The idea is to set default home path, game name, game version, basepak, gamename string (thing used by master servers to filter out games), master servers, www_baseurl and uri proto (like unv in unv://) from a configuration file stored next to daemon binary.

This is based on @DefaultUser work.

This PR obsoletes #16:


Thing that is required to consider this PR complete:

  • Implement the master server list.

Thing that is outside of the scope of this PR:

  • Provide a generic Windows icon and a way for a game to compile the engine with a custom Windows icon.

…ished#817

Co-authored-by: Sebastian Schmidt <schro.sb@gmail.com>
Co-authored-by: Thomas “illwieckz” Debesse <dev@illwieckz.net>
@illwieckz
Copy link
Copy Markdown
Member Author

I have not implemented the master server list because I don't know how to do it.

@illwieckz
Copy link
Copy Markdown
Member Author

illwieckz commented Feb 27, 2022

Here is another gameinfo.conf syntax suggestion: #16 (comment)

We may also name the file game.conf or daemon.conf or something else.

@illwieckz
Copy link
Copy Markdown
Member Author

I added an implementation of master server list from gameinfo.conf file. I find it a bit hacky and I'm not super happy with it but the problem is that the server master cvar list looks to be initialized before we read that file…

@illwieckz illwieckz changed the title Read game information from gameinfo.conf file, fix Unvanquished/Unvanquished#817 Read game information from daemon.conf file, fix Unvanquished/Unvanquished#817 Feb 28, 2022
@illwieckz illwieckz force-pushed the gameinfo/sync branch 4 times, most recently from daa987f to 6241602 Compare February 28, 2022 23:55
@illwieckz
Copy link
Copy Markdown
Member Author

We MUST split on lines and consider everything following a key to be the value (stripping leading and trailing spaces. Especially, game names may contain white space! It looks like the current implementation iterates every word!

@illwieckz
Copy link
Copy Markdown
Member Author

@Kangz you said there Unvanquished/Unvanquished#817 (comment)

This was on my TODO list after the "Application" refactor

So maybe this will interest you. I'll appreciate reviews and improvements. =)

@illwieckz
Copy link
Copy Markdown
Member Author

Spearmint engine has a similar features with a file named mint-game.settings: https://github.com/zturtleman/spearmint/wiki/New-Game#game-separation

cvarDefault com_homepath "Jump Land Adventure"
cvarDefault com_gamename JumpLand
cvarDefault com_demoext jumplanddemo

This is similar to my suggest from #16 (comment)

Copy link
Copy Markdown
Member

@slipher slipher left a comment

Choose a reason for hiding this comment

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

The feature to override the default of any cvar sounds good (instead of only specifically allowed ones). We've talked about that sort of thing in the past, like maybe Xonotic would need to allow symlinks in paks by default or something.

Some other things I want to look at (I might fix them myself):

  • Don't add stuff to q_shared.h or qcommon.h
  • Avoid macros with va() or other function calls in them
  • Parsing should be case-insensitive
  • Consider moving CMake conf copying stuff into Daemon. It's similar to DLLs - a required file that must be copied to the engine dir.
  • Sanity check cvars that are used in filesystem paths

std::string uriprotocol() const;
private:
Gameinfo() : _name("MISSING_NAME"), _version("UNKNOWN") {};
std::string _name;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't see any reason for private fields + getter functions. Just expose a const reference to a Gameinfo struct, and then the fields can be read (e.g. Gameinfo::getInstanc().basepak), but not modified.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That was code by @DefaultUser, if there is better way to do it then we can do it.

/* The key names and values MUST NOT be quoted
in the daemon.conf */

/* Display name, can contain special characters,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The documentation of each field should go in the struct definition rather than parsing code.

Alternatively the parser could support comments and this could go in the template. It's always annoying to use languages without comments...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We need a better parser anyway, I currently reused the one that was proposed in #16 but I'm not happy with it.

Cvar_Get( "layout", "", CVAR_SERVERINFO );
Cvar_Get( "g_layouts", "", 0 ); // FIXME
sv_hostname = Cvar_Get( "sv_hostname", UNNAMED_SERVER, CVAR_SERVERINFO );
sv_hostname = Cvar_Get( "sv_hostname", Gameinfo::getInstance().unnamedservername().c_str(), CVAR_SERVERINFO );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

duplicated line

return temp;
}

std::string Gameinfo::name_upper() const
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unused?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, there are also some others to purge before merging (master ones).

@illwieckz illwieckz marked this pull request as draft March 7, 2022 00:11
@illwieckz illwieckz changed the title Read game information from daemon.conf file, fix Unvanquished/Unvanquished#817 Read game information from daemon.ini file Apr 7, 2026
@illwieckz
Copy link
Copy Markdown
Member Author

Everything works but the master servers.

They are properly registered but the listing doesn't work. I suspect that the Cvar::Modified thing is messing with them.

@illwieckz
Copy link
Copy Markdown
Member Author

We now use a .ini file which is read by using tomlc17:

This makes it easy to declare arrays, like master servers.

In the future we will be able to use an array as well for extra basepaks, the list of pak names to prevent accidental upgrade through autodownload.

@illwieckz
Copy link
Copy Markdown
Member Author

illwieckz commented Apr 7, 2026

The default sv_hostname is incorrect because it is set before the file is read.

We need a way to change a Cvar default after startup and set the cvar to this value when the hardcoded default wasn't modified.

@illwieckz
Copy link
Copy Markdown
Member Author

The default sv_hostname is incorrect because it is set before the file is read.

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-Feature-Request Proposed new feature

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Hardcoded references to Unvanquished in the engine

3 participants