home · contact · privacy
Add to TODO.
[plomrogue] / src / server / god_commands.c
index 755acd5881b4ff8bf4ba604c08d89c0f8d83e986..420142a92d830eb5eaeb6ce13d25822d1b438466 100644 (file)
@@ -18,7 +18,7 @@
                             * actor_use(), actor_pickup(), actor_drop()
                             */
 #include "things.h" /* Thing, ThingType, add_thing(), get_thing(), own_thing(),
-                     * free_things()
+                     * free_things(), add_thing_to_memory_map(),get_thing_type()
                      */
 #include "world.h" /* world */
 
@@ -301,7 +301,7 @@ 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)
@@ -475,3 +475,34 @@ extern uint8_t parse_god_command_2arg(char * tok0, char * tok1, char * tok2)
     }
     return 1;
 }
+
+
+
+extern uint8_t parse_god_command_3arg(char * tok0, char * tok1, char * tok2,
+                                      char * tok3)
+{
+    if (!t && !strcmp(tok0, s[S_CMD_T_MEMTHING]))
+    {
+        err_line(1, "No thing defined to manipulate yet.");
+        return 1;
+    }
+    if (!strcmp(tok0, s[S_CMD_T_MEMTHING]))
+    {
+        uint8_t id = atoi(tok1);
+        uint8_t y  = atoi(tok2);
+        uint8_t x  = atoi(tok3);
+        if (   parsetest_int(tok1, '8') || !get_thing_type(id)
+            || 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;
+        }
+        add_thing_to_memory_map(t, id, y, x);
+    }
+    else
+    {
+        return 0;
+    }
+    return 1;
+}