I am further unhappy about the descriptions in terrains/init.lua, see below.

If someone want to make more terrains, he should be able to choose the right 
"is" value. Call me scrupulously, sometimes i am ;)

Diff comments:

> === modified file 'src/ai/ai_help_structs.h'
> --- src/ai/ai_help_structs.h  2015-02-05 12:11:20 +0000
> +++ src/ai/ai_help_structs.h  2015-02-16 13:12:39 +0000
> @@ -147,8 +147,8 @@
>  
>       bool accept(const Map& /* map */, const FCoords& coord) const {
>               return (world_.terrain_descr(coord.field->terrain_d()).get_is() 
> &
> -                     TerrainDescription::WATER) ||
> -                    (world_.terrain_descr(coord.field->terrain_r()).get_is() 
> & TerrainDescription::WATER);
> +                               TerrainDescription::Type::kWater) ||
> +                              
> (world_.terrain_descr(coord.field->terrain_r()).get_is() & 
> TerrainDescription::Type::kWater);
>       }
>  
>  private:
> 
> === modified file 'src/editor/tools/editor_increase_resources_tool.cc'
> --- src/editor/tools/editor_increase_resources_tool.cc        2014-12-01 
> 21:47:22 +0000
> +++ src/editor/tools/editor_increase_resources_tool.cc        2015-02-16 
> 13:12:39 +0000
> @@ -37,7 +37,7 @@
>       if (!terrain.is_resource_valid(resource)) {
>               return -1;
>       }
> -     if (terrain.get_is() & Widelands::TerrainDescription::UNPASSABLE) {
> +     if (terrain.get_is() & 
> Widelands::TerrainDescription::Type::kUnpassable) {
>               return 8;
>       }
>       return 1;
> 
> === modified file 'src/editor/tools/editor_info_tool.cc'
> --- src/editor/tools/editor_info_tool.cc      2015-01-30 23:10:35 +0000
> +++ src/editor/tools/editor_info_tool.cc      2015-02-16 13:12:39 +0000
> @@ -104,22 +104,22 @@
>       Widelands::TerrainDescription::Type terrain_is = ter.get_is();
>       std::vector<std::string> terrain_is_strings;
>  
> -     if (terrain_is == Widelands::TerrainDescription::Type::GREEN) {
> +     if (terrain_is == Widelands::TerrainDescription::Type::kGreen) {
>               terrain_is_strings.push_back(_("arable"));
>       }
> -     if (terrain_is & Widelands::TerrainDescription::Type::DRY) {
> +     if (terrain_is & Widelands::TerrainDescription::Type::kDry) {
>               terrain_is_strings.push_back(_("treeless"));
>       }
> -     if (terrain_is & Widelands::TerrainDescription::Type::WATER) {
> +     if (terrain_is & Widelands::TerrainDescription::Type::kWater) {
>               terrain_is_strings.push_back(_("aquatic"));
>       }
> -     if (terrain_is & Widelands::TerrainDescription::Type::ACID) {
> +     if (terrain_is & Widelands::TerrainDescription::Type::kDead) {
>               terrain_is_strings.push_back(_("dead"));
>       }
> -     if (terrain_is & Widelands::TerrainDescription::Type::MOUNTAIN) {
> +     if (terrain_is & Widelands::TerrainDescription::Type::kMountain) {
>               terrain_is_strings.push_back(_("mountainous"));
>       }
> -     if (terrain_is & Widelands::TerrainDescription::Type::UNPASSABLE) {
> +     if (terrain_is & Widelands::TerrainDescription::Type::kUnpassable) {
>               terrain_is_strings.push_back(_("unpassable"));
>       }
>       buf += "• " + (boost::format(_("Category: %s"))
> 
> === modified file 
> 'src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc'
> --- src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc       
> 2015-01-30 23:10:35 +0000
> +++ src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc       
> 2015-02-16 13:12:39 +0000
> @@ -43,13 +43,13 @@
>  using namespace Widelands;
>  
>  static const int32_t check[] = {
> -     TerrainDescription::GREEN,                                 //  "green"
> -     TerrainDescription::DRY,                                   //  "dry"
> -     TerrainDescription::DRY | TerrainDescription::MOUNTAIN,    //  
> "mountain"
> -     TerrainDescription::DRY | TerrainDescription::UNPASSABLE,  //  
> "unpassable"
> -     TerrainDescription::ACID | TerrainDescription::DRY |
> -             TerrainDescription::UNPASSABLE,  //  "dead" or "acid"
> -     TerrainDescription::UNPASSABLE | TerrainDescription::DRY | 
> TerrainDescription::WATER,
> +     TerrainDescription::Type::kGreen,                                 //  
> "green"
> +     TerrainDescription::Type::kDry,                                   //  
> "dry"
> +     TerrainDescription::Type::kDry | TerrainDescription::Type::kMountain,   
>  //  "mountain"
> +     TerrainDescription::Type::kDry | TerrainDescription::Type::kUnpassable, 
>  //  "unpassable"
> +     TerrainDescription::Type::kDead | TerrainDescription::Type::kDry |
> +             TerrainDescription::Type::kUnpassable,  //  "dead"
> +     TerrainDescription::Type::kUnpassable | TerrainDescription::Type::kDry 
> | TerrainDescription::Type::kWater,
>       -1,  // end marker
>  };
>  
> @@ -82,7 +82,7 @@
>                             BlendMode::UseAlpha, texture);
>               Point pt(1, terrain_texture.height() - kSmallPicHeight - 1);
>  
> -             if (ter_is == TerrainDescription::GREEN) {
> +             if (ter_is == TerrainDescription::Type::kGreen) {
>                       blit(Rect(pt.x, pt.y, green->width(), green->height()),
>                            *green,
>                            Rect(0, 0, green->width(), green->height()),
> @@ -93,7 +93,7 @@
>                       /** TRANSLATORS: This is a terrain type tooltip in the 
> editor */
>                       tooltips.push_back(_("arable"));
>               } else {
> -                     if (ter_is & TerrainDescription::WATER) {
> +                     if (ter_is & TerrainDescription::Type::kWater) {
>                               blit(Rect(pt.x, pt.y, water->width(), 
> water->height()),
>                                    *water,
>                                    Rect(0, 0, water->width(), 
> water->height()),
> @@ -104,7 +104,7 @@
>                               /** TRANSLATORS: This is a terrain type tooltip 
> in the editor */
>                               tooltips.push_back(_("aquatic"));
>                       }
> -                     else if (ter_is & TerrainDescription::MOUNTAIN) {
> +                     else if (ter_is & TerrainDescription::Type::kMountain) {
>                               blit(Rect(pt.x, pt.y, mountain->width(), 
> mountain->height()),
>                                    *mountain,
>                                    Rect(0, 0, mountain->width(), 
> mountain->height()),
> @@ -115,7 +115,7 @@
>                               /** TRANSLATORS: This is a terrain type tooltip 
> in the editor */
>                               tooltips.push_back(_("mountainous"));
>                       }
> -                     if (ter_is & TerrainDescription::ACID) {
> +                     if (ter_is & TerrainDescription::Type::kDead) {
>                               blit(Rect(pt.x, pt.y, dead->width(), 
> dead->height()),
>                                    *dead,
>                                    Rect(0, 0, dead->width(), dead->height()),
> @@ -126,7 +126,7 @@
>                               /** TRANSLATORS: This is a terrain type tooltip 
> in the editor */
>                               tooltips.push_back(_("dead"));
>                       }
> -                     if (ter_is & TerrainDescription::UNPASSABLE) {
> +                     if (ter_is & TerrainDescription::Type::kUnpassable) {
>                               blit(Rect(pt.x, pt.y, unpassable->width(), 
> unpassable->height()),
>                                    *unpassable,
>                                    Rect(0, 0, unpassable->width(), 
> unpassable->height()),
> @@ -137,7 +137,7 @@
>                               /** TRANSLATORS: This is a terrain type tooltip 
> in the editor */
>                               tooltips.push_back(_("unpassable"));
>                       }
> -                     if (ter_is & TerrainDescription::DRY) {
> +                     if (ter_is & TerrainDescription::Type::kDry) {
>                               blit(Rect(pt.x, pt.y, dry->width(), 
> dry->height()),
>                                    *dry,
>                                    Rect(0, 0, dry->width(), dry->height()),
> 
> === modified file 'src/logic/map.cc'
> --- src/logic/map.cc  2015-02-12 07:55:25 +0000
> +++ src/logic/map.cc  2015-02-16 13:12:39 +0000
> @@ -215,7 +215,7 @@
>                               const TerrainDescription& terr = 
> world.terrain_descr(f1.field->terrain_r());
>                               const int8_t resr = terr.get_default_resource();
>                               const int default_amount = 
> terr.get_default_resource_amount();
> -                             if ((terr.get_is() & 
> TerrainDescription::UNPASSABLE) && default_amount > 0)
> +                             if ((terr.get_is() & 
> TerrainDescription::Type::kUnpassable) && default_amount > 0)
>                                       m[resr] += 3;
>                               else
>                                       ++m[resr];
> @@ -225,7 +225,7 @@
>                               const TerrainDescription& terd = 
> world.terrain_descr(f1.field->terrain_d());
>                               const int8_t resd = terd.get_default_resource();
>                               const int default_amount = 
> terd.get_default_resource_amount();
> -                             if ((terd.get_is() & 
> TerrainDescription::UNPASSABLE) && default_amount > 0)
> +                             if ((terd.get_is() & 
> TerrainDescription::Type::kUnpassable) && default_amount > 0)
>                                       m[resd] += 3;
>                               else
>                                       ++m[resd];
> @@ -238,7 +238,7 @@
>                               const TerrainDescription& terd = 
> world.terrain_descr(f1.field->terrain_d());
>                               const int8_t resd = terd.get_default_resource();
>                               const int default_amount = 
> terd.get_default_resource_amount();
> -                             if ((terd.get_is() & 
> TerrainDescription::UNPASSABLE) && default_amount > 0)
> +                             if ((terd.get_is() & 
> TerrainDescription::Type::kUnpassable) && default_amount > 0)
>                                       m[resd] += 3;
>                               else
>                                       ++m[resd];
> @@ -251,7 +251,7 @@
>                               const TerrainDescription& terr = 
> world.terrain_descr(f1.field->terrain_r());
>                               const int8_t resr = terr.get_default_resource();
>                               const int default_amount = 
> terr.get_default_resource_amount();
> -                             if ((terr.get_is() & 
> TerrainDescription::UNPASSABLE) && default_amount > 0)
> +                             if ((terr.get_is() & 
> TerrainDescription::Type::kUnpassable) && default_amount > 0)
>                                       m[resr] += 3;
>                               else
>                                       ++m[resr];
> @@ -1037,28 +1037,28 @@
>       //  1b) Collect some information about the neighbours
>       uint8_t cnt_unpassable = 0;
>       uint8_t cnt_water = 0;
> -     uint8_t cnt_acid = 0;
> -
> -     if  (tr_d_terrain_is & TerrainDescription::UNPASSABLE) ++cnt_unpassable;
> -     if  (tl_r_terrain_is & TerrainDescription::UNPASSABLE) ++cnt_unpassable;
> -     if  (tl_d_terrain_is & TerrainDescription::UNPASSABLE) ++cnt_unpassable;
> -     if   (l_r_terrain_is & TerrainDescription::UNPASSABLE) ++cnt_unpassable;
> -     if   (f_d_terrain_is & TerrainDescription::UNPASSABLE) ++cnt_unpassable;
> -     if   (f_r_terrain_is & TerrainDescription::UNPASSABLE) ++cnt_unpassable;
> -
> -     if  (tr_d_terrain_is & TerrainDescription::WATER)      ++cnt_water;
> -     if  (tl_r_terrain_is & TerrainDescription::WATER)      ++cnt_water;
> -     if  (tl_d_terrain_is & TerrainDescription::WATER)      ++cnt_water;
> -     if   (l_r_terrain_is & TerrainDescription::WATER)      ++cnt_water;
> -     if   (f_d_terrain_is & TerrainDescription::WATER)      ++cnt_water;
> -     if   (f_r_terrain_is & TerrainDescription::WATER)      ++cnt_water;
> -
> -     if  (tr_d_terrain_is & TerrainDescription::ACID)       ++cnt_acid;
> -     if  (tl_r_terrain_is & TerrainDescription::ACID)       ++cnt_acid;
> -     if  (tl_d_terrain_is & TerrainDescription::ACID)       ++cnt_acid;
> -     if   (l_r_terrain_is & TerrainDescription::ACID)       ++cnt_acid;
> -     if   (f_d_terrain_is & TerrainDescription::ACID)       ++cnt_acid;
> -     if   (f_r_terrain_is & TerrainDescription::ACID)       ++cnt_acid;
> +     uint8_t cnt_dead = 0;
> +
> +     if  (tr_d_terrain_is & TerrainDescription::Type::kUnpassable) 
> ++cnt_unpassable;
> +     if  (tl_r_terrain_is & TerrainDescription::Type::kUnpassable) 
> ++cnt_unpassable;
> +     if  (tl_d_terrain_is & TerrainDescription::Type::kUnpassable) 
> ++cnt_unpassable;
> +     if   (l_r_terrain_is & TerrainDescription::Type::kUnpassable) 
> ++cnt_unpassable;
> +     if   (f_d_terrain_is & TerrainDescription::Type::kUnpassable) 
> ++cnt_unpassable;
> +     if   (f_r_terrain_is & TerrainDescription::Type::kUnpassable) 
> ++cnt_unpassable;
> +
> +     if  (tr_d_terrain_is & TerrainDescription::Type::kWater)      
> ++cnt_water;
> +     if  (tl_r_terrain_is & TerrainDescription::Type::kWater)      
> ++cnt_water;
> +     if  (tl_d_terrain_is & TerrainDescription::Type::kWater)      
> ++cnt_water;
> +     if   (l_r_terrain_is & TerrainDescription::Type::kWater)      
> ++cnt_water;
> +     if   (f_d_terrain_is & TerrainDescription::Type::kWater)      
> ++cnt_water;
> +     if   (f_r_terrain_is & TerrainDescription::Type::kWater)      
> ++cnt_water;
> +
> +     if  (tr_d_terrain_is & TerrainDescription::Type::kDead)       
> ++cnt_dead;
> +     if  (tl_r_terrain_is & TerrainDescription::Type::kDead)       
> ++cnt_dead;
> +     if  (tl_d_terrain_is & TerrainDescription::Type::kDead)       
> ++cnt_dead;
> +     if   (l_r_terrain_is & TerrainDescription::Type::kDead)       
> ++cnt_dead;
> +     if   (f_d_terrain_is & TerrainDescription::Type::kDead)       
> ++cnt_dead;
> +     if   (f_r_terrain_is & TerrainDescription::Type::kDead)       
> ++cnt_dead;
>  
>  
>       //  2) Passability
> @@ -1075,7 +1075,7 @@
>  
>       // 2c) [OVERRIDE] If any of the neighbouring triangles is really "bad" 
> (such
>       // as lava), we can neither walk nor swim to this node.
> -     if (cnt_acid)
> +     if (cnt_dead)
>               caps &= ~(MOVECAPS_WALK | MOVECAPS_SWIM);
>  
>       //  === everything below is used to check buildability ===
> @@ -1265,10 +1265,10 @@
>       uint32_t cnt_mountain = 0;
>       uint32_t cnt_dry = 0;
>       for (uint32_t i = 0; i < 6; ++i) {
> -             if (terrains[i] & TerrainDescription::WATER)
> +             if (terrains[i] & TerrainDescription::Type::kWater)
>                       return BaseImmovable::NONE;
> -             if (terrains[i] & TerrainDescription::MOUNTAIN) ++cnt_mountain;
> -             if (terrains[i] & TerrainDescription::DRY) ++cnt_dry;
> +             if (terrains[i] & TerrainDescription::Type::kMountain) 
> ++cnt_mountain;
> +             if (terrains[i] & TerrainDescription::Type::kDry) ++cnt_dry;
>       }
>  
>       if (cnt_mountain == 6) {
> 
> === modified file 'src/logic/worker.cc'
> --- src/logic/worker.cc       2015-01-15 15:33:52 +0000
> +++ src/logic/worker.cc       2015-02-16 13:12:39 +0000
> @@ -2708,11 +2708,11 @@
>                       bool is_center_mountain =
>                               
> (world.terrain_descr(owner_area.field->terrain_d()).get_is()
>                                &
> -                              TerrainDescription::MOUNTAIN)
> +                              TerrainDescription::Type::kMountain)
>                               |
>                               
> (world.terrain_descr(owner_area.field->terrain_r()).get_is()
>                                &
> -                              TerrainDescription::MOUNTAIN);
> +                              TerrainDescription::Type::kMountain);
>                       // Only run towards fields that are on a mountain (or 
> not)
>                       // depending on position of center
>                       bool is_target_mountain;
> @@ -2725,11 +2725,11 @@
>                               is_target_mountain =
>                                       
> (world.terrain_descr(target.field->terrain_d()).get_is()
>                                        &
> -                                      TerrainDescription::MOUNTAIN)
> +                                      TerrainDescription::Type::kMountain)
>                                       |
>                                       
> (world.terrain_descr(target.field->terrain_r()).get_is()
>                                        &
> -                                      TerrainDescription::MOUNTAIN);
> +                                      TerrainDescription::Type::kMountain);
>                               if (i == 0)
>                                       i = list.size();
>                               --i;
> 
> === modified file 'src/logic/world/terrain_description.cc'
> --- src/logic/world/terrain_description.cc    2015-01-31 16:03:59 +0000
> +++ src/logic/world/terrain_description.cc    2015-02-16 13:12:39 +0000
> @@ -39,30 +39,28 @@
>  // Parse a terrain type from the giving string.
>  TerrainDescription::Type terrain_type_from_string(const std::string& type) {
>       if (type == "green") {
> -             return TerrainDescription::GREEN;
> +             return TerrainDescription::Type::kGreen;
>       }
>       if (type == "dry") {
> -             return TerrainDescription::DRY;
> +             return TerrainDescription::Type::kDry;
>       }
>       if (type == "water") {
> -             return static_cast<TerrainDescription::Type>(
> -                TerrainDescription::WATER | TerrainDescription::DRY | 
> TerrainDescription::UNPASSABLE);
> +             return 
> static_cast<TerrainDescription::Type>(TerrainDescription::Type::kWater |
> +                                                                             
>                                                         
> TerrainDescription::Type::kDry |
> +                                                                             
>                                                         
> TerrainDescription::Type::kUnpassable);
>       }
> -     if (type == "acid") {
> -             return static_cast<TerrainDescription::Type>(
> -                TerrainDescription::ACID | TerrainDescription::DRY | 
> TerrainDescription::UNPASSABLE);
> +     if (type == "dead") {
> +             return 
> static_cast<TerrainDescription::Type>(TerrainDescription::Type::kDead |
> +                                                                             
>                                                         
> TerrainDescription::Type::kDry |
> +                                                                             
>                                                         
> TerrainDescription::Type::kUnpassable);
>       }
>       if (type == "mountain") {
> -             return 
> static_cast<TerrainDescription::Type>(TerrainDescription::DRY |
> -                                                          
> TerrainDescription::MOUNTAIN);
> -     }
> -     if (type == "dead") {
> -             return static_cast<TerrainDescription::Type>(
> -                TerrainDescription::DRY | TerrainDescription::UNPASSABLE | 
> TerrainDescription::ACID);
> +             return 
> static_cast<TerrainDescription::Type>(TerrainDescription::Type::kDry |
> +                                                                             
>                                                         
> TerrainDescription::Type::kMountain);
>       }
>       if (type == "unpassable") {
> -             return 
> static_cast<TerrainDescription::Type>(TerrainDescription::DRY |
> -                                                          
> TerrainDescription::UNPASSABLE);
> +             return 
> static_cast<TerrainDescription::Type>(TerrainDescription::Type::kDry |
> +                                                                             
>                                                         
> TerrainDescription::Type::kUnpassable);
>       }
>       throw LuaError((boost::format("invalid terrain type '%s'") % 
> type).str());
>  }
> 
> === modified file 'src/logic/world/terrain_description.h'
> --- src/logic/world/terrain_description.h     2014-11-28 05:40:53 +0000
> +++ src/logic/world/terrain_description.h     2015-02-16 13:12:39 +0000
> @@ -43,12 +43,12 @@
>  class TerrainDescription {
>  public:
>       enum Type {
> -             GREEN = 0,
> -             DRY = 1,
> -             WATER =  2,
> -             ACID = 4,
> -             MOUNTAIN = 8,
> -             UNPASSABLE = 16,
> +             kGreen = 0,
> +             kDry = 1,
> +             kWater =  2,
> +             kDead = 4,
> +             kMountain = 8,
> +             kUnpassable = 16,
>       };
>  
>       TerrainDescription(const LuaTable& table, const World&);
> 
> === modified file 'world/terrains/init.lua'
> --- world/terrains/init.lua   2015-01-30 10:16:22 +0000
> +++ world/terrains/init.lua   2015-02-16 13:12:39 +0000
> @@ -38,6 +38,16 @@
>     -- Type of terrain. Describes if the terrain is walkable, swimmable, if
>     -- mines or buildings can be build on it, if flags can be build on it and 
> so
>     -- on.
> +   --
> +   -- The following properties are available:
> +   -- "green": Allows building of normal buildings and roads
> +   -- "mountain": Allows building of mines and roads
> +   -- "dry": Allows building of roads only. Trees don't like this terrain.

Do allways and forever trees don't like this terrain?

> +   -- "water": Nothing can be built here, but ships and aquatic animals can 
> pass
> +   -- "dead": Nothing can be built here, and nothing can walk on it, and 
> nothing will grow.
> +   -- "unpassable": Nothing can be built here, and nothing can walk on it
> +   --
> +   -- Note that "is" also has implications for trees' terrain affinity.

Is this really true? And if, it is a vague sentence. If i want to make more 
terrains, which knowledge do i need for defining a correct "is" value?

>     is = "green",
>  
>     -- The list resources that can be found in this terrain.
> @@ -267,7 +277,7 @@
>     name = "lava",
>     descname = _ "Lava",
>     editor_category = "green",
> -   is = "acid",
> +   is = "dead",
>     valid_resources = {},
>     default_resource = "",
>     default_resource_amount = 0,
> @@ -482,7 +492,7 @@
>     name = "lava-stone1",
>     descname = _ "Lava Rocks",
>     editor_category = "wasteland",
> -   is = "acid",
> +   is = "dead",
>     valid_resources = {},
>     default_resource = "",
>     default_resource_amount = 0,
> @@ -498,7 +508,7 @@
>     name = "lava-stone2",
>     descname = _ "Lava Rocks",
>     editor_category = "wasteland",
> -   is = "acid",
> +   is = "dead",
>     valid_resources = {},
>     default_resource = "",
>     default_resource_amount = 0,
> 


-- 
https://code.launchpad.net/~widelands-dev/widelands/terrain_doc/+merge/249747
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/terrain_doc.

_______________________________________________
Mailing list: https://launchpad.net/~widelands-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to