Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. *Read more...*

Feature #657363 ยป Subsurface.patch

Marko Lindqvist, 2017-05-03 07:32 PM

View differences:

freeciv/client/gui-gtk-3.0/editprop.c 2017-02-02 09:44:38.459095913 +0200
case V_INVIS:
/* TRANS: Vision layer name. Feel free to leave untranslated. */
return _("Seen (Invis)");
case V_SUBSURFACE:
/* TRANS: Vision layer name. Feel free to leave untranslated. */
return _("Seen (Subsurface)");
case V_COUNT:
break;
}
freeciv/client/gui-gtk-3.22/editprop.c 2017-02-02 09:44:15.554914645 +0200
case V_INVIS:
/* TRANS: Vision layer name. Feel free to leave untranslated. */
return _("Seen (Invis)");
case V_SUBSURFACE:
/* TRANS: Vision layer name. Feel free to leave untranslated. */
return _("Seen (Subsurface)");
case V_COUNT:
break;
}
freeciv/common/player.c 2017-02-02 09:28:53.627487226 +0200
if (!fc_funcs->player_tile_vision_get(ptile, pplayer, V_INVIS)) {
return FALSE;
}
if (!fc_funcs->player_tile_vision_get(ptile, pplayer, V_SUBSURFACE)) {
return FALSE;
}
/* Can't see city units. */
pcity = tile_city(ptile);
......
(e) the unit isn't in a transporter, or we can see the transporter
****************************************************************************/
bool can_player_see_unit_at(const struct player *pplayer,
const struct unit *punit,
const struct unit *punit,
const struct tile *ptile,
bool is_transported)
{
freeciv/common/vision.c 2017-02-02 09:55:52.788160855 +0200
vision->can_reveal_tiles = TRUE;
vision->radius_sq[V_MAIN] = -1;
vision->radius_sq[V_INVIS] = -1;
vision->radius_sq[V_SUBSURFACE] = -1;
return vision;
}
......
{
fc_assert(-1 == vision->radius_sq[V_MAIN]);
fc_assert(-1 == vision->radius_sq[V_INVIS]);
fc_assert(-1 == vision->radius_sq[V_SUBSURFACE]);
free(vision);
}
freeciv/common/vision.h 2017-02-02 09:34:28.098224491 +0200
extern "C" {
#endif /* __cplusplus */
/* common */
#include "fc_types.h"
#include "improvement.h" /* bv_imprs */
#include "improvement.h" /* bv_imprs */
/****************************************************************************
Vision for cities and units:
......
enum vision_layer {
V_MAIN,
V_INVIS,
V_SUBSURFACE,
V_COUNT
};
......
};
/* Initialize a vision radius array. */
#define V_RADIUS(main_sq, invis_sq) { (main_sq), (invis_sq) }
#define V_RADIUS(main_sq, invis_sq, subs_sq) { (main_sq), (invis_sq), (subs_sq) }
#define ASSERT_VISION(v) \
do { \
fc_assert((v)->radius_sq[V_MAIN] >= (v)->radius_sq[V_INVIS]); \
fc_assert((v)->radius_sq[V_MAIN] >= (v)->radius_sq[V_SUBSURFACE]); \
} while (FALSE);
struct vision *vision_new(struct player *pplayer, struct tile *ptile);
freeciv/server/citytools.c 2017-02-02 09:36:09.819044390 +0200
void city_refresh_vision(struct city *pcity)
{
v_radius_t vision_radius_sq =
V_RADIUS(get_city_bonus(pcity, EFT_CITY_VISION_RADIUS_SQ), 2);
V_RADIUS(get_city_bonus(pcity, EFT_CITY_VISION_RADIUS_SQ), 2, 2);
vision_change_sight(pcity->server.vision, vision_radius_sq);
ASSERT_VISION(pcity->server.vision);
freeciv/server/maphand.c 2017-02-02 09:57:40.392866081 +0200
void map_set_border_vision(struct player *pplayer,
const bool is_enabled)
{
const v_radius_t radius_sq = V_RADIUS(is_enabled ? 1 : -1, 0);
const v_radius_t radius_sq = V_RADIUS(is_enabled ? 1 : -1, 0, 0);
if (pplayer->server.border_vision == is_enabled) {
/* No change. Changing the seen count beyond what already exists would
......
****************************************************************************/
void map_know_and_see_all(struct player *pplayer)
{
const v_radius_t radius_sq = V_RADIUS(1, 1);
const v_radius_t radius_sq = V_RADIUS(1, 1, 1);
buffer_shared_vision(pplayer);
whole_map_iterate(&(wld.map), ptile) {
......
plrtile->seen_count[V_MAIN] = !game.server.fogofwar_old;
plrtile->seen_count[V_INVIS] = 0;
plrtile->seen_count[V_SUBSURFACE] = 0;
memcpy(plrtile->own_seen, plrtile->seen_count, sizeof(v_radius_t));
}
......
whole_map_iterate(&(wld.map), ptile) {
const v_radius_t change =
V_RADIUS(map_get_own_seen(pplayer, ptile, V_MAIN),
map_get_own_seen(pplayer, ptile, V_INVIS));
map_get_own_seen(pplayer, ptile, V_INVIS),
map_get_own_seen(pplayer, ptile, V_SUBSURFACE));
if (0 < change[V_MAIN] || 0 < change[V_INVIS]) {
map_change_seen(pplayer2, ptile, change,
......
whole_map_iterate(&(wld.map), ptile) {
const v_radius_t change =
V_RADIUS(-map_get_own_seen(pplayer, ptile, V_MAIN),
-map_get_own_seen(pplayer, ptile, V_INVIS));
-map_get_own_seen(pplayer, ptile, V_INVIS),
-map_get_own_seen(pplayer, ptile, V_SUBSURFACE));
if (0 > change[V_MAIN] || 0 > change[V_INVIS]) {
map_change_seen(pplayer2, ptile, change, FALSE);
......
*************************************************************************/
void enable_fog_of_war_player(struct player *pplayer)
{
const v_radius_t radius_sq = V_RADIUS(-1, 0);
const v_radius_t radius_sq = V_RADIUS(-1, 0, 0);
buffer_shared_vision(pplayer);
whole_map_iterate(&(wld.map), ptile) {
......
*************************************************************************/
void disable_fog_of_war_player(struct player *pplayer)
{
const v_radius_t radius_sq = V_RADIUS(1, 0);
const v_radius_t radius_sq = V_RADIUS(1, 0, 0);
buffer_shared_vision(pplayer);
whole_map_iterate(&(wld.map), ptile) {
......
&& (BORDERS_SEE_INSIDE == game.info.borders
|| BORDERS_EXPAND == game.info.borders
|| ploser->server.border_vision)) {
const v_radius_t radius_sq = V_RADIUS(-1, 0);
const v_radius_t radius_sq = V_RADIUS(-1, 0, 0);
shared_vision_change_seen(ploser, ptile, radius_sq, FALSE);
}
......
&& (BORDERS_SEE_INSIDE == game.info.borders
|| BORDERS_EXPAND == game.info.borders
|| powner->server.border_vision)) {
const v_radius_t radius_sq = V_RADIUS(1, 0);
const v_radius_t radius_sq = V_RADIUS(1, 0, 0);
shared_vision_change_seen(powner, ptile, radius_sq, TRUE);
}
......
/* Transfer base provided vision to new owner */
if (powner != NULL) {
const v_radius_t old_radius_sq = V_RADIUS(-1, -1);
const v_radius_t old_radius_sq = V_RADIUS(-1, -1, -1);
const v_radius_t new_radius_sq = V_RADIUS(pbase->vision_main_sq,
pbase->vision_invis_sq);
pbase->vision_invis_sq,
0);
map_vision_update(powner, ptile, old_radius_sq, new_radius_sq,
game.server.vision_reveal_tiles);
......
if (ploser != NULL) {
const v_radius_t old_radius_sq = V_RADIUS(pbase->vision_main_sq,
pbase->vision_invis_sq);
const v_radius_t new_radius_sq = V_RADIUS(-1, -1);
pbase->vision_invis_sq,
0);
const v_radius_t new_radius_sq = V_RADIUS(-1, -1, -1);
map_vision_update(ploser, ptile, old_radius_sq, new_radius_sq,
game.server.vision_reveal_tiles);
......
****************************************************************************/
void vision_clear_sight(struct vision *vision)
{
const v_radius_t vision_radius_sq = V_RADIUS(-1, -1);
const v_radius_t vision_radius_sq = V_RADIUS(-1, -1, -1);
vision_change_sight(vision, vision_radius_sq);
}
......
/* Base provides vision, but no borders. */
const v_radius_t old_radius_sq =
V_RADIUS(0 <= pbase->vision_main_sq ? pbase->vision_main_sq : -1,
0 <= pbase->vision_invis_sq ? pbase->vision_invis_sq : -1);
const v_radius_t new_radius_sq = V_RADIUS(-1, -1);
0 <= pbase->vision_invis_sq ? pbase->vision_invis_sq : -1,
0);
const v_radius_t new_radius_sq = V_RADIUS(-1, -1, -1);
map_vision_update(owner, ptile, old_radius_sq, new_radius_sq,
game.server.vision_reveal_tiles);
freeciv/server/unittools.c 2017-02-02 09:42:07.433899098 +0200
struct player *powner = unit_owner(punit);
const v_radius_t radius_sq =
V_RADIUS(get_unit_vision_at(punit, pdesttile, V_MAIN),
get_unit_vision_at(punit, pdesttile, V_INVIS));
get_unit_vision_at(punit, pdesttile, V_INVIS),
get_unit_vision_at(punit, pdesttile, V_SUBSURFACE));
struct vision *new_vision;
bool success;
......
Note that vision MUST be independent of transported_by for this to work
properly.
****************************************************************************/
int get_unit_vision_at(struct unit *punit, struct tile *ptile,
enum vision_layer vlayer)
int get_unit_vision_at(struct unit *punit, const struct tile *ptile,
enum vision_layer vlayer)
{
const int base = (unit_type_get(punit)->vision_radius_sq
+ get_unittype_bonus(unit_owner(punit), ptile,
......
case V_MAIN:
return base;
case V_INVIS:
case V_SUBSURFACE:
return MIN(base, 2);
case V_COUNT:
break;
......
void unit_refresh_vision(struct unit *punit)
{
struct vision *uvision = punit->server.vision;
const struct tile *utile = unit_tile(punit);
const v_radius_t radius_sq =
V_RADIUS(get_unit_vision_at(punit, unit_tile(punit), V_MAIN),
get_unit_vision_at(punit, unit_tile(punit), V_INVIS));
V_RADIUS(get_unit_vision_at(punit, utile, V_MAIN),
get_unit_vision_at(punit, utile, V_INVIS),
get_unit_vision_at(punit, utile, V_SUBSURFACE));
vision_change_sight(uvision, radius_sq);
ASSERT_VISION(uvision);
freeciv/server/unittools.h 2017-02-02 09:42:20.538003101 +0200
void remove_allied_visibility(struct player *pplayer, struct player *aplayer,
const struct unit_list *seen_units);
void give_allied_visibility(struct player *pplayer, struct player *aplayer);
int get_unit_vision_at(struct unit *punit, struct tile *ptile,
enum vision_layer vlayer);
int get_unit_vision_at(struct unit *punit, const struct tile *ptile,
enum vision_layer vlayer);
void unit_refresh_vision(struct unit *punit);
void unit_list_refresh_vision(struct unit_list *punitlist);
void bounce_unit(struct unit *punit, bool verbose);
    (1-1/1)