From b73c16c216e3bcfcd25faff11ba57392b642d794 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sun, 5 Feb 2023 03:39:32 +0100 Subject: [PATCH 1/6] engine: net_ws: pass correct sockaddr lengths where needed --- engine/common/net_ws.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/engine/common/net_ws.c b/engine/common/net_ws.c index df569b9b..549536b4 100644 --- a/engine/common/net_ws.c +++ b/engine/common/net_ws.c @@ -188,6 +188,19 @@ char *NET_ErrorString( void ) #endif } +_inline socklen_t NET_SockAddrLen( const struct sockaddr_storage *addr ) +{ + switch ( addr->ss_family ) + { + case AF_INET: + return sizeof( struct sockaddr_in ); + case AF_INET6: + return sizeof( struct sockaddr_in6 ); + default: + return sizeof( *addr ); // what the fuck is this? + } +} + _inline qboolean NET_IsSocketError( int retval ) { #if XASH_WIN32 || XASH_DOS4GW @@ -1626,7 +1639,7 @@ void NET_SendPacketEx( netsrc_t sock, size_t length, const void *data, netadr_t NET_NetadrToSockadr( &to, &addr ); - ret = NET_SendLong( sock, net_socket, data, length, 0, &addr, sizeof( addr ), splitsize ); + ret = NET_SendLong( sock, net_socket, data, length, 0, &addr, NET_SockAddrLen( &addr ), splitsize ); if( NET_IsSocketError( ret )) { @@ -1799,7 +1812,7 @@ static int NET_IPSocket( const char *net_iface, int port, int family ) if( port == PORT_ANY ) ((struct sockaddr_in6 *)&addr)->sin6_port = 0; else ((struct sockaddr_in6 *)&addr)->sin6_port = htons((short)port); - if( NET_IsSocketError( bind( net_socket, (struct sockaddr *)&addr, sizeof( addr )))) + if( NET_IsSocketError( bind( net_socket, (struct sockaddr *)&addr, sizeof( struct sockaddr_in6 )))) { Con_DPrintf( S_WARN "NET_UDPSocket: port: %d bind6: %s\n", port, NET_ErrorString( )); closesocket( net_socket ); @@ -1836,7 +1849,7 @@ static int NET_IPSocket( const char *net_iface, int port, int family ) if( port == PORT_ANY ) ((struct sockaddr_in *)&addr)->sin_port = 0; else ((struct sockaddr_in *)&addr)->sin_port = htons((short)port); - if( NET_IsSocketError( bind( net_socket, (struct sockaddr *)&addr, sizeof( addr )))) + if( NET_IsSocketError( bind( net_socket, (struct sockaddr *)&addr, sizeof( struct sockaddr_in )))) { Con_DPrintf( S_WARN "NET_UDPSocket: port: %d bind: %s\n", port, NET_ErrorString( )); closesocket( net_socket ); @@ -2644,7 +2657,7 @@ void HTTP_Run( void ) if( curfile->state < HTTP_CONNECTED ) // Connection not enstabilished { - res = connect( curfile->socket, (struct sockaddr*)&addr, sizeof( addr )); + res = connect( curfile->socket, (struct sockaddr*)&addr, NET_SockAddrLen( &addr ) ); if( res ) { From 15ba932046c57cd14dc42546989f24bfd1324844 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Fri, 28 May 2021 20:12:01 +0300 Subject: [PATCH 2/6] engine: server: add sv_autosave cvar * a1ba: added FCVAR_PRIVILEGED just in case --- engine/server/server.h | 1 + engine/server/sv_cmds.c | 3 ++- engine/server/sv_main.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/engine/server/server.h b/engine/server/server.h index 1f0ba150..eee4e358 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -438,6 +438,7 @@ extern convar_t sv_uploadmax; extern convar_t sv_trace_messages; extern convar_t sv_enttools_enable; extern convar_t sv_enttools_maxfire; +extern convar_t sv_autosave; extern convar_t deathmatch; extern convar_t hostname; extern convar_t skill; diff --git a/engine/server/sv_cmds.c b/engine/server/sv_cmds.c index d4b733f2..8812811d 100644 --- a/engine/server/sv_cmds.c +++ b/engine/server/sv_cmds.c @@ -502,7 +502,8 @@ void SV_AutoSave_f( void ) return; } - SV_SaveGame( "autosave" ); + if( Cvar_VariableInteger( "sv_autosave" ) ) + SV_SaveGame( "autosave" ); } /* diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index 8f32e7eb..0db6b0fc 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -60,6 +60,7 @@ CVAR_DEFINE_AUTO( sv_log_singleplayer, "0", FCVAR_ARCHIVE, "allows logging in si CVAR_DEFINE_AUTO( sv_log_onefile, "0", FCVAR_ARCHIVE, "logs server information to only one file" ); CVAR_DEFINE_AUTO( sv_trace_messages, "0", FCVAR_LATCH, "enable server usermessages tracing (good for developers)" ); CVAR_DEFINE_AUTO( sv_master_response_timeout, "4", FCVAR_ARCHIVE, "master server heartbeat response timeout in seconds" ); +CVAR_DEFINE_AUTO( sv_autosave, "1", FCVAR_ARCHIVE|FCVAR_SERVER|FCVAR_PRIVILEGED, "enable autosaving" ); // game-related cvars CVAR_DEFINE_AUTO( mapcyclefile, "mapcycle.txt", 0, "name of multiplayer map cycle configuration file" ); @@ -967,6 +968,7 @@ void SV_Init( void ) Cvar_RegisterVariable( &sv_master_response_timeout ); Cvar_RegisterVariable( &sv_background_freeze ); + Cvar_RegisterVariable( &sv_autosave ); Cvar_RegisterVariable( &mapcyclefile ); Cvar_RegisterVariable( &motdfile ); From d944301a60e3ec158b3697b4f0507419d189a67a Mon Sep 17 00:00:00 2001 From: fgsfds Date: Mon, 24 May 2021 04:10:24 +0300 Subject: [PATCH 3/6] engine: client: add barebones gamepad controls to input fields --- engine/client/console.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/engine/client/console.c b/engine/client/console.c index 2267b44c..dc461fec 100644 --- a/engine/client/console.c +++ b/engine/client/console.c @@ -1230,7 +1230,7 @@ void Field_KeyDownEvent( field_t *edit, int key ) return; } - if( key == K_BACKSPACE ) + if( key == K_BACKSPACE || key == K_B_BUTTON ) { if( edit->cursor > 0 ) { @@ -1242,7 +1242,7 @@ void Field_KeyDownEvent( field_t *edit, int key ) return; } - if( key == K_RIGHTARROW ) + if( key == K_RIGHTARROW || key == K_DPAD_RIGHT ) { if( edit->cursor < len ) edit->cursor = Con_UtfMoveRight( edit->buffer, edit->cursor, edit->widthInChars ); if( edit->cursor >= edit->scroll + edit->widthInChars && edit->cursor <= len ) @@ -1250,7 +1250,7 @@ void Field_KeyDownEvent( field_t *edit, int key ) return; } - if( key == K_LEFTARROW ) + if( key == K_LEFTARROW || key == K_DPAD_LEFT ) { if( edit->cursor > 0 ) edit->cursor = Con_UtfMoveLeft( edit->buffer, edit->cursor ); if( edit->cursor < edit->scroll ) edit->scroll--; @@ -1547,8 +1547,8 @@ void Key_Console( int key ) return; } - // enter finishes the line - if( key == K_ENTER || key == K_KP_ENTER ) + // enter or A finish the line + if( key == K_ENTER || key == K_KP_ENTER || key == K_A_BUTTON ) { // backslash text are commands, else chat if( con.input.buffer[0] == '\\' || con.input.buffer[0] == '/' ) @@ -1575,7 +1575,7 @@ void Key_Console( int key ) } // command completion - if( key == K_TAB ) + if( key == K_TAB || key == K_X_BUTTON ) { Con_CompleteCommand( &con.input ); Con_Bottom(); From b68def2b9cca456f99a9778e28b42f669f5a18a0 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Mon, 24 May 2021 04:53:35 +0300 Subject: [PATCH 4/6] engine: touch: only pop up touch keyboard on FINGERDOWN events --- engine/client/in_touch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/client/in_touch.c b/engine/client/in_touch.c index b3cd2b3a..a35a1a67 100644 --- a/engine/client/in_touch.c +++ b/engine/client/in_touch.c @@ -1956,7 +1956,8 @@ int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx // Hack for keyboard, hope it help if( cls.key_dest == key_console || cls.key_dest == key_message ) { - Key_EnableTextInput( true, true ); + if ( type == event_down ) // don't pop it again on event_up + Key_EnableTextInput( true, true ); if( cls.key_dest == key_console ) { static float y1 = 0; From f782d444a84c27ed4a5f81c313cc5b67a7801529 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sun, 5 Feb 2023 02:16:38 +0100 Subject: [PATCH 5/6] engine: platform: posix: don't redefine _GNU_SOURCE --- engine/platform/posix/lib_posix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engine/platform/posix/lib_posix.c b/engine/platform/posix/lib_posix.c index 746b73e7..fe1204e0 100644 --- a/engine/platform/posix/lib_posix.c +++ b/engine/platform/posix/lib_posix.c @@ -12,7 +12,9 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include "platform/platform.h" #if XASH_LIB == LIB_POSIX #include From 634574f249398fb6b398b4aae7e7152fc80fcfc9 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 6 Feb 2023 00:29:14 +0300 Subject: [PATCH 6/6] engine: platform: sdl: don't enable text mode with cursor??? --- engine/platform/sdl/in_sdl.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/engine/platform/sdl/in_sdl.c b/engine/platform/sdl/in_sdl.c index 3957b2e9..0603a421 100644 --- a/engine/platform/sdl/in_sdl.c +++ b/engine/platform/sdl/in_sdl.c @@ -343,12 +343,10 @@ void Platform_SetCursorType( VGUI_DefaultCursor type ) { SDL_SetCursor( cursors.cursors[type] ); SDL_ShowCursor( true ); - Key_EnableTextInput( true, false ); } else { SDL_ShowCursor( false ); - Key_EnableTextInput( false, false ); } #else if( host.mouse_visible )