Fix possible crash bug, remove useless casts to const chars, and remove duplicate macro getStatName().

master
per 2013-05-13 23:11:34 +02:00
parent 7fae836060
commit e7e643c05b
11 changed files with 60 additions and 63 deletions

View File

@ -34,13 +34,12 @@
#include "lib/ivis_opengl/textdraw.h"
W_LABINIT::W_LABINIT()
: pText(NULL)
, FontID(font_regular)
: FontID(font_regular)
{}
W_LABEL::W_LABEL(W_LABINIT const *init)
: WIDGET(init, WIDG_LABEL)
, aText(QString::fromUtf8(init->pText))
, aText(init->pText)
, FontID(init->FontID)
, pTip(init->pTip)
, fontColour(WZCOL_FORM_TEXT)

View File

@ -133,7 +133,7 @@ struct W_LABINIT : public W_INIT
{
W_LABINIT();
const char *pText; ///< label text
QString pText; ///< label text
QString pTip; ///< Tool tip for the label.
enum iV_fonts FontID; ///< ID of the IVIS font to use for this widget.
};

View File

@ -1196,7 +1196,7 @@ static bool _intSetSystemForm(COMPONENT_STATS *psStats)
sFormInit.y = DES_BARFORMY;
sFormInit.width = DES_BARFORMWIDTH; //COMPBUTWIDTH;
sFormInit.height = DES_BARFORMHEIGHT; //COMPBUTHEIGHT;
sFormInit.pTip = getStatName(psStats); /* set form tip to stats string */
sFormInit.pTip = psStats->name; /* set form tip to stats string */
sFormInit.pUserData = psStats; /* store component stats */
sFormInit.pDisplay = intDisplayStatForm;
if (!widgAddForm(psWScreen, &sFormInit))
@ -1540,7 +1540,7 @@ static bool intSetPropulsionForm(PROPULSION_STATS *psStats)
sFormInit.y = DES_BARFORMY;
sFormInit.width = DES_BARFORMWIDTH; //DES_COMPBUTWIDTH;
sFormInit.height = DES_BARFORMHEIGHT; //DES_COMPBUTHEIGHT;
sFormInit.pTip = getStatName(psStats); /* set form tip to stats string */
sFormInit.pTip = psStats->name; /* set form tip to stats string */
sFormInit.pDisplay = intDisplayStatForm;
if (!widgAddForm(psWScreen, &sFormInit))
{
@ -2032,7 +2032,7 @@ static void intSetSystemStats(COMPONENT_STATS *psStats)
ASSERT_OR_RETURN(, psStats != NULL, "Invalid stats pointer");
/* set form tip to stats string */
widgSetTip(psWScreen, IDDES_SYSTEMFORM, getStatName(psStats));
widgSetTip(psWScreen, IDDES_SYSTEMFORM, psStats->name);
/* set form stats for later display in intDisplayStatForm */
psForm = (W_FORM *) widgGetFromID(psWScreen, IDDES_SYSTEMFORM);
@ -2374,7 +2374,7 @@ static void intSetBodyStats(BODY_STATS *psStats)
"stats ref is out of range");
/* set form tip to stats string */
widgSetTip(psWScreen, IDDES_BODYFORM, getStatName(psStats));
widgSetTip(psWScreen, IDDES_BODYFORM, psStats->name);
/* armour */
//do kinetic armour
@ -2677,7 +2677,7 @@ static void intSetPropulsionStats(PROPULSION_STATS *psStats)
(psStats->ref < REF_PROPULSION_START + REF_RANGE), "stats ref is out of range");
/* set form tip to stats string */
widgSetTip(psWScreen, IDDES_PROPFORM, getStatName(psStats));
widgSetTip(psWScreen, IDDES_PROPFORM, psStats->name);
/* set form stats for later display in intDisplayStatForm */
psForm = (W_FORM *) widgGetFromID(psWScreen, IDDES_PROPFORM);

View File

@ -148,8 +148,7 @@ public:
virtual void display(int xOffset, int yOffset);
void setStats(BASE_STATS *stats) { Stat = stats; }
void setStatsAndTip(BASE_STATS *stats) { setStats(stats); setTip(getStatName(Stat)); }
void setStatsAndTip(DROID_TEMPLATE *stats) { setStats(stats); setTip(getName(stats)); }
void setStatsAndTip(BASE_STATS *stats) { setStats(stats); setTip(stats->name); }
protected:
BASE_STATS *Stat;

View File

@ -315,7 +315,7 @@ static bool intAddMessageForm(bool playCurrent)
psResearch = getResearchForMsg((VIEWDATA *)psMessage->pViewData);
if (psResearch)
{
button->setTip(getStatName(psResearch));
button->setTip(psResearch->name);
}
else
{
@ -450,7 +450,7 @@ bool intAddMessageView(MESSAGE * psMessage)
ASSERT( psResearch!=NULL,"Research not found" );
//sLabInit.pText=psResearch->pName;
sLabInit.pText = getStatName(psResearch);
sLabInit.pText = psResearch->name;
sLabInit.FontID = font_regular;
if (!widgAddLabel(psWScreen, &sLabInit))

View File

@ -60,7 +60,7 @@ static void printComponentInfo(const COMPONENT_STATS* psStats)
{
CONPRINTF(ConsoleString,(ConsoleString,"%s ref %d\n"
" bPwr %d bPnts %d wt %d bdy %d imd %p\n",
getStatName(psStats), psStats->ref, psStats->buildPower,
getName(psStats), psStats->ref, psStats->buildPower,
psStats->buildPoints, psStats->weight, psStats->body,
psStats->pIMD));
}

View File

@ -867,7 +867,7 @@ static QScriptValue js_getWeaponInfo(QScriptContext *context, QScriptEngine *eng
WEAPON_STATS *psStats = asWeaponStats + idx;
QScriptValue info = engine->newObject();
info.setProperty("id", id);
info.setProperty("name", getStatName(psStats));
info.setProperty("name", psStats->name);
info.setProperty("impactClass", psStats->weaponClass == WC_KINETIC ? "KINETIC" : "HEAT");
info.setProperty("damage", psStats->base.damage);
info.setProperty("firePause", psStats->base.firePause);
@ -4084,7 +4084,7 @@ bool registerFunctions(QScriptEngine *engine, QString scriptName)
body.setProperty("Size", psStats->size, QScriptValue::ReadOnly | QScriptValue::Undeletable);
body.setProperty("WeaponSlots", psStats->weaponSlots, QScriptValue::ReadOnly | QScriptValue::Undeletable);
body.setProperty("BodyClass", psStats->bodyClass, QScriptValue::ReadOnly | QScriptValue::Undeletable);
bodybase.setProperty(getStatName(psStats), body, QScriptValue::ReadOnly | QScriptValue::Undeletable);
bodybase.setProperty(psStats->name, body, QScriptValue::ReadOnly | QScriptValue::Undeletable);
}
stats.setProperty("Body", bodybase, QScriptValue::ReadOnly | QScriptValue::Undeletable);
//== \item[Sensor] Sensor turrets
@ -4099,7 +4099,7 @@ bool registerFunctions(QScriptEngine *engine, QString scriptName)
sensor.setProperty("BuildTime", psStats->buildPoints, QScriptValue::ReadOnly | QScriptValue::Undeletable);
sensor.setProperty("HitPoints", psStats->body, QScriptValue::ReadOnly | QScriptValue::Undeletable);
sensor.setProperty("Range", psStats->base.range, QScriptValue::ReadOnly | QScriptValue::Undeletable);
sensorbase.setProperty(getStatName(psStats), sensor, QScriptValue::ReadOnly | QScriptValue::Undeletable);
sensorbase.setProperty(psStats->name, sensor, QScriptValue::ReadOnly | QScriptValue::Undeletable);
}
stats.setProperty("Sensor", sensorbase, QScriptValue::ReadOnly | QScriptValue::Undeletable);
//== \item[ECM] ECM (Electronic Counter-Measure) turrets
@ -4114,7 +4114,7 @@ bool registerFunctions(QScriptEngine *engine, QString scriptName)
ecm.setProperty("BuildTime", psStats->buildPoints, QScriptValue::ReadOnly | QScriptValue::Undeletable);
ecm.setProperty("HitPoints", psStats->body, QScriptValue::ReadOnly | QScriptValue::Undeletable);
ecm.setProperty("Range", psStats->base.range, QScriptValue::ReadOnly | QScriptValue::Undeletable);
ecmbase.setProperty(getStatName(psStats), ecm, QScriptValue::ReadOnly | QScriptValue::Undeletable);
ecmbase.setProperty(psStats->name, ecm, QScriptValue::ReadOnly | QScriptValue::Undeletable);
}
stats.setProperty("ECM", ecmbase, QScriptValue::ReadOnly | QScriptValue::Undeletable);
//== \item[Repair] Repair turrets (not used, incidentially, for repair centers)
@ -4129,7 +4129,7 @@ bool registerFunctions(QScriptEngine *engine, QString scriptName)
repair.setProperty("BuildTime", psStats->buildPoints, QScriptValue::ReadOnly | QScriptValue::Undeletable);
repair.setProperty("HitPoints", psStats->body, QScriptValue::ReadOnly | QScriptValue::Undeletable);
repair.setProperty("RepairPoints", psStats->base.repairPoints, QScriptValue::ReadOnly | QScriptValue::Undeletable);
repairbase.setProperty(getStatName(psStats), repair, QScriptValue::ReadOnly | QScriptValue::Undeletable);
repairbase.setProperty(psStats->name, repair, QScriptValue::ReadOnly | QScriptValue::Undeletable);
}
stats.setProperty("Repair", repairbase, QScriptValue::ReadOnly | QScriptValue::Undeletable);
//== \item[Construct] Constructor turrets (eg for trucks)
@ -4144,7 +4144,7 @@ bool registerFunctions(QScriptEngine *engine, QString scriptName)
con.setProperty("BuildTime", psStats->buildPoints, QScriptValue::ReadOnly | QScriptValue::Undeletable);
con.setProperty("HitPoints", psStats->body, QScriptValue::ReadOnly | QScriptValue::Undeletable);
con.setProperty("ConstructorPoints", psStats->base.constructPoints, QScriptValue::ReadOnly | QScriptValue::Undeletable);
conbase.setProperty(getStatName(psStats), con, QScriptValue::ReadOnly | QScriptValue::Undeletable);
conbase.setProperty(psStats->name, con, QScriptValue::ReadOnly | QScriptValue::Undeletable);
}
stats.setProperty("Construct", conbase, QScriptValue::ReadOnly | QScriptValue::Undeletable);
//== \item[Weapon] Weapon turrets
@ -4178,7 +4178,7 @@ bool registerFunctions(QScriptEngine *engine, QString scriptName)
weap.setProperty("RepeatClass", getWeaponSubClass(psStats->periodicalDamageWeaponSubClass),
QScriptValue::ReadOnly | QScriptValue::Undeletable);
weap.setProperty("FireOnMove", psStats->fireOnMove, QScriptValue::ReadOnly | QScriptValue::Undeletable);
wbase.setProperty(getStatName(psStats), weap, QScriptValue::ReadOnly | QScriptValue::Undeletable);
wbase.setProperty(psStats->name, weap, QScriptValue::ReadOnly | QScriptValue::Undeletable);
}
stats.setProperty("Weapon", wbase, QScriptValue::ReadOnly | QScriptValue::Undeletable);
//== \item[WeaponClass] Defined weapon classes
@ -4217,7 +4217,7 @@ bool registerFunctions(QScriptEngine *engine, QString scriptName)
strct.setProperty("Thermal", psStats->base.thermal, QScriptValue::ReadOnly | QScriptValue::Undeletable);
strct.setProperty("HitPoints", psStats->base.hitpoints, QScriptValue::ReadOnly | QScriptValue::Undeletable);
strct.setProperty("Resistance", psStats->base.resistance, QScriptValue::ReadOnly | QScriptValue::Undeletable);
structbase.setProperty(getStatName(psStats), strct, QScriptValue::ReadOnly | QScriptValue::Undeletable);
structbase.setProperty(psStats->name, strct, QScriptValue::ReadOnly | QScriptValue::Undeletable);
}
stats.setProperty("Building", structbase, QScriptValue::ReadOnly | QScriptValue::Undeletable);
}
@ -4244,7 +4244,7 @@ bool registerFunctions(QScriptEngine *engine, QString scriptName)
setStatsFunc(body, engine, "Armour", i, COMP_BODY, j, psStats->upgrade[i].armour);
setStatsFunc(body, engine, "Thermal", i, COMP_BODY, j, psStats->upgrade[i].thermal);
setStatsFunc(body, engine, "Resistance", i, COMP_BODY, j, psStats->upgrade[i].resistance);
bodybase.setProperty(getStatName(psStats), body, QScriptValue::ReadOnly | QScriptValue::Undeletable);
bodybase.setProperty(psStats->name, body, QScriptValue::ReadOnly | QScriptValue::Undeletable);
}
node.setProperty("Body", bodybase, QScriptValue::ReadOnly | QScriptValue::Undeletable);
//== \item[Sensor] Sensor turrets
@ -4254,7 +4254,7 @@ bool registerFunctions(QScriptEngine *engine, QString scriptName)
SENSOR_STATS *psStats = asSensorStats + j;
QScriptValue sensor = engine->newObject();
setStatsFunc(sensor, engine, "Range", i, COMP_SENSOR, j, psStats->upgrade[i].range);
sensorbase.setProperty(getStatName(psStats), sensor, QScriptValue::ReadOnly | QScriptValue::Undeletable);
sensorbase.setProperty(psStats->name, sensor, QScriptValue::ReadOnly | QScriptValue::Undeletable);
}
node.setProperty("Sensor", sensorbase, QScriptValue::ReadOnly | QScriptValue::Undeletable);
//== \item[ECM] ECM (Electronic Counter-Measure) turrets
@ -4264,7 +4264,7 @@ bool registerFunctions(QScriptEngine *engine, QString scriptName)
ECM_STATS *psStats = asECMStats + j;
QScriptValue ecm = engine->newObject();
setStatsFunc(ecm, engine, "Range", i, COMP_ECM, j, psStats->upgrade[i].range);
ecmbase.setProperty(getStatName(psStats), ecm, QScriptValue::ReadOnly | QScriptValue::Undeletable);
ecmbase.setProperty(psStats->name, ecm, QScriptValue::ReadOnly | QScriptValue::Undeletable);
}
node.setProperty("ECM", ecmbase, QScriptValue::ReadOnly | QScriptValue::Undeletable);
//== \item[Repair] Repair turrets (not used, incidentially, for repair centers)
@ -4274,7 +4274,7 @@ bool registerFunctions(QScriptEngine *engine, QString scriptName)
REPAIR_STATS *psStats = asRepairStats + j;
QScriptValue repair = engine->newObject();
setStatsFunc(repair, engine, "RepairPoints", i, COMP_REPAIRUNIT, j, psStats->upgrade[i].repairPoints);
repairbase.setProperty(getStatName(psStats), repair, QScriptValue::ReadOnly | QScriptValue::Undeletable);
repairbase.setProperty(psStats->name, repair, QScriptValue::ReadOnly | QScriptValue::Undeletable);
}
node.setProperty("Repair", repairbase, QScriptValue::ReadOnly | QScriptValue::Undeletable);
//== \item[Construct] Constructor turrets (eg for trucks)
@ -4284,7 +4284,7 @@ bool registerFunctions(QScriptEngine *engine, QString scriptName)
CONSTRUCT_STATS *psStats = asConstructStats + j;
QScriptValue con = engine->newObject();
setStatsFunc(con, engine, "ConstructorPoints", i, COMP_CONSTRUCT, j, psStats->upgrade[i].constructPoints);
conbase.setProperty(getStatName(psStats), con, QScriptValue::ReadOnly | QScriptValue::Undeletable);
conbase.setProperty(psStats->name, con, QScriptValue::ReadOnly | QScriptValue::Undeletable);
}
node.setProperty("Construct", conbase, QScriptValue::ReadOnly | QScriptValue::Undeletable);
//== \item[Weapon] Weapon turrets
@ -4305,7 +4305,7 @@ bool registerFunctions(QScriptEngine *engine, QString scriptName)
setStatsFunc(weap, engine, "RepeatDamage", i, COMP_WEAPON, j, psStats->upgrade[i].periodicalDamage);
setStatsFunc(weap, engine, "RepeatTime", i, COMP_WEAPON, j, psStats->upgrade[i].periodicalDamageTime);
setStatsFunc(weap, engine, "RepeatRadius", i, COMP_WEAPON, j, psStats->upgrade[i].periodicalDamageRadius);
wbase.setProperty(getStatName(psStats), weap, QScriptValue::ReadOnly | QScriptValue::Undeletable);
wbase.setProperty(psStats->name, weap, QScriptValue::ReadOnly | QScriptValue::Undeletable);
}
node.setProperty("Weapon", wbase, QScriptValue::ReadOnly | QScriptValue::Undeletable);
//== \item[Building] Buildings
@ -4323,7 +4323,7 @@ bool registerFunctions(QScriptEngine *engine, QString scriptName)
setStatsFunc(strct, engine, "Resistance", i, SCRCB_ELW, j, psStats->upgrade[i].resistance);
setStatsFunc(strct, engine, "Thermal", i, SCRCB_HEA, j, psStats->upgrade[i].thermal);
setStatsFunc(strct, engine, "HitPoints", i, SCRCB_HIT, j, psStats->upgrade[i].hitpoints);
structbase.setProperty(getStatName(psStats), strct, QScriptValue::ReadOnly | QScriptValue::Undeletable);
structbase.setProperty(psStats->name, strct, QScriptValue::ReadOnly | QScriptValue::Undeletable);
}
node.setProperty("Building", structbase, QScriptValue::ReadOnly | QScriptValue::Undeletable);
// Finally

View File

@ -2706,7 +2706,7 @@ bool scrSetDefaultSensor(void)
if (asSensorStats[sensorInc].location != LOC_DEFAULT)
{
ASSERT(false, "This sensor is not a default one - %s", getStatName(&asSensorStats[sensorInc]));
ASSERT(false, "This sensor is not a default one - %s", getName(&asSensorStats[sensorInc]));
return false;
}
@ -2740,7 +2740,7 @@ bool scrSetDefaultECM(void)
//check that this ecm is a default ecm
if (asECMStats[ecmInc].location != LOC_DEFAULT)
{
ASSERT(false, "This ecm is not a default one - %s", getStatName(&asECMStats[ecmInc]));
ASSERT(false, "This ecm is not a default one - %s", getName(&asECMStats[ecmInc]));
return false;
}
@ -2774,7 +2774,7 @@ bool scrSetDefaultRepair(void)
//check that this repair is a default repair
if (asRepairStats[repairInc].location != LOC_DEFAULT)
{
ASSERT(false, "This repair is not a default one - %s", getStatName(&asRepairStats[repairInc]));
ASSERT(false, "This repair is not a default one - %s", getName(&asRepairStats[repairInc]));
return false;
}

View File

@ -283,7 +283,7 @@ static iIMDShape *statsGetIMD(WzConfig &ini, BASE_STATS *psStats, QString key)
QString model = ini.value(key).toString();
retval = (iIMDShape *)resGetData("IMD", model.toUtf8().constData());
ASSERT(retval != NULL, "Cannot find the PIE model %s for stat %s in %s",
model.toUtf8().constData(), getStatName(psStats), ini.fileName().toUtf8().constData());
model.toUtf8().constData(), getName(psStats), ini.fileName().toUtf8().constData());
}
return retval;
}
@ -383,7 +383,7 @@ bool loadWeaponStats(const char *pFileName)
//set the weapon class
if (!getWeaponClass(ini.value("weaponClass").toString(), &psStats->weaponClass))
{
debug(LOG_ERROR, "Invalid weapon class for weapon %s - assuming KINETIC", getStatName(psStats));
debug(LOG_ERROR, "Invalid weapon class for weapon %s - assuming KINETIC", getName(psStats));
psStats->weaponClass = WC_KINETIC;
}
@ -410,7 +410,7 @@ bool loadWeaponStats(const char *pFileName)
//set the weapon effect
if (!getWeaponEffect(ini.value("weaponEffect").toString().toUtf8().constData(), &psStats->weaponEffect))
{
debug(LOG_FATAL, "loadWepaonStats: Invalid weapon effect for weapon %s", getStatName(psStats));
debug(LOG_FATAL, "loadWepaonStats: Invalid weapon effect for weapon %s", getName(psStats));
return false;
}
@ -423,7 +423,7 @@ bool loadWeaponStats(const char *pFileName)
}
else if (!getWeaponClass(periodicalDamageWeaponClass, &psStats->periodicalDamageWeaponClass))
{
debug(LOG_ERROR, "Invalid periodicalDamageWeaponClass for weapon %s - assuming same class as weapon", getStatName(psStats));
debug(LOG_ERROR, "Invalid periodicalDamageWeaponClass for weapon %s - assuming same class as weapon", getName(psStats));
psStats->periodicalDamageWeaponClass = psStats->weaponClass;
}
@ -436,7 +436,7 @@ bool loadWeaponStats(const char *pFileName)
}
else if (!getWeaponSubClass(periodicalDamageWeaponSubClass.toUtf8().data(), &psStats->periodicalDamageWeaponSubClass))
{
debug(LOG_ERROR, "Invalid periodicalDamageWeaponSubClass for weapon %s - assuming same subclass as weapon", getStatName(psStats));
debug(LOG_ERROR, "Invalid periodicalDamageWeaponSubClass for weapon %s - assuming same subclass as weapon", getName(psStats));
psStats->periodicalDamageWeaponSubClass = psStats->weaponSubClass;
}
@ -449,7 +449,7 @@ bool loadWeaponStats(const char *pFileName)
}
else if (!getWeaponEffect(periodicalDamageWeaponEffect.toUtf8().data(), &psStats->periodicalDamageWeaponEffect))
{
debug(LOG_ERROR, "Invalid periodicalDamageWeaponEffect for weapon %s - assuming same effect as weapon", getStatName(psStats));
debug(LOG_ERROR, "Invalid periodicalDamageWeaponEffect for weapon %s - assuming same effect as weapon", getName(psStats));
psStats->periodicalDamageWeaponEffect = psStats->weaponEffect;
}
@ -472,7 +472,7 @@ bool loadWeaponStats(const char *pFileName)
if (surfaceToAir > UBYTE_MAX)
{
ASSERT(false, "loadWeaponStats: Surface to Air is outside of limits for weapon %s",
getStatName(psStats));
getName(psStats));
return false;
}
if (surfaceToAir == 0)
@ -568,7 +568,7 @@ bool loadBodyStats(const char *pFileName)
psStats->ref = REF_BODY_START + i;
if (!getBodySize(ini.value("size").toString().toUtf8().constData(), &psStats->size))
{
ASSERT(false, "Unknown body size for %s", getStatName(psStats));
ASSERT(false, "Unknown body size for %s", getName(psStats));
return false;
}
psStats->pIMD = statsGetIMD(ini, psStats, "model");
@ -617,7 +617,7 @@ bool loadBrainStats(const char *pFileName)
if (ini.contains("turret"))
{
int weapon = getCompFromName(COMP_WEAPON, ini.value("turret").toString());
ASSERT_OR_RETURN(false, weapon >= 0, "Unable to find weapon for brain %s", getStatName(psStats));
ASSERT_OR_RETURN(false, weapon >= 0, "Unable to find weapon for brain %s", getName(psStats));
psStats->psWeaponStat = asWeaponStats + weapon;
}
psStats->designable = ini.value("designable", false).toBool();
@ -708,7 +708,7 @@ bool loadPropulsionStats(const char *pFileName)
psStats->pIMD = statsGetIMD(ini, psStats, "model");
if (!getPropulsionType(ini.value("type").toString().toUtf8().constData(), &psStats->propulsionType))
{
debug(LOG_FATAL, "loadPropulsionStats: Invalid Propulsion type for %s", getStatName(psStats));
debug(LOG_FATAL, "loadPropulsionStats: Invalid Propulsion type for %s", getName(psStats));
return false;
}
ini.endGroup();
@ -940,7 +940,7 @@ bool loadRepairStats(const char *pFileName)
}
//check its not 0 since we will be dividing by it at a later stage
ASSERT_OR_RETURN(false, psStats->time > 0, "Repair delay cannot be zero for %s", getStatName(psStats));
ASSERT_OR_RETURN(false, psStats->time > 0, "Repair delay cannot be zero for %s", getName(psStats));
//get the IMD for the component
psStats->pIMD = statsGetIMD(ini, psStats, "model");

View File

@ -246,7 +246,6 @@ struct BASE_STATS
};
#define getName(_psStats) (_psStats)->name.toUtf8().constData()
#define getStatName(_psStats) (_psStats)->name.toUtf8().constData()
#define getID(_psStats) (_psStats)->id.toUtf8().constData()
/* Stats common to all droid components */

View File

@ -1732,7 +1732,7 @@ STRUCTURE *buildBlueprint(STRUCTURE_STATS const *psStats, Vector2i xy, uint16_t
STRUCTURE *blueprint;
ASSERT_OR_RETURN(NULL, psStats != NULL, "No blueprint stats");
ASSERT_OR_RETURN(NULL, psStats->pIMD[0] != NULL, "No blueprint model for %s", getStatName(psStats));
ASSERT_OR_RETURN(NULL, psStats->pIMD[0] != NULL, "No blueprint model for %s", getName(psStats));
Vector3i pos(xy, INT32_MIN);
Rotation rot((direction + 0x2000)&0xC000, 0, 0); // Round direction to nearest 90°.
@ -5448,7 +5448,7 @@ void printStructureInfo(STRUCTURE *psStructure)
if (getDebugMappingStatus())
{
CONPRINTF(ConsoleString, (ConsoleString, "%s - %d Units assigned - ID %d - sensor range %d - ECM %d",
getStatName(psStructure->pStructureType), countAssignedDroids(psStructure),
getName(psStructure->pStructureType), countAssignedDroids(psStructure),
psStructure->id, structSensorRange(psStructure), structJammerPower(psStructure)));
}
else
@ -5457,7 +5457,7 @@ void printStructureInfo(STRUCTURE *psStructure)
unsigned int assigned_droids = countAssignedDroids(psStructure);
CONPRINTF(ConsoleString, (ConsoleString, ngettext("%s - %u Unit assigned - Damage %3.0f%%", "%s - %u Units assigned - Damage %3.0f%%", assigned_droids),
getStatName(psStructure->pStructureType), assigned_droids, getStructureDamage(psStructure) * (100.f/65536.f)));
getName(psStructure->pStructureType), assigned_droids, getStructureDamage(psStructure) * (100.f/65536.f)));
}
break;
case REF_DEFENSE:
@ -5465,7 +5465,7 @@ void printStructureInfo(STRUCTURE *psStructure)
if (getDebugMappingStatus())
{
CONPRINTF(ConsoleString, (ConsoleString, "%s - %d Units assigned - ID %d - armour %d|%d - sensor range %d - ECM %d - born %u - depth %.02f",
getStatName(psStructure->pStructureType), countAssignedDroids(psStructure),
getName(psStructure->pStructureType), countAssignedDroids(psStructure),
psStructure->id, objArmour(psStructure, WC_KINETIC), objArmour(psStructure, WC_HEAT),
structSensorRange(psStructure), structJammerPower(psStructure), psStructure->born, psStructure->foundationDepth));
} else
@ -5482,12 +5482,12 @@ void printStructureInfo(STRUCTURE *psStructure)
unsigned int assigned_droids = countAssignedDroids(psStructure);
CONPRINTF(ConsoleString, (ConsoleString, ngettext("%s - %u Unit assigned - Damage %3.0f%%", "%s - %u Units assigned - Damage %3.0f%%", assigned_droids),
getStatName(psStructure->pStructureType), assigned_droids, getStructureDamage(psStructure) * (100.f/65536.f)));
getName(psStructure->pStructureType), assigned_droids, getStructureDamage(psStructure) * (100.f/65536.f)));
}
else
{
CONPRINTF(ConsoleString, (ConsoleString, _("%s - Damage %3.0f%%"),
getStatName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f)));
getName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f)));
}
break;
case REF_REPAIR_FACILITY:
@ -5495,12 +5495,12 @@ void printStructureInfo(STRUCTURE *psStructure)
if (getDebugMappingStatus())
{
CONPRINTF(ConsoleString,(ConsoleString, "%s - Unique ID %d - Queue %d",
getStatName(psStructure->pStructureType), psStructure->id, psStructure->pFunctionality->repairFacility.droidQueue));
getName(psStructure->pStructureType), psStructure->id, psStructure->pFunctionality->repairFacility.droidQueue));
}
else
#endif
{
CONPRINTF(ConsoleString, (ConsoleString, "%s - Damage %3.0f%%", getStatName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f)));
CONPRINTF(ConsoleString, (ConsoleString, "%s - Damage %3.0f%%", getName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f)));
}
break;
case REF_RESOURCE_EXTRACTOR:
@ -5508,12 +5508,12 @@ void printStructureInfo(STRUCTURE *psStructure)
if (getDebugMappingStatus())
{
CONPRINTF(ConsoleString,(ConsoleString, "%s - Unique ID %d - %s",
getStatName(psStructure->pStructureType), psStructure->id, (auxTile(map_coord(psStructure->pos.x), map_coord(psStructure->pos.y), selectedPlayer) & AUXBITS_DANGER) ? "danger" : "safe"));
getName(psStructure->pStructureType), psStructure->id, (auxTile(map_coord(psStructure->pos.x), map_coord(psStructure->pos.y), selectedPlayer) & AUXBITS_DANGER) ? "danger" : "safe"));
}
else
#endif
{
CONPRINTF(ConsoleString, (ConsoleString, "%s - Damage %3.0f%%", getStatName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f)));
CONPRINTF(ConsoleString, (ConsoleString, "%s - Damage %3.0f%%", getName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f)));
}
break;
case REF_POWER_GEN:
@ -5530,14 +5530,14 @@ void printStructureInfo(STRUCTURE *psStructure)
if (getDebugMappingStatus())
{
CONPRINTF(ConsoleString, (ConsoleString, "%s - Connected %u of %u - Unique ID %u - Multiplier: %u",
getStatName(psStructure->pStructureType), numConnected, NUM_POWER_MODULES,
getName(psStructure->pStructureType), numConnected, NUM_POWER_MODULES,
psStructure->id, getBuildingPowerPoints(psStructure)));
}
else
#endif
{
CONPRINTF(ConsoleString, (ConsoleString, _("%s - Connected %u of %u - Damage %3.0f%%"),
getStatName(psStructure->pStructureType), numConnected, NUM_POWER_MODULES, getStructureDamage(psStructure) * (100.f/65536.f)));
getName(psStructure->pStructureType), numConnected, NUM_POWER_MODULES, getStructureDamage(psStructure) * (100.f/65536.f)));
}
break;
case REF_CYBORG_FACTORY:
@ -5547,7 +5547,7 @@ void printStructureInfo(STRUCTURE *psStructure)
if (getDebugMappingStatus())
{
CONPRINTF(ConsoleString, (ConsoleString, "%s - Damage % 3.2f%% - Unique ID %u - Production Output: %u - BuildPointsRemaining: %u",
getStatName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f), psStructure->id,
getName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f), psStructure->id,
getBuildingProductionPoints(psStructure),
psStructure->pFunctionality->factory.buildPointsRemaining));
}
@ -5555,7 +5555,7 @@ void printStructureInfo(STRUCTURE *psStructure)
#endif
{
CONPRINTF(ConsoleString, (ConsoleString, _("%s - Damage %3.0f%%"),
getStatName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f)));
getName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f)));
}
break;
case REF_RESEARCH:
@ -5563,14 +5563,14 @@ void printStructureInfo(STRUCTURE *psStructure)
if (getDebugMappingStatus())
{
CONPRINTF(ConsoleString, (ConsoleString, "%s - Damage % 3.2f%% - Unique ID %u - Research Points: %u",
getStatName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f), psStructure->id,
getName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f), psStructure->id,
getBuildingResearchPoints(psStructure)));
}
else
#endif
{
CONPRINTF(ConsoleString, (ConsoleString, _("%s - Damage %3.0f%%"),
getStatName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f)));
getName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f)));
}
break;
default:
@ -5578,13 +5578,13 @@ void printStructureInfo(STRUCTURE *psStructure)
if (getDebugMappingStatus())
{
CONPRINTF(ConsoleString, (ConsoleString, "%s - Damage % 3.2f%% - Unique ID %u",
getStatName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f), psStructure->id));
getName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f), psStructure->id));
}
else
#endif
{
CONPRINTF(ConsoleString, (ConsoleString, _("%s - Damage %3.0f%%"),
getStatName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f)));
getName(psStructure->pStructureType), getStructureDamage(psStructure) * (100.f/65536.f)));
}
break;
}
@ -5710,7 +5710,7 @@ bool electronicDamage(BASE_OBJECT *psTarget, UDWORD damage, UBYTE attackPlayer)
{
CONPRINTF(ConsoleString,(ConsoleString,
_("%s - Electronically Damaged"),
getStatName(psStructure->pStructureType)));
getName(psStructure->pStructureType)));
//tell the scripts if selectedPlayer has lost a structure
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_ELECTRONIC_TAKEOVER);
}