home
·
contact
·
privacy
projects
/
plomrogue
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
35bdfc8
)
Eliminated some potential problems for alternative game map sizes.
author
Christian Heller
<c.heller@plomlompom.de>
Wed, 5 Feb 2014 23:02:16 +0000
(
00:02
+0100)
committer
Christian Heller
<c.heller@plomlompom.de>
Wed, 5 Feb 2014 23:02:16 +0000
(
00:02
+0100)
src/client/windows.c
patch
|
blob
|
history
src/client/windows.h
patch
|
blob
|
history
src/server/ai.c
patch
|
blob
|
history
src/server/io.c
patch
|
blob
|
history
src/server/map.c
patch
|
blob
|
history
diff --git
a/src/client/windows.c
b/src/client/windows.c
index b0734dc5cca71989e1b7bc9137b0a5dd33f62952..674e6ad67a00f149dfa06fa20c778ebb3f414697 100644
(file)
--- a/
src/client/windows.c
+++ b/
src/client/windows.c
@@
-551,8
+551,8
@@
static void suspend_win(struct Win * w)
-extern uint16_t center_offset(uint16_t position, uint
16
_t mapsize,
- uint
16
_t frame_size)
+extern uint16_t center_offset(uint16_t position, uint
32
_t mapsize,
+ uint
32
_t frame_size)
{
uint16_t offset = 0;
if (mapsize > frame_size)
{
uint16_t offset = 0;
if (mapsize > frame_size)
diff --git
a/src/client/windows.h
b/src/client/windows.h
index 92a35a1d93b96ca00e1efc645e81d9b22f00ee16..872fe13a4b37f22abeeaa3ea7b1698cd639dbb62 100644
(file)
--- a/
src/client/windows.h
+++ b/
src/client/windows.h
@@
-25,7
+25,7
@@
#define WINDOWS_H
#include <ncurses.h> /* WINDOW, chtype */
#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 */
#include "../common/yx_uint16.h" /* yx_uint16 struct */
#include "keybindings.h" /* struct KeyBindingDB */
@@
-66,7
+66,7
@@
struct Win
/* Return yx offset to focus map of "mapsize" on "position" in "frame_size". */
extern uint16_t center_offset(uint16_t position,
/* Return yx offset to focus map of "mapsize" on "position" in "frame_size". */
extern uint16_t center_offset(uint16_t position,
- uint
16_t mapsize, uint16
_t frame_size);
+ uint
32_t mapsize, uint32
_t frame_size);
/* Get Win of "id". */
extern struct Win * get_win_by_id(char id);
/* Get Win of "id". */
extern struct Win * get_win_by_id(char id);
diff --git
a/src/server/ai.c
b/src/server/ai.c
index 50c5031018810d5baca6348299e394ae5329cb98..c25c277dcb73b70101c823e41e0f360b5698f204 100644
(file)
--- a/
src/server/ai.c
+++ b/
src/server/ai.c
@@
-44,7
+44,7
@@
static char get_dir_to_nearest_enemy(struct MapObj * mo_origin);
static void get_neighbor_scores(uint32_t * score_map, uint16_t pos_i,
uint32_t max_score, uint32_t * neighbors)
{
static void get_neighbor_scores(uint32_t * score_map, uint16_t pos_i,
uint32_t max_score, uint32_t * neighbors)
{
- uint
16
_t map_size = world.map.size.y * world.map.size.x;
+ uint
32
_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;
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;
@@
-90,7
+90,7
@@
static void get_neighbor_scores(uint32_t * score_map, uint16_t pos_i,
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;
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;
- uint
16
_t map_size = world.map.size.y * world.map.size.x;
+ uint
32
_t map_size = world.map.size.y * world.map.size.x;
uint16_t pos;
uint8_t scores_still_changing = 1;
uint8_t i_dirs;
uint16_t pos;
uint8_t scores_still_changing = 1;
uint8_t i_dirs;
@@
-138,7
+138,7
@@
static char get_dir_to_nearest_enemy(struct MapObj * mo_origin)
* not "mo_origin", with movement only possible in the directions of "dir".
* (Actors' own cells start with a distance of 0 towards themselves.)
*/
* not "mo_origin", with movement only possible in the directions of "dir".
* (Actors' own cells start with a distance of 0 towards themselves.)
*/
- uint
16
_t map_size = world.map.size.y * world.map.size.x;
+ uint
32
_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;
uint32_t max_score = UINT32_MAX - (world.map.dist_diagonal + 1);
uint32_t score_map[map_size];
uint32_t i;
diff --git
a/src/server/io.c
b/src/server/io.c
index a516d81b018b121a90c3fb614415b029634c81d1..2507d3b1e3e3a0faee7842261e1f572e8927fedc 100644
(file)
--- a/
src/server/io.c
+++ b/
src/server/io.c
@@
-5,7
+5,7
@@
#include <fcntl.h> /* open(), O_RDONLY, O_NONBLOCK */
#include <limits.h> /* PIPE_BUF */
#include <stddef.h> /* size_t, NULL */
#include <fcntl.h> /* open(), O_RDONLY, O_NONBLOCK */
#include <limits.h> /* PIPE_BUF */
#include <stddef.h> /* size_t, NULL */
-#include <stdint.h> /* uint8_t, uint
16_t, uint
32_t */
+#include <stdint.h> /* uint8_t, uint32_t */
#include <stdio.h> /* define FILE, sprintf() */
#include <stdlib.h> /* free() */
#include <string.h> /* strlen(), memset(), memcpy() */
#include <stdio.h> /* define FILE, sprintf() */
#include <stdlib.h> /* free() */
#include <string.h> /* strlen(), memset(), memcpy() */
@@
-183,7
+183,7
@@
static void write_inventory(struct MapObj * player, FILE * file)
static void write_map(FILE * file)
{
char * f_name = "write_map()";
static void write_map(FILE * file)
{
char * f_name = "write_map()";
- uint
16
_t map_size = world.map.size.y * world.map.size.x;
+ uint
32
_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;
char visible_map[map_size];
memcpy(visible_map, world.map.cells, map_size);
struct MapObj * o;
diff --git
a/src/server/map.c
b/src/server/map.c
index 29beb1a03d5d0a6ebf1113d6ead1cd34763f2573..9b0f29422b8564d3476b4f9223560413aa912d81 100644
(file)
--- a/
src/server/map.c
+++ b/
src/server/map.c
@@
-1,7
+1,7
@@
/* src/server/map.c */
#include "map.h"
/* 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() */
#include "../common/try_malloc.h" /* try_malloc() */
#include "../common/yx_uint8.h" /* struct yx_uint8 */
#include "rrand.h" /* rrand() */
@@
-12,7
+12,7
@@
extern void init_map()
{
char * f_name = "init_map()";
extern void init_map()
{
char * f_name = "init_map()";
- uint
16
_t size = world.map.size.x * world.map.size.y;
+ uint
32
_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++)
world.map.cells = try_malloc(size, f_name);
uint8_t y, x;
for (y = 0; y < world.map.size.y; y++)
@@
-21,13
+21,14
@@
extern void init_map()
x < world.map.size.x;
world.map.cells[(y * world.map.size.x) + x] = '~', x++);
}
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;
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])
if ('~' == world.map.cells[curpos]
&& ( ( curpos >= world.map.size.x
&& '.' == world.map.cells[curpos - world.map.size.x])
@@
-39,8
+40,8
@@
extern void init_map()
&& (curpos+1) % world.map.size.x != 0
&& '.' == world.map.cells[curpos+1])))
{
&& (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;
}
{
break;
}
@@
-57,7
+58,7
@@
extern uint8_t is_passable(struct yx_uint8 pos)
if ( 0 <= pos.x && pos.x < world.map.size.x
&& 0 <= pos.y && pos.y < world.map.size.y)
{
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;
}
}
return passable;
}