Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
improve --client flag, fix hud font character width for spaces (#277)
Browse files Browse the repository at this point in the history
* improve --client flag and domain resolution

* stop using the debug flag for dev binds

* smaller character width with spaces for the hud font
  • Loading branch information
Isaac0-dev authored Feb 16, 2023
1 parent e01f1ea commit 98834d5
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/pc/chat_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ bool exec_chat_command(char* command) {

return true;
}
#if defined(DEBUG) && defined(DEVELOPMENT)
#if defined(DEVELOPMENT)
if (gNetworkSystem == &gNetworkSystemSocket && str_starts_with("/warp ", command)) {
static const struct { const char *name; s32 num; } sLevelNumByName[] = {
#undef STUB_LEVEL
Expand Down Expand Up @@ -325,7 +325,7 @@ void display_chat_commands(void) {
djui_chat_message_create("/permban [NAME|ID] - Ban this player from any game you host");
djui_chat_message_create("/moderator [NAME|ID] - Make this player able to use commands like /kick, /ban, /permban on any game you host");
}
#if defined(DEBUG) && defined(DEVELOPMENT)
#if defined(DEVELOPMENT)
djui_chat_message_create("/warp [LEVEL] [AREA] [ACT] - Level can be either a numeric value or a shorthand name");
#endif
if (sConfirming != CCC_NONE) { djui_chat_message_create("/confirm"); }
Expand Down
8 changes: 6 additions & 2 deletions src/pc/cliopts.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,14 @@ void parse_cli_opts(int argc, char* argv[]) {
gCLIOpts.Network = NT_SERVER;
arg_uint("--server <port>", argv[++i], &gCLIOpts.NetworkPort);

} else if (strcmp(argv[i], "--client") == 0 && (i + 2) < argc) { // Join server
} else if (strcmp(argv[i], "--client") == 0 && (((i + 1) < argc) || (i + 2) < argc)) { // Join server
gCLIOpts.Network = NT_CLIENT;
arg_string("--client <ip>", argv[++i], gCLIOpts.JoinIp, IP_MAX_LEN);
arg_uint("--client <port>", argv[++i], &gCLIOpts.NetworkPort);
if ((i + 2) < argc) {
arg_uint("--client <port>", argv[++i], &gCLIOpts.NetworkPort);
} else {
gCLIOpts.NetworkPort = 7777;
}

} else if (strcmp(argv[i], "--cheats") == 0) // Enable cheats menu
Cheats.enabled = true;
Expand Down
4 changes: 2 additions & 2 deletions src/pc/controller/controller_keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static int keyboard_map_scancode(int scancode) {
}

bool keyboard_on_key_down(int scancode) {
#ifdef DEBUG
#ifdef DEVELOPMENT
debug_keyboard_on_key_down(scancode);
#endif

Expand All @@ -51,7 +51,7 @@ bool keyboard_on_key_down(int scancode) {
}

bool keyboard_on_key_up(int scancode) {
#ifdef DEBUG
#ifdef DEVELOPMENT
debug_keyboard_on_key_up(scancode);
#endif
djui_interactable_on_key_up(scancode);
Expand Down
4 changes: 1 addition & 3 deletions src/pc/controller/controller_keyboard_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "behavior_data.h"
#include "behavior_table.h"

#ifdef DEBUG
#ifdef DEVELOPMENT
#include "pc/lua/smlua.h"
#include "pc/network/socket/socket.h"

Expand Down Expand Up @@ -99,15 +99,13 @@ void debug_keyboard_on_key_down(int scancode) {
case SCANCODE_ALT: sHoldingAlt = true; break;
case SCANCODE_SHIFT: sHoldingShift = true; break;
case SCANCODE_3: debug_breakpoint_here(); break;
#ifdef DEVELOPMENT
case SCANCODE_1: if (sHoldingAlt) { debug_warp_level1(); } break;
case SCANCODE_2: if (sHoldingAlt) { debug_warp_level2(); } break;
case SCANCODE_4: if (sHoldingAlt) { debug_warp_level3(); } break;
case SCANCODE_8: if (sHoldingAlt) { debug_spawn_object(); } break;
case SCANCODE_9: if (sHoldingAlt) { debug_warp_to(); } break;
case SCANCODE_0: if (sHoldingAlt) { debug_suicide(); } break;
case SCANCODE_F5: debug_reload_lua(); break;
#endif
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pc/controller/controller_keyboard_debug.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef CONTROLLER_KEYBOARD_DEBUG_H
#define CONTROLLER_KEYBOARD_DEBUG_H
#ifdef DEBUG
#ifdef DEVELOPMENT

void debug_keyboard_on_key_down(int scancode);
void debug_keyboard_on_key_up(int scancode);
Expand Down
3 changes: 2 additions & 1 deletion src/pc/djui/djui_font.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ static void djui_font_hud_render_char(char c) {
djui_gfx_render_texture(main_hud_lut[index], 16, 16, 16);
}

static f32 djui_font_hud_char_width(UNUSED char c) {
static f32 djui_font_hud_char_width(char c) {
if (c == ' ') { return 0.5; }
return 0.75f;
}

Expand Down
4 changes: 3 additions & 1 deletion src/pc/pc_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "pc/discord/discordrpc.h"
#endif
#include "pc/network/version.h"
#include "pc/network/socket/socket.h"
#include "pc/network/network_player.h"
#include "pc/djui/djui.h"
#include "pc/debuglog.h"
Expand Down Expand Up @@ -352,7 +353,8 @@ void main_func(void) {

if (gCLIOpts.Network == NT_CLIENT) {
network_set_system(NS_SOCKET);
strncpy(configJoinIp, gCLIOpts.JoinIp, IP_MAX_LEN);
snprintf(gGetHostName, MAX_CONFIG_STRING, "%s", gCLIOpts.JoinIp);
snprintf(configJoinIp, MAX_CONFIG_STRING, "%s", gCLIOpts.JoinIp);
configJoinPort = gCLIOpts.NetworkPort;
network_init(NT_CLIENT);
} else if (gCLIOpts.Network == NT_SERVER) {
Expand Down

0 comments on commit 98834d5

Please sign in to comment.