X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=common.c;h=9e549fe7dd8ab781a66172792d409221deba64f8;hb=c8040b7bcd6e0e31ab1d3d90c137414cb8d0d997;hp=7ce4b548eb07e34e1fc647e26208349e2ade7244;hpb=43ee5e136a693ac9cfb40cb03fceea7d3149104f;p=xonotic%2Fdarkplaces.git diff --git a/common.c b/common.c index 7ce4b548..9e549fe7 100644 --- a/common.c +++ b/common.c @@ -36,8 +36,6 @@ mempool_t *pak_mempool; qboolean com_modified; // set true if using non-id files -qboolean msg_suppress_1 = 0; - void COM_InitFilesystem (void); char com_token[1024]; @@ -52,6 +50,7 @@ char com_cmdline[CMDLINE_LENGTH]; int gamemode; char *gamename; char *gamedirname; +char com_modname[MAX_OSPATH]; /* @@ -376,7 +375,7 @@ char *MSG_ReadString (void) break; string[l] = c; l++; - } while (l < sizeof(string)-1); + } while (l < (int)sizeof(string)-1); string[l] = 0; @@ -468,52 +467,61 @@ void SZ_Print (sizebuf_t *buf, const char *data) } static char *hexchar = "0123456789ABCDEF"; -void SZ_HexDumpToConsole(const sizebuf_t *buf) +void Com_HexDumpToConsole(const qbyte *data, int size) { - int i; + int i, j, n; char text[1024]; char *cur, *flushpointer; + const qbyte *d; cur = text; flushpointer = text + 512; - for (i = 0;i < buf->cursize;i++) + for (i = 0;i < size;) { - if ((i & 15) == 0) + n = 16; + if (n > size - i) + n = size - i; + d = data + i; + *cur++ = hexchar[(i >> 12) & 15]; + *cur++ = hexchar[(i >> 8) & 15]; + *cur++ = hexchar[(i >> 4) & 15]; + *cur++ = hexchar[(i >> 0) & 15]; + *cur++ = ':'; + for (j = 0;j < n;j++) { - *cur++ = hexchar[(i >> 12) & 15]; - *cur++ = hexchar[(i >> 8) & 15]; - *cur++ = hexchar[(i >> 4) & 15]; - *cur++ = hexchar[(i >> 0) & 15]; - *cur++ = ':'; - *cur++ = ' '; + if (j & 1) + { + *cur++ = hexchar[(d[j] >> 4) & 15] | 0x80; + *cur++ = hexchar[(d[j] >> 0) & 15] | 0x80; + } + else + { + *cur++ = hexchar[(d[j] >> 4) & 15]; + *cur++ = hexchar[(d[j] >> 0) & 15]; + } } - else if ((i & 15) == 15) - *cur++ = '\n'; - else - *cur++ = ' '; - if (i & 1) + for (;j < 16;j++) { - *cur++ = hexchar[(buf->data[i] >> 4) & 15] | 0x80; - *cur++ = hexchar[(buf->data[i] >> 0) & 15] | 0x80; - } - else - { - *cur++ = hexchar[(buf->data[i] >> 4) & 15]; - *cur++ = hexchar[(buf->data[i] >> 0) & 15]; + *cur++ = ' '; + *cur++ = ' '; } - if (cur >= flushpointer) + for (j = 0;j < n;j++) + *cur++ = (d[j] >= ' ' && d[j] <= 0x7E) ? d[j] : '.'; + for (;j < 16;j++) + *cur++ = ' '; + *cur++ = '\n'; + i += n; + if (cur >= flushpointer || i >= size) { *cur++ = 0; Con_Printf("%s", text); cur = text; } } - if ((i & 15) != 0) - *cur++ = '\n'; - if (cur > text) - { - *cur++ = 0; - Con_Printf("%s", text); - } +} + +void SZ_HexDumpToConsole(const sizebuf_t *buf) +{ + Com_HexDumpToConsole(buf->data, buf->cursize); } @@ -796,6 +804,8 @@ void COM_InitGameType (void) if (strstr(name, "transfusion")) gamemode = GAME_TRANSFUSION; + else if (strstr(name, "nexiuz")) + gamemode = GAME_NEXIUZ; else if (strstr(name, "nehahra")) gamemode = GAME_NEHAHRA; else if (strstr(name, "hipnotic")) @@ -807,6 +817,8 @@ void COM_InitGameType (void) if (COM_CheckParm ("-transfusion")) gamemode = GAME_TRANSFUSION; + else if (COM_CheckParm ("-nexiuz")) + gamemode = GAME_NEXIUZ; else if (COM_CheckParm ("-nehahra")) gamemode = GAME_NEHAHRA; else if (COM_CheckParm ("-hipnotic")) @@ -834,6 +846,10 @@ void COM_InitGameType (void) gamename = "DarkPlaces-Nehahra"; gamedirname = "nehahra"; break; + case GAME_NEXIUZ: + gamename = "Nexiuz"; + gamedirname = "data"; + break; case GAME_TRANSFUSION: gamename = "Transfusion"; gamedirname = "transfusion"; @@ -1084,7 +1100,7 @@ void COM_CopyFile (char *netpath, char *cachepath) while (remaining) { - if (remaining < sizeof(buf)) + if (remaining < (int)sizeof(buf)) count = remaining; else count = sizeof(buf); @@ -1386,7 +1402,7 @@ void COM_AddGameDirectory (char *dir) list = listdirectory(dir); for (current = list;current;current = current->next) { - if (matchpattern(current->text, "*.pak")) + if (matchpattern(current->text, "*.pak", true)) { sprintf (pakfile, "%s/%s", dir, current->text); pak = COM_LoadPackFile (pakfile); @@ -1427,10 +1443,12 @@ void COM_InitFilesystem (void) com_basedir[i-1] = 0; // start up with GAMENAME by default (id1) + strcpy(com_modname, GAMENAME); COM_AddGameDirectory (va("%s/"GAMENAME, com_basedir)); if (gamedirname[0]) { com_modified = true; + strcpy(com_modname, gamedirname); COM_AddGameDirectory (va("%s/%s", com_basedir, gamedirname)); } @@ -1440,6 +1458,7 @@ void COM_InitFilesystem (void) if (i && i < com_argc-1) { com_modified = true; + strcpy(com_modname, com_argv[i+1]); COM_AddGameDirectory (va("%s/%s", com_basedir, com_argv[i+1])); }