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 (from parent 1:
b9c39db
)
Server: Decouple update_map_memory() and build_fov_map(), thus fix bugs.
author
Christian Heller
<c.heller@plomlompom.de>
Sun, 7 Dec 2014 05:59:38 +0000
(06:59 +0100)
committer
Christian Heller
<c.heller@plomlompom.de>
Sun, 7 Dec 2014 05:59:38 +0000
(06:59 +0100)
SERVER_COMMANDS
patch
|
blob
|
history
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/run.c
patch
|
blob
|
history
diff --git
a/SERVER_COMMANDS
b/SERVER_COMMANDS
index c43efed6dd1682a9942cff97b64163888bd71ced..cca06717a99d73208f003a929cdcdc8b2b2486d5 100644
(file)
--- a/
SERVER_COMMANDS
+++ b/
SERVER_COMMANDS
@@
-114,8
+114,8
@@
WORLD_ACTIVE [0 to 255]
Set world activity state to argument. If 0, remove ./server/worldstate file.
Else, if world was so far inactive, a map exists, at least one "wait" thing
action is defined, and a thing of ID 0 (= a player character) that is not part
Set world activity state to argument. If 0, remove ./server/worldstate file.
Else, if world was so far inactive, a map exists, at least one "wait" thing
action is defined, and a thing of ID 0 (= a player character) that is not part
-of any other thing's inventory, (re-)build all animate things' fields of view
and
-activate world. (Initial value: 0.)
+of any other thing's inventory, (re-)build all animate things' fields of view
,
+a
nd a
ctivate world. (Initial value: 0.)
TA_ID [0 to 255]
Select thing action to manipulate by argument as ID. If argument is 0, change it
TA_ID [0 to 255]
Select thing action to manipulate by argument as ID. If argument is 0, change it
diff --git
a/src/server/field_of_view.c
b/src/server/field_of_view.c
index 34bfa138eb06c1b5f641f0ff386d78d0f7e9d3d6..7ab567833a1bd67eb3087c67e80e9fc92eb28c70 100644
(file)
--- a/
src/server/field_of_view.c
+++ b/
src/server/field_of_view.c
@@
-75,11
+75,6
@@
static void eval_position(uint16_t dist, uint16_t hex_i, char * fov_map,
struct yx_uint8 * test_pos,
struct shadow_angle ** shadows);
struct yx_uint8 * test_pos,
struct shadow_angle ** shadows);
-/* Update "t"'s .mem_map memory with what's in its current FOV, remove from its
- * .t_mem all memorized things in FOV and add inanimiate things in FOV to it.
- */
-static void update_map_memory(struct Thing * t, uint32_t map_size);
-
static uint32_t correct_angle(int32_t angle)
static uint32_t correct_angle(int32_t angle)
@@
-267,15
+262,15
@@
static void eval_position(uint16_t dist, uint16_t hex_i, char * fov_map,
-
static void update_map_memory(struct Thing * t_eye, uint32_t map_siz
e)
+
extern void update_map_memory(struct Thing * t_ey
e)
{
if (!t_eye->mem_map)
{
{
if (!t_eye->mem_map)
{
- t_eye->mem_map = try_malloc(
map_size,
__func__);
- memset(t_eye->mem_map, ' ',
map_size
);
+ t_eye->mem_map = try_malloc(
world.map.length*world.map.length,
__func__);
+ memset(t_eye->mem_map, ' ',
world.map.length * world.map.length
);
}
uint32_t i;
}
uint32_t i;
- for (i = 0; i <
map_size
; i++)
+ for (i = 0; i <
(uint32_t) (world.map.length * world.map.length)
; i++)
{
if (' ' == t_eye->mem_map[i] && t_eye->fov_map[i] == 'v')
{
{
if (' ' == t_eye->mem_map[i] && t_eye->fov_map[i] == 'v')
{
@@
-352,5
+347,4
@@
extern void build_fov_map(struct Thing * t)
}
mv_yx_in_dir_legal(0, NULL);
free_angles(shadows);
}
mv_yx_in_dir_legal(0, NULL);
free_angles(shadows);
- update_map_memory(t, map_size);
}
}
diff --git
a/src/server/field_of_view.h
b/src/server/field_of_view.h
index 6e4edb908c2779a1648387417bb5c2a9fcbd642b..5cc9edb6601b871b1ba824d0076715722b023fc0 100644
(file)
--- a/
src/server/field_of_view.h
+++ b/
src/server/field_of_view.h
@@
-10,12
+10,17
@@
#ifndef FIELD_OF_VIEW_H
#define FIELD_OF_VIEW_H
#ifndef FIELD_OF_VIEW_H
#define FIELD_OF_VIEW_H
-#include <stdint.h> /* uint8_t */
+#include <stdint.h> /* uint8_t
, uint32_t
*/
struct Thing;
struct Thing;
-/* Build "t"'s field of view and update its map memory with the result. */
+/* Update "t"'s .mem_map memory with what's in its current FOV, remove from its
+ * .t_mem all memorized things in FOV and add inanimiate things in FOV to it.
+ */
+extern void update_map_memory(struct Thing * t_eye);
+
+/* Build "t"'s field of view. */
extern void build_fov_map(struct Thing * t);
extern void build_fov_map(struct Thing * t);
diff --git
a/src/server/god_commands.c
b/src/server/god_commands.c
index 06abcfec87626d6677daa9586db3bf0e35dc8042..a190682edbd1c28efcfed80891b14ba7277a7c71 100644
(file)
--- a/
src/server/god_commands.c
+++ b/
src/server/god_commands.c
@@
-15,7
+15,7
@@
#include "../common/rexit.h" /* exit_trouble() */
#include "../common/try_malloc.h" /* try_malloc() */
#include "cleanup.h" /* unset_cleanup_flag() */
#include "../common/rexit.h" /* exit_trouble() */
#include "../common/try_malloc.h" /* try_malloc() */
#include "cleanup.h" /* unset_cleanup_flag() */
-#include "field_of_view.h" /* build_fov_map() */
+#include "field_of_view.h" /* build_fov_map()
, update_map_memory()
*/
#include "hardcoded_strings.h" /* s */
#include "init.h" /* remake_world() */
#include "map.h" /* remake_map() */
#include "hardcoded_strings.h" /* s */
#include "init.h" /* remake_world() */
#include "map.h" /* remake_map() */
@@
-23,7
+23,8
@@
* actor_use(), actor_pickup(), actor_drop()
*/
#include "things.h" /* Thing, ThingType, add_thing(), get_thing(), own_thing(),
* actor_use(), actor_pickup(), actor_drop()
*/
#include "things.h" /* Thing, ThingType, add_thing(), get_thing(), own_thing(),
- * free_things(), add_thing_to_memory_map(),get_thing_type()
+ * free_things(), add_thing_to_memory_map(),get_thing_type(),
+ * get_player()
*/
#include "world.h" /* world */
*/
#include "world.h" /* world */
@@
-251,6
+252,10
@@
static uint8_t parse_position(char* tok0, char * tok1, struct Thing * t)
if (world.exists && t->lifepoints)
{
build_fov_map(t);
if (world.exists && t->lifepoints)
{
build_fov_map(t);
+ if (t == get_player())
+ {
+ update_map_memory(t);
+ }
}
}
return 1;
}
}
return 1;
@@
-374,6
+379,10
@@
static uint8_t parse_world_active(char * tok0, char * tok1)
if (ti->lifepoints)
{
build_fov_map(ti);
if (ti->lifepoints)
{
build_fov_map(ti);
+ if (ti == get_player())
+ {
+ update_map_memory(ti);
+ }
}
}
world.exists = 1;
}
}
world.exists = 1;
diff --git
a/src/server/init.c
b/src/server/init.c
index 093f1f5053905638ef2e5545a420db8bd707e1e2..43a4d685a5477a2a375f9e7c2fc4c08b6f4c5a86 100644
(file)
--- a/
src/server/init.c
+++ b/
src/server/init.c
@@
-25,11
+25,11
@@
#include "../common/rexit.h" /* exit_err(), exit_trouble() */
#include "../common/try_malloc.h" /* try_malloc() */
#include "cleanup.h" /* set_cleanup_flag() */
#include "../common/rexit.h" /* exit_err(), exit_trouble() */
#include "../common/try_malloc.h" /* try_malloc() */
#include "cleanup.h" /* set_cleanup_flag() */
-#include "field_of_view.h" /*
build_fov_map
() */
+#include "field_of_view.h" /*
update_map_memory
() */
#include "hardcoded_strings.h" /* s */
#include "map.h" /* remake_map() */
#include "things.h" /* Thing, ThingType, free_things(), add_things(),
#include "hardcoded_strings.h" /* s */
#include "map.h" /* remake_map() */
#include "things.h" /* Thing, ThingType, free_things(), add_things(),
- * get_thing_id_action_id_by_name()
+ * get_thing_id_action_id_by_name()
, get_player()
*/
#include "run.h" /* obey_msg(), io_loop(), record(), send_to_outfile() */
#include "world.h" /* global world */
*/
#include "run.h" /* obey_msg(), io_loop(), record(), send_to_outfile() */
#include "world.h" /* global world */
@@
-199,6
+199,7
@@
extern uint8_t remake_world()
world.seed_map = world.seed;
free_things(world.things);
remake_map();
world.seed_map = world.seed;
free_things(world.things);
remake_map();
+ world.exists = 1;
struct ThingType * tt;
for (tt = world.thing_types; tt; tt = tt->next)
{
struct ThingType * tt;
for (tt = world.thing_types; tt; tt = tt->next)
{
@@
-208,6
+209,7
@@
extern uint8_t remake_world()
break;
}
}
break;
}
}
+ update_map_memory(get_player());
for (tt = world.thing_types; tt; tt = tt->next)
{
if (world.player_type != tt->id)
for (tt = world.thing_types; tt; tt = tt->next)
{
if (world.player_type != tt->id)
@@
-215,16
+217,7
@@
extern uint8_t remake_world()
add_things(tt->id, tt->start_n);
}
}
add_things(tt->id, tt->start_n);
}
}
- struct Thing * t;
- for (t = world.things; t; t = t->next)
- {
- if (t->lifepoints)
- {
- build_fov_map(t);
- }
- }
world.turn = 1;
world.turn = 1;
- world.exists = 1;
send_to_outfile("NEW_WORLD\n", 1);
return 0;
}
send_to_outfile("NEW_WORLD\n", 1);
return 0;
}
diff --git
a/src/server/run.c
b/src/server/run.c
index 6f24f461d0c6d96ccf404574b8a8cc89d697dec7..38dc5a04174edc6b68832f227cbb40f9a7a2ac8d 100644
(file)
--- a/
src/server/run.c
+++ b/
src/server/run.c
@@
-26,6
+26,7
@@
#include "../common/try_malloc.h" /* try_malloc() */
#include "ai.h" /* ai() */
#include "cleanup.h" /* unset_cleanup_flag() */
#include "../common/try_malloc.h" /* try_malloc() */
#include "ai.h" /* ai() */
#include "cleanup.h" /* unset_cleanup_flag() */
+#include "field_of_view.h" /* update_map_memory() */
#include "god_commands.h" /* parse_god_command_(1|2|3)arg() */
#include "hardcoded_strings.h" /* s */
#include "io.h" /* io_round(), save_world() */
#include "god_commands.h" /* parse_god_command_(1|2|3)arg() */
#include "hardcoded_strings.h" /* s */
#include "io.h" /* io_round(), save_world() */
@@
-325,6
+326,7
@@
static void turn_over()
{
if (0 == thing->command)
{
{
if (0 == thing->command)
{
+ update_map_memory(thing);
if (thing == player)
{
break;
if (thing == player)
{
break;