AMFP Enhanced
C++ reference: the code this unofficial fork added
Loading...
Searching...
No Matches
LuxInitConfigPath.h
Go to the documentation of this file.
1/*
2 * AMFP-2026: choose the main init config. The Enhanced exe prefers amfp_enhanced/main_init.cfg, which
3 * points at our own game.cfg, resources.cfg (with /amfp_enhanced/override first) and lang folder, so the Steam
4 * install's files are never edited. Unit tested in tests/cpp/test_init_config_path.cpp.
5 */
6#ifndef LUX_INIT_CONFIG_PATH_H
7#define LUX_INIT_CONFIG_PATH_H
8
9static const wchar_t* const kLuxInitConfig2026 = L"amfp_enhanced/main_init.cfg";
10static const wchar_t* const kLuxInitConfigStock = L"config/main_init.cfg";
11
12/**
13 * afFileExists is injected so tests need no file system.
14 */
15inline const wchar_t* LuxChooseInitConfig(bool (*afFileExists)(const wchar_t*))
16{
17 if(afFileExists(kLuxInitConfig2026)) return kLuxInitConfig2026;
19}
20
21#include <string>
22
23/** Start map given as "-map <file>"; anything else (e.g. the launcher path Steam passes with
24 * "%command%") is not a map. Stock took any command line minus 5 characters as a map. */
25inline std::string LuxStartMapFromCommandLine(const std::string& asLine)
26{
27 size_t a = asLine.find_first_not_of(' ');
28 if(a == std::string::npos || asLine.compare(a, 5, "-map ") != 0) return "";
29 size_t b = asLine.find_first_not_of(' ', a + 5);
30 if(b == std::string::npos) return "";
31 size_t e = asLine.find_last_not_of(' ');
32 return asLine.substr(b, e - b + 1);
33}
34
35/** AMFP-2026: "-options" anywhere on the command line (Steam appends its own arguments): open the
36 * title menu with Options showing, no logos. Steam's "Run Settings Launcher" on macOS starts the
37 * game this way (tools/macos/steam_starter.c), standing in for the old 32-bit settings launcher. */
38inline bool LuxStartInOptionsFromCommandLine(const std::string& asLine)
39{
40 size_t p = 0;
41 while((p = asLine.find("-options", p)) != std::string::npos)
42 {
43 bool bStart = p == 0 || asLine[p - 1] == ' ';
44 bool bEnd = p + 8 == asLine.size() || asLine[p + 8] == ' ';
45 if(bStart && bEnd) return true;
46 p += 8;
47 }
48 return false;
49}
50
51#endif
const wchar_t * LuxChooseInitConfig(bool(*afFileExists)(const wchar_t *))
afFileExists is injected so tests need no file system.
static const wchar_t *const kLuxInitConfigStock
bool LuxStartInOptionsFromCommandLine(const std::string &asLine)
AMFP-2026: "-options" anywhere on the command line (Steam appends its own arguments): open the title ...
std::string LuxStartMapFromCommandLine(const std::string &asLine)
Start map given as "-map <file>"; anything else (e.g.
static const wchar_t *const kLuxInitConfig2026