Exemplo n.º 1
0
/*
** when a remote player leaves an arena game do this!
**
** @param player -- the one we need to clear
** @param quietly -- true means without any visible effects
*/
void clearPlayer(UDWORD player,bool quietly)
{
	UDWORD			i;
	STRUCTURE		*psStruct,*psNext;

	debug(LOG_NET, "R.I.P. %s (%u). quietly is %s", getPlayerName(player), player, quietly ? "true":"false");

	ingame.JoiningInProgress[player] = false;	// if they never joined, reset the flag
	ingame.DataIntegrity[player] = false;

	(void)setPlayerName(player,"");				//clear custom player name (will use default instead)

	for(i = 0;i<MAX_PLAYERS;i++)				// remove alliances
	{
		alliances[player][i]	= ALLIANCE_BROKEN;
		alliances[i][player]	= ALLIANCE_BROKEN;
	}

	debug(LOG_DEATH, "killing off all droids for player %d", player);
	while(apsDroidLists[player])				// delete all droids
	{
		if(quietly)			// don't show effects
		{
			killDroid(apsDroidLists[player]);
		}
		else				// show effects
		{
			destroyDroid(apsDroidLists[player], gameTime);
		}
	}

	debug(LOG_DEATH, "killing off all structures for player %d", player);
	psStruct = apsStructLists[player];
	while(psStruct)				// delete all structs
	{
		psNext = psStruct->psNext;

		// FIXME: look why destroyStruct() doesn't put back the feature like removeStruct() does
		if(quietly || psStruct->pStructureType->type == REF_RESOURCE_EXTRACTOR)		// don't show effects
		{
			removeStruct(psStruct, true);
		}
		else			// show effects
		{
			destroyStruct(psStruct, gameTime);
		}

		psStruct = psNext;
	}

	return;
}
Exemplo n.º 2
0
// ////////////////////////////////////////////////////////////////////////////
// remove structures from map before campaign play.
static BOOL cleanMap(UDWORD player)
{
    DROID		*psD,*psD2;
    STRUCTURE	*psStruct;
    BOOL		firstFact,firstRes;

    bMultiPlayer = false;
    bMultiMessages = false;

    firstFact = true;
    firstRes = true;

    switch(game.base)
    {
    case CAMP_CLEAN:									//clean map
        while(apsStructLists[player])					//strip away structures.
        {
            removeStruct(apsStructLists[player], true);
        }
        psD = apsDroidLists[player];					// remove all but construction droids.
        while(psD)
        {
            psD2=psD->psNext;
            if (psD->droidType != DROID_CONSTRUCT && psD->droidType != DROID_CYBORG_CONSTRUCT)
            {
                killDroid(psD);
            }
            psD = psD2;
        }
        break;

    case CAMP_BASE:												//just structs, no walls
        psStruct = apsStructLists[player];
        while(psStruct)
        {
            if ( (psStruct->pStructureType->type == REF_WALL)
                    ||(psStruct->pStructureType->type == REF_WALLCORNER)
                    ||(psStruct->pStructureType->type == REF_DEFENSE)
                    ||(psStruct->pStructureType->type == REF_BLASTDOOR)
                    ||(psStruct->pStructureType->type == REF_GATE)
                    ||(psStruct->pStructureType->type == REF_CYBORG_FACTORY)
                    ||(psStruct->pStructureType->type == REF_COMMAND_CONTROL))
            {
                removeStruct(psStruct, true);
                psStruct= apsStructLists[player];			//restart,(list may have changed).
            }
            else if( (psStruct->pStructureType->type == REF_FACTORY)
                     ||(psStruct->pStructureType->type == REF_RESEARCH)
                     ||(psStruct->pStructureType->type == REF_POWER_GEN))
            {
                if(psStruct->pStructureType->type == REF_FACTORY )
                {
                    if(firstFact == true)
                    {
                        firstFact = false;
                        removeStruct(psStruct, true);
                        psStruct= apsStructLists[player];
                    }
                    else	// don't delete, just rejig!
                    {
                        if(((FACTORY*)psStruct->pFunctionality)->capacity != 0)
                        {
                            ((FACTORY*)psStruct->pFunctionality)->capacity = 0;
                            ((FACTORY*)psStruct->pFunctionality)->productionOutput = (UBYTE)((PRODUCTION_FUNCTION*)psStruct->pStructureType->asFuncList[0])->productionOutput;

                            psStruct->sDisplay.imd	= psStruct->pStructureType->pIMD;
                            psStruct->body			= (UWORD)(structureBody(psStruct));

                        }
                        psStruct				= psStruct->psNext;
                    }
                }
                else if(psStruct->pStructureType->type == REF_RESEARCH)
                {
                    if(firstRes == true)
                    {
                        firstRes = false;
                        removeStruct(psStruct, true);
                        psStruct= apsStructLists[player];
                    }
                    else
                    {
                        if(((RESEARCH_FACILITY*)psStruct->pFunctionality)->capacity != 0)
                        {   // downgrade research
                            ((RESEARCH_FACILITY*)psStruct->pFunctionality)->capacity = 0;
                            ((RESEARCH_FACILITY*)psStruct->pFunctionality)->researchPoints = ((RESEARCH_FUNCTION*)psStruct->pStructureType->asFuncList[0])->researchPoints;
                            psStruct->sDisplay.imd	= psStruct->pStructureType->pIMD;
                            psStruct->body			= (UWORD)(structureBody(psStruct));
                        }
                        psStruct=psStruct->psNext;
                    }
                }
                else if(psStruct->pStructureType->type == REF_POWER_GEN)
                {
                    if(((POWER_GEN*)psStruct->pFunctionality)->capacity != 0)
                    {   // downgrade powergen.
                        ((POWER_GEN*)psStruct->pFunctionality)->capacity = 0;

                        psStruct->sDisplay.imd	= psStruct->pStructureType->pIMD;
                        psStruct->body			= (UWORD)(structureBody(psStruct));
                    }
                    structurePowerUpgrade(psStruct);
                    psStruct=psStruct->psNext;
                }
            }

            else
            {
                psStruct=psStruct->psNext;
            }
        }
        break;


    case CAMP_WALLS:												//everything.
        break;
    default:
        debug( LOG_FATAL, "Unknown Campaign Style" );
        abort();
        break;
    }

    bMultiPlayer = true;
    bMultiMessages = true;
    return true;
}