67 #include "../shared/infostring.h"
68 #include "../shared/parse.h"
69 #include "../ports/system.h"
103 Com_Printf(
"Unknown command \"%s\" - wasn't sent to server\n", cmd);
109 msg.
add(cmd, strlen(cmd));
128 }
else if (argc == 2) {
129 const char* env = SDL_getenv(
Cmd_Argv(1));
224 Com_Printf(
"Could not connect to localhost\n");
291 #ifdef ACTIVATE_PACKET_COMMAND
299 static void CL_Packet_f (
void)
314 const int l = strlen(in);
318 for (
int i = 0;
i < l;
i++) {
319 if (in[
i] ==
'\\' && in[
i + 1] ==
'n') {
362 Com_Printf(
"Dup connect received. Ignored.\n");
376 Com_Printf(
"Command packet from remote host. Ignored.\n");
407 UI_Popup(
_(
"Connection failure"),
_(
"The password you specified was wrong."));
410 UI_Popup(
_(
"Connection failure"),
_(
"This server requires a password."));
414 UI_Popup(
_(
"Connection failure"),
_(
"This server is full."));
417 UI_Popup(
_(
"Connection failure"),
_(
"You are banned on this server."));
420 UI_Popup(
_(
"Connection failure"),
_(
"The game has already started."));
423 UI_Popup(
_(
"Connection failure"),
_(
"The server is running a different version of the game."));
425 Cvar_Set(
"rcon_password",
"%s",
"");
426 UI_Popup(
_(
"Bad rcon password"),
_(
"The rcon password you specified was wrong."));
429 UI_Popup(
_(
"Connection failure"),
_(
"The server refused the connection."));
437 Com_Printf(
"Unknown command received \"%s\"\n", c);
503 bool startedDownload =
false;
510 return startedDownload;
513 if (token[0] ==
'-') {
520 Com_sprintf(name,
sizeof(name),
"%s%s", base, token + 1);
527 return startedDownload;
532 bool startedDownload;
537 if (!startedDownload) {
543 return startedDownload;
563 UI_Popup(
_(
"Error"),
_(
"Script files are not the same"));
582 Com_Printf(
"You are using modified ufo script files - might produce problems\n");
588 UI_Popup(
_(
"Error"),
_(
"Local map version differs from server"));
651 float requestedRation = atof(
Cmd_Argv(1));
654 const float delta = 0.01;
666 requestedRation = atof(
Cmd_Argv(1));
671 bool visible =
false;
672 const int result = sscanf(
OPTIONEXTRADATA(option).label,
"%i x %i", &width, &height);
674 Com_Error(
ERR_FATAL,
"CL_SetRatioFilter_f: Impossible to decode resolution label.\n");
675 const float ratio = (float)width / (
float)height;
681 visible = ratio > 2 || (ratio > 1.7 && ratio < 1.76);
683 visible = ratio - delta < requestedRation && ratio + delta > requestedRation;
685 option->
invis = !visible;
686 option = option->
next;
707 if (!
Q_streq(name,
"default") != 0) {
708 Com_Error(
ERR_DROP,
"CL_ParseActorSkin: First actorskin read from script must be \"default\" skin.");
722 const char* map1 = ((
const mapDef_t*)mapDef1)->mapTheme;
723 const char* map2 = ((
const mapDef_t*)mapDef2)->mapTheme;
726 if (map1[0] ==
'+' || map1[0] ==
'.')
728 if (map2[0] ==
'+' || map2[0] ==
'.')
773 #ifndef COMPILE_UNITTESTS
774 static int progressCurrent = 0;
777 if (progressCurrent % 10 == 0)
783 else if (
Q_streq(type,
"component"))
785 else if (
Q_streq(type,
"particle"))
787 else if (
Q_streq(type,
"language"))
789 else if (
Q_streq(type,
"font"))
791 else if (
Q_streq(type,
"tutorial"))
793 else if (
Q_streq(type,
"menu_model"))
795 else if (
Q_streq(type,
"sprite"))
797 else if (
Q_streq(type,
"sequence"))
799 else if (
Q_streq(type,
"music"))
801 else if (
Q_streq(type,
"actorskin"))
803 else if (
Q_streq(type,
"cgame"))
820 const char* configString;
829 if (configString[0] ==
'\0')
831 Com_Printf(
"configstring[%3i]: %s\n",
i, configString);
864 cl_connecttimeout =
Cvar_Get(
"cl_connecttimeout",
"25000",
CVAR_ARCHIVE,
"Connection timeout for multiplayer connects");
868 cl_ready =
Cvar_Get(
"cl_ready",
"0",
CVAR_USERINFO,
"Ready indicator in the userinfo for tactical missions");
874 cl_map_debug =
Cvar_Get(
"debug_map",
"0", 0,
"Activate realtime map debugging options - bitmask. Valid values are 0, 1, 3 and 7");
877 cl_leshowinvis =
Cvar_Get(
"cl_leshowinvis",
"0",
CVAR_ARCHIVE,
"Show invisible local entities as null models");
886 #ifdef ACTIVATE_PACKET_COMMAND
888 Cmd_AddCommand(
"packet", CL_Packet_f,
"Dangerous debug function for network testing");
905 Cmd_AddCommand(
"players",
nullptr,
"List of team and player name");
907 Cmd_AddCommand(
"debug_cgrid", Grid_DumpWholeClientMap_f,
"Shows the whole client side pathfinding grid of the current loaded map");
908 Cmd_AddCommand(
"debug_croute", Grid_DumpClientRoutes_f,
"Shows the whole client side pathfinding grid of the current loaded map");
909 Cmd_AddCommand(
"debug_listle", LE_List_f,
"Shows a list of current know local entities with type and status");
910 Cmd_AddCommand(
"debug_listlm", LM_List_f,
"Shows a list of current know local models");
912 Cmd_AddCommand(
"debug_edictdestroy",
nullptr,
"Call the 'destroy' function of a given edict");
913 Cmd_AddCommand(
"debug_edictuse",
nullptr,
"Call the 'use' function of a given edict");
914 Cmd_AddCommand(
"debug_edicttouch",
nullptr,
"Call the 'touch' function of a given edict");
917 Cmd_AddCommand(
"debug_listscore",
nullptr,
"Shows mission-score entries of all team members");
918 Cmd_AddCommand(
"debug_statechange",
nullptr,
"Change the state of an edict");
953 dbuffer msg(strlen(userInfo) + 2);
996 Com_Error(
ERR_DROP,
"Server aborted connection - the server didn't response in %is. You can try to increase the cvar cl_connecttimeout",
997 cl_connecttimeout->
integer / 1000);
1021 switch (cls.
state) {
1050 static int lastFrame = 0;
1057 delta = now - lastFrame;
1155 fs_i18ndir =
Cvar_Get(
"fs_i18ndir",
"", 0,
"System path to language files");
1157 setlocale(LC_ALL,
"C");
1161 setlocale(LC_MESSAGES,
"");
1165 if (fs_i18ndir->
string[0] !=
'\0')
1169 Com_sprintf(languagePath,
sizeof(languagePath), LOCALEDIR);
1223 printf(
"recursive shutdown\n");
bool CL_ParseClientData(const char *type, const char *name, const char **text)
Called at client startup.
bool Com_ParseBlock(const char *name, const char **text, void *base, const value_t *values, memPool_t *mempool)
void CL_CameraMove(void)
Update the camera position. This can be done in two different reasons. The first is the user input...
const char * Cmd_Argv(int arg)
Returns a given argument.
static cvar_t * fs_i18ndir
void NET_StreamFinished(struct net_stream *s)
Call NET_StreamFinished to mark the stream as uninteresting, but to finish sending any data in the bu...
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
mapTiles_t * SV_GetMapTiles(void)
static void CL_InitMemPools(void)
static void CL_SetRatioFilter_f(void)
cvarChangeListener_t * Cvar_RegisterChangeListener(const char *varName, cvarChangeListenerFunc_t listenerFunc)
Registers a listener that is executed each time a cvar changed its value.
void SCR_DrawLoading(int percent)
Draws the current loading pic of the map from base/pics/maps/loading.
void Sys_SetAffinityAndPriority(void)
memPool_t * vid_modelPool
static void CL_UserInfo_f(void)
Prints the current userinfo string to the game console.
QGL_EXTERN GLint GLenum type
mapDef_t mds[MAX_MAPDEFS]
struct net_stream * NET_Connect(const char *node, const char *service, stream_onclose_func *onclose)
Try to connect to a given host on a given port.
void Cvar_UnRegisterChangeListener(const char *varName, cvarChangeListenerFunc_t listenerFunc)
Unregisters a cvar change listener.
static void CL_ShowConfigstrings_f(void)
Print the configstrings to game console.
bool UI_ParseAndLoadLuaScript(const char *name, const char **text)
Parses and loads a .ufo file holding a lua script.
void S_Stop(void)
Stop all channels.
void TOTD_InitStartup(void)
Init function for cvars and console command bindings.
#define NET_STATE_DISCONNECT
void CL_ViewPrecacheModels(void)
Precaches all models at game startup - for faster access.
void TUT_ParseTutorials(const char *name, const char **text)
Basic lua initialization for the ui.
bool CL_OnBattlescape(void)
Check whether we are in a tactical mission as server or as client. But this only means that we are ab...
bool UI_ParseComponent(const char *type, const char *name, const char **text)
Parse a component.
int Sys_Setenv(const char *name, const char *value)
set/unset environment variables (empty value removes it)
void GAME_SpawnSoldiers(void)
Called during startup of mission to send team info.
static const value_t actorskin_vals[]
valid actorskin descriptors
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
#define CL_CMD_CLIENT_CONNECT
void M_ParseMusic(const char *name, const char **text)
Parses music definitions for different situations.
static void CL_Precache_f(void)
The server will send this command right before allowing the client into the server.
void UI_Shutdown(void)
Reset and free the UI data hunk.
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
#define BAD_RCON_PASSWORD
static void CL_SendChangedUserinfos(void)
Send the userinfo to the server (and to all other clients) when they changed (CVAR_USERINFO) ...
char * CL_GetConfigString(int index)
void NET_Wait(int timeout)
void SCR_DrawLoadingScreen(bool string, int percent)
Precache and loading screen at startup.
static void CL_ReadPackets(void)
void ACTOR_InitStartup(void)
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
void CL_SlowFrame(int now, void *data)
#define REJ_CONNECTION_REFUSED
bool GAME_HandleServerCommand(const char *command, dbuffer *msg)
struct net_stream * NET_ConnectToLoopBack(stream_onclose_func *onclose)
void CL_ServerEventsInit(void)
void R_ShutdownModels(bool complete)
Frees the model pool.
void CL_LanguageInit(void)
Fills the options language menu node with the parsed language mappings.
void CL_LanguageShutdown(void)
void Cbuf_AddText(const char *format,...)
Adds command text at the end of the buffer.
void NET_WriteString(dbuffer *buf, const char *str)
void GAME_ParseModes(const char *name, const char **text)
Shared game type headers.
static void CL_ParseActorSkin(const char *name, const char **text)
memPool_t * vid_genericPool
void CL_ShutdownLua(void)
Shutdown the ui-lua interfacing environment.
unsigned int CL_GetActorSkinCount(void)
Get number of registered actorskins.
void SCR_UpdateScreen(void)
This is called every frame, and can also be called explicitly to flush text to the screen...
Events that are send from the client to the server.
void Cmd_TokenizeString(const char *text, bool macroExpand, bool replaceWhitespaces)
Parses the given string into command line tokens.
bool CL_PendingHTTPDownloads(void)
See if we're still busy with some downloads. Called by precacher just before it loads the map since w...
void Com_Printf(const char *const fmt,...)
uiNode_t * UI_GetOption(int dataId)
Header file for inventory handling and Equipment menu.
int CL_GetConfigStringInteger(int index)
static void CL_ClearState(void)
Called after tactical missions to wipe away the tactical-mission-only data.
cvar_t * masterserver_url
static void CL_InitLocal(void)
Calls all reset functions for all subsystems like production and research also initializes the cvars ...
void GAME_UnloadGame(void)
void CL_Drop(void)
Ensures the right menu cvars are set after error drop or map change.
bool UI_ParseUIModel(const char *name, const char **text)
parses the models.ufo and all files where UI models (menu_model) are defined
memPool_t * cl_genericPool
static cvar_t * cl_connecttimeout
#define Q_strvalid(string)
int Com_GetScriptChecksum(void)
void Com_Error(int code, const char *fmt,...)
void TUT_InitStartup(void)
cvar_t * Cvar_GetFirst(void)
Return the first cvar of the cvar list.
void CL_ParseTipOfTheDay(const char *name, const char **text)
Parse all tip definitions from the script files.
void CL_InitAfter(void)
Init function for clients - called after menu was initialized and ufo-scripts were parsed...
#define REJ_GAME_ALREADY_STARTED
void LE_Cleanup(void)
Cleanup unused LE inventories that the server sent to the client also free some unused LE memory...
void GAME_EndBattlescape(void)
This is called when a client quits the battlescape.
#define MAX_STRING_TOKENS
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
mapData_t * SV_GetMapData(void)
void add(const char *, size_t)
void NET_OOB_Printf(struct net_stream *s, const char *format,...)
Out of band print.
uiNode_t * UI_PushWindow(const char *name, const char *parentName, linkedList_t *params)
Push a window onto the window stack.
void CL_RequestNextDownload(void)
static void CL_RContextCvarChange(const char *cvarName, const char *oldValue, const char *newValue, void *data)
#define OPTIONEXTRADATA(node)
void CL_ParseSequence(const char *name, const char **text)
Reads the sequence values from given text-pointer.
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
int NET_ReadString(dbuffer *buf, char *string, size_t length)
void CL_HTTP_Cleanup(void)
UFO is exiting or we're changing servers. Clean up.
void GAME_SetMode(const cgame_export_t *gametype)
void GAME_InitMissionBriefing(const char *title)
void CL_InitLua(void)
Initializes the ui-lua interfacing environment.
void SCR_EndLoadingPlaque(void)
#define REJ_PASSWORD_REQUIRED_OR_INCORRECT
Reject messages that are send to the client from the game module.
void GAME_Frame(void)
Called every frame and allows us to hook into the current running game mode.
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
bool UI_ParseWindow(const char *type, const char *name, const char **text)
Parse a window.
static void CL_RImagesCvarChange(const char *cvarName, const char *oldValue, const char *newValue, void *data)
static bool CL_DownloadMap(const char *map)
void Con_SaveConsoleHistory(void)
Stores the console history.
cgame team management headers.
#define Mem_CreatePool(name)
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
bool CL_CheckOrDownloadFile(const char *filename)
Battlescape radar header.
static bool CL_DownloadUMPMap(const char *tiles)
bool GAME_IsMultiplayer(void)
const char * FS_GetCwd(void)
Return current working dir.
bool Com_IsUserinfoModified(void)
void CL_ViewCalcFieldOfViewX(void)
Calculates refdef's FOV_X. Should generally be called after any changes are made to the zoom level (v...
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
struct net_stream * netStream
#define MAX_CONFIGSTRINGS
memPool_t * vid_lightPool
void CL_ActorTargetAlign_f(void)
Targets to the ground when holding the assigned button.
static void CL_SendCommand(void)
static void CL_Connect(void)
Header for certain screen operations.
Atomic structure used to define most of the UI.
void Cvar_FixCheatVars(void)
Reset cheat cvar values to default.
Particle system header file.
void CL_Frame(int now, void *data)
const char * Sys_GetCurrentUser(void)
bool UI_ParseSprite(const char *name, const char **text)
void HUD_InitStartup(void)
static void CL_SpawnSoldiers_f(void)
Send the clc_teaminfo command to server.
void WEB_InitStartup(void)
void CL_BattlescapeRadarInit(void)
static void CL_StartMatch_f(void)
void Cmd_ForwardToServer(void)
adds the current command line as a clc_stringcmd to the client message. things like action...
static void CL_ConnectionlessPacket(dbuffer *msg)
Responses to broadcasts, etc.
static void CL_FreeClientStream(void)
void CL_RunHTTPDownloads(void)
This calls curl_multi_perform do actually do stuff. Called every frame while connecting to minimise l...
Not cleared on a map change (static data)
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
static void CL_Reconnect(void)
void LE_Think(void)
Calls the le think function and updates the animation. The animation updated even if the particular l...
static void CL_Quit_f(void)
void SCR_BeginLoadingPlaque(void)
void Sys_OpenURL(const char *url)
void CL_SetHTTPServer(const char *URL)
A new server is specified, so we nuke all our state.
void CL_ParseLanguages(const char *name, const char **text)
Parse all language definitions from the script files.
#define REJ_SERVER_VERSION_MISMATCH
QGL_EXTERN GLuint GLchar GLuint * len
void INV_InitStartup(void)
void CL_SetClientState(connstate_t state)
Sets the client state.
UFOAI web interface management. Authentication as well as uploading/downloading stuff to and from you...
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
void NET_WriteByte(dbuffer *buf, byte c)
void CL_Shutdown(void)
Saves configuration file and shuts the client systems down.
void CL_ParseParticle(const char *name, const char **text)
Parses particle definitions from UFO-script files.
void HUD_Update(void)
Updates console vars for an actor.
void UI_RegisterOption(int dataId, uiNode_t *option)
static bool CL_CanMultiplayerStart(void)
static int Com_MapDefSort(const void *mapDef1, const void *mapDef2)
static void CL_ForwardToServer_f(void)
const char * Cvar_Userinfo(char *info, size_t infoSize)
Returns an info string containing all the CVAR_USERINFO cvars.
void Irc_Logic_Frame(void)
#define MEMBER_SIZEOF(TYPE, MEMBER)
static void CL_Env_f(void)
Set or print some environment variables via console command.
bool CL_LanguageTryToSet(const char *localeID)
Cycle through all parsed locale mappings and try to set one after another.
void R_FreeWorldImages(void)
Any image that is a mesh or world texture will be removed here.
static void CL_OpenURL_f(void)
Opens the specified URL and minimizes the game window. You have to specify the whole url including th...
int CL_ClearBattlescapeEvents(void)
memPool_t * vid_imagePool
bool NET_StreamIsLoopback(struct net_stream *s)
void Info_Print(const char *s)
Prints info strings (like userinfo or serverinfo - CVAR_USERINFO, CVAR_SERVERINFO) ...
void CL_Disconnect(void)
Sets the cls.state to ca_disconnected and informs the server.
int Q_StringSort(const void *string1, const void *string2)
Compare two strings.
void PTL_InitStartup(void)
Clears particle data.
dbuffer * NET_ReadMsg(struct net_stream *s)
Reads messages from the network channel and adds them to the dbuffer where you can use the NET_Read* ...
void GAME_InitStartup(void)
GLsizei const GLvoid * data
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
Primary header for client.
IRC client header for UFO:AI.
const char * Cvar_GetString(const char *varName)
Returns the value of cvar as string.
void SCR_RunConsole(void)
Scroll it up or down.
cvar_t * cl_log_battlescape_events
void GAME_StartMatch(void)
void TEAM_InitStartup(void)
void Cbuf_Execute(void)
Pulls off terminated lines of text from the command buffer and sends them through Cmd_ExecuteString...
void CL_ParseServerMessage(svc_ops_t cmd, dbuffer *msg)
Parses the server sent data from the given buffer.
void S_LoadSamples(void)
Wrapper for S_PrecacheSamples to avoid exposing it via s_sample.h.
int Com_ServerState(void)
Check whether we are the server or have a singleplayer tactical mission.
bool UI_ParseFont(const char *name, const char **text)
Header file for cinematics.
void CL_ViewLoadMedia(void)
Call before entering a new level, or after vid_restart.
int NET_ReadByte(dbuffer *buf)
Reads a byte from the netchannel.
const char * Cmd_Args(void)
Returns a single string containing argv(1) to argv(argc()-1)
void CL_ParticleRun(void)
General system for particle running during the game.
void CM_LoadMap(const char *tiles, bool day, const char *pos, const char *entityString, mapData_t *mapData, mapTiles_t *mapTiles)
Loads in the map and all submodels.
int CL_GetClientState(void)
int NET_ReadStringLine(dbuffer *buf, char *string, size_t length)
actorSkin_t * CL_AllocateActorSkin(const char *name)
Allocate a skin from the cls structure.
void Com_SetUserinfoModified(bool modified)
void HTTP_InitStartup(void)
int CL_Milliseconds(void)
void UI_DisplayNotice(const char *text, int time, const char *windowName)
Displays a message over all windows.
int Sys_Milliseconds(void)
void Key_WriteBindings(const char *filename)
Writes lines containing "bind key value".
void NET_WriteMsg(struct net_stream *s, dbuffer &buf)
Enqueue the buffer in the net stream for ONE client.