Branch merge in oil drum fix from 2.2 in r6764.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6765 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2009-03-01 23:50:18 +00:00
parent 677c52277e
commit 5e1895ac70
4 changed files with 21 additions and 25 deletions

View File

@ -2130,20 +2130,22 @@ INT_RETVAL intRunWidgets(void)
Cheated = true;
}
}
else if (psPositionStats->ref >= REF_FEATURE_START &&
psPositionStats->ref < REF_FEATURE_START + REF_RANGE)
else if (psPositionStats->ref >= REF_FEATURE_START && psPositionStats->ref < REF_FEATURE_START + REF_RANGE)
{
const char* msg;
buildFeature((FEATURE_STATS *)psPositionStats,
world_coord(structX), world_coord(structY), false);
FEATURE *result = buildFeature((FEATURE_STATS *)psPositionStats, world_coord(structX), world_coord(structY), false);
// Send a text message to all players, notifying them of
// the fact that we're cheating ourselves a new feature.
sasprintf((char**)&msg, _("Player %u is cheating (debug menu) him/herself a new feature: %s."), selectedPlayer, psPositionStats->pName);
sendTextMessage(msg, true);
Cheated = true;
// Notify the other hosts that we've just built ourselves a feature
sendMultiPlayerFeature(((FEATURE_STATS *)psPositionStats)->subType, world_coord(structX), world_coord(structY));
if (result)
{
const char* msg;
// Send a text message to all players, notifying them of the fact that we're cheating ourselves a new feature.
sasprintf((char**)&msg, _("Player %u is cheating (debug menu) him/herself a new feature: %s."),
selectedPlayer, psPositionStats->pName);
sendTextMessage(msg, true);
Cheated = true;
// Notify the other hosts that we've just built ourselves a feature
sendMultiPlayerFeature(result->psStats->subType, result->pos.x, result->pos.y, result->id);
}
}
else if (psPositionStats->ref >= REF_TEMPLATE_START &&
psPositionStats->ref < REF_TEMPLATE_START + REF_RANGE)

View File

@ -563,13 +563,14 @@ void technologyGiveAway(const STRUCTURE *pS)
* \param subType the type of feature to build
* \param x,y the coordinates to place the feature at
*/
void sendMultiPlayerFeature(FEATURE_TYPE subType, uint32_t x, uint32_t y)
void sendMultiPlayerFeature(FEATURE_TYPE subType, uint32_t x, uint32_t y, uint32_t id)
{
NETbeginEncode(NET_FEATURES, NET_ALL_PLAYERS);
{
NETenum(&subType);
NETuint32_t(&x);
NETuint32_t(&y);
NETuint32_t(&id);
}
NETend();
}
@ -577,7 +578,7 @@ void sendMultiPlayerFeature(FEATURE_TYPE subType, uint32_t x, uint32_t y)
void recvMultiPlayerFeature()
{
FEATURE_TYPE subType;
uint32_t x, y;
uint32_t x, y, id;
unsigned int i;
NETbeginDecode(NET_FEATURES);
@ -585,6 +586,7 @@ void recvMultiPlayerFeature()
NETenum(&subType);
NETuint32_t(&x);
NETuint32_t(&y);
NETuint32_t(&id);
}
NETend();
@ -595,8 +597,8 @@ void recvMultiPlayerFeature()
if (asFeatureStats[i].subType == subType)
{
// Create a feature of the specified type at the given location
buildFeature(&asFeatureStats[i], x, y, false);
FEATURE *result = buildFeature(&asFeatureStats[i], x, y, false);
result->id = id;
break;
}
}

View File

@ -39,7 +39,7 @@ extern void recvMultiPlayerRandomArtifacts (void);
extern void addMultiPlayerRandomArtifacts (uint8_t quantity, FEATURE_TYPE type);
extern void processMultiPlayerArtifacts (void);
extern void recvMultiPlayerFeature(void);
extern void sendMultiPlayerFeature(FEATURE_TYPE type, uint32_t x, uint32_t y);
extern void sendMultiPlayerFeature(FEATURE_TYPE type, uint32_t x, uint32_t y, uint32_t id);
extern void giftArtifact (UDWORD owner,UDWORD x,UDWORD y);
extern BOOL addOilDrum (uint8_t count);

View File

@ -1479,13 +1479,6 @@ static BOOL recvDestroyTemplate()
// send a destruct feature message.
BOOL SendDestroyFeature(FEATURE *pF)
{
// Since ANYPLAYER is supposed to be controlled by host only, that creates a issue when
// a MP player gets a feature, and it is 'ANYPLAYER' it would never send the destroy msg.
if (!myResponsibility(pF->player) || !(pF->player == ANYPLAYER))
{
return true;
}
debug(LOG_FEATURE, "p%d feature id %d destroyed (%s)", pF->player, pF->id, pF->psStats->pName);
NETbeginEncode(NET_FEATUREDEST, NET_ALL_PLAYERS);
NETuint32_t(&pF->id);
return NETend();
@ -1502,7 +1495,6 @@ BOOL recvDestroyFeature()
NETend();
pF = IdToFeature(id,ANYPLAYER);
if (pF == NULL)
{
debug(LOG_WARNING, "feature id %d not found? (sync error?)", id);