Skip to content

Commit

Permalink
semperfi: Fix attacks of opportunity with allies. Do not try to hug a…
Browse files Browse the repository at this point in the history
…n allied oil derrick, believing it to be hostile.

Also do not crash if we check whether an oil feature is allied to us.
  • Loading branch information
perim committed Jun 5, 2011
1 parent 4f50b07 commit 5066a04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions data/base/multiplay/skirmish/semperfi.slo
Expand Up @@ -2422,7 +2422,7 @@ event attackStuff(attackStuffTr)
best = NULLOBJECT;
while (result != NULLOBJECT)
{
if (result.type == OBJ_STRUCTURE and result.player != me and safeDest(me, result.x, result.y))
if (result.type == OBJ_STRUCTURE and !allianceExistsBetween(result.player, me) and safeDest(me, result.x, result.y))
{
best = result; // easy pickings
}
Expand All @@ -2431,7 +2431,7 @@ event attackStuff(attackStuffTr)
}
if (best != NULLOBJECT)
{
dbgPlr("MOVEMENT OF OPPORTUNITY");
dbgPlr("MOVEMENT OF OPPORTUNITY to " & best.x & ", " & best.y);
orderGroupLoc(attackGroup, DORDER_SCOUT, best.x, best.y);
exit;
}
Expand Down
8 changes: 3 additions & 5 deletions src/scriptfuncs.cpp
Expand Up @@ -198,12 +198,13 @@ bool scrGetDerrick()
x = derricks[i].x;
y = derricks[i].y;
MAPTILE *psTile = worldTile(x, y);
ASSERT(psTile, "No derrick or oil at position!");
if (psTile)
{
scrFunctionResult.v.oval = psTile->psObject;
}
}
if (!stackPushResult((INTERP_TYPE)ST_STRUCTURE, &scrFunctionResult))
if (!stackPushResult((INTERP_TYPE)ST_BASEOBJECT, &scrFunctionResult))
{
ASSERT(false, "Failed to push result");
return false;
Expand Down Expand Up @@ -4043,13 +4044,11 @@ bool scrAllianceExistsBetween(void)
{
UDWORD i,j;


if (!stackPopParams(2, VAL_INT, &i,VAL_INT, &j))
{
return false;
}
ASSERT_OR_RETURN(false, i < MAX_PLAYERS && j < MAX_PLAYERS, "Invalid player parameters %d and %d", i, j);
if(alliances[i][j] == ALLIANCE_FORMED)
if (i < MAX_PLAYERS && j < MAX_PLAYERS && alliances[i][j] == ALLIANCE_FORMED)
{
scrFunctionResult.v.bval = true;
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
Expand All @@ -4058,7 +4057,6 @@ bool scrAllianceExistsBetween(void)
}
return true;
}

scrFunctionResult.v.bval = false;
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
{
Expand Down

0 comments on commit 5066a04

Please sign in to comment.