![]() |
Crossfire Server, Trunk
1.75.0
|
Go to the source code of this file.
Data Structures | |
struct | blocks |
Macros | |
#define | LOS_BLOCKED 100 |
Special values for the blocked_los array. More... | |
#define | LOS_MARKED -1 |
#define | LOS_NO_DARKNESS 0 |
#define | SEE_IN_DARK_LEVELS 2 |
Number of darkness levels to reduce for FLAG_SEE_IN_DARK (Infravision) More... | |
#define | SPACE_BLOCK 0.5 |
Distance must be less than this for the object to be blocked. More... | |
#define | XRAY_RADIUS 2 |
Number of spaces that FLAG_XRAYS (X-Ray) can see through. More... | |
Functions | |
static void | blinded_sight (player *pl) |
Sets all veiwable squares to blocked except for the one the central one that the player occupies. More... | |
static void | check_wall (object *op, int x, int y) |
Used to initialise the array used by the LOS routines. More... | |
void | clear_los (player *pl) |
Clears/initialises the los-array associated to the player controlling the object. More... | |
static void | expand_lighted_sight (object *op) |
Propagate the light information. More... | |
static void | expand_sight (object *op) |
Goes through the array of what the given player is able to see, and expands the visible area a bit, so the player will, to a certain degree, be able to see into corners. More... | |
int | has_carried_lights (const object *op) |
Checks if op has a light source. More... | |
void | init_block (void) |
initialises the array used by the LOS routines. More... | |
void | make_sure_not_seen (const object *op) |
The object which is supposed to be visible through walls has just been removed from the map, so update the los of any players within its range. More... | |
void | make_sure_seen (const object *op) |
The object is supposed to be visible through walls, thus check if any players are nearby, and edit their LOS array. More... | |
void | print_los (object *op) |
Debug-routine which dumps the array which specifies the visible area of a player. More... | |
static void | set_block (int x, int y, int bx, int by) |
What this sets is that x,y blocks the view of bx,by This then sets up a relation - for example, something at 5,4 blocks view at 5,3 which blocks view at 5,2 etc. More... | |
static void | set_wall (player *pl, int x, int y) |
This recursively sets the blocked line of sight view. More... | |
void | update_all_los (const mapstruct *map, int x, int y) |
This function makes sure that update_los() will be called for all players on the given map within the next frame. More... | |
void | update_all_map_los (mapstruct *map) |
update all_map_los is like update_all_los() below, but updates everyone on the map, no matter where they are. More... | |
void | update_los (object *op) |
Recalculates the array which specifies what is visible for the given player-object. More... | |
Variables | |
static blocks | block [MAP_CLIENT_X][MAP_CLIENT_Y] |
This handles the "line of sight" for players and monsters.
Definition in file los.cpp.
#define LOS_BLOCKED 100 |
#define SEE_IN_DARK_LEVELS 2 |
#define SPACE_BLOCK 0.5 |
Distance must be less than this for the object to be blocked.
An object is 1.0 wide, so if set to 0.5, it means the object that blocks half the view (0.0 is complete block) will block view in our tables. .4 or less lets you see through walls. .5 is about right.
#define XRAY_RADIUS 2 |
|
static |
Sets all veiwable squares to blocked except for the one the central one that the player occupies.
A little odd that you can see yourself (and what your standing on), but really need for any reasonable game play.
pl | player for which to reset los. |
Definition at line 492 of file los.cpp.
References player::blocked_los, LOS_BLOCKED, LOS_NO_DARKNESS, socket_struct::mapx, socket_struct::mapy, and player::socket.
Referenced by update_los().
|
static |
Used to initialise the array used by the LOS routines.
op | player's object |
x | |
y | Values based on MAP_CLIENT_X and Y that index the blocked[][] arrays. |
Definition at line 235 of file los.cpp.
References block, player::blocked_los, object::contr, get_map_flags(), LOS_BLOCKED, object::map, MAP_CLIENT_X, MAP_CLIENT_Y, socket_struct::mapx, socket_struct::mapy, P_BLOCKSVIEW, P_OUT_OF_MAP, set_wall(), player::socket, object::x, and object::y.
Referenced by update_los().
void clear_los | ( | player * | pl | ) |
Clears/initialises the los-array associated to the player controlling the object.
pl | player to clear. |
Definition at line 270 of file los.cpp.
References player::blocked_los, LOS_NO_DARKNESS, MAP_CLIENT_X, and MAP_CLIENT_Y.
Referenced by do_wizard_dm(), get_player(), and update_los().
|
static |
Propagate the light information.
op | player's object for which to compute the light values. |
Definition at line 360 of file los.cpp.
References player::blocked_los, object::contr, FLAG_SEE_IN_DARK, get_map_flags(), GET_MAP_LIGHT, ihypot(), llevError, LOG(), LOS_BLOCKED, m, object::map, MAP_DARKNESS, socket_struct::mapx, socket_struct::mapy, MAX, MAX_DARKNESS, MAX_LIGHT_RADII, MIN, object::name, mapstruct::outdoor, P_OUT_OF_MAP, mapstruct::path, QUERY_FLAG, SEE_IN_DARK_LEVELS, player::socket, object::x, and object::y.
Referenced by expand_sight().
|
static |
Goes through the array of what the given player is able to see, and expands the visible area a bit, so the player will, to a certain degree, be able to see into corners.
This is somewhat suboptimal, would be better to improve the formula.
op | player's object to process. |
Definition at line 291 of file los.cpp.
References player::blocked_los, object::contr, expand_lighted_sight(), freearr_x, freearr_y, get_map_flags(), LOS_MARKED, LOS_NO_DARKNESS, object::map, MAP_DARKNESS, socket_struct::mapx, socket_struct::mapy, P_BLOCKSVIEW, P_OUT_OF_MAP, player::socket, object::x, and object::y.
Referenced by update_los().
int has_carried_lights | ( | const object * | op | ) |
Checks if op has a light source.
op | object being checked. |
Definition at line 346 of file los.cpp.
References object::glow_radius.
Referenced by hideability(), and monster_can_see_enemy().
void init_block | ( | void | ) |
initialises the array used by the LOS routines.
Since we are only doing the upper left quadrant, only these spaces could possibly get blocked, since these are the only ones further out that are still possibly in the sightline.
Definition at line 106 of file los.cpp.
References block, FABS, blocks::index, MAP_CLIENT_X, MAP_CLIENT_Y, set_block(), and SPACE_BLOCK.
Referenced by init_library().
void make_sure_not_seen | ( | const object * | op | ) |
The object which is supposed to be visible through walls has just been removed from the map, so update the los of any players within its range.
op | object that disappears. |
Definition at line 718 of file los.cpp.
References player::do_los, first_player, object::map, socket_struct::mapx, socket_struct::mapy, player::next, player::ob, player::socket, object::x, and object::y.
Referenced by process_object().
void make_sure_seen | ( | const object * | op | ) |
The object is supposed to be visible through walls, thus check if any players are nearby, and edit their LOS array.
op | object that should be visible. |
Definition at line 695 of file los.cpp.
References player::blocked_los, first_player, LOS_NO_DARKNESS, object::map, socket_struct::mapx, socket_struct::mapy, player::next, player::ob, player::socket, object::x, and object::y.
Referenced by process_object().
void print_los | ( | object * | op | ) |
Debug-routine which dumps the array which specifies the visible area of a player.
Triggered by the DM command printlos.
op | DM asking for information. |
Definition at line 665 of file los.cpp.
References player::blocked_los, buf, object::contr, draw_ext_info, LOS_BLOCKED, MAP_CLIENT_X, socket_struct::mapx, socket_struct::mapy, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DEBUG, NDI_UNIQUE, and player::socket.
Referenced by command_printlos().
|
static |
What this sets is that x,y blocks the view of bx,by This then sets up a relation - for example, something at 5,4 blocks view at 5,3 which blocks view at 5,2 etc.
So when we check 5,4 and find it blocks, we have the data to know that 5,3 and 5,2 and 5,1 should also be blocked. Used to initialise the array used by the LOS routines.
x | |
y | coordinates that block. |
bx | |
by | coordinates that get blocked. |
Definition at line 79 of file los.cpp.
References block, blocks::index, llevDebug, LOG(), blocks::x, and blocks::y.
Referenced by init_block().
|
static |
This recursively sets the blocked line of sight view.
From the blocked[][] array, we know for example that if some particular space is blocked, it blocks the view of the spaces 'behind' it, and those blocked spaces behind it may block other spaces, etc. In this way, the chain of visibility is set. Used to initialise the array used by the LOS routines.
pl | player for which we're computing. |
x | |
y | indexes into the blocked[][] array. |
Definition at line 188 of file los.cpp.
References block, player::blocked_los, blocks::index, LOS_BLOCKED, MAP_CLIENT_X, MAP_CLIENT_Y, socket_struct::mapx, socket_struct::mapy, player::socket, blocks::x, and blocks::y.
Referenced by check_wall().
void update_all_los | ( | const mapstruct * | map, |
int | x, | ||
int | y | ||
) |
This function makes sure that update_los() will be called for all players on the given map within the next frame.
It is triggered by removal or inserting of objects which blocks the sight in the map. Modified by MSW 2001-07-12 to take a coordinate of the changed position, and to also take map tiling into account. This change means that just being on the same map is not sufficient - the space that changes must be withing your viewable area.
map | map that changed. |
x | |
y | coordinates of the change. |
Definition at line 595 of file los.cpp.
References player::do_los, first_player, object::map, MAP_HEIGHT, MAP_WIDTH, socket_struct::mapx, socket_struct::mapy, player::next, player::ob, player::socket, mapstruct::tile_map, object::x, and object::y.
Referenced by cfapi_object_set_property(), do_turn(), gate_type_process(), kill_object(), magic_wall(), object_insert_in_map(), object_insert_in_ob(), object_remove(), and tear_down_wall().
void update_all_map_los | ( | mapstruct * | map | ) |
update all_map_los is like update_all_los() below, but updates everyone on the map, no matter where they are.
This generally should not be used, as a per specific map change doesn't make much sense when tiling is considered (lowering darkness would certainly be a strange effect if done on a tile map, as it makes the distinction between maps much more obvious to the players, which is should not be. Currently, this function is called from the change_map_light function
map | map on which affected players are. |
Definition at line 567 of file los.cpp.
References player::do_los, first_player, object::map, player::next, and player::ob.
Referenced by change_map_light().
void update_los | ( | object * | op | ) |
Recalculates the array which specifies what is visible for the given player-object.
op | player's object for which to compute. |
Definition at line 509 of file los.cpp.
References blinded_sight(), player::blocked_los, check_wall(), clear_los(), object::contr, expand_sight(), FLAG_BLIND, FLAG_REMOVED, FLAG_WIZ, FLAG_XRAYS, LOS_NO_DARKNESS, MAP_CLIENT_X, MAP_CLIENT_Y, socket_struct::mapx, socket_struct::mapy, QUERY_FLAG, player::socket, and XRAY_RADIUS.
Referenced by command_nowiz(), draw_client_map(), and set_up_cmd().
|
static |
Definition at line 57 of file los.cpp.
Referenced by check_wall(), init_block(), set_block(), and set_wall().