Difference between revisions of "User:Ayin/Extended terrains proposal"
From The Battle for Wesnoth Wiki
(→Code changes) |
|||
Line 16: | Line 16: | ||
==Code changes== | ==Code changes== | ||
− | * Add the support of multiple maps in <tt>map.cpp</tt>. In <tt>terrain.cpp</tt>, there should be 2 classes: <tt>terrain_type</tt> which describes the base terrain types, and <tt> | + | * Add the support of multiple maps in <tt>map.cpp</tt>. In <tt>terrain.cpp</tt>, there should be 2 classes: <tt>terrain_type</tt> which describes the base terrain types, and <tt>terrain_group</tt> which describes a combo of several terrains. <tt>terrain_group</tt> should have the same methods as base terrains, but be '''very lightweight''' as those will need to be created on-the-fly. It may, for example, have char[2] as a data payload. <tt>get_terrain_info</tt> should return a <tt>terrain_group</tt>. |
− | * Fix <tt>unit_types.cpp</tt> so the defense_modifiers and attack_modifiers work with the new multiple maps. | + | * Fix <tt>unit_types.cpp</tt> so the defense_modifiers and attack_modifiers work with the new multiple maps. Those methods should not use gamemap:TERRAIN anymore to identify terrain types, but should rather use <tt>terrain_group</tt>. |
+ | * Most places where gamemap::TERRAIN is used should use <tt>terrain_group</tt> instead (<tt>actions.cpp</tt>, <tt>unit_display.cpp</tt>, <tt>reports.cpp</tt>, etc.) | ||
* Modify <tt>builder.cpp</tt> so it works with the new-style maps (changes to <tt>display.cpp</tt> may not be necessary if it is done properly). | * Modify <tt>builder.cpp</tt> so it works with the new-style maps (changes to <tt>display.cpp</tt> may not be necessary if it is done properly). | ||
+ | * The map generator will need to take those changes into account. | ||
+ | * The editor is certainly the part which will need the most work, as UI changes will be necessary. |
Revision as of 13:14, 9 October 2005
This is a proposal to implement extended terrain types. The base ideas for this proposals were submitted by Ivanovic and freim.
Description
The idea is that scenarios are now to have 2 (or more?) maps. The “base terrain” map, and the “terrain overlay” map. Then, the terrains defined in [terrain] WML will have another attribute, named, for example, layer, defining the map this terrain applies to. Same for [terrain_graphics] rules: a rule may be defined for a layer, or for another.
This will have the following consequences :
- One letter may be available, with different meanings, for both maps (not sure this is a good thing, though).
- Terrains will be a combo of several base terrains. For example, swamp + bridge, forest + village.
Backwards compatibility
To be determined.
Code changes
- Add the support of multiple maps in map.cpp. In terrain.cpp, there should be 2 classes: terrain_type which describes the base terrain types, and terrain_group which describes a combo of several terrains. terrain_group should have the same methods as base terrains, but be very lightweight as those will need to be created on-the-fly. It may, for example, have char[2] as a data payload. get_terrain_info should return a terrain_group.
- Fix unit_types.cpp so the defense_modifiers and attack_modifiers work with the new multiple maps. Those methods should not use gamemap:TERRAIN anymore to identify terrain types, but should rather use terrain_group.
- Most places where gamemap::TERRAIN is used should use terrain_group instead (actions.cpp, unit_display.cpp, reports.cpp, etc.)
- Modify builder.cpp so it works with the new-style maps (changes to display.cpp may not be necessary if it is done properly).
- The map generator will need to take those changes into account.
- The editor is certainly the part which will need the most work, as UI changes will be necessary.