Esempio n. 1
0
void MN_ActivateMenu(void)
{
    if (MenuActive)
    {
        return;
    }
    if (paused)
    {
        S_ResumeSound();
    }
    MenuActive = true;
    FileMenuKeySteal = false;
    MenuTime = 0;
    CurrentMenu = &MainMenu;
    CurrentItPos = CurrentMenu->oldItPos;
    if (!netgame && !demoplayback)
    {
        paused = true;
    }
    S_StartSound(NULL, sfx_dorcls);
    slottextloaded = false;     //reload the slot text, when needed
}
Esempio n. 2
0
void G_InitNew (const char *mapname)
{
    size_t i;

    // [RH] Remove all particles
    R_ClearParticles ();

    for (i = 0; i < players.size(); i++)
    {
        players[i].mo = AActor::AActorPtr();
        players[i].camera = AActor::AActorPtr();
        players[i].attacker = AActor::AActorPtr();
    }

    if (!savegamerestore)
        G_ClearSnapshots ();

    // [RH] Mark all levels as not visited
    if (!savegamerestore)
    {
        for (i = 0; i < wadlevelinfos.size(); i++)
            wadlevelinfos[i].flags &= ~LEVEL_VISITED;

        for (i = 0; LevelInfos[i].mapname[0]; i++)
            LevelInfos[i].flags &= ~LEVEL_VISITED;
    }

    cvar_t::UnlatchCVars ();

    if (sv_skill > sk_nightmare)
        sv_skill.Set (sk_nightmare);
    else if (sv_skill < sk_baby)
        sv_skill.Set (sk_baby);

    cvar_t::UnlatchCVars ();

    if (paused)
    {
        paused = false;
        S_ResumeSound ();
    }

    // If were in chasecam mode, clear out // [Toke - fix]
    if ((consoleplayer().cheats & CF_CHASECAM))
    {
        consoleplayer().cheats &= ~CF_CHASECAM;
    }

    // [RH] If this map doesn't exist, bomb out
    if (W_CheckNumForName (mapname) == -1)
    {
        I_Error ("Could not find map %s\n", mapname);
    }

    if (sv_skill == sk_nightmare || sv_monstersrespawn)
        respawnmonsters = true;
    else
        respawnmonsters = false;

    bool wantFast = sv_fastmonsters || (sv_skill == sk_nightmare);
    if (wantFast != isFast)
    {
        if (wantFast)
        {
            for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++)
                states[i].tics >>= 1;
            mobjinfo[MT_BRUISERSHOT].speed = 20*FRACUNIT;
            mobjinfo[MT_HEADSHOT].speed = 20*FRACUNIT;
            mobjinfo[MT_TROOPSHOT].speed = 20*FRACUNIT;
        }
        else
        {
            for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++)
                states[i].tics <<= 1;
            mobjinfo[MT_BRUISERSHOT].speed = 15*FRACUNIT;
            mobjinfo[MT_HEADSHOT].speed = 10*FRACUNIT;
            mobjinfo[MT_TROOPSHOT].speed = 10*FRACUNIT;
        }
        isFast = wantFast;
    }
Esempio n. 3
0
void G_Ticker (void)
{
	int 		buf;
	gamestate_t	oldgamestate;
	size_t i;

	// Run client tics;
	CL_RunTics ();

	// do player reborns if needed
	if(serverside)
		for (i = 0; i < players.size(); i++)
			if (players[i].ingame() && players[i].playerstate == PST_REBORN)
				G_DoReborn (players[i]);

	// do things to change the game state
	oldgamestate = gamestate;
	while (gameaction != ga_nothing)
	{
		switch (gameaction)
		{
		case ga_loadlevel:
			G_DoLoadLevel (-1);
			break;
		case ga_newgame:
			G_DoNewGame ();
			break;
		case ga_loadgame:
			gameaction = ga_nothing;
			break;
		case ga_savegame:
			gameaction = ga_nothing;
			break;
		case ga_playdemo:
			G_DoPlayDemo ();
			break;
		case ga_completed:
			G_DoCompleted ();
			break;
		case ga_victory:
		    gameaction = ga_nothing;
			break;
		case ga_worlddone:
			G_DoWorldDone ();
			break;
		case ga_screenshot:
			I_ScreenShot(shotfile.c_str());
			gameaction = ga_nothing;
			break;
		case ga_fullconsole:
			C_FullConsole ();
			gameaction = ga_nothing;
			break;
		case ga_nothing:
			break;
		}
		C_AdjustBottom ();
	}

    // get commands
    buf = gametic%BACKUPTICS;
	memcpy (&consoleplayer().cmd, &consoleplayer().netcmds[buf], sizeof(ticcmd_t));

    static int realrate = 0;
    int packet_size;

	if (demoplayback)
		G_ReadDemoTiccmd(); // play all player commands
	if (demorecording)
		G_WriteDemoTiccmd(); // read in all player commands

    if (connected)
    {
       while ((packet_size = NET_GetPacket()) )
       {
		   // denis - don't accept candy from strangers
		   if(!NET_CompareAdr(serveraddr, net_from))
			  break;

           realrate += packet_size;
		   last_received = gametic;
		   noservermsgs = false;

		   CL_ReadPacketHeader();
           CL_ParseCommands();

		   if (gameaction == ga_fullconsole) // Host_EndGame was called
			   return;
       }

       if (!(gametic%TICRATE))
       {
          netin = realrate;
          realrate = 0;
       }

       if (!noservermsgs)
		   CL_SendCmd();  // send console commands to the server

       CL_SaveCmd();      // save console commands

       if (!(gametic%TICRATE))
       {
           netout = outrate;
           outrate = 0;
       }

	   if (gametic - last_received > 65)
		   noservermsgs = true;
	}
	else if (NET_GetPacket() )
	{
		// denis - don't accept candy from strangers
		if((gamestate == GS_DOWNLOAD || gamestate == GS_CONNECTING)
			&& NET_CompareAdr(serveraddr, net_from))
		{
			int type = MSG_ReadLong();

			if(type == CHALLENGE)
			{
				CL_PrepareConnect();
			}
			else if(type == 0)
			{
				if (!CL_Connect())
					memset (&serveraddr, 0, sizeof(serveraddr));

				connecttimeout = 0;
			}
			else
			{
				// we are already connected to this server, quit first
				MSG_WriteMarker(&net_buffer, clc_disconnect);
				NET_SendPacket(net_buffer, serveraddr);
			}
		}
	}

	// check for special buttons
	if(serverside && consoleplayer().ingame())
    {
		player_t &player = consoleplayer();

		if (player.cmd.ucmd.buttons & BT_SPECIAL)
		{
			switch (player.cmd.ucmd.buttons & BT_SPECIALMASK)
			{
			  case BTS_PAUSE:
				paused ^= 1;
				if (paused)
					S_PauseSound ();
				else
					S_ResumeSound ();
				break;

			  case BTS_SAVEGAME:
				if (!savedescription[0])
					strcpy (savedescription, "NET GAME");
				savegameslot =  (player.cmd.ucmd.buttons & BTS_SAVEMASK)>>BTS_SAVESHIFT;
				gameaction = ga_savegame;
				break;
			}
		}
    }
Esempio n. 4
0
//
// P_Ticker
//
void P_Ticker (void)
{
	int i;

	interpolator.UpdateInterpolations ();
	r_NoInterpolate = true;

	if (!demoplayback)
	{
		// This is a separate slot from the wipe in D_Display(), because this
		// is delayed slightly due to latency. (Even on a singleplayer game!)
//		GSnd->SetSfxPaused(!!playerswiping, 2);
	}

	// run the tic
	if (paused || P_CheckTickerPaused())
		return;

	DPSprite::NewTick();

	// [RH] Frozen mode is only changed every 4 tics, to make it work with A_Tracer().
	if ((level.time & 3) == 0)
	{
		if (bglobal.changefreeze)
		{
			bglobal.freeze ^= 1;
			bglobal.changefreeze = 0;
		}
	}

	// [BC] Do a quick check to see if anyone has the freeze time power. If they do,
	// then don't resume the sound, since one of the effects of that power is to shut
	// off the music.
	for (i = 0; i < MAXPLAYERS; i++ )
	{
		if (playeringame[i] && players[i].timefreezer != 0)
			break;
	}

	if ( i == MAXPLAYERS )
		S_ResumeSound (false);

	P_ResetSightCounters (false);
	R_ClearInterpolationPath();

	// Since things will be moving, it's okay to interpolate them in the renderer.
	r_NoInterpolate = false;

	P_ThinkParticles();	// [RH] make the particles think

	for (i = 0; i<MAXPLAYERS; i++)
		if (playeringame[i] &&
			/*Added by MC: Freeze mode.*/!(bglobal.freeze && players[i].Bot != NULL))
			P_PlayerThink (&players[i]);

	// [ZZ] call the WorldTick hook
	E_WorldTick();
	StatusBar->CallTick ();		// [RH] moved this here
	level.Tick ();			// [RH] let the level tick
	DThinker::RunThinkers ();

	//if added by MC: Freeze mode.
	if (!bglobal.freeze && !(level.flags2 & LEVEL2_FROZEN))
	{
		P_UpdateSpecials ();
		P_RunEffects ();	// [RH] Run particle effects
	}

	// for par times
	level.time++;
	level.maptime++;
	level.totaltime++;
}
Esempio n. 5
0
void G_InitNew (const char *mapname, bool bTitleLevel)
{
	EGameSpeed oldSpeed;
	bool wantFast;
	int i;

	G_ClearHubInfo();
	if (!savegamerestore)
	{
		G_ClearSnapshots ();
		P_RemoveDefereds ();

		// [RH] Mark all levels as not visited
		for (unsigned int i = 0; i < wadlevelinfos.Size(); i++)
			wadlevelinfos[i].flags = wadlevelinfos[i].flags & ~LEVEL_VISITED;
	}

	UnlatchCVars ();
	G_VerifySkill();
	UnlatchCVars ();

	if (paused)
	{
		paused = 0;
		S_ResumeSound (false);
	}

	if (StatusBar != NULL)
	{
		StatusBar->Destroy();
		StatusBar = NULL;
	}
	if (bTitleLevel)
	{
		StatusBar = new DBaseStatusBar (0);
	}
	else if (SBarInfoScript[SCRIPT_CUSTOM] != NULL)
	{
		int cstype = SBarInfoScript[SCRIPT_CUSTOM]->GetGameType();

		//Did the user specify a "base"
		if(cstype == GAME_Strife)
		{
			StatusBar = CreateStrifeStatusBar();
		}
		else if(cstype == GAME_Any) //Use the default, empty or custom.
		{
			StatusBar = CreateCustomStatusBar(SCRIPT_CUSTOM);
		}
		else
		{
			StatusBar = CreateCustomStatusBar(SCRIPT_DEFAULT);
		}
	}
	if (StatusBar == NULL)
	{
		if (gameinfo.gametype & (GAME_DoomChex|GAME_Heretic|GAME_Hexen))
		{
			StatusBar = CreateCustomStatusBar (SCRIPT_DEFAULT);
		}
		else if (gameinfo.gametype == GAME_Strife)
		{
			StatusBar = CreateStrifeStatusBar ();
		}
		else
		{
			StatusBar = new DBaseStatusBar (0);
		}
	}
	GC::WriteBarrier(StatusBar);
	StatusBar->AttachToPlayer (&players[consoleplayer]);
	StatusBar->NewGame ();
	setsizeneeded = true;

	if (gameinfo.gametype == GAME_Strife || (SBarInfoScript[SCRIPT_CUSTOM] != NULL && SBarInfoScript[SCRIPT_CUSTOM]->GetGameType() == GAME_Strife))
	{
		// Set the initial quest log text for Strife.
		for (i = 0; i < MAXPLAYERS; ++i)
		{
			players[i].SetLogText ("Find help");
		}
	}

	// [RH] If this map doesn't exist, bomb out
	if (!P_CheckMapData(mapname))
	{
		I_Error ("Could not find map %s\n", mapname);
	}

	oldSpeed = GameSpeed;
	wantFast = !!G_SkillProperty(SKILLP_FastMonsters);
	GameSpeed = wantFast ? SPEED_Fast : SPEED_Normal;

	if (!savegamerestore)
	{
		if (!netgame && !demorecording && !demoplayback)
		{
			// [RH] Change the random seed for each new single player game
			// [ED850] The demo already sets the RNG.
			rngseed = use_staticrng ? staticrngseed : (rngseed + 1);
		}
		FRandom::StaticClearRandom ();
		P_ClearACSVars(true);
		level.time = 0;
		level.maptime = 0;
		level.totaltime = 0;

		if (!multiplayer || !deathmatch)
		{
			InitPlayerClasses ();
		}

		// force players to be initialized upon first level load
		for (i = 0; i < MAXPLAYERS; i++)
			players[i].playerstate = PST_ENTER;	// [BC]

		STAT_StartNewGame(mapname);
	}

	usergame = !bTitleLevel;		// will be set false if a demo
	paused = 0;
	demoplayback = false;
	automapactive = false;
	viewactive = true;
	V_SetBorderNeedRefresh();

	//Added by MC: Initialize bots.
	if (!deathmatch)
	{
		bglobal.Init ();
	}

	level.MapName = mapname;
	if (bTitleLevel)
	{
		gamestate = GS_TITLELEVEL;
	}
	else if (gamestate != GS_STARTUP)
	{
		gamestate = GS_LEVEL;
	}
	G_DoLoadLevel (0, false);
}
Esempio n. 6
0
void G_Ticker(void)
{
    int i, buf;
    ticcmd_t *cmd = NULL;

//
// do player reborns if needed
//
    for (i = 0; i < MAXPLAYERS; i++)
        if (playeringame[i] && players[i].playerstate == PST_REBORN)
            G_DoReborn(i);

//
// do things to change the game state
//
    while (gameaction != ga_nothing)
    {
        switch (gameaction)
        {
            case ga_loadlevel:
                G_DoLoadLevel();
                break;
            case ga_newgame:
                G_DoNewGame();
                break;
            case ga_loadgame:
                G_DoLoadGame();
                break;
            case ga_savegame:
                G_DoSaveGame();
                break;
            case ga_playdemo:
                G_DoPlayDemo();
                break;
            case ga_screenshot:
                V_ScreenShot("HTIC%02i.%s");
                gameaction = ga_nothing;
                break;
            case ga_completed:
                G_DoCompleted();
                break;
            case ga_worlddone:
                G_DoWorldDone();
                break;
            case ga_victory:
                F_StartFinale();
                break;
            default:
                break;
        }
    }


//
// get commands, check consistancy, and build new consistancy check
//
    //buf = gametic%BACKUPTICS;
    buf = (gametic / ticdup) % BACKUPTICS;

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

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

            if (demoplayback)
                G_ReadDemoTiccmd(cmd);
            if (demorecording)
                G_WriteDemoTiccmd(cmd);

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

//
// check for special buttons
//
    for (i = 0; i < MAXPLAYERS; i++)
        if (playeringame[i])
        {
            if (players[i].cmd.buttons & BT_SPECIAL)
            {
                switch (players[i].cmd.buttons & BT_SPECIALMASK)
                {
                    case BTS_PAUSE:
                        paused ^= 1;
                        if (paused)
                        {
                            S_PauseSound();
                        }
                        else
                        {
                            S_ResumeSound();
                        }
                        break;

                    case BTS_SAVEGAME:
                        if (!savedescription[0])
                        {
                            if (netgame)
                            {
                                M_StringCopy(savedescription,
                                             DEH_String("NET GAME"),
                                             sizeof(savedescription));
                            }
                            else
                            {
                                M_StringCopy(savedescription,
                                             DEH_String("SAVE GAME"),
                                             sizeof(savedescription));
                            }
                        }
                        savegameslot =
                            (players[i].cmd.
                             buttons & BTS_SAVEMASK) >> BTS_SAVESHIFT;
                        gameaction = ga_savegame;
                        break;
                }
            }
        }
    // turn inventory off after a certain amount of time
    if (inventory && !(--inventoryTics))
    {
        players[consoleplayer].readyArtifact =
            players[consoleplayer].inventory[inv_ptr].type;
        inventory = false;
        cmd->arti = 0;
    }
//
// do main actions
//
//
// do main actions
//
    switch (gamestate)
    {
        case GS_LEVEL:
            P_Ticker();
            SB_Ticker();
            AM_Ticker();
            CT_Ticker();
            break;
        case GS_INTERMISSION:
            IN_Ticker();
            break;
        case GS_FINALE:
            F_Ticker();
            break;
        case GS_DEMOSCREEN:
            D_PageTicker();
            break;
    }
}
Esempio n. 7
0
void G_InitNew(skill_t skill, int episode, int map)
{
    int i;
    int speed;
    static char *skyLumpNames[5] = {
        "SKY1", "SKY2", "SKY3", "SKY1", "SKY3"
    };

    if (paused)
    {
        paused = false;
        S_ResumeSound();
    }
    if (skill < sk_baby)
        skill = sk_baby;
    if (skill > sk_nightmare)
        skill = sk_nightmare;
    if (episode < 1)
        episode = 1;
    // Up to 9 episodes for testing
    if (episode > 9)
        episode = 9;
    if (map < 1)
        map = 1;
    if (map > 9)
        map = 9;
    M_ClearRandom();
    if (respawnparm)
    {
        respawnmonsters = true;
    }
    else
    {
        respawnmonsters = false;
    }
    // Set monster missile speeds
    speed = skill == sk_nightmare;
    for (i = 0; MonsterMissileInfo[i].type != -1; i++)
    {
        mobjinfo[MonsterMissileInfo[i].type].speed
            = MonsterMissileInfo[i].speed[speed] << FRACBITS;
    }
    // Force players to be initialized upon first level load
    for (i = 0; i < MAXPLAYERS; i++)
    {
        players[i].playerstate = PST_REBORN;
        players[i].didsecret = false;
    }
    // Set up a bunch of globals
    usergame = true;            // will be set false if a demo
    paused = false;
    demorecording = false;
    demoplayback = false;
    viewactive = true;
    gameepisode = episode;
    gamemap = map;
    gameskill = skill;
    viewactive = true;
    BorderNeedRefresh = true;

    // Set the sky map
    if (episode > 5)
    {
        skytexture = R_TextureNumForName(DEH_String("SKY1"));
    }
    else
    {
        skytexture = R_TextureNumForName(DEH_String(skyLumpNames[episode - 1]));
    }

//
// give one null ticcmd_t
//
#if 0
    gametic = 0;
    maketic = 1;
    for (i = 0; i < MAXPLAYERS; i++)
        nettics[i] = 1;         // one null event for this gametic
    memset(localcmds, 0, sizeof(localcmds));
    memset(netcmds, 0, sizeof(netcmds));
#endif
    G_DoLoadLevel();
}
Esempio n. 8
0
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;
                }
            }
        }
    }
}