Feature #2331 ยป 0086-Refactor-scout-vision-handling.patch
| server/unithand.c | ||
|---|---|---|
|
static bool do_scout(struct unit *punit, struct tile *ptile,
|
||
|
const struct action *paction)
|
||
|
{
|
||
|
struct player *owner = unit_owner(punit);
|
||
|
if (punit->server.scout_vision != nullptr
|
||
|
&& punit->server.scout_vision->tile != ptile) {
|
||
|
vision_free(punit->server.scout_vision);
|
||
|
punit->server.scout_vision = nullptr;
|
||
|
unit_scout_vision_clear(punit);
|
||
|
}
|
||
|
if (punit->server.scout_vision == nullptr) {
|
||
|
const v_radius_t radius_sq = V_RADIUS(5, 0, 0);
|
||
|
punit->server.scout_vision = vision_new(owner, ptile);
|
||
|
vision_reveal_tiles(punit->server.scout_vision, TRUE);
|
||
|
vision_change_sight(punit->server.scout_vision, radius_sq);
|
||
|
unit_scout_vision_gain(punit, ptile);
|
||
|
}
|
||
|
return TRUE;
|
||
| server/unittools.c | ||
|---|---|---|
|
punit->changed_from_target = punit->activity_target;
|
||
|
punit->changed_from_count = punit->activity_count;
|
||
|
if (punit->server.scout_vision != nullptr) {
|
||
|
vision_clear_sight(punit->server.scout_vision);
|
||
|
vision_free(punit->server.scout_vision);
|
||
|
punit->server.scout_vision = nullptr;
|
||
|
}
|
||
|
unit_scout_vision_clear(punit);
|
||
|
send_unit_info(nullptr, punit);
|
||
|
} unit_list_iterate_end;
|
||
| ... | ... | |
|
vision_free(punit->server.vision);
|
||
|
punit->server.vision = nullptr;
|
||
|
}
|
||
|
if (punit->server.scout_vision != nullptr) {
|
||
|
vision_clear_sight(punit->server.scout_vision);
|
||
|
vision_free(punit->server.scout_vision);
|
||
|
punit->server.scout_vision = nullptr;
|
||
|
}
|
||
|
unit_scout_vision_clear(punit);
|
||
|
packet.unit_id = punit->id;
|
||
|
/* Send to onlookers. */
|
||
| ... | ... | |
|
maybe_make_contact(ptile != nullptr ? ptile : unit_tile(punit),
|
||
|
pplayer != nullptr ? pplayer : unit_owner(punit));
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Add scout vision to the unit.
|
||
|
@param punit Unit to add the scout vision for
|
||
|
@param ptile Central tile of the scouted area
|
||
|
**************************************************************************/
|
||
|
void unit_scout_vision_gain(struct unit *punit, struct tile *ptile)
|
||
|
{
|
||
|
const v_radius_t radius_sq = V_RADIUS(5, 0, 0);
|
||
|
fc_assert(punit->server.scout_vision == nullptr);
|
||
|
punit->server.scout_vision = vision_new(unit_owner(punit), ptile);
|
||
|
vision_reveal_tiles(punit->server.scout_vision, TRUE);
|
||
|
vision_change_sight(punit->server.scout_vision, radius_sq);
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Clear scout vision from the unit.
|
||
|
@param punit Unit to clear the scout vision from
|
||
|
**************************************************************************/
|
||
|
void unit_scout_vision_clear(struct unit *punit)
|
||
|
{
|
||
|
if (punit->server.scout_vision != nullptr) {
|
||
|
vision_clear_sight(punit->server.scout_vision);
|
||
|
vision_free(punit->server.scout_vision);
|
||
|
punit->server.scout_vision = nullptr;
|
||
|
}
|
||
|
}
|
||
| server/unittools.h | ||
|---|---|---|
|
void unit_get_goods(struct unit *punit);
|
||
|
void unit_scout_vision_gain(struct unit *punit, struct tile *ptile);
|
||
|
void unit_scout_vision_clear(struct unit *punit);
|
||
|
#endif /* FC__UNITTOOLS_H */
|
||