Пример #1
0
// ---------------------------------------------------------------------
// Selects all damaged units - on screen toggle.
UDWORD	selSelectAllDamaged( UDWORD player, BOOL bOnScreen)
{
DROID	*psDroid;
UDWORD	damage;
UDWORD	count;

	selDroidDeselect(player);
	for(psDroid = apsDroidLists[player], count = 0;
		psDroid; psDroid = psDroid->psNext)
		{
			/* Get present percent of damage level */
			damage = PERCENT(psDroid->body,psDroid->originalBody);

			/* Less than threshold? */
			if(damage<REPAIRLEV_LOW)
			{
				/* Is on screen relevant? */
				if(bOnScreen ? droidOnScreen(psDroid,0) : true)
				{
                    //we don't want to get the Transporter
	 				if(psDroid->droidType != DROID_TRANSPORTER)
                    {
//    					psDroid->selected = true;
						SelectDroid(psDroid);
	    				count ++;
                    }
				}
			}
		}
	return(count);
}
Пример #2
0
// ---------------------------------------------------------------------
// Selects all units owned by the player that have a weapon. On screen
// toggle.
UDWORD	selSelectAllCombat( UDWORD player, BOOL bOnScreen)
{
DROID	*psDroid;
UDWORD	count;

	selDroidDeselect(player);
	for(psDroid = apsDroidLists[player], count = 0;
		psDroid; psDroid = psDroid->psNext)
		{
			/* Does it have a weapon? */
			//if(psDroid->numWeaps)
            if(psDroid->asWeaps[0].nStat > 0)
			{
		  		/* Is on screen relevant? */
				if(bOnScreen ? droidOnScreen(psDroid,0) : true)
				{
                    //we don't want to get the Transporter
	 				if(psDroid->droidType != DROID_TRANSPORTER)
					{
						psDroid->selected = true;
						count ++;
					}
				}
			}
		}
	return(count);
}
Пример #3
0
// ---------------------------------------------------------------------
// Selects all units owned by the player of a certain propulsion type.
// On Screen toggle.
UDWORD	selSelectAllSameProp( UDWORD player, PROPULSION_TYPE propType,
						   BOOL bOnScreen )
{
PROPULSION_STATS	*psPropStats;
DROID	*psDroid;
UDWORD	count;

	selDroidDeselect(player);
	/* Go thru' them all */
	for(psDroid = apsDroidLists[player], count = 0;
		psDroid; psDroid = psDroid->psNext)
	{
		/* Is on screen important */
		if(bOnScreen ? droidOnScreen(psDroid,0) : true)
		{
			/* Get the propulsion type */
			psPropStats = asPropulsionStats + psDroid->asBits[COMP_PROPULSION].nStat;
			ASSERT( psPropStats != NULL,
				"moveUpdateUnit: invalid propulsion stats pointer" );
			/* Same as that asked for - don't want Transporters*/
			if ( psPropStats->propulsionType == propType && psDroid->droidType != DROID_TRANSPORTER)
			{
				psDroid->selected = true;
				count++;
			}
		}
	}

	return(selNumSelected(player));
}
Пример #4
0
// ---------------------------------------------------------------------
// Selects all units owned by the player - onscreen toggle.
UDWORD	selSelectAllUnits( UDWORD player, BOOL bOnScreen )
{
DROID	*psDroid;
UDWORD	count;

	selDroidDeselect(player);
	/* Go thru' all */
	for(psDroid = apsDroidLists[player],count = 0;
		psDroid; psDroid = psDroid->psNext)
		{
			/* Do we care about them being on screen? */
			if(bOnScreen ? droidOnScreen(psDroid,0) : true)
			{
				/* can select everything except transporters */
				if(psDroid->droidType != DROID_TRANSPORTER)
				{
//					psDroid->selected = true;
					SelectDroid(psDroid);
					count++;
				}
			}
		}

	return(count);
}
Пример #5
0
static unsigned selSelectUnitsIf(unsigned player, T condition, bool onlyOnScreen)
{
	unsigned count = 0;

	selDroidDeselect(player);

	// Go through all.
	for (DROID *psDroid = apsDroidLists[player]; psDroid != nullptr; psDroid = psDroid->psNext)
	{
		bool shouldSelect = (!onlyOnScreen || droidOnScreen(psDroid, 0)) &&
		                    condition(psDroid);
		count += shouldSelect;
		if (shouldSelect && !psDroid->selected)
		{
			SelectDroid(psDroid);
		}
		else if (!shouldSelect && psDroid->selected)
		{
			DeSelectDroid(psDroid);
		}
	}

	return count;
}
Пример #6
0
// ////////////////////////////////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////////////
// MultiPlayer main game loop code.
bool multiPlayerLoop(void)
{
	UDWORD		i;
	UBYTE		joinCount;

		joinCount =0;
		for(i=0;i<MAX_PLAYERS;i++)
		{
			if(isHumanPlayer(i) && ingame.JoiningInProgress[i] )
			{
				joinCount++;
			}
		}
		if(joinCount)
		{
			setWidgetsStatus(false);
			bDisplayMultiJoiningStatus = joinCount;	// someone is still joining! say So

			// deselect anything selected.
			selDroidDeselect(selectedPlayer);

			if(keyPressed(KEY_ESC) )// check for cancel
			{
				bDisplayMultiJoiningStatus = 0;
				setWidgetsStatus(true);
				setPlayerHasLost(true);
			}
		}
		else		//everyone is in the game now!
		{
			if(bDisplayMultiJoiningStatus)
			{
				bDisplayMultiJoiningStatus = 0;
				setWidgetsStatus(true);
			}
			if (!ingame.TimeEveryoneIsInGame)
			{
				ingame.TimeEveryoneIsInGame = gameTime;
				debug(LOG_NET, "I have entered the game @ %d", ingame.TimeEveryoneIsInGame );
				if (!NetPlay.isHost)
				{
					debug(LOG_NET, "=== Sending hash to host ===");
					sendDataCheck();
				}
			}
			if (NetPlay.bComms)
			{
				sendPing();
			}
			// Only have to do this on a true MP game
			if (NetPlay.isHost && !ingame.isAllPlayersDataOK && NetPlay.bComms)
			{
				if (gameTime - ingame.TimeEveryoneIsInGame > GAME_TICKS_PER_SEC * 60)
				{
					// we waited 60 secs to make sure people didn't bypass the data integrity checks
					int index;
					for (index=0; index < MAX_PLAYERS; index++)
					{
						if (ingame.DataIntegrity[index] == false && isHumanPlayer(index) && index != NET_HOST_ONLY)
						{
							char msg[256] = {'\0'};

							sprintf(msg, _("Kicking player %s, because they tried to bypass data integrity check!"), getPlayerName(index));
							sendTextMessage(msg, true);
							addConsoleMessage(msg, LEFT_JUSTIFY, NOTIFY_MESSAGE);
							NETlogEntry(msg, SYNC_FLAG, index);

#ifndef DEBUG
							kickPlayer(index, "invalid data!", ERROR_INVALID);
#endif
							debug(LOG_WARNING, "Kicking Player %s (%u), they tried to bypass data integrity check!", getPlayerName(index), index);
						}
					}
					ingame.isAllPlayersDataOK = true;
				}
			}
		}

	// if player has won then process the win effects...
	if(testPlayerHasWon())
	{
		multiplayerWinSequence(false);
	}
	return true;
}
Пример #7
0
// ---------------------------------------------------------------------
void	selNextUnassignedUnit( void )
{
DROID	*psCurr;
DROID	*psResult;
DROID	*psFirst;
BOOL	bLaterInList;

	for(psCurr = apsDroidLists[selectedPlayer],psFirst = NULL,psResult = NULL,bLaterInList = false;
		psCurr && !psResult; psCurr = psCurr->psNext)
	{
		/* Only look at unselected ones */
		if(psCurr->group==UBYTE_MAX)
		{

		  	/* Keep a record of first one */
			if(!psFirst)
			{
				psFirst = psCurr;
			}

			if(psCurr == psOldNS)
			{
				bLaterInList = true;
			}

			/* First one...? */
			if(!psOldNS)
			{
				psResult = psCurr;
			}

			/* Dont choose same one again */
			else if(psCurr!=psOldNS && bLaterInList)
			{
				psResult = psCurr;
			}

		}
	}

	/* If we didn't get one - then select first one */
	if(!psResult)
	{
		if(psFirst)
		{
			psResult = psFirst;
		}
	}

	if(psResult && !psResult->died)
	{
	 	selDroidDeselect(selectedPlayer);
//		psResult->selected = true;
		SelectDroid(psResult);
		if(getWarCamStatus())
		{
			camToggleStatus();			 // messy - fix this
	//		setViewPos(map_coord(psCentreDroid->pos.x), map_coord(psCentreDroid->pos.y));
			processWarCam(); //odd, but necessary
			camToggleStatus();				// messy - FIXME
		}
		else
			if(!getWarCamStatus())
			{
//				camToggleStatus();
				/* Centre display on him if warcam isn't active */
				setViewPos(map_coord(psResult->pos.x), map_coord(psResult->pos.y), true);
			}
		psOldNS = psResult;
	}
	else
	{
		addConsoleMessage(_("Unable to locate any repair units!"),LEFT_JUSTIFY,SYSTEM_MESSAGE);
	}
}
Пример #8
0
// ffs am
// ---------------------------------------------------------------------
void	selNextSpecifiedUnit(UDWORD unitType)
{
DROID	*psCurr;
DROID	*psResult;
DROID	*psFirst;
BOOL	bLaterInList, bMatch;

	for(psCurr = apsDroidLists[selectedPlayer],psFirst = NULL,psResult = NULL,bLaterInList = false;
		psCurr && !psResult; psCurr = psCurr->psNext)
	{
		//if( psCurr->droidType == (SDWORD)unitType )
        //exceptions - as always...
        bMatch = false;
        if (unitType == DROID_CONSTRUCT)
        {
            if (psCurr->droidType == DROID_CONSTRUCT ||
                psCurr->droidType == DROID_CYBORG_CONSTRUCT)
            {
                bMatch = true;
            }
        }
        else if (unitType == DROID_REPAIR)
        {
            if (psCurr->droidType == DROID_REPAIR ||
                psCurr->droidType == DROID_CYBORG_REPAIR)
            {
                bMatch = true;
            }
        }
        else if(psCurr->droidType == (SDWORD)unitType)
        {
            bMatch = true;
        }
        if (bMatch)
		{
		 	/* Always store away the first one we find */
			if(!psFirst)
			{
				psFirst = psCurr;
			}

			if(psCurr == psOldRD)
			{
				bLaterInList = true;
			}

			/* Nothing previously found... */
			if(!psOldRD)
			{
				psResult = psCurr;
			}

			/* Only select is this isn't the old one and it's further on in list */
			else if(psCurr!=psOldRD && bLaterInList)
			{
				psResult = psCurr;
			}

		 }
	}

	/* Did we get one? */
	if(!psResult)
	{
		/* was there at least one - the first one? Resetting */
		if(psFirst)
		{
			psResult = psFirst;
		}
	}

	if(psResult && !psResult->died)
	{
	 	selDroidDeselect(selectedPlayer);
//		psResult->selected = true;
		SelectDroid(psResult);
		if(getWarCamStatus())
		{
			camToggleStatus();			 // messy - fix this
	//		setViewPos(map_coord(psCentreDroid->pos.x), map_coord(psCentreDroid->pos.y));
			processWarCam(); //odd, but necessary
			camToggleStatus();				// messy - FIXME
		}
		else
			if(!getWarCamStatus())
			{
//				camToggleStatus();
				/* Centre display on him if warcam isn't active */
				setViewPos(map_coord(psResult->pos.x), map_coord(psResult->pos.y), true);
			}
		psOldRD = psResult;
	}
	else
	{
		switch(unitType)
		{
		case	DROID_REPAIR:
			addConsoleMessage(_("Unable to locate any repair units!"),LEFT_JUSTIFY,SYSTEM_MESSAGE);
			break;
		case	DROID_CONSTRUCT:
			addConsoleMessage(_("Unable to locate any Trucks!"),LEFT_JUSTIFY,SYSTEM_MESSAGE);
			break;
		case	DROID_SENSOR:
			addConsoleMessage(_("Unable to locate any Sensor Units!"),LEFT_JUSTIFY,SYSTEM_MESSAGE);
			break;
		case	DROID_COMMAND:
			addConsoleMessage(_("Unable to locate any Commanders!"),LEFT_JUSTIFY,SYSTEM_MESSAGE);
			break;
		}
	}
}