X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=src%2Fserver%2Fgod_commands.c;h=a190682edbd1c28efcfed80891b14ba7277a7c71;hb=ac7521c1d40b86cd7d33cef590353692542fa0a4;hp=09aeecec624d60e48d0703478c0f46787d550968;hpb=3dedf6344c941891491773d1cc5d647aa664b218;p=plomrogue
diff --git a/src/server/god_commands.c b/src/server/god_commands.c
index 09aeece..a190682 100644
--- a/src/server/god_commands.c
+++ b/src/server/god_commands.c
@@ -1,4 +1,9 @@
-/* src/server/god_commands.c */
+/* src/server/god_commands.c
+ *
+ * This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
+ * or any later version. For details on its copyright, license, and warranties,
+ * see the file NOTICE in the root directory of the PlomRogue source package.
+ */
#include "god_commands.h"
#include /* NULL */
@@ -10,7 +15,7 @@
#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() */
@@ -18,7 +23,8 @@
* 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 */
@@ -83,23 +89,23 @@ static uint8_t parse_thingtype_manipulation(char * tok0, char * tok1)
if (!tt &&
( !strcmp(tok0, s[S_CMD_TT_CONSUM]) || !strcmp(tok0, s[S_CMD_TT_SYMB])
|| !strcmp(tok0, s[S_CMD_TT_STARTN]) || !strcmp(tok0, s[S_CMD_TT_NAME])
- || !strcmp(tok0, s[S_CMD_TT_CORPS]) || !strcmp(tok0, s[S_CMD_TT_HP])))
+ || !strcmp(tok0, s[S_CMD_TT_CORPS]) || !strcmp(tok0, s[S_CMD_TT_HP])
+ || !strcmp(tok0, s[S_CMD_TT_PROL])))
{
- err_line(1, "No thing type defined to manipulate yet.");
- return 1;
+ return err_line(1, "No thing type defined to manipulate yet.");
}
int16_t id;
if ( parse_val(tok0,tok1,s[S_CMD_TT_CONSUM],'8',(char *) &tt->consumable)
|| parse_val(tok0,tok1,s[S_CMD_TT_HP],'8',(char *) &tt->lifepoints)
|| parse_val(tok0,tok1,s[S_CMD_TT_STARTN],'8',(char *) &tt->start_n)
|| parse_val(tok0,tok1,s[S_CMD_TT_SYMB],'c',(char *) &tt->char_on_map)
+ || parse_val(tok0,tok1,s[S_CMD_TT_PROL],'8',(char *) &tt->proliferate)
|| parse_val(tok0,tok1,s[S_CMD_TT_NAME],'s',(char *) &tt->name));
else if (parse_val(tok0, tok1, s[S_CMD_TT_CORPS],'8',(char *)&id))
{
if (!get_thing_type(id))
{
- err_line(1, "Corpse ID belongs to no known thing type.");
- return 1;
+ return err_line(1, "Corpse ID belongs to no known thing type.");
}
tt->corpse_id = id;
}
@@ -138,8 +144,7 @@ static uint8_t parse_thingaction_manipulation(char * tok0, char * tok1)
if (!ta &&
(!strcmp(tok0, s[S_CMD_TA_EFFORT]) || !strcmp(tok0, s[S_CMD_TA_NAME])))
{
- err_line(1, "No thing action defined to manipulate yet.");
- return 1;
+ return err_line(1, "No thing action defined to manipulate yet.");
}
int16_t id;
if (parse_val(tok0, tok1, s[S_CMD_TA_EFFORT],'8',(char *)&ta->effort));
@@ -151,11 +156,10 @@ static uint8_t parse_thingaction_manipulation(char * tok0, char * tok1)
|| try_func_name(ta, s[S_CMD_DROP], actor_drop)
|| try_func_name(ta, s[S_CMD_USE], actor_use)))
{
- err_line(1, "Invalid action function name.");
- return 1;
- } /* Legal worlds have at least one thing action for waiting. */
+ return err_line(1, "Invalid action function name.");
+ }
if (world.exists)
- {
+ { /* Legal worlds have at least one thing action for waiting. */
world.exists = 0 != get_thing_action_id_by_name(s[S_CMD_WAIT]);
if (!world.exists)
{
@@ -248,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 (t == get_player())
+ {
+ update_map_memory(t);
+ }
}
}
return 1;
@@ -286,8 +294,7 @@ static uint8_t parse_thing_manipulation_1arg(char * tok0, char * tok1)
|| !strcmp(tok0, s[S_CMD_T_POSY]) || !strcmp(tok0, s[S_CMD_T_ARGUMENT])
|| !strcmp(tok0, s[S_CMD_T_HP]) || !strcmp(tok0, s[S_CMD_T_COMMAND])))
{
- err_line(1, "No thing defined to manipulate yet.");
- return 1;
+ return err_line(1, "No thing defined to manipulate yet.");
}
int16_t id;
if ( parse_thing_type(tok0, tok1, t)
@@ -301,13 +308,9 @@ static uint8_t parse_thing_manipulation_1arg(char * tok0, char * tok1)
{
t = get_thing(world.things, id, 1);
char * err = "No thing type found to initialize new thing.";
- if (!t && !err_line(NULL == world.thing_types, err))
+ if (!t && !err_line(!world.thing_types, err))
{
t = add_thing(id, world.thing_types->id, 0, 0);
- if (world.exists && t->lifepoints)
- {
- build_fov_map(t);
- }
}
}
else
@@ -376,6 +379,10 @@ static uint8_t parse_world_active(char * tok0, char * tok1)
if (ti->lifepoints)
{
build_fov_map(ti);
+ if (ti == get_player())
+ {
+ update_map_memory(ti);
+ }
}
}
world.exists = 1;
@@ -395,8 +402,7 @@ static uint8_t set_map_length(char * tok0, char * tok1)
uint16_t argument = atoi(tok1);
if (argument < 1 || argument > 256)
{
- err_line(1, "Value must be >= 1 and <= 256.");
- return 1;
+ return err_line(1, "Value must be >= 1 and <= 256.");
}
world.exists = 0;
remove_worldstate_file();
@@ -445,21 +451,18 @@ extern uint8_t parse_god_command_2arg(char * tok0, char * tok1, char * tok2)
{
if (!t && !strcmp(tok0, s[S_CMD_T_MEMMAP]))
{
- err_line(1, "No thing defined to manipulate yet.");
- return 1;
+ return err_line(1, "No thing defined to manipulate yet.");
}
if (!strcmp(tok0, s[S_CMD_T_MEMMAP]))
{
uint8_t y = atoi(tok1);
if (parsetest_int(tok1, '8') || y >= world.map.length)
{
- err_line(1, "Illegal value for map line number.");
- return 1;
+ return err_line(1, "Illegal value for map line number.");
}
if (strlen(tok2) != world.map.length)
{
- err_line(1, "Map line length is unequal map width.");
- return 1;
+ return err_line(1, "Map line length is unequal map width.");
}
if (!t->mem_map)
{
@@ -483,8 +486,7 @@ extern uint8_t parse_god_command_3arg(char * tok0, char * tok1, char * tok2,
{
if (!t && !strcmp(tok0, s[S_CMD_T_MEMTHING]))
{
- err_line(1, "No thing defined to manipulate yet.");
- return 1;
+ return err_line(1, "No thing defined to manipulate yet.");
}
if (!strcmp(tok0, s[S_CMD_T_MEMTHING]))
{
@@ -495,8 +497,7 @@ extern uint8_t parse_god_command_3arg(char * tok0, char * tok1, char * tok2,
|| parsetest_int(tok2, '8') || y >= world.map.length
|| parsetest_int(tok3, '8') || x >= world.map.length)
{
- err_line(1, "Illegal value for thing type or position.");
- return 1;
+ return err_line(1, "Illegal value for thing type or position.");
}
add_thing_to_memory_map(t, id, y, x);
}