Skip to content

Commit

Permalink
Fix transporter check for SP games.
Browse files Browse the repository at this point in the history
Add some FIXME comments when we properly fix the campaign scripts.
Expose DROID_SUPERTRANSPORTER to the script engine
Fix gifting of the Super Transporter, along with some other fixes.
Fixes ticket:3224
  • Loading branch information
vexed committed Feb 28, 2012
1 parent 475d1e6 commit 9e63fe3
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/droid.cpp
Expand Up @@ -188,6 +188,7 @@ int32_t droidDamage(DROID *psDroid, unsigned damage, WEAPON_CLASS weaponClass, W
else if (relativeDamage < 0)
{
// HACK: Prevent transporters from being destroyed in single player
// FIXME: When we fix campaign scripts to use DROID_SUPERTRANSPORTER
if ((game.type == CAMPAIGN) && !bMultiPlayer && (psDroid->droidType == DROID_TRANSPORTER))
{
debug(LOG_ATTACK, "Transport(%d) saved from death--since it should never die (SP only)", psDroid->id);
Expand Down
2 changes: 1 addition & 1 deletion src/droiddef.h
Expand Up @@ -69,13 +69,13 @@ enum DROID_TYPE
DROID_PERSON, ///< person
DROID_CYBORG, ///< cyborg-type thang
DROID_TRANSPORTER, ///< guess what this is!
DROID_SUPERTRANSPORTER, ///< SuperTransport (MP)
DROID_COMMAND, ///< Command droid
DROID_REPAIR, ///< Repair droid
DROID_DEFAULT, ///< Default droid
DROID_CYBORG_CONSTRUCT, ///< cyborg constructor droid - new for update 28/5/99
DROID_CYBORG_REPAIR, ///< cyborg repair droid - new for update 28/5/99
DROID_CYBORG_SUPER, ///< cyborg repair droid - new for update 7/6/99
DROID_SUPERTRANSPORTER, ///< SuperTransport (MP)
DROID_ANY, ///< Any droid. Only used as a parameter for intGotoNextDroidType(DROID_TYPE).
};

Expand Down
3 changes: 2 additions & 1 deletion src/mission.cpp
Expand Up @@ -671,6 +671,7 @@ void missionFlyTransportersIn( SDWORD iPlayer, bool bTrackTransporter )
NULL; psTransporter = psNext)
{
psNext = psTransporter->psNext;
// FIXME: When we convert campaign scripts to use DROID_SUPERTRANSPORTER
if (psTransporter->droidType == DROID_TRANSPORTER)
{
// Check that this transporter actually contains some droids
Expand Down Expand Up @@ -1909,7 +1910,7 @@ void missionMoveTransporterOffWorld( DROID *psTransporter )
{
W_CLICKFORM *psForm;
DROID *psDroid;

// FIXME: When we convert campaign scripts, use DROID_SUPERTRANSPORTER
if (psTransporter->droidType == DROID_TRANSPORTER)
{
/* trigger script callback */
Expand Down
4 changes: 2 additions & 2 deletions src/move.cpp
Expand Up @@ -1149,7 +1149,7 @@ static void moveCalcDroidSlide(DROID *psDroid, int *pmx, int *pmy)
{
if (psObj->type == OBJ_DROID)
{
if (((DROID *)psObj)->droidType == DROID_TRANSPORTER)
if (((DROID *)psObj)->droidType == DROID_TRANSPORTER || ((DROID *)psObj)->droidType == DROID_SUPERTRANSPORTER)
{
// ignore transporters
continue;
Expand Down Expand Up @@ -1270,7 +1270,7 @@ static Vector2i moveGetObstacleVector(DROID *psDroid, Vector2i dest)
continue;
}

if (psObstacle->droidType == DROID_TRANSPORTER ||
if ((psObstacle->droidType == DROID_TRANSPORTER || psObstacle->droidType == DROID_SUPERTRANSPORTER) ||
(psObstacle->droidType == DROID_PERSON &&
psObstacle->player != psDroid->player))
{
Expand Down
2 changes: 1 addition & 1 deletion src/multigifts.cpp
Expand Up @@ -237,7 +237,7 @@ static void sendGiftDroids(uint8_t from, uint8_t to)

for (psD = apsDroidLists[from]; psD && totalToSend != 0; psD = psD->psNext)
{
if (psD->droidType == DROID_TRANSPORTER
if ((psD->droidType == DROID_TRANSPORTER || psD->droidType == DROID_SUPERTRANSPORTER)
&& !transporterIsEmpty(psD))
{
CONPRINTF(ConsoleString, (ConsoleString, _("Tried to give away a non-empty %s - but this is not allowed."), psD->aName));
Expand Down
4 changes: 2 additions & 2 deletions src/objmem.cpp
Expand Up @@ -779,7 +779,7 @@ BASE_OBJECT *getBaseObjFromData(unsigned id, unsigned player, OBJECT_TYPE type)
return psObj;
}
// if transporter check any droids in the grp
if ((psObj->type == OBJ_DROID) && (((DROID*)psObj)->droidType == DROID_TRANSPORTER))
if ((psObj->type == OBJ_DROID) && ((((DROID*)psObj)->droidType == DROID_TRANSPORTER || ((DROID*)psObj)->droidType == DROID_SUPERTRANSPORTER)))
{
for(psTrans = ((DROID*)psObj)->psGroup->psList; psTrans != NULL; psTrans = psTrans->psGrpNext)
{
Expand Down Expand Up @@ -865,7 +865,7 @@ BASE_OBJECT *getBaseObjFromId(UDWORD id)
return psObj;
}
// if transporter check any droids in the grp
if ((psObj->type == OBJ_DROID) && (((DROID*)psObj)->droidType == DROID_TRANSPORTER))
if ((psObj->type == OBJ_DROID) && ((((DROID*)psObj)->droidType == DROID_TRANSPORTER || ((DROID*)psObj)->droidType == DROID_SUPERTRANSPORTER)))
{
for(psTrans = ((DROID*)psObj)->psGroup->psList; psTrans != NULL; psTrans = psTrans->psGrpNext)
{
Expand Down
10 changes: 5 additions & 5 deletions src/order.cpp
Expand Up @@ -792,11 +792,9 @@ void orderUpdateDroid(DROID *psDroid)
DROID *temp = NULL;

temp = (DROID*)psDroid->order.psObj;
if ((temp->droidType == DROID_TRANSPORTER) && !cyborgDroid(psDroid))
// FIXME: since we now have 2 transporter types, we should fix this in the scripts for campaign
if ((temp->droidType == DROID_TRANSPORTER) && !cyborgDroid(psDroid) && game.type != CAMPAIGN && bMultiPlayer)
{
// NOTE: since we only have one type of transport (DROID_TRANSPORT), it isn't worth changing tons of code
// to have two types available (DROID_TRANSPORT_SUPER), so we just check the name which can never be
// renamed anyway, so we should be safe with this kludge.
psDroid->order = DroidOrder(DORDER_NONE);
actionDroid(psDroid, DACTION_NONE);
audio_PlayTrack( ID_SOUND_BUILD_FAIL );
Expand Down Expand Up @@ -1483,8 +1481,9 @@ void orderDroidBase(DROID *psDroid, DROID_ORDER_DATA *psOrder)
else if (psOrder->psObj && !psOrder->psObj->died)
{
//cannot attack a Transporter with EW in multiPlayer
// FIXME: Why not ?
if (game.type == SKIRMISH && electronicDroid(psDroid)
&& psOrder->psObj->type == OBJ_DROID && ((DROID *)psOrder->psObj)->droidType == DROID_TRANSPORTER)
&& psOrder->psObj->type == OBJ_DROID && (((DROID *)psOrder->psObj)->droidType == DROID_TRANSPORTER || ((DROID *)psOrder->psObj)->droidType == DROID_SUPERTRANSPORTER))
{
break;
}
Expand Down Expand Up @@ -2491,6 +2490,7 @@ void orderSelectedLoc(uint32_t player, uint32_t x, uint32_t y, bool add)
if (psCurr->selected)
{
// can't use bMultiPlayer since multimsg could be off.
// FIXME: Fix this for DROID_SUPERTRANSPORTER when we fix campaign scripts
if (psCurr->droidType == DROID_TRANSPORTER && game.type == CAMPAIGN)
{
// Transport in campaign cannot be controlled by players
Expand Down
3 changes: 2 additions & 1 deletion src/qtscriptfuncs.cpp
Expand Up @@ -1312,7 +1312,7 @@ static QScriptValue js_groupAddArea(QScriptContext *context, QScriptEngine *engi
for (DROID *psDroid = apsDroidLists[player]; psGroup && psDroid; psDroid = psDroid->psNext)
{
if (psDroid->pos.x >= x1 && psDroid->pos.x <= x2 && psDroid->pos.y >= y1 && psDroid->pos.y <= y2
&& psDroid->droidType != DROID_COMMAND && psDroid->droidType != DROID_TRANSPORTER)
&& psDroid->droidType != DROID_COMMAND && (psDroid->droidType != DROID_TRANSPORTER && psDroid->droidType != DROID_SUPERTRANSPORTER))
{
psGroup->add(psDroid);
}
Expand Down Expand Up @@ -2119,6 +2119,7 @@ bool registerFunctions(QScriptEngine *engine)
engine->globalObject().setProperty("DROID_ECM", DROID_ECM, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("DROID_CYBORG", DROID_CYBORG, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("DROID_TRANSPORTER", DROID_TRANSPORTER, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("DROID_SUPERTRANSPORTER", DROID_SUPERTRANSPORTER, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("DROID_COMMAND", DROID_COMMAND, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("HQ", REF_HQ, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("FACTORY", REF_FACTORY, QScriptValue::ReadOnly | QScriptValue::Undeletable);
Expand Down
3 changes: 1 addition & 2 deletions src/research.cpp
Expand Up @@ -1986,8 +1986,7 @@ void replaceTransDroidComponents(DROID *psTransporter, UDWORD oldType,
{
DROID *psCurr;

ASSERT( psTransporter->droidType == DROID_TRANSPORTER,
"replaceTransUnitComponents: invalid unit type" );
ASSERT ((psTransporter->droidType == DROID_TRANSPORTER || psTransporter->droidType == DROID_SUPERTRANSPORTER), "invalid unit type" );

for (psCurr = psTransporter->psGroup->psList; psCurr != NULL; psCurr =
psCurr->psGrpNext)
Expand Down
2 changes: 1 addition & 1 deletion src/scriptfuncs.cpp
Expand Up @@ -1188,7 +1188,7 @@ bool scrAddDroidToTransporter(void)

ASSERT(psTransporter != NULL, "scrAddUnitToTransporter: invalid transporter pointer");
ASSERT(psDroid != NULL, "scrAddUnitToTransporter: invalid unit pointer");
ASSERT(psTransporter->droidType == DROID_TRANSPORTER, "scrAddUnitToTransporter: invalid transporter type");
ASSERT((psTransporter->droidType == DROID_TRANSPORTER || psTransporter->droidType == DROID_SUPERTRANSPORTER), "scrAddUnitToTransporter: invalid transporter type");

/* check for space */
if (checkTransporterSpace(psTransporter, psDroid))
Expand Down
2 changes: 1 addition & 1 deletion src/structure.cpp
Expand Up @@ -5709,7 +5709,7 @@ bool validTemplateForFactory(DROID_TEMPLATE *psTemplate, STRUCTURE *psFactory)
if (!bMultiPlayer)
{
//ignore Transporter Droids
if (psTemplate->droidType == DROID_TRANSPORTER)
if (psTemplate->droidType == DROID_TRANSPORTER || psTemplate->droidType == DROID_SUPERTRANSPORTER)
{
return false;
}
Expand Down

0 comments on commit 9e63fe3

Please sign in to comment.