[Freeciv-Dev] (PR#13719) change plrtile->owner to a pointer
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13719 >
This patch changes plrtile->owner from an index to a pointer value.
-jason
Index: server/maphand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/maphand.c,v
retrieving revision 1.172
diff -p -u -r1.172 maphand.c
--- server/maphand.c 13 Aug 2005 05:27:24 -0000 1.172
+++ server/maphand.c 20 Aug 2005 20:16:15 -0000
@@ -491,7 +491,8 @@ void send_tile_info(struct conn_list *de
info.special[spe] = BV_ISSET(ptile->special, spe);
}
info.continent = ptile->continent;
- info.owner = ptile->owner ? ptile->owner->player_no :
MAP_TILE_OWNER_NULL;
+ info.owner = (ptile->owner
+ ? ptile->owner->player_no : MAP_TILE_OWNER_NULL);
send_packet_tile_info(pconn, &info);
} else if (pplayer && map_is_known(ptile, pplayer)
&& map_get_seen(ptile, pplayer) == 0) {
@@ -499,7 +500,8 @@ void send_tile_info(struct conn_list *de
info.known = TILE_KNOWN_FOGGED;
info.type = plrtile->terrain->index;
- info.owner = plrtile->owner >= 0 ? plrtile->owner : MAP_TILE_OWNER_NULL;
+ info.owner = (plrtile->owner
+ ? plrtile->owner->player_no : MAP_TILE_OWNER_NULL);
for (spe = 0; spe < S_LAST; spe++) {
info.special[spe] = BV_ISSET(plrtile->special, spe);
}
@@ -1147,7 +1149,7 @@ static void player_tile_init(struct tile
plrtile->last_updated = GAME_START_YEAR;
plrtile->own_seen = plrtile->seen_count;
- plrtile->owner = -1;
+ plrtile->owner = NULL;
}
/****************************************************************************
@@ -1176,15 +1178,10 @@ bool update_player_tile_knowledge(struct
if (plrtile->terrain != ptile->terrain
|| memcmp(&plrtile->special, &ptile->special,
sizeof(plrtile->special)) != 0
- || (ptile->owner && plrtile->owner != ptile->owner->player_no)
- || (!ptile->owner && plrtile->owner >= 0)) {
+ || ptile->owner != plrtile->owner) {
plrtile->terrain = ptile->terrain;
plrtile->special = ptile->special;
- if (ptile->owner) {
- plrtile->owner = ptile->owner->player_no;
- } else {
- plrtile->owner = -1;
- }
+ plrtile->owner = ptile->owner;
return TRUE;
}
return FALSE;
Index: server/maphand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/maphand.h,v
retrieving revision 1.61
diff -p -u -r1.61 maphand.h
--- server/maphand.h 13 Aug 2005 05:27:24 -0000 1.61
+++ server/maphand.h 20 Aug 2005 20:16:15 -0000
@@ -39,7 +39,7 @@ struct dumb_city{
struct player_tile {
struct terrain *terrain; /* May be NULL for unknown tiles. */
bv_special special;
- signed char owner;
+ struct player *owner;
unsigned short seen_count;
unsigned short own_seen;
/* If you build a city with an unknown square within city radius
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.275
diff -p -u -r1.275 savegame.c
--- server/savegame.c 18 Aug 2005 06:44:29 -0000 1.275
+++ server/savegame.c 20 Aug 2005 20:16:16 -0000
@@ -2359,21 +2359,16 @@ static void player_map_load(struct playe
secfile_lookup_str
(file, "player%d.map_oa%03d", plrno, nat_y),
map_get_player_tile(ptile, plr)->owner =
- ascii_hex2bin(ch, 0));
+ get_player(ascii_hex2bin(ch, 0)));
LOAD_MAP_DATA(ch, nat_y, ptile,
secfile_lookup_str
(file, "player%d.map_ob%03d", plrno, nat_y),
map_get_player_tile(ptile, plr)->owner =
- ascii_hex2bin(ch, 1));
+ get_player(ascii_hex2bin(ch, 1)));
} else {
- int nat_x, nat_y;
- for (nat_y = 0; nat_y < map.ysize; nat_y++) {
- for (nat_x = 0; nat_x < map.xsize; nat_x++) {
- struct tile *ptile = native_pos_to_tile(nat_x, nat_y);
- map_get_player_tile(ptile, plr)->owner =
- ptile->owner ? ptile->owner->player_no : -1;
- }
- }
+ whole_map_iterate(ptile) {
+ map_get_player_tile(ptile, plr)->owner = ptile->owner;
+ } whole_map_iterate_end;
}
{
@@ -2954,11 +2949,9 @@ static void player_save(struct player *p
/* put 4-bit segments of 8-bit "owner" field */
SAVE_PLAYER_MAP_DATA(ptile, file, "player%d.map_oa%03d", plrno,
- bin2ascii_hex(map_get_player_tile
- (ptile, plr)->owner, 0));
+ bin2ascii_hex(map_get_player_tile(ptile, plr)->owner
? map_get_player_tile(ptile, plr)->owner->player_no : 255, 0));
SAVE_PLAYER_MAP_DATA(ptile, file, "player%d.map_ob%03d", plrno,
- bin2ascii_hex(map_get_player_tile
- (ptile, plr)->owner, 1));
+ bin2ascii_hex(map_get_player_tile(ptile, plr)->owner
? map_get_player_tile(ptile, plr)->owner->player_no : 255, 1));
if (TRUE) {
struct dumb_city *pdcity;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#13719) change plrtile->owner to a pointer,
Jason Short <=
|
|