Skip to content

Commit

Permalink
qtscript: Fix bugs giving cyborg engineers only legs, no body.
Browse files Browse the repository at this point in the history
The problem lies with the hardcoded 'droid type', which needs
to be set somehow. It used to be hardcoded in the body component,
but once those were merged, the type information was lost. Now
with this patch they are supplied by turret components instead.
In the longer run, we should just remove reliance upon 'droid type'
altogether.
  • Loading branch information
perim committed Jul 17, 2017
1 parent 80d2fce commit 490b91d
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 29 deletions.
2 changes: 2 additions & 0 deletions data/mp/stats/construction.json
Expand Up @@ -3,6 +3,7 @@
"buildPoints": 65,
"buildPower": 10,
"constructPoints": 5,
"droidType": "CYBORG_CONSTRUCT",
"hitpoints": 35,
"id": "CyborgSpade",
"mountModel": "cybody.pie",
Expand All @@ -15,6 +16,7 @@
"buildPower": 17,
"constructPoints": 8,
"designable": 1,
"droidType": "DROID_CONSTRUCT",
"hitpoints": 25,
"id": "Spade1Mk1",
"name": "Truck",
Expand Down
1 change: 1 addition & 0 deletions data/mp/stats/ecm.json
Expand Up @@ -3,6 +3,7 @@
"buildPoints": 100,
"buildPower": 20,
"designable": 1,
"droidType": "DROID_ECM",
"hitpoints": 200,
"id": "ECM1TurretMk1",
"location": "TURRET",
Expand Down
3 changes: 3 additions & 0 deletions data/mp/stats/repair.json
Expand Up @@ -10,6 +10,7 @@
"buildPoints": 100,
"buildPower": 35,
"id": "CyborgRepair",
"droidType": "CYBORG_REPAIR",
"location": "TURRET",
"model": "cy_rep.pie",
"mountModel": "cybody.pie",
Expand All @@ -22,6 +23,7 @@
"buildPoints": 300,
"buildPower": 70,
"designable": 1,
"droidType": "DROID_REPAIR",
"id": "HeavyRepair",
"location": "TURRET",
"model": "GNMREPR2.PIE",
Expand All @@ -35,6 +37,7 @@
"buildPoints": 250,
"buildPower": 50,
"designable": 1,
"droidType": "DROID_REPAIR",
"id": "LightRepair1",
"location": "TURRET",
"model": "GNMREPAR.PIE",
Expand Down
6 changes: 6 additions & 0 deletions data/mp/stats/sensor.json
Expand Up @@ -27,6 +27,7 @@
},
"DefaultSensor1Mk1": {
"id": "DefaultSensor1Mk1",
"droidType": "DROID_SENSOR",
"location": "DEFAULT",
"name": "*Default Sensor*",
"power": 500,
Expand Down Expand Up @@ -68,6 +69,7 @@
"buildPoints": 25,
"buildPower": 5,
"designable": 1,
"droidType": "DROID_SENSOR",
"hitpoints": 200,
"id": "Sensor-WideSpec",
"location": "TURRET",
Expand Down Expand Up @@ -97,6 +99,7 @@
"buildPoints": 100,
"buildPower": 20,
"designable": 1,
"droidType": "DROID_SENSOR",
"hitpoints": 200,
"id": "SensorTurret1Mk1",
"location": "TURRET",
Expand Down Expand Up @@ -126,6 +129,7 @@
"buildPoints": 100,
"buildPower": 20,
"designable": 1,
"droidType": "DROID_SENSOR",
"hitpoints": 200,
"id": "Sys-CBTurret01",
"location": "TURRET",
Expand Down Expand Up @@ -170,6 +174,7 @@
"buildPoints": 100,
"buildPower": 20,
"designable": 1,
"droidType": "DROID_SENSOR",
"hitpoints": 200,
"id": "Sys-VTOLCBTurret01",
"location": "TURRET",
Expand Down Expand Up @@ -199,6 +204,7 @@
"buildPoints": 100,
"buildPower": 20,
"designable": 1,
"droidType": "DROID_SENSOR",
"id": "Sys-VstrikeTurret01",
"location": "TURRET",
"mountModel": "TRLSNSR1.PIE",
Expand Down
4 changes: 4 additions & 0 deletions src/qtscriptfuncs.cpp
Expand Up @@ -1753,6 +1753,10 @@ static DROID_TEMPLATE *makeTemplate(int player, const QString &templName, QScrip
delete psTemplate;
return nullptr;
}
if (psComp->droidTypeOverride != DROID_ANY)
{
psTemplate->droidType = psComp->droidTypeOverride; // set droidType based on component
}
if (psComp->compType == COMP_WEAPON)
{
for (int i = 0; i < numTurrets; i++) // may be multi-weapon
Expand Down
77 changes: 51 additions & 26 deletions src/stats.cpp
Expand Up @@ -297,6 +297,57 @@ static void loadCompStats(WzConfig &json, COMPONENT_STATS *psStats, int index)
psStats->weight = json.value("weight", 0).toUInt();
psStats->pBase->hitpoints = json.value("hitpoints", 0).toUInt();
psStats->pBase->hitpointPct = json.value("hitpointPct", 100).toUInt();

QString dtype = json.value("droidType", "DROID").toString();
psStats->droidTypeOverride = DROID_DEFAULT;
if (dtype.compare("PERSON") == 0)
{
psStats->droidTypeOverride = DROID_PERSON;
}
else if (dtype.compare("TRANSPORTER") == 0)
{
psStats->droidTypeOverride = DROID_TRANSPORTER;
}
else if (dtype.compare("CYBORG") == 0)
{
psStats->droidTypeOverride = DROID_CYBORG;
}
else if (dtype.compare("CYBORG_SUPER") == 0)
{
psStats->droidTypeOverride = DROID_CYBORG_SUPER;
}
else if (dtype.compare("CYBORG_CONSTRUCT") == 0)
{
psStats->droidTypeOverride = DROID_CYBORG_CONSTRUCT;
}
else if (dtype.compare("CYBORG_REPAIR") == 0)
{
psStats->droidTypeOverride = DROID_CYBORG_REPAIR;
}
else if (dtype.compare("DROID_CONSTRUCT") == 0)
{
psStats->droidTypeOverride = DROID_CONSTRUCT;
}
else if (dtype.compare("DROID_ECM") == 0)
{
psStats->droidTypeOverride = DROID_ECM;
}
else if (dtype.compare("DROID_COMMAND") == 0)
{
psStats->droidTypeOverride = DROID_COMMAND;
}
else if (dtype.compare("DROID_SENSOR") == 0)
{
psStats->droidTypeOverride = DROID_SENSOR;
}
else if (dtype.compare("DROID_REPAIR") == 0)
{
psStats->droidTypeOverride = DROID_REPAIR;
}
else if (dtype.compare("DROID") != 0)
{
debug(LOG_ERROR, "Unrecognized droidType %s", dtype.toUtf8().constData());
}
}

/*Load the weapon stats from the file exported from Access*/
Expand Down Expand Up @@ -533,32 +584,6 @@ bool loadBodyStats(const char *pFileName)
{
psStats->upgrade[j] = psStats->base;
}
QString dtype = ini.value("droidType", "DROID").toString();
psStats->droidTypeOverride = DROID_DEFAULT;
if (dtype.compare("PERSON") == 0)
{
psStats->droidTypeOverride = DROID_PERSON;
}
else if (dtype.compare("TRANSPORTER") == 0)
{
psStats->droidTypeOverride = DROID_TRANSPORTER;
}
else if (dtype.compare("CYBORG") == 0)
{
psStats->droidTypeOverride = DROID_CYBORG;
}
else if (dtype.compare("CYBORG_SUPER") == 0)
{
psStats->droidTypeOverride = DROID_CYBORG_SUPER;
}
else if (dtype.compare("CYBORG_CONSTRUCT") == 0)
{
psStats->droidTypeOverride = DROID_CYBORG_CONSTRUCT;
}
else if (dtype.compare("CYBORG_REPAIR") == 0)
{
psStats->droidTypeOverride = DROID_CYBORG_REPAIR;
}
psStats->ref = REF_BODY_START + i;
if (!getBodySize(ini.value("size").toString().toUtf8().constData(), &psStats->size))
{
Expand Down
6 changes: 3 additions & 3 deletions src/statsdef.h
Expand Up @@ -260,14 +260,15 @@ struct BASE_STATS
struct COMPONENT_STATS : public BASE_STATS
{
COMPONENT_STATS() : buildPower(0), buildPoints(0), weight(0), designable(false), pIMD(nullptr),
compType(COMP_NUMCOMPONENTS) {}
compType(COMP_NUMCOMPONENTS), droidTypeOverride(DROID_ANY) {}

UDWORD buildPower; /**< Power required to build the component */
UDWORD buildPoints; /**< Time required to build the component */
UDWORD weight; /**< Component's weight */
bool designable; /**< flag to indicate whether this component can be used in the design screen */
iIMDShape *pIMD; /**< The IMD to draw for this component */
COMPONENT_TYPE compType;
DROID_TYPE droidTypeOverride; ///< If not DROID_ANY, sets droid type.

struct UPGRADE
{
Expand Down Expand Up @@ -471,15 +472,14 @@ struct BRAIN_STATS : public COMPONENT_STATS

struct BODY_STATS : public COMPONENT_STATS
{
BODY_STATS() : size(SIZE_NUM), weaponSlots(0), droidTypeOverride(DROID_ANY)
BODY_STATS() : size(SIZE_NUM), weaponSlots(0)
{
pBase = &base;
for (int i = 0; i < MAX_PLAYERS; i++) pUpgrade[i] = &upgrade[i];
}

BODY_SIZE size; ///< How big the body is - affects how hit
UDWORD weaponSlots; ///< The number of weapon slots on the body
DROID_TYPE droidTypeOverride; // if not DROID_ANY, sets droid type

std::vector<iIMDShape *> ppIMDList; ///< list of IMDs to use for propulsion unit - up to numPropulsionStats
std::vector<iIMDShape *> ppMoveIMDList; ///< list of IMDs to use when droid is moving - up to numPropulsionStats
Expand Down

0 comments on commit 490b91d

Please sign in to comment.