コード例 #1
0
ファイル: mid2strm.c プロジェクト: Pupswoof117/SRB2-Public
// ----------------------
// AddEventToStreamBuffer
//
// Put the given event into the given stream buffer at the given location
// pMe must point to an event filled out in accordance with the
// description given in GetTrackEvent
//
// Returns FALSE on sucess or TRUE on an error condition
// Handles its own error notification by displaying to the appropriate
// output device (either our debugging window, or the screen).
// ----------------------
static int AddEventToStreamBuffer(LPTEMPEVENT pMe, LPCONVERTINFO lpciInfo)
{
	DWORD      tkNow, tkDelta;
	MIDIEVENT *pmeEvent;

	pmeEvent = (MIDIEVENT *)(lpciInfo->mhBuffer.lpData
	                        + lpciInfo->dwStartOffset
	                        + lpciInfo->dwBytesRecorded);

	// When we see a new, empty buffer, set the start time on it...
	if (!lpciInfo->dwBytesRecorded)
		lpciInfo->tkStart = tkCurrentTime;

	// Use the above set start time to figure out how much longer we should fill
	// this buffer before officially declaring it as "full"
	if (tkCurrentTime - lpciInfo->tkStart > dwBufferTickLength)
	{
		if (lpciInfo->bTimesUp)
		{
			lpciInfo->bTimesUp = FALSE;
			return CONVERTERR_BUFFERFULL;
		}
		else
			lpciInfo->bTimesUp = TRUE;
	}

	tkNow = tkCurrentTime;

	// Delta time is absolute event time minus absolute time
	// already gone by on this track
	tkDelta = pMe->tkEvent - tkCurrentTime;

	// Event time is now current time on this track
	tkCurrentTime = pMe->tkEvent;

	if (pMe->abEvent[0] < MIDI_SYSEX)
	{
		// Channel message. We know how long it is, just copy it.
		// Need 3 DWORD's: delta-t, stream-ID, event
		if (lpciInfo->dwMaxLength-lpciInfo->dwBytesRecorded < 3*sizeof (DWORD))
		{
			// Cleanup from our write operation
			return CONVERTERR_BUFFERFULL;
		}

		pmeEvent->dwDeltaTime = tkDelta;
		pmeEvent->dwStreamID = 0;
		pmeEvent->dwEvent = (pMe->abEvent[0])
		                    | (((DWORD)pMe->abEvent[1]) << 8)
		                    | (((DWORD)pMe->abEvent[2]) << 16)
		                    | MEVT_F_SHORT;

		//faB: control the volume with our own volume percentage
		if (((pMe->abEvent[0] & 0xF0) == MIDI_CTRLCHANGE) &&
			(pMe->abEvent[1] == MIDICTRL_VOLUME))
		{
			// If this is a volume change, generate a callback so we can grab
			// the new volume for our cache
			// BP: this seems like this is useless and cause many many many bugs !
			//pmeEvent->dwEvent |= MEVT_F_CALLBACK;
		}
		lpciInfo->dwBytesRecorded += 3 *sizeof (DWORD);
	}
	else if ((pMe->abEvent[0] == MIDI_SYSEX) ||
			(pMe->abEvent[0] == MIDI_SYSEXEND))
	{
		if (devparm) // Tails
			I_OutputMsg("NOTE: Ignoring SysEx for now.\n");
	}
	else
	{
		DWORD   dwCurrentTempo;

		// Better be a meta event.
		//  BYTE        byEvent
		//  BYTE        byEventType
		//  VDWORD      dwEventLength
		//  BYTE        pLongEventData[dwEventLength]
		//
		if (!(pMe->abEvent[0] == MIDI_META))
		{
			I_Error("AddEventToStreamBuffer: not a META event\n");
		}

		// The only meta-event we care about is change tempo
		//
		if (pMe->abEvent[1] != MIDI_META_TEMPO)
			return CONVERTERR_METASKIP;

		// We should have three bytes of parameter data...
		if (!(pMe->dwEventLength == 3))
		{
			I_Error("AddEventToStreamBuffer: dwEventLength <> 3\n");
		}

		// Need 3 DWORD's: delta-t, stream-ID, event data
		if (lpciInfo->dwMaxLength - lpciInfo->dwBytesRecorded < 3 *sizeof (DWORD))
		{
			return CONVERTERR_BUFFERFULL;
		}

		pmeEvent->dwDeltaTime = tkDelta;
		pmeEvent->dwStreamID = 0;
		// Note: this is backwards from above because we're converting a single
		//       data value from hi-lo to lo-hi format...
		pmeEvent->dwEvent = (pMe->pEvent[2])
			| (((DWORD)pMe->pEvent[1]) << 8)
			| (((DWORD)pMe->pEvent[0]) << 16);

		dwCurrentTempo = pmeEvent->dwEvent;
		pmeEvent->dwEvent |= (((DWORD)MEVT_TEMPO) << 24) | MEVT_F_SHORT;

		dwBufferTickLength = (ifs.dwTimeDivision * 1000 * BUFFER_TIME_LENGTH) / dwCurrentTempo;
#ifdef DEBUGMIDISTREAM
		I_OutputMsg("dwBufferTickLength = %lu", dwBufferTickLength);
#endif
		lpciInfo->dwBytesRecorded += 3 *sizeof (DWORD);
	}

	return FALSE;
}
コード例 #2
0
ファイル: d_main.c プロジェクト: 1833183060/DOOM
//
// IdentifyVersion
// Checks availability of IWAD files by name,
// to determine whether registered/commercial features
// should be executed (notably loading PWAD's).
//
void IdentifyVersion (void)
{

    char*	doom1wad;
    char*	doomwad;
    char*	doomuwad;
    char*	doom2wad;

    char*	doom2fwad;
    char*	plutoniawad;
    char*	tntwad;

#ifdef NORMALUNIX
    char *home;
    char *doomwaddir;
    doomwaddir = getenv("DOOMWADDIR");
    if (!doomwaddir)
	doomwaddir = ".";

    // Commercial.
    doom2wad = malloc(strlen(doomwaddir)+1+9+1);
    sprintf(doom2wad, "%s/doom2.wad", doomwaddir);

    // Retail.
    doomuwad = malloc(strlen(doomwaddir)+1+8+1);
    sprintf(doomuwad, "%s/doomu.wad", doomwaddir);
    
    // Registered.
    doomwad = malloc(strlen(doomwaddir)+1+8+1);
    sprintf(doomwad, "%s/doom.wad", doomwaddir);
    
    // Shareware.
    doom1wad = malloc(strlen(doomwaddir)+1+9+1);
    sprintf(doom1wad, "%s/doom1.wad", doomwaddir);

     // Bug, dear Shawn.
    // Insufficient malloc, caused spurious realloc errors.
    plutoniawad = malloc(strlen(doomwaddir)+1+/*9*/12+1);
    sprintf(plutoniawad, "%s/plutonia.wad", doomwaddir);

    tntwad = malloc(strlen(doomwaddir)+1+9+1);
    sprintf(tntwad, "%s/tnt.wad", doomwaddir);


    // French stuff.
    doom2fwad = malloc(strlen(doomwaddir)+1+10+1);
    sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir);

    home = getenv("HOME");
    if (!home)
      I_Error("Please set $HOME to your home directory");
    sprintf(basedefault, "%s/.doomrc", home);
#endif

    if (M_CheckParm ("-shdev"))
    {
	gamemode = shareware;
	devparm = true;
	D_AddFile (DEVDATA"doom1.wad");
	D_AddFile (DEVMAPS"data_se/texture1.lmp");
	D_AddFile (DEVMAPS"data_se/pnames.lmp");
	strcpy (basedefault,DEVDATA"default.cfg");
	return;
    }

    if (M_CheckParm ("-regdev"))
    {
	gamemode = registered;
	devparm = true;
	D_AddFile (DEVDATA"doom.wad");
	D_AddFile (DEVMAPS"data_se/texture1.lmp");
	D_AddFile (DEVMAPS"data_se/texture2.lmp");
	D_AddFile (DEVMAPS"data_se/pnames.lmp");
	strcpy (basedefault,DEVDATA"default.cfg");
	return;
    }

    if (M_CheckParm ("-comdev"))
    {
	gamemode = commercial;
	devparm = true;
	/* I don't bother
	if(plutonia)
	    D_AddFile (DEVDATA"plutonia.wad");
	else if(tnt)
	    D_AddFile (DEVDATA"tnt.wad");
	else*/
	    D_AddFile (DEVDATA"doom2.wad");
	    
	D_AddFile (DEVMAPS"cdata/texture1.lmp");
	D_AddFile (DEVMAPS"cdata/pnames.lmp");
	strcpy (basedefault,DEVDATA"default.cfg");
	return;
    }

    if ( !access (doom2fwad,R_OK) )
    {
	gamemode = commercial;
	// C'est ridicule!
	// Let's handle languages in config files, okay?
	language = french;
	printf("French version\n");
	D_AddFile (doom2fwad);
	return;
    }

    if ( !access (doom2wad,R_OK) )
    {
	gamemode = commercial;
	D_AddFile (doom2wad);
	return;
    }

    if ( !access (plutoniawad, R_OK ) )
    {
      gamemode = commercial;
      D_AddFile (plutoniawad);
      return;
    }

    if ( !access ( tntwad, R_OK ) )
    {
      gamemode = commercial;
      D_AddFile (tntwad);
      return;
    }

    if ( !access (doomuwad,R_OK) )
    {
      gamemode = retail;
      D_AddFile (doomuwad);
      return;
    }

    if ( !access (doomwad,R_OK) )
    {
      gamemode = registered;
      D_AddFile (doomwad);
      return;
    }

    if ( !access (doom1wad,R_OK) )
    {
      gamemode = shareware;
      D_AddFile (doom1wad);
      return;
    }

    printf("Game mode indeterminate.\n");
    gamemode = indetermined;

    // We don't abort. Let's see what the PWAD contains.
    //exit(1);
    //I_Error ("Game mode indeterminate\n");
}
コード例 #3
0
ファイル: i_tcp.c プロジェクト: RedEnchilada/SRB2
static void SOCK_Send(void)
{
	ssize_t c = ERRSOCKET;
	socklen_t d4 = (socklen_t)sizeof(struct sockaddr_in);
#ifdef HAVE_IPV6
	socklen_t d6 = (socklen_t)sizeof(struct sockaddr_in6);
#endif
	socklen_t d, da = (socklen_t)sizeof(mysockaddr_t);
	size_t i, j;

	if (!nodeconnected[doomcom->remotenode])
		return;

	if (doomcom->remotenode == BROADCASTADDR)
	{
		for (i = 0; i < mysocketses; i++)
		{
			for (j = 0; j < broadcastaddresses; j++)
			{
				if (myfamily[i] == broadcastaddress[j].any.sa_family)
				{
					if (broadcastaddress[i].any.sa_family == AF_INET)
						d = d4;
#ifdef HAVE_IPV6
					if (broadcastaddress[i].any.sa_family == AF_INET6)
						d = d6;
#endif
					else
						d = da;

					c = sendto(mysockets[i], (char *)&doomcom->data, doomcom->datalength, 0,
						&broadcastaddress[j].any, d);
				}
			}
		}
		return;
	}
	else if (nodesocket[doomcom->remotenode] == BADSOCKET)
	{
		for (i = 0; i < mysocketses; i++)
		{
			if (myfamily[i] == clientaddress[doomcom->remotenode].any.sa_family)
			{
				if (clientaddress[doomcom->remotenode].any.sa_family == AF_INET)
					d = d4;
#ifdef HAVE_IPV6
				else if (clientaddress[doomcom->remotenode].any.sa_family == AF_INET6)
					d = d6;
#endif
				else
					d = da;

				sendto(mysockets[i], (char *)&doomcom->data, doomcom->datalength, 0,
					&clientaddress[doomcom->remotenode].any, d);
			}
		}
		return;
	}
	else
	{
		if (clientaddress[doomcom->remotenode].any.sa_family == AF_INET)
			d = d4;
#ifdef HAVE_IPV6
		if (clientaddress[doomcom->remotenode].any.sa_family == AF_INET6)
			d = d6;
#endif
		else
			d = da;

		c = sendto(nodesocket[doomcom->remotenode], (char *)&doomcom->data, doomcom->datalength, 0,
			&clientaddress[doomcom->remotenode].any, d);
	}

	if (c == ERRSOCKET && errno != ECONNREFUSED && errno != EWOULDBLOCK)
		I_Error("SOCK_Send, error sending to node %d (%s) #%u: %s", doomcom->remotenode,
			SOCK_GetNodeAddress(doomcom->remotenode), errno, strerror(errno));
}
コード例 #4
0
ファイル: p_mobj.cpp プロジェクト: JohnnyonFlame/odamex
void AActor::Serialize (FArchive &arc)
{
	Super::Serialize (arc);
	if (arc.IsStoring ())
	{
		arc << x
			<< y
			<< z
			<< pitch
			<< angle
			<< roll
			<< (int)sprite
			<< frame
			<< effects
			<< floorz
			<< ceilingz
			<< radius
			<< height
			<< momx
			<< momy
			<< momz
			<< (int)type
			<< tics
			<< state
			<< flags
			<< flags2
			<< health
			<< movedir
			<< visdir
			<< movecount
			<< target->netid
			<< lastenemy->netid
			<< reactiontime
			<< threshold
			<< player
			<< lastlook
			<< tracer->netid
			<< tid
			<< goal->netid
			<< (unsigned)0
			<< translucency
			<< waterlevel;
		spawnpoint.Serialize (arc);
	}
	else
	{
		unsigned dummy;
		arc >> x
			>> y
			>> z
			>> pitch
			>> angle
			>> roll
			>> (int&)sprite
			>> frame
			>> effects
			>> floorz
			>> ceilingz
			>> radius
			>> height
			>> momx
			>> momy
			>> momz
			>> (int&)type
			>> tics
			>> state
			>> flags
			>> flags2
			>> health
			>> movedir
			>> visdir
			>> movecount
			>> target->netid
			>> lastenemy->netid
			>> reactiontime
			>> threshold
			>> player
			>> lastlook
			>> tracer->netid
			>> tid
			>> goal->netid
			>> dummy
			>> translucency
			>> waterlevel;

		DWORD trans;
		arc >> trans;
		spawnpoint.Serialize (arc);
		if(type >= NUMMOBJTYPES)
			I_Error("Unknown object type in saved game");
		if(sprite >= NUMSPRITES)
			I_Error("Unknown sprite in saved game");
		info = &mobjinfo[type];
		touching_sectorlist = NULL;
		LinkToWorld ();
		AddToHash ();
	}
}
コード例 #5
0
ファイル: bmp.cpp プロジェクト: jeske/hz
int load_bmp_v3 (IMAGEDATA *im, uint8 *data)
{
  uint8  byte;
  uint16 word;
  uint32 dword, data_offset;
  uint32 compression, size;
  uint32 scan_len, data_len;
  int x, y;

  /* go through header */
  dword = read_little_32 (&data);
  dword = read_little_32 (&data);
  data_offset = read_little_32 (&data);

  /* load info struct */
  /* header size */
  dword = read_little_32 (&data);
  if (dword != 40)
  {
    I_Error ("load_bmp(): Unexpected header size, expected 40 got %d", word);
    return (-1);
  }
  dword = read_little_32 (&data);
  im->width = dword;
  dword = read_little_32 (&data);
  im->height = dword;
  /* image planes, always 1 */
  word = read_little_16 (&data);
  /* bits per pixel */
  word = read_little_16 (&data);
  im->colordepth = word;
  /* compression method */
  dword = read_little_32 (&data);
  compression = dword;
  dword = read_little_32 (&data);
  size = dword;
  if (!size)
  {
    I_Message ("-W- Uh oh, image size is 0, guessing\n");
    size = im->height * im->width * im->colordepth / 8;
  }
//  else
//    I_Message ("Size is %d\n", size);

  /* horz resolution */
  dword = read_little_32 (&data);
  /* vert resolution */
  dword = read_little_32 (&data);
  /* colors */
  dword = read_little_32 (&data);
  im->numcolors = dword;
  /* significant colors */
  dword = read_little_32 (&data);

  /* Palette on 1, 4 or 8 bit displays */
  if (im->colordepth != 24)
  {
    if (im->numcolors == 0)
    {
      /* Hmm, if numcolors is 0, guess using the start of data */
      im->numcolors = (data_offset - 54) / 4;
    }

    im->palette = (RGBQUAD *) malloc (im->numcolors * sizeof (RGBQUAD));
    for (x = 0; x < im->numcolors; x++)
    {
      dword = read_little_32 (&data);
      im->palette[x].red = (dword >> 16) & 0x0ff;
      im->palette[x].green = (dword >> 8) & 0x0ff;
      im->palette[x].blue = (dword >> 0) & 0x0ff;
    }
  }
  else
コード例 #6
0
ファイル: w_wad.c プロジェクト: BruceJawn/flash-doom
int W_LumpLength (int lump)
{
	if (lump >= numlumps)
		I_Error ("W_LumpLength: %i >= numlumps",lump);
	return lumpinfo[lump].size;
}
コード例 #7
0
ファイル: d_main.c プロジェクト: ilag11111/SRB2
//
// D_SRB2Main
//
void D_SRB2Main(void)
{
	INT32 p;
	char srb2[82]; // srb2 title banner
	char title[82];

	INT32 pstartmap = 1;
	boolean autostart = false;

	// keep error messages until the final flush(stderr)
#if !defined (PC_DOS) && !defined (_WIN32_WCE) && !defined(NOTERMIOS)
	if (setvbuf(stderr, NULL, _IOFBF, 1000))
		I_OutputMsg("setvbuf didnt work\n");
#endif

#ifdef GETTEXT
	// initialise locale code
	M_StartupLocale();
#endif

	// get parameters from a response file (eg: srb2 @parms.txt)
	M_FindResponseFile();

	// MAINCFG is now taken care of where "OBJCTCFG" is handled
	G_LoadGameSettings();

	// Test Dehacked lists
	DEH_Check();

	// identify the main IWAD file to use
	IdentifyVersion();

#if !defined (_WIN32_WCE) && !defined(NOTERMIOS)
	setbuf(stdout, NULL); // non-buffered output
#endif

#if defined (_WIN32_WCE) //|| defined (_DEBUG) || defined (GP2X)
	devparm = M_CheckParm("-nodebug") == 0;
#else
	devparm = M_CheckParm("-debug") != 0;
#endif

	// for dedicated server
#if !defined (_WINDOWS) //already check in win_main.c
	dedicated = M_CheckParm("-dedicated") != 0;
#endif

	strcpy(title, "Sonic Robo Blast 2");
	strcpy(srb2, "Sonic Robo Blast 2");
	D_MakeTitleString(srb2);

#ifdef PC_DOS
	D_Titlebar(srb2, title);
#endif

#if defined (__OS2__) && !defined (HAVE_SDL)
	// set PM window title
	snprintf(pmData->title, sizeof (pmData->title),
		"Sonic Robo Blast 2" VERSIONSTRING ": %s",
		title);
	pmData->title[sizeof (pmData->title) - 1] = '\0';
#endif

	if (devparm)
		CONS_Printf(M_GetText("Development mode ON.\n"));

	// default savegame
	strcpy(savegamename, SAVEGAMENAME"%u.ssg");

	{
		const char *userhome = D_Home(); //Alam: path to home

		if (!userhome)
		{
#if ((defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)) && !defined (__CYGWIN__) && !defined (DC) && !defined (PSP) && !defined(GP2X)
			I_Error("Please set $HOME to your home directory\n");
#elif defined (_WIN32_WCE) && 0
			if (dedicated)
				snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/d"CONFIGFILENAME);
			else
				snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/"CONFIGFILENAME);
#else
			if (dedicated)
				snprintf(configfile, sizeof configfile, "d"CONFIGFILENAME);
			else
				snprintf(configfile, sizeof configfile, CONFIGFILENAME);
#endif
		}
		else
		{
			// use user specific config file
#ifdef DEFAULTDIR
			snprintf(srb2home, sizeof srb2home, "%s" PATHSEP DEFAULTDIR, userhome);
			snprintf(downloaddir, sizeof downloaddir, "%s" PATHSEP "DOWNLOAD", srb2home);
			if (dedicated)
				snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, srb2home);
			else
				snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, srb2home);

			// can't use sprintf since there is %u in savegamename
			strcatbf(savegamename, srb2home, PATHSEP);

			I_mkdir(srb2home, 0700);
#else
			snprintf(srb2home, sizeof srb2home, "%s", userhome);
			snprintf(downloaddir, sizeof downloaddir, "%s", userhome);
			if (dedicated)
				snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, userhome);
			else
				snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, userhome);

			// can't use sprintf since there is %u in savegamename
			strcatbf(savegamename, userhome, PATHSEP);
#endif
		}

		configfile[sizeof configfile - 1] = '\0';

#ifdef _arch_dreamcast
	strcpy(downloaddir, "/ram"); // the dreamcast's TMP
#endif
	}

	// rand() needs seeded regardless of password
	srand((unsigned int)time(NULL));

	if (M_CheckParm("-password") && M_IsNextParm())
		D_SetPassword(M_GetNextParm());
	else
	{
		size_t z;
		char junkpw[25];
		for (z = 0; z < 24; z++)
			junkpw[z] = (char)(rand() & 64)+32;
		junkpw[24] = '\0';
		D_SetPassword(junkpw);
	}

	// add any files specified on the command line with -file wadfile
	// to the wad list
	if (!(M_CheckParm("-connect")))
	{
		if (M_CheckParm("-file"))
		{
			// the parms after p are wadfile/lump names,
			// until end of parms or another - preceded parm
			while (M_IsNextParm())
			{
				const char *s = M_GetNextParm();

				if (s) // Check for NULL?
				{
					if (!W_VerifyNMUSlumps(s))
						G_SetGameModified(true);
					D_AddFile(s);
				}
			}
		}
	}

	// get map from parms

	if (M_CheckParm("-server") || dedicated)
		netgame = server = true;

	if (M_CheckParm("-warp") && M_IsNextParm())
	{
		const char *word = M_GetNextParm();
		char ch; // use this with sscanf to catch non-digits with
		if (fastncmp(word, "MAP", 3)) // MAPxx name
			pstartmap = M_MapNumber(word[3], word[4]);
		else if (sscanf(word, "%d%c", &pstartmap, &ch) != 1) // a plain number
			I_Error("Cannot warp to map %s (invalid map name)\n", word);
		// Don't check if lump exists just yet because the wads haven't been loaded!
		// Just do a basic range check here.
		if (pstartmap < 1 || pstartmap > NUMMAPS)
			I_Error("Cannot warp to map %d (out of range)\n", pstartmap);
		else
		{
			if (!M_CheckParm("-server"))
				G_SetGameModified(true);
			autostart = true;
		}
	}

	CONS_Printf("Z_Init(): Init zone memory allocation daemon. \n");
	Z_Init();

	// adapt tables to SRB2's needs, including extra slots for dehacked file support
	P_PatchInfoTables();

	//---------------------------------------------------- READY TIME
	// we need to check for dedicated before initialization of some subsystems

	CONS_Printf("I_StartupTimer()...\n");
	I_StartupTimer();

	// Make backups of some SOCcable tables.
	P_BackupTables();

	// Setup default unlockable conditions
	M_SetupDefaultConditionSets();

	// load wad, including the main wad file
	CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n");
	if (!W_InitMultipleFiles(startupwadfiles))
#ifdef _DEBUG
		CONS_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n");
#else
		I_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n");
#endif
	D_CleanFile();

#ifndef DEVELOP // md5s last updated 12/14/14

	// Check MD5s of autoloaded files
	W_VerifyFileMD5(0, ASSET_HASH_SRB2_SRB); // srb2.srb/srb2.wad
	W_VerifyFileMD5(1, ASSET_HASH_ZONES_DTA); // zones.dta
	W_VerifyFileMD5(2, ASSET_HASH_PLAYER_DTA); // player.dta
	W_VerifyFileMD5(3, ASSET_HASH_RINGS_DTA); // rings.dta
#ifdef USE_PATCH_DTA
	W_VerifyFileMD5(4, ASSET_HASH_PATCH_DTA); // patch.dta
#endif

	// don't check music.dta because people like to modify it, and it doesn't matter if they do
	// ...except it does if they slip maps in there, and that's what W_VerifyNMUSlumps is for.
#endif //ifndef DEVELOP

	mainwads = 4; // there are 4 wads not to unload
#ifdef USE_PATCH_DTA
	++mainwads; // patch.dta adds one more
#endif

	cht_Init();

	//---------------------------------------------------- READY SCREEN
	// we need to check for dedicated before initialization of some subsystems

	CONS_Printf("I_StartupGraphics()...\n");
	I_StartupGraphics();

	//--------------------------------------------------------- CONSOLE
	// setup loading screen
	SCR_Startup();

	// we need the font of the console
	CONS_Printf("HU_Init(): Setting up heads up display.\n");
	HU_Init();

	COM_Init();
	// libogc has a CON_Init function, we must rename SRB2's CON_Init in WII/libogc
#ifndef _WII
	CON_Init();
#else
	CON_InitWii();
#endif

	D_RegisterServerCommands();
	D_RegisterClientCommands(); // be sure that this is called before D_CheckNetGame
	R_RegisterEngineStuff();
	S_RegisterSoundStuff();

	I_RegisterSysCommands();

	//--------------------------------------------------------- CONFIG.CFG
	M_FirstLoadConfig(); // WARNING : this do a "COM_BufExecute()"

	G_LoadGameData();

#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
	VID_PrepareModeList(); // Regenerate Modelist according to cv_fullscreen
#endif

	// set user default mode or mode set at cmdline
	SCR_CheckDefaultMode();

	wipegamestate = gamestate;

	savedata.lives = 0; // flag this as not-used

	//------------------------------------------------ COMMAND LINE PARAMS

	// Initialize CD-Audio
	if (M_CheckParm("-usecd") && !dedicated)
		I_InitCD();

	if (M_CheckParm("-noupload"))
		COM_BufAddText("downloading 0\n");

	CONS_Printf("M_Init(): Init miscellaneous info.\n");
	M_Init();

	CONS_Printf("R_Init(): Init SRB2 refresh daemon.\n");
	R_Init();

	// setting up sound
	CONS_Printf("S_Init(): Setting up sound.\n");
	if (M_CheckParm("-nosound"))
		nosound = true;
	if (M_CheckParm("-nomusic")) // combines -nomidimusic and -nodigmusic
		nomidimusic = nodigimusic = true;
	else
	{
		if (M_CheckParm("-nomidimusic"))
			nomidimusic = true; ; // WARNING: DOS version initmusic in I_StartupSound
		if (M_CheckParm("-nodigmusic"))
			nodigimusic = true; // WARNING: DOS version initmusic in I_StartupSound
	}
	I_StartupSound();
	I_InitMusic();
	S_Init(cv_soundvolume.value, cv_digmusicvolume.value, cv_midimusicvolume.value);

	CONS_Printf("ST_Init(): Init status bar.\n");
	ST_Init();

	if (M_CheckParm("-room"))
	{
		if (!M_IsNextParm())
			I_Error("usage: -room <room_id>\nCheck the Master Server's webpage for room ID numbers.\n");
		ms_RoomId = atoi(M_GetNextParm());

#ifdef UPDATE_ALERT
		GetMODVersion_Console();
#endif
	}

	// init all NETWORK
	CONS_Printf("D_CheckNetGame(): Checking network game status.\n");
	if (D_CheckNetGame())
		autostart = true;

	// check for a driver that wants intermission stats
	// start the apropriate game based on parms
	if (M_CheckParm("-metal"))
	{
		G_RecordMetal();
		autostart = true;
	}
	else if (M_CheckParm("-record") && M_IsNextParm())
	{
		G_RecordDemo(M_GetNextParm());
		autostart = true;
	}

	// user settings come before "+" parameters.
	if (dedicated)
		COM_ImmedExecute(va("exec \"%s"PATHSEP"adedserv.cfg\"\n", srb2home));
	else
		COM_ImmedExecute(va("exec \"%s"PATHSEP"autoexec.cfg\" -noerror\n", srb2home));

	if (!autostart)
		M_PushSpecialParameters(); // push all "+" parameters at the command buffer

	// demo doesn't need anymore to be added with D_AddFile()
	p = M_CheckParm("-playdemo");
	if (!p)
		p = M_CheckParm("-timedemo");
	if (p && M_IsNextParm())
	{
		char tmp[MAX_WADPATH];
		// add .lmp to identify the EXTERNAL demo file
		// it is NOT possible to play an internal demo using -playdemo,
		// rather push a playdemo command.. to do.

		strcpy(tmp, M_GetNextParm());
		// get spaced filename or directory
		while (M_IsNextParm())
		{
			strcat(tmp, " ");
			strcat(tmp, M_GetNextParm());
		}

		FIL_DefaultExtension(tmp, ".lmp");

		CONS_Printf(M_GetText("Playing demo %s.\n"), tmp);

		if (M_CheckParm("-playdemo"))
		{
			singledemo = true; // quit after one demo
			G_DeferedPlayDemo(tmp);
		}
		else
			G_TimeDemo(tmp);

		G_SetGamestate(GS_NULL);
		wipegamestate = GS_NULL;
		return;
	}

	if (M_CheckParm("-ultimatemode"))
	{
		autostart = true;
		ultimatemode = true;
	}

	if (autostart || netgame || M_CheckParm("+connect") || M_CheckParm("-connect"))
	{
		gameaction = ga_nothing;

		CV_ClearChangedFlags();

		// Do this here so if you run SRB2 with eg +timelimit 5, the time limit counts
		// as having been modified for the first game.
		M_PushSpecialParameters(); // push all "+" parameter at the command buffer

		if (M_CheckParm("-gametype") && M_IsNextParm())
		{
			// from Command_Map_f
			INT32 j;
			INT16 newgametype = -1;
			const char *sgametype = M_GetNextParm();

			for (j = 0; gametype_cons_t[j].strvalue; j++)
				if (!strcasecmp(gametype_cons_t[j].strvalue, sgametype))
				{
					newgametype = (INT16)gametype_cons_t[j].value;
					break;
				}
			if (!gametype_cons_t[j].strvalue) // reached end of the list with no match
			{
				j = atoi(sgametype); // assume they gave us a gametype number, which is okay too
				if (j >= 0 && j < NUMGAMETYPES)
					newgametype = (INT16)j;
			}

			if (newgametype != -1)
			{
				j = gametype;
				gametype = newgametype;
				D_GameTypeChanged(j);
			}
		}

		if (server && !M_CheckParm("+map") && !M_CheckParm("+connect")
			&& !M_CheckParm("-connect"))
		{
			// Prevent warping to nonexistent levels
			if (W_CheckNumForName(G_BuildMapName(pstartmap)) == LUMPERROR)
				I_Error("Could not warp to %s (map not found)\n", G_BuildMapName(pstartmap));
			// Prevent warping to locked levels
			// ... unless you're in a dedicated server.  Yes, technically this means you can view any level by
			// running a dedicated server and joining it yourself, but that's better than making dedicated server's
			// lives hell.
			else if (!dedicated && M_MapLocked(pstartmap))
				I_Error("You need to unlock this level before you can warp to it!\n");
			else
				D_MapChange(pstartmap, gametype, ultimatemode, true, 0, false, false);
		}
	}
	else if (M_CheckParm("-skipintro"))
	{
		CON_ToggleOff();
		CON_ClearHUD();
		F_StartTitleScreen();
	}
	else
		F_StartIntro(); // Tails 03-03-2002

	if (dedicated && server)
	{
		pagename = "TITLESKY";
		levelstarttic = gametic;
		G_SetGamestate(GS_LEVEL);
		if (!P_SetupLevel(false))
			I_Quit(); // fail so reset game stuff
	}
}
コード例 #8
0
ファイル: r_plane.c プロジェクト: jeffdoggett/Doom
//-----------------------------------------------------------------------------
//
// R_DrawPlanes
// At the end of each frame.
//
void R_DrawPlanes(void)
{
    int i;
    visplane_t *pl;

#ifdef RANGECHECK
    if (ds_p > &drawsegs[MAXDRAWSEGS])
        I_Error ("R_DrawPlanes: drawsegs overflow (%i)",
                 ds_p - drawsegs);

    if (lastvisplane > &visplanes[MAXVISPLANES])
        I_Error ("R_DrawPlanes: visplane overflow (%i)",
                 lastvisplane - visplanes);

    if (lastopening > &openings[MAXOPENINGS])
        I_Error ("R_DrawPlanes: opening overflow (%i)",
                 lastopening - openings);
#endif

    if (showrplanestats)
    {
#ifdef __riscos
        extern void _kernel_oswrch (int);
        _kernel_oswrch (31);
        _kernel_oswrch (0);
        _kernel_oswrch (0);
#endif
        printf ("Drawsegs = %u/%u, Visplanes = %u/%u, Openings = %u/%u\n",
                ds_p - drawsegs, MAXDRAWSEGS,
                lastvisplane - visplanes, MAXVISPLANES,
                lastopening - openings, MAXOPENINGS);
    }

    for (pl = visplanes ; pl < lastvisplane ; pl++)
    {
        if (pl->minx <= pl->maxx)
        {
            int picnum = pl->picnum;

            // sky flat
            if (picnum == skyflatnum || (picnum & PL_SKYFLAT))
            {
                int	 x;
                int	 texture;
                int	 offset;
                angle_t  an, flip;
                rpatch_t *tex_patch;

                // killough 10/98: allow skies to come from sidedefs.
                // Allows scrolling and/or animated skies, as well as
                // arbitrary multiple skies per level without having
                // to use info lumps.
                an = viewangle;

                if (picnum & PL_SKYFLAT)
                {
                    // Sky Linedef
                    const line_t *l = &lines[picnum & ~PL_SKYFLAT];

                    // Sky transferred from first sidedef
                    const side_t *s = *l->sidenum + sides;

                    // Texture comes from upper texture of reference sidedef
                    texture = texturetranslation[s->toptexture];

                    // Horizontal offset is turned into an angle offset,
                    // to allow sky rotation as well as careful positioning.
                    // However, the offset is scaled very small, so that it
                    // allows a long-period of sky rotation.
                    an += s->textureoffset;

                    // Vertical offset allows careful sky positioning.
                    dc_texturemid = s->rowoffset - 28 * FRACUNIT;

                    // We sometimes flip the picture horizontally.
                    //
                    // DOOM always flipped the picture, so we make it optional,
                    // to make it easier to use the new feature, while to still
                    // allow old sky textures to be used.
                    flip = l->special==272 ? 0u : ~0u;
                }
                else	// Normal DOOM sky, only one allowed per level
                {
                    dc_texturemid = skytexturemid;	// Default y-offset
                    texture = skytexture;			// Default texture
                    flip = 0;				// DOOM flips it
                }

                // Sky is always drawn full bright,
                //  i.e. colormaps[0] is used.
                // Because of this hack, sky is not affected
                //  by INVUL inverse mapping.
                dc_colormap = (fixedcolormap ? fixedcolormap : colormaps);

                dc_ylim = textureheight[texture];
                dc_iscale = skyiscale;
                tex_patch = R_CacheTextureCompositePatchNum (texture);
                offset = skycolumnoffset >> FRACBITS;

                for (x = pl->minx; x <= pl->maxx; x++)
                {
                    dc_yl = pl->top[x+1];
                    dc_yh = pl->bottom[x+1];

                    if (dc_yl <= dc_yh)
                    {
                        dc_x = x;
                        dc_source = R_GetTextureColumn(tex_patch, (((an + xtoviewangle[x]) ^ flip)
                                                       >> ANGLETOSKYSHIFT) + offset);
                        dc_texturefrac = R_CalcFrac ();
                        colfunc();
                    }
                }
                R_UnlockTextureCompositePatchNum (texture);
            }
コード例 #9
0
ファイル: r_bsp.cpp プロジェクト: davidsgalbraith/odamex
//
// R_Subsector
// Determine floor/ceiling planes.
// Add sprites of things in sector.
// Draw one or more line segments.
//
void R_Subsector (int num)
{
	int 		 count;
	seg_t*		 line;
	subsector_t *sub;
	sector_t     tempsec;				// killough 3/7/98: deep water hack
	int          floorlightlevel;		// killough 3/16/98: set floor lightlevel
	int          ceilinglightlevel;		// killough 4/11/98

#ifdef RANGECHECK
    if (num>=numsubsectors)
		I_Error ("R_Subsector: ss %i with numss = %i",
				 num,
				 numsubsectors);
#endif

	sub = &subsectors[num];
	frontsector = sub->sector;
	count = sub->numlines;
	line = &segs[sub->firstline];

	// killough 3/8/98, 4/4/98: Deep water / fake ceiling effect
	frontsector = R_FakeFlat(frontsector, &tempsec, &floorlightlevel,
						   &ceilinglightlevel, false);	// killough 4/11/98

	basecolormap = frontsector->colormap->maps;

	ceilingplane = P_CeilingHeight(camera) > viewz ||
		frontsector->ceilingpic == skyflatnum ||
		(frontsector->heightsec && 
		!(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) && 
		frontsector->heightsec->floorpic == skyflatnum) ?
		R_FindPlane(frontsector->ceilingplane,		// killough 3/8/98
					frontsector->ceilingpic == skyflatnum &&  // killough 10/98
						frontsector->sky & PL_SKYFLAT ? frontsector->sky :
						frontsector->ceilingpic,
					ceilinglightlevel,				// killough 4/11/98
					frontsector->ceiling_xoffs,		// killough 3/7/98
					frontsector->ceiling_yoffs + frontsector->base_ceiling_yoffs,
					frontsector->ceiling_xscale,
					frontsector->ceiling_yscale,
					frontsector->ceiling_angle + frontsector->base_ceiling_angle
					) : NULL;

	// killough 3/7/98: Add (x,y) offsets to flats, add deep water check
	// killough 3/16/98: add floorlightlevel
	// killough 10/98: add support for skies transferred from sidedefs
	floorplane = P_FloorHeight(camera) < viewz || // killough 3/7/98
		(frontsector->heightsec &&
		!(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) &&
		frontsector->heightsec->ceilingpic == skyflatnum) ?
		R_FindPlane(frontsector->floorplane,
					frontsector->floorpic == skyflatnum &&  // killough 10/98
						frontsector->sky & PL_SKYFLAT ? frontsector->sky :
						frontsector->floorpic,
					floorlightlevel,				// killough 3/16/98
					frontsector->floor_xoffs,		// killough 3/7/98
					frontsector->floor_yoffs + frontsector->base_floor_yoffs,
					frontsector->floor_xscale,
					frontsector->floor_yscale,
					frontsector->floor_angle + frontsector->base_floor_angle
					) : NULL;

	// [RH] set foggy flag
	foggy = level.fadeto_color[0] || level.fadeto_color[1] || level.fadeto_color[2] || level.fadeto_color[3]
				|| frontsector->colormap->fade;

	// killough 9/18/98: Fix underwater slowdown, by passing real sector
	// instead of fake one. Improve sprite lighting by basing sprite
	// lightlevels on floor & ceiling lightlevels in the surrounding area.
	R_AddSprites (sub->sector, (floorlightlevel + ceilinglightlevel) / 2, FakeSide);

	// [RH] Add particles
	if (r_particles)
	{
		for (WORD i = ParticlesInSubsec[num]; i != NO_PARTICLE; i = Particles[i].nextinsubsector)
			R_ProjectParticle(Particles + i, subsectors[num].sector, FakeSide);
	}		

	if (sub->poly)
	{ // Render the polyobj in the subsector first
		int polyCount = sub->poly->numsegs;
		seg_t **polySeg = sub->poly->segs;
		while (polyCount--)
			R_AddLine (*polySeg++);
	}
	
	while (count--)
		R_AddLine (line++);
}
コード例 #10
0
ファイル: z_zone.c プロジェクト: gabrielbaez/Doom64EX
void *(Z_Realloc)(void *ptr, int size, int tag, void *user, const char *file, int line) {
    memblock_t *block;
    memblock_t *newblock;
    unsigned char *data;
    void *result;

    if(!ptr) {
        return (Z_Malloc)(size, tag, user, file, line);
    }

    if(size == 0) {
        (Z_Free)(ptr, file, line);
        return NULL;
    }

    if(tag < 0 || tag >= PU_MAX) {
        I_Error("Z_Realloc: tag out of range: %i (%s:%d)", tag, file, line);
    }

    if(user == NULL && tag >= PU_PURGELEVEL) {
        I_Error("Z_Realloc: an owner is required for purgable blocks (%s:%d)", file, line);
    }

    block = (memblock_t*)((byte *)ptr - sizeof(memblock_t));

    newblock = NULL;

    if(block->id != ZONEID) {
        I_Error("Z_Realloc: Reallocated a pointer without ZONEID (%s:%d)", file, line);
    }

    Z_RemoveBlock(block);

    block->next = NULL;
    block->prev = NULL;

    if(block->user) {
        *block->user = NULL;
    }

    if(!(newblock = (memblock_t*)realloc(block, sizeof(memblock_t) + size))) {
        if(Z_ClearCache(sizeof(memblock_t) + size)) {
            newblock = (memblock_t*)realloc(block, sizeof(memblock_t) + size);
        }
    }

    if(!newblock) {
        I_Error("Z_Realloc: failed on allocation of %u bytes (%s:%d)", size, file, line);
    }

    newblock->tag = tag;
    newblock->id = ZONEID;
    newblock->user = user;
    newblock->size = size;

    Z_InsertBlock(newblock);

    data = (unsigned char*)newblock;
    result = data + sizeof(memblock_t);

    if(user != NULL) {
        *newblock->user = result;
    }

#ifdef ZONEFILE
    Z_LogPrintf("* %p = Z_Realloc(ptr=%p, n=%lu, tag=%d, user=%p, source=%s:%d)\n",
                result, ptr, size, tag, user, file, line);
#endif

    return result;
}
コード例 #11
0
ファイル: v_video.cpp プロジェクト: 469486139/DOOM-3-BFG
//
// V_DrawPatchFlipped 
// Masks a column based masked pic to the screen.
// Flips horizontally, e.g. to mirror face.
//
void
V_DrawPatchFlipped
( int		x,
  int		y,
  int		scrn,
  patch_t*	patch ) 
{ 

    int				count;
    int				col; 
    postColumn_t*	column; 
    byte*			source; 
    int				w; 
	 
    y -= SHORT(patch->topoffset); 
    x -= SHORT(patch->leftoffset); 
#ifdef RANGECHECK 
    if (x<0
	||x+SHORT(patch->width) >ORIGINAL_WIDTH
	|| y<0
	|| y+SHORT(patch->height)>ORIGINAL_HEIGHT
	|| (unsigned)scrn>4)
    {
      I_PrintfE("Patch origin %d,%d exceeds LFB\n", x,y );
      I_Error ("Bad V_DrawPatch in V_DrawPatchFlipped");
    }
#endif 
 
    if (!scrn)
	V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height)); 

    col = 0; 
	int destx = x;
	int desty = y;

    w = SHORT(patch->width); 

    for ( ; col<w ; x++, col++ ) 
    { 
		column = (postColumn_t *)((byte *)patch + LONG(patch->columnofs[w-1-col])); 

		destx = x;
	 
		// step through the posts in a column 
		while (column->topdelta != 0xff ) 
		{ 
			source = (byte *)column + 3; 
			desty = y + column->topdelta;
			count = column->length; 
				 
			while (count--) 
			{
				int scaledx, scaledy;
				scaledx = destx * GLOBAL_IMAGE_SCALER;
				scaledy = desty * GLOBAL_IMAGE_SCALER;
				byte src = *source++;

				for ( int i = 0; i < GLOBAL_IMAGE_SCALER; i++ ) {
					for ( int j = 0; j < GLOBAL_IMAGE_SCALER; j++ ) {
						::g->screens[scrn][( scaledx + j ) + ( scaledy + i ) * SCREENWIDTH] = src;
					}
				}

				desty++;
			} 
			column = (postColumn_t *)(  (byte *)column + column->length + 4 );
		} 
    }			 
} 
コード例 #12
0
//
// R_InitTextures
// Initializes the texture list
//  with the textures from the world map.
//
void R_InitTextures (void)
{
    maptexture_t*       mtexture;
    texture_t*          texture;
    mappatch_t*         mpatch;
    texpatch_t*         patch;

    int                 i;
    int                 j;

    int*                maptex;
    int*                maptex2;
    int*                maptex1;
    
    char                name[9];
    char*               names;
    char*               name_p;
    
    int*                patchlookup;
    
    int                 totalwidth;
    int                 nummappatches;
    int                 offset;
    int                 maxoff;
    int                 maxoff2;
    int                 numtextures1;
    int                 numtextures2;

    int*                directory;
    
    int                 temp1;
    int                 temp2;
    int                 temp3;

    
    // Load the patch names from pnames.lmp.
    name[8] = 0;        
    names = W_CacheLumpName ("PNAMES", PU_STATIC);
    nummappatches = LONG ( *((int *)names) );
    name_p = names+4;
    patchlookup = alloca (nummappatches*sizeof(*patchlookup));
    
    for (i=0 ; i<nummappatches ; i++)
    {
        strncpy (name,name_p+i*8, 8);
        patchlookup[i] = W_CheckNumForName (name);
    }
    Z_Free (names);
    
    // Load the map texture definitions from textures.lmp.
    // The data is contained in one or two lumps,
    //  TEXTURE1 for shareware, plus TEXTURE2 for commercial.
    maptex = maptex1 = W_CacheLumpName ("TEXTURE1", PU_STATIC);
    numtextures1 = LONG(*maptex);
    maxoff = W_LumpLength (W_GetNumForName ("TEXTURE1"));
    directory = maptex+1;
        
    if (W_CheckNumForName ("TEXTURE2") != -1)
    {
        maptex2 = W_CacheLumpName ("TEXTURE2", PU_STATIC);
        numtextures2 = LONG(*maptex2);
        maxoff2 = W_LumpLength (W_GetNumForName ("TEXTURE2"));
    }
    else
    {
        maptex2 = NULL;
        numtextures2 = 0;
        maxoff2 = 0;
    }
    numtextures = numtextures1 + numtextures2;
        
    textures = Z_Malloc (numtextures*4, PU_STATIC, 0);
    texturecolumnlump = Z_Malloc (numtextures*4, PU_STATIC, 0);
    texturecolumnofs = Z_Malloc (numtextures*4, PU_STATIC, 0);
    texturecomposite = Z_Malloc (numtextures*4, PU_STATIC, 0);
    texturecompositesize = Z_Malloc (numtextures*4, PU_STATIC, 0);
    texturewidthmask = Z_Malloc (numtextures*4, PU_STATIC, 0);
    textureheight = Z_Malloc (numtextures*4, PU_STATIC, 0);

    totalwidth = 0;
    
    //  Really complex printing shit...
    temp1 = W_GetNumForName ("S_START");  // P_???????
    temp2 = W_GetNumForName ("S_END") - 1;
    temp3 = ((temp2-temp1+63)/64) + ((numtextures+63)/64);
    printf("[");
    for (i = 0; i < temp3; i++)
        printf(" ");
    printf("         ]");
    for (i = 0; i < temp3; i++)
        printf("\x8");
    printf("\x8\x8\x8\x8\x8\x8\x8\x8\x8\x8");   
        
    for (i=0 ; i<numtextures ; i++, directory++)
    {
        if (!(i&63))
            printf (".");

        if (i == numtextures1)
        {
            // Start looking in second texture file.
            maptex = maptex2;
            maxoff = maxoff2;
            directory = maptex+1;
        }
                
        offset = LONG(*directory);

        if (offset > maxoff)
            I_Error ("R_InitTextures: bad texture directory");
        
        mtexture = (maptexture_t *) ( (byte *)maptex + offset);

        texture = textures[i] =
            Z_Malloc (sizeof(texture_t)
                      + sizeof(texpatch_t)*(SHORT(mtexture->patchcount)-1),
                      PU_STATIC, 0);
        
        texture->width = SHORT(mtexture->width);
        texture->height = SHORT(mtexture->height);
        texture->patchcount = SHORT(mtexture->patchcount);

        memcpy (texture->name, mtexture->name, sizeof(texture->name));
        mpatch = &mtexture->patches[0];
        patch = &texture->patches[0];

        for (j=0 ; j<texture->patchcount ; j++, mpatch++, patch++)
        {
            patch->originx = SHORT(mpatch->originx);
            patch->originy = SHORT(mpatch->originy);
            patch->patch = patchlookup[SHORT(mpatch->patch)];
            if (patch->patch == -1)
            {
                I_Error ("R_InitTextures: Missing patch in texture %s",
                         texture->name);
            }
        }               
        texturecolumnlump[i] = Z_Malloc (texture->width*2, PU_STATIC,0);
        texturecolumnofs[i] = Z_Malloc (texture->width*2, PU_STATIC,0);

        j = 1;
        while (j*2 <= texture->width)
            j<<=1;

        texturewidthmask[i] = j-1;
        textureheight[i] = texture->height<<FRACBITS;
                
        totalwidth += texture->width;
    }

    Z_Free (maptex1);
    if (maptex2)
        Z_Free (maptex2);
    
    // Precalculate whatever possible.  
    for (i=0 ; i<numtextures ; i++)
        R_GenerateLookup (i);
    
    // Create translation table for global animation.
    texturetranslation = Z_Malloc ((numtextures+1)*4, PU_STATIC, 0);
    
    for (i=0 ; i<numtextures ; i++)
        texturetranslation[i] = i;
}
コード例 #13
0
//
// R_GenerateLookup
//
void R_GenerateLookup (int texnum)
{
    texture_t*          texture;
    byte*               patchcount;     // patchcount[texture->width]
    texpatch_t*         patch;  
    patch_t*            realpatch;
    int                 x;
    int                 x1;
    int                 x2;
    int                 i;
    short*              collump;
    unsigned short*     colofs;
        
    texture = textures[texnum];

    // Composited texture not created yet.
    texturecomposite[texnum] = 0;
    
    texturecompositesize[texnum] = 0;
    collump = texturecolumnlump[texnum];
    colofs = texturecolumnofs[texnum];
    
    // Now count the number of columns
    //  that are covered by more than one patch.
    // Fill in the lump / offset, so columns
    //  with only a single patch are all done.
    patchcount = (byte *)alloca (texture->width);
    memset (patchcount, 0, texture->width);
    patch = texture->patches;
                
    for (i=0 , patch = texture->patches;
         i<texture->patchcount;
         i++, patch++)
    {
        realpatch = W_CacheLumpNum (patch->patch, PU_CACHE);
        x1 = patch->originx;
        x2 = x1 + SHORT(realpatch->width);
        
        if (x1 < 0)
            x = 0;
        else
            x = x1;

        if (x2 > texture->width)
            x2 = texture->width;
        for ( ; x<x2 ; x++)
        {
            patchcount[x]++;
            collump[x] = patch->patch;
            colofs[x] = LONG(realpatch->columnofs[x-x1])+3;
        }
    }
        
    for (x=0 ; x<texture->width ; x++)
    {
        if (!patchcount[x])
        {
            printf ("R_GenerateLookup: column without a patch (%s)\n",
                    texture->name);
            return;
        }
        // I_Error ("R_GenerateLookup: column without a patch");
        
        if (patchcount[x] > 1)
        {
            // Use the cached block.
            collump[x] = -1;    
            colofs[x] = texturecompositesize[texnum];
            
            if (texturecompositesize[texnum] > 0x10000-texture->height)
            {
                I_Error ("R_GenerateLookup: texture %i is >64k",
                         texnum);
            }
            
            texturecompositesize[texnum] += texture->height;
        }
    }   
}
コード例 #14
0
ファイル: mid2strm.c プロジェクト: Pupswoof117/SRB2-Public
// -------------------------
// Mid2StreamConvertToBuffer
//
// This function converts MIDI data from the track buffers setup by a previous
// call to Mid2StreamConverterInit().  It will convert data until an error is
// encountered or the output buffer has been filled with as much event data
// as possible, not to exceed dwMaxLength. This function can take a couple
// bit flags, passed through dwFlags. Information about the success/failure
// of this operation and the number of output bytes actually converted will
// be returned in the CONVERTINFO structure pointed at by lpciInfo.
// -------------------------
int Mid2StreamConvertToBuffer(DWORD dwFlags, LPCONVERTINFO lpciInfo)
{
	static LPINTRACKSTATE pInTrack, pInTrackFound;
	static DWORD          dwStatus;
	static DWORD          tkNext;
	static TEMPEVENT      teTemp;

	int     nChkErr;
	DWORD   idx;

	lpciInfo->dwBytesRecorded = 0;

	if (dwFlags & CONVERTF_RESET)
	{
		dwProgressBytes = 0;
		dwStatus = 0;
		ZeroMemory(&teTemp, sizeof (TEMPEVENT));
		pInTrack = pInTrackFound = NULL;
	}

	// If we were already done, then return with a warning...
	if (dwStatus & CONVERTF_STATUS_DONE)
	{
		if (bMidiLooped)
		{
			Mid2StreamRewindConverter();
			dwProgressBytes = 0;
			dwStatus = 0;
		}
		else
			return CONVERTERR_DONE;
	}
	// The caller is asking us to continue, but we're already hosed because we
	// previously identified something as corrupt, so complain louder this time.
	else if (dwStatus & CONVERTF_STATUS_STUCK)
		return CONVERTERR_STUCK;
	else if (dwStatus & CONVERTF_STATUS_GOTEVENT)
	{
		// Turn off this bit flag
		dwStatus ^= CONVERTF_STATUS_GOTEVENT;

		// Don't add end of track event 'til we're done
		//
		if (teTemp.abEvent[0] == MIDI_META &&
			teTemp.abEvent[1] == MIDI_META_EOT)
		{
		}
		else if ((nChkErr = AddEventToStreamBuffer(&teTemp, lpciInfo))
		         != CONVERTERR_NOERROR)
		{
			if (nChkErr == CONVERTERR_BUFFERFULL)
			{
				// Do some processing and tell caller that this buffer's full
				dwStatus |= CONVERTF_STATUS_GOTEVENT;
				return CONVERTERR_NOERROR;
			}
			else if (nChkErr == CONVERTERR_METASKIP)
			{
				// We skip by all meta events that aren't tempo changes...
			}
			else
			{
				I_Error("Unable to add event to stream buffer.");
			}
		}
	}

	for (; ;)
	{
		pInTrackFound = NULL;
		tkNext = 0xFFFFFFFFL;

		// Find nearest event due
		//
		for (idx = 0, pInTrack = ifs.pTracks; idx < ifs.nTracks; ++idx, ++pInTrack)
		{
			if ((!(pInTrack->fdwTrack & ITS_F_ENDOFTRK)) && (pInTrack->tkNextEventDue < tkNext))
			{
				tkNext = pInTrack->tkNextEventDue;
				pInTrackFound = pInTrack;
			}
		}

		// None found?  We must be done, so return to the caller with a smile.
		//
		if (!pInTrackFound)
		{
			dwStatus |= CONVERTF_STATUS_DONE;
			// Need to set return buffer members properly
			return CONVERTERR_NOERROR;
		}

		// Ok, get the event header from that track
		//
		if (!GetTrackEvent(pInTrackFound, &teTemp))
		{
			// Warn future calls that this converter is stuck at a corrupt spot
			// and can't continue
			dwStatus |= CONVERTF_STATUS_STUCK;
			return CONVERTERR_CORRUPT;
		}

		// Don't add end of track event 'til we're done
		//
		if (teTemp.abEvent[0] == MIDI_META &&
		    teTemp.abEvent[1] == MIDI_META_EOT)
			continue;

		if ((nChkErr = AddEventToStreamBuffer(&teTemp, lpciInfo))
			!= CONVERTERR_NOERROR)
		{
			if (nChkErr == CONVERTERR_BUFFERFULL)
			{
				// Do some processing and tell somebody this buffer is full...
				dwStatus |= CONVERTF_STATUS_GOTEVENT;
				return CONVERTERR_NOERROR;
			}
			else if (nChkErr == CONVERTERR_METASKIP)
			{
				// We skip by all meta events that aren't tempo changes...
			}
			else
			{
				I_Error("Unable to add event to stream buffer.");
			}
		}
	}

	//return CONVERTERR_NOERROR;
}
コード例 #15
0
void W_AddFile (char *filename)
{
    wadinfo_t		header;
    lumpinfo_t*		lump_p;
    unsigned		i;
    FILE	       *handle;
    int			length;
    int			startlump;
    filelump_t*		fileinfo;
    filelump_t		singleinfo;
    int			storehandle;
    
    // open the file and add to directory

    // handle reload indicator.
    if (filename[0] == '~')
    {
	filename++;
	reloadname = filename;
	reloadlump = numlumps;
    }
		
    if ( (handle = fopen (filename,"rb")) == NULL)
    {
	printf (" couldn't open %s\n",filename);
	return;
    }

    printf (" adding %s\n",filename);
    startlump = numlumps;
	
    if (I_strncasecmp (filename+strlen(filename)-3 , "wad", 3 ) )
    {
	// single lump file
	fileinfo = &singleinfo;
	singleinfo.filepos = 0;
	singleinfo.size = LONG(filelength(handle));
	ExtractFileBase (filename, singleinfo.name);
	numlumps++;
    }
    else 
    {
	// WAD file
	fread (&header, 1, sizeof(header), handle);
	if (strncmp(header.identification,"IWAD",4))
	{
	    // Homebrew levels?
	    if (strncmp(header.identification,"PWAD",4))
	    {
		I_Error ("Wad file %s doesn't have IWAD "
			 "or PWAD id\n", filename);
	    }
	    
	    // ???modifiedgame = true;		
	}
	header.numlumps = LONG(header.numlumps);
	header.infotableofs = LONG(header.infotableofs);
	length = header.numlumps*sizeof(filelump_t);
	fileinfo = alloca (length);
	fseek (handle, header.infotableofs, SEEK_SET);
	fread (fileinfo, 1, length, handle);
	numlumps += header.numlumps;
    }

    
    // Fill in lumpinfo
    lumpinfo = realloc (lumpinfo, numlumps*sizeof(lumpinfo_t));

    if (!lumpinfo)
	I_Error ("Couldn't realloc lumpinfo");

    lump_p = &lumpinfo[startlump];
	
    storehandle = reloadname ? -1 : (int)handle;
	
    for (i=startlump ; i<numlumps ; i++,lump_p++, fileinfo++)
    {
	lump_p->handle = storehandle;
	lump_p->position = LONG(fileinfo->filepos);
	lump_p->size = LONG(fileinfo->size);
	strncpy (lump_p->name, fileinfo->name, 8);
    }
	
    if (reloadname)
	fclose (handle);
}
コード例 #16
0
ファイル: i_net.cpp プロジェクト: Doom2fan/gzdoom
//
// PacketGet
//
void PacketGet (void)
{
	int c;
	socklen_t fromlen;
	sockaddr_in fromaddress;
	int node;

	fromlen = sizeof(fromaddress);
	c = recvfrom (mysocket, (char*)TransmitBuffer, TRANSMIT_SIZE, 0,
				  (sockaddr *)&fromaddress, &fromlen);
	node = FindNode (&fromaddress);

	if (node >= 0 && c == SOCKET_ERROR)
	{
		int err = WSAGetLastError();

		if (err == WSAECONNRESET)
		{ // The remote node aborted unexpectedly, so pretend it sent an exit packet

			if (StartScreen != NULL)
			{
				StartScreen->NetMessage ("The connection from %s was dropped.\n",
					players[sendplayer[node]].userinfo.GetName());
			}
			else
			{
				Printf("The connection from %s was dropped.\n",
					players[sendplayer[node]].userinfo.GetName());
			}

			doomcom.data[0] = 0x80;	// NCMD_EXIT
			c = 1;
		}
		else if (err != WSAEWOULDBLOCK)
		{
			I_Error ("GetPacket: %s", neterror ());
		}
		else
		{
			doomcom.remotenode = -1;		// no packet
			return;
		}
	}
	else if (node >= 0 && c > 0)
	{
		doomcom.data[0] = TransmitBuffer[0] & ~NCMD_COMPRESSED;
		if (TransmitBuffer[0] & NCMD_COMPRESSED)
		{
			uLongf msgsize = MAX_MSGLEN - 1;
			int err = uncompress(doomcom.data + 1, &msgsize, TransmitBuffer + 1, c - 1);
//			Printf("recv %d/%lu\n", c, msgsize + 1);
			if (err != Z_OK)
			{
				Printf("Net decompression failed (zlib error %s)\n", M_ZLibError(err).GetChars());
				// Pretend no packet
				doomcom.remotenode = -1;
				return;
			}
			c = msgsize + 1;
		}
		else
		{
//			Printf("recv %d\n", c);
			memcpy(doomcom.data + 1, TransmitBuffer + 1, c - 1);
		}
	}
	else if (c > 0)
	{	//The packet is not from any in-game node, so we might as well discard it.
		// Don't show the message for disconnect notifications.
		if (c != 2 || TransmitBuffer[0] != PRE_FAKE || TransmitBuffer[1] != PRE_DISCONNECT)
		{
			DPrintf(DMSG_WARNING, "Dropped packet: Unknown host (%s:%d)\n", inet_ntoa(fromaddress.sin_addr), fromaddress.sin_port);
		}
		doomcom.remotenode = -1;
		return;
	}

	doomcom.remotenode = node;
	doomcom.datalength = (short)c;
}
コード例 #17
0
ファイル: w_wad.c プロジェクト: BruceJawn/flash-doom
void W_AddFile (char *filename)
{
	wadinfo_t		header;
	lumpinfo_t		*lump_p;
	unsigned		i;
	int				handle, length;
	int				startlump;
	filelump_t		*fileinfo, singleinfo;
	
//
// open the file and add to directory
//	
	if ( (handle = open (filename,O_RDONLY | O_BINARY)) == -1)
		return;

	startlump = numlumps;
	
	if (strcmpi (filename+strlen(filename)-3 , "wad" ) )
	{
	// single lump file
		fileinfo = &singleinfo;
		singleinfo.filepos = 0;
		singleinfo.size = LONG(filelength(handle));
		ExtractFileBase (filename, singleinfo.name);
		numlumps++;
	}
	else 
	{
	// WAD file
		read (handle, &header, sizeof(header));
		if (strncmp(header.identification,"IWAD",4))
		{
			if (strncmp(header.identification,"PWAD",4))
				I_Error ("Wad file %s doesn't have IWAD or PWAD id\n"
				,filename);
		}
		header.numlumps = LONG(header.numlumps);
		header.infotableofs = LONG(header.infotableofs);
		length = header.numlumps*sizeof(filelump_t);
		fileinfo = alloca (length);
		lseek (handle, header.infotableofs, SEEK_SET);
		read (handle, fileinfo, length);
		numlumps += header.numlumps;
	}

//
// Fill in lumpinfo
//
	lumpinfo = realloc (lumpinfo, numlumps*sizeof(lumpinfo_t));
	if (!lumpinfo)
		I_Error ("Couldn't realloc lumpinfo");
	lump_p = &lumpinfo[startlump];
	
	for (i=startlump ; i<numlumps ; i++,lump_p++, fileinfo++)
	{
		lump_p->handle = handle;
		lump_p->position = LONG(fileinfo->filepos);
		lump_p->size = LONG(fileinfo->size);
		strncpy (lump_p->name, fileinfo->name, 8);
	}
}
コード例 #18
0
//
// EV_VerticalDoor : open a door manually, no tag value
//
void
EV_VerticalDoor
( line_t*	line,
  mobj_t*	thing )
{
    player_t*	player;
    sector_t*	sec;
    vldoor_t*	door;
    int		side;
	
    side = 0;	// only front sides can be used

    //	Check for locks
    player = thing->player;
		
    switch(line->special)
    {
      case 26: // Blue Lock
      case 32:
	if ( !player )
	    return;
	
	if (!player->cards[it_bluecard] && !player->cards[it_blueskull])
	{
	    player->message = DEH_String(PD_BLUEK);
	    S_StartSound(NULL,sfx_oof);
	    return;
	}
	break;
	
      case 27: // Yellow Lock
      case 34:
	if ( !player )
	    return;
	
	if (!player->cards[it_yellowcard] &&
	    !player->cards[it_yellowskull])
	{
	    player->message = DEH_String(PD_YELLOWK);
	    S_StartSound(NULL,sfx_oof);
	    return;
	}
	break;
	
      case 28: // Red Lock
      case 33:
	if ( !player )
	    return;
	
	if (!player->cards[it_redcard] && !player->cards[it_redskull])
	{
	    player->message = DEH_String(PD_REDK);
	    S_StartSound(NULL,sfx_oof);
	    return;
	}
	break;
    }
	
    // if the sector has an active thinker, use it

    if (line->sidenum[side^1] == -1)
    {
        I_Error("EV_VerticalDoor: DR special type on 1-sided linedef");
    }

    sec = sides[ line->sidenum[side^1]] .sector;

    if (sec->specialdata)
    {
	door = sec->specialdata;
	switch(line->special)
	{
	  case	1: // ONLY FOR "RAISE" DOORS, NOT "OPEN"s
	  case	26:
	  case	27:
	  case	28:
	  case	117:
	    if (door->direction == -1)
		door->direction = 1;	// go back up
	    else
	    {
		if (!thing->player)
		    return;		// JDC: bad guys never close doors

                // When is a door not a door?
                // In Vanilla, door->direction is set, even though
                // "specialdata" might not actually point at a door.

                if (door->thinker.function.acp1 == (actionf_p1) T_VerticalDoor)
                {
                    door->direction = -1;	// start going down immediately
                }
                else if (door->thinker.function.acp1 == (actionf_p1) T_PlatRaise)
                {
                    // Erm, this is a plat, not a door.
                    // This notably causes a problem in ep1-0500.lmp where
                    // a plat and a door are cross-referenced; the door
                    // doesn't open on 64-bit.
                    // The direction field in vldoor_t corresponds to the wait
                    // field in plat_t.  Let's set that to -1 instead.

                    plat_t *plat;

                    plat = (plat_t *) door;
                    plat->wait = -1;
                }
                else
                {
                    // This isn't a door OR a plat.  Now we're in trouble.

                    fprintf(stderr, "EV_VerticalDoor: Tried to close "
                                    "something that wasn't a door.\n");

                    // Try closing it anyway. At least it will work on 32-bit
                    // machines.

                    door->direction = -1;
                }
	    }
	    return;
	}
    }
	
    // for proper sound
    switch(line->special)
    {
      case 117:	// BLAZING DOOR RAISE
      case 118:	// BLAZING DOOR OPEN
	S_StartSound(&sec->soundorg,sfx_bdopn);
	break;
	
      case 1:	// NORMAL DOOR SOUND
      case 31:
	S_StartSound(&sec->soundorg,sfx_doropn);
	break;
	
      default:	// LOCKED DOOR SOUND
	S_StartSound(&sec->soundorg,sfx_doropn);
	break;
    }
	
    
    // new door thinker
    door = Z_Malloc (sizeof(*door), PU_LEVSPEC, 0);
    P_AddThinker (&door->thinker);
    sec->specialdata = door;
    door->thinker.function.acp1 = (actionf_p1) T_VerticalDoor;
    door->sector = sec;
    door->direction = 1;
    door->speed = VDOORSPEED;
    door->topwait = VDOORWAIT;

    switch(line->special)
    {
      case 1:
      case 26:
      case 27:
      case 28:
	door->type = vld_normal;
	break;
	
      case 31:
      case 32:
      case 33:
      case 34:
	door->type = vld_open;
	line->special = 0;
	break;
	
      case 117:	// blazing door raise
	door->type = vld_blazeRaise;
	door->speed = VDOORSPEED*4;
	break;
      case 118:	// blazing door open
	door->type = vld_blazeOpen;
	line->special = 0;
	door->speed = VDOORSPEED*4;
	break;
    }
    
    // find the top and bottom of the movement range
    door->topheight = P_FindLowestCeilingSurrounding(sec);
    door->topheight -= 4*FRACUNIT;
}
コード例 #19
0
ファイル: d_main.c プロジェクト: ilag11111/SRB2
static void IdentifyVersion(void)
{
	char *srb2wad1, *srb2wad2;
	const char *srb2waddir = NULL;

#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
	// change to the directory where 'srb2.srb' is found
	srb2waddir = I_LocateWad();
#endif

	// get the current directory (possible problem on NT with "." as current dir)
	if (srb2waddir)
	{
		strlcpy(srb2path,srb2waddir,sizeof (srb2path));
	}
	else
	{
#if !defined(_WIN32_WCE) && !defined(_PS3)
		if (getcwd(srb2path, 256) != NULL)
			srb2waddir = srb2path;
		else
#endif
		{
#ifdef _arch_dreamcast
			srb2waddir = "/cd";
#else
			srb2waddir = ".";
#endif
		}
	}

#if defined (macintosh) && !defined (HAVE_SDL)
	// cwd is always "/" when app is dbl-clicked
	if (!stricmp(srb2waddir, "/"))
		srb2waddir = I_GetWadDir();
#endif
	// Commercial.
	srb2wad1 = malloc(strlen(srb2waddir)+1+8+1);
	srb2wad2 = malloc(strlen(srb2waddir)+1+8+1);
	if (srb2wad1 == NULL && srb2wad2 == NULL)
		I_Error("No more free memory to look in %s", srb2waddir);
	if (srb2wad1 != NULL)
		sprintf(srb2wad1, pandf, srb2waddir, "srb2.srb");
	if (srb2wad2 != NULL)
		sprintf(srb2wad2, pandf, srb2waddir, "srb2.wad");

	// will be overwritten in case of -cdrom or unix/win home
	snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, srb2waddir);
	configfile[sizeof configfile - 1] = '\0';

	// Load the IWAD
	if (srb2wad2 != NULL && FIL_ReadFileOK(srb2wad2))
		D_AddFile(srb2wad2);
	else if (srb2wad1 != NULL && FIL_ReadFileOK(srb2wad1))
		D_AddFile(srb2wad1);
	else
		I_Error("SRB2.SRB/SRB2.WAD not found! Expected in %s, ss files: %s and %s\n", srb2waddir, srb2wad1, srb2wad2);

	if (srb2wad1)
		free(srb2wad1);
	if (srb2wad2)
		free(srb2wad2);

	// if you change the ordering of this or add/remove a file, be sure to update the md5
	// checking in D_SRB2Main

	// Add the maps
	D_AddFile(va(pandf,srb2waddir,"zones.dta"));

	// Add the players
	D_AddFile(va(pandf,srb2waddir, "player.dta"));

	// Add the weapons
	D_AddFile(va(pandf,srb2waddir,"rings.dta"));

#ifdef USE_PATCH_DTA
	// Add our crappy patches to fix our bugs
	D_AddFile(va(pandf,srb2waddir,"patch.dta"));
#endif

#if !defined (HAVE_SDL) || defined (HAVE_MIXER)
	{
#if defined (DC) && 0
		const char *musicfile = "music_dc.dta";
#else
		const char *musicfile = "music.dta";
#endif
		const char *musicpath = va(pandf,srb2waddir,musicfile);
		int ms = W_VerifyNMUSlumps(musicpath); // Don't forget the music!
		if (ms == 1)
			D_AddFile(musicpath);
		else if (ms == 0)
			I_Error("File %s has been modified with non-music lumps",musicfile);
	}
#endif
}
コード例 #20
0
ファイル: p_spec.c プロジェクト: grobe0ba/plan9front
//
// P_PlayerInSpecialSector
// Called every tic frame
//  that the player origin is in a special sector
//
void P_PlayerInSpecialSector (player_t* player)
{
    sector_t*	sector;
	
    sector = player->mo->subsector->sector;

    // Falling, not all the way down yet?
    if (player->mo->z != sector->floorheight)
	return;	

    // Has hitten ground.
    switch (sector->special)
    {
      case 5:
	// HELLSLIME DAMAGE
	if (!player->powers[pw_ironfeet])
	    if (!(leveltime&0x1f))
		P_DamageMobj (player->mo, NULL, NULL, 10);
	break;
	
      case 7:
	// NUKAGE DAMAGE
	if (!player->powers[pw_ironfeet])
	    if (!(leveltime&0x1f))
		P_DamageMobj (player->mo, NULL, NULL, 5);
	break;
	
      case 16:
	// SUPER HELLSLIME DAMAGE
      case 4:
	// STROBE HURT
	if (!player->powers[pw_ironfeet]
	    || (P_Random()<5) )
	{
	    if (!(leveltime&0x1f))
		P_DamageMobj (player->mo, NULL, NULL, 20);
	}
	break;
			
      case 9:
	// SECRET SECTOR
	player->secretcount++;
	sector->special = 0;
	break;
			
      case 11:
	// EXIT SUPER DAMAGE! (for E1M8 finale)
	player->cheats &= ~CF_GODMODE;

	if (!(leveltime&0x1f))
	    P_DamageMobj (player->mo, NULL, NULL, 20);

	if (player->health <= 10)
	    G_ExitLevel();
	break;
			
      default:
	I_Error ("P_PlayerInSpecialSector: "
		 "unknown special %i",
		 sector->special);
	break;
    };
}
コード例 #21
0
ファイル: m_argv.c プロジェクト: Nekrofage/DoomRPi
static void LoadResponseFile(int argv_index)
{
    FILE *handle;
    int size;
    char *infile;
    char *file;
    char *response_filename;
    char **newargv;
    int newargc;
    int i, k;

    response_filename = myargv[argv_index] + 1;

    // Read the response file into memory
    handle = fopen(response_filename, "rb");

    if (handle == NULL)
    {
        printf ("\nNo such response file!");
        exit(1);
    }

    printf("Found response file %s!\n", response_filename);

    size = M_FileLength(handle);

    // Read in the entire file
    // Allocate one byte extra - this is in case there is an argument
    // at the end of the response file, in which case a '\0' will be 
    // needed.

    file = malloc(size + 1);

    if (fread(file, 1, size, handle) < size)
    {
        I_Error("Failed to read entire response file");
    }

    fclose(handle);

    // Create new arguments list array

    newargv = malloc(sizeof(char *) * MAXARGVS);
    newargc = 0;
    memset(newargv, 0, sizeof(char *) * MAXARGVS);

    // Copy all the arguments in the list up to the response file

    for (i=0; i<argv_index; ++i)
    {
        newargv[i] = myargv[i];
        ++newargc;
    }
    
    infile = file;
    k = 0;

    while(k < size)
    {
        // Skip past space characters to the next argument

        while(k < size && isspace(infile[k]))
        {
            ++k;
        } 

        if (k >= size)
        {
            break;
        }

        // If the next argument is enclosed in quote marks, treat
        // the contents as a single argument.  This allows long filenames
        // to be specified.

        if (infile[k] == '\"') 
        {
            // Skip the first character(")
            ++k;

            newargv[newargc++] = &infile[k];

            // Read all characters between quotes

            while (k < size && infile[k] != '\"' && infile[k] != '\n')
            {
                ++k;
            }

            if (k >= size || infile[k] == '\n') 
            {
                I_Error("Quotes unclosed in response file '%s'", 
                        response_filename);
            }

            // Cut off the string at the closing quote

            infile[k] = '\0';
            ++k;
        }
        else
        {
            // Read in the next argument until a space is reached

            newargv[newargc++] = &infile[k];

            while(k < size && !isspace(infile[k]))
            {
                ++k;
            }

            // Cut off the end of the argument at the first space

            infile[k] = '\0';

            ++k;
        }
    } 

    // Add arguments following the response file argument

    for (i=argv_index + 1; i<myargc; ++i)
    {
        newargv[newargc] = myargv[i];
        ++newargc;
    }

    myargv = newargv;
    myargc = newargc;

#if 0
    // Disabled - Vanilla Doom does not do this.
    // Display arguments

    printf("%d command-line args:\n", myargc);

    for (k=1; k<myargc; k++)
    {
        printf("'%s'\n", myargv[k]);
    }
#endif
}
コード例 #22
0
ファイル: p_udmf.cpp プロジェクト: eevee/zdoom
	void ProcessLineDefs()
	{
		int sidecount = 0;
		for(unsigned i = 0, skipped = 0; i < ParsedLines.Size();)
		{
			// Relocate the vertices
			intptr_t v1i = intptr_t(ParsedLines[i].v1);
			intptr_t v2i = intptr_t(ParsedLines[i].v2);

			if (v1i >= numvertexes || v2i >= numvertexes || v1i < 0 || v2i < 0)
			{
				I_Error ("Line %d has invalid vertices: %zd and/or %zd.\nThe map only contains %d vertices.", i+skipped, v1i, v2i, numvertexes);
			}
			else if (v1i == v2i ||
				(vertexes[v1i].x == vertexes[v2i].x && vertexes[v1i].y == vertexes[v2i].y))
			{
				Printf ("Removing 0-length line %d\n", i+skipped);
				ParsedLines.Delete(i);
				ForceNodeBuild = true;
				skipped++;
			}
			else
			{
				ParsedLines[i].v1 = &vertexes[v1i];
				ParsedLines[i].v2 = &vertexes[v2i];

				if (ParsedLines[i].sidedef[0] != NULL)
					sidecount++;
				if (ParsedLines[i].sidedef[1] != NULL)
					sidecount++;
				linemap.Push(i+skipped);
				i++;
			}
		}
		numlines = ParsedLines.Size();
		numsides = sidecount;
		lines = new line_t[numlines];
		sides = new side_t[numsides];
		int line, side;

		for(line = 0, side = 0; line < numlines; line++)
		{
			short tempalpha[2] = { SHRT_MIN, SHRT_MIN };

			lines[line] = ParsedLines[line];

			for(int sd = 0; sd < 2; sd++)
			{
				if (lines[line].sidedef[sd] != NULL)
				{
					int mapside = int(intptr_t(lines[line].sidedef[sd]))-1;
					if (mapside < sidecount)
					{
						sides[side] = ParsedSides[mapside];
						sides[side].linedef = &lines[line];
						sides[side].sector = &sectors[intptr_t(sides[side].sector)];
						lines[line].sidedef[sd] = &sides[side];

						P_ProcessSideTextures(!isExtended, &sides[side], sides[side].sector, &ParsedSideTextures[mapside],
							lines[line].special, lines[line].args[0], &tempalpha[sd], missingTex);

						side++;
					}
					else
					{
						lines[line].sidedef[sd] = NULL;
					}
				}
			}

			P_AdjustLine(&lines[line]);
			P_FinishLoadingLineDef(&lines[line], tempalpha[0]);
		}
		assert(side <= numsides);
		if (side < numsides)
		{
			Printf("Map had %d invalid side references\n", numsides - side);
			numsides = side;
		}
	}
コード例 #23
0
ファイル: w_wad.cpp プロジェクト: JohnnyonFlame/odamex
std::string W_AddFile (std::string filename)
{
	wadinfo_t		header;
	lumpinfo_t*		lump_p;
	size_t			i;
	FILE			*handle;
	size_t			length;
	size_t			startlump;
	size_t          res;
	filelump_t*		fileinfo;
	filelump_t		singleinfo;

	FixPathSeparator (filename);
	std::string name = filename;
	M_AppendExtension (name, ".wad");

    // open the file
	if ( (handle = fopen (filename.c_str(), "rb")) == NULL)
	{
		Printf (PRINT_HIGH, " couldn't open %s\n", filename.c_str());
		return "";
	}

	Printf (PRINT_HIGH, "adding %s\n", filename.c_str());

	startlump = numlumps;

	res = fread (&header, sizeof(header), 1, handle);
	header.identification = LELONG(header.identification);

	if (header.identification != IWAD_ID && header.identification != PWAD_ID)
	{
		// raw lump file
		fileinfo = &singleinfo;
		singleinfo.filepos = 0;
		singleinfo.size = M_FileLength(handle);
		M_ExtractFileBase (filename, name);
		numlumps++;
		Printf (PRINT_HIGH, " (single lump)\n", header.numlumps);
	}
	else
	{
		// WAD file
		header.numlumps = LELONG(header.numlumps);
		header.infotableofs = LELONG(header.infotableofs);
		length = header.numlumps*sizeof(filelump_t);

		if(length > (unsigned)M_FileLength(handle))
		{
			Printf (PRINT_HIGH, " bad number of lumps for %s\n", filename.c_str());
			fclose(handle);
			return "";
		}

		fileinfo = (filelump_t *)Z_Malloc (length, PU_STATIC, 0);
		fseek (handle, header.infotableofs, SEEK_SET);
		res = fread (fileinfo, length, 1, handle);
		numlumps += header.numlumps;
		Printf (PRINT_HIGH, " (%d lumps)\n", header.numlumps);
	}

    // Fill in lumpinfo
	lumpinfo = (lumpinfo_t *)Realloc (lumpinfo, numlumps*sizeof(lumpinfo_t));

	if (!lumpinfo)
		I_Error ("Couldn't realloc lumpinfo");

	lump_p = &lumpinfo[startlump];

	for (i=startlump ; i<numlumps ; i++,lump_p++, fileinfo++)
	{
		lump_p->handle = handle;
		lump_p->position = LELONG(fileinfo->filepos);
		lump_p->size = LELONG(fileinfo->size);
		strncpy (lump_p->name, fileinfo->name, 8);

		// W_CheckNumForName needs all lump names in upper case
		std::transform(lump_p->name, lump_p->name+8, lump_p->name, toupper);
	}

	return W_MD5(filename);
}
コード例 #24
0
ファイル: p_udmf.cpp プロジェクト: eevee/zdoom
	void ParseTextMap(MapData *map)
	{
		char *buffer = new char[map->Size(ML_TEXTMAP)];

		isTranslated = true;
		isExtended = false;
		floordrop = false;

		map->Read(ML_TEXTMAP, buffer);
		sc.OpenMem(Wads.GetLumpFullName(map->lumpnum), buffer, map->Size(ML_TEXTMAP));
		delete [] buffer;
		sc.SetCMode(true);
		if (sc.CheckString("namespace"))
		{
			sc.MustGetStringName("=");
			sc.MustGetString();
			namespc = sc.String;
			switch(namespc)
			{
			case NAME_ZDoom:
				namespace_bits = Zd;
				isTranslated = false;
				break;
			case NAME_ZDoomTranslated:
				level.flags2 |= LEVEL2_DUMMYSWITCHES;
				namespace_bits = Zdt;
				break;
			case NAME_Vavoom:
				namespace_bits = Va;
				isTranslated = false;
				break;
			case NAME_Hexen:
				namespace_bits = Hx;
				isTranslated = false;
				break;
			case NAME_Doom:
				namespace_bits = Dm;
				P_LoadTranslator("xlat/doom_base.txt");
				level.flags2 |= LEVEL2_DUMMYSWITCHES;
				floordrop = true;
				break;
			case NAME_Heretic:
				namespace_bits = Ht;
				P_LoadTranslator("xlat/heretic_base.txt");
				level.flags2 |= LEVEL2_DUMMYSWITCHES;
				floordrop = true;
				break;
			case NAME_Strife:
				namespace_bits = St;
				P_LoadTranslator("xlat/strife_base.txt");
				level.flags2 |= LEVEL2_DUMMYSWITCHES|LEVEL2_RAILINGHACK;
				floordrop = true;
				break;
			default:
				Printf("Unknown namespace %s. Using defaults for %s\n", sc.String, GameTypeName());
				switch (gameinfo.gametype)
				{
				default:			// Shh, GCC
				case GAME_Doom:
				case GAME_Chex:
					namespace_bits = Dm;
					P_LoadTranslator("xlat/doom_base.txt");
					break;
				case GAME_Heretic:
					namespace_bits = Ht;
					P_LoadTranslator("xlat/heretic_base.txt");
					break;
				case GAME_Strife:
					namespace_bits = St;
					P_LoadTranslator("xlat/strife_base.txt");
					break;
				case GAME_Hexen:
					namespace_bits = Hx;
					isTranslated = false;
					break;
				}
			}
			sc.MustGetStringName(";");
		}
		else
		{
			Printf("Map does not define a namespace.\n");
		}

		while (sc.GetString())
		{
			if (sc.Compare("thing"))
			{
				FMapThing th;
				unsigned userdatastart = MapThingsUserData.Size();
				ParseThing(&th);
				MapThingsConverted.Push(th);
				if (userdatastart < MapThingsUserData.Size())
				{ // User data added
					MapThingsUserDataIndex[MapThingsConverted.Size()-1] = userdatastart;
					// Mark end of the user data for this map thing
					FMapThingUserData ud;
					ud.Property = NAME_None;
					ud.Value = 0;
					MapThingsUserData.Push(ud);
				}
			}
			else if (sc.Compare("linedef"))
			{
				line_t li;
				ParseLinedef(&li, ParsedLines.Size());
				ParsedLines.Push(li);
			}
			else if (sc.Compare("sidedef"))
			{
				side_t si;
				intmapsidedef_t st;
				ParseSidedef(&si, &st, ParsedSides.Size());
				ParsedSides.Push(si);
				ParsedSideTextures.Push(st);
			}
			else if (sc.Compare("sector"))
			{
				sector_t sec;
				ParseSector(&sec, ParsedSectors.Size());
				ParsedSectors.Push(sec);
			}
			else if (sc.Compare("vertex"))
			{
				vertex_t vt;
				vertexdata_t vd;
				ParseVertex(&vt, &vd);
				ParsedVertices.Push(vt);
				ParsedVertexDatas.Push(vd);
			}
			else
			{
				Skip();
			}
		}

		// Catch bogus maps here rather than during nodebuilding
		if (ParsedVertices.Size() == 0)	I_Error("Map has no vertices.\n");
		if (ParsedSectors.Size() == 0)	I_Error("Map has no sectors. \n");
		if (ParsedLines.Size() == 0)	I_Error("Map has no linedefs.\n");
		if (ParsedSides.Size() == 0)	I_Error("Map has no sidedefs.\n");

		// Create the real vertices
		numvertexes = ParsedVertices.Size();
		vertexes = new vertex_t[numvertexes];
		memcpy(vertexes, &ParsedVertices[0], numvertexes * sizeof(*vertexes));

		// Create the real vertex datas
		numvertexdatas = ParsedVertexDatas.Size();
		vertexdatas = new vertexdata_t[numvertexdatas];
		memcpy(vertexdatas, &ParsedVertexDatas[0], numvertexdatas * sizeof(*vertexdatas));

		// Create the real sectors
		numsectors = ParsedSectors.Size();
		sectors = new sector_t[numsectors];
		memcpy(sectors, &ParsedSectors[0], numsectors * sizeof(*sectors));
		sectors[0].e = new extsector_t[numsectors];
		for(int i = 0; i < numsectors; i++)
		{
			sectors[i].e = &sectors[0].e[i];
		}

		// Create the real linedefs and decompress the sidedefs
		ProcessLineDefs();
	}
コード例 #25
0
ファイル: in_lude.c プロジェクト: MP2E/chocolate-doom
static void InitStats(void)
{
    int i;
    int j;
    int oldCluster;
    signed int slaughterfrags;
    int posnum;
    int slaughtercount;
    int playercount;
    char *msgLumpName;
    int msgSize;
    int msgLump;

    extern int LeaveMap;

    if (!deathmatch)
    {
        gametype = SINGLE;
        HubCount = 0;
        oldCluster = P_GetMapCluster(gamemap);
        if (oldCluster != P_GetMapCluster(LeaveMap))
        {
            if (oldCluster >= 1 && oldCluster <= 5)
            {
                msgLumpName = ClusMsgLumpNames[oldCluster - 1];
                msgLump = W_GetNumForName(msgLumpName);
                msgSize = W_LumpLength(msgLump);
                if (msgSize >= MAX_INTRMSN_MESSAGE_SIZE)
                {
                    I_Error("Cluster message too long (%s)", msgLumpName);
                }
                W_ReadLump(msgLump, ClusterMessage);
                ClusterMessage[msgSize] = 0;    // Append terminator
                HubText = ClusterMessage;
                HubCount = strlen(HubText) * TEXTSPEED + TEXTWAIT;
                S_StartSongName("hub", true);
            }
        }
    }
    else
    {
        gametype = DEATHMATCH;
        slaughterboy = 0;
        slaughterfrags = -9999;
        posnum = 0;
        playercount = 0;
        slaughtercount = 0;
        for (i = 0; i < MAXPLAYERS; i++)
        {
            totalFrags[i] = 0;
            if (playeringame[i])
            {
                playercount++;
                for (j = 0; j < MAXPLAYERS; j++)
                {
                    if (playeringame[j])
                    {
                        totalFrags[i] += players[i].frags[j];
                    }
                }
                posnum++;
            }
            if (totalFrags[i] > slaughterfrags)
            {
                slaughterboy = 1 << i;
                slaughterfrags = totalFrags[i];
                slaughtercount = 1;
            }
            else if (totalFrags[i] == slaughterfrags)
            {
                slaughterboy |= 1 << i;
                slaughtercount++;
            }
        }
        if (playercount == slaughtercount)
        {                       // don't do the slaughter stuff if everyone is equal
            slaughterboy = 0;
        }
        S_StartSongName("hub", true);
    }
}
コード例 #26
0
ファイル: d_client.c プロジェクト: DrBeef/DVR
void D_InitNetGame (void)
{
  int i;
  int numplayers = 1;

  i = M_CheckParm("-net");
  if (i && i < myargc-1) i++;

  if (!(netgame = server =  !!i)) {
    playeringame[consoleplayer = 0] = true;
    // e6y
    // for play, recording or playback using "single-player coop" mode.
    // Equivalent to using prboom_server with -N 1
    netgame = M_CheckParm("-solo-net");
  } else {
    // Get game info from server
    packet_header_t *packet = Z_Malloc(1000, PU_STATIC, NULL);
    struct setup_packet_s *sinfo = (void*)(packet+1);
  struct { packet_header_t head; short pn; } PACKEDATTR initpacket;

    I_InitNetwork();
  udp_socket = I_Socket(0);
  I_ConnectToServer(myargv[i]);

    do
    {
      do { 
	// Send init packet
	initpacket.pn = doom_htons(wanted_player_number);
	packet_set(&initpacket.head, PKT_INIT, 0);
	I_SendPacket(&initpacket.head, sizeof(initpacket));
	I_WaitForPacket(5000);
      } while (!I_GetPacket(packet, 1000));
      if (packet->type == PKT_DOWN) I_Error("Server aborted the game");
    } while (packet->type != PKT_SETUP);

    // Once we have been accepted by the server, we should tell it when we leave
    atexit(D_QuitNetGame);

    // Get info from the setup packet
    consoleplayer = sinfo->yourplayer;
    compatibility_level = sinfo->complevel;
    G_Compatibility();
    startskill = sinfo->skill;
    deathmatch = sinfo->deathmatch;
    startmap = sinfo->level;
    startepisode = sinfo->episode;
    ticdup = sinfo->ticdup;
    xtratics = sinfo->extratic;
    G_ReadOptions(sinfo->game_options);

    lprintf(LO_INFO, "\tjoined game as player %d/%d; %d WADs specified\n",
      consoleplayer+1, numplayers = sinfo->players, sinfo->numwads);
    {
      char *p = sinfo->wadnames;
      int i = sinfo->numwads;

      while (i--) {
#ifdef USE_ANDROID
    	  char tmp[80];
    	  strcpy(tmp, doomWADDir);
    	  strcat(tmp, "/");
    	  strcat(tmp, p);
  D_AddFile(tmp, source_net);
#else
  D_AddFile(p, source_net);
#endif
  p += strlen(p) + 1;
      }
    }
    Z_Free(packet);
  }
  localcmds = netcmds[displayplayer = consoleplayer];
  for (i=0; i<numplayers; i++)
    playeringame[i] = true;
  for (; i<MAXPLAYERS; i++)
    playeringame[i] = false;
  if (!playeringame[consoleplayer]) I_Error("D_InitNetGame: consoleplayer not in game");
}
コード例 #27
0
ファイル: d_main.c プロジェクト: 1833183060/DOOM
//
// D_DoomMain
//
void D_DoomMain (void)
{
    int             p;
    char                    file[256];

    FindResponseFile ();
	
    IdentifyVersion ();
	
    setbuf (stdout, NULL);
    modifiedgame = false;
	
    nomonsters = M_CheckParm ("-nomonsters");
    respawnparm = M_CheckParm ("-respawn");
    fastparm = M_CheckParm ("-fast");
    devparm = M_CheckParm ("-devparm");
    if (M_CheckParm ("-altdeath"))
	deathmatch = 2;
    else if (M_CheckParm ("-deathmatch"))
	deathmatch = 1;

    switch ( gamemode )
    {
      case retail:
	sprintf (title,
		 "                         "
		 "The Ultimate DOOM Startup v%i.%i"
		 "                           ",
		 VERSION/100,VERSION%100);
	break;
      case shareware:
	sprintf (title,
		 "                            "
		 "DOOM Shareware Startup v%i.%i"
		 "                           ",
		 VERSION/100,VERSION%100);
	break;
      case registered:
	sprintf (title,
		 "                            "
		 "DOOM Registered Startup v%i.%i"
		 "                           ",
		 VERSION/100,VERSION%100);
	break;
      case commercial:
	sprintf (title,
		 "                         "
		 "DOOM 2: Hell on Earth v%i.%i"
		 "                           ",
		 VERSION/100,VERSION%100);
	break;
/*FIXME
       case pack_plut:
	sprintf (title,
		 "                   "
		 "DOOM 2: Plutonia Experiment v%i.%i"
		 "                           ",
		 VERSION/100,VERSION%100);
	break;
      case pack_tnt:
	sprintf (title,
		 "                     "
		 "DOOM 2: TNT - Evilution v%i.%i"
		 "                           ",
		 VERSION/100,VERSION%100);
	break;
*/
      default:
	sprintf (title,
		 "                     "
		 "Public DOOM - v%i.%i"
		 "                           ",
		 VERSION/100,VERSION%100);
	break;
    }
    
    printf ("%s\n",title);

    if (devparm)
	printf(D_DEVSTR);
    
    if (M_CheckParm("-cdrom"))
    {
	printf(D_CDROM);
	mkdir("c:\\doomdata",0);
	strcpy (basedefault,"c:/doomdata/default.cfg");
    }	
    
    // turbo option
    if ( (p=M_CheckParm ("-turbo")) )
    {
	int     scale = 200;
	extern int forwardmove[2];
	extern int sidemove[2];
	
	if (p<myargc-1)
	    scale = atoi (myargv[p+1]);
	if (scale < 10)
	    scale = 10;
	if (scale > 400)
	    scale = 400;
	printf ("turbo scale: %i%%\n",scale);
	forwardmove[0] = forwardmove[0]*scale/100;
	forwardmove[1] = forwardmove[1]*scale/100;
	sidemove[0] = sidemove[0]*scale/100;
	sidemove[1] = sidemove[1]*scale/100;
    }
    
    // add any files specified on the command line with -file wadfile
    // to the wad list
    //
    // convenience hack to allow -wart e m to add a wad file
    // prepend a tilde to the filename so wadfile will be reloadable
    p = M_CheckParm ("-wart");
    if (p)
    {
	myargv[p][4] = 'p';     // big hack, change to -warp

	// Map name handling.
	switch (gamemode )
	{
	  case shareware:
	  case retail:
	  case registered:
	    sprintf (file,"~"DEVMAPS"E%cM%c.wad",
		     myargv[p+1][0], myargv[p+2][0]);
	    printf("Warping to Episode %s, Map %s.\n",
		   myargv[p+1],myargv[p+2]);
	    break;
	    
	  case commercial:
	  default:
	    p = atoi (myargv[p+1]);
	    if (p<10)
	      sprintf (file,"~"DEVMAPS"cdata/map0%i.wad", p);
	    else
	      sprintf (file,"~"DEVMAPS"cdata/map%i.wad", p);
	    break;
	}
	D_AddFile (file);
    }
	
    p = M_CheckParm ("-file");
    if (p)
    {
	// the parms after p are wadfile/lump names,
	// until end of parms or another - preceded parm
	modifiedgame = true;            // homebrew levels
	while (++p != myargc && myargv[p][0] != '-')
	    D_AddFile (myargv[p]);
    }

    p = M_CheckParm ("-playdemo");

    if (!p)
	p = M_CheckParm ("-timedemo");

    if (p && p < myargc-1)
    {
	sprintf (file,"%s.lmp", myargv[p+1]);
	D_AddFile (file);
	printf("Playing demo %s.lmp.\n",myargv[p+1]);
    }
    
    // get skill / episode / map from parms
    startskill = sk_medium;
    startepisode = 1;
    startmap = 1;
    autostart = false;

		
    p = M_CheckParm ("-skill");
    if (p && p < myargc-1)
    {
	startskill = myargv[p+1][0]-'1';
	autostart = true;
    }

    p = M_CheckParm ("-episode");
    if (p && p < myargc-1)
    {
	startepisode = myargv[p+1][0]-'0';
	startmap = 1;
	autostart = true;
    }
	
    p = M_CheckParm ("-timer");
    if (p && p < myargc-1 && deathmatch)
    {
	int     time;
	time = atoi(myargv[p+1]);
	printf("Levels will end after %d minute",time);
	if (time>1)
	    printf("s");
	printf(".\n");
    }

    p = M_CheckParm ("-avg");
    if (p && p < myargc-1 && deathmatch)
	printf("Austin Virtual Gaming: Levels will end after 20 minutes\n");

    p = M_CheckParm ("-warp");
    if (p && p < myargc-1)
    {
	if (gamemode == commercial)
	    startmap = atoi (myargv[p+1]);
	else
	{
	    startepisode = myargv[p+1][0]-'0';
	    startmap = myargv[p+2][0]-'0';
	}
	autostart = true;
    }
    
    // init subsystems
    printf ("V_Init: allocate screens.\n");
    V_Init ();

    printf ("M_LoadDefaults: Load system defaults.\n");
    M_LoadDefaults ();              // load before initing other systems

    printf ("Z_Init: Init zone memory allocation daemon. \n");
    Z_Init ();

    printf ("W_Init: Init WADfiles.\n");
    W_InitMultipleFiles (wadfiles);
    

    // Check for -file in shareware
    if (modifiedgame)
    {
	// These are the lumps that will be checked in IWAD,
	// if any one is not present, execution will be aborted.
	char name[23][8]=
	{
	    "e2m1","e2m2","e2m3","e2m4","e2m5","e2m6","e2m7","e2m8","e2m9",
	    "e3m1","e3m3","e3m3","e3m4","e3m5","e3m6","e3m7","e3m8","e3m9",
	    "dphoof","bfgga0","heada1","cybra1","spida1d1"
	};
	int i;
	
	if ( gamemode == shareware)
	    I_Error("\nYou cannot -file with the shareware "
		    "version. Register!");

	// Check for fake IWAD with right name,
	// but w/o all the lumps of the registered version. 
	if (gamemode == registered)
	    for (i = 0;i < 23; i++)
		if (W_CheckNumForName(name[i])<0)
		    I_Error("\nThis is not the registered version.");
    }
    
    // Iff additonal PWAD files are used, print modified banner
    if (modifiedgame)
    {
	/*m*/printf (
	    "===========================================================================\n"
	    "ATTENTION:  This version of DOOM has been modified.  If you would like to\n"
	    "get a copy of the original game, call 1-800-IDGAMES or see the readme file.\n"
	    "        You will not receive technical support for modified games.\n"
	    "                      press enter to continue\n"
	    "===========================================================================\n"
	    );
	getchar ();
    }
	

    // Check and print which version is executed.
    switch ( gamemode )
    {
      case shareware:
      case indetermined:
	printf (
	    "===========================================================================\n"
	    "                                Shareware!\n"
	    "===========================================================================\n"
	);
	break;
      case registered:
      case retail:
      case commercial:
	printf (
	    "===========================================================================\n"
	    "                 Commercial product - do not distribute!\n"
	    "         Please report software piracy to the SPA: 1-800-388-PIR8\n"
	    "===========================================================================\n"
	);
	break;
	
      default:
	// Ouch.
	break;
    }

    printf ("M_Init: Init miscellaneous info.\n");
    M_Init ();

    printf ("R_Init: Init DOOM refresh daemon - ");
    R_Init ();

    printf ("\nP_Init: Init Playloop state.\n");
    P_Init ();

    printf ("I_Init: Setting up machine state.\n");
    I_Init ();

    printf ("D_CheckNetGame: Checking network game status.\n");
    D_CheckNetGame ();

    printf ("S_Init: Setting up sound.\n");
    S_Init (snd_SfxVolume /* *8 */, snd_MusicVolume /* *8*/ );

    printf ("HU_Init: Setting up heads up display.\n");
    HU_Init ();

    printf ("ST_Init: Init status bar.\n");
    ST_Init ();

    // check for a driver that wants intermission stats
    p = M_CheckParm ("-statcopy");
    if (p && p<myargc-1)
    {
	// for statistics driver
	extern  void*	statcopy;                            

	statcopy = (void*)atoi(myargv[p+1]);
	printf ("External statistics registered.\n");
    }
    
    // start the apropriate game based on parms
    p = M_CheckParm ("-record");

    if (p && p < myargc-1)
    {
	G_RecordDemo (myargv[p+1]);
	autostart = true;
    }
	
    p = M_CheckParm ("-playdemo");
    if (p && p < myargc-1)
    {
	singledemo = true;              // quit after one demo
	G_DeferedPlayDemo (myargv[p+1]);
	D_DoomLoop ();  // never returns
    }
	
    p = M_CheckParm ("-timedemo");
    if (p && p < myargc-1)
    {
	G_TimeDemo (myargv[p+1]);
	D_DoomLoop ();  // never returns
    }
	
    p = M_CheckParm ("-loadgame");
    if (p && p < myargc-1)
    {
	if (M_CheckParm("-cdrom"))
	    sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
	else
	    sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
	G_LoadGame (file);
    }
	

    if ( gameaction != ga_loadgame )
    {
	if (autostart || netgame)
	    G_InitNew (startskill, startepisode, startmap);
	else
	    D_StartTitle ();                // start up intro loop

    }

    D_DoomLoop ();  // never returns
}
コード例 #28
0
ファイル: g_game.c プロジェクト: ProfessorKaos64/Doom64EX
void G_Ticker(void) {
    int         i;
    int         buf;
    ticcmd_t*   cmd;

    G_ActionTicker();
    CON_Ticker();

    if(savenow) {
        G_DoSaveGame();
        savenow = false;
    }

    if(gameaction == ga_screenshot) {
        M_ScreenShot();
        gameaction = ga_nothing;
    }

    if(paused & 2 || (!demoplayback && menuactive && !netgame)) {
        basetic++;    // For tracers and RNG -- we must maintain sync
    }
    else {
        // get commands, check consistency,
        // and build new consistency check
        buf = (gametic / ticdup) % BACKUPTICS;

        for(i = 0; i < MAXPLAYERS; i++) {
            if(playeringame[i]) {
                cmd = &players[i].cmd;

                dmemcpy(cmd, &netcmds[i][buf], sizeof(ticcmd_t));

                //
                // 20120404 villsa - make sure gameaction isn't set to anything before
                // reading a demo lump
                //
                if(demoplayback && gameaction == ga_nothing) {
                    G_ReadDemoTiccmd(cmd);
                }

                if(demorecording) {
                    G_WriteDemoTiccmd(cmd);

                    if(endDemo == true) {
                        G_CheckDemoStatus();
                    }
                }

                if(netgame && !netdemo && !(gametic % ticdup)) {
                    if(gametic > BACKUPTICS
                            && consistency[i][buf] != cmd->consistency) {
                        I_Error("consistency failure (%i should be %i)",
                                cmd->consistency, consistency[i][buf], consoleplayer);
                    }
                    if(players[i].mo) {
                        consistency[i][buf] = players[i].mo->x;
                    }
                    else {
                        consistency[i][buf] = 0;
                    }
                }
            }
        }
    }

    // check for special buttons
    for(i = 0; i < MAXPLAYERS; i++) {
        if(playeringame[i]) {
            if(players[i].cmd.buttons & BT_SPECIAL) {
                /*villsa - fixed crash when player restarts level after dying
                    Changed switch statments to if statments*/
                if((players[i].cmd.buttons & BT_SPECIALMASK) == BTS_PAUSE) {
                    paused ^= 1;
                    if(paused) {
                        S_PauseSound();
                    }
                    else {
                        S_ResumeSound();
                    }
                }

                if((players[i].cmd.buttons & BT_SPECIALMASK) == BTS_SAVEGAME) {
                    if(!savedescription[0]) {
                        dstrcpy(savedescription, "NET GAME");
                    }
                    savegameslot =
                        (players[i].cmd.buttons & BTS_SAVEMASK)>>BTS_SAVESHIFT;
                    savenow = true;
                }
            }
        }
    }
}
コード例 #29
0
ファイル: w_wad.c プロジェクト: Fellowzdoomer/crispy-doom
wad_file_t *W_AddFile (char *filename)
{
    wadinfo_t header;
    lumpindex_t i;
    wad_file_t *wad_file;
    int length;
    int startlump;
    filelump_t *fileinfo;
    filelump_t *filerover;
    lumpinfo_t *filelumps;
    int numfilelumps;

    // If the filename begins with a ~, it indicates that we should use the
    // reload hack.
    if (filename[0] == '~')
    {
        if (reloadname != NULL)
        {
            I_Error("Prefixing a WAD filename with '~' indicates that the "
                    "WAD should be reloaded\n"
                    "on each level restart, for use by level authors for "
                    "rapid development. You\n"
                    "can only reload one WAD file, and it must be the last "
                    "file in the -file list.");
        }

        reloadname = strdup(filename);
        reloadlump = numlumps;
        ++filename;
    }

    // Open the file and add to directory
    wad_file = W_OpenFile(filename);

    if (wad_file == NULL)
    {
	printf (" couldn't open %s\n", filename);
	return NULL;
    }

    // [crispy] save the file name
    wad_file->path = M_BaseName(filename);

    if (strcasecmp(filename+strlen(filename)-3 , "wad" ) )
    {
	// single lump file

        // fraggle: Swap the filepos and size here.  The WAD directory
        // parsing code expects a little-endian directory, so will swap
        // them back.  Effectively we're constructing a "fake WAD directory"
        // here, as it would appear on disk.

	fileinfo = Z_Malloc(sizeof(filelump_t), PU_STATIC, 0);
	fileinfo->filepos = LONG(0);
	fileinfo->size = LONG(wad_file->length);

        // Name the lump after the base of the filename (without the
        // extension).

	M_ExtractFileBase (filename, fileinfo->name);
	numfilelumps = 1;
    }
    else
    {
	// WAD file
        W_Read(wad_file, 0, &header, sizeof(header));

	if (strncmp(header.identification,"IWAD",4))
	{
	    // Homebrew levels?
	    if (strncmp(header.identification,"PWAD",4))
	    {
		I_Error ("Wad file %s doesn't have IWAD "
			 "or PWAD id\n", filename);
	    }

	    // ???modifiedgame = true;
	}

	header.numlumps = LONG(header.numlumps);
	header.infotableofs = LONG(header.infotableofs);
	length = header.numlumps*sizeof(filelump_t);
	fileinfo = Z_Malloc(length, PU_STATIC, 0);

        W_Read(wad_file, header.infotableofs, fileinfo, length);
	numfilelumps = header.numlumps;
    }

    // Increase size of numlumps array to accomodate the new file.
    filelumps = calloc(numfilelumps, sizeof(lumpinfo_t));
    if (filelumps == NULL)
    {
        I_Error("Failed to allocate array for lumps from new file.");
    }

    startlump = numlumps;
    numlumps += numfilelumps;
    lumpinfo = realloc(lumpinfo, numlumps * sizeof(lumpinfo_t *));
    if (lumpinfo == NULL)
    {
        I_Error("Failed to increase lumpinfo[] array size.");
    }

    filerover = fileinfo;

    for (i = startlump; i < numlumps; ++i)
    {
        lumpinfo_t *lump_p = &filelumps[i - startlump];
        lump_p->wad_file = wad_file;
        lump_p->position = LONG(filerover->filepos);
        lump_p->size = LONG(filerover->size);
        lump_p->cache = NULL;
        strncpy(lump_p->name, filerover->name, 8);
        lumpinfo[i] = lump_p;

        ++filerover;
    }

    Z_Free(fileinfo);

    if (lumphash != NULL)
    {
        Z_Free(lumphash);
        lumphash = NULL;
    }

    // If this is the reload file, we need to save some details about the
    // file so that we can close it later on when we do a reload.
    if (reloadname)
    {
        reloadhandle = wad_file;
        reloadlumps = filelumps;
    }

    return wad_file;
}
コード例 #30
0
ファイル: r_bsp.c プロジェクト: DrBeef/DVR
static void R_Subsector(int num)
{
  int         count;
  seg_t       *line;
  subsector_t *sub;
  sector_t    tempsec;              // killough 3/7/98: deep water hack
  int         floorlightlevel;      // killough 3/16/98: set floor lightlevel
  int         ceilinglightlevel;    // killough 4/11/98
#ifdef GL_DOOM
  visplane_t dummyfloorplane;
  visplane_t dummyceilingplane;
#endif

#ifdef RANGECHECK
  if (num>=numsubsectors)
    I_Error ("R_Subsector: ss %i with numss = %i", num, numsubsectors);
#endif

  sub = &subsectors[num];
  frontsector = sub->sector;
  count = sub->numlines;
  line = &segs[sub->firstline];

  // killough 3/8/98, 4/4/98: Deep water / fake ceiling effect
  frontsector = R_FakeFlat(frontsector, &tempsec, &floorlightlevel,
                           &ceilinglightlevel, false);   // killough 4/11/98

  // killough 3/7/98: Add (x,y) offsets to flats, add deep water check
  // killough 3/16/98: add floorlightlevel
  // killough 10/98: add support for skies transferred from sidedefs

  floorplane = frontsector->floorheight < viewz || // killough 3/7/98
    (frontsector->heightsec != -1 &&
     sectors[frontsector->heightsec].ceilingpic == skyflatnum) ?
    R_FindPlane(frontsector->floorheight,
                frontsector->floorpic == skyflatnum &&  // kilough 10/98
                frontsector->sky & PL_SKYFLAT ? frontsector->sky :
                frontsector->floorpic,
                floorlightlevel,                // killough 3/16/98
                frontsector->floor_xoffs,       // killough 3/7/98
                frontsector->floor_yoffs
                ) : NULL;

  ceilingplane = frontsector->ceilingheight > viewz ||
    frontsector->ceilingpic == skyflatnum ||
    (frontsector->heightsec != -1 &&
     sectors[frontsector->heightsec].floorpic == skyflatnum) ?
    R_FindPlane(frontsector->ceilingheight,     // killough 3/8/98
                frontsector->ceilingpic == skyflatnum &&  // kilough 10/98
                frontsector->sky & PL_SKYFLAT ? frontsector->sky :
                frontsector->ceilingpic,
                ceilinglightlevel,              // killough 4/11/98
                frontsector->ceiling_xoffs,     // killough 3/7/98
                frontsector->ceiling_yoffs
                ) : NULL;
#ifdef GL_DOOM
  // check if the sector is faked
  if ((frontsector==sub->sector)  && (V_GetMode() == VID_MODEGL))
  {
    // if the sector has bottomtextures, then the floorheight will be set to the
    // highest surounding floorheight
    if ((frontsector->no_bottomtextures) || (!floorplane))
    {
      int i=frontsector->linecount;

      dummyfloorplane.height=INT_MIN;
      while (i--)
      {
        line_t *tmpline=frontsector->lines[i];
        if (tmpline->backsector)
          if (tmpline->backsector != frontsector)
            if (tmpline->backsector->floorheight>dummyfloorplane.height)
            {
              dummyfloorplane.height=tmpline->backsector->floorheight;
              dummyfloorplane.lightlevel=tmpline->backsector->lightlevel;
            }
        if (tmpline->frontsector)
          if (tmpline->frontsector != frontsector)
            if (tmpline->frontsector->floorheight>dummyfloorplane.height)
            {
              dummyfloorplane.height=tmpline->frontsector->floorheight;
              dummyfloorplane.lightlevel=tmpline->frontsector->lightlevel;
            }
      }
      if (dummyfloorplane.height!=INT_MIN)
        floorplane=&dummyfloorplane;
    }
    // the same for ceilings. they will be set to the lowest ceilingheight
    if ((frontsector->no_toptextures) || (!ceilingplane))
    {
      int i=frontsector->linecount;

      dummyceilingplane.height=INT_MAX;
      while (i--)
      {
        line_t *tmpline=frontsector->lines[i];
        if (tmpline->backsector)
          if (tmpline->backsector != frontsector)
            if (tmpline->backsector->ceilingheight<dummyceilingplane.height)
            {
              dummyceilingplane.height=tmpline->backsector->ceilingheight;
              dummyceilingplane.lightlevel=tmpline->backsector->lightlevel;
            }
        if (tmpline->frontsector)
          if (tmpline->frontsector != frontsector)
            if (tmpline->frontsector->ceilingheight<dummyceilingplane.height)
            {
              dummyceilingplane.height=tmpline->frontsector->ceilingheight;
              dummyceilingplane.lightlevel=tmpline->frontsector->lightlevel;
            }
      }
      if (dummyceilingplane.height!=INT_MAX)
        ceilingplane=&dummyceilingplane;
    }
  }
#endif

  // killough 9/18/98: Fix underwater slowdown, by passing real sector
  // instead of fake one. Improve sprite lighting by basing sprite
  // lightlevels on floor & ceiling lightlevels in the surrounding area.
  //
  // 10/98 killough:
  //
  // NOTE: TeamTNT fixed this bug incorrectly, messing up sprite lighting!!!
  // That is part of the 242 effect!!!  If you simply pass sub->sector to
  // the old code you will not get correct lighting for underwater sprites!!!
  // Either you must pass the fake sector and handle validcount here, on the
  // real sector, or you must account for the lighting in some other way,
  // like passing it as an argument.

  R_AddSprites(sub, (floorlightlevel+ceilinglightlevel)/2);
  while (count--)
  {
    if (line->miniseg == false)
      R_AddLine (line);
    line++;
    curline = NULL; /* cph 2001/11/18 - must clear curline now we're done with it, so R_ColourMap doesn't try using it for other things */
  }
#ifdef GL_DOOM
  if (V_GetMode() == VID_MODEGL)
    gld_AddPlane(num, floorplane, ceilingplane);
#endif
}