Page MenuHomeWildfire Games

Nuke randInt function
ClosedPublic

Authored by bb on Jun 2 2017, 10:16 PM.

Details

Summary

As of rP19270 the randInt function got depricated, but wasn't removed since it was still used in the rms. Following commits (rp19355 rP19433 etc.) removed most instances of randInt, this commit nukes the last bit in Unknown* and newly added ones...

As all instance have been removed the old function and the random.js file can be removed. Notice some wiki pages need to be adapted since they mention this file:
https://trac.wildfiregames.com/wiki/Rmgen_Library
https://trac.wildfiregames.com/wiki/Random_Map_Scripting_Interface
https://trac.wildfiregames.com/wiki/Random_Map_Scripting_Functions

refs D121 D235 D278 D201

Test Plan

Tests changed maps in Atlas.
Scroll through the code and see the code in logicaly equivalent
notice tons of whitespace errors in surrounding code, but consider them out of scope.
grep code and see all instances of randInt are removed so the old function can safely be removed.

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

bb created this revision.Jun 2 2017, 10:16 PM
Owners added a subscriber: Restricted Owners Package.Jun 2 2017, 10:16 PM
elexis accepted this revision.Jun 3 2017, 1:52 AM

Thanks and congratulations on getting it both fixed and reviewed ;-)

binaries/data/mods/public/maps/random/unknown.js
85 ↗(On Diff #2390)

115 ↗(On Diff #2390)

156 ↗(On Diff #2390)

188 ↗(On Diff #2390)

203 ↗(On Diff #2390)

220 ↗(On Diff #2390)

280 ↗(On Diff #2390)

359 ↗(On Diff #2390)

511 ↗(On Diff #2390)


(

randInt(3)
= Math.floor(Math.random() * 3)

where Math.random() returns something between 0 (inclusive) and 1 (exclusive).

So the term returns 0, 1 or 2 with equal probability. (some phrase with distribution would be more correct I guess)

So !randInt(3) is true with 1/3 chance
)

516 ↗(On Diff #2390)

520 ↗(On Diff #2390)

533 ↗(On Diff #2390)

538 ↗(On Diff #2390)

548 ↗(On Diff #2390)

555 ↗(On Diff #2390)

565 ↗(On Diff #2390)

598 ↗(On Diff #2390)

685 ↗(On Diff #2390)

691 ↗(On Diff #2390)

701 ↗(On Diff #2390)

718 ↗(On Diff #2390)

721 ↗(On Diff #2390)

(2) should be 0, 1

815 ↗(On Diff #2390)

866 ↗(On Diff #2390)

909 ↗(On Diff #2390)

938 ↗(On Diff #2390)

979 ↗(On Diff #2390)

1144 ↗(On Diff #2390)

1149 ↗(On Diff #2390)

1159 ↗(On Diff #2390)

1166 ↗(On Diff #2390)

1176 ↗(On Diff #2390)

1344 ↗(On Diff #2390)

1425 ↗(On Diff #2390)

1748 ↗(On Diff #2390)

1763 ↗(On Diff #2390)

1813 ↗(On Diff #2390)

1862 ↗(On Diff #2390)

1869 ↗(On Diff #2390)

1877 ↗(On Diff #2390)

binaries/data/mods/public/maps/random/unknown_land.js
925 ↗(On Diff #2390)

✓ and above until the last checkmark

1107 ↗(On Diff #2390)

binaries/data/mods/public/maps/random/unknown_nomad.js
187 ↗(On Diff #2390)

In the other occurances you pass 1/3, so should be 1/4 here

359 ↗(On Diff #2390)

500 ↗(On Diff #2390)

another forgotton (0, 1)

569 ↗(On Diff #2390)

binaries/data/mods/public/maps/random/wild_lake.js
486 ↗(On Diff #2390)

Oh, I had missed it (but not in Hannibals maps)

This revision is now accepted and ready to land.Jun 3 2017, 1:52 AM
Vulcan added a subscriber: Vulcan.Jun 3 2017, 2:18 AM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jw:8080/job/phabricator/1453/ for more details.

This revision was automatically updated to reflect the committed changes.