More conversion
This commit is contained in:
+50
-30
@@ -20,8 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _QUAKE_CMD_H
|
||||
#define _QUAKE_CMD_H
|
||||
#pragma once
|
||||
|
||||
// cmd.h -- Command buffer and command execution
|
||||
|
||||
@@ -72,56 +71,77 @@ not apropriate.
|
||||
|
||||
typedef void (*xcommand_t) (void);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
src_client, // came in over a net connection as a clc_stringcmd
|
||||
// host_client will be valid during this state.
|
||||
src_command // from the command buffer
|
||||
} cmd_source_t;
|
||||
|
||||
extern cmd_source_t cmd_source;
|
||||
|
||||
void Cmd_Init (void);
|
||||
namespace command {
|
||||
enum class source {
|
||||
client,
|
||||
command
|
||||
};
|
||||
|
||||
extern source last_source;
|
||||
|
||||
struct alias {
|
||||
std::string name;
|
||||
std::string value;
|
||||
};
|
||||
|
||||
struct definition {
|
||||
std::string name{};
|
||||
xcommand_t func{nullptr};
|
||||
|
||||
definition(const std::string &name, const xcommand_t func) {
|
||||
this->name = name;
|
||||
this->func = func;
|
||||
}
|
||||
};
|
||||
|
||||
using definition_view = std::ranges::elements_view<std::ranges::ref_view<std::map<std::string, definition, std::less<>>>, 1>;
|
||||
using alias_view = std::ranges::elements_view<std::ranges::ref_view<std::map<std::string, alias, std::less<>>>, 1>;
|
||||
|
||||
|
||||
void init();
|
||||
|
||||
void add(const std::string &name, xcommand_t cmd);
|
||||
std::optional<std::string> complete(const std::string &partial);
|
||||
bool exists(std::string_view lookup);
|
||||
|
||||
int argc();
|
||||
std::optional<std::string> argv(int arg);
|
||||
std::string args();
|
||||
|
||||
int check_parm(const std::string &parm);
|
||||
|
||||
void tokenize_string(const std::string &text);
|
||||
|
||||
void execute_string(const std::string &text, source src);
|
||||
|
||||
void forward_to_server();
|
||||
|
||||
definition_view get_commands();
|
||||
|
||||
alias_view get_aliases();
|
||||
}
|
||||
|
||||
void Cmd_AddCommand (const char *cmd_name, xcommand_t function);
|
||||
// called by the init functions of other parts of the program to
|
||||
// register commands and functions to call for them.
|
||||
// The cmd_name is referenced later, so it should not be in temp memory
|
||||
|
||||
qboolean Cmd_Exists (const char *cmd_name);
|
||||
// used by the cvar code to check for cvar / command name overlap
|
||||
|
||||
const char *Cmd_CompleteCommand (const char *partial);
|
||||
// attempts to match a partial command for automatic command line completion
|
||||
// returns NULL if nothing fits
|
||||
|
||||
int Cmd_Argc (void);
|
||||
const char *Cmd_Argv (int arg);
|
||||
const char *Cmd_Args (void);
|
||||
// The functions that execute commands get their parameters with these
|
||||
// functions. Cmd_Argv () will return an empty string, not a NULL
|
||||
// if arg > argc, so string operations are allways safe.
|
||||
|
||||
int Cmd_CheckParm (const char *parm);
|
||||
// Returns the position (1 to argc-1) in the command's argument list
|
||||
// where the given parameter apears, or 0 if not present
|
||||
|
||||
void Cmd_TokenizeString (const char *text);
|
||||
// Takes a null terminated string. Does not need to be /n terminated.
|
||||
// breaks the string up into arg tokens.
|
||||
|
||||
void Cmd_ExecuteString (const char *text, cmd_source_t src);
|
||||
// Parses a single line of text into arguments and tries to execute it.
|
||||
// The text can come from the command buffer, a remote client, or stdin.
|
||||
|
||||
void Cmd_ForwardToServer (void);
|
||||
// adds the current command line as a clc_stringcmd to the client message.
|
||||
// things like godmode, noclip, etc, are commands directed to the server,
|
||||
// so when they are typed in at the console, they will need to be forwarded.
|
||||
|
||||
void Cmd_Print (const char *text);
|
||||
// used by command functions to send output to either the graphics console or
|
||||
// passed as a print message to the client
|
||||
|
||||
#endif /* _QUAKE_CMD_H */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user