This pretty much works now.

git-svn-id: https://svn.eduke32.com/eduke32@131 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2006-05-01 06:30:33 +00:00
parent 111c923844
commit 106f0efd24
3 changed files with 41 additions and 15 deletions

View file

@ -61,7 +61,7 @@ char qe,cp;
static int32 CommandSoundToggleOff = 0; static int32 CommandSoundToggleOff = 0;
static int32 CommandMusicToggleOff = 0; static int32 CommandMusicToggleOff = 0;
static char *CommandMap = NULL; static char *CommandMap = NULL;
static char *CommandName = NULL; static char *CommandName = NULL,*CommandNet = NULL;
int32 CommandWeaponChoice = 0; int32 CommandWeaponChoice = 0;
char confilename[BMAX_PATH] = {"EDUKE.CON"}, boardfilename[BMAX_PATH] = {0}; char confilename[BMAX_PATH] = {"EDUKE.CON"}, boardfilename[BMAX_PATH] = {0};
@ -7471,7 +7471,7 @@ enum {
}; };
signed int rancid_players = 0; signed int rancid_players = 0;
char rancid_ips[MAXPLAYERS][16]; char rancid_ips[MAXPLAYERS+1][16];
typedef struct { char *text; int tokenid; } tokenlist; typedef struct { char *text; int tokenid; } tokenlist;
static tokenlist basetokens[] = static tokenlist basetokens[] =
@ -7507,6 +7507,13 @@ static int parserancidnet(scriptfile *script)
cmdtokptr = script->ltextptr; cmdtokptr = script->ltextptr;
switch (tokn) { switch (tokn) {
case T_INTERFACE: case T_INTERFACE:
{
char *ip;
if (scriptfile_getstring(script,&ip)) break;
Bstrcpy(rancid_ips[MAXPLAYERS],ip);
Bstrcpy(rancid_ips[rancid_players++],ip);
}
break;
case T_ALLOW: case T_ALLOW:
{ {
char *ip; char *ip;
@ -7538,6 +7545,11 @@ int loadrancidnet(char *fn)
return 0; return 0;
} }
static int stringsort(const char *p1, const char *p2)
{
return Bstrcmp(&p1[0],&p2[0]);
}
void checkcommandline(int argc,char **argv) void checkcommandline(int argc,char **argv)
{ {
short i, j; short i, j;
@ -7574,14 +7586,20 @@ void checkcommandline(int argc,char **argv)
{ {
if (!Bstrcasecmp(c+1,"rmnet")) { if (!Bstrcasecmp(c+1,"rmnet")) {
if (argc > i+1) { if (argc > i+1) {
CommandName = argv[i+1]; CommandNet = argv[i+1];
i++; i++;
} }
if(CommandName) { if(CommandNet) {
loadrancidnet(CommandName); loadrancidnet(CommandNet);
qsort((char *)rancid_ips, rancid_players, sizeof(rancid_ips[0]), (int(*)(const void*,const void*))stringsort);
for(j=0;j<rancid_players;j++) for(j=0;j<rancid_players;j++)
initprintf("Rancidmeat configuration IP %d: %s\n",j,rancid_ips[j]); if(Bstrcmp(rancid_ips[j],rancid_ips[MAXPLAYERS]) == 0)
CommandName = 0; Bsprintf(rancid_ips[j],"/n1");
CommandNet = 0;
netparamcount = rancid_players;
netparam = (char **)calloc(netparamcount, sizeof(char **));
for(j=0;j<netparamcount;j++)
netparam[j] = rancid_ips[j];
} }
i++; i++;
continue; continue;

View file

@ -2,6 +2,7 @@
// gcc -o duke3d_w32.exe wrapper.c // gcc -o duke3d_w32.exe wrapper.c
#include <windows.h> #include <windows.h>
#include <string.h>
#include <stdio.h> #include <stdio.h>
#define ISWS(x) ((x == ' ') || (x == '\t') || (x == '\r') || (x == '\n')) #define ISWS(x) ((x == ' ') || (x == '\t') || (x == '\r') || (x == '\n'))
@ -19,32 +20,39 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, in
STARTUPINFO si; STARTUPINFO si;
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
for(i=0;i<sizeof(CmdLine);i++) ZeroMemory(&szFileName,sizeof(szFileName));
for(i=0;i<strlen(lpCmdLine);i++)
{ {
if(lpCmdLine[i] == ' ' && lpCmdLine[i+1] == '-' && lpCmdLine[i+2] == 'n' && lpCmdLine[i+3] == 'e' && lpCmdLine[i+4] == 't') if(lpCmdLine[i] == '-' && lpCmdLine[i+1] == 'n' && lpCmdLine[i+2] == 'e' && lpCmdLine[i+3] == 't')
{ {
i += 6; i += 5;
j = 0; j = 0;
while(!ISWS(lpCmdLine[i])) while(!ISWS(lpCmdLine[i]) && i<strlen(lpCmdLine))
{ {
szFileName[j] = lpCmdLine[i]; szFileName[j] = lpCmdLine[i];
j++,i++;
fprintf(fp,"%d %d\n",j,i); fprintf(fp,"%d %d\n",j,i);
if(lpCmdLine[i] == ' ' || lpCmdLine[i] == '\n' || lpCmdLine[i] == '\r') if(lpCmdLine[i+1] == ' ' || lpCmdLine[i+1] == '\n' || lpCmdLine[i+1] == '\r')
break; break;
j++,i++;
} }
break; break;
} }
else CmdLine[i] = lpCmdLine[i]; else CmdLine[i] = lpCmdLine[i];
} }
sprintf(sCmdLine,"eduke32.exe %s -rmnet %s",CmdLine,szFileName); if(szFileName[0])
sprintf(sCmdLine,"eduke32.exe %s -rmnet %s",CmdLine,szFileName);
else sprintf(sCmdLine,"eduke32.exe %s",CmdLine);
szCmdLine = sCmdLine; szCmdLine = sCmdLine;
fprintf(fp,"EDuke32 wrapper for Dukester X v0.01\ fprintf(fp,"EDuke32 wrapper for Dukester X v0.01\
\nCopyright (c) 2006 EDuke32 team\n\ \nCopyright (c) 2006 EDuke32 team\n\
\nArgs passed to wrapper: %s\ \nArgs passed to wrapper: %s\
\nRancidmeat net filename: %s\ \nRancidmeat net filename: %s\
\nFinal command line: %s\n",lpCmdLine,szFileName,szCmdLine); \nFinal command line: %s\n",lpCmdLine,szFileName,szCmdLine);
fclose(fp); fclose(fp);
ZeroMemory(&si,sizeof(si)); ZeroMemory(&si,sizeof(si));