[Freeciv-Dev] (PR#7068) is_starter_close should be in server code
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#7068) is_starter_close should be in server code |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Mon, 8 Dec 2003 11:33:10 -0800 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=7068 >
The function is_starter_close in map.c is only used in mapgen.c. It
should be moved there. It is entirely mapgen-centric.
This patch does the move and renames it as is_illegal_start_pos.
jason
? rc
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.153
diff -u -r1.153 map.c
--- common/map.c 2003/12/08 19:19:56 1.153
+++ common/map.c 2003/12/08 19:31:26
@@ -508,44 +508,6 @@
}
/***************************************************************
- Returns 1 if (x,y) is _not_ a good position to start from;
- Bad places:
- - Non-suitable terrain;
- - On a hut;
- - On North/South pole continents
- - Too close to another starter on the same continent:
- 'dist' is too close (real_map_distance)
- 'nr' is the number of other start positions in
- map.start_positions to check for too closeness.
-***************************************************************/
-bool is_starter_close(int x, int y, int nr, int dist)
-{
- int i;
- enum tile_terrain_type t = map_get_terrain(x, y);
-
- /* only start on clear terrain: */
- if (t!=T_PLAINS && t!=T_GRASSLAND && t!=T_RIVER)
- return TRUE;
-
- /* don't start on a hut: */
- if (map_has_special(x, y, S_HUT))
- return TRUE;
-
- /* Nobody will start on the poles since they aren't valid terrain. */
-
- /* don't start too close to someone else: */
- for (i=0;i<nr;i++) {
- int x1 = map.start_positions[i].x;
- int y1 = map.start_positions[i].y;
- if (map_get_continent(x, y) == map_get_continent(x1, y1)
- && real_map_distance(x, y, x1, y1) < dist) {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/***************************************************************
...
***************************************************************/
int is_good_tile(int x, int y)
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.165
diff -u -r1.165 map.h
--- common/map.h 2003/11/28 17:37:21 1.165
+++ common/map.h 2003/12/08 19:31:26
@@ -325,7 +325,6 @@
bool terrain_is_clean(int x, int y);
bool is_at_coast(int x, int y);
bool is_hut_close(int x, int y);
-bool is_starter_close(int x, int y, int nr, int dist);
int is_good_tile(int x, int y);
bool is_special_close(int x, int y);
bool is_sea_usable(int x, int y);
Index: server/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v
retrieving revision 1.122
diff -u -r1.122 mapgen.c
--- server/mapgen.c 2003/11/18 23:11:14 1.122
+++ server/mapgen.c 2003/12/08 19:31:27
@@ -1070,6 +1070,47 @@
}
}
+/***************************************************************
+ Returns TRUE if (x,y) is _not_ a good position to start from;
+ Bad places:
+ - Non-suitable terrain;
+ - On a hut;
+ - Too close to another starter on the same continent:
+ 'dist' is the too-close distance (real_map_distance)
+ 'nr' is the number of other start positions in
+ map.start_positions to check for too closeness.
+***************************************************************/
+static bool is_illegal_start_pos(int x, int y, int nr, int dist)
+{
+ int i;
+ enum tile_terrain_type t = map_get_terrain(x, y);
+
+ /* only start on clear terrain: */
+ if (t != T_PLAINS && t != T_GRASSLAND && t != T_RIVER) {
+ return TRUE;
+ }
+
+ /* don't start on a hut: */
+ if (map_has_special(x, y, S_HUT)) {
+ return TRUE;
+ }
+
+ /* Nobody will start on the poles since they aren't valid terrain. */
+
+ /* don't start too close to someone else: */
+ for (i = 0; i < nr; i++) {
+ int x1 = map.start_positions[i].x;
+ int y1 = map.start_positions[i].y;
+
+ if (map_get_continent(x, y) == map_get_continent(x1, y1)
+ && real_map_distance(x, y, x1, y1) < dist) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
/**************************************************************************
where do the different races start on the map? well this function tries
to spread them out on the different islands.
@@ -1110,7 +1151,7 @@
rand_map_pos(&x, &y);
if (islands[(int)map_get_continent(x, y)].starters != 0) {
j++;
- if (!is_starter_close(x, y, nr, dist)) {
+ if (!is_illegal_start_pos(x, y, nr, dist)) {
islands[(int)map_get_continent(x, y)].starters--;
map.start_positions[nr].x=x;
map.start_positions[nr].y=y;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#7068) is_starter_close should be in server code,
Jason Short <=
|
|