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:
522ee38
)
Server: Refactor writing of field of view to Thing struct.
author
Christian Heller
<c.heller@plomlompom.de>
Wed, 30 Jul 2014 04:38:31 +0000
(06:38 +0200)
committer
Christian Heller
<c.heller@plomlompom.de>
Wed, 30 Jul 2014 04:38:31 +0000
(06:38 +0200)
src/server/field_of_view.c
patch
|
blob
|
history
src/server/field_of_view.h
patch
|
blob
|
history
src/server/god_commands.c
patch
|
blob
|
history
src/server/init.c
patch
|
blob
|
history
src/server/thing_actions.c
patch
|
blob
|
history
diff --git
a/src/server/field_of_view.c
b/src/server/field_of_view.c
index 1a9acd588654f6d44b523ff18180a2201493fab9..f34885de66d073a771f848c200032d820d8182bc 100644
(file)
--- a/
src/server/field_of_view.c
+++ b/
src/server/field_of_view.c
@@
-327,7
+327,7
@@
static void eval_position(uint16_t dist, uint16_t hex_i, uint8_t * fov_map,
-extern
uint8_t *
build_fov_map(struct Thing * eye)
+extern
void
build_fov_map(struct Thing * eye)
{
uint32_t map_size = world.map.length * world.map.length;
uint8_t * fov_map = try_malloc(map_size, __func__);
{
uint32_t map_size = world.map.length * world.map.length;
uint8_t * fov_map = try_malloc(map_size, __func__);
@@
-363,5
+363,6
@@
extern uint8_t * build_fov_map(struct Thing * eye)
}
mv_yx_in_dir_wrap(0, NULL, 1);
free_angles(shadows);
}
mv_yx_in_dir_wrap(0, NULL, 1);
free_angles(shadows);
- return fov_map;
+ free(eye->fov_map);
+ eye->fov_map = fov_map;
}
}
diff --git
a/src/server/field_of_view.h
b/src/server/field_of_view.h
index 85a414f8e84e8a2835484be5ce5b8c815e77cfc8..555ae63c12a2e4780615342a65983282f8570078 100644
(file)
--- a/
src/server/field_of_view.h
+++ b/
src/server/field_of_view.h
@@
-19,8
+19,8
@@
enum fov_cell_states {
VISIBLE = 0x01
};
VISIBLE = 0x01
};
-/*
Return field of view map of the world as seen from the position of "eye"
. */
-extern
uint8_t *
build_fov_map(struct Thing * eye);
+/*
Build "eye"'s field of view
. */
+extern
void
build_fov_map(struct Thing * eye);
diff --git
a/src/server/god_commands.c
b/src/server/god_commands.c
index b0aa86aabf2d6e927065d486d7cd92ecb543107a..6eec5722d6bddcf729f9264d104a1490e9d9de5c 100644
(file)
--- a/
src/server/god_commands.c
+++ b/
src/server/god_commands.c
@@
-239,10
+239,9
@@
static uint8_t parse_position(char* tok0, char * tok1, struct Thing * t)
{
t->pos.x = length;
}
{
t->pos.x = length;
}
- free(t->fov_map);
if (world.exists && t->lifepoints)
{
if (world.exists && t->lifepoints)
{
-
t->fov_map =
build_fov_map(t);
+ build_fov_map(t);
}
}
return 1;
}
}
return 1;
@@
-302,7
+301,7
@@
static uint8_t parse_thing_manipulation(char * tok0, char * tok1)
t = add_thing(id, world.thing_types->id, 0, 0);
if (world.exists && t->lifepoints)
{
t = add_thing(id, world.thing_types->id, 0, 0);
if (world.exists && t->lifepoints)
{
-
t->fov_map =
build_fov_map(t);
+ build_fov_map(t);
}
}
}
}
}
}
@@
-371,11
+370,7
@@
static uint8_t parse_world_active(char * tok0, char * tok1)
{
if (ti->lifepoints)
{
{
if (ti->lifepoints)
{
- if (ti->fov_map)
- {
- free(ti->fov_map);
- }
- ti->fov_map = build_fov_map(ti);
+ build_fov_map(ti);
}
}
world.exists = 1;
}
}
world.exists = 1;
diff --git
a/src/server/init.c
b/src/server/init.c
index 01950bcac3111f455dabd97eb515090e8c89d3e2..42ec699a921d067f237c7eb67c9bafaa78454463 100644
(file)
--- a/
src/server/init.c
+++ b/
src/server/init.c
@@
-215,7
+215,10
@@
extern uint8_t remake_world()
struct Thing * t;
for (t = world.things; NULL != t; t = t->next)
{
struct Thing * t;
for (t = world.things; NULL != t; t = t->next)
{
- t->fov_map = t->lifepoints ? build_fov_map(t) : NULL;
+ if (t->lifepoints)
+ {
+ build_fov_map(t);
+ }
}
world.turn = 1;
world.do_update = 1;
}
world.turn = 1;
world.do_update = 1;
diff --git
a/src/server/thing_actions.c
b/src/server/thing_actions.c
index bcf9e455f4d382d538633f75681f77b6d76d7b3d..8d6a802417ea6df95068892fe3b89b77cad7057f 100644
(file)
--- a/
src/server/thing_actions.c
+++ b/
src/server/thing_actions.c
@@
-266,8
+266,7
@@
extern void actor_move(struct Thing * t)
if (passable)
{
set_thing_position(t, target);
if (passable)
{
set_thing_position(t, target);
- free(t->fov_map);
- t->fov_map = build_fov_map(t);
+ build_fov_map(t);
}
if (t == get_player())
{
}
if (t == get_player())
{