HomeWildfire Games

Added new Random maps. Updated the existing ones with the new starting unit…
AuditedrP11137

Tags
None
Subscribers
Tokens
"Manufacturing Defect?" token, awarded by elexis.

Description

Added new Random maps. Updated the existing ones with the new starting unit formation.

Details

Auditors
elexis
Committed
SpahbodFeb 24 2012, 11:34 AM
Parents
rP11136: Automated build.
Branches
Unknown
Tags
Unknown

Event Timeline

elexis added a subscriber: elexis.Feb 20 2017, 4:19 AM

Problem: Map needs to work with 8 different mapsizes
Solution: Copy the entire code of map 8 times

elexis raised a concern with this commit.Mar 3 2017, 11:04 PM

See above. Got a WIP nuking all copy pasta for each mapsize and playernumbers.

This commit now has outstanding concerns.Mar 3 2017, 11:04 PM

The meme posted about snowflake searocks also works for guadalquivir_river.js. The memes from D252 also apply.

/ps/trunk/binaries/data/mods/public/maps/random/aegean_sea.js
417

Really explaining the argument of the painter constructors in hundreds of calls with a bunch of tabs?

485

What would we have done without these comments...

/ps/trunk/binaries/data/mods/public/maps/random/anatolian_plateau.js
1

Can't add an inline comment here for any reason. That loop was useless (if we already add a path from X to Y, then we don't need another from Y to X):

for (m = 0; m < numIslands; m++){
 for (n = 0; n < numIslands; n++){
   if(isConnected[m][n] == 1){
      isConnected[n][m] = 1;
   }
 }
}
/ps/trunk/binaries/data/mods/public/maps/random/guadalquivir_river.js
308

unused var

310

That value is never read from as it is overwritten in each if-statement below

314

After a too long time, I figured cu = curve

318

The wrong indentation mislead me to remove a wrong brace and commit a JS syntax error.

322

Took me only a day of solving equations to come to the conclusion that this is an exact copy of the other dozens of river functions and give those magic numbers human readable names.
That 200.0 had been 1/0.05/10, i.e. fadeDist = 0.005 and 1/fadeDist/10 .
That abs is not present in the other copies because the if determines the sign

That -3 had been some other constant some day, but all the constants were squelched so that noone could recognize them (and thus change them feasibly) anymore.

-> rP20185

339

Not to speak of 9 pairs of unneeded braces in each of the copies of this line.

/ps/trunk/binaries/data/mods/public/maps/random/the_nile.js
295

copies every mistake from guadalquivir river

elexis added inline comments.Oct 18 2017, 8:07 PM
/ps/trunk/binaries/data/mods/public/maps/random/rivers.js
641

No need to compute the angle with that formula, as its just halfway between the two player angles.

641

isRiver[c][numPlayers] doesn't have to be a two-dimensional array, nor a one-dimensional array.

In this commit there is a river between each neighbor, later it was changed to only add rivers between players. Can just query that, no need to save it in a two dimensional array where one dimension is never used.

657

No need for an array in thetha, seed, shallowstuff if it can be just determined in the loop below

666

Only one player loop needed as we only need to compare neighbors, not every player with everyone else.

The playerloop should be the outermost, as everything inside it is about that one river for that one player.

693

^ mess

elexis accepted this commit.Nov 10 2017, 6:26 PM

All of the issues yelled about above were fixed.
The rndRiver copies were removed by iirc spahbod in a later commit.
Most of the other copied code is equally copied in all the other maps.
So all of the issues that can be complained about in particularly this commit are finished.
Hence marking this as audited.

/ps/trunk/binaries/data/mods/public/maps/random/rivers.js
671

//very important calculations. don't change anything

Readable code doesn't fear modification

673

image point = foot of the perpendicular

677

c = determinant, cross product

691

sit is between 0 and 1 if the foot of the perpendicular is within the line segment given by the river start and end coordinates

692

scaleByMapSize(5,15) = half river width

740

duplication above

All concerns with this commit have now been addressed.Nov 10 2017, 6:26 PM