예제 #1
0
파일: game.c 프로젝트: Almamu/doom3do
void G_RunGame(void)
{
	for (;;) {

	/* Run a level until death or completion */

		MiniLoop(P_Start,P_Stop,P_Ticker,P_Drawer);

	/* Take away cards and stuff */

		G_PlayerFinishLevel();
		if ((gameaction == ga_died) ||	/* died, so restart the level */
			(gameaction == ga_warped)) {	/* skip intermission */
			continue;
		}

	/* decide which level to go to next */

		if (gameaction == ga_secretexit) {
			 nextmap = 24;	/* Go to the secret level */
		} else {
			switch (gamemap) {
			case 24:		/* Secret level? */
				nextmap = 4;
				break;
			case 23:		/* Final level! */
				nextmap = 23;
				break;		/* Don't add secret level to prefs */
			default:
				nextmap = gamemap+1;
			}
			if (nextmap>MaxLevel) {
				MaxLevel = nextmap;	/* Save the prefs file */
				WritePrefsFile();
			}
		}

	/* Run a stats intermission */

		MiniLoop(IN_Start,IN_Stop,IN_Ticker,IN_Drawer);

	/* Run the finale if needed */

		if (gamemap == 23) {
			MiniLoop(F_Start,F_Stop,F_Ticker,F_Drawer);
			return;		/* Exit */
		}
		gamemap = nextmap;
	}
}
예제 #2
0
void G_DoCompleted(void)
{
    int i;
    static int afterSecret[5] = { 7, 5, 5, 5, 4 };

    gameaction = ga_nothing;

    // quit demo unless -demoextend
    if (!demoextend && G_CheckDemoStatus())
    {
        return;
    }
    for (i = 0; i < MAXPLAYERS; i++)
    {
        if (playeringame[i])
        {
            G_PlayerFinishLevel(i);
        }
    }
    prevmap = gamemap;
    if (secretexit == true)
    {
        gamemap = 9;
    }
    else if (gamemap == 9)
    {                           // Finished secret level
        gamemap = afterSecret[gameepisode - 1];
    }
    else if (gamemap == 8)
    {
        gameaction = ga_victory;
        return;
    }
    else
    {
        gamemap++;
    }
    gamestate = GS_INTERMISSION;
    IN_Start();
}
예제 #3
0
파일: g_game.c 프로젝트: Arc0re/jaguardoom
void G_RunGame (void)
{
	int		i;
	
	while (1)
	{
	/* load a level */
		G_DoLoadLevel ();   
	
	/* run a level until death or completion */
		MiniLoop (P_Start, P_Stop, P_Ticker, P_Drawer);
	
	/* take away cards and stuff */
			
		for (i=0 ; i<MAXPLAYERS ; i++) 
			if (playeringame[i]) 
				G_PlayerFinishLevel (i);	 

		if (gameaction == ga_died)
			continue;			/* died, so restart the level */
	
		if (gameaction == ga_warped)
			continue;			/* skip intermission */
					
	/* decide which level to go to next */
#ifdef MARS
		if (gameaction == ga_secretexit)
			nextmap = 24;
		else
		{
			switch (gamemap)
			{
			case 15: nextmap = 23; break;
			case 24: nextmap = 4; break;
			default: nextmap = gamemap+1; break;
			}
		}
#else
		if (gameaction == ga_secretexit)
		{
			 nextmap = 24;
		}
		else
		{
			switch (gamemap)
			{
			case 24: nextmap = 4; break;
			case 23: nextmap = 23; break;	/* don't add secret level to eeprom */
			default: nextmap = gamemap+1; break;
			}
#ifdef JAGUAR
			if (nextmap > maxlevel)
			{	/* allow higher menu selection now */
				void WriteEEProm (void);
				maxlevel = nextmap;
				WriteEEProm ();
			}
#endif

		}
#endif

	/* run a stats intermission */
		MiniLoop (IN_Start, IN_Stop, IN_Ticker, IN_Drawer);
	
	/* run the finale if needed */
		if (gamemap == 23)
			MiniLoop (F_Start, F_Stop, F_Ticker, F_Drawer);
			
		gamemap = nextmap;
	}
}
예제 #4
0
void G_DoCompleted (void)
{
	int i; 

	gameaction = ga_nothing;

	if (gamestate == GS_TITLELEVEL)
	{
		level.MapName = nextlevel;
		G_DoLoadLevel (startpos, false);
		startpos = 0;
		viewactive = true;
		return;
	}

	// [RH] Mark this level as having been visited
	if (!(level.flags & LEVEL_CHANGEMAPCHEAT))
		FindLevelInfo (level.MapName)->flags |= LEVEL_VISITED;

	if (automapactive)
		AM_Stop ();

	wminfo.finished_ep = level.cluster - 1;
	wminfo.LName0 = TexMan[TexMan.CheckForTexture(level.info->PName, FTexture::TEX_MiscPatch)];
	wminfo.current = level.MapName;

	if (deathmatch &&
		(dmflags & DF_SAME_LEVEL) &&
		!(level.flags & LEVEL_CHANGEMAPCHEAT))
	{
		wminfo.next = level.MapName;
		wminfo.LName1 = wminfo.LName0;
	}
	else
	{
		level_info_t *nextinfo = FindLevelInfo (nextlevel, false);
		if (nextinfo == NULL || strncmp (nextlevel, "enDSeQ", 6) == 0)
		{
			wminfo.next = nextlevel;
			wminfo.LName1 = NULL;
		}
		else
		{
			wminfo.next = nextinfo->MapName;
			wminfo.LName1 = TexMan[TexMan.CheckForTexture(nextinfo->PName, FTexture::TEX_MiscPatch)];
		}
	}

	CheckWarpTransMap (wminfo.next, true);
	nextlevel = wminfo.next;

	wminfo.next_ep = FindLevelInfo (wminfo.next)->cluster - 1;
	wminfo.maxkills = level.total_monsters;
	wminfo.maxitems = level.total_items;
	wminfo.maxsecret = level.total_secrets;
	wminfo.maxfrags = 0;
	wminfo.partime = TICRATE * level.partime;
	wminfo.sucktime = level.sucktime;
	wminfo.pnum = consoleplayer;
	wminfo.totaltime = level.totaltime;

	for (i=0 ; i<MAXPLAYERS ; i++)
	{
		wminfo.plyr[i].in = playeringame[i];
		wminfo.plyr[i].skills = players[i].killcount;
		wminfo.plyr[i].sitems = players[i].itemcount;
		wminfo.plyr[i].ssecret = players[i].secretcount;
		wminfo.plyr[i].stime = level.time;
		memcpy (wminfo.plyr[i].frags, players[i].frags
				, sizeof(wminfo.plyr[i].frags));
		wminfo.plyr[i].fragcount = players[i].fragcount;
	}

	// [RH] If we're in a hub and staying within that hub, take a snapshot
	//		of the level. If we're traveling to a new hub, take stuff from
	//		the player and clear the world vars. If this is just an
	//		ordinary cluster (not a hub), take stuff from the player, but
	//		leave the world vars alone.
	cluster_info_t *thiscluster = FindClusterInfo (level.cluster);
	cluster_info_t *nextcluster = FindClusterInfo (wminfo.next_ep+1);	// next_ep is cluster-1
	EFinishLevelType mode;

	if (thiscluster != nextcluster || deathmatch ||
		!(thiscluster->flags & CLUSTER_HUB))
	{
		if (nextcluster->flags & CLUSTER_HUB)
		{
			mode = FINISH_NextHub;
		}
		else
		{
			mode = FINISH_NoHub;
		}
	}
	else
	{
		mode = FINISH_SameHub;
	}

	// Intermission stats for entire hubs
	G_LeavingHub(mode, thiscluster, &wminfo);

	for (i = 0; i < MAXPLAYERS; i++)
	{
		if (playeringame[i])
		{ // take away appropriate inventory
			G_PlayerFinishLevel (i, mode, changeflags);
		}
	}

	if (mode == FINISH_SameHub)
	{ // Remember the level's state for re-entry.
		if (!(level.flags2 & LEVEL2_FORGETSTATE))
		{
			G_SnapshotLevel ();
			// Do not free any global strings this level might reference
			// while it's not loaded.
			FBehavior::StaticLockLevelVarStrings();
		}
		else
		{ // Make sure we don't have a snapshot lying around from before.
			level.info->ClearSnapshot();
		}
	}
	else
	{ // Forget the states of all existing levels.
		G_ClearSnapshots ();

		if (mode == FINISH_NextHub)
		{ // Reset world variables for the new hub.
			P_ClearACSVars(false);
		}
		level.time = 0;
		level.maptime = 0;
	}

	if (!deathmatch &&
		((level.flags & LEVEL_NOINTERMISSION) ||
		((nextcluster == thiscluster) && (thiscluster->flags & CLUSTER_HUB))))
	{
		G_WorldDone ();
		return;
	}

	gamestate = GS_INTERMISSION;
	viewactive = false;
	automapactive = false;

// [RH] If you ever get a statistics driver operational, adapt this.
//	if (statcopy)
//		memcpy (statcopy, &wminfo, sizeof(wminfo));

	WI_Start (&wminfo);
}
예제 #5
0
void P_Stop(void) {
    int i = 0;
    int action = gameaction;

    //
    // [d64] stop plasma buzz
    //
    S_StopSound(NULL, sfx_electric);

    for(i = 0; i < MAXPLAYERS; i++) {
        // take away cards and stuff
        if(playeringame[i]) {
            G_PlayerFinishLevel(i);
        }
    }

    // [kex] reset damage indicators
    if(p_damageindicator.value) {
        ST_ClearDamageMarkers();
    }

    // free level tags
    Z_FreeTags(PU_LEVEL, PU_PURGELEVEL-1);

    if(automapactive) {
        AM_Stop();
    }

    // music continues on exit if defined
    if(!P_GetMapInfo(gamemap)->contmusexit) {
        S_StopMusic();
    }

    // end iwad demo playback here
    if(demoplayback && iwadDemo) {
        demoplayback = false;
        iwadDemo = false;
    }

    // do wipe/melt effect
    if(gameaction != ga_loadgame) {
        if(r_wipe.value) {
            if(gameaction != ga_warpquick) {
                WIPE_MeltScreen();
            }
            else {
                S_StopMusic();
                WIPE_FadeScreen(8);
            }
        }
        else {
            if(gameaction == ga_warpquick) {
                S_StopMusic();
            }
        }
    }

    S_ResetSound();

    // action is warpquick only because the user
    // cancelled demo playback...
    // boot the user back to the title screen
    if(gameaction == ga_warpquick && demoplayback) {
        gameaction = ga_title;
        demoplayback = false;
    }
    else {
        gameaction = action;
    }
}