Skip to content

Commit

Permalink
game: Enable network menu in debug mode only
Browse files Browse the repository at this point in the history
  • Loading branch information
mrannanj committed Dec 9, 2024
1 parent 3000d54 commit 5c248de
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/game/scenes/mainmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ int mainmenu_create(scene *scene) {
scene_set_dynamic_tick_cb(scene, mainmenu_tick);
scene_set_startup_cb(scene, mainmenu_startup);

#ifdef DEBUGMODE
if(scene->gs->net_mode == NET_MODE_CLIENT) {
component_action(guiframe_find(local->frame, NETWORK_BUTTON_ID), ACT_PUNCH);
component_action(guiframe_find(local->frame, NETWORK_CONNECT_BUTTON_ID), ACT_PUNCH);
Expand All @@ -146,6 +147,7 @@ int mainmenu_create(scene *scene) {
component_action(guiframe_find(local->frame, NETWORK_BUTTON_ID), ACT_PUNCH);
component_action(guiframe_find(local->frame, NETWORK_LISTEN_BUTTON_ID), ACT_PUNCH);
}
#endif

// clear it, so this only happens the first time
scene->gs->net_mode = NET_MODE_NONE;
Expand Down
4 changes: 4 additions & 0 deletions src/game/scenes/mainmenu/menu_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ component *menu_main_create(scene *s) {
menu_attach(menu, textbutton_create(&tconf, "ONE PLAYER GAME", NULL, COM_ENABLED, mainmenu_1v1, s));
menu_attach(menu, textbutton_create(&tconf, "TWO PLAYER GAME", NULL, COM_ENABLED, mainmenu_1v2, s));
menu_attach(menu, textbutton_create(&tconf, "TOURNAMENT PLAY", NULL, COM_ENABLED, mainmenu_mechlab, s));
#ifdef DEBUGMODE
component *net = textbutton_create(&tconf, "NETWORK PLAY", NULL, COM_ENABLED, mainmenu_enter_network, s);
#else
component *net = textbutton_create(&tconf, "NETWORK PLAY", NULL, COM_DISABLED, NULL, NULL);
#endif
widget_set_id(net, NETWORK_BUTTON_ID);
menu_attach(menu, net);
menu_attach(menu, textbutton_create(&tconf, "CONFIGURATION", NULL, COM_ENABLED, mainmenu_enter_configuration, s));
Expand Down
15 changes: 14 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,25 @@ int main(int argc, char *argv[]) {

struct arg_lit *help = arg_lit0("h", "help", "print this help and exit");
struct arg_lit *vers = arg_lit0("v", "version", "print version information and exit");
#ifdef DEBUGMODE
struct arg_lit *listen = arg_lit0("l", "listen", "Start a network game server");
struct arg_str *connect = arg_str0("c", "connect", "<host>", "Connect to a remote game");
#endif
struct arg_str *force_audio_backend =
arg_str0(NULL, "force-audio-backend", "<force-audio-backend>", "Force an audio backend to use");
struct arg_str *force_renderer = arg_str0(NULL, "force-renderer", "<force-renderer>", "Force a renderer to use");
struct arg_str *trace = arg_str0("t", "trace", "<file>", "Trace netplay events to file");
#ifdef DEBUGMODE
struct arg_int *port = arg_int0("p", "port", "<port>", "Port to connect or listen (default: 2097)");
#endif
struct arg_file *play = arg_file0("P", "play", "<file>", "Play an existing recfile");
struct arg_file *rec = arg_file0("R", "rec", "<file>", "Record a new recfile");
struct arg_end *end = arg_end(30);
#ifdef DEBUGMODE
void *argtable[] = {help, vers, listen, connect, force_audio_backend, force_renderer, trace, port, play, rec, end};
#else
void *argtable[] = {help, vers, force_audio_backend, force_renderer, trace, play, rec, end};
#endif
const char *progname = "openomf";

// Make sure everything got allocated
Expand Down Expand Up @@ -119,6 +127,7 @@ int main(int argc, char *argv[]) {
}

// Check other flags
#ifdef DEBUGMODE
if(connect->count > 0) {
init_flags.net_mode = NET_MODE_CLIENT;
connect_port = 2097;
Expand All @@ -129,7 +138,9 @@ int main(int argc, char *argv[]) {
} else if(listen->count > 0) {
init_flags.net_mode = NET_MODE_SERVER;
listen_port = 2097;
} else if(play->count > 0) {
}
#endif
if(play->count > 0) {
strncpy(init_flags.rec_file, play->filename[0], 254);
} else if(rec->count > 0) {
init_flags.record = 1;
Expand All @@ -143,9 +154,11 @@ int main(int argc, char *argv[]) {
sizeof(init_flags.force_audio_backend));
}

#ifdef DEBUGMODE
if(port->count > 0) {
listen_port = port->ival[0] & 0xFFFF;
}
#endif

if(trace->count > 0) {
trace_file = omf_strdup(trace->sval[0]);
Expand Down

0 comments on commit 5c248de

Please sign in to comment.