Show all features in debug menu. Patch by vexed. Closes ticket:4166

master
per 2014-01-26 22:54:19 +01:00
parent 8c0cb1bb23
commit 144c2e380d
6 changed files with 47 additions and 8 deletions

View File

@ -50,6 +50,11 @@ UDWORD getStructureStatSizeMax(STRUCTURE_STATS *Stats);
#define SMALL_STRUCT_SCALE (55)
#define MED_STRUCT_SCALE (25)//reduced from 30 to fit command centre in window
#define LARGE_STRUCT_SCALE (25)
#define ULTRA_SMALL_FEATURE_SCALE (146)
#define REALLY_SMALL_FEATURE_SCALE (116)
#define SMALL_FEATURE_SCALE (55)
#define MED_FEATURE_SCALE (26)
#define LARGE_FEATURE_SCALE (16)
#define TOWER_HEIGHT 100
UDWORD getStructureStatHeight(STRUCTURE_STATS *psStat);

View File

@ -1575,7 +1575,7 @@ INT_RETVAL intRunWidgets(void)
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);
sendMultiPlayerFeature(((FEATURE_STATS *)psPositionStats)->subType, world_coord(structX), world_coord(structY), generateNewObjectId());
sendMultiPlayerFeature(((FEATURE_STATS *)psPositionStats)->ref, world_coord(structX), world_coord(structY), generateNewObjectId());
}
else if (psPositionStats->ref >= REF_TEMPLATE_START &&
psPositionStats->ref < REF_TEMPLATE_START + REF_RANGE)

View File

@ -875,6 +875,10 @@ void IntStatsButton::display(int xOffset, int yOffset)
{
object = ImdObject::DroidTemplate(Stat);
}
else if (StatIsFeature(Stat))
{
object = ImdObject::Feature(Stat);
}
else
{
compID = StatIsComponent(Stat); // This failes for viper body.
@ -1537,6 +1541,31 @@ void IntFancyButton::displayIMD(Image image, ImdObject imdObject, int xOffset, i
scale = LARGE_STRUCT_SCALE;
}
}
else if (IMDType == IMDTYPE_FEATURE)
{
int imdRadius = ((iIMDShape *)Object)->radius;
if (imdRadius <= 40)
{
scale = ULTRA_SMALL_FEATURE_SCALE;
}
else if (imdRadius <= 64)
{
scale = REALLY_SMALL_FEATURE_SCALE;
}
else if (imdRadius <= 128)
{
scale = SMALL_FEATURE_SCALE;
}
else if (imdRadius <= 256)
{
scale = MED_FEATURE_SCALE;
}
else
{
scale = LARGE_FEATURE_SCALE;
}
}
else
{
Radius = ((iIMDShape *)Object)->sradius;
@ -1589,6 +1618,10 @@ void IntFancyButton::displayIMD(Image image, ImdObject imdObject, int xOffset, i
{
displayStructureStatButton((STRUCTURE_STATS *)Object, &Rotation, &Position, scale);
}
else if (IMDType == IMDTYPE_FEATURE)
{
displayIMDButton((iIMDShape *)Object, &Rotation, &Position, scale);
}
else
{
displayIMDButton((iIMDShape *)Object, &Rotation, &Position, scale);

View File

@ -45,6 +45,7 @@ enum ImdType
IMDTYPE_STRUCTURE,
IMDTYPE_RESEARCH,
IMDTYPE_STRUCTURESTAT,
IMDTYPE_FEATURE,
};
struct ImdObject
@ -56,6 +57,7 @@ struct ImdObject
static ImdObject Structure(BASE_OBJECT *p) { return ImdObject(p, IMDTYPE_STRUCTURE); }
static ImdObject Research(BASE_STATS *p) { return ImdObject(p, IMDTYPE_RESEARCH); }
static ImdObject StructureStat(BASE_STATS *p) { return ImdObject(p, IMDTYPE_STRUCTURESTAT); }
static ImdObject Feature(BASE_STATS *p) { FEATURE_STATS *fStat = (FEATURE_STATS *)p; return ImdObject(fStat->psImd, IMDTYPE_FEATURE); }
bool empty() const { return ptr == nullptr; }

View File

@ -616,11 +616,11 @@ 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, uint32_t id)
void sendMultiPlayerFeature(uint32_t ref, uint32_t x, uint32_t y, uint32_t id)
{
NETbeginEncode(NETgameQueue(selectedPlayer), GAME_DEBUG_ADD_FEATURE);
{
NETenum(&subType);
NETuint32_t(&ref);
NETuint32_t(&x);
NETuint32_t(&y);
NETuint32_t(&id);
@ -630,13 +630,12 @@ void sendMultiPlayerFeature(FEATURE_TYPE subType, uint32_t x, uint32_t y, uint32
void recvMultiPlayerFeature(NETQUEUE queue)
{
FEATURE_TYPE subType = FEAT_TREE; // Dummy initialisation.
uint32_t x, y, id;
uint32_t ref = 0xff, x =0, y = 0, id = 0;
unsigned int i;
NETbeginDecode(queue, GAME_DEBUG_ADD_FEATURE);
{
NETenum(&subType);
NETuint32_t(&ref);
NETuint32_t(&x);
NETuint32_t(&y);
NETuint32_t(&id);
@ -653,7 +652,7 @@ void recvMultiPlayerFeature(NETQUEUE queue)
for (i = 0; i < numFeatureStats; ++i)
{
// If we found the correct feature type
if (asFeatureStats[i].subType == subType)
if (asFeatureStats[i].ref == ref)
{
// Create a feature of the specified type at the given location
FEATURE *result = buildFeature(&asFeatureStats[i], x, y, false);

View File

@ -36,7 +36,7 @@ extern bool recvGift (NETQUEUE queue);
extern void technologyGiveAway (const STRUCTURE* pS);
extern void recvMultiPlayerFeature (NETQUEUE queue);
extern void sendMultiPlayerFeature(FEATURE_TYPE type, uint32_t x, uint32_t y, uint32_t id);
extern void sendMultiPlayerFeature(uint32_t ref, uint32_t x, uint32_t y, uint32_t id);
bool pickupArtefact(int toPlayer, int fromPlayer);
void giftPower (uint8_t from, uint8_t to, uint32_t amount, bool send);