Revert some of the aim changes as well as add the start of support for loading Duke3d_w32 network configuration files. The wrapper application reformats a Duke3d_w32 command line sent from Dukester X into something EDuke32 can work with.

Still left to be done: sort IPs (they aren't in the same order on all machines in Rancidmeat config files) and construct a proper string of network parameters for Ken's netcode.


git-svn-id: https://svn.eduke32.com/eduke32@130 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2006-05-01 05:03:44 +00:00
parent 7d8048482a
commit 111c923844
3 changed files with 155 additions and 3 deletions

View file

@ -38,6 +38,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "osd.h"
#include "osdfuncs.h"
#include "osdcmds.h"
#include "scriptfile.h"
//#include "crc32.h"
@ -7461,6 +7462,82 @@ void comlinehelp(char **argv)
wm_msgbox(apptitle,s);
}
enum {
T_EOF = -2,
T_ERROR = -1,
T_INTERFACE = 0,
T_MODE,
T_ALLOW
};
signed int rancid_players = 0;
char rancid_ips[MAXPLAYERS][16];
typedef struct { char *text; int tokenid; } tokenlist;
static tokenlist basetokens[] =
{
{ "interface", T_INTERFACE },
{ "mode", T_MODE },
{ "allow", T_ALLOW },
};
static int getatoken(scriptfile *sf, tokenlist *tl, int ntokens)
{
char *tok;
int i;
if (!sf) return T_ERROR;
tok = scriptfile_gettoken(sf);
if (!tok) return T_EOF;
for(i=0;i<ntokens;i++) {
if (!Bstrcasecmp(tok, tl[i].text))
return tl[i].tokenid;
}
return T_ERROR;
}
static int parserancidnet(scriptfile *script)
{
int tokn;
char *cmdtokptr;
while (1) {
tokn = getatoken(script,basetokens,sizeof(basetokens)/sizeof(tokenlist));
cmdtokptr = script->ltextptr;
switch (tokn) {
case T_INTERFACE:
case T_ALLOW:
{
char *ip;
if (scriptfile_getstring(script,&ip)) break;
Bstrcpy(rancid_ips[rancid_players++],ip);
}
break;
case T_EOF:
return(0);
default:
break;
}
}
return 0;
}
int loadrancidnet(char *fn)
{
scriptfile *script;
script = scriptfile_fromfile(fn);
if (!script) return -1;
parserancidnet(script);
scriptfile_close(script);
scriptfile_clearsymbols();
return 0;
}
void checkcommandline(int argc,char **argv)
{
short i, j;
@ -7495,6 +7572,20 @@ void checkcommandline(int argc,char **argv)
c = argv[i];
if (((*c == '/') || (*c == '-')) && (!firstnet))
{
if (!Bstrcasecmp(c+1,"rmnet")) {
if (argc > i+1) {
CommandName = argv[i+1];
i++;
}
if(CommandName) {
loadrancidnet(CommandName);
for(j=0;j<rancid_players;j++)
initprintf("Rancidmeat configuration IP %d: %s\n",j,rancid_ips[j]);
CommandName = 0;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1,"net")) {
firstnet = i;
netparamcount = argc - i - 1;
@ -8346,7 +8437,7 @@ void writestring(long a1,long a2,long a3,short a4,long vx,long vy,long vz)
FILE *fp;
fp = (FILE *)fopenfrompath("debug.txt","rt+");
fp = (FILE *)fopen("debug.txt","rt+");
fprintf(fp,"%ld %ld %ld %d %ld %ld %ld\n",a1,a2,a3,a4,vx,vy,vz);
fclose(fp);
@ -9615,7 +9706,7 @@ FAKEHORIZONLY:
}
if(p->aim_mode)
myhoriz += syn->horz/2;
myhoriz += syn->horz>>1;
else
{
if( myhoriz > 95 && myhoriz < 105) myhoriz = 100;

View file

@ -2833,6 +2833,7 @@ void getinput(short snum)
else horiz = (info.dz+lastinfo.dz)/(314-128);
lastinfo.dz = (lastinfo.dz+info.dz) % (314-128);
if(horiz <= 0) horiz++;
info.dz = 0;
} else {
lastinfo.dz = info.dz % (1<<6);
@ -4388,7 +4389,7 @@ HORIZONLY:
}
if(p->aim_mode)
p->horiz += sync[snum].horz/2;
p->horiz += sync[snum].horz>>1;
else
{
if( p->horiz > 95 && p->horiz < 105) p->horiz = 100;

View file

@ -0,0 +1,60 @@
// this is a wrapper to launch EDuke32 properly from Dukester X
// gcc -o duke3d_w32.exe wrapper.c
#include <windows.h>
#include <stdio.h>
#define ISWS(x) ((x == ' ') || (x == '\t') || (x == '\r') || (x == '\n'))
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
{
int i,j;
LPTSTR szCmdLine;
char CmdLine[1024];
char sCmdLine[1024];
char szFileName[255];
FILE * fp=fopen("wrapper.log","w");
STARTUPINFO si;
PROCESS_INFORMATION pi;
for(i=0;i<sizeof(CmdLine);i++)
{
if(lpCmdLine[i] == ' ' && lpCmdLine[i+1] == '-' && lpCmdLine[i+2] == 'n' && lpCmdLine[i+3] == 'e' && lpCmdLine[i+4] == 't')
{
i += 6;
j = 0;
while(!ISWS(lpCmdLine[i]))
{
szFileName[j] = lpCmdLine[i];
j++,i++;
fprintf(fp,"%d %d\n",j,i);
if(lpCmdLine[i] == ' ' || lpCmdLine[i] == '\n' || lpCmdLine[i] == '\r')
break;
}
break;
}
else CmdLine[i] = lpCmdLine[i];
}
sprintf(sCmdLine,"eduke32.exe %s -rmnet %s",CmdLine,szFileName);
szCmdLine = sCmdLine;
fprintf(fp,"EDuke32 wrapper for Dukester X v0.01\
\nCopyright (c) 2006 EDuke32 team\n\
\nArgs passed to wrapper: %s\
\nRancidmeat net filename: %s\
\nFinal command line: %s\n",lpCmdLine,szFileName,szCmdLine);
fclose(fp);
ZeroMemory(&si,sizeof(si));
ZeroMemory(&pi,sizeof(pi));
si.cb = sizeof(si);
if (!CreateProcess(NULL,szCmdLine,NULL,NULL,0,0,NULL,NULL,&si,&pi)) {
MessageBox(0,"Failed to start eduke32.exe.", "Failure starting game", MB_OK|MB_ICONSTOP);
return 1;
}
return 0;
}