|
Atrinik Server 2.5
|
Go to the source code of this file.
Data Structures | |
| struct | blstr |
Defines | |
| #define | SPACE_BLOCK 0.5 |
| #define | MAX_MASK_SIZE 81 |
| #define | NR_LIGHT_MASK 10 |
| #define | MAX_LIGHT_SOURCE 13 |
| #define | BLOCKED_LOS_EXPAND 0x20 |
Typedefs | |
| typedef struct blstr | blocks |
Functions | |
| static void | expand_sight (object *op) |
| void | init_block () |
| void | set_block (int x, int y, int bx, int by) |
| static void | set_wall (object *op, int x, int y) |
| static void | check_wall (object *op, int x, int y) |
| static void | blinded_sight (object *op) |
| void | update_los (object *op) |
| void | clear_los (object *op) |
| static int | get_real_light_source_value (int l) |
| static void | remove_light_mask (mapstruct *map, int x, int y, int mid) |
| static int | add_light_mask (mapstruct *map, int x, int y, int mid) |
| void | adjust_light_source (mapstruct *map, int x, int y, int light) |
| static void | restore_light_mask (mapstruct *restore_map, mapstruct *map, int x, int y, int mid) |
| void | check_light_source_list (mapstruct *map) |
| static void | remove_light_mask_other (mapstruct *map, int x, int y, int mid) |
| void | remove_light_source_list (mapstruct *map) |
| int | obj_in_line_of_sight (object *obj, rv_vector *rv) |
Variables | |
| static blocks | block [MAP_CLIENT_X][MAP_CLIENT_Y] |
| static int | lmask_x [MAX_MASK_SIZE] |
| static int | lmask_y [MAX_MASK_SIZE] |
| static int | light_mask [MAX_LIGHT_SOURCE+1] |
| static int | light_mask_width [NR_LIGHT_MASK] |
| static int | light_mask_size [NR_LIGHT_MASK] |
| static int | light_masks [NR_LIGHT_MASK][MAX_MASK_SIZE] |
Line of sight related functions.
Definition in file los.c.
| #define SPACE_BLOCK 0.5 |
| void adjust_light_source | ( | mapstruct * | map, |
| int | x, | ||
| int | y, | ||
| int | light | ||
| ) |
| static void blinded_sight | ( | object * | op | ) | [static] |
| void check_light_source_list | ( | mapstruct * | map | ) |
| static void check_wall | ( | object * | op, |
| int | x, | ||
| int | y | ||
| ) | [static] |
Used to initialize the array used by the LOS routines. Instead of light values, blocked_los[][] now tells the client update function what kind of tile we have: visible, sight blocked, blocksview trigger or out of map.
| op | The player object |
| x | X position based on MAP_CLIENT_X |
| y | Y position based on MAP_CLIENT_Y |
| void clear_los | ( | object * | op | ) |
| static void expand_sight | ( | object * | op | ) | [static] |
This 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 | The player object. |
| void init_block | ( | ) |
Initializes the array used by the LOS routines. This is NOT called for every LOS - only at server start to init the base block structure.
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.
Check if object is in line of sight, based on rv_vector. This will check also check for blocksview 1 objects.
Uses the Bresenham line algorithm.
| obj | The object to check |
| rv | rv_vector to get distances, map, etc from |
| void remove_light_source_list | ( | mapstruct * | map | ) |
| void set_block | ( | int | x, |
| int | y, | ||
| int | bx, | ||
| int | by | ||
| ) |
Used to initialize the array used by the LOS routines. What this sets if 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 block, we have the data to know that 5, 3 and 5, 2 and 5, 1 should also be blocked.
| x | X position |
| y | Y position |
| bx | Blocked X position |
| by | Blocked Y position |
| static void set_wall | ( | object * | op, |
| int | x, | ||
| int | y | ||
| ) | [static] |
Used to initialize the array used by the LOS routines. x, y are indexes into the blocked[][] array. 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.
| op | Player object |
| x | X position |
| y | Y position |
| void update_los | ( | object * | op | ) |
int light_mask[MAX_LIGHT_SOURCE+1] [static] |
int light_mask_size[NR_LIGHT_MASK] [static] |
int light_mask_width[NR_LIGHT_MASK] [static] |
int lmask_x[MAX_MASK_SIZE] [static] |
{
0, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1,
0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -3, -3, -3, -3, -2, -1,
0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 0, -1, -2, -3, -4, -4, -4, -4, -4, -4, -4, -4, -4, -3, -2, -1
}
int lmask_y[MAX_MASK_SIZE] [static] |
{
0, -1, -1, 0, 1, 1, 1, 0, -1, -2, -2, -2, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2,
-3, -3, -3, -3, -2, -1, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3,
4, 4, 4, 4, 4, 3, 2, 1, 0, -1, -2, -3, -4, -4, -4, -4, -4, -4, -4, -4, -4, -3, -2, -1, 0, 1, 2, 3, 4, 4, 4, 4
}
1.7.4