From 8ab97fbbf07965c4b011ed513194a9db5e15cdd1 Mon Sep 17 00:00:00 2001 From: Bohdan Shulyar Date: Sat, 13 Nov 2021 23:55:15 +0200 Subject: [PATCH] engine: client: Add svc_exec support (#671) * Add svc_exec support * engine: client: add gamedir check for svc_exec --- engine/client/cl_debug.c | 1 + engine/client/cl_parse.c | 50 +++++++++++++++++++++++++++++++++++++++ engine/common/dedicated.c | 2 +- engine/common/protocol.h | 3 ++- 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/engine/client/cl_debug.c b/engine/client/cl_debug.c index dcff1263..7b019daa 100644 --- a/engine/client/cl_debug.c +++ b/engine/client/cl_debug.c @@ -86,6 +86,7 @@ const char *svc_strings[svc_lastmsg+1] = "svc_resourcelocation", "svc_querycvarvalue", "svc_querycvarvalue2", + "svc_exec", }; typedef struct diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index 917da93c..8b931009 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -1925,6 +1925,53 @@ void CL_ParseCvarValue2( sizebuf_t *msg ) } } +/* +============== +CL_ParseExec + +Exec map/class specific configs +============== +*/ +void CL_ParseExec( sizebuf_t *msg ) +{ + qboolean is_class; + int class_idx; + string mapname; + const char *class_cfgs[] = { + "", + "exec scout.cfg\n", + "exec sniper.cfg\n", + "exec soldier.cfg\n", + "exec demoman.cfg\n", + "exec medic.cfg\n", + "exec hwguy.cfg\n", + "exec pyro.cfg\n", + "exec spy.cfg\n", + "exec engineer.cfg\n", + "", + "exec civilian.cfg\n" + }; + + is_class = MSG_ReadByte( msg ); + + if ( is_class ) + { + class_idx = MSG_ReadByte( msg ); + + if ( class_idx >= 0 && class_idx <= 11 && !Q_stricmp( GI->gamefolder, "tfc" ) ) + Cbuf_AddText( class_cfgs[class_idx] ); + } + else if ( !Q_stricmp( GI->gamefolder, "tfc" ) ) + { + Cbuf_AddText( "exec mapdefault.cfg\n" ); + + COM_FileBase( clgame.mapname, mapname ); + + if ( COM_CheckString( mapname ) ) + Cbuf_AddText( va( "exec %s.cfg\n", mapname ) ); + } +} + /* ============== CL_DispatchUserMessage @@ -2334,6 +2381,9 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message ) case svc_querycvarvalue2: CL_ParseCvarValue2( msg ); break; + case svc_exec: + CL_ParseExec( msg ); + break; default: CL_ParseUserMessage( msg, cmd ); cl.frames[cl.parsecountmod].graphdata.usr += MSG_GetNumBytesRead( msg ) - bufStart; diff --git a/engine/common/dedicated.c b/engine/common/dedicated.c index ff56a840..965c75c7 100644 --- a/engine/common/dedicated.c +++ b/engine/common/dedicated.c @@ -80,7 +80,7 @@ const char *svc_strings[256] = "svc_unused56", "svc_querycvarvalue", "svc_querycvarvalue2", - "svc_unused59", + "svc_exec", "svc_unused60", "svc_unused61", "svc_unused62", diff --git a/engine/common/protocol.h b/engine/common/protocol.h index f2321459..bfaf29bb 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -78,7 +78,8 @@ GNU General Public License for more details. #define svc_resourcelocation 56 // [string] #define svc_querycvarvalue 57 // [string] #define svc_querycvarvalue2 58 // [string][int] (context) -#define svc_lastmsg 58 // start user messages at this point +#define svc_exec 59 // [byte][...] +#define svc_lastmsg 59 // start user messages at this point // client to server #define clc_bad 0 // immediately drop client when received