Page MenuHomeWildfire Games

Units should only be able to build structures from their owner's civ, and not from their identity civ
ClosedPublic

Authored by mimo on Nov 25 2017, 4:05 PM.

Details

Summary

If we ever implement unit conversion, we don't want the civ capturing a unit to have access to all structures from the captured one.
See #4870 for more details

Test Plan

Agree with what is said in the summary and check that it was not the case up to now

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

mimo created this revision.Nov 25 2017, 4:05 PM
elexis accepted this revision.EditedNov 25 2017, 4:18 PM
elexis added a subscriber: elexis.

I agree with the Builder.js diff.
It can be tested with the "salad bowl" cheat and we notice that we can no more build things of the civ of the unit but buildings of the civ of the player, as advertized.
No clue about the petra one, but I have tested it with the AI and the reported error was gone.

If any mod wants to allow building of converted units, the new boolean property in Builder templates should be easy to implement in the simulation side (1 BuilderAI diff + 3 templates + something in the AI), see ticket.

Edit: Thanks for the patch!

This revision is now accepted and ready to land.Nov 25 2017, 4:18 PM
Vulcan added a subscriber: Vulcan.Nov 25 2017, 4:42 PM

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

Updating workspaces...
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (308 tests).
In TestComponentScripts::test_scripts:
../../../source/test_setup.cpp:134: Error: Test failed: Stack trace:
@simulation/components/tests/test_Builder.js:18:1
Expected equal, got [] !== ["structures/{civ}_barracks", "structures/{civ}_civil_centre"]
../../../source/test_setup.cpp:134: Error: Test failed: Stack trace:
@simulation/components/tests/test_Builder.js:28:1
Expected equal, got [] !== ["structures/iber_barracks", "structures/iber_civil_centre"]
ERROR: JavaScript error: simulation/components/Builder.js line 37
TypeError: cmpPlayer.GetCiv is not a function
  Builder.prototype.GetEntitiesList@simulation/components/Builder.js:37:44
  @simulation/components/tests/test_Builder.js:43:25
/mnt/data/jenkins-phabricator/workspace/phabricator/source/simulation2/components/tests/test_scripts.h:44: Error: Test failed: L"Running script simulation/components/tests/test_Builder.js"
/mnt/data/jenkins-phabricator/workspace/phabricator/source/simulation2/components/tests/test_scripts.h:44: Error: Assertion failed: scriptInterface.LoadScript(pathname, content)
..................................................................................................................................................................................................................................................................................................................
Failed 1 and Skipped 0 of 308 tests
Success rate: 99%
Running debug tests...
Running cxxtest tests (308 tests).
In TestComponentScripts::test_scripts:
../../../source/test_setup.cpp:134: Error: Test failed: Stack trace:
@simulation/components/tests/test_Builder.js:18:1
Expected equal, got [] !== ["structures/{civ}_barracks", "structures/{civ}_civil_centre"]
../../../source/test_setup.cpp:134: Error: Test failed: Stack trace:
@simulation/components/tests/test_Builder.js:28:1
Expected equal, got [] !== ["structures/iber_barracks", "structures/iber_civil_centre"]
ERROR: JavaScript error: simulation/components/Builder.js line 37
TypeError: cmpPlayer.GetCiv is not a function
  Builder.prototype.GetEntitiesList@simulation/components/Builder.js:37:44
  @simulation/components/tests/test_Builder.js:43:25
/mnt/data/jenkins-phabricator/workspace/phabricator/source/simulation2/components/tests/test_scripts.h:44: Error: Test failed: L"Running script simulation/components/tests/test_Builder.js"
/mnt/data/jenkins-phabricator/workspace/phabricator/source/simulation2/components/tests/test_scripts.h:44: Error: Assertion failed: scriptInterface.LoadScript(pathname, content)
..................................................................................................................................................................................................................................................................................................................
Failed 1 and Skipped 0 of 308 tests
Success rate: 99%
Checking XML files...
Executing section Default...
Executing section Source...
Executing section JS...
This revision was automatically updated to reflect the committed changes.