home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
D!Zone (Collector's Edition)
/
D_ZONE_CD.ISO
/
programs
/
editors
/
ser4_src
/
doomnet.c
next >
Wrap
C/C++ Source or Header
|
1994-12-06
|
4KB
|
178 lines
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <process.h>
#include <dos.h>
#include <conio.h>
#include "doomnet.h"
doomcom_t doomcom;
int vectorishooked;
void interrupt (*olddoomvect) (void);
extern int loadgame;
extern char config [256+1];
extern char devparm [256+1];
extern int nomonsters;
extern int respawn;
extern int episode;
extern int map;
extern int skill;
extern int deathmatch;
/*
=================
=
= CheckParm
=
= Checks for the given parameter in the program's command line arguments
=
= Returns the argument number (1 to argc-1) or 0 if not present
=
=================
*/
#if 0 /****************************************/
int CheckParm (char *check)
{
int i;
for (i = 1;i<_argc;i++)
if ( !stricmp(check,_argv[i]) )
return i;
return 0;
}
#endif /****************************************/
/*
=============
=
= LaunchDOOM
=
These fields in doomcom should be filled in before calling:
short numnodes; // console is allways node 0
short ticdup; // 1 = no duplication, 2-5 = dup for slow nets
short extratics; // 1 = send a backup tic in every packet
short consoleplayer; // 0-3 = player number
short numplayers; // 1-4
short angleoffset; // 1 = left, 0 = center, -1 = right
short drone; // 1 = drone
=============
*/
void LaunchDOOM (void)
{
char *newargs[99];
char adrstring[10];
long flatadr;
char epstr [2];
char mapstr [2];
char skstr [2];
char lostr [2];
int argnum = 0;
int i;
int prev;
char devstr [256+1];
// prepare for DOOM
olddoomvect = getvect (doomcom.intnum);
setvect (doomcom.intnum,NetISR);
vectorishooked = 1;
// build the argument list for DOOM, adding "-net" and the address of doomcom.
/* Copy our program name first - isn't necessary, but doom relies on it */
newargs [argnum++] = _argv [0];
if (deathmatch)
newargs [argnum++] = "-deathmatch";
if (nomonsters)
newargs [argnum++] = "-nomonsters";
if (respawn)
newargs [argnum++] = "-respawn";
if (map != -1)
{
if (devparm [0] == EOS)
newargs [argnum++] = "-devparm";
newargs [argnum++] = "-warp";
sprintf (epstr, "%d", episode == -1 ? 1 : episode);
newargs [argnum++] = epstr;
sprintf (mapstr, "%d", map);
newargs [argnum++] = mapstr;
}
else if (episode != -1)
{
newargs [argnum++] = "-episode";
sprintf (epstr, "%d", episode);
newargs [argnum++] = epstr;
}
if (skill != -1)
{
newargs [argnum++] = "-skill";
sprintf (skstr, "%d", skill);
newargs [argnum++] = skstr;
}
if (loadgame != -1)
{
newargs [argnum++] = "-loadgame";
sprintf (lostr, "%d", loadgame);
newargs [argnum++] = lostr;
}
if (config [0] != EOS)
{
newargs [argnum++] = "-config";
newargs [argnum++] = config;
}
if (devparm [0] != EOS)
{
newargs [argnum++] = "-devparm";
/* Copy all devparm args */
strcpy (devstr, devparm);
prev = 0;
i = -1;
while (devstr [++i] != EOS)
{
if (devstr [i] == ' ')
{
devstr [i] = EOS;
newargs [argnum++] = &devstr [prev];
prev = i+1;
}
}
newargs [argnum++] = &devstr [prev];
}
newargs [argnum++] = "-net";
/* Add address of doomcom structure */
flatadr = (long)_DS*16 + (unsigned)&doomcom;
sprintf (adrstring,"%lu",flatadr);
newargs [argnum++] = adrstring;
newargs [argnum] = NULL;
printf ("About to launch doom.exe -- Passing these arguments:\n");
for (i = 0; i < argnum; i++)
printf (" arg %d = %s\n", i, newargs [i]);
printf (" player = %d\n", doomcom.consoleplayer);
printf (" extratics = %d\n", doomcom.extratics);
printf ("\nPress ESC to abort, or any other key to continue...");
if (getch () == ESC)
{
printf ("\n\n");
return;
}
spawnv (P_WAIT, "doom", newargs);
printf ("\nReturned from DOOM\n\n");
}