forked from 0ad/0ad
Fix tests. BuildingAI now handles DiplomacyChanged messages.
This was SVN commit r12812.
This commit is contained in:
parent
d75ae52f56
commit
a0e13d9625
@ -253,8 +253,7 @@
|
||||
<object name="diplomacyHeader" size="32 32 100%-32 64">
|
||||
<object name="diplomacyHeaderName" size="0 0 150 100%" type="text" style="chatPanel" ghost="true" caption="Name"/>
|
||||
<object name="diplomacyHeaderCiv" size="150 0 250 100%" type="text" style="chatPanel" ghost="true" caption="Civilization"/>
|
||||
<object name="diplomacyHeaderTheirs" size="250 0 310 100%" type="text" style="chatPanel" ghost="true" caption="Theirs"/>
|
||||
<object name="diplomacyHeaderTeam" size="310 0 360 100%" type="text" style="chatPanel" ghost="true" caption="Team"/>
|
||||
<object name="diplomacyHeaderTeam" size="250 0 310 100%" type="text" style="chatPanel" ghost="true" caption="Team"/>
|
||||
<object name="diplomacyHeaderAlly" size="100%-180 0 100%-160 100%" type="text" style="chatPanel" caption="A" tooltip="Ally" tooltip_style="sessionToolTipBold"/>
|
||||
<object name="diplomacyHeaderNeutral" size="100%-160 0 100%-140 100%" type="text" style="chatPanel" caption="N" tooltip="Neutral" tooltip_style="sessionToolTipBold"/>
|
||||
<object name="diplomacyHeaderEnemy" size="100%-140 0 100%-120 100%" type="text" style="chatPanel" caption="E" tooltip="Enemy" tooltip_style="sessionToolTipBold"/>
|
||||
|
@ -38,6 +38,17 @@ BuildingAI.prototype.OnOwnershipChanged = function(msg)
|
||||
this.SetupGaiaRangeQuery(msg.to);
|
||||
};
|
||||
|
||||
BuildingAI.prototype.OnDiplomacyChanged = function(msg)
|
||||
{
|
||||
var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership);
|
||||
if (cmpOwnership && cmpOwnership.GetOwner() == msg.player)
|
||||
{
|
||||
// Remove maybe now allied/neutral units
|
||||
this.targetUnits = [];
|
||||
this.SetupRangeQuery(msg.player);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Cleanup on destroy
|
||||
*/
|
||||
@ -66,7 +77,10 @@ BuildingAI.prototype.SetupRangeQuery = function(owner)
|
||||
var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
||||
var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
|
||||
if (this.enemyUnitsQuery)
|
||||
{
|
||||
cmpRangeManager.DestroyActiveQuery(this.enemyUnitsQuery);
|
||||
this.enemyUnitsQuery = undefined;
|
||||
}
|
||||
var players = [];
|
||||
|
||||
var cmpPlayer = Engine.QueryInterface(cmpPlayerManager.GetPlayerByID(owner), IID_Player);
|
||||
|
@ -300,6 +300,8 @@ Player.prototype.SetDiplomacyIndex = function(idx, value)
|
||||
else
|
||||
{
|
||||
this.diplomacy[idx] = value;
|
||||
if (this.diplomacy[idx] == cmpPlayer.diplomacy[this.playerID])
|
||||
Engine.BroadcastMessage(MT_DiplomacyChanged, {"player": idx});
|
||||
}
|
||||
Engine.BroadcastMessage(MT_DiplomacyChanged, {"player": this.playerID});
|
||||
}
|
||||
@ -317,6 +319,8 @@ Player.prototype.SetDiplomacyIndex = function(idx, value)
|
||||
else
|
||||
{
|
||||
this.diplomacy[idx] = value;
|
||||
if (this.diplomacy[idx] == cmpPlayer.diplomacy[this.playerID])
|
||||
Engine.BroadcastMessage(MT_DiplomacyChanged, {"player": idx});
|
||||
}
|
||||
|
||||
Engine.BroadcastMessage(MT_DiplomacyChanged, {"player": this.playerID});
|
||||
|
@ -67,6 +67,8 @@ AddMock(100, IID_Player, {
|
||||
IsAlly: function() { return false; },
|
||||
IsNeutral: function() { return false; },
|
||||
IsEnemy: function() { return true; },
|
||||
WantAlly: function() { return false; },
|
||||
WantNeutral: function() { return false; },
|
||||
});
|
||||
|
||||
AddMock(100, IID_BuildLimits, {
|
||||
@ -120,6 +122,8 @@ AddMock(101, IID_Player, {
|
||||
IsAlly: function() { return true; },
|
||||
IsNeutral: function() { return false; },
|
||||
IsEnemy: function() { return false; },
|
||||
WantAlly: function() { return false; },
|
||||
WantNeutral: function() { return false; },
|
||||
});
|
||||
|
||||
AddMock(101, IID_BuildLimits, {
|
||||
@ -174,9 +178,11 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetSimulationState(), {
|
||||
team: -1,
|
||||
teamsLocked: false,
|
||||
phase: "",
|
||||
isAlly: [false, false, false],
|
||||
isNeutral: [false, false, false],
|
||||
isEnemy: [true, true, true],
|
||||
isAlly: [false, false],
|
||||
isNeutral: [false, false],
|
||||
isEnemy: [true, true],
|
||||
wantAlly: [false, false],
|
||||
wantNeutral: [false, false],
|
||||
buildLimits: {"Foo": 10},
|
||||
buildCounts: {"Foo": 5},
|
||||
techModifications: {},
|
||||
@ -194,9 +200,11 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetSimulationState(), {
|
||||
team: -1,
|
||||
teamsLocked: false,
|
||||
phase: "village",
|
||||
isAlly: [true, true, true],
|
||||
isNeutral: [false, false, false],
|
||||
isEnemy: [false, false, false],
|
||||
isAlly: [true, true],
|
||||
isNeutral: [false, false],
|
||||
isEnemy: [false, false],
|
||||
wantAlly: [false, false],
|
||||
wantNeutral: [false, false],
|
||||
buildLimits: {"Bar": 20},
|
||||
buildCounts: {"Bar": 0},
|
||||
techModifications: {},
|
||||
@ -219,11 +227,13 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedSimulationState(), {
|
||||
trainingBlocked: false,
|
||||
state: "active",
|
||||
team: -1,
|
||||
teamsLocked:false,
|
||||
teamsLocked: false,
|
||||
phase: "",
|
||||
isAlly: [false, false, false],
|
||||
isNeutral: [false, false, false],
|
||||
isEnemy: [true, true, true],
|
||||
isAlly: [false, false],
|
||||
isNeutral: [false, false],
|
||||
isEnemy: [true, true],
|
||||
wantAlly: [false, false],
|
||||
wantNeutral: [false, false],
|
||||
buildLimits: {"Foo": 10},
|
||||
buildCounts: {"Foo": 5},
|
||||
techModifications: {},
|
||||
@ -255,11 +265,13 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedSimulationState(), {
|
||||
trainingBlocked: false,
|
||||
state: "active",
|
||||
team: -1,
|
||||
teamsLocked:false,
|
||||
teamsLocked: false,
|
||||
phase: "village",
|
||||
isAlly: [true, true, true],
|
||||
isNeutral: [false, false, false],
|
||||
isEnemy: [false, false, false],
|
||||
isAlly: [true, true],
|
||||
isNeutral: [false, false],
|
||||
isEnemy: [false, false],
|
||||
wantAlly: [false, false],
|
||||
wantNeutral: [false, false],
|
||||
buildLimits: {"Bar": 20},
|
||||
buildCounts: {"Bar": 0},
|
||||
techModifications: {},
|
||||
|
Loading…
Reference in New Issue
Block a user