コード例 #1
0
ファイル: sv_mobj.cpp プロジェクト: JohnnyonFlame/odamex
//
// P_PreservePlayer
//
void P_PreservePlayer(player_t &player)
{
	if (!serverside || sv_gametype != GM_COOP || !validplayer(player) || !player.ingame())
		return;

	if(!unnatural_level_progression)
		player.playerstate = PST_LIVE; // denis - carry weapons and keys over to next level

	G_DoReborn(player);

	// inform client
	{
		size_t i;
		client_t *cl = &player.client;

		MSG_WriteMarker (&cl->reliablebuf, svc_playerinfo);

		for(i = 0; i < NUMWEAPONS; i++)
			MSG_WriteByte (&cl->reliablebuf, player.weaponowned[i]);

		for(i = 0; i < NUMAMMO; i++)
		{
			MSG_WriteShort (&cl->reliablebuf, player.maxammo[i]);
			MSG_WriteShort (&cl->reliablebuf, player.ammo[i]);
		}

		MSG_WriteByte (&cl->reliablebuf, player.health);
		MSG_WriteByte (&cl->reliablebuf, player.armorpoints);
		MSG_WriteByte (&cl->reliablebuf, player.armortype);
		MSG_WriteByte (&cl->reliablebuf, player.readyweapon);
		MSG_WriteByte (&cl->reliablebuf, player.backpack);
	}
}
コード例 #2
0
ファイル: tick.c プロジェクト: Almamu/doom3do
Word P_Ticker(void)
{
	player_t *pl;

	/* wait for refresh to latch all needed data before */
	/* running the next tick */

	gameaction = ga_nothing;		/* Game in progress */
	Tick1 = FALSE;			/* Reset the flags */
	Tick2 = FALSE;
	Tick4 = FALSE;

	TimeMark1+=ElapsedTime;	/* Timer for ticks */
	TimeMark2+=ElapsedTime;
	TimeMark4+=ElapsedTime;

	if (TimeMark1>=TICKSPERSEC) {	/* Now see if the time has passed... */
		TimeMark1-=TICKSPERSEC;
		Tick1 = TRUE;
	}
	if (TimeMark2>=(TICKSPERSEC/2)) {
		TimeMark2-=(TICKSPERSEC/2);
		Tick2 = TRUE;
	}
	if (TimeMark4>=(TICKSPERSEC/4)) {
		TimeMark4-=(TICKSPERSEC/4);
		Tick4 = TRUE;
	}

	CheckCheats();		/* Handle pause and cheats */

/* Do option screen processing and control reading */

	if (gamepaused) {		/* If in pause mode, then don't do any game logic */
		return gameaction;
	}

/* Run player actions */

	pl = &players;
	
	if (pl->playerstate == PST_REBORN) {	/* Restart player? */
		G_DoReborn();		/* Poof!! */
	}
	AM_Control(pl);		/* Handle automap controls */
	O_Control(pl);		/* Handle option controls */
	P_PlayerThink(pl);	/* Process player in the game */
		
	if (!(players.AutomapFlags & AF_OPTIONSACTIVE)) {
		RunThinkers();		/* Handle logic for doors, walls etc... */
		P_RunMobjBase();	/* Handle critter think logic */
	}
	P_UpdateSpecials();	/* Handle wall and floor animations */
	ST_Ticker();		/* Update status bar */
	return gameaction;	/* may have been set to ga_died, ga_completed, */
						/* or ga_secretexit */
}
コード例 #3
0
ファイル: b_game.cpp プロジェクト: rsrsps/gzdoom
bool FCajunMaster::DoAddBot (BYTE *info, botskill_t skill)
{
    int bnum;

    for (bnum = 0; bnum < MAXPLAYERS; bnum++)
    {
        if (!playeringame[bnum])
        {
            break;
        }
    }

    if (bnum == MAXPLAYERS)
    {
        Printf ("The maximum of %d players/bots has been reached\n", MAXPLAYERS);
        return false;
    }

    D_ReadUserInfoStrings (bnum, &info, false);

    if (!deathmatch && playerstarts[bnum].type == 0)
    {
        Printf ("%s tried to join, but there was no player %d start\n",
                players[bnum].userinfo.GetName(), bnum+1);
        ClearPlayer (bnum, false);	// Make the bot inactive again
        return false;
    }

    multiplayer = true; //Prevents cheating and so on; emulates real netgame (almost).
    players[bnum].Bot = new DBot;
    players[bnum].Bot->player = &players[bnum];
    players[bnum].Bot->skill = skill;
    playeringame[bnum] = true;
    players[bnum].mo = NULL;
    players[bnum].playerstate = PST_ENTER;

    if (teamplay)
        Printf ("%s joined the %s team\n", players[bnum].userinfo.GetName(), Teams[players[bnum].userinfo.GetTeam()].GetName());
    else
        Printf ("%s joined the game\n", players[bnum].userinfo.GetName());

    G_DoReborn (bnum, true);
    if (StatusBar != NULL)
    {
        StatusBar->MultiplayerChanged ();
    }

    return true;
}
コード例 #4
0
ファイル: p_tick.c プロジェクト: ProfessorKaos64/Doom64EX
int P_Ticker(void) {
    int i;

    if(i_interpolateframes.value) {
        P_UpdateFrameStates();
    }

    if(paused) {
        return 0;
    }

    // pause if in menu and at least one tic has been run
    if(!netgame && menuactive &&
            !demoplayback && players[consoleplayer].viewz != 1) {
        return 0;
    }

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

            P_PlayerThink(&players[i]);
        }
    }

    P_RunThinkers();
    P_ScanSights();
    P_RunMobjs();
    P_UpdateSpecials();
    P_RunMacros();

    ST_Ticker();
    AM_Ticker();

    // for par times
    leveltime++;

    return gameaction;
}
コード例 #5
0
ファイル: b_game.cpp プロジェクト: ArcticPheenix/gzdoom
bool FCajunMaster::DoAddBot (uint8_t *info, botskill_t skill)
{
	int bnum;

	for (bnum = 0; bnum < MAXPLAYERS; bnum++)
	{
		if (!playeringame[bnum])
		{
			break;
		}
	}

	if (bnum == MAXPLAYERS)
	{
		Printf ("The maximum of %d players/bots has been reached\n", MAXPLAYERS);
		return false;
	}

	D_ReadUserInfoStrings (bnum, &info, false);

	multiplayer = true; //Prevents cheating and so on; emulates real netgame (almost).
	players[bnum].Bot = Create<DBot>();
	players[bnum].Bot->player = &players[bnum];
	players[bnum].Bot->skill = skill;
	playeringame[bnum] = true;
	players[bnum].mo = NULL;
	players[bnum].playerstate = PST_ENTER;

	if (teamplay)
		Printf ("%s joined the %s team\n", players[bnum].userinfo.GetName(), Teams[players[bnum].userinfo.GetTeam()].GetName());
	else
		Printf ("%s joined the game\n", players[bnum].userinfo.GetName());

	G_DoReborn (bnum, true);
	return true;
}
コード例 #6
0
void FCajunMaster::DoAddBot (int bnum, char *info)
{
	BYTE *infob = (BYTE *)info;
	D_ReadUserInfoStrings (bnum, &infob, false);
	if (!deathmatch && playerstarts[bnum].type == 0)
	{
		Printf ("%s tried to join, but there was no player %d start\n",
			players[bnum].userinfo.netname, bnum+1);
		ClearPlayer (bnum, false);	// Make the bot inactive again
		if (botnum > 0)
		{
			botnum--;
		}
	}
	else
	{
		multiplayer = true; //Prevents cheating and so on; emulates real netgame (almost).
		players[bnum].isbot = true;
		playeringame[bnum] = true;
		players[bnum].mo = NULL;
		players[bnum].playerstate = PST_ENTER;
		botingame[bnum] = true;

		if (teamplay)
			Printf ("%s joined the %s team\n", players[bnum].userinfo.netname,Teams[players[bnum].userinfo.team].GetName ());
		else
			Printf ("%s joined the game\n", players[bnum].userinfo.netname);

		G_DoReborn (bnum, true);
		if (StatusBar != NULL)
		{
			StatusBar->MultiplayerChanged ();
		}
	}
	waitingforspawn[bnum] = false;
}
コード例 #7
0
ファイル: g_game.cpp プロジェクト: JohnnyonFlame/odamex
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;
			}
		}
    }
コード例 #8
0
ファイル: g_level.cpp プロジェクト: Quaker540/gzdoom
void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill)
{
	level_info_t *nextinfo = NULL;

	if (unloading)
	{
		Printf (TEXTCOLOR_RED "Unloading scripts cannot exit the level again.\n");
		return;
	}

	if (levelname == NULL || *levelname == 0)
	{
		// end the game
		levelname = NULL;
		if (!level.NextMap.Compare("enDSeQ",6))
		{
			nextlevel = level.NextMap;	// If there is already an end sequence please leave it alone!
		}
		else 
		{
			nextlevel.Format("enDSeQ%04x", int(gameinfo.DefaultEndSequence));
		}
	}
	else if (strncmp(levelname, "enDSeQ", 6) != 0)
	{
		nextinfo = FindLevelInfo (levelname, false);
		if (nextinfo != NULL)
		{
			level_info_t *nextredir = nextinfo->CheckLevelRedirect();
			if (nextredir != NULL)
			{
				nextinfo = nextredir;
			}
		}
		nextlevel = nextinfo->MapName;
	}
	else
	{
		nextlevel = levelname;
	}

	if (nextSkill != -1)
		NextSkill = nextSkill;

	if (flags & CHANGELEVEL_NOINTERMISSION)
	{
		level.flags |= LEVEL_NOINTERMISSION;
	}

	cluster_info_t *thiscluster = FindClusterInfo (level.cluster);
	cluster_info_t *nextcluster = nextinfo? FindClusterInfo (nextinfo->cluster) : NULL;

	startpos = position;
	gameaction = ga_completed;
		
	if (nextinfo != NULL) 
	{
		if (thiscluster != nextcluster || (thiscluster && !(thiscluster->flags & CLUSTER_HUB)))
		{
			if (nextinfo->flags2 & LEVEL2_RESETINVENTORY)
			{
				flags |= CHANGELEVEL_RESETINVENTORY;
			}
			if (nextinfo->flags2 & LEVEL2_RESETHEALTH)
			{
				flags |= CHANGELEVEL_RESETHEALTH;
			}
		}
	}
	changeflags = flags;

	bglobal.End();	//Added by MC:

	// [RH] Give scripts a chance to do something
	unloading = true;
	FBehavior::StaticStartTypedScripts (SCRIPT_Unloading, NULL, false, 0, true);
	unloading = false;

	STAT_ChangeLevel(nextlevel);

	if (thiscluster && (thiscluster->flags & CLUSTER_HUB))
	{
		if ((level.flags & LEVEL_NOINTERMISSION) || (nextcluster == thiscluster))
			NoWipe = 35;
		D_DrawIcon = "TELEICON";
	}

	for(int i = 0; i < MAXPLAYERS; i++)
	{
		if (playeringame[i])
		{
			player_t *player = &players[i];

			// Un-crouch all players here.
			player->Uncrouch();

			// If this is co-op, respawn any dead players now so they can
			// keep their inventory on the next map.
			if ((multiplayer || level.flags2 & LEVEL2_ALLOWRESPAWN) && !deathmatch && player->playerstate == PST_DEAD)
			{
				// Copied from the end of P_DeathThink [[
				player->cls = NULL;		// Force a new class if the player is using a random class
				player->playerstate = PST_REBORN;
				if (player->mo->special1 > 2)
				{
					player->mo->special1 = 0;
				}
				// ]]
				G_DoReborn(i, false);
			}
		}
	}
}
コード例 #9
0
ファイル: g_game.c プロジェクト: GhostlyDeath/chocolate-doom
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;
    }
}
コード例 #10
0
ファイル: p_tick.c プロジェクト: team-eternity/calico-doom
int P_Ticker(void)
{
   //int       start;
   //int       ticstart;
   player_t *pl;

   //ticstart = samplecount;

   while(!I_RefreshLatched())
      ; // wait for refresh to latch all needed data before running the next tick

   gameaction = ga_nothing;

   gametic++;
 
   //
   // check for pause and cheats
   //
   P_CheckCheats();

   //
   // do option screen processing
   //
   for(playernum = 0, pl = players; playernum < MAXPLAYERS; playernum++, pl++)
   {
      if(playeringame[playernum])
         O_Control(pl);
   }

   if(gamepaused)
      return 0;

   //
   // run player actions
   //
   //start = samplecount;
   for(playernum = 0, pl = players; playernum < MAXPLAYERS; playernum++, pl++)
   {
      if(playeringame[playernum])
      {
         if(pl->playerstate == PST_REBORN) 
            G_DoReborn(playernum); 
         AM_Control(pl);
         P_PlayerThink(pl);
      }
   }

   //playertics = samplecount - start;

   //start = samplecount;
   P_RunThinkers();
   //thinkertics = samplecount - start;

   //start = samplecount;
   P_CheckSights();
   //sighttics = samplecount - start;

   //start = samplecount;
   P_RunMobjBase();
   //basetics = samplecount - start;

   //start = samplecount;
   P_RunMobjLate();
   //latetics = samplecount - start;

   P_UpdateSpecials();

   P_RespawnSpecials();

   ST_Ticker(); // update status bar

   //tictics = samplecount - ticstart;

   return gameaction; // may have been set to ga_died, ga_completed, or ga_secretexit
}