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,
+and activate world. (Initial value: 0.)
TA_ID [0 to 255]
Select thing action to manipulate by argument as ID. If argument is 0, change it
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 void update_map_memory(struct Thing * t_eye, uint32_t map_size)
+extern void update_map_memory(struct Thing * t_eye)
{
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;
- 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')
{
}
mv_yx_in_dir_legal(0, NULL);
free_angles(shadows);
- update_map_memory(t, map_size);
}
#ifndef FIELD_OF_VIEW_H
#define FIELD_OF_VIEW_H
-#include <stdint.h> /* uint8_t */
+#include <stdint.h> /* uint8_t, uint32_t */
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);
#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() */
* 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 */
if (world.exists && t->lifepoints)
{
build_fov_map(t);
+ if (t == get_player())
+ {
+ update_map_memory(t);
+ }
}
}
return 1;
if (ti->lifepoints)
{
build_fov_map(ti);
+ if (ti == get_player())
+ {
+ update_map_memory(ti);
+ }
}
}
world.exists = 1;
#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(),
- * 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 */
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)
{
break;
}
}
+ update_map_memory(get_player());
for (tt = world.thing_types; tt; tt = tt->next)
{
if (world.player_type != tt->id)
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.exists = 1;
send_to_outfile("NEW_WORLD\n", 1);
return 0;
}
#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() */
{
if (0 == thing->command)
{
+ update_map_memory(thing);
if (thing == player)
{
break;