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
Branch
/ps/trunk
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 2125
Build 3449: Vulcan BuildJenkins
Build 3446: arc lint + arc unit

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

115

156

188

203

220

280

359

511


(

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

520

533

538

548

555

565

598

685

691

701

718

721

(2) should be 0, 1

815

866

909

938

979

1144

1149

1159

1166

1176

1344

1425

1748

1763

1813

1862

1869

1877

binaries/data/mods/public/maps/random/unknown_land.js
925

✓ and above until the last checkmark

1107

binaries/data/mods/public/maps/random/unknown_nomad.js
187

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

359

500

another forgotton (0, 1)

569

binaries/data/mods/public/maps/random/wild_lake.js
486

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.