-extern uint16_t center_offset(uint16_t position, uint16_t mapsize,
- uint16_t frame_size)
+extern uint16_t center_offset(uint16_t position, uint32_t mapsize,
+ uint32_t frame_size)
{
uint16_t offset = 0;
if (mapsize > frame_size)
#define WINDOWS_H
#include <ncurses.h> /* WINDOW, chtype */
-#include <stdint.h> /* uint8_t, int16_t, uint16_t */
+#include <stdint.h> /* uint8_t, int16_t, uint16_t, uint32_t */
#include "../common/yx_uint16.h" /* yx_uint16 struct */
#include "keybindings.h" /* struct KeyBindingDB */
/* Return yx offset to focus map of "mapsize" on "position" in "frame_size". */
extern uint16_t center_offset(uint16_t position,
- uint16_t mapsize, uint16_t frame_size);
+ uint32_t mapsize, uint32_t frame_size);
/* Get Win of "id". */
extern struct Win * get_win_by_id(char id);
static void get_neighbor_scores(uint32_t * score_map, uint16_t pos_i,
uint32_t max_score, uint32_t * neighbors)
{
- uint16_t map_size = world.map.size.y * world.map.size.x;
+ uint32_t map_size = world.map.size.y * world.map.size.x;
uint8_t i_dir;
for (i_dir = 0; i_dir < N_DIRS; neighbors[i_dir] = max_score, i_dir++);
uint8_t open_north = pos_i >= world.map.size.x;
static void dijkstra_map(uint32_t * score_map, uint32_t max_score)
{
uint32_t i_scans, neighbors[N_DIRS], min_neighbor_o, min_neighbor_d;
- uint16_t map_size = world.map.size.y * world.map.size.x;
+ uint32_t map_size = world.map.size.y * world.map.size.x;
uint16_t pos;
uint8_t scores_still_changing = 1;
uint8_t i_dirs;
* not "mo_origin", with movement only possible in the directions of "dir".
* (Actors' own cells start with a distance of 0 towards themselves.)
*/
- uint16_t map_size = world.map.size.y * world.map.size.x;
+ uint32_t map_size = world.map.size.y * world.map.size.x;
uint32_t max_score = UINT32_MAX - (world.map.dist_diagonal + 1);
uint32_t score_map[map_size];
uint32_t i;
#include <fcntl.h> /* open(), O_RDONLY, O_NONBLOCK */
#include <limits.h> /* PIPE_BUF */
#include <stddef.h> /* size_t, NULL */
-#include <stdint.h> /* uint8_t, uint16_t, uint32_t */
+#include <stdint.h> /* uint8_t, uint32_t */
#include <stdio.h> /* define FILE, sprintf() */
#include <stdlib.h> /* free() */
#include <string.h> /* strlen(), memset(), memcpy() */
static void write_map(FILE * file)
{
char * f_name = "write_map()";
- uint16_t map_size = world.map.size.y * world.map.size.x;
+ uint32_t map_size = world.map.size.y * world.map.size.x;
char visible_map[map_size];
memcpy(visible_map, world.map.cells, map_size);
struct MapObj * o;
/* src/server/map.c */
#include "map.h"
-#include <stdint.h> /* uint8_t, uint16_t */
+#include <stdint.h> /* uint8_t, uint16_t, uint32_t */
#include "../common/try_malloc.h" /* try_malloc() */
#include "../common/yx_uint8.h" /* struct yx_uint8 */
#include "rrand.h" /* rrand() */
extern void init_map()
{
char * f_name = "init_map()";
- uint16_t size = world.map.size.x * world.map.size.y;
+ uint32_t size = world.map.size.x * world.map.size.y;
world.map.cells = try_malloc(size, f_name);
uint8_t y, x;
for (y = 0; y < world.map.size.y; y++)
x < world.map.size.x;
world.map.cells[(y * world.map.size.x) + x] = '~', x++);
}
- world.map.cells[size / 2 + (world.map.size.x / 2)] = '.';
+ uint8_t add_half_width = !(world.map.size.y % 2) * (world.map.size.x / 2);
+ world.map.cells[(size / 2) + add_half_width] = '.';
uint16_t curpos;
while (1)
{
y = rrand() % world.map.size.y;
x = rrand() % world.map.size.x;
- curpos = y * world.map.size.x + x;
+ curpos = (y * world.map.size.x) + x;
if ('~' == world.map.cells[curpos]
&& ( ( curpos >= world.map.size.x
&& '.' == world.map.cells[curpos - world.map.size.x])
&& (curpos+1) % world.map.size.x != 0
&& '.' == world.map.cells[curpos+1])))
{
- if ( y == 0 || y == world.map.size.y - 1 || x == 0
- || x == world.map.size.x - 1)
+ if ( y == 0 || y == world.map.size.y - 1
+ || x == 0 || x == world.map.size.x - 1)
{
break;
}
if ( 0 <= pos.x && pos.x < world.map.size.x
&& 0 <= pos.y && pos.y < world.map.size.y)
{
- passable = (('.' == world.map.cells[pos.y * world.map.size.x + pos.x]));
+ passable = ('.' == world.map.cells[(pos.y * world.map.size.x) + pos.x]);
}
return passable;
}