* Apply a large quantity of style changes from patch #888 by EvilGuru (it's a backport from the netcode branch btw) (to reduce the diff-size of it)
* Remove some useless casts * Rewrite some "else { if (X) { } }" statements to "else if (X) { }" * Rewrite several "if (X) { if (Y) { } }" statements to "if (X && Y) { }" * Remove some commented out (and sometimes also duplicated) code * Add some tiny bits of comments here & there git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3119 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
75753bc3f8
commit
50c444f6e6
166
src/multigifts.c
166
src/multigifts.c
|
@ -153,7 +153,7 @@ void giftRadar(UDWORD from, UDWORD to,BOOL send)
|
|||
{
|
||||
NETMSG m;
|
||||
|
||||
hqReward((UBYTE)from, (UBYTE)to);
|
||||
hqReward(from, to);
|
||||
|
||||
if (send)
|
||||
{
|
||||
|
@ -164,20 +164,16 @@ void giftRadar(UDWORD from, UDWORD to,BOOL send)
|
|||
m.size = 3;
|
||||
NETbcast(&m,TRUE); //send it
|
||||
}
|
||||
else
|
||||
{
|
||||
if(to == selectedPlayer)
|
||||
else if (to == selectedPlayer)
|
||||
{
|
||||
CONPRINTF(ConsoleString,(ConsoleString,_("%s Gives You A Visibility Report"),
|
||||
getPlayerName(from)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void recvGiftDroids(UDWORD from,UDWORD to,NETMSG *pMsg)
|
||||
{
|
||||
|
||||
UDWORD id,pos=3;
|
||||
DROID *pD;
|
||||
|
||||
|
@ -188,8 +184,7 @@ static void recvGiftDroids(UDWORD from,UDWORD to,NETMSG *pMsg)
|
|||
|
||||
if (IdToDroid(id, from, &pD)) // find the droid.
|
||||
{
|
||||
//giftSingleDroid(pD,from,to); // give it away.
|
||||
(void)giftSingleDroid(pD,to); // give it away.
|
||||
giftSingleDroid(pD,to); // give it away.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,26 +252,18 @@ static void giftResearch(UDWORD from,UDWORD to,BOOL send)
|
|||
pR = asPlayerResList[from];
|
||||
pRto = asPlayerResList[to];
|
||||
|
||||
for(i=0; i<numResearch; i++) // do for each topic.
|
||||
// For each topic
|
||||
for (i = 0; i < numResearch; i++)
|
||||
{
|
||||
if(IsResearchCompleted(&pR[i]) )
|
||||
{
|
||||
if(IsResearchCompleted(&pRto[i])==FALSE)
|
||||
// If they have it and we don't research it
|
||||
if (IsResearchCompleted(&pR[i])
|
||||
&& !IsResearchCompleted(&pRto[i]))
|
||||
{
|
||||
MakeResearchCompleted(&pRto[i]);
|
||||
researchResult(i,(UBYTE)to,FALSE,NULL);
|
||||
}
|
||||
researchResult(i, to, FALSE, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* pPlayerRes = asPlayerResList[player];
|
||||
pPlayerRes += index;
|
||||
if(IsResearchCompleted(pPlayerRes)==FALSE)
|
||||
{
|
||||
MakeResearchCompleted(pPlayerRes);
|
||||
rese
|
||||
*/
|
||||
if (send)
|
||||
{
|
||||
m.body[0] = RESEARCH_GIFT;
|
||||
|
@ -286,13 +273,10 @@ static void giftResearch(UDWORD from,UDWORD to,BOOL send)
|
|||
m.size = 3;
|
||||
NETbcast(&m,TRUE); //send it
|
||||
}
|
||||
else
|
||||
{
|
||||
if(to == selectedPlayer)
|
||||
else if (to == selectedPlayer)
|
||||
{
|
||||
CONPRINTF(ConsoleString,(ConsoleString,_("%s Gives You Technology Documents"),getPlayerName(from) ));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -310,6 +294,7 @@ void giftPower(UDWORD from,UDWORD to,BOOL send)
|
|||
}
|
||||
else
|
||||
{
|
||||
// Give 1/3 of our power away
|
||||
gifval = asPower[from]->currentPower / 3;
|
||||
// asPower[from]->currentPower -= gifval;
|
||||
usePower(from, gifval);
|
||||
|
@ -326,14 +311,11 @@ void giftPower(UDWORD from,UDWORD to,BOOL send)
|
|||
m.size = 3;
|
||||
NETbcast(&m,TRUE); //send it
|
||||
}
|
||||
else
|
||||
{
|
||||
if(to == selectedPlayer)
|
||||
else if (to == selectedPlayer)
|
||||
{
|
||||
CONPRINTF(ConsoleString,(ConsoleString,_("%s Gives You Power"),getPlayerName(from)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -341,8 +323,8 @@ void giftPower(UDWORD from,UDWORD to,BOOL send)
|
|||
|
||||
void requestAlliance(UBYTE from ,UBYTE to,BOOL prop,BOOL allowAudio)
|
||||
{
|
||||
alliances[from][to] = ALLIANCE_REQUESTED; // we've asked.
|
||||
alliances[to][from] = ALLIANCE_INVITATION; // they've been invited.
|
||||
alliances[from][to] = ALLIANCE_REQUESTED; // We've asked
|
||||
alliances[to][from] = ALLIANCE_INVITATION; // They've been invited
|
||||
|
||||
|
||||
CBallFrom = from;
|
||||
|
@ -368,13 +350,14 @@ void requestAlliance(UBYTE from ,UBYTE to,BOOL prop,BOOL allowAudio)
|
|||
|
||||
if (prop)
|
||||
{
|
||||
sendAlliance(from,to,ALLIANCE_REQUESTED,0);
|
||||
sendAlliance(from, to, ALLIANCE_REQUESTED, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void breakAlliance(UBYTE p1, UBYTE p2,BOOL prop,BOOL allowAudio)
|
||||
{
|
||||
char tm1[128];
|
||||
|
||||
if (alliances[p1][p2] == ALLIANCE_FORMED)
|
||||
{
|
||||
strlcpy(tm1, getPlayerName(p1), sizeof(tm1));
|
||||
|
@ -390,7 +373,7 @@ void breakAlliance(UBYTE p1, UBYTE p2,BOOL prop,BOOL allowAudio)
|
|||
|
||||
if (prop)
|
||||
{
|
||||
sendAlliance(p1,p2,ALLIANCE_BROKEN,0);
|
||||
sendAlliance(p1, p2, ALLIANCE_BROKEN, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -399,8 +382,8 @@ void formAlliance(UBYTE p1, UBYTE p2,BOOL prop,BOOL allowAudio,BOOL allowNotific
|
|||
DROID *psDroid;
|
||||
char tm1[128];
|
||||
|
||||
// dont add message if already allied,
|
||||
if(bMultiPlayer && !(alliances[p1][p2] == ALLIANCE_FORMED) && allowNotification )
|
||||
// Don't add message if already allied
|
||||
if (bMultiPlayer && alliances[p1][p2] != ALLIANCE_FORMED && allowNotification)
|
||||
{
|
||||
strlcpy(tm1, getPlayerName(p1), sizeof(tm1));
|
||||
CONPRINTF(ConsoleString,(ConsoleString,_("%s Forms An Alliance With %s"),tm1,getPlayerName(p2)));
|
||||
|
@ -409,30 +392,27 @@ void formAlliance(UBYTE p1, UBYTE p2,BOOL prop,BOOL allowAudio,BOOL allowNotific
|
|||
alliances[p1][p2] = ALLIANCE_FORMED;
|
||||
alliances[p2][p1] = ALLIANCE_FORMED;
|
||||
|
||||
//make sure they can see our base location
|
||||
|
||||
|
||||
if (allowAudio && (p1 == selectedPlayer || p2== selectedPlayer))
|
||||
{
|
||||
audio_QueueTrack(ID_ALLIANCE_ACC);
|
||||
}
|
||||
|
||||
if(bMultiPlayer)//jps 15apr99
|
||||
if (bMultiPlayer && prop)
|
||||
{
|
||||
if(prop)
|
||||
{
|
||||
sendAlliance(p1,p2,ALLIANCE_FORMED,0);
|
||||
}
|
||||
sendAlliance(p1, p2, ALLIANCE_FORMED, FALSE);
|
||||
}
|
||||
|
||||
if((bMultiPlayer || game.type == SKIRMISH) && game.alliance == ALLIANCES_TEAMS) //not campaign and alliances are transitive
|
||||
// Not campaign and alliances are transitive
|
||||
if ((bMultiPlayer || game.type == SKIRMISH) && game.alliance == ALLIANCES_TEAMS)
|
||||
{
|
||||
giftRadar(p1, p2, FALSE);
|
||||
giftRadar(p2, p1, FALSE);
|
||||
}
|
||||
|
||||
// clear out any attacking orders.
|
||||
// Clear out any attacking orders
|
||||
turnOffMultiMsg(TRUE);
|
||||
|
||||
for (psDroid = apsDroidLists[p1]; psDroid; psDroid = psDroid->psNext) // from -> to
|
||||
{
|
||||
if (psDroid->order == DORDER_ATTACK
|
||||
|
@ -581,9 +561,6 @@ void technologyGiveAway(STRUCTURE *pS)
|
|||
|
||||
void addLoserGifts(void)
|
||||
{
|
||||
// DROID *psD;
|
||||
// DROID_TEMPLATE *psTempl;
|
||||
// Vector3i position;
|
||||
static UDWORD lastgift=0;
|
||||
UDWORD i,x,y,quantity,count;
|
||||
UWORD nx,ny;
|
||||
|
@ -592,18 +569,20 @@ void addLoserGifts(void)
|
|||
SDWORD type = FEAT_OIL_DRUM;
|
||||
STRUCTURE *psStruct;
|
||||
|
||||
if(lastgift>gameTime)lastgift=0; // might be a restart
|
||||
if (lastgift > gameTime)
|
||||
lastgift = 0; // might be a restart
|
||||
|
||||
// player has no power
|
||||
if(apsStructLists[selectedPlayer] && asPower[selectedPlayer]->currentPower < 10) // give some oil drums.
|
||||
// Player has no power, so give the player some oil
|
||||
if (apsStructLists[selectedPlayer]
|
||||
&& asPower[selectedPlayer]->currentPower < 10) // give some oil drums.
|
||||
{
|
||||
// only proceed if it's been a while
|
||||
// Only proceed if it's been a while
|
||||
if (gameTime - lastgift < GIFTFREQ)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// only proceed if no powergen.
|
||||
// Only proceed if no powergen
|
||||
for (psStruct = apsStructLists[selectedPlayer];
|
||||
psStruct && psStruct->pStructureType->type != REF_POWER_GEN;
|
||||
psStruct = psStruct->psNext);
|
||||
|
@ -652,51 +631,7 @@ void addLoserGifts(void)
|
|||
audio_QueueTrack(ID_GIFT);
|
||||
m.type = NET_ARTIFACTS;
|
||||
NETbcast(&m,FALSE); // tell everyone.
|
||||
|
||||
}
|
||||
|
||||
/* removed. too confusing.. con droids all over!
|
||||
// player has no construction droids
|
||||
for(psD=apsDroidLists[selectedPlayer];(psD != NULL)&&(psD->droidType !=DROID_CONSTRUCT);psD = psD->psNext);
|
||||
if(!psD)
|
||||
{
|
||||
for(psTempl=apsDroidTemplates[selectedPlayer];
|
||||
psTempl && (psTempl->asParts[COMP_CONSTRUCT] == 0);
|
||||
psTempl = psTempl->psNext);
|
||||
|
||||
if(psTempl)
|
||||
{
|
||||
// give player a construction Droid.right now!
|
||||
if(apsStructLists[selectedPlayer])
|
||||
{
|
||||
x = map_coord(apsStructLists[selectedPlayer]->pos.x);
|
||||
y = map_coord(apsStructLists[selectedPlayer]->pos.y);
|
||||
z = map_coord(apsStructLists[selectedPlayer]->pos.z);
|
||||
|
||||
pickATileGen(&x,&y,LOOK_FOR_EMPTY_TILE,normalPAT);
|
||||
|
||||
position.x = world_coord(x); // Add an effect
|
||||
position.z = world_coord(y);
|
||||
position.y = world_coord(z);
|
||||
|
||||
if(gameTime - lastgift< GIFTFREQ)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastgift = gameTime;
|
||||
powerCalc(FALSE);
|
||||
psD=buildDroid( psTempl, world_coord(x), world_coord(y), selectedPlayer, FALSE);
|
||||
if(psD)
|
||||
{
|
||||
audio_QueueTrack(ID_GIFT);
|
||||
addDroid(psD,apsDroidLists); // add droid. telling everyone
|
||||
addEffect(&position,EFFECT_EXPLOSION,EXPLOSION_TYPE_DISCOVERY,FALSE,NULL,FALSE);
|
||||
}
|
||||
powerCalc(TRUE); // power back on.
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -717,7 +652,7 @@ void addMultiPlayerRandomArtifacts(UDWORD quantity,SDWORD type)
|
|||
NetAdd(m,m.size,type);
|
||||
m.size += sizeof(type);
|
||||
|
||||
for(i=0; (i<numFeatureStats) && (asFeatureStats[i].subType != type); i++);
|
||||
for (i = 0; i < numFeatureStats && asFeatureStats[i].subType != type; i++);
|
||||
|
||||
ASSERT( mapWidth>20,"map not big enough" );
|
||||
ASSERT( mapHeight>20,"map not big enough" );
|
||||
|
@ -776,7 +711,7 @@ void recvMultiPlayerRandomArtifacts(NETMSG *pMsg)
|
|||
NetGet(pMsg,index,type);
|
||||
index += sizeof(type);
|
||||
|
||||
for(i=0; (i<numFeatureStats) && (asFeatureStats[i].subType != type); i++);
|
||||
for (i = 0; i < numFeatureStats && asFeatureStats[i].subType != type; i++);
|
||||
|
||||
for (count = 0; count < quantity; count++)
|
||||
{
|
||||
|
@ -819,7 +754,8 @@ void giftArtifact(UDWORD owner,UDWORD x,UDWORD y)
|
|||
|
||||
for (topic = numResearch; topic > 0; topic--)
|
||||
{
|
||||
if( (IsResearchCompleted(&pO[topic]) ) && (IsResearchPossible(&pR[topic])==FALSE ) )
|
||||
if (IsResearchCompleted(&pO[topic])
|
||||
&& !IsResearchPossible(&pR[topic]))
|
||||
{
|
||||
MakeResearchPossible(&pR[topic]);
|
||||
CONPRINTF(ConsoleString,(ConsoleString,_("You Discover Blueprints For %s"),
|
||||
|
@ -872,28 +808,13 @@ void processMultiPlayerArtifacts(void)
|
|||
audio_QueueTrack( ID_SOUND_ARTIFACT_RECOVERED );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// oil drums
|
||||
// if(pF->psStats->subType == FEAT_OIL_DRUM)
|
||||
// {
|
||||
// found = objectInRange((BASE_OBJECT *)apsDroidLists[selectedPlayer], pF->pos.x,pF->pos.y,(TILE_UNITS+(TILE_UNITS/3)) );
|
||||
// if(found)
|
||||
// {
|
||||
// giftPower(ANYPLAYER,selectedPlayer,TRUE); // give power and tell everyone.
|
||||
// removeFeature(pF); // remove artifact+ send info.
|
||||
// addOilDrum(1);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Ally team members with each other */
|
||||
void createTeamAlliances(void)
|
||||
{
|
||||
UDWORD i,j;
|
||||
int i, j;
|
||||
|
||||
debug(LOG_WZ, "Creating teams");
|
||||
|
||||
|
@ -901,13 +822,16 @@ void createTeamAlliances(void)
|
|||
{
|
||||
for (j = 0; j < MAX_PLAYERS; j++)
|
||||
{
|
||||
if( i!=j && (playerTeam[i] == playerTeam[j]) //wto different players belonging to the same team
|
||||
&& !aiCheckAlliances(i,j) && (playerTeam[i] >= 0)) //not allied and not ignoring teams
|
||||
if (i != j
|
||||
&& playerTeam[i] == playerTeam[j] // Wto different players belonging to the same team
|
||||
&& !aiCheckAlliances(i, j)
|
||||
&& playerTeam[i] >= 0
|
||||
&& game.skDiff[i]
|
||||
&& game.skDiff[j]) // Not allied and not ignoring teams
|
||||
{
|
||||
if(game.skDiff[i] && game.skDiff[j]) //make sure both players are enabled
|
||||
formAlliance(i,j,FALSE,FALSE,FALSE); //create silently
|
||||
// Create silently
|
||||
formAlliance(i, j, FALSE, FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue