fixed bug #7274, terrain probabilites when using rotations

This commit is contained in:
John W. C. McNabb 2006-10-09 21:38:45 +00:00
parent fd995bd7ae
commit edab950bff
3 changed files with 41 additions and 13 deletions

View file

@ -32,6 +32,7 @@ Version 1.3-svn:
* show leader's name and colour at status table even when that team is fogged
(patch #605)
* WML engine
* fixed terrain probabilities for terrains defined with rotations (bug #7274)
* added a 'hide_help' key that prevents a unit type from being listed in the
in-game help
* added an 'allow_new_game' key (default=yes) to prevent [multiplayer]

View file

@ -1,26 +1,47 @@
#testing terrain rotation probability
[terrain]
symbol_image=castle
id=castle
name= _ "Castle"
char=y
aliasof=W
[/terrain]
{FORESTADJ y g 33 mountains}
{FORESTADJ y g 50 forest}
{FORESTADJ y g 100 reed1-small}
#{SHEX y overlay 50 mountains}
#{SHEX y overlay 100 forest}
[test]
name="Test scenario"
map_data="mmmmggggggggggggggggggggggggggggggggg
mmmmggggggggggggggggggggggggggggggggg
mgggggCCCCggggggggggggggggggggggggggg
mgggggC1Cgggggggggfffffgggggggggggggg
mgggggCCCgggggggggfffffgggccccggggggg
mgggggCCCgggggggggfffffgggcchhggggggg
mgggggtgtgggggggggggggggggccccggggggg
ggggggggggggggggggggggggggggggggggggg
ggggggggggggggggggggggggggggggggggggg
ggggggggggggggggggggggggggggggggggggg
gggggggggggggggggggggCCCggggggggggggg
gggggggggggggggggggggCCCggggggggggggg
ggggggggggggggggggggggggggggggggggggg
ggnnKnggggggggggggggggggggggggggggggg
gggnngggggggggggggggggggggggggggggggg
gggggggggggggggggggggggggggg2gggggggg
gggggggDgggggtggggggggggggggggggggggg
ggggggDgggtgggggggggggggggggggggggggg
ggggggggggggggggggggggggggggggggggggg
mgggggtgtgggggggggggggggggccccygggygg
ggggggggggggggggggggggggggggggggygggg
ggggggggggggggggggggggggggggggygggygg
ggggggggggggggggggggggggggggggggygggg
gggggggggggggggggggggCCCggggggygggygg
gggggggggggggggggggggCCCggggggggygggg
ggggggggggggggggggggggggggggggygggygg
ggnnKnggggggggggggggggggggggggggygggg
gggnngggggggggggggggggggggggggygggygg
gggggggggggggggggggggggggggg2gggygggg
gggggggDgggggtggggggggggggggggygggygg
ggggggDgggtgggggggggggggggggggggygggg
ggggggggggggggggggggggggggggggygggygg
"
[event]
name=moveto
[filter]

View file

@ -650,9 +650,15 @@ void terrain_builder::add_rotated_rules(building_ruleset& rules, building_rule&
add_rule(rules, tpl);
} else {
const std::vector<std::string>& rot = utils::split(rotations, ',');
int prob = tpl.probability;
double p = ((float)prob)/100;
double in = 1.0/rot.size();
prob = (prob >= 100 || prob<0) ? 100 : floor(100*(1.0 - pow(1.0 - p,in)));
for(size_t angle = 0; angle < rot.size(); angle++) {
building_rule rule = rotate_rule(tpl, angle, rot);
rule.probability=prob;
//correct probability for number of rotations
add_rule(rules, rule);
}
}