Some cleanups, reworked commandline parsing, added basedir command
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2557 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
0b22c1f542
commit
b0759ce32f
6 changed files with 103 additions and 58 deletions
|
@ -43,7 +43,7 @@ struct bsp_s {
|
|||
intermission_t intermissionspot[8];
|
||||
};
|
||||
|
||||
static const intermission_t nullintermissionspot;
|
||||
static const intermission_t nullintermissionspot = {{0}};
|
||||
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -9,8 +9,8 @@ Contains the control routines that handle both incoming and outgoing stuff
|
|||
|
||||
|
||||
// char *date = "Oct 24 1996";
|
||||
static char *date = __DATE__ ;
|
||||
static char *mon[12] =
|
||||
static const char *date = __DATE__ ;
|
||||
static const char *mon[12] =
|
||||
{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
||||
static char mond[12] =
|
||||
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
|
@ -18,13 +18,10 @@ static char mond[12] =
|
|||
// returns days since Oct 24 1996
|
||||
int build_number( void )
|
||||
{
|
||||
int m = 0;
|
||||
int m;
|
||||
int d = 0;
|
||||
int y = 0;
|
||||
static int b = 0;
|
||||
|
||||
if (b != 0)
|
||||
return b;
|
||||
int y;
|
||||
int b;
|
||||
|
||||
for (m = 0; m < 11; m++)
|
||||
{
|
||||
|
@ -410,37 +407,66 @@ void DoCommandLine(cluster_t *cluster, int argc, char **argv)
|
|||
{
|
||||
int i;
|
||||
char commandline[8192];
|
||||
char *start, *end, *result;
|
||||
char *result;
|
||||
char *arg;
|
||||
char buffer[8192];
|
||||
|
||||
//exec the - commands
|
||||
commandline[0] = '\0';
|
||||
for (i = 1; i <= argc; i++)
|
||||
{
|
||||
if (i == argc)
|
||||
arg = "";
|
||||
else
|
||||
{
|
||||
arg = argv[i];
|
||||
if (!arg) //NeXT can do this supposedly
|
||||
arg = "";
|
||||
}
|
||||
if(i == argc || *arg == '+' || *arg == '-')
|
||||
{
|
||||
if (commandline[0] == '-')
|
||||
{
|
||||
result = Rcon_Command(cluster, NULL, commandline+1, buffer, sizeof(buffer), true);
|
||||
Sys_Printf(cluster, "%s", result);
|
||||
}
|
||||
|
||||
commandline[0] = '\0';
|
||||
}
|
||||
strcat(commandline, arg);
|
||||
strcat(commandline, " ");
|
||||
}
|
||||
|
||||
//exec the configs
|
||||
result = Rcon_Command(cluster, NULL, "exec qtv.cfg", buffer, sizeof(buffer), true);
|
||||
Sys_Printf(cluster, "%s", result);
|
||||
|
||||
commandline[0] = '\0';
|
||||
|
||||
//build a block of strings.
|
||||
for (i = 1; i < argc; i++)
|
||||
//exec the + commands
|
||||
commandline[0] = '\0';
|
||||
for (i = 1; i <= argc; i++)
|
||||
{
|
||||
strcat(commandline, argv[i]);
|
||||
if (i == argc)
|
||||
arg = "";
|
||||
else
|
||||
{
|
||||
arg = argv[i];
|
||||
if (!arg) //NeXT can do this supposedly
|
||||
arg = "";
|
||||
}
|
||||
if(i == argc || *arg == '+' || *arg == '-')
|
||||
{
|
||||
if (commandline[0] == '+')
|
||||
{
|
||||
result = Rcon_Command(cluster, NULL, commandline+1, buffer, sizeof(buffer), true);
|
||||
Sys_Printf(cluster, "%s", result);
|
||||
}
|
||||
|
||||
commandline[0] = '\0';
|
||||
}
|
||||
strcat(commandline, arg);
|
||||
strcat(commandline, " ");
|
||||
}
|
||||
strcat(commandline, "+");
|
||||
|
||||
start = commandline;
|
||||
while(start)
|
||||
{
|
||||
end = strchr(start+1, '+');
|
||||
if (end)
|
||||
*end = '\0';
|
||||
if (start[1])
|
||||
{
|
||||
result = Rcon_Command(cluster, NULL, start+1, buffer, sizeof(buffer), true);
|
||||
Sys_Printf(cluster, "%s", result);
|
||||
}
|
||||
|
||||
start = end;
|
||||
}
|
||||
Sys_Printf(cluster, "\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
|
@ -54,10 +54,10 @@ struct mdfour {
|
|||
uint32 totalN;
|
||||
};
|
||||
|
||||
void mdfour_begin(struct mdfour *md); // old: MD4Init
|
||||
void mdfour_update(struct mdfour *md, unsigned char *in, int n); //old: MD4Update
|
||||
void mdfour_result(struct mdfour *md, unsigned char *out); // old: MD4Final
|
||||
void mdfour(unsigned char *out, unsigned char *in, int n);
|
||||
static void mdfour_begin(struct mdfour *md); // old: MD4Init
|
||||
static void mdfour_update(struct mdfour *md, unsigned char *in, int n); //old: MD4Update
|
||||
static void mdfour_result(struct mdfour *md, unsigned char *out); // old: MD4Final
|
||||
static void mdfour(unsigned char *out, unsigned char *in, int n);
|
||||
|
||||
#endif // _MDFOUR_H
|
||||
|
||||
|
@ -68,8 +68,6 @@ void mdfour(unsigned char *out, unsigned char *in, int n);
|
|||
It assumes that a int is at least 32 bits long
|
||||
*/
|
||||
|
||||
static struct mdfour *m;
|
||||
|
||||
#define F(X,Y,Z) (((X)&(Y)) | ((~(X))&(Z)))
|
||||
#define G(X,Y,Z) (((X)&(Y)) | ((X)&(Z)) | ((Y)&(Z)))
|
||||
#define H(X,Y,Z) ((X)^(Y)^(Z))
|
||||
|
@ -84,7 +82,7 @@ static struct mdfour *m;
|
|||
#define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + 0x6ED9EBA1,s)
|
||||
|
||||
/* this applies md4 to 64 byte chunks */
|
||||
static void mdfour64(uint32 *M)
|
||||
static void mdfour64(struct mdfour *m, uint32 *M)
|
||||
{
|
||||
int j;
|
||||
uint32 AA, BB, CC, DD;
|
||||
|
@ -154,7 +152,7 @@ static void copy4(unsigned char *out,uint32 x)
|
|||
out[3] = (x>>24)&0xFF;
|
||||
}
|
||||
|
||||
void mdfour_begin(struct mdfour *md)
|
||||
static void mdfour_begin(struct mdfour *md)
|
||||
{
|
||||
md->A = 0x67452301;
|
||||
md->B = 0xefcdab89;
|
||||
|
@ -164,7 +162,7 @@ void mdfour_begin(struct mdfour *md)
|
|||
}
|
||||
|
||||
|
||||
static void mdfour_tail(unsigned char *in, int n)
|
||||
static void mdfour_tail(struct mdfour *m, unsigned char *in, int n)
|
||||
{
|
||||
unsigned char buf[128];
|
||||
uint32 M[16];
|
||||
|
@ -178,43 +176,43 @@ static void mdfour_tail(unsigned char *in, int n)
|
|||
if (n) memcpy(buf, in, n);
|
||||
buf[n] = 0x80;
|
||||
|
||||
if (n <= 55) {
|
||||
if (n <= 55)
|
||||
{
|
||||
copy4(buf+56, b);
|
||||
copy64(M, buf);
|
||||
mdfour64(M);
|
||||
} else {
|
||||
mdfour64(m, M);
|
||||
}
|
||||
else
|
||||
{
|
||||
copy4(buf+120, b);
|
||||
copy64(M, buf);
|
||||
mdfour64(M);
|
||||
mdfour64(m, M);
|
||||
copy64(M, buf+64);
|
||||
mdfour64(M);
|
||||
mdfour64(m, M);
|
||||
}
|
||||
}
|
||||
|
||||
void mdfour_update(struct mdfour *md, unsigned char *in, int n)
|
||||
static void mdfour_update(struct mdfour *m, unsigned char *in, int n)
|
||||
{
|
||||
uint32 M[16];
|
||||
|
||||
m = md;
|
||||
|
||||
// if (n == 0) mdfour_tail(in, n); //Spike: This is where the bug was.
|
||||
|
||||
while (n >= 64) {
|
||||
while (n >= 64)
|
||||
{
|
||||
copy64(M, in);
|
||||
mdfour64(M);
|
||||
mdfour64(m, M);
|
||||
in += 64;
|
||||
n -= 64;
|
||||
m->totalN += 64;
|
||||
}
|
||||
|
||||
mdfour_tail(in, n);
|
||||
mdfour_tail(m, in, n);
|
||||
}
|
||||
|
||||
|
||||
void mdfour_result(struct mdfour *md, unsigned char *out)
|
||||
static void mdfour_result(struct mdfour *m, unsigned char *out)
|
||||
{
|
||||
m = md;
|
||||
|
||||
copy4(out, m->A);
|
||||
copy4(out+4, m->B);
|
||||
copy4(out+8, m->C);
|
||||
|
@ -222,7 +220,7 @@ void mdfour_result(struct mdfour *md, unsigned char *out)
|
|||
}
|
||||
|
||||
|
||||
void mdfour(unsigned char *out, unsigned char *in, int n)
|
||||
static void mdfour(unsigned char *out, unsigned char *in, int n)
|
||||
{
|
||||
struct mdfour md;
|
||||
mdfour_begin(&md);
|
||||
|
|
|
@ -187,7 +187,7 @@ static void ParseCDTrack(sv_t *tv, netmsg_t *m, int to, unsigned int mask)
|
|||
char nqversion[3];
|
||||
tv->cdtrack = ReadByte(m);
|
||||
|
||||
ConnectionData(tv, m->data+m->startpos, m->readpos - m->startpos, to, mask, QW);
|
||||
ConnectionData(tv, (void*)((char*)m->data+m->startpos), m->readpos - m->startpos, to, mask, QW);
|
||||
|
||||
nqversion[0] = svc_cdtrack;
|
||||
nqversion[1] = tv->cdtrack;
|
||||
|
|
|
@ -68,7 +68,7 @@ int vsnprintf(char *buffer, int buffersize, char *format, va_list argptr)
|
|||
}
|
||||
#endif
|
||||
|
||||
const usercmd_t nullcmd;
|
||||
const usercmd_t nullcmd = {0};
|
||||
|
||||
#define CM_ANGLE1 (1<<0)
|
||||
#define CM_ANGLE3 (1<<1)
|
||||
|
@ -1255,7 +1255,7 @@ void SV_WriteDelta(int entnum, const entity_state_t *from, const entity_state_t
|
|||
WriteByte(msg, to->angles[2]);
|
||||
}
|
||||
|
||||
const entity_state_t nullentstate;
|
||||
const entity_state_t nullentstate = {0};
|
||||
void SV_EmitPacketEntities (const sv_t *qtv, const viewer_t *v, const packet_entities_t *to, netmsg_t *msg)
|
||||
{
|
||||
const entity_state_t *baseline;
|
||||
|
|
|
@ -944,6 +944,26 @@ void Cmd_DemoList(cmdctxt_t *ctx)
|
|||
}
|
||||
}
|
||||
|
||||
void Cmd_BaseDir(cmdctxt_t *ctx)
|
||||
{
|
||||
char *val;
|
||||
val = Cmd_Argv(ctx, 1);
|
||||
if (!Cmd_IsLocal(ctx))
|
||||
Cmd_Printf(ctx, "Sorry, you may not use this command remotly\n");
|
||||
|
||||
if (*val)
|
||||
chdir(val);
|
||||
else
|
||||
{
|
||||
char buffer[256];
|
||||
val = getcwd(buffer, sizeof(buffer));
|
||||
if (val)
|
||||
Cmd_Printf(ctx, "basedir is: %s\n", val);
|
||||
else
|
||||
Cmd_Printf(ctx, "system error getting basedir\n");
|
||||
}
|
||||
}
|
||||
|
||||
void Cmd_DemoDir(cmdctxt_t *ctx)
|
||||
{
|
||||
char *val;
|
||||
|
@ -1047,6 +1067,7 @@ const rconcommands_t rconcommands[] =
|
|||
{"maxviewers", 0, 1, Cmd_MaxViewers},
|
||||
{"maxproxies", 0, 1, Cmd_MaxProxies},
|
||||
{"demodir", 0, 1, Cmd_DemoDir},
|
||||
{"basedir", 0, 1, Cmd_BaseDir},
|
||||
{"ping", 0, 1, Cmd_Ping},
|
||||
{"reconnect", 0, 1, Cmd_Reconnect},
|
||||
{"echo", 0, 1, Cmd_Echo},
|
||||
|
|
Loading…
Reference in a new issue