32 #define SPACE_BLOCK 0.5 43 #define SEE_IN_DARK_LEVELS 2 48 #define LOS_BLOCKED 100 49 #define LOS_NO_DARKNESS 0 84 for (i = 0; i <
index; i++) {
85 if (block[x][y].x[i] == bx
86 && block[x][y].y[i] == by)
94 LOG(
llevDebug,
"setblock: added %d %d -> %d %d (%d)\n", x, y, bx, by, block[x][y].index);
108 static const int block_x[3] = {
122 for (x = 1; x <= MAP_CLIENT_X/2; x++) {
123 for (y = 1; y <= MAP_CLIENT_Y/2; y++) {
125 if (x == MAP_CLIENT_X/2 && y == MAP_CLIENT_Y/2)
128 for (i = 0; i < 3; i++) {
133 if ((dx == x && x == MAP_CLIENT_X/2)
134 || (dy == y && y == MAP_CLIENT_Y/2)) {
139 if (x == MAP_CLIENT_X/2) {
140 set_block(x, MAP_CLIENT_Y-y-1, dx, MAP_CLIENT_Y-dy-1);
141 }
else if (y == MAP_CLIENT_Y/2) {
142 set_block(MAP_CLIENT_X-x-1, y, MAP_CLIENT_X-dx-1, dy);
154 d1 = (float)(pow(MAP_CLIENT_X/2-dx, 2)+pow(MAP_CLIENT_Y/2-dy, 2));
155 s = (float)((dy-y)*(MAP_CLIENT_X/2-dx)-(dx-x)*(MAP_CLIENT_Y/2-dy))/d1;
156 l =
FABS(sqrt(d1)*s);
163 set_block(MAP_CLIENT_X-x-1, y, MAP_CLIENT_X-dx-1, dy);
164 set_block(x, MAP_CLIENT_Y-y-1, dx, MAP_CLIENT_Y-dy-1);
165 set_block(MAP_CLIENT_X-x-1, MAP_CLIENT_Y-y-1, MAP_CLIENT_X-dx-1, MAP_CLIENT_Y-dy-1);
192 const blocks *
const at = block[
x] +
y;
199 for (
int i = 0; i < at->
index; i++) {
200 int dx = at->
x[i], dy = at->
y[i];
238 if (!block[x][y].
index)
303 for (i = 1; i <= 8; i += 1) {
361 int x,
y, darklevel, ax, ay, basex, basey, mflags, light_radius, dark_change;
417 if (light_radius == 0)
420 for (ax = basex-light_radius; ax <= basex+light_radius; ax++) {
425 for (ay = basey-light_radius; ay <= basey+light_radius; ay++) {
443 if (light_radius > 0)
445 if (light_radius < 0)
462 for (x = -1; x <= 1; x++) {
463 for (y = -1; y <= 1; y++) {
510 int mapx, mapy, dx, dy,
x,
y;
571 if (pl->
ob->
map == map)
614 if (pl->
ob->
map == map) {
669 snprintf(buf,
sizeof(buf),
"[fixed] ");
671 snprintf(buf2,
sizeof(buf2),
"%2d", x);
672 strncat(buf, buf2,
sizeof(buf)-strlen(buf)-1);
676 snprintf(buf,
sizeof(buf),
"[fixed]%2d:", y);
679 strncat(buf, buf2,
sizeof(buf)-strlen(buf)-1);
#define FLAG_SEE_IN_DARK
if set ob not effected by darkness
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...
#define MAX_LIGHT_RADII
Max radii for 'light' object, really large values allow objects that can slow down the game...
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...
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
#define FABS(x)
Decstations have trouble with fabs()...
player * first_player
First player.
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...
#define MAP_HEIGHT(m)
Map height.
#define FLAG_BLIND
If set, object cannot see (visually)
#define MAX_DARKNESS
Maximum map darkness, there is no practical reason to exceed this.
int8_t blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y]
Array showing what spaces the player can see.
#define LOS_BLOCKED
Special values for the blocked_los array.
int16_t y
Position in the map for this object.
#define SEE_IN_DARK_LEVELS
Number of darkness levels to reduce for FLAG_SEE_IN_DARK (Infravision)
void print_los(object *op)
Debug-routine which dumps the array which specifies the visible area of a player. ...
int ihypot(int a, int b)
Rough estimate of hypot(a, b).
static blocks block[MAP_CLIENT_X][MAP_CLIENT_Y]
Global type definitions and header inclusions.
struct player * contr
Pointer to the player which control this object.
static void expand_lighted_sight(object *op)
Propagate the light information.
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Sends message to player(s).
void init_block(void)
initialises the array used by the LOS routines.
#define FLAG_REMOVED
Object is not in any map or invenory.
static void set_wall(player *pl, int x, int y)
This recursively sets the blocked line of sight view.
void make_sure_seen(const object *op)
The object is supposed to be visible through walls, thus check if any players are nearby...
player * next
Pointer to next player, NULL if this is last.
#define MSG_TYPE_COMMAND
Responses to commands, eg, who.
#define XRAY_RADIUS
Number of spaces that FLAG_XRAYS (X-Ray) can see through.
uint32_t do_los
If true, need to call update_los() in draw(), and clear.
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.
#define MAP_DARKNESS(m)
Map darkness level (0-MAX_DARKNESS)
char path[HUGE_BUF]
Filename of the map.
#define QUERY_FLAG(xyz, p)
#define SPACE_BLOCK
Distance must be less than this for the object to be blocked.
short freearr_x[SIZEOFFREE]
X offset when searching around a spot.
socket_struct * socket
Socket information for this player.
int has_carried_lights(const object *op)
Checks if op has a light source.
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...
#define GET_MAP_LIGHT(M, X, Y)
Gets map light.
object * ob
The object representing the player.
int8_t glow_radius
indicates the glow radius of the object
#define P_OUT_OF_MAP
This space is outside the map.
static void check_wall(object *op, int x, int y)
Used to initialise the array used by the LOS routines.
#define FLAG_XRAYS
X-ray vision.
static void blinded_sight(player *pl)
Sets all veiwable squares to blocked except for the one the central one that the player occupies...
#define FLAG_WIZ
Object has special privilegies.
void update_los(object *op)
Recalculates the array which specifies what is visible for the given player-object.
#define MSG_TYPE_COMMAND_DEBUG
Various debug type commands.
struct mapstruct * map
Pointer to the map in which this object is present.
#define MAP_CLIENT_X
This determines the maximum map size the client can request (and thus what the server will send to th...
short freearr_y[SIZEOFFREE]
Y offset when searching around a spot.
mapstruct * tile_map[4]
Adjoining maps.
void clear_los(player *pl)
Clears/initialises the los-array associated to the player controlling the object. ...
static event_registration m
sstring name
The name of the object, obviously...
#define MAP_WIDTH(m)
Map width.
Only for debugging purposes.
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
This rolls up wall, blocks_magic, blocks_view, etc, all into one function that just returns a P_...
#define NDI_UNIQUE
Print immediately, don't buffer.
uint32_t outdoor
True if an outdoor map.
#define P_BLOCKSVIEW
This spot blocks the player's view.
uint8_t mapy
How large a map the client wants.