From 144c2e380d7a999f9012804119d32b79b37dc39c Mon Sep 17 00:00:00 2001 From: per Date: Sun, 26 Jan 2014 22:54:19 +0100 Subject: [PATCH] Show all features in debug menu. Patch by vexed. Closes ticket:4166 --- src/component.h | 5 +++++ src/hci.cpp | 2 +- src/intdisplay.cpp | 33 +++++++++++++++++++++++++++++++++ src/intdisplay.h | 2 ++ src/multigifts.cpp | 11 +++++------ src/multigifts.h | 2 +- 6 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/component.h b/src/component.h index 189cfdace..b156f6e8d 100644 --- a/src/component.h +++ b/src/component.h @@ -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); diff --git a/src/hci.cpp b/src/hci.cpp index bf57c0411..99541d1bc 100644 --- a/src/hci.cpp +++ b/src/hci.cpp @@ -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) diff --git a/src/intdisplay.cpp b/src/intdisplay.cpp index a1a1e80f6..43d160093 100644 --- a/src/intdisplay.cpp +++ b/src/intdisplay.cpp @@ -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); diff --git a/src/intdisplay.h b/src/intdisplay.h index 6969b2bf3..9ff1b5a3e 100644 --- a/src/intdisplay.h +++ b/src/intdisplay.h @@ -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; } diff --git a/src/multigifts.cpp b/src/multigifts.cpp index eaec50fcf..2c022056e 100644 --- a/src/multigifts.cpp +++ b/src/multigifts.cpp @@ -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); diff --git a/src/multigifts.h b/src/multigifts.h index 2cfa7cf81..0bbc6f240 100644 --- a/src/multigifts.h +++ b/src/multigifts.h @@ -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);