home · contact · privacy
Server: Make objects definable as "consumable" to gain n hitpoints.
[plomrogue] / src / server / map_objects.c
index 696db048ad17d3810a468a023d268bf99a7bdcac..f60cefeb3092b7df42c3b5c8c7a3ea7c78330a4c 100644 (file)
@@ -10,7 +10,7 @@
                                       * reset_err_try_fgets_counter()
                                       */
 #include "../common/readwrite.h" /* try_fopen(), try_fclose(), try_fgetc(),
-                                  * textfile_sizes()
+                                  * textfile_width()
                                   */
 #include "../common/rexit.h" /* exit_err(), exit_trouble() */
 #include "../common/try_malloc.h" /* try_malloc() */
@@ -108,7 +108,7 @@ extern void init_map_object_defs()
     char * err_toolarge = "Value is too large.";
     char * err_uniq     = "Declaration of ID already used.";
     FILE * file = try_fopen(world.path_map_obj_defs, "r", f_name);
-    uint32_t linemax = textfile_sizes(file, NULL);
+    uint32_t linemax = textfile_width(file);
     struct MapObjDef ** last_mod_ptr_ptr = &world.map_obj_defs;
     char line[linemax + 1];
     reset_err_try_fgets_counter();
@@ -142,6 +142,9 @@ extern void init_map_object_defs()
         line[strlen(line) - 1] = '\0';
         mod->name = try_malloc(strlen(line) + 1, f_name);
         memcpy(mod->name, line, strlen(line) + 1);
+        err_try_fgets(line, linemax, file, context, "0nfi");
+        err_line(atoi(line) > UINT8_MAX, line, context, err_toolarge);
+        mod->consumable = atoi(line);
         * last_mod_ptr_ptr = mod;
         last_mod_ptr_ptr = &mod->next;
         err_try_fgets(line, linemax, file, context, "d");