Page MenuHomeWildfire Games

Create function to distribute a message to several entities.
Changes PlannedPublic

Authored by Freagarach on Apr 19 2020, 2:38 PM.

Details

Reviewers
None
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Trac Tickets
#3214
Summary

Currently, when one wants to send a message to several entities (both from JS and C++) one iterates over the entities and sends all the message.
From JS, this means useless work is done by converting the message often.

This patch aims at introducing a function that would allow to distribute a message to several entities at once, thus reducing the amount of conversions that ought to be done.
Then, after sending all those messages to the specific entities, one global message is sent, instead of a global message for all PostMessages.

This can be used for cmpGuard (GuardAttacked) and cmpFoundation (ConstructionFinished), but perhaps more kandidates can be found.

Test Plan

Verify that the messages are still received.

Event Timeline

Freagarach created this revision.Apr 19 2020, 2:38 PM
Owners added a subscriber: Restricted Owners Package.Apr 19 2020, 2:38 PM
Freagarach added inline comments.Apr 19 2020, 2:43 PM
source/simulation2/system/ComponentManager.h
295

entities

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/1491/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/604/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2018/display/redirect

Freagarach updated this revision to Diff 11699.Apr 20 2020, 9:18 AM
Freagarach retitled this revision from [WIP] - Create function to distribute a message to several entities. to Create function to distribute a message to several entities..
Freagarach edited the summary of this revision. (Show Details)
Freagarach edited the test plan for this revision. (Show Details)

Working version.

  • cmpGuard as use case.
  • Send global message.

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

source/simulation2/system/ComponentManager.h
|  39| class·CComponentManager
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'classCComponentManager{' is invalid C code. Use --std or --language to configure the language.

source/simulation2/Simulation2.h
|  45| class·CSimulation2
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'classCSimulation2{' is invalid C code. Use --std or --language to configure the language.
Executing section JS...
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
| 245| 245| 			this.FinishOrder();
| 246| 246| 			return;
| 247| 247| 		}
| 248|    |-Engine.DistributeMessage([this.entity], MT_Attacked, { "attacker": this.entity });
|    | 248|+		Engine.DistributeMessage([this.entity], MT_Attacked, { "attacker": this.entity });
| 249| 249| 		// Stop moving immediately.
| 250| 250| 		this.StopMoving();
| 251| 251| 		this.FinishOrder();
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
| 788| 788| 					this.FinishOrder();
| 789| 789| 					return;
| 790| 790| 				}
| 791|    |-				else
| 792|    |-				{
|    | 791|+				
| 793| 792| 					this.SetNextState("GARRISON.APPROACHING");
| 794| 793| 					return;
| 795|    |-				}
|    | 794|+				
| 796| 795| 			}
| 797| 796| 
| 798| 797| 			this.SetNextState("GARRISON.GARRISONING");
|    | [NORMAL] ESLintBear (key-spacing):
|    | Missing space before value for key 'GARRISON'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|1060|1060| 			},
|1061|1061| 		},
|1062|1062| 
|1063|    |-		"GARRISON":{
|    |1063|+		"GARRISON": {
|1064|1064| 			"APPROACHING": {
|1065|1065| 				"enter": function() {
|1066|1066| 					if (!this.MoveToGarrisonRange(this.order.data.target))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2042|2042| 
|2043|2043| 				"Attacked": function(msg) {
|2044|2044| 					// If we are capturing and are attacked by something that we would not capture, attack that entity instead
|2045|    |-					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force)
|2046|    |-						&& this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|    |2045|+					if (this.order.data.attackType == "Capture" && (this.GetStance().targetAttackersAlways || !this.order.data.force) &&
|    |2046|+						this.order.data.target != msg.data.attacker && this.GetBestAttackAgainst(msg.data.attacker, true) != "Capture")
|2047|2047| 						this.RespondToTargetedEntities([msg.data.attacker]);
|2048|2048| 				},
|2049|2049| 			},
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2201|2201| 					"MovementUpdate": function(msg) {
|2202|2202| 						// If it looks like the path is failing, and we are close enough (3 tiles) from wanted range
|2203|2203| 						// stop anyways. This avoids pathing for an unreachable goal and reduces lag considerably.
|2204|    |-						if (msg.likelyFailure || 
|    |2204|+						if (msg.likelyFailure ||
|2205|2205| 							msg.obstructed && this.RelaxedMaxRangeCheck(this.order.data, this.order.data.max + this.DefaultRelaxedMaxRange) ||
|2206|2206| 							!msg.obstructed && this.CheckRange(this.order.data))
|2207|2207| 							this.FinishOrder();
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2843|2843| 					{
|2844|2844| 						// The building was already finished/fully repaired before we arrived;
|2845|2845| 						// let the ConstructionFinished handler handle this.
|2846|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2846|+						this.OnGlobalConstructionFinished({ "entity": this.repairTarget, "newentity": this.repairTarget});
|2847|2847| 						return true;
|2848|2848| 					}
|2849|2849| 
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|2843|2843| 					{
|2844|2844| 						// The building was already finished/fully repaired before we arrived;
|2845|2845| 						// let the ConstructionFinished handler handle this.
|2846|    |-						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget});
|    |2846|+						this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget });
|2847|2847| 						return true;
|2848|2848| 					}
|2849|2849| 
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3141|3141| 				this.StopTimer();
|3142|3142| 				this.ResetAnimation();
|3143|3143| 				if (this.formationAnimationVariant)
|3144|    |-					this.SetAnimationVariant(this.formationAnimationVariant)
|    |3144|+					this.SetAnimationVariant(this.formationAnimationVariant);
|3145|3145| 				else
|3146|3146| 					this.SetDefaultAnimationVariant();
|3147|3147| 				var cmpResistance = Engine.QueryInterface(this.entity, IID_Resistance);
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 7.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3367|3367| 		"COMBAT": "INDIVIDUAL.COMBAT", // reuse the same combat behaviour for animals
|3368|3368| 
|3369|3369| 		"WALKING": "INDIVIDUAL.WALKING",	// reuse the same walking behaviour for animals
|3370|    |-							// only used for domestic animals
|    |3370|+		// only used for domestic animals
|3371|3371| 
|3372|3372| 		// Reuse the same garrison behaviour for animals.
|3373|3373| 		"GARRISON": "INDIVIDUAL.GARRISON",
|    | [NORMAL] ESLintBear (no-unneeded-ternary):
|    | Unnecessary use of boolean literals in conditional expression.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3429|3429| 
|3430|3430| UnitAI.prototype.IsAnimal = function()
|3431|3431| {
|3432|    |-	return (this.template.NaturalBehaviour ? true : false);
|    |3432|+	return (!!this.template.NaturalBehaviour);
|3433|3433| };
|3434|3434| 
|3435|3435| UnitAI.prototype.IsDangerousAnimal = function()
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3545|3545| 		{
|3546|3546| 			let index = this.GetCurrentState().indexOf(".");
|3547|3547| 			if (index != -1)
|3548|    |-				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
|    |3548|+				this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0, index));
|3549|3549| 			this.Stop(false);
|3550|3550| 		}
|3551|3551| 
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3601|3601| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3602|3602| 			continue;
|3603|3603| 		if (i == 0)
|3604|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3604|+			this.UnitFsm.ProcessMessage(this, { "type": "PickupCanceled", "data": msg});
|3605|3605| 		else
|3606|3606| 			this.orderQueue.splice(i, 1);
|3607|3607| 		Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3601|3601| 		if (this.orderQueue[i].type != "PickupUnit" || this.orderQueue[i].data.target != msg.entity)
|3602|3602| 			continue;
|3603|3603| 		if (i == 0)
|3604|    |-			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg});
|    |3604|+			this.UnitFsm.ProcessMessage(this, {"type": "PickupCanceled", "data": msg });
|3605|3605| 		else
|3606|3606| 			this.orderQueue.splice(i, 1);
|3607|3607| 		Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3688|3688| };
|3689|3689| 
|3690|3690| 
|3691|    |-//// FSM linkage functions ////
|    |3691|+// // FSM linkage functions ////
|3692|3692| 
|3693|3693| // Setting the next state to the current state will leave/re-enter the top-most substate.
|3694|3694| UnitAI.prototype.SetNextState = function(state)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3859|3859| 				continue;
|3860|3860| 			if (this.orderQueue[i].type == type)
|3861|3861| 				continue;
|3862|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3862|+			this.orderQueue.splice(i, 0, { "type": type, "data": data});
|3863|3863| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3864|3864| 			return;
|3865|3865| 		}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|3859|3859| 				continue;
|3860|3860| 			if (this.orderQueue[i].type == type)
|3861|3861| 				continue;
|3862|    |-			this.orderQueue.splice(i, 0, {"type": type, "data": data});
|    |3862|+			this.orderQueue.splice(i, 0, {"type": type, "data": data });
|3863|3863| 			Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|3864|3864| 			return;
|3865|3865| 		}
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4101|4101| 	if (data.timerRepeat === undefined)
|4102|4102| 		this.timer = undefined;
|4103|4103| 
|4104|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4104|+	this.UnitFsm.ProcessMessage(this, { "type": "Timer", "data": data, "lateness": lateness});
|4105|4105| };
|4106|4106| 
|4107|4107| /**
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4101|4101| 	if (data.timerRepeat === undefined)
|4102|4102| 		this.timer = undefined;
|4103|4103| 
|4104|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness});
|    |4104|+	this.UnitFsm.ProcessMessage(this, {"type": "Timer", "data": data, "lateness": lateness });
|4105|4105| };
|4106|4106| 
|4107|4107| /**
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4146|4146| 	// TODO: This is a bit inefficient since every unit listens to every
|4147|4147| 	// construction message - ideally we could scope it to only the one we're building
|4148|4148| 
|4149|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4149|+	this.UnitFsm.ProcessMessage(this, { "type": "ConstructionFinished", "data": msg});
|4150|4150| };
|4151|4151| 
|4152|4152| UnitAI.prototype.OnGlobalEntityRenamed = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4146|4146| 	// TODO: This is a bit inefficient since every unit listens to every
|4147|4147| 	// construction message - ideally we could scope it to only the one we're building
|4148|4148| 
|4149|    |-	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg});
|    |4149|+	this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg });
|4150|4150| };
|4151|4151| 
|4152|4152| UnitAI.prototype.OnGlobalEntityRenamed = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4177|4177| 	if (msg.fromStatusEffect)
|4178|4178| 		return;
|4179|4179| 
|4180|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4180|+	this.UnitFsm.ProcessMessage(this, { "type": "Attacked", "data": msg});
|4181|4181| };
|4182|4182| 
|4183|4183| UnitAI.prototype.OnGuardedAttacked = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4177|4177| 	if (msg.fromStatusEffect)
|4178|4178| 		return;
|4179|4179| 
|4180|    |-	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg});
|    |4180|+	this.UnitFsm.ProcessMessage(this, {"type": "Attacked", "data": msg });
|4181|4181| };
|4182|4182| 
|4183|4183| UnitAI.prototype.OnGuardedAttacked = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4182|4182| 
|4183|4183| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4184|4184| {
|4185|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4185|+	this.UnitFsm.ProcessMessage(this, { "type": "GuardedAttacked", "data": msg.data});
|4186|4186| };
|4187|4187| 
|4188|4188| UnitAI.prototype.OnHealthChanged = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4182|4182| 
|4183|4183| UnitAI.prototype.OnGuardedAttacked = function(msg)
|4184|4184| {
|4185|    |-	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data});
|    |4185|+	this.UnitFsm.ProcessMessage(this, {"type": "GuardedAttacked", "data": msg.data });
|4186|4186| };
|4187|4187| 
|4188|4188| UnitAI.prototype.OnHealthChanged = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4187|4187| 
|4188|4188| UnitAI.prototype.OnHealthChanged = function(msg)
|4189|4189| {
|4190|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4190|+	this.UnitFsm.ProcessMessage(this, { "type": "HealthChanged", "from": msg.from, "to": msg.to});
|4191|4191| };
|4192|4192| 
|4193|4193| UnitAI.prototype.OnRangeUpdate = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4187|4187| 
|4188|4188| UnitAI.prototype.OnHealthChanged = function(msg)
|4189|4189| {
|4190|    |-	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to});
|    |4190|+	this.UnitFsm.ProcessMessage(this, {"type": "HealthChanged", "from": msg.from, "to": msg.to });
|4191|4191| };
|4192|4192| 
|4193|4193| UnitAI.prototype.OnRangeUpdate = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4193|4193| UnitAI.prototype.OnRangeUpdate = function(msg)
|4194|4194| {
|4195|4195| 	if (msg.tag == this.losRangeQuery)
|4196|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4196|+		this.UnitFsm.ProcessMessage(this, { "type": "LosRangeUpdate", "data": msg});
|4197|4197| 	else if (msg.tag == this.losHealRangeQuery)
|4198|4198| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4199|4199| };
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4193|4193| UnitAI.prototype.OnRangeUpdate = function(msg)
|4194|4194| {
|4195|4195| 	if (msg.tag == this.losRangeQuery)
|4196|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|    |4196|+		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg });
|4197|4197| 	else if (msg.tag == this.losHealRangeQuery)
|4198|4198| 		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|4199|4199| };
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4195|4195| 	if (msg.tag == this.losRangeQuery)
|4196|4196| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4197|4197| 	else if (msg.tag == this.losHealRangeQuery)
|4198|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4198|+		this.UnitFsm.ProcessMessage(this, { "type": "LosHealRangeUpdate", "data": msg});
|4199|4199| };
|4200|4200| 
|4201|4201| UnitAI.prototype.OnPackFinished = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4195|4195| 	if (msg.tag == this.losRangeQuery)
|4196|4196| 		this.UnitFsm.ProcessMessage(this, {"type": "LosRangeUpdate", "data": msg});
|4197|4197| 	else if (msg.tag == this.losHealRangeQuery)
|4198|    |-		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg});
|    |4198|+		this.UnitFsm.ProcessMessage(this, {"type": "LosHealRangeUpdate", "data": msg });
|4199|4199| };
|4200|4200| 
|4201|4201| UnitAI.prototype.OnPackFinished = function(msg)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4200|4200| 
|4201|4201| UnitAI.prototype.OnPackFinished = function(msg)
|4202|4202| {
|4203|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4203|+	this.UnitFsm.ProcessMessage(this, { "type": "PackFinished", "packed": msg.packed});
|4204|4204| };
|4205|4205| 
|4206|4206| //// Helper functions to be called by the FSM ////
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4200|4200| 
|4201|4201| UnitAI.prototype.OnPackFinished = function(msg)
|4202|4202| {
|4203|    |-	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|    |4203|+	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed });
|4204|4204| };
|4205|4205| 
|4206|4206| //// Helper functions to be called by the FSM ////
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4203|4203| 	this.UnitFsm.ProcessMessage(this, {"type": "PackFinished", "packed": msg.packed});
|4204|4204| };
|4205|4205| 
|4206|    |-//// Helper functions to be called by the FSM ////
|    |4206|+// // Helper functions to be called by the FSM ////
|4207|4207| 
|4208|4208| UnitAI.prototype.GetWalkSpeed = function()
|4209|4209| {
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4915|4915| UnitAI.prototype.AttackEntityInZone = function(ents)
|4916|4916| {
|4917|4917| 	var target = ents.find(target =>
|4918|    |-		this.CanAttack(target)
|4919|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|    |4918|+		this.CanAttack(target) &&
|    |4919|+		this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4920|4920| 		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4921|4921| 	);
|4922|4922| 	if (!target)
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4916|4916| {
|4917|4917| 	var target = ents.find(target =>
|4918|4918| 		this.CanAttack(target)
|4919|    |-		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true))
|4920|    |-		&& (this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|    |4919|+		&& this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|    |4920|+		(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|4921|4921| 	);
|4922|4922| 	if (!target)
|4923|4923| 		return false;
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'Engine'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4980|4980| 	// If we are guarding/escorting, don't abandon as long as the guarded unit is in target range of the attacker
|4981|4981| 	if (this.isGuardOf)
|4982|4982| 	{
|4983|    |-		var cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |4983|+		var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|4984|4984| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4985|4985| 		if (cmpUnitAI && cmpAttack &&
|4986|4986| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 3 tabs but found 4.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|4984|4984| 		var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|4985|4985| 		if (cmpUnitAI && cmpAttack &&
|4986|4986| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|4987|    |-				return false;
|    |4987|+			return false;
|4988|4988| 	}
|4989|4989| 
|4990|4990| 	// Stop if we're in hold-ground mode and it's too far from the holding point
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'Engine'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5022|5022| 	// If we are guarding/escorting, chase at least as long as the guarded unit is in target range of the attacker
|5023|5023| 	if (this.isGuardOf)
|5024|5024| 	{
|5025|    |-		let cmpUnitAI =  Engine.QueryInterface(target, IID_UnitAI);
|    |5025|+		let cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|5026|5026| 		let cmpAttack = Engine.QueryInterface(target, IID_Attack);
|5027|5027| 		if (cmpUnitAI && cmpAttack &&
|5028|5028| 		    cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5035|5035| 	return false;
|5036|5036| };
|5037|5037| 
|5038|    |-//// External interface functions ////
|    |5038|+// // External interface functions ////
|5039|5039| 
|5040|5040| UnitAI.prototype.SetFormationController = function(ent)
|5041|5041| {
|    | [NORMAL] ESLintBear (no-else-return):
|    | Unnecessary 'else' after 'return'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5191|5191| 	{
|5192|5192| 		if (this.isGuardOf == target && this.order && this.order.type == "Guard")
|5193|5193| 			return;
|5194|    |-		else
|5195|    |-			this.RemoveGuard();
|    |5194|+		this.RemoveGuard();
|5196|5195| 	}
|5197|5196| 
|5198|5197| 	this.AddOrder("Guard", { "target": target, "force": false }, queued);
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5522|5522| 
|5523|5523| 	if (this.IsFormationController())
|5524|5524| 		this.CallMemberFunction("CancelSetupTradeRoute", [target]);
|5525|    |-}
|    |5525|+};
|5526|5526| /**
|5527|5527|  * Adds trade order to the queue. Either walk to the first market, or
|5528|5528|  * start a new route. Not forced, so it can be interrupted by attacks.
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5543|5543| 	    this.workOrders.length && this.workOrders[0].type == "Trade")
|5544|5544| 	{
|5545|5545| 		let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|5546|    |-		if (cmpTrader.HasBothMarkets() && 
|    |5546|+		if (cmpTrader.HasBothMarkets() &&
|5547|5547| 		   (cmpTrader.GetFirstMarket() == target && cmpTrader.GetSecondMarket() == source ||
|5548|5548| 		    cmpTrader.GetFirstMarket() == source && cmpTrader.GetSecondMarket() == target))
|5549|5549| 		{
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5824|5824| 				{
|5825|5825| 					var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5826|5826| 					var targetClasses = this.order.data.targetClasses;
|5827|    |-					if (targetClasses.attack && cmpIdentity
|5828|    |-						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5827|+					if (targetClasses.attack && cmpIdentity &&
|    |5828|+						!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5829|5829| 						continue;
|5830|5830| 					if (targetClasses.avoid && cmpIdentity
|5831|5831| 						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5827|5827| 					if (targetClasses.attack && cmpIdentity
|5828|5828| 						&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5829|5829| 						continue;
|5830|    |-					if (targetClasses.avoid && cmpIdentity
|5831|    |-						&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5830|+					if (targetClasses.avoid && cmpIdentity &&
|    |5831|+						MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5832|5832| 						continue;
|5833|5833| 					// Only used by the AIs to prevent some choices of targets
|5834|5834| 					if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ])
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5850|5850| 		{
|5851|5851| 			var cmpIdentity = Engine.QueryInterface(targ, IID_Identity);
|5852|5852| 			var targetClasses = this.order.data.targetClasses;
|5853|    |-			if (cmpIdentity && targetClasses.attack
|5854|    |-				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|    |5853|+			if (cmpIdentity && targetClasses.attack &&
|    |5854|+				!MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5855|5855| 				continue;
|5856|5856| 			if (cmpIdentity && targetClasses.avoid
|5857|5857| 				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5853|5853| 			if (cmpIdentity && targetClasses.attack
|5854|5854| 				&& !MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.attack))
|5855|5855| 				continue;
|5856|    |-			if (cmpIdentity && targetClasses.avoid
|5857|    |-				&& MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|    |5856|+			if (cmpIdentity && targetClasses.avoid &&
|    |5857|+				MatchesClassList(cmpIdentity.GetClassesList(), targetClasses.avoid))
|5858|5858| 				continue;
|5859|5859| 			// Only used by the AIs to prevent some choices of targets
|5860|5860| 			if (targetClasses.vetoEntities && targetClasses.vetoEntities[targ])
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5996|5996| 
|5997|5997| UnitAI.prototype.SetHeldPosition = function(x, z)
|5998|5998| {
|5999|    |-	this.heldPosition = {"x": x, "z": z};
|    |5999|+	this.heldPosition = { "x": x, "z": z};
|6000|6000| };
|6001|6001| 
|6002|6002| UnitAI.prototype.SetHeldPositionOnEntity = function(entity)
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|5996|5996| 
|5997|5997| UnitAI.prototype.SetHeldPosition = function(x, z)
|5998|5998| {
|5999|    |-	this.heldPosition = {"x": x, "z": z};
|    |5999|+	this.heldPosition = {"x": x, "z": z };
|6000|6000| };
|6001|6001| 
|6002|6002| UnitAI.prototype.SetHeldPositionOnEntity = function(entity)
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6023|6023| 	return false;
|6024|6024| };
|6025|6025| 
|6026|    |-//// Helper functions ////
|    |6026|+// // Helper functions ////
|6027|6027| 
|6028|6028| /**
|6029|6029|  * General getter for ranges.
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6042|6042| 		return undefined;
|6043|6043| 
|6044|6044| 	return component.GetRange(type);
|6045|    |-}
|    |6045|+};
|6046|6046| 
|6047|6047| UnitAI.prototype.CanAttack = function(target)
|6048|6048| {
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6240|6240| 	return cmpPack && cmpPack.IsPacking();
|6241|6241| };
|6242|6242| 
|6243|    |-//// Formation specific functions ////
|    |6243|+// // Formation specific functions ////
|6244|6244| 
|6245|6245| UnitAI.prototype.IsAttackingAsFormation = function()
|6246|6246| {
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '&&' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6245|6245| UnitAI.prototype.IsAttackingAsFormation = function()
|6246|6246| {
|6247|6247| 	var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|6248|    |-	return cmpAttack && cmpAttack.CanAttackAsFormation()
|6249|    |-		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    |6248|+	return cmpAttack && cmpAttack.CanAttackAsFormation() &&
|    |6249|+		this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6250|6250| };
|6251|6251| 
|6252|6252| //// Animal specific functions ////
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
|6249|6249| 		&& this.GetCurrentState() == "FORMATIONCONTROLLER.COMBAT.ATTACKING";
|6250|6250| };
|6251|6251| 
|6252|    |-//// Animal specific functions ////
|    |6252|+// // Animal specific functions ////
|6253|6253| 
|6254|6254| UnitAI.prototype.MoveRandomly = function(distance)
|6255|6255| {

binaries/data/mods/public/simulation/components/UnitAI.js
| 338| »   »   »   return·true;
|    | [NORMAL] ESLintBear (consistent-return):
|    | Method 'Order.WalkToTarget' expected no return value.

binaries/data/mods/public/simulation/components/UnitAI.js
|1252| »   »   »   »   return·false;
|    | [NORMAL] ESLintBear (consistent-return):
|    | Method 'Timer' expected no return value.

binaries/data/mods/public/simulation/components/UnitAI.js
|4006| »   var·isWorkType·=·type·=>·type·==·"Gather"·||·type·==·"Trade"·||·type·==·"Repair"·||·type·==·"ReturnResource";
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'type' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4902| »   var·target·=·ents.find(target·=>·this.CanAttack(target));
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'target' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4917| »   var·target·=·ents.find(target·=>
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'target' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4963| »   var·ent·=·ents.find(ent·=>·this.CanHeal(ent));
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'ent' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|4986| »   »   ····cmpAttack.GetAttackTypes().some(type·=>·cmpUnitAI.CheckTargetAttackRange(this.isGuardOf,·type)))
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'type' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/UnitAI.js
|2046| »   »   »   »   »   »   &&·this.order.data.target·!=·msg.data.attacker·&&·this.GetBestAttackAgainst(msg.data.attacker,·true)·!=·"Capture")
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|3144| »   »   »   »   »   this.SetAnimationVariant(this.formationAnimationVariant)
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|3953| »   »   var·order·=·{·"type":·type,·"data":·data·};
|    | [NORMAL] JSHintBear:
|    | 'order' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|4037| »   for·(var·i·=·0;·i·<·this.orderQueue.length;·++i)
|    | [NORMAL] JSHintBear:
|    | 'i' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|4919| »   »   &&·this.CheckTargetDistanceFromHeldPosition(target,·IID_Attack,·this.GetBestAttackAgainst(target,·true))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|4920| »   »   &&·(this.GetStance().respondChaseBeyondVision·||·this.CheckTargetIsInVisionRange(target))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5525| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|5828| »   »   »   »   »   »   &&·!MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.attack))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5831| »   »   »   »   »   »   &&·MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.avoid))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5844| »   var·targets·=·this.GetTargetsFromUnit();
|    | [NORMAL] JSHintBear:
|    | 'targets' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5845| »   for·(var·targ·of·targets)
|    | [NORMAL] JSHintBear:
|    | 'targ' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5851| »   »   »   var·cmpIdentity·=·Engine.QueryInterface(targ,·IID_Identity);
|    | [NORMAL] JSHintBear:
|    | 'cmpIdentity' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5852| »   »   »   var·targetClasses·=·this.order.data.targetClasses;
|    | [NORMAL] JSHintBear:
|    | 'targetClasses' is already defined.

binaries/data/mods/public/simulation/components/UnitAI.js
|5854| »   »   »   »   &&·!MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.attack))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|5857| »   »   »   »   &&·MatchesClassList(cmpIdentity.GetClassesList(),·targetClasses.avoid))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.

binaries/data/mods/public/simulation/components/UnitAI.js
|6045| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.

binaries/data/mods/public/simulation/components/UnitAI.js
|6249| »   »   &&·this.GetCurrentState()·==·"FORMATIONCONTROLLER.COMBAT.ATTACKING";
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '&&'; readers may interpret this as an expression boundary.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2020/display/redirect

Freagarach added inline comments.Apr 20 2020, 10:58 AM
source/simulation2/system/ComponentManager.cpp
1044

Should we handle an empty array earlier?

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

source/simulation2/Simulation2.h
|  45| class·CSimulation2
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'classCSimulation2{' is invalid C code. Use --std or --language to configure the language.

source/simulation2/system/ComponentManager.h
|  39| class·CComponentManager
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'classCComponentManager{' is invalid C code. Use --std or --language to configure the language.
Executing section JS...
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2021/display/redirect

Stan added a subscriber: Stan.Apr 23 2020, 11:41 AM
Stan added inline comments.
binaries/data/mods/public/simulation/components/Guard.js
60

Does this mean the player no longer receives the warning he has been attacked?

source/simulation2/system/ComponentManager.cpp
447

Wonder if that errors out a lot?

1044

I guess you could to save some cycles. Could be profiled. One could also not send message for empty arrays :D

Dunno if that should be the responsibility of the caller or the callee.

1050

Leftover?

Freagarach marked an inline comment as done.Apr 23 2020, 11:59 AM
Freagarach added inline comments.
binaries/data/mods/public/simulation/components/Guard.js
60

Nope, that is handled differently.

Freagarach marked an inline comment as done and an inline comment as not done.Apr 29 2020, 10:52 AM
Freagarach added inline comments.
source/simulation2/system/ComponentManager.cpp
1050

Not sure where I should add the profiler stuff. I could do it in every function?
It is not a leftover, no ;)
Also not sure what the IFSPIKE, means? I assume it is like: if it takes longer than x, register it, or something?

Stan added inline comments.Apr 29 2020, 11:06 AM
source/simulation2/system/ComponentManager.cpp
1050

Yep, it does the profiling anyway, but if it's too small it doesn't register it in the graph. I guess you should check at which treshold it becomes relevant to have it.

For some functions it's normal to execute in 500us for some it's terrible

bb added a subscriber: bb.Apr 30 2020, 12:05 AM
bb added inline comments.
source/simulation2/system/ComponentManager.cpp
1020–1055

Do we want to keep this function, if we have a more general one?

1037

Where did this ENTIY_IS_LOCAL check come from?

1044

Empty arrays should probably not send a global messages. However there seems to be a problem here: We only send a global message for 1 ent. For example (taking an extreme) using this function to ownershipchange several entities, will just return 1 globalOwnershipchanged. So any component listening to that, will only know of 1 entities change and not of all others... Sounds like trouble, we don't want.

In the current implementation I guess one would need to send a global message for every entity. One could change all listeners to allow for several entities, but not sure if we want to go down that road...

Freagarach marked an inline comment as not done.Apr 30 2020, 7:25 AM
Freagarach added inline comments.
source/simulation2/system/ComponentManager.cpp
1020–1055

I'd say yes. This is needed e.g. for ownership changes, where a global message is to be sent for every single entity. Otherwise one would have to make an array every time one wants to send a message to a single entity, that sounds costly and unnecessary.

1037

Global messages to local entities are handles differently (see L1112), hence if there is at least one non-local entity we should send the global message using that entity.
But there might be a cleaner solution to this ^^

1044

The idea is that there can be only one message sent with DistributeMessage, so that needs to be sent globally only once, right? If one would send a global message for every entity in the array, the exact same global message is sent for all of them, which is rather unnecessary.
This implies that this function is not suited for the global ownership change, at least at the moment. That is where PostMessage comes in handy ;)

Freagarach updated this revision to Diff 11752.Apr 30 2020, 8:29 AM
Freagarach marked an inline comment as done and an inline comment as not done.
  • Early returns for empty entities.
  • Added comment regarding local entities.

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

source/simulation2/Simulation2.h
|  45| class·CSimulation2
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'classCSimulation2{' is invalid C code. Use --std or --language to configure the language.

source/simulation2/system/ComponentManager.h
|  39| class·CComponentManager
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'classCComponentManager{' is invalid C code. Use --std or --language to configure the language.
Executing section JS...
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2048/display/redirect

bb added a comment.May 1 2020, 5:12 PM

I think I see what you mean. Given that I think we found a design error in the current code: To me it appears the code implicitly assumes that when we send a PostMessage the target entity equals the origin entity. This patch (implicitly) breaks that assumption. I think doing this assumption is wrong anyways, and should be fixed. I think the following will bug: In the current code sending a message TO a local entity (wherever it came from) will not trigger a global message (for script components), so far so good. But a message FROM a local entity TO a global one, WILL trigger a global message and this sounds like problems ahead....

svn blaming this directed me to rP8865, stating Stop globally-subscribed component scripts receiving messages posted to local components, to reduce out-of-sync risks.. But I don't see how stopping messages send TO local ents prevents OOS's (I would see messages FROM local ents). We probably never OOS'ed since we rarely send messages from one ent to a different, let be a local ent to a non local ent, such that the message changes the sim.

To me it appears that we should check for the origin of a message instead for considering it a local ent or not and act upon that.

source/simulation2/system/ComponentManager.cpp
1033–1034

Actually on a second thought, we should send a global message shouldn't we? The change still happened, just no subscribers, so any global listener should still be notified (the global listener shouldn't care about other listeners, right?)

Freagarach planned changes to this revision.May 8 2020, 5:52 PM

Then the current message system needs to be reworked first I guess for we currently don't know who sent the message, only to whom it was sent.

source/simulation2/system/ComponentManager.cpp
1033–1034

Yep, agreed.

wraitii added a subscriber: wraitii.Jun 3 2020, 8:53 AM

As noted by stan -> See D576 for a situation that relies on local entities not sending messages to globally subscribed non-local entities.