diff --git a/cmake/DaemonFlags.cmake b/cmake/DaemonFlags.cmake index e8da09c008..0bd6eb94f0 100644 --- a/cmake/DaemonFlags.cmake +++ b/cmake/DaemonFlags.cmake @@ -231,6 +231,17 @@ else() endif() endif() + if (NACL AND USE_NACL_SAIGO AND SAIGO_ARCH STREQUAL "arm") + # This should be set for every build type because build type flags + # are set after the other custom flags and then have the last word. + # DEBUG should already use -O0 anyway. + # See: https://github.com/Unvanquished/Unvanquished/issues/3297 + set_c_cxx_flag("-O0" DEBUG) + set_c_cxx_flag("-O0" RELEASE) + set_c_cxx_flag("-O0" RELWITHDEBINFO) + set_c_cxx_flag("-O0" MINSIZEREL) + endif() + # Extra debug flags. set_c_cxx_flag("-g3" RELWITHDEBINFO) set_c_cxx_flag("-g3" DEBUG) diff --git a/src/common/Command.cpp b/src/common/Command.cpp index 75f3e40a7b..22ea4c3df8 100644 --- a/src/common/Command.cpp +++ b/src/common/Command.cpp @@ -493,11 +493,13 @@ namespace Cmd { return *Cmd::GetEnv(); } +#ifndef BUILD_ENGINE StaticCmd::StaticCmd(std::string name, std::string description) :CmdBase(0){ //Register this command statically AddCommand(std::move(name), *this, std::move(description)); } +#endif StaticCmd::StaticCmd(std::string name, const int flags, std::string description) :CmdBase(flags){ @@ -509,9 +511,11 @@ namespace Cmd { return {}; } +#ifndef BUILD_ENGINE LambdaCmd::LambdaCmd(std::string name, std::string description, RunFn run, CompleteFn complete) :StaticCmd(std::move(name), std::move(description)), run(run), complete(complete) { } +#endif LambdaCmd::LambdaCmd(std::string name, int flags, std::string description, RunFn run, CompleteFn complete) :StaticCmd(std::move(name), flags, std::move(description)), run(run), complete(complete) { } @@ -528,7 +532,7 @@ class InjectFaultCmd : public Cmd::StaticCmd { public: InjectFaultCmd() : StaticCmd( - VM_STRING_PREFIX "injectFault", "make the program error and crash") {} + VM_STRING_PREFIX "injectFault", Cmd::BASE, "make the program error and crash") {} void Run(const Cmd::Args& args) const override { diff --git a/src/common/Command.h b/src/common/Command.h index 17360e5566..54f5898647 100644 --- a/src/common/Command.h +++ b/src/common/Command.h @@ -41,15 +41,18 @@ namespace Cmd { * mass removal of commands. */ enum { - BASE = BIT(0), - CVAR = BIT(1), - ALIAS = BIT(2), - SYSTEM = BIT(3), - RENDERER = BIT(4), - AUDIO = BIT(5), - SGAME_VM = BIT(6), - CGAME_VM = BIT(7), - KEY_BINDING = BIT(8), + BASE = BIT(0), // anything in the dummy app? + SERVER = BIT(1), + CLIENT = BIT(2), // client stuff other than renderer, audio, keys + RENDERER = BIT(3), + AUDIO = BIT(4), + KEY_BINDING = BIT(5), + + // ones you should not use when defining a StaticCmd + SGAME_VM = BIT(27), + CGAME_VM = BIT(28), + CVAR = BIT(29), // auto-generated cvar show/set command + ALIAS = BIT(30), PROXY_FOR_OLD = BIT(31) // OLD: The command has been registered through the proxy function in cmd.c }; @@ -154,14 +157,19 @@ namespace Cmd { * instanciated and removes it when it is destroyed. A typical usage is * * class MyCmd : public Cmd::StaticCmd { - * MyCmd() : Cmd::StaticCmd("my_command", NAMESPACE, "my_description"){} + * MyCmd() : Cmd::StaticCmd("my_command", Cmd::NAMESPACE, "my_description"){} * //Other stuff * }; * static MyCmd MyCmdRegistration; + * + * The 'namespace' flag(s) is mandatory in the engine (so that the command will appear + * in /listCmds), but ignored in the gamelogic (there they automatically get [CS]GAME_VM). */ class StaticCmd : public CmdBase { protected: +#ifndef BUILD_ENGINE StaticCmd(std::string name, std::string description); +#endif StaticCmd(std::string name, int flags, std::string description); }; @@ -180,7 +188,9 @@ namespace Cmd { public: using RunFn = std::function; using CompleteFn = std::function; +#ifndef BUILD_ENGINE LambdaCmd(std::string name, std::string description, RunFn run, CompleteFn complete = NoopComplete); +#endif LambdaCmd(std::string name, int flags, std::string description, RunFn run, CompleteFn complete = NoopComplete); void Run(const Args& args) const override; diff --git a/src/engine/client/cl_main.cpp b/src/engine/client/cl_main.cpp index c98bc13f66..639ed7ed6d 100644 --- a/src/engine/client/cl_main.cpp +++ b/src/engine/client/cl_main.cpp @@ -292,7 +292,7 @@ class DemoRecordStopCmd: public Cmd::StaticCmd { public: DemoRecordStopCmd() - : Cmd::StaticCmd("demo_record_stop", Cmd::SYSTEM, "Stops recording a demo") + : Cmd::StaticCmd("demo_record_stop", Cmd::CLIENT, "Stops recording a demo") {} void Run(const Cmd::Args&) const override @@ -312,7 +312,7 @@ class DemoRecordCmd : public Cmd::StaticCmd { public: DemoRecordCmd() - : Cmd::StaticCmd("demo_record", Cmd::SYSTEM, "Begins recording a demo from the current position") + : Cmd::StaticCmd("demo_record", Cmd::CLIENT, "Begins recording a demo from the current position") {} void Run(const Cmd::Args& args) const override @@ -562,7 +562,7 @@ void CL_ReadDemoMessage() class DemoPlayCmd: public Cmd::StaticCmd { public: - DemoPlayCmd(): Cmd::StaticCmd("demo_play", Cmd::SYSTEM, "Starts playing a demo file") { + DemoPlayCmd(): Cmd::StaticCmd("demo_play", Cmd::CLIENT, "Starts playing a demo file") { } void Run(const Cmd::Args& args) const override { @@ -1223,7 +1223,7 @@ class RconCmd: public Cmd::StaticCmd { public: RconCmd(): - StaticCmd("rcon", Cmd::SYSTEM, "Sends a remote console command") + StaticCmd("rcon", Cmd::CLIENT, "Sends a remote console command") {} void Run(const Cmd::Args& args) const override @@ -1287,7 +1287,7 @@ class RconDiscoverCmd: public Cmd::StaticCmd { public: RconDiscoverCmd(): - StaticCmd("rconDiscover", Cmd::SYSTEM, "Sends a request to the server to populate rcon.client cvars") + StaticCmd("rconDiscover", Cmd::CLIENT, "Sends a request to the server to populate rcon.client cvars") {} void Run(const Cmd::Args&) const override @@ -1528,7 +1528,7 @@ class DemoVideoCmd: public Cmd::StaticCmd { public: DemoVideoCmd() - : Cmd::StaticCmd("demo_video", Cmd::SYSTEM, + : Cmd::StaticCmd("demo_video", Cmd::CLIENT, "Begins recording a video from the current demo") {} @@ -1586,7 +1586,7 @@ class DemoStopVideoCmd: public Cmd::StaticCmd { public: DemoStopVideoCmd() - : Cmd::StaticCmd("demo_video_stop", Cmd::SYSTEM, "Stops recording a video") + : Cmd::StaticCmd("demo_video_stop", Cmd::CLIENT, "Stops recording a video") {} void Run(const Cmd::Args&) const override diff --git a/src/engine/framework/BaseCommands.cpp b/src/engine/framework/BaseCommands.cpp index 39ad163aa4..ccd96ab45a 100644 --- a/src/engine/framework/BaseCommands.cpp +++ b/src/engine/framework/BaseCommands.cpp @@ -1010,7 +1010,7 @@ namespace Cmd { class ShowFPSCommand : public Cmd::StaticCmd { public: - ShowFPSCommand() : StaticCmd("showfps", "prints engine frame rate") {} + ShowFPSCommand() : StaticCmd("showfps", Cmd::BASE, "prints engine frame rate") {} void Run(const Cmd::Args&) const override { Print("FPS: %.1f", Application::GetFPS()); diff --git a/src/engine/framework/CommandSystem.cpp b/src/engine/framework/CommandSystem.cpp index 7ba2f6395c..133adffdf6 100644 --- a/src/engine/framework/CommandSystem.cpp +++ b/src/engine/framework/CommandSystem.cpp @@ -351,12 +351,11 @@ namespace Cmd { void Run(const Cmd::Args& args) const override { CommandMap& commands = GetCommandMap(); - std::vector matches; - std::vector matchesNames; + std::vector matches; unsigned long maxNameLength = 0; //Find all the matching commands and their names - for (auto it = commands.cbegin(); it != commands.cend(); ++it) { + for (CommandMap::const_iterator it = commands.cbegin(); it != commands.cend(); ++it) { const commandRecord_t& record = it->second; // /listCmds's argument is used for prefix matching @@ -365,16 +364,19 @@ namespace Cmd { } if (record.cmd->GetFlags() & showCmdFlags) { - matches.push_back(&it->second); - matchesNames.push_back(&it->first); + matches.push_back(it); maxNameLength = std::max(maxNameLength, it->first.size()); } } + // TODO: case insensitive compare function? + std::sort(matches.begin(), matches.end(), + [](CommandMap::const_iterator a, CommandMap::const_iterator b) { return a->first < b->first; }); + //Print the matches, keeping the description aligned - for (unsigned i = 0; i < matches.size(); i++) { - int toFill = maxNameLength - matchesNames[i]->size(); - Print(" %s%s %s", matchesNames[i]->c_str(), std::string(toFill, ' ').c_str(), matches[i]->description.c_str()); + for (CommandMap::const_iterator it : matches) { + int toFill = maxNameLength - it->first.size(); + Print(" %s%s %s", it->first, std::string(toFill, ' '), it->second.description); } Print("%zu commands", matches.size()); @@ -396,11 +398,12 @@ namespace Cmd { static ListCmdsCmd listCmdsRegistration("listCmds", BASE, "lists all the commands", ~(CVAR|ALIAS)); static ListCmdsCmd listBaseCmdsRegistration("listBaseCmds", BASE, "lists all the base commands", BASE); - static ListCmdsCmd listSystemCmdsRegistration("listSystemCmds", BASE | SYSTEM, "lists all the system commands", SYSTEM); + static ListCmdsCmd listServerCmdsRegistration("listServerCmds", BASE | SERVER, "lists all the server commands", SERVER); + static ListCmdsCmd listClientCmdsRegistration("listClientCmds", BASE | CLIENT, "lists all the client commands", CLIENT | RENDERER | AUDIO | KEY_BINDING); static ListCmdsCmd listRendererCmdsRegistration("listRendererCmds", BASE | RENDERER, "lists all the renderer commands", RENDERER); static ListCmdsCmd listAudioCmdsRegistration("listAudioCmds", BASE | AUDIO, "lists all the audio commands", AUDIO); - static ListCmdsCmd listCGameCmdsRegistration("listCGameCmds", BASE | CGAME_VM, "lists all the client-side game commands", CGAME_VM); - static ListCmdsCmd listGameCmdsRegistration("listSGameCmds", BASE | SGAME_VM, "lists all the server-side game commands", CGAME_VM); static ListCmdsCmd listKeyCmdsRegistration("listKeyBindingCmds", BASE | KEY_BINDING, "lists all the key binding commands", KEY_BINDING); + static ListCmdsCmd listCGameCmdsRegistration("listCGameCmds", BASE, "lists all the client-side game commands", CGAME_VM); + static ListCmdsCmd listGameCmdsRegistration("listSGameCmds", BASE, "lists all the server-side game commands", SGAME_VM); static ListCmdsCmd listOldStyleCmdsRegistration("listOldStyleCmds", BASE, "lists all the commands registered through the C interface", PROXY_FOR_OLD); } diff --git a/src/engine/qcommon/files.cpp b/src/engine/qcommon/files.cpp index 9b532b30a3..dffaa10b35 100644 --- a/src/engine/qcommon/files.cpp +++ b/src/engine/qcommon/files.cpp @@ -766,7 +766,7 @@ bool FS_ComparePaks(char* neededpaks, int len) class WhichCmd: public Cmd::StaticCmd { public: WhichCmd() - : Cmd::StaticCmd("which", Cmd::SYSTEM, "shows which pak a file is in") {} + : Cmd::StaticCmd("which", Cmd::BASE, "shows which pak a file is in") {} void Run(const Cmd::Args& args) const override { @@ -797,7 +797,7 @@ static WhichCmd WhichCmdRegistration; class ListPathsCmd: public Cmd::StaticCmd { public: ListPathsCmd() - : Cmd::StaticCmd("listPaths", Cmd::SYSTEM, "list filesystem search paths") {} + : Cmd::StaticCmd("listPaths", Cmd::BASE, "list filesystem search paths") {} void Run(const Cmd::Args&) const override { @@ -810,7 +810,7 @@ static ListPathsCmd ListPathsCmdRegistration; class DirCmd: public Cmd::StaticCmd { public: - DirCmd(): Cmd::StaticCmd("dir", Cmd::SYSTEM, "list all files in a given directory with the option to pass a filter") {} + DirCmd(): Cmd::StaticCmd("dir", Cmd::BASE, "list all files in a given directory with the option to pass a filter") {} void Run(const Cmd::Args& args) const override { diff --git a/src/engine/qcommon/net_ip.cpp b/src/engine/qcommon/net_ip.cpp index 125f2e1366..0b26f1c920 100644 --- a/src/engine/qcommon/net_ip.cpp +++ b/src/engine/qcommon/net_ip.cpp @@ -35,6 +35,7 @@ Maryland 20850 USA. #include "qcommon/q_shared.h" #include "qcommon/qcommon.h" #include +#include "engine/framework/Application.h" #include "engine/framework/Network.h" #include "server/server.h" @@ -120,11 +121,6 @@ namespace net { static bool usingSocks = false; static bool networkingEnabled = false; -#ifndef BUILD_SERVER -static bool serverMode = false; -#else -static const bool serverMode = true; -#endif cvar_t *net_enabled; @@ -935,7 +931,13 @@ SOCKET NET_IPSocket( const char *net_interface, int port, struct sockaddr_in *bi Log::Notice( "Opening IP socket: %s:%s", net_interface ? net_interface : "0.0.0.0", port ? va( "%i", port ) : "*" ); - if ( ( newsocket = socket( PF_INET, SOCK_DGRAM, IPPROTO_UDP ) ) == INVALID_SOCKET ) +#ifdef _WIN32 + newsocket = WSASocketW( PF_INET, SOCK_DGRAM, IPPROTO_UDP, nullptr, 0, WSA_FLAG_NO_HANDLE_INHERIT ); +#else + newsocket = socket( PF_INET, SOCK_DGRAM, IPPROTO_UDP ); +#endif + + if ( newsocket == INVALID_SOCKET ) { *err = socketError; Log::Warn( "NET_IPSocket: socket: %s", NET_ErrorString() ); @@ -1020,7 +1022,13 @@ SOCKET NET_IP6Socket( const char *net_interface, int port, struct sockaddr_in6 * // Print the name in brackets if there is a colon: Log::Notice( "Opening IP6 socket: %s%s%s:%s", brackets ? "[" : "", net_interface ? net_interface : "[::]", brackets ? "]" : "", port ? va( "%i", port ) : "*" ); - if ( ( newsocket = socket( PF_INET6, SOCK_DGRAM, IPPROTO_UDP ) ) == INVALID_SOCKET ) +#ifdef _WIN32 + newsocket = WSASocketW( PF_INET6, SOCK_DGRAM, IPPROTO_UDP, nullptr, 0, WSA_FLAG_NO_HANDLE_INHERIT ); +#else + newsocket = socket( PF_INET6, SOCK_DGRAM, IPPROTO_UDP ); +#endif + + if ( newsocket == INVALID_SOCKET ) { *err = socketError; Log::Warn( "NET_IP6Socket: socket: %s", NET_ErrorString() ); @@ -1223,7 +1231,13 @@ void NET_OpenSocks( int port ) Log::Notice( "Opening connection to SOCKS server." ); - if ( ( socks_socket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ) ) == INVALID_SOCKET ) +#ifdef _WIN32 + socks_socket = WSASocketW( AF_INET, SOCK_STREAM, IPPROTO_TCP, nullptr, 0, WSA_FLAG_NO_HANDLE_INHERIT ); +#else + socks_socket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); +#endif + + if ( socks_socket == INVALID_SOCKET ) { Log::Warn( "NET_OpenSocks: socket: %s", NET_ErrorString() ); return; @@ -1580,7 +1594,7 @@ static int NET_EnsureValidPortNo( int port ) NET_OpenIP ==================== */ -static void NET_OpenIP() +static void NET_OpenIP( bool serverMode ) { int i; int err = 0; @@ -1630,7 +1644,7 @@ static void NET_OpenIP() if ( net_enabled->integer & NET_ENABLEV4 ) { - for ( i = ( port6 == PORT_ANY ? 1 : MAX_TRY_PORTS ); i; i-- ) + for ( i = ( port == PORT_ANY ? 1 : MAX_TRY_PORTS ); i; i-- ) { ip_socket = NET_IPSocket( net_ip->string, port, &boundto4, &err ); @@ -1671,10 +1685,8 @@ static void NET_OpenIP() NET_GetCvars ==================== */ -static bool NET_GetCvars() +static void NET_GetCvars() { - int modified; - #ifdef BUILD_SERVER // I want server owners to explicitly turn on IPv6 support. net_enabled = Cvar_Get( "net_enabled", "1", CVAR_LATCH ); @@ -1684,147 +1696,82 @@ static bool NET_GetCvars() * used if available due to ping */ net_enabled = Cvar_Get( "net_enabled", "3", CVAR_LATCH ); #endif - modified = net_enabled->modified; - net_enabled->modified = false; net_ip = Cvar_Get( "net_ip", "0.0.0.0", CVAR_LATCH ); - modified += net_ip->modified; - net_ip->modified = false; - net_ip6 = Cvar_Get( "net_ip6", "::", CVAR_LATCH ); - modified += net_ip6->modified; - net_ip6->modified = false; - net_port = Cvar_Get( "net_port", va( "%i", PORT_SERVER ), CVAR_LATCH ); - modified += net_port->modified; - net_port->modified = false; - net_port6 = Cvar_Get( "net_port6", va( "%i", PORT_SERVER ), CVAR_LATCH ); - modified += net_port6->modified; - net_port6->modified = false; // Some cvars for configuring multicast options which facilitates scanning for servers on local subnets. net_mcast6addr = Cvar_Get( "net_mcast6addr", NET_MULTICAST_IP6, CVAR_LATCH ); - modified += net_mcast6addr->modified; - net_mcast6addr->modified = false; - #ifdef _WIN32 net_mcast6iface = Cvar_Get( "net_mcast6iface", "0", CVAR_LATCH ); #else net_mcast6iface = Cvar_Get( "net_mcast6iface", "", CVAR_LATCH ); #endif - modified += net_mcast6iface->modified; - net_mcast6iface->modified = false; net_socksEnabled = Cvar_Get( "net_socksEnabled", "0", CVAR_LATCH ); - modified += net_socksEnabled->modified; - net_socksEnabled->modified = false; - net_socksServer = Cvar_Get( "net_socksServer", "", CVAR_LATCH ); - modified += net_socksServer->modified; - net_socksServer->modified = false; - net_socksPort = Cvar_Get( "net_socksPort", "1080", CVAR_LATCH ); - modified += net_socksPort->modified; - net_socksPort->modified = false; - net_socksUsername = Cvar_Get( "net_socksUsername", "", CVAR_LATCH ); - modified += net_socksUsername->modified; - net_socksUsername->modified = false; - net_socksPassword = Cvar_Get( "net_socksPassword", "", CVAR_LATCH ); - modified += net_socksPassword->modified; - net_socksPassword->modified = false; - - return modified ? true : false; } -/* -==================== -NET_Config -==================== -*/ -void NET_Config( bool enableNetworking ) +void NET_EnableNetworking( bool serverMode ) { - bool modified; - bool stop; - bool start; -#ifndef BUILD_SERVER - bool svRunning; -#endif - // get any latched changes to cvars - modified = NET_GetCvars(); -#ifndef BUILD_SERVER - svRunning = !!com_sv_running->integer; - modified |= ( svRunning != serverMode ); -#endif + NET_GetCvars(); - if ( !net_enabled->integer ) - { - enableNetworking = false; - } + // always cycle off and on because this function is only called on a state change or forced restart + NET_DisableNetworking(); - // if enable state is the same and no cvars were modified, we have nothing to do - if ( enableNetworking == networkingEnabled && !modified ) + if ( !( net_enabled->integer & ( NET_ENABLEV4 | NET_ENABLEV6 ) ) ) { return; } - start = enableNetworking; - if ( enableNetworking == networkingEnabled ) - { - stop = enableNetworking; - } - else + networkingEnabled = true; + + NET_OpenIP( serverMode ); + NET_SetMulticast6(); + SV_NET_Config(); +} + +void NET_DisableNetworking() +{ + if ( !networkingEnabled ) { - stop = !enableNetworking; + return; } -#ifndef BUILD_SERVER - serverMode = svRunning; -#endif - networkingEnabled = enableNetworking; + networkingEnabled = false; - if ( stop ) + if ( ip_socket != INVALID_SOCKET ) { - if ( ip_socket != INVALID_SOCKET ) - { - closesocket( ip_socket ); - ip_socket = INVALID_SOCKET; - } + closesocket( ip_socket ); + ip_socket = INVALID_SOCKET; + } - if ( multicast6_socket != INVALID_SOCKET ) + if ( multicast6_socket != INVALID_SOCKET ) + { + if ( multicast6_socket != ip6_socket ) { - if ( multicast6_socket != ip6_socket ) - { - closesocket( multicast6_socket ); - } - - multicast6_socket = INVALID_SOCKET; + closesocket( multicast6_socket ); } - if ( ip6_socket != INVALID_SOCKET ) - { - closesocket( ip6_socket ); - ip6_socket = INVALID_SOCKET; - } + multicast6_socket = INVALID_SOCKET; + } - if ( socks_socket != INVALID_SOCKET ) - { - closesocket( socks_socket ); - socks_socket = INVALID_SOCKET; - } + if ( ip6_socket != INVALID_SOCKET ) + { + closesocket( ip6_socket ); + ip6_socket = INVALID_SOCKET; } - if ( start ) + if ( socks_socket != INVALID_SOCKET ) { - if ( net_enabled->integer ) - { - NET_OpenIP(); - NET_SetMulticast6(); - SV_NET_Config(); - } + closesocket( socks_socket ); + socks_socket = INVALID_SOCKET; } } @@ -1850,7 +1797,7 @@ void NET_Init() Log::Notice( "Winsock Initialized" ); #endif - NET_Config( true ); + NET_EnableNetworking( Application::GetTraits().isServer ); Cmd_AddCommand( "net_restart", NET_Restart_f ); } @@ -1862,16 +1809,14 @@ NET_Shutdown */ void NET_Shutdown() { - if ( !networkingEnabled ) - { - return; - } - - NET_Config( false ); + NET_DisableNetworking(); #ifdef _WIN32 - WSACleanup(); - winsockInitialized = false; + if ( winsockInitialized ) + { + WSACleanup(); + winsockInitialized = false; + } #endif } @@ -1930,8 +1875,12 @@ NET_Restart_f */ void NET_Restart_f() { - NET_Config( false ); + NET_DisableNetworking(); SV_NET_Config(); Net::ShutDownDNS(); - NET_Config( true ); +#ifdef BUILD_SERVER + NET_EnableNetworking( true ); +#else + NET_EnableNetworking( !!com_sv_running->integer ); +#endif } diff --git a/src/engine/qcommon/qcommon.h b/src/engine/qcommon/qcommon.h index 6e8a60a886..128a4f03fa 100644 --- a/src/engine/qcommon/qcommon.h +++ b/src/engine/qcommon/qcommon.h @@ -149,7 +149,8 @@ extern cvar_t *net_enabled; void NET_Init(); void NET_Shutdown(); void NET_Restart_f(); -void NET_Config( bool enableNetworking ); +void NET_EnableNetworking( bool serverMode ); +void NET_DisableNetworking(); void NET_SendPacket( netsrc_t sock, int length, const void *data, const netadr_t& to ); diff --git a/src/engine/renderer/gl_shader.cpp b/src/engine/renderer/gl_shader.cpp index 0c4b21bd45..d37926ffdb 100644 --- a/src/engine/renderer/gl_shader.cpp +++ b/src/engine/renderer/gl_shader.cpp @@ -599,7 +599,7 @@ static std::string GenEngineConstants() { // Engine constants std::string str; - AddDefine( str, "r_AmbientScale", r_ambientScale->value ); + AddDefine( str, "r_AmbientScale", r_ambientScale.Get() ); AddDefine( str, "r_SpecularScale", r_specularScale->value ); AddDefine( str, "r_zNear", r_znear->value ); diff --git a/src/engine/renderer/tr_animation.cpp b/src/engine/renderer/tr_animation.cpp index 9e5fe88fd5..ea39201019 100644 --- a/src/engine/renderer/tr_animation.cpp +++ b/src/engine/renderer/tr_animation.cpp @@ -584,7 +584,8 @@ skelAnimation_t *R_GetAnimationByHandle( qhandle_t index ) class ListAnimationsCmd : public Cmd::StaticCmd { public: - ListAnimationsCmd() : StaticCmd("listAnimations", "list model animations loaded in renderer") {} + ListAnimationsCmd() : StaticCmd( + "listAnimations", Cmd::RENDERER, "list model animations loaded in renderer") {} void Run( const Cmd::Args & ) const override { @@ -679,12 +680,6 @@ void R_AddMD5Surfaces( trRefEntity_t *ent ) return; } - // set up lighting now that we know we aren't culled - if ( !personalModel || glConfig2.shadowMapping ) - { - R_SetupEntityLighting( &tr.refdef, ent, nullptr ); - } - // see if we are in a fog volume fogNum = R_FogWorldBox( ent->worldBounds ); diff --git a/src/engine/renderer/tr_bsp.cpp b/src/engine/renderer/tr_bsp.cpp index f366f28379..c1b1c6c32e 100644 --- a/src/engine/renderer/tr_bsp.cpp +++ b/src/engine/renderer/tr_bsp.cpp @@ -3955,7 +3955,7 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) Log::Debug("%i fog volumes loaded", s_worldData.numFogs ); } -static void R_SetDefaultLightGrid() +static void R_SetConstantColorLightGrid( const byte color[3] ) { world_t *w = &s_worldData; @@ -3983,9 +3983,9 @@ static void R_SetDefaultLightGrid() bspGridPoint2_t *gridPoint2 = (bspGridPoint2_t *) (gridPoint1 + w->numLightGridPoints); // default some white light from above - gridPoint1->color[ 0 ] = 64; - gridPoint1->color[ 1 ] = 64; - gridPoint1->color[ 2 ] = 64; + gridPoint1->color[ 0 ] = color[0]; + gridPoint1->color[ 1 ] = color[1]; + gridPoint1->color[ 2 ] = color[2]; gridPoint1->ambientPart = 128; gridPoint2->direction[ 0 ] = floatToSnorm8(0.0f); gridPoint2->direction[ 1 ] = floatToSnorm8(0.0f); @@ -4039,9 +4039,16 @@ void R_LoadLightGrid( lump_t *l ) vec3_t ambientColor, directedColor, direction; float scale; + if ( tr.ambientLightSet ) { + const byte color[3]{ floatToUnorm8( tr.ambientLight[0] ), floatToUnorm8( tr.ambientLight[1] ), + floatToUnorm8( tr.ambientLight[2] ) }; + R_SetConstantColorLightGrid( color ); + } + if ( !r_precomputedLighting->integer ) { - R_SetDefaultLightGrid(); + const byte color[3] { 64, 64, 64 }; + R_SetConstantColorLightGrid( color ); return; } @@ -4081,7 +4088,8 @@ void R_LoadLightGrid( lump_t *l ) { Log::Warn("light grid mismatch, default light grid used" ); - R_SetDefaultLightGrid(); + const byte color[3]{ 64, 64, 64 }; + R_SetConstantColorLightGrid( color ); return; } @@ -4116,6 +4124,12 @@ void R_LoadLightGrid( lump_t *l ) tmpDirected[ 2 ] = in->directed[ 2 ]; tmpDirected[ 3 ] = 255; + if ( tmpAmbient[0] < r_forceAmbient.Get() && + tmpAmbient[1] < r_forceAmbient.Get() && + tmpAmbient[2] < r_forceAmbient.Get() ) { + VectorSet( tmpAmbient, r_forceAmbient.Get(), r_forceAmbient.Get(), r_forceAmbient.Get() ); + } + if ( tr.legacyOverBrightClamping ) { R_ColorShiftLightingBytes( tmpAmbient ); @@ -4338,13 +4352,12 @@ void R_LoadEntities( lump_t *l, std::string &externalEntities ) // check for ambient color else if ( !Q_stricmp( keyname, "_color" ) || !Q_stricmp( keyname, "ambientColor" ) ) { - if ( r_forceAmbient->value <= 0 ) - { - sscanf( value, "%f %f %f", &tr.worldEntity.ambientLight[ 0 ], &tr.worldEntity.ambientLight[ 1 ], - &tr.worldEntity.ambientLight[ 2 ] ); + if ( r_forceAmbient.Get() == 0 ) { + sscanf( value, "%f %f %f", &tr.ambientLight[0], &tr.ambientLight[1], + &tr.ambientLight[2] ); - VectorCopy( tr.worldEntity.ambientLight, tr.worldEntity.ambientLight ); - VectorScale( tr.worldEntity.ambientLight, r_ambientScale->value, tr.worldEntity.ambientLight ); + VectorScale( tr.ambientLight, r_ambientScale.Get(), tr.ambientLight ); + tr.ambientLightSet = true; } } @@ -5017,7 +5030,7 @@ void R_BuildCubeMaps() } static Cmd::LambdaCmd buildCubeMapsCmd( - "buildcubemaps", "generate cube probes for reflection mapping", + "buildcubemaps", Cmd::RENDERER, "generate cube probes for reflection mapping", []( const Cmd::Args & ) { R_BuildCubeMaps(); }); /* @@ -5048,11 +5061,6 @@ void RE_LoadWorldMap( const char *name ) VectorNormalize( tr.sunDirection ); - // set default ambient color - tr.worldEntity.ambientLight[ 0 ] = r_forceAmbient->value; - tr.worldEntity.ambientLight[ 1 ] = r_forceAmbient->value; - tr.worldEntity.ambientLight[ 2 ] = r_forceAmbient->value; - tr.worldMapLoaded = true; // load it diff --git a/src/engine/renderer/tr_fbo.cpp b/src/engine/renderer/tr_fbo.cpp index 98beddeacb..45d006e871 100644 --- a/src/engine/renderer/tr_fbo.cpp +++ b/src/engine/renderer/tr_fbo.cpp @@ -594,7 +594,7 @@ void R_ShutdownFBOs() class ListFBOsCmd : public Cmd::StaticCmd { public: - ListFBOsCmd() : StaticCmd("listFBOs", "list renderer's OpenGL framebuffer objects") {} + ListFBOsCmd() : StaticCmd("listFBOs", Cmd::RENDERER, "list renderer's OpenGL framebuffer objects") {} void Run( const Cmd::Args & ) const override { diff --git a/src/engine/renderer/tr_image.cpp b/src/engine/renderer/tr_image.cpp index b7d32839b5..974d84848a 100644 --- a/src/engine/renderer/tr_image.cpp +++ b/src/engine/renderer/tr_image.cpp @@ -140,7 +140,7 @@ void GL_TextureMode( const char *string ) class ListImagesCmd : public Cmd::StaticCmd { public: - ListImagesCmd() : StaticCmd("listImages", "list images loaded in renderer") {} + ListImagesCmd() : StaticCmd("listImages", Cmd::RENDERER, "list images loaded in renderer") {} void Run( const Cmd::Args &args ) const override { diff --git a/src/engine/renderer/tr_init.cpp b/src/engine/renderer/tr_init.cpp index 543adc87c0..1354bbc132 100644 --- a/src/engine/renderer/tr_init.cpp +++ b/src/engine/renderer/tr_init.cpp @@ -216,8 +216,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA cvar_t *r_wolfFog; cvar_t *r_noFog; - cvar_t *r_forceAmbient; - cvar_t *r_ambientScale; + Cvar::Range> r_forceAmbient( "r_forceAmbient", "Minimal light amount in lightGrid", Cvar::NONE, + 0.125f, 0.0f, 0.3f ); + Cvar::Cvar r_ambientScale( "r_ambientScale", "Scale lightGrid produced by ambientColor keyword by this much", Cvar::CHEAT, 1.0 ); cvar_t *r_lightScale; cvar_t *r_debugSort; cvar_t *r_printShaders; @@ -340,11 +341,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA return false; } - if( glConfig2.glCoreProfile ) { - glGenVertexArrays( 1, &backEnd.currentVAO ); - glBindVertexArray( backEnd.currentVAO ); - } - glState.tileStep[ 0 ] = TILE_SIZE * ( 1.0f / glConfig.vidWidth ); glState.tileStep[ 1 ] = TILE_SIZE * ( 1.0f / glConfig.vidHeight ); @@ -380,6 +376,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA GLSL_InitGPUShaders(); } + if ( glConfig2.glCoreProfile ) { + glGenVertexArrays( 1, &backEnd.currentVAO ); + glBindVertexArray( backEnd.currentVAO ); + } + GL_CheckErrors(); // set default state @@ -524,7 +525,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA class ListModesCmd : public Cmd::StaticCmd { public: - ListModesCmd() : StaticCmd("listModes", "list suggested screen/window dimensions") {} + ListModesCmd() : StaticCmd("listModes", Cmd::RENDERER, "list suggested screen/window dimensions") {} void Run( const Cmd::Args& ) const override { int i; @@ -1084,14 +1085,14 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p // FIXME: uses regular logging not Print() static Cmd::LambdaCmd gfxInfoCmd( - "gfxinfo", "dump graphics driver and configuration info", + "gfxinfo", Cmd::RENDERER, "dump graphics driver and configuration info", []( const Cmd::Args & ) { GfxInfo_f(); }); class GlslRestartCmd : public Cmd::StaticCmd { public: GlslRestartCmd() : StaticCmd( - "glsl_restart", "recompile GLSL shaders (useful when shaderpath is set)") {} + "glsl_restart", Cmd::RENDERER, "recompile GLSL shaders (useful when shaderpath is set)") {} void Run( const Cmd::Args & ) const override { @@ -1165,8 +1166,7 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p r_wolfFog = Cvar_Get( "r_wolfFog", "1", CVAR_CHEAT ); r_noFog = Cvar_Get( "r_noFog", "0", CVAR_CHEAT ); - r_forceAmbient = Cvar_Get( "r_forceAmbient", "0.125", CVAR_LATCH ); - AssertCvarRange( r_forceAmbient, 0.0f, 0.3f, false ); + Cvar::Latch( r_forceAmbient ); r_smp = Cvar_Get( "r_smp", "0", CVAR_LATCH ); @@ -1192,7 +1192,7 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p r_gamma = Cvar_Get( "r_gamma", "1.0", CVAR_ARCHIVE ); r_facePlaneCull = Cvar_Get( "r_facePlaneCull", "1", 0 ); - r_ambientScale = Cvar_Get( "r_ambientScale", "1.0", CVAR_CHEAT | CVAR_LATCH ); + Cvar::Latch( r_ambientScale ); r_lightScale = Cvar_Get( "r_lightScale", "2", CVAR_CHEAT ); r_vboFaces = Cvar_Get( "r_vboFaces", "1", CVAR_CHEAT ); diff --git a/src/engine/renderer/tr_light.cpp b/src/engine/renderer/tr_light.cpp index c134b3ea5f..c6fbaf27db 100644 --- a/src/engine/renderer/tr_light.cpp +++ b/src/engine/renderer/tr_light.cpp @@ -248,110 +248,18 @@ int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, ve VectorNormalize( lightDir ); - if ( ambientLight[ 0 ] < r_forceAmbient->value && - ambientLight[ 1 ] < r_forceAmbient->value && - ambientLight[ 2 ] < r_forceAmbient->value ) + if ( ambientLight[ 0 ] < r_forceAmbient.Get() && + ambientLight[ 1 ] < r_forceAmbient.Get() && + ambientLight[ 2 ] < r_forceAmbient.Get() ) { - ambientLight[ 0 ] = r_forceAmbient->value; - ambientLight[ 1 ] = r_forceAmbient->value; - ambientLight[ 2 ] = r_forceAmbient->value; + ambientLight[ 0 ] = r_forceAmbient.Get(); + ambientLight[ 1 ] = r_forceAmbient.Get(); + ambientLight[ 2 ] = r_forceAmbient.Get(); } return true; } -/* -================= -R_SetupEntityLightingGrid -================= -*/ -static void R_SetupEntityLightingGrid( trRefEntity_t *ent, vec3_t forcedOrigin ) -{ - vec3_t lightOrigin; - - if ( forcedOrigin ) - { - VectorCopy( forcedOrigin, lightOrigin ); - } - else - { - if ( ent->e.renderfx & RF_LIGHTING_ORIGIN ) - { - // separate lightOrigins are needed so an object that is - // sinking into the ground can still be lit, and so - // multi-part models can be lit identically - VectorCopy( ent->e.lightingOrigin, lightOrigin ); - } - else - { - VectorCopy( ent->e.origin, lightOrigin ); - } - } - - R_LightForPoint( lightOrigin, ent->ambientLight, ent->directedLight, - ent->lightDir ); -} - -/* -================= -R_SetupEntityLighting - -Calculates all the lighting values that will be used -by the Calc_* functions -================= -*/ -void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent, vec3_t forcedOrigin ) -{ - // lighting calculations - if ( ent->lightingCalculated ) - { - return; - } - - ent->lightingCalculated = true; - - // if NOWORLDMODEL, only use dynamic lights (menu system, etc) - if ( !( refdef->rdflags & RDF_NOWORLDMODEL ) && tr.world - && tr.world->lightGridData1 && tr.world->lightGridData2 ) - { - R_SetupEntityLightingGrid( ent, forcedOrigin ); - } - else - { - /* Historically those values were multiplied by - tr.identityLight but tr.identityLight is always 1.0f - in Dæmon engine as the overbright bit implementation - is fully software. */ - - //% ent->ambientLight[0] = ent->ambientLight[1] = ent->ambientLight[2] = 150.0f; - //% ent->directedLight[0] = ent->directedLight[1] = ent->directedLight[2] = 150.0f; - //% VectorCopy( tr.sunDirection, ent->lightDir ); - ent->ambientLight[ 0 ] = 64.0f / 255.0f; - ent->ambientLight[ 1 ] = 64.0f / 255.0f; - ent->ambientLight[ 2 ] = 96.0f / 255.0f; - - ent->directedLight[ 0 ] = 255.0f / 255.0f; - ent->directedLight[ 1 ] = 232.0f / 255.0f; - ent->directedLight[ 2 ] = 224.0f / 255.0f; - - VectorSet( ent->lightDir, -1, 1, 1.25 ); - VectorNormalize( ent->lightDir ); - } - - if ( ( ent->e.renderfx & RF_MINLIGHT ) ) // && VectorLength(ent->ambientLight) <= 0) - { - /* Historically those values were multiplied by - tr.identityLight but tr.identityLight is always 1.0f - in Dæmon engine as the as the overbright bit - implementation is fully software. */ - - // give everything a minimum light add - ent->ambientLight[ 0 ] += 0.125f; - ent->ambientLight[ 1 ] += 0.125f; - ent->ambientLight[ 2 ] += 0.125f; - } -} - /* ================= R_SetupLightOrigin diff --git a/src/engine/renderer/tr_local.h b/src/engine/renderer/tr_local.h index 42988156a4..3bf09cf9e7 100644 --- a/src/engine/renderer/tr_local.h +++ b/src/engine/renderer/tr_local.h @@ -465,10 +465,6 @@ enum class shaderProfilerRenderSubGroupsMode { // local float axisLength; // compensate for non-normalized axis - bool lightingCalculated; - vec3_t lightDir; // normalized direction towards light - vec3_t ambientLight; // color normalized to 0-1 - vec3_t directedLight; cullResult_t cull; vec3_t localBounds[ 2 ]; @@ -2755,6 +2751,9 @@ enum class shaderProfilerRenderSubGroupsMode { std::vector lightmaps; std::vector deluxemaps; + vec3_t ambientLight; + bool ambientLightSet = false; + image_t *lightGrid1Image; image_t *lightGrid2Image; @@ -2852,7 +2851,6 @@ enum class shaderProfilerRenderSubGroupsMode { extern const matrix_t quakeToOpenGLMatrix; extern const matrix_t openGLToQuakeMatrix; extern const matrix_t flipZMatrix; - extern const GLenum geometricRenderTargets[]; extern int shadowMapResolutions[ 5 ]; extern int sunShadowMapResolutions[ 5 ]; @@ -2891,8 +2889,8 @@ enum class shaderProfilerRenderSubGroupsMode { extern cvar_t *r_wolfFog; extern cvar_t *r_noFog; - extern cvar_t *r_forceAmbient; - extern cvar_t *r_ambientScale; + extern Cvar::Range> r_forceAmbient; + extern Cvar::Cvar r_ambientScale; extern cvar_t *r_lightScale; extern Cvar::Cvar r_drawSky; // Controls whether sky should be drawn or cleared. @@ -3563,7 +3561,6 @@ inline bool checkGLErrors() */ void R_AddBrushModelInteractions( trRefEntity_t *ent, trRefLight_t *light, interactionType_t iaType ); - void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent, vec3_t forcedOrigin ); float R_InterpolateLightGrid( world_t *w, int from[3], int to[3], float *factors[3], vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ); diff --git a/src/engine/renderer/tr_mesh.cpp b/src/engine/renderer/tr_mesh.cpp index 3338777fc1..8aefcda50b 100644 --- a/src/engine/renderer/tr_mesh.cpp +++ b/src/engine/renderer/tr_mesh.cpp @@ -302,12 +302,6 @@ void R_AddMDVSurfaces( trRefEntity_t *ent ) return; } - // set up lighting now that we know we aren't culled - if ( !personalModel || glConfig2.shadowMapping ) - { - R_SetupEntityLighting( &tr.refdef, ent, nullptr ); - } - // see if we are in a fog volume fogNum = R_FogWorldBox( ent->worldBounds ); diff --git a/src/engine/renderer/tr_model.cpp b/src/engine/renderer/tr_model.cpp index a8ce4a733a..8d85386946 100644 --- a/src/engine/renderer/tr_model.cpp +++ b/src/engine/renderer/tr_model.cpp @@ -309,7 +309,7 @@ void R_ModelInit() class ListModelsCmd : public Cmd::StaticCmd { public: - ListModelsCmd() : StaticCmd("listModels", "list loaded 3D models") {} + ListModelsCmd() : StaticCmd("listModels", Cmd::RENDERER, "list loaded 3D models") {} void Run( const Cmd::Args &args ) const override { diff --git a/src/engine/renderer/tr_model_iqm.cpp b/src/engine/renderer/tr_model_iqm.cpp index 167bc98e40..c865571542 100644 --- a/src/engine/renderer/tr_model_iqm.cpp +++ b/src/engine/renderer/tr_model_iqm.cpp @@ -948,10 +948,8 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) { personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && tr.viewParms.portalLevel == 0; - // // cull the entire model if merged bounding box of both frames // is outside the view frustum. - // R_CullIQM( ent ); // HACK: Never cull first-person models, due to issues with a certain model's bounds @@ -962,16 +960,7 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) { return; } - // - // set up lighting now that we know we aren't culled - // - if ( !personalModel || glConfig2.shadowMapping ) { - R_SetupEntityLighting( &tr.refdef, ent, nullptr ); - } - - // // see if we are in a fog volume - // fogNum = R_FogWorldBox( ent->worldBounds ); for ( i = 0 ; i < IQModel->num_surfaces ; i++ ) { diff --git a/src/engine/renderer/tr_scene.cpp b/src/engine/renderer/tr_scene.cpp index 2aa9d5cf6a..aa02565b4a 100644 --- a/src/engine/renderer/tr_scene.cpp +++ b/src/engine/renderer/tr_scene.cpp @@ -274,7 +274,6 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) } backEndData[ tr.smpFrame ]->entities[ r_numEntities ].e = *ent; - backEndData[ tr.smpFrame ]->entities[ r_numEntities ].lightingCalculated = false; r_numEntities++; } diff --git a/src/engine/renderer/tr_shader.cpp b/src/engine/renderer/tr_shader.cpp index f5c2b10184..77b52a80ce 100644 --- a/src/engine/renderer/tr_shader.cpp +++ b/src/engine/renderer/tr_shader.cpp @@ -6641,7 +6641,8 @@ A second parameter will cause it to print in sorted order class ListShadersCmd : public Cmd::StaticCmd { public: - ListShadersCmd() : StaticCmd("listShaders", "list q3shaders currently registered in the renderer") {} + ListShadersCmd() : StaticCmd( + "listShaders", Cmd::RENDERER, "list q3shaders currently registered in the renderer") {} void Run( const Cmd::Args &args ) const override { @@ -6858,7 +6859,8 @@ static ListShadersCmd listShadersCmdRegistration; class ShaderExpCmd : public Cmd::StaticCmd { public: - ShaderExpCmd() : StaticCmd("shaderexp", "evaluate a q3shader expression (RB_EvalExpression)") {} + ShaderExpCmd() : StaticCmd( + "shaderexp", Cmd::RENDERER, "evaluate a q3shader expression (RB_EvalExpression)") {} void Run( const Cmd::Args &args ) const override { diff --git a/src/engine/renderer/tr_skin.cpp b/src/engine/renderer/tr_skin.cpp index ee552a4a73..2f3afbf110 100644 --- a/src/engine/renderer/tr_skin.cpp +++ b/src/engine/renderer/tr_skin.cpp @@ -330,7 +330,7 @@ skin_t *R_GetSkinByHandle( qhandle_t hSkin ) class ListSkinsCmd : public Cmd::StaticCmd { public: - ListSkinsCmd() : StaticCmd("listSkins", "list model skins") {} + ListSkinsCmd() : StaticCmd("listSkins", Cmd::RENDERER, "list model skins") {} void Run( const Cmd::Args & ) const override { diff --git a/src/engine/renderer/tr_world.cpp b/src/engine/renderer/tr_world.cpp index 2f05042212..4ca207aec0 100644 --- a/src/engine/renderer/tr_world.cpp +++ b/src/engine/renderer/tr_world.cpp @@ -322,9 +322,6 @@ void R_AddBSPModelSurfaces( trRefEntity_t *ent ) return; } - // Tr3B: BSP inline models should always use vertex lighting - R_SetupEntityLighting( &tr.refdef, ent, boundsCenter ); - fogNum = R_FogWorldBox( ent->worldBounds ); for ( i = 0; i < bspModel->numSurfaces; i++ ) diff --git a/src/engine/server/sv_ccmds.cpp b/src/engine/server/sv_ccmds.cpp index 963ec38066..1f5667f534 100644 --- a/src/engine/server/sv_ccmds.cpp +++ b/src/engine/server/sv_ccmds.cpp @@ -47,7 +47,7 @@ These commands can only be entered from stdin or by a remote operator datagram class MapCmd: public Cmd::StaticCmd { public: MapCmd(Str::StringRef name, Str::StringRef description, bool cheat): - Cmd::StaticCmd(name, Cmd::SYSTEM, description), cheat(cheat) { + Cmd::StaticCmd(name, Cmd::SERVER, description), cheat(cheat) { } void Run(const Cmd::Args& args) const override { @@ -255,7 +255,7 @@ class StatusCmd: public Cmd::StaticCmd { public: StatusCmd(): - StaticCmd("status", Cmd::SYSTEM, "Shows a table with server and player information") + StaticCmd("status", Cmd::SERVER, "Shows a table with server and player information") {} void Run(const Cmd::Args&) const override @@ -402,7 +402,7 @@ class ListMapsCmd: public Cmd::StaticCmd { public: ListMapsCmd(): - StaticCmd("listmaps", Cmd::SYSTEM, "Lists all maps available to the server") + StaticCmd("listmaps", Cmd::SERVER, "Lists all maps available to the server") {} void Run(const Cmd::Args&) const override diff --git a/src/engine/server/sv_init.cpp b/src/engine/server/sv_init.cpp index 9cff95dfa0..306b5e24d5 100644 --- a/src/engine/server/sv_init.cpp +++ b/src/engine/server/sv_init.cpp @@ -345,7 +345,8 @@ void SV_Startup() Cvar_Set( "sv_running", "1" ); #ifndef BUILD_SERVER - NET_Config( true ); + // For clients, reconfigure to open server ports. + NET_EnableNetworking( true ); #endif // Join the IPv6 multicast group now that a map is running, so clients can scan for us on the local network. @@ -767,7 +768,8 @@ void SV_Shutdown( const char *finalmsg ) Cvar_Set( "sv_running", "0" ); #ifndef BUILD_SERVER - NET_Config( true ); + // For clients, reconfigure to close server ports. + NET_EnableNetworking( false ); #endif SV_NET_Config(); // clear master server DNS queries diff --git a/src/engine/sys/sdl_glimp.cpp b/src/engine/sys/sdl_glimp.cpp index d484be43f8..36519fccd3 100644 --- a/src/engine/sys/sdl_glimp.cpp +++ b/src/engine/sys/sdl_glimp.cpp @@ -501,7 +501,7 @@ void GLimp_Shutdown() } static Cmd::LambdaCmd minimizeCmd( - "minimize", "minimize the window", + "minimize", Cmd::CLIENT, "minimize the window", []( const Cmd::Args & ) { SDL_MinimizeWindow( window ); }); static void SetSwapInterval( int swapInterval )