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 16, 2017
1 parent 80d2fce commit 5aab20b
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 29 deletions.
2 changes: 2 additions & 0 deletions data/mp/stats/construction.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"buildPoints": 65, "buildPoints": 65,
"buildPower": 10, "buildPower": 10,
"constructPoints": 5, "constructPoints": 5,
"droidType": "CYBORG_CONSTRUCT",
"hitpoints": 35, "hitpoints": 35,
"id": "CyborgSpade", "id": "CyborgSpade",
"mountModel": "cybody.pie", "mountModel": "cybody.pie",
Expand All @@ -15,6 +16,7 @@
"buildPower": 17, "buildPower": 17,
"constructPoints": 8, "constructPoints": 8,
"designable": 1, "designable": 1,
"droidType": "DROID_CONSTRUCT",
"hitpoints": 25, "hitpoints": 25,
"id": "Spade1Mk1", "id": "Spade1Mk1",
"name": "Truck", "name": "Truck",
Expand Down
1 change: 1 addition & 0 deletions data/mp/stats/ecm.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"buildPoints": 100, "buildPoints": 100,
"buildPower": 20, "buildPower": 20,
"designable": 1, "designable": 1,
"droidType": "DROID_ECM",
"hitpoints": 200, "hitpoints": 200,
"id": "ECM1TurretMk1", "id": "ECM1TurretMk1",
"location": "TURRET", "location": "TURRET",
Expand Down
3 changes: 3 additions & 0 deletions data/mp/stats/repair.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"buildPoints": 100, "buildPoints": 100,
"buildPower": 35, "buildPower": 35,
"id": "CyborgRepair", "id": "CyborgRepair",
"droidType": "CYBORG_REPAIR",
"location": "TURRET", "location": "TURRET",
"model": "cy_rep.pie", "model": "cy_rep.pie",
"mountModel": "cybody.pie", "mountModel": "cybody.pie",
Expand All @@ -22,6 +23,7 @@
"buildPoints": 300, "buildPoints": 300,
"buildPower": 70, "buildPower": 70,
"designable": 1, "designable": 1,
"droidType": "DROID_REPAIR",
"id": "HeavyRepair", "id": "HeavyRepair",
"location": "TURRET", "location": "TURRET",
"model": "GNMREPR2.PIE", "model": "GNMREPR2.PIE",
Expand All @@ -35,6 +37,7 @@
"buildPoints": 250, "buildPoints": 250,
"buildPower": 50, "buildPower": 50,
"designable": 1, "designable": 1,
"droidType": "DROID_REPAIR",
"id": "LightRepair1", "id": "LightRepair1",
"location": "TURRET", "location": "TURRET",
"model": "GNMREPAR.PIE", "model": "GNMREPAR.PIE",
Expand Down
6 changes: 6 additions & 0 deletions data/mp/stats/sensor.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
}, },
"DefaultSensor1Mk1": { "DefaultSensor1Mk1": {
"id": "DefaultSensor1Mk1", "id": "DefaultSensor1Mk1",
"droidType": "DROID_SENSOR",
"location": "DEFAULT", "location": "DEFAULT",
"name": "*Default Sensor*", "name": "*Default Sensor*",
"power": 500, "power": 500,
Expand Down Expand Up @@ -68,6 +69,7 @@
"buildPoints": 25, "buildPoints": 25,
"buildPower": 5, "buildPower": 5,
"designable": 1, "designable": 1,
"droidType": "DROID_SENSOR",
"hitpoints": 200, "hitpoints": 200,
"id": "Sensor-WideSpec", "id": "Sensor-WideSpec",
"location": "TURRET", "location": "TURRET",
Expand Down Expand Up @@ -97,6 +99,7 @@
"buildPoints": 100, "buildPoints": 100,
"buildPower": 20, "buildPower": 20,
"designable": 1, "designable": 1,
"droidType": "DROID_SENSOR",
"hitpoints": 200, "hitpoints": 200,
"id": "SensorTurret1Mk1", "id": "SensorTurret1Mk1",
"location": "TURRET", "location": "TURRET",
Expand Down Expand Up @@ -126,6 +129,7 @@
"buildPoints": 100, "buildPoints": 100,
"buildPower": 20, "buildPower": 20,
"designable": 1, "designable": 1,
"droidType": "DROID_SENSOR",
"hitpoints": 200, "hitpoints": 200,
"id": "Sys-CBTurret01", "id": "Sys-CBTurret01",
"location": "TURRET", "location": "TURRET",
Expand Down Expand Up @@ -170,6 +174,7 @@
"buildPoints": 100, "buildPoints": 100,
"buildPower": 20, "buildPower": 20,
"designable": 1, "designable": 1,
"droidType": "DROID_SENSOR",
"hitpoints": 200, "hitpoints": 200,
"id": "Sys-VTOLCBTurret01", "id": "Sys-VTOLCBTurret01",
"location": "TURRET", "location": "TURRET",
Expand Down Expand Up @@ -199,6 +204,7 @@
"buildPoints": 100, "buildPoints": 100,
"buildPower": 20, "buildPower": 20,
"designable": 1, "designable": 1,
"droidType": "DROID_SENSOR",
"id": "Sys-VstrikeTurret01", "id": "Sys-VstrikeTurret01",
"location": "TURRET", "location": "TURRET",
"mountModel": "TRLSNSR1.PIE", "mountModel": "TRLSNSR1.PIE",
Expand Down
77 changes: 51 additions & 26 deletions src/stats.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -297,6 +297,57 @@ static void loadCompStats(WzConfig &json, COMPONENT_STATS *psStats, int index)
psStats->weight = json.value("weight", 0).toUInt(); psStats->weight = json.value("weight", 0).toUInt();
psStats->pBase->hitpoints = json.value("hitpoints", 0).toUInt(); psStats->pBase->hitpoints = json.value("hitpoints", 0).toUInt();
psStats->pBase->hitpointPct = json.value("hitpointPct", 100).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*/ /*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; 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; psStats->ref = REF_BODY_START + i;
if (!getBodySize(ini.value("size").toString().toUtf8().constData(), &psStats->size)) if (!getBodySize(ini.value("size").toString().toUtf8().constData(), &psStats->size))
{ {
Expand Down
6 changes: 3 additions & 3 deletions src/statsdef.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -260,14 +260,15 @@ struct BASE_STATS
struct COMPONENT_STATS : public BASE_STATS struct COMPONENT_STATS : public BASE_STATS
{ {
COMPONENT_STATS() : buildPower(0), buildPoints(0), weight(0), designable(false), pIMD(nullptr), 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 buildPower; /**< Power required to build the component */
UDWORD buildPoints; /**< Time required to build the component */ UDWORD buildPoints; /**< Time required to build the component */
UDWORD weight; /**< Component's weight */ UDWORD weight; /**< Component's weight */
bool designable; /**< flag to indicate whether this component can be used in the design screen */ bool designable; /**< flag to indicate whether this component can be used in the design screen */
iIMDShape *pIMD; /**< The IMD to draw for this component */ iIMDShape *pIMD; /**< The IMD to draw for this component */
COMPONENT_TYPE compType; COMPONENT_TYPE compType;
DROID_TYPE droidTypeOverride; ///< If not DROID_ANY, sets droid type.


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


struct BODY_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; pBase = &base;
for (int i = 0; i < MAX_PLAYERS; i++) pUpgrade[i] = &upgrade[i]; for (int i = 0; i < MAX_PLAYERS; i++) pUpgrade[i] = &upgrade[i];
} }


BODY_SIZE size; ///< How big the body is - affects how hit BODY_SIZE size; ///< How big the body is - affects how hit
UDWORD weaponSlots; ///< The number of weapon slots on the body 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 *> 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 std::vector<iIMDShape *> ppMoveIMDList; ///< list of IMDs to use when droid is moving - up to numPropulsionStats
Expand Down

0 comments on commit 5aab20b

Please sign in to comment.