home · contact · privacy
Server: Add ENEMY_FOV option (default: off) to force FOV on enemies.
[plomrogue] / src / server / configfile.c
index aad3b7417e6f53823f91258dcd38759f5603d07a..14464396dc7e93ff6af93396d8a0faee0e2f78bf 100644 (file)
@@ -28,8 +28,6 @@ enum flag
 {
     HEIGHT_SET     = 0x02,
     WIDTH_SET      = 0x04,
-    ORTH_SET       = 0x08,
-    DIAG_SET       = 0x10,
     NAME_SET       = 0x02,
     EFFORT_SET     = 0x04,
     CORPSE_ID_SET  = 0x04,
@@ -40,7 +38,7 @@ enum flag
     READY_ACT = NAME_SET | EFFORT_SET,
     READY_OBJ = NAME_SET | CORPSE_ID_SET | SYMBOL_SET | LIFEPOINTS_SET
                 | CONSUMABLE_SET | START_N_SET,
-    READY_MAP = HEIGHT_SET | WIDTH_SET | ORTH_SET | DIAG_SET
+    READY_MAP = HEIGHT_SET | WIDTH_SET
 };
 
 
@@ -92,6 +90,12 @@ static void write_if_entry(struct EntryHead ** entry,
  */
 static void test_corpse_ids();
 
+/* set_members() helper specifically for editing world.map members. */
+static uint8_t set_map_members(char * token0,char * token1,uint8_t * map_flags);
+
+/* If "token0" matches "comparand", set world.enemy_fov to "token1". */
+static uint8_t set_enemy_fov(char * token0, char * comparand, char * token1);
+
 /* If "token0" matches "comparand", set world.player_type to int in "token1". */
 static uint8_t set_player_type(char * token0, char * comparand, char * token1);
 
@@ -106,9 +110,6 @@ static uint8_t set_members(char * token0, char * token1, uint8_t * object_flags,
                            uint8_t * action_flags, uint8_t * map_flags,
                            struct MapObjDef * mod, struct MapObjAct * moa);
 
-/* set_members() helper specifically for editing world.map members. */
-static uint8_t set_map_members(char * token0,char * token1,uint8_t * map_flags);
-
 /* If "name" fits "moa"->name, set "moa"->func to "func". (Derives MapObjAct
  * .func from .name for set_members().
  */
@@ -123,6 +124,7 @@ static void tokens_into_entries(char * token0, char * token1)
     char * str_obj = "OBJECT";
     char * str_map = "MAP_TYPE";
     char * str_player = "PLAYER_TYPE";
+    char * str_enemyfov = "ENEMY_FOV";
     static struct MapObjAct ** moa_p_p = &world.map_obj_acts;
     static struct MapObjDef ** mod_p_p = &world.map_obj_defs;
     static uint8_t action_flags = READY_ACT;
@@ -131,7 +133,8 @@ static void tokens_into_entries(char * token0, char * token1)
     static struct EntryHead * moa = NULL;
     static struct EntryHead * mod = NULL;
     if (!token0 || !strcmp(token0, str_act) || !strcmp(token0, str_obj)
-                || !strcmp(token0, str_map) || !strcmp(token0, str_player))
+                || !strcmp(token0, str_map) || !strcmp(token0, str_player)
+                || !strcmp(token0, str_enemyfov))
     {
         parse_and_reduce_to_readyflag(&action_flags, READY_ACT);
         parse_and_reduce_to_readyflag(&object_flags, READY_OBJ);
@@ -142,17 +145,22 @@ static void tokens_into_entries(char * token0, char * token1)
     if (token0)
     {
         parsetest_too_many_values();
-        if (!(   start_entry(token0, token1, str_act, &action_flags,
-                             sizeof(struct MapObjAct),(struct EntryHead**) &moa,
-                             (struct EntryHead *) world.map_obj_acts)
-              || start_entry(token0, token1, str_obj, &object_flags,
-                             sizeof(struct MapObjDef),(struct EntryHead**) &mod,
-                             (struct EntryHead *) world.map_obj_defs)
-              || start_map(token0, str_map, &map_flags)
-              || set_player_type(token0, str_player, token1)
-              || set_members(token0, token1, &object_flags, &action_flags,
-                              &map_flags, (struct MapObjDef *)mod,
-                              (struct MapObjAct *) moa)))
+        if (start_entry(token0, token1, str_act, &action_flags,
+                        sizeof(struct MapObjAct), (struct EntryHead**) &moa,
+                        (struct EntryHead *) world.map_obj_acts))
+        {
+            err_line(0 == atoi(token1), "Value must not be 0.");
+        }
+        else if (!(   start_entry(token0, token1, str_obj, &object_flags,
+                                  sizeof(struct MapObjDef),
+                                  (struct EntryHead**) &mod,
+                                  (struct EntryHead *) world.map_obj_defs)
+                   || start_map(token0, str_map, &map_flags)
+                   || set_player_type(token0, str_player, token1)
+                   || set_enemy_fov(token0, str_enemyfov, token1)
+                   || set_members(token0, token1, &object_flags, &action_flags,
+                                  &map_flags, (struct MapObjDef *)mod,
+                                  (struct MapObjAct *) moa)))
         {
             parse_unknown_arg();
         }
@@ -237,7 +245,7 @@ static void test_corpse_ids()
 
 
 
-static uint8_t set_map_members(char * token0, char * token1, uint8_t * map_flags)
+static uint8_t set_map_members(char * token0, char * token1,uint8_t * map_flags)
 {
     if      (   parse_val(token0, token1, "HEIGHT", map_flags,
                           HEIGHT_SET, 'i', (char *) &world.map.size.y)
@@ -248,15 +256,22 @@ static uint8_t set_map_members(char * token0, char * token1, uint8_t * map_flags
         err_line(test, "Value must be >= 1 and <= 256.");
         return 1;
     }
-    else if (    parse_val(token0, token1, "DIST_ORTHOGONAL", map_flags,
-                           ORTH_SET, '8', (char *) &world.map.dist_orthogonal)
-             ||  parse_val(token0, token1, "DIST_DIAGONAL", map_flags,
-                           DIAG_SET, '8', (char *) &world.map.dist_diagonal))
+    return 0;
+}
+
+
+
+static uint8_t set_enemy_fov(char * token0, char * comparand, char * token1)
+{
+    if (strcmp(token0, comparand))
     {
-        err_line(0 == atoi(token1), "Value must not be zero.");
-        return 1;
+        return 0;
     }
-    return 0;
+    parsetest_int(token1, '8');
+    int test = atoi(token1) > 1;
+    err_line(test, "Value must be 0 or 1.");
+    world.enemy_fov = atoi(token1);
+    return 1;
 }