[Freeciv-Dev] (PR#12780) move SINGLE_MOVE and other move data into the r
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12780 >
This patch moves SINGLE_MOVE, MOVE_COST_ROAD, MOVE_COST_RAIL,
MOVE_COST_RIVEr into the ruleset.
I chose to put it into the terrain_control structure for convenience.
However this caused several problems:
1. I moved SINGLE_MOVE and friends into map.h (from unit.h).
2. The terrain_control is #defined in map.h, but it's declared in
packets.h (actually packets_gen). map.h doesn't include packets.h, and
adding an #include breaks because packets.h *does* include map.h. I
solved this by moving the #includes in map.h outside of the #ifndef
FC__MAP_H check - so if you #include map.h you get packets.h first, as
needed. This isn't a very good solution however. How should it be fixed?
3. The terrain_control isn't loaded until after unittypes are loaded,
which causes all units to have a move_rate of 0. I solved this by
simply moving it up a line.
The second attached patch is the interesting one. The first patch is
just one I used for testing first. Multiplying all move costs by 3 and
setting the rail cost to 1 means rails don't give infinite moves, which
could be good for the default ruleset (at least it should make the AI
faster). In the second patch you can just change the terrain.ruleset to
have this work.
Note that changing SINGLE_MOVE can confuse savegames greatly, since the
move rates stored in the savegame are already multiplied by SINGLE_MOVE.
I think we should make MOVE_COST_IGTER another value. In the default
ruleset MOVE_COST_IGTER should be SINGLE_MOVE and explorers/alpinetroops
should just have 3 MP.
-jason
Index: common/unit.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.h,v
retrieving revision 1.139
diff -u -r1.139 unit.h
--- common/unit.h 21 Mar 2005 12:28:00 -0000 1.139
+++ common/unit.h 12 Apr 2005 17:14:57 -0000
@@ -185,11 +185,11 @@
#define unit_list_iterate(unitlist, punit) \
TYPED_LIST_ITERATE(struct unit, unitlist, punit)
#define unit_list_iterate_end LIST_ITERATE_END
-#define SINGLE_MOVE 3
-#define MOVE_COST_RIVER 1
-#define MOVE_COST_RAIL 0
-#define MOVE_COST_ROAD 1
-#define MOVE_COST_AIR 1
+#define SINGLE_MOVE 9
+#define MOVE_COST_RIVER 3
+#define MOVE_COST_RAIL 1
+#define MOVE_COST_ROAD 3
+#define MOVE_COST_AIR SINGLE_MOVE
#define unit_list_iterate_safe(unitlist, punit) \
{ \
? vgcore.pid20253
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.235
diff -u -r1.235 map.h
--- common/map.h 13 Mar 2005 17:50:54 -0000 1.235
+++ common/map.h 12 Apr 2005 21:09:35 -0000
@@ -10,8 +10,6 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
-#ifndef FC__MAP_H
-#define FC__MAP_H
#include <assert.h>
#include <math.h>
@@ -19,10 +17,14 @@
#include "fc_types.h"
#include "game.h"
+#include "packets.h"
#include "player.h"
#include "terrain.h"
#include "unit.h"
+#ifndef FC__MAP_H
+#define FC__MAP_H
+
/*
* The value of MOVE_COST_FOR_VALID_SEA_STEP has no particular
* meaning. The value is only used for comparison. The value must be
@@ -69,6 +71,12 @@
*****************************************************************/
#define terrain_misc packet_ruleset_terrain_control
+#define SINGLE_MOVE (terrain_control.single_move)
+#define MOVE_COST_RIVER (terrain_control.move_cost_river)
+#define MOVE_COST_RAIL (terrain_control.move_cost_rail)
+#define MOVE_COST_ROAD (terrain_control.move_cost_road)
+#define MOVE_COST_AIR 1
+
/* The direction8 gives the 8 possible directions. These may be used in
* a number of ways, for instance as an index into the DIR_DX/DIR_DY
* arrays. Not all directions may be valid; see is_valid_dir and
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.104
diff -u -r1.104 packets.def
--- common/packets.def 10 Apr 2005 23:55:25 -0000 1.104
+++ common/packets.def 12 Apr 2005 21:09:36 -0000
@@ -1091,6 +1091,11 @@
BOOL may_mine; /* may build mines */
BOOL may_transform; /* may transform terrain */
+ UINT8 single_move;
+ UINT8 move_cost_river;
+ UINT8 move_cost_rail;
+ UINT8 move_cost_road;
+
/* parameters */
UINT8 ocean_reclaim_requirement_pct; /* # adjacent land tiles for reclaim */
UINT8 land_channel_requirement_pct; /* # adjacent ocean tiles for channel */
Index: common/unit.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.h,v
retrieving revision 1.139
diff -u -r1.139 unit.h
--- common/unit.h 21 Mar 2005 12:28:00 -0000 1.139
+++ common/unit.h 12 Apr 2005 21:09:36 -0000
@@ -185,11 +185,6 @@
#define unit_list_iterate(unitlist, punit) \
TYPED_LIST_ITERATE(struct unit, unitlist, punit)
#define unit_list_iterate_end LIST_ITERATE_END
-#define SINGLE_MOVE 3
-#define MOVE_COST_RIVER 1
-#define MOVE_COST_RAIL 0
-#define MOVE_COST_ROAD 1
-#define MOVE_COST_AIR 1
#define unit_list_iterate_safe(unitlist, punit) \
{ \
Index: common/aicore/pf_tools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/pf_tools.c,v
retrieving revision 1.29
diff -u -r1.29 pf_tools.c
--- common/aicore/pf_tools.c 31 Mar 2005 18:32:10 -0000 1.29
+++ common/aicore/pf_tools.c 12 Apr 2005 21:09:36 -0000
@@ -20,6 +20,7 @@
#include "mem.h"
+#include "map.h"
#include "movement.h"
#include "pf_tools.h"
Index: data/civ1/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/terrain.ruleset,v
retrieving revision 1.31
diff -u -r1.31 terrain.ruleset
--- data/civ1/terrain.ruleset 8 Nov 2004 15:15:53 -0000 1.31
+++ data/civ1/terrain.ruleset 12 Apr 2005 21:09:36 -0000
@@ -20,6 +20,12 @@
may_mine=1 ; 0 means no, 1 means yes
may_transform=0 ; 0 means no, 1 means yes
+[movement]
+single_move = 3
+move_cost_river = 1
+move_cost_rail = 0
+move_cost_road = 1
+
[parameters]
; Percentage of "land" tiles required to be adjacent to an ocean tile before
Index: data/civ2/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/terrain.ruleset,v
retrieving revision 1.33
diff -u -r1.33 terrain.ruleset
--- data/civ2/terrain.ruleset 8 Nov 2004 15:15:53 -0000 1.33
+++ data/civ2/terrain.ruleset 12 Apr 2005 21:09:36 -0000
@@ -20,6 +20,12 @@
may_mine=1 ; 0 means no, 1 means yes
may_transform=1 ; 0 means no, 1 means yes
+[movement]
+single_move = 3
+move_cost_river = 1
+move_cost_rail = 0
+move_cost_road = 1
+
[parameters]
; Percentage of "land" tiles required to be adjacent to an ocean tile before
Index: data/default/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/terrain.ruleset,v
retrieving revision 1.37
diff -u -r1.37 terrain.ruleset
--- data/default/terrain.ruleset 21 Mar 2005 13:05:21 -0000 1.37
+++ data/default/terrain.ruleset 12 Apr 2005 21:09:36 -0000
@@ -20,6 +20,12 @@
may_mine=1 ; 0 means no, 1 means yes
may_transform=1 ; 0 means no, 1 means yes
+[movement]
+single_move = 3
+move_cost_river = 1
+move_cost_rail = 0
+move_cost_road = 1
+
[parameters]
; Percentage of "land" tiles required to be adjacent to an ocean tile before
Index: data/history/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/terrain.ruleset,v
retrieving revision 1.15
diff -u -r1.15 terrain.ruleset
--- data/history/terrain.ruleset 14 Sep 2004 00:01:35 -0000 1.15
+++ data/history/terrain.ruleset 12 Apr 2005 21:09:36 -0000
@@ -20,6 +20,12 @@
may_mine=1 ; 0 means no, 1 means yes
may_transform=1 ; 0 means no, 1 means yes
+[movement]
+single_move = 3
+move_cost_river = 1
+move_cost_rail = 0
+move_cost_road = 1
+
[parameters]
; Percentage of "land" tiles required to be adjacent to an ocean tile before
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.242
diff -u -r1.242 ruleset.c
--- server/ruleset.c 10 Apr 2005 23:55:25 -0000 1.242
+++ server/ruleset.c 12 Apr 2005 21:09:37 -0000
@@ -1422,6 +1422,16 @@
terrain_control.may_transform =
secfile_lookup_bool_default(file, TRUE, "options.may_transform");
+ /* movement */
+ terrain_control.single_move
+ = secfile_lookup_int_default(file, 3, "movement.single_move");
+ terrain_control.move_cost_river
+ = secfile_lookup_int_default(file, 1, "movement.move_cost_river");
+ terrain_control.move_cost_rail
+ = secfile_lookup_int_default(file, 0, "movement.move_cost_rail");
+ terrain_control.move_cost_road
+ = secfile_lookup_int_default(file, 1, "movement.move_cost_road");
+
/* parameters */
terrain_control.ocean_reclaim_requirement_pct
@@ -3141,8 +3151,8 @@
load_ruleset_techs(&techfile);
load_ruleset_cities(&cityfile);
load_ruleset_governments(&govfile);
+ load_ruleset_terrain(&terrfile); /* terrain must precede nations + units */
load_ruleset_units(&unitfile);
- load_ruleset_terrain(&terrfile); /* terrain must precede nations */
load_ruleset_buildings(&buildfile);
load_ruleset_nations(&nationfile);
load_ruleset_effects(&effectfile);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12780) move SINGLE_MOVE and other move data into the rulest,
Jason Short <=
|
|