Skip to content

Commit

Permalink
Merge branch 'master' into for-0.56.0/sync
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed Jan 25, 2025
2 parents b30415a + 3265f2d commit bc94987
Show file tree
Hide file tree
Showing 27 changed files with 204 additions and 335 deletions.
11 changes: 11 additions & 0 deletions cmake/DaemonFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion src/common/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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) {
}
Expand All @@ -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
{
Expand Down
30 changes: 20 additions & 10 deletions src/common/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down Expand Up @@ -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);
};

Expand All @@ -180,7 +188,9 @@ namespace Cmd {
public:
using RunFn = std::function<void(const Args&)>;
using CompleteFn = std::function<CompletionResult(int, const Args&, Str::StringRef)>;
#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;
Expand Down
14 changes: 7 additions & 7 deletions src/engine/client/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
{}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/engine/framework/BaseCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
25 changes: 14 additions & 11 deletions src/engine/framework/CommandSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,11 @@ namespace Cmd {
void Run(const Cmd::Args& args) const override {
CommandMap& commands = GetCommandMap();

std::vector<const commandRecord_t*> matches;
std::vector<const std::string*> matchesNames;
std::vector<CommandMap::const_iterator> 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
Expand All @@ -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<size_t>(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());
Expand All @@ -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);
}
6 changes: 3 additions & 3 deletions src/engine/qcommon/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -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
{
Expand Down
Loading

0 comments on commit bc94987

Please sign in to comment.