X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=common.c;h=71c059aca7d739bb5452ce701c45dd432e51412f;hb=1a7bba11dc66eb6188b21c3aa6dfb5898be5299e;hp=3b7135a50da9bb2bdc71e7dfed11f5df0c876760;hpb=04ebd98618c773b10ada031f18b99f11020b559f;p=xonotic%2Fdarkplaces.git diff --git a/common.c b/common.c index 3b7135a5..71c059ac 100644 --- a/common.c +++ b/common.c @@ -19,20 +19,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // common.c -- misc functions used in client and server -#include "quakedef.h" - #include #include #ifndef WIN32 #include #endif +#include "quakedef.h" + cvar_t registered = {0, "registered","0", "indicates if this is running registered quake (whether gfx/pop.lmp was found)"}; cvar_t cmdline = {0, "cmdline","0", "contains commandline the engine was launched with"}; char com_token[MAX_INPUTLINE]; int com_argc; const char **com_argv; +int com_selffd = -1; gamemode_t gamemode; const char *gamename; @@ -605,7 +606,7 @@ void SZ_Write (sizebuf_t *buf, const unsigned char *data, int length) // attention, it has been eradicated from here, its only (former) use in // all of darkplaces. -static char *hexchar = "0123456789ABCDEF"; +static const char *hexchar = "0123456789ABCDEF"; void Com_HexDumpToConsole(const unsigned char *data, int size) { int i, j, n; @@ -1312,7 +1313,7 @@ skipwhite: else { // regular word - for (;!ISWHITESPACE(*data) && *data != ',' && *data != ';' && *data != '{' && *data != '}' && *data != ')' && *data != '(' && *data != ']' && *data != '[' && *data != ':' && *data != ',' && *data != ';';data++) + for (;!ISWHITESPACE(*data) && *data != '{' && *data != '}' && *data != ')' && *data != '(' && *data != ']' && *data != '[' && *data != ':' && *data != ',' && *data != ';';data++) if (len < (int)sizeof(com_token) - 1) com_token[len++] = *data; com_token[len] = 0; @@ -1420,13 +1421,13 @@ int COM_CheckParm (const char *parm) typedef struct gamemode_info_s { - const char* prog_name; - const char* cmdline; - const char* gamename; - const char* gamedirname1; - const char* gamedirname2; - const char* gamescreenshotname; - const char* gameuserdirname; + const char* prog_name; // not null + const char* cmdline; // not null + const char* gamename; // not null + const char* gamedirname1; // not null + const char* gamedirname2; // null + const char* gamescreenshotname; // not nul + const char* gameuserdirname; // not null } gamemode_info_t; static const gamemode_info_t gamemode_info [GAME_COUNT] = @@ -1447,6 +1448,9 @@ static const gamemode_info_t gamemode_info [GAME_COUNT] = // GAME_NEXUIZ // COMMANDLINEOPTION: Game: -nexuiz runs the multiplayer game Nexuiz { "nexuiz", "-nexuiz", "Nexuiz", "data", NULL, "nexuiz", "nexuiz" }, +// GAME_XONOTIC +// COMMANDLINEOPTION: Game: -xonotic runs the multiplayer game Xonotic +{ "xonotic", "-xonotic", "Xonotic", "data", NULL, "xonotic", "xonotic" }, // GAME_TRANSFUSION // COMMANDLINEOPTION: Game: -transfusion runs Transfusion (the recreation of Blood in Quake) { "transfusion", "-transfusion", "Transfusion", "basetf", NULL, "transfusion", "transfusion" }, @@ -1498,21 +1502,28 @@ static const gamemode_info_t gamemode_info [GAME_COUNT] = // GAME_EDU2P // COMMANDLINEOPTION: Game: -edu2p runs the game Edu2 prototype { "edu2p", "-edu2p", "EDU2 Prototype", "id1", "edu2", "edu2_p", "edu2prototype" }, -// GAME_BLADEMASTER -// COMMANDLINEOPTION: Game: -blademaster runs the game Prophecy: Return of the BladeMaster -{ "blademaster", "-blademaster", "Prophecy: Return of the BladeMaster", "basebm", NULL, "blademaster", "blademaster" }, // GAME_PROPHECY -// COMMANDLINEOPTION: Game: -prophecy runs the game Quake (default) +// COMMANDLINEOPTION: Game: -prophecy runs the game Prophecy { "prophecy", "-prophecy", "Prophecy", "data", NULL, "prophecy", "prophecy" }, // GAME_BLOODOMNICIDE // COMMANDLINEOPTION: Game: -omnicide runs the game Blood Omnicide { "omnicide", "-omnicide", "Blood Omnicide", "kain", NULL, "omnicide", "omnicide" }, +// GAME_STEELSTORM +// COMMANDLINEOPTION: Game: -steelstorm runs the game Steel Storm +{ "steelstorm", "-steelstorm", "Steel-Storm", "gamedata", NULL, "ss", "steelstorm" }, +// GAME_STRAPBOMB +// COMMANDLINEOPTION: Game: -strapbomb runs the game Strap-on-bomb Car +{ "strapbomb", "-strapbomb", "Strap-on-bomb Car", "id1", NULL, "strap", "strapbomb" }, +// GAME_MOONHELM +// COMMANDLINEOPTION: Game: -moonhelm runs the game MoonHelm +{ "moonhelm", "-moonhelm", "MoonHelm", "data", NULL, "mh", "moonhelm" }, }; void COM_InitGameType (void) { char name [MAX_OSPATH]; unsigned int i; + int t; FS_StripExtension (com_argv[0], name, sizeof (name)); COM_ToLowerString (name, name, sizeof (name)); @@ -1539,6 +1550,17 @@ void COM_InitGameType (void) gamedirname2 = gamemode_info[gamemode].gamedirname2; gamescreenshotname = gamemode_info[gamemode].gamescreenshotname; gameuserdirname = gamemode_info[gamemode].gameuserdirname; + + if((t = COM_CheckParm("-customgamename")) && t + 1 < com_argc) + gamename = com_argv[t+1]; + if((t = COM_CheckParm("-customgamedirname1")) && t + 1 < com_argc) + gamedirname1 = com_argv[t+1]; + if((t = COM_CheckParm("-customgamedirname2")) && t + 1 < com_argc) + gamedirname2 = *com_argv[t+1] ? com_argv[t+1] : NULL; + if((t = COM_CheckParm("-customgamescreenshotname")) && t + 1 < com_argc) + gamescreenshotname = com_argv[t+1]; + if((t = COM_CheckParm("-customgameuserdirname")) && t + 1 < com_argc) + gameuserdirname = com_argv[t+1]; } @@ -1980,8 +2002,6 @@ void InfoString_GetValue(const char *buffer, const char *key, char *value, size_ size_t keylength; if (!key) key = ""; - if (!value) - value = ""; keylength = strlen(key); if (valuelength < 1 || !value) { @@ -2212,3 +2232,31 @@ void FindFraction(double val, int *num, int *denom, int denomMax) } } } + +// decodes an XPM from C syntax +char **XPM_DecodeString(const char *in) +{ + static char *tokens[257]; + static char lines[257][512]; + size_t line = 0; + + // skip until "{" token + while(COM_ParseToken_QuakeC(&in, false) && strcmp(com_token, "{")); + + // now, read in succession: string, comma-or-} + while(COM_ParseToken_QuakeC(&in, false)) + { + tokens[line] = lines[line]; + strlcpy(lines[line++], com_token, sizeof(lines[0])); + if(!COM_ParseToken_QuakeC(&in, false)) + return NULL; + if(!strcmp(com_token, "}")) + break; + if(strcmp(com_token, ",")) + return NULL; + if(line >= sizeof(tokens) / sizeof(tokens[0])) + return NULL; + } + + return tokens; +}