Skip to content

Commit

Permalink
Fix enemy base detection in libcampaign upon load.
Browse files Browse the repository at this point in the history
  • Loading branch information
KJeff01 committed Aug 18, 2017
1 parent c39da08 commit e90d507
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions data/base/script/campaign/libcampaign.js
Expand Up @@ -779,16 +779,32 @@ const CAM_REINFORCE_TRANSPORT = 2;
//;; \end{description}
function camSetEnemyBases(bases)
{
__camEnemyBases = bases;
__camNumEnemyBases = 0;
var reload = !camDef(bases);
if (!reload)
{
__camEnemyBases = bases;
__camNumEnemyBases = 0;
}
// convert label strings to groups and store
for (var blabel in __camEnemyBases)
{
var bi = __camEnemyBases[blabel];
var obj = getObject(blabel);
if (camDef(obj) && obj) // group already defined
{
bi.group = obj.id;
if (!camDef(bi.group))
{
bi.group = obj.id;
}
else
{
var structures = enumGroup(bi.group);
addLabel({ type: GROUP, id: bi.group }, blabel);
for (var i = 0, l = structures.length; i < l; ++i)
{
groupAdd(bi.group, structures[i]);
}
}
if (!camDef(bi.cleanup)) // auto-detect cleanup area
{
var objs = enumGroup(bi.group);
Expand Down Expand Up @@ -843,8 +859,11 @@ function camSetEnemyBases(bases)
}
if (groupSize(bi.group) === 0)
camDebug("Base", blabel, "defined as empty group");
bi.detected = false;
bi.eliminated = false;
if(!reload)
{
bi.detected = false;
bi.eliminated = false;
}
camTrace("Resetting label", blabel);
resetLabel(blabel, CAM_HUMAN_PLAYER); // subscribe for eventGroupSeen
}
Expand Down Expand Up @@ -2992,6 +3011,9 @@ function cam_eventGameLoaded()

//reset active factory management.
__camResetFactories();

//Subscribe to eventGroupSeen again.
camSetEnemyBases();
}

//Plays Nexus sounds if nexusActivated is true.
Expand Down

0 comments on commit e90d507

Please sign in to comment.