World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Файл Launcher.cpp

См. исходные тексты.

Функции

bool OS_GetAppStringRecursive (HKEY parent_key, const char *path, char *out_string, int out_string_size)
 
bool OS_GetAppString (const char *path, char *out_string, int out_string_size)
 
void GetDefaultConfig (ApplicationConfig &config)
 
int __stdcall WinMain (HINSTANCE, HINSTANCE, char *, int)
 

Функции

◆ OS_GetAppStringRecursive()

bool OS_GetAppStringRecursive ( HKEY  parent_key,
const char *  path,
char *  out_string,
int  out_string_size 
)

См. определение в файле Launcher.cpp строка 6

7  {
8  char current_key[128];
9  char path_tail[1024];
10 
11  const char *delimiter = strstr(path, "/");
12  if (delimiter) {
13  strncpy(current_key, path, delimiter - path);
14  current_key[delimiter - path] = '\0';
15 
16  strcpy(path_tail, delimiter + 1);
17 
18  if (!parent_key) {
19  if (!strcmpi(current_key, "HKEY_CLASSES_ROOT"))
20  parent_key = HKEY_CLASSES_ROOT;
21  else if (!strcmpi(current_key, "HKEY_CURRENT_CONFIG"))
22  parent_key = HKEY_CURRENT_CONFIG;
23  else if (!strcmpi(current_key, "HKEY_CURRENT_USER"))
24  parent_key = HKEY_CURRENT_USER;
25  else if (!strcmpi(current_key, "HKEY_LOCAL_MACHINE"))
26  parent_key = HKEY_LOCAL_MACHINE;
27  else if (!strcmpi(current_key, "HKEY_USERS"))
28  parent_key = HKEY_USERS;
29  else
30  return false;
31 
32  delimiter = strstr(path_tail, "/");
33  if (delimiter) {
34  strncpy(current_key, path_tail, delimiter - path_tail);
35  current_key[delimiter - path_tail] = '\0';
36 
37  strcpy(path_tail, delimiter + 1);
38  } else {
39  return false;
40  }
41  }
42 
43  bool result = false;
44  HKEY key;
45  if (!RegOpenKeyExA(parent_key, current_key, 0,
46  KEY_READ | KEY_WOW64_32KEY, &key)) {
47  result = OS_GetAppStringRecursive(key, path_tail, out_string,
48  out_string_size);
49  RegCloseKey(key);
50  }
51 
52  return result;
53  } else {
54  DWORD data_size = out_string_size;
55  if (RegQueryValueExA(parent_key, path, nullptr, nullptr,
56  (LPBYTE)out_string, &data_size))
57  return false;
58  return true;
59  }
60 }

Используется в OS_GetAppString().

+ Граф вызова функции:

◆ OS_GetAppString()

bool OS_GetAppString ( const char *  path,
char *  out_string,
int  out_string_size 
)

См. определение в файле Launcher.cpp строка 62

62  {
63  return OS_GetAppStringRecursive(nullptr, path, out_string, out_string_size);
64 }

Используется в FindMm7Directory(), GetDefaultConfig() и KeyboardActionMapping::ReadMappings().

+ Граф вызова функции:

◆ GetDefaultConfig()

void GetDefaultConfig ( ApplicationConfig config)

См. определение в файле Launcher.cpp строка 66

66  {
67  char mm7_path[2048];
68 
69  if (const char *path_override = std::getenv("WOMM_PATH_OVERRIDE")) {
70  config.mm7_install_type = "Custom Folder (ENV path override)";
71  config.mm7_install_path = path_override;
72  return;
73  }
74 
75  bool gog_found = OS_GetAppString(
76  "HKEY_LOCAL_MACHINE/SOFTWARE/GOG.com/GOGMM7/PATH",
77  mm7_path, sizeof(mm7_path));
78  if (gog_found) {
79  config.mm7_install_type = "GoG MM7 installation";
80  config.mm7_install_path = mm7_path;
81  return;
82  }
83 
84  bool std_found = OS_GetAppString(
85  "HKEY_LOCAL_MACHINE/SOFTWARE/New World Computing/Might and Magic VII/1.0/AppPath",
86  mm7_path, sizeof(mm7_path));
87  if (std_found) {
88  config.mm7_install_type = "Standard MM7 1.0 installation";
89  config.mm7_install_path = mm7_path;
90  return;
91  }
92 }

Перекрестные ссылки OS_GetAppString().

Используется в WinMain().

+ Граф вызовов:
+ Граф вызова функции:

◆ WinMain()

int __stdcall WinMain ( HINSTANCE  ,
HINSTANCE  ,
char *  ,
int   
)

См. определение в файле Launcher.cpp строка 94

94  {
97 
98  (new Application())->Configure(config)->Run();
99  return 0;
100 }

Перекрестные ссылки GetDefaultConfig().

+ Граф вызовов:
OS_GetAppStringRecursive
bool OS_GetAppStringRecursive(HKEY parent_key, const char *path, char *out_string, int out_string_size)
Definition: Launcher.cpp:6
GetDefaultConfig
void GetDefaultConfig(ApplicationConfig &config)
Definition: Launcher.cpp:66
path
GLsizei const GLchar *const * path
Definition: SDL_opengl_glext.h:3733
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9435
ApplicationConfig
Definition: ApplicationConfig.h:4
Application
Definition: Configuration.h:5
OS_GetAppString
bool OS_GetAppString(const char *path, char *out_string, int out_string_size)
Definition: Launcher.cpp:62
config
EGLConfig config
Definition: SDL_egl.h:1149