MCPcopy Create free account
hub / github.com/NetHack/NetHack / parse_condition

Function parse_condition

src/botl.c:3232–3348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3230}
3231
3232staticfn boolean
3233parse_condition(char (*s)[QBUFSZ], int sidx)
3234{
3235 int i;
3236 int coloridx = NO_COLOR;
3237 char *tmp, *how;
3238 unsigned long conditions_bitmask = 0UL;
3239 boolean result = FALSE;
3240
3241 if (!s)
3242 return FALSE;
3243
3244 /*3.6.1:
3245 OPTION=hilite_status: condition/stone+slime+foodPois/red&inverse */
3246
3247 /*
3248 * TODO?
3249 * It would be simpler to treat each condition (also hunger state
3250 * and encumbrance level) as if it were a separate field. That
3251 * way they could have either or both 'changed' temporary rule and
3252 * 'always' persistent rule and wouldn't need convoluted access to
3253 * the intended color and attributes.
3254 */
3255
3256 sidx++;
3257 if (!s[sidx][0]) {
3258 config_error_add("Missing condition(s)");
3259 return FALSE;
3260 }
3261 while (s[sidx][0]) {
3262 int sf = 0; /* subfield count */
3263 char buf[BUFSZ], **subfields;
3264
3265 tmp = s[sidx];
3266 Strcpy(buf, tmp);
3267 conditions_bitmask = str2conditionbitmask(buf);
3268
3269 if (!conditions_bitmask)
3270 return FALSE;
3271
3272 /*
3273 * We have the conditions_bitmask with bits set for
3274 * each ailment we want in a particular color and/or
3275 * attribute, but we need to assign it to an array of
3276 * bitmasks indexed by the color chosen
3277 * (0 to (CLR_MAX - 1))
3278 * and/or attributes chosen
3279 * (HL_ATTCLR_NONE to (BL_ATTCLR_MAX - 1))
3280 * We still have to parse the colors and attributes out.
3281 */
3282
3283 /* actions */
3284 sidx++;
3285 how = s[sidx];
3286 if (!how || !*how) {
3287 config_error_add("Missing color+attribute");
3288 return FALSE;
3289 }

Callers 1

parse_status_hl2Function · 0.85

Calls 5

config_error_addFunction · 0.85
str2conditionbitmaskFunction · 0.85
splitsubfieldsFunction · 0.85
match_str2attrFunction · 0.85
match_str2clrFunction · 0.85

Tested by

no test coverage detected