* When cheating ourselvs new features & droids (in the CTRL+O debug menu) make sure to notify other hosts & players of this

Patch #920 with some modifications by me to make it compile and slightly simpler


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3399 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-01-06 21:55:23 +00:00
parent 53abc0a73b
commit dfc4e101ad
4 changed files with 62 additions and 0 deletions

View File

@ -58,6 +58,7 @@
#include "mission.h"
#include "multimenu.h"
#include "multiplay.h"
#include "multigifts.h"
#include "radar.h"
#include "research.h"
#include "scriptcb.h"
@ -2125,8 +2126,17 @@ INT_RETVAL intRunWidgets(void)
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);
// 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);
// Notify the other hosts that we've just built ourselves a feature
sendMultiPlayerFeature(((FEATURE_STATS *)psPositionStats)->subType, world_coord(structX), world_coord(structY));
}
else if (psPositionStats->ref >= REF_TEMPLATE_START &&
psPositionStats->ref < REF_TEMPLATE_START + REF_RANGE)
@ -2136,7 +2146,13 @@ INT_RETVAL intRunWidgets(void)
selectedPlayer, FALSE);
if (psDroid)
{
const char* msg;
addDroid(psDroid, apsDroidLists);
// Send a text message to all players, notifying them of
// the fact that we're cheating ourselves a new droid.
sasprintf((char**)&msg, _("Player %u is cheating (debug menu) him/herself a new droid: %s."), selectedPlayer, psDroid->aName);
sendTextMessage(msg, TRUE);
}
}
editPosMode = IED_NOPOS;

View File

@ -631,7 +631,48 @@ void addLoserGifts(void)
}
}
/** Sends a build order for the given feature type to all players
* \param type 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)
{
NETbeginEncode(NET_FEATURES, NET_ALL_PLAYERS);
{
NETenum(&subType);
NETuint32_t(&x);
NETuint32_t(&y);
}
NETend();
}
void recvMultiPlayerFeature()
{
FEATURE_TYPE subType;
uint32_t x, y;
unsigned int i;
NETbeginDecode();
{
NETenum(&subType);
NETuint32_t(&x);
NETuint32_t(&y);
}
NETend();
// Find the feature stats list that contains the feature type we want to build
for (i = 0; i < numFeatureStats; ++i)
{
// If we found the correct feature type
if (asFeatureStats[i].subType != subType)
{
// Create a feature of the specified type at the given location
buildFeature(&asFeatureStats[i], x, y, FALSE);
break;
}
}
}
///////////////////////////////////////////////////////////////////////////////
// splatter artifact gifts randomly about.
void addMultiPlayerRandomArtifacts(uint8_t quantity, FEATURE_TYPE type)

View File

@ -37,6 +37,8 @@ extern void technologyGiveAway (const STRUCTURE* pS);
extern void recvMultiPlayerRandomArtifacts ();
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 giftArtifact (UDWORD owner,UDWORD x,UDWORD y);
extern BOOL addOilDrum (uint8_t count);

View File

@ -752,6 +752,9 @@ BOOL recvMessage(void)
case NET_ARTIFACTS:
recvMultiPlayerRandomArtifacts();
break;
case NET_FEATURES:
recvMultiPlayerFeature();
break;
case NET_ALLIANCE:
recvAlliance(TRUE);
break;