launcher: allow overriding service url and url slash from the command line

This commit is contained in:
Will Xyen 2020-12-20 23:44:59 -08:00
parent f7e1c8b3f9
commit 29db89cebe
7 changed files with 91 additions and 5 deletions

View File

@ -36,7 +36,8 @@ enum property_type {
PROPERTY_TYPE_S64 = 8,
PROPERTY_TYPE_U64 = 9,
PROPERTY_TYPE_BIN = 10,
PROPERTY_TYPE_STR = 11
PROPERTY_TYPE_STR = 11,
PROPERTY_TYPE_BOOL = 52
};
struct property;
@ -57,8 +58,6 @@ enum psmap_type {
PSMAP_TYPE_S64 = 8,
PSMAP_TYPE_U64 = 9,
PSMAP_TYPE_STR = 10,
/* Used on avs 803 instead of value 10 */
PSMAP_TYPE_STR_LEGACY = 11,
PSMAP_TYPE_ATTR = 45,
PSMAP_TYPE_BOOL = 50,
};

View File

@ -77,7 +77,7 @@ static void avs_boot_replace_property_str(
property_node_remove(tmp);
}
tmp = property_node_create(NULL, node, PSMAP_TYPE_STR_LEGACY, name, val);
tmp = property_node_create(NULL, node, PROPERTY_TYPE_STR, name, val);
if (tmp) {
property_node_datasize(tmp);

View File

@ -160,3 +160,31 @@ void ea3_ident_to_property(
property_psmap_export(ea3_config, NULL, ident, ea3_ident_psmap);
}
void ea3_ident_replace_property_bool(
struct property_node *node, const char *name, uint8_t val)
{
struct property_node *tmp;
tmp = property_search(NULL, node, name);
if (tmp) {
property_node_remove(tmp);
}
property_node_create(NULL, node, PROPERTY_TYPE_BOOL, name, val);
}
void ea3_ident_replace_property_str(
struct property_node *node, const char *name, const char *val)
{
struct property_node *tmp;
tmp = property_search(NULL, node, name);
if (tmp) {
property_node_remove(tmp);
}
tmp = property_node_create(NULL, node, PROPERTY_TYPE_STR, name, val);
}

View File

@ -38,5 +38,9 @@ bool ea3_ident_invoke_module_init(
struct property_node *app_config);
void ea3_ident_to_property(
const struct ea3_ident *ident, struct property *ea3_config);
void ea3_ident_replace_property_bool(
struct property_node *node, const char *name, uint8_t val);
void ea3_ident_replace_property_str(
struct property_node *node, const char *name, const char *val);
#endif

View File

@ -94,7 +94,8 @@ static AVS_LOG_WRITER(log_callback, chars, nchars, ctx)
free(utf16);
}
static void load_hook_dlls(struct array* hook_dlls) {
static void load_hook_dlls(struct array *hook_dlls)
{
const char *hook_dll;
for (size_t i = 0; i < hook_dlls->nitems; i++) {
@ -283,6 +284,24 @@ int main(int argc, const char **argv)
ea3_ident_to_property(&ea3, ea3_config);
if (options.override_urlslash_enabled) {
log_info("Overriding url_slash to: %d", options.override_urlslash);
ea3_ident_replace_property_bool(
ea3_config_root,
"/network/url_slash",
options.override_urlslash);
}
if (options.override_service_enabled) {
log_info("Overriding service url to: %s", options.override_service);
ea3_ident_replace_property_str(
ea3_config_root,
"/network/services",
options.override_service);
}
/* Start up e-Amusement client */
ea3_boot(ea3_config_root);

View File

@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "imports/avs.h"
@ -135,6 +136,35 @@ bool options_read_cmdline(struct options *options, int argc, const char **argv)
break;
case 'S':
if (i + 1 >= argc) {
return false;
}
options->override_service_enabled = true;
options->override_service = argv[++i];
break;
case 'U':
if (i + 1 >= argc) {
return false;
}
options->override_urlslash_enabled = true;
const char * urlslash_value = argv[++i];
options->override_urlslash = false;
if (_stricmp(urlslash_value, "1") == 0) {
options->override_urlslash = true;
}
if (_stricmp(urlslash_value, "true") == 0) {
options->override_urlslash = true;
}
break;
case 'D':
options->remote_debugger = true;
@ -179,6 +209,8 @@ void options_print_usage(void)
#endif
" -P [pcbid] Specify PCBID (default: use ea3 config)\n"
" -R [pcbid] Specify Soft ID (default: use ea3 config)\n"
" -S [url] Specify service url (default: use ea3 config)\n"
" -U [0/1] Specify url_slash (default: use ea3 config)\n"
" -K [filename] Load hook DLL (can be specified multiple "
"times)\n"
" -B [filename] Load pre-hook DLL loaded before avs boot "

View File

@ -19,6 +19,10 @@ struct options {
struct array hook_dlls;
struct array before_hook_dlls;
bool remote_debugger;
bool override_service_enabled;
const char *override_service;
bool override_urlslash_enabled;
bool override_urlslash;
};
void options_init(struct options *options);