… | |
… | |
353 | if (op->flag [FLAG_MAKE_INVIS ]) enc += 1; |
353 | if (op->flag [FLAG_MAKE_INVIS ]) enc += 1; |
354 | |
354 | |
355 | return get_power_from_ench (enc); |
355 | return get_power_from_ench (enc); |
356 | } |
356 | } |
357 | |
357 | |
|
|
358 | static const struct get_typedata |
|
|
359 | { |
|
|
360 | const typedata *data [NUM_TYPES]; |
|
|
361 | |
|
|
362 | get_typedata () |
|
|
363 | { |
|
|
364 | for (int i = 0; i < item_types_size; i++) |
|
|
365 | data [item_types[i].number] = &item_types [i]; |
|
|
366 | } |
|
|
367 | |
|
|
368 | const typedata *operator ()(int itemtype) const |
|
|
369 | { |
|
|
370 | return data [itemtype]; |
|
|
371 | } |
|
|
372 | } get_typedata_; |
|
|
373 | |
358 | /* returns the typedata that has a number equal to itemtype, if there |
374 | /* returns the typedata that has a number equal to itemtype, if there |
359 | * isn't one, returns NULL */ |
375 | * isn't one, returns NULL */ |
360 | const typedata * |
376 | const typedata * |
361 | get_typedata (int itemtype) |
377 | get_typedata (int itemtype) |
362 | { |
378 | { |
363 | for (int i = 0; i < item_types_size; i++) |
379 | return get_typedata_ (itemtype); |
364 | if (item_types[i].number == itemtype) |
|
|
365 | return &item_types[i]; |
|
|
366 | |
|
|
367 | return NULL; |
|
|
368 | } |
380 | } |
369 | |
381 | |
370 | /* returns the typedata that has a name equal to itemtype, if there |
382 | /* returns the typedata that has a name equal to itemtype, if there |
371 | * isn't one, return the plural name that matches, if there still isn't |
383 | * isn't one, return the plural name that matches, if there still isn't |
372 | * one return NULL */ |
384 | * one return NULL */ |