read one tile from win/share/{monsters,objects,other}.txt */
| 177 | |
| 178 | /* read one tile from win/share/{monsters,objects,other}.txt */ |
| 179 | static boolean |
| 180 | read_txttile(FILE *txtfile, pixel (*pixels)[TILE_X]) |
| 181 | { |
| 182 | static int gidx = 0; |
| 183 | int ph, i = 0, j, k, reslt; |
| 184 | char buf[BUFSZ], ttype[BUFSZ], gend[BUFSZ]; |
| 185 | const char *p; |
| 186 | char *q; |
| 187 | boolean res = FALSE; |
| 188 | |
| 189 | gend[0] = '\0'; |
| 190 | reslt = 0; |
| 191 | if (get_next_line(txtfile, FALSE)) { |
| 192 | if (tile_set == MONSTER_SET) |
| 193 | reslt = sscanf(inbuf, "# %255s %d (%255[^,],%255[^)])", |
| 194 | ttype, &i, buf, gend); |
| 195 | else |
| 196 | reslt = sscanf(inbuf, "# %255s %d (%255[^)])", |
| 197 | ttype, &i, buf); |
| 198 | } |
| 199 | if (reslt <= 0) |
| 200 | goto done; |
| 201 | |
| 202 | ttype[sizeof ttype - 1] = '\0'; |
| 203 | buf[sizeof buf - 1] = '\0'; |
| 204 | |
| 205 | if (tile_set == MONSTER_SET && gend[0] == 'f') |
| 206 | gidx = 1; |
| 207 | |
| 208 | ph = strcmp(ttype, "placeholder") == 0; |
| 209 | |
| 210 | if (!ph && strcmp(ttype, "tile") != 0) |
| 211 | Fprintf(stderr, "Keyword \"%s\" unexpected for entry %d\n", ttype, i); |
| 212 | |
| 213 | /* check tile name, but not relative number, which will |
| 214 | * change when tiles are added |
| 215 | */ |
| 216 | p = tilename(tile_set, tile_set_indx, gidx); |
| 217 | if (p && (q = strstr(p, " {")) != 0) { |
| 218 | *q = '\0'; |
| 219 | } |
| 220 | if (p && strcmp(p, buf)) { |
| 221 | boolean other_mismatch = |
| 222 | (tile_set == OTHER_SET |
| 223 | && !acceptable_tilename(tile_set, tile_set_indx, buf, p)); |
| 224 | |
| 225 | if (tile_set != OTHER_SET || other_mismatch) { |
| 226 | Fprintf(stderr, "warning: for tile %d (numbered %d) of %s,\n", |
| 227 | tile_set_indx, i, text_sets[tile_set]); |
| 228 | Fprintf(stderr, "\tfound '%s' while expecting '%s'\n", buf, p); |
| 229 | } |
| 230 | } |
| 231 | tile_set_indx++; |
| 232 | |
| 233 | /* look for non-whitespace at each stage */ |
| 234 | if (!get_next_line(txtfile, TRUE)) { |
| 235 | Fprintf(stderr, "unexpected EOF\n"); |
| 236 | goto done; |
no test coverage detected