ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/item.C
(Generate patch)

Comparing deliantra/server/common/item.C (file contents):
Revision 1.84 by root, Thu Apr 15 02:51:39 2010 UTC vs.
Revision 1.88 by root, Wed May 12 20:40:50 2010 UTC

202 {BUILDER, "item builder", "item builders", 0, 0}, 202 {BUILDER, "item builder", "item builders", 0, 0},
203 {MATERIAL, "building material", "building materials", 0, 0}, 203 {MATERIAL, "building material", "building materials", 0, 0},
204 {ITEM_TRANSFORMER, "item_transformer", "item_transformers", 0, 0}, 204 {ITEM_TRANSFORMER, "item_transformer", "item_transformers", 0, 0},
205}; 205};
206 206
207static const int item_types_size = sizeof (item_types) / sizeof (*item_types); 207static const int item_types_size = array_length (item_types);
208 208
209/* This curve may be too steep. But the point is that there should 209/* This curve may be too steep. But the point is that there should
210 * be tough choices - there is no real point to this if everyone can 210 * be tough choices - there is no real point to this if everyone can
211 * wear whatever they want with no worries. Perhaps having the steep 211 * wear whatever they want with no worries. Perhaps having the steep
212 * curve is good (maybe even steeper), but allowing players to 212 * curve is good (maybe even steeper), but allowing players to
214 * able to use 2-3 of the most powerful items. 214 * able to use 2-3 of the most powerful items.
215 * note that this table is only really used for program generated items - 215 * note that this table is only really used for program generated items -
216 * custom objects can use whatever they want. 216 * custom objects can use whatever they want.
217 */ 217 */
218static int enc_to_item_power[21] = { 218static int enc_to_item_power[21] = {
219 0,
219 0, 0, 1, 2, 3, 4, /* 5 */ 220 0, 1, 2, 3, 4, // 5
220 5, 7, 9, 11, 13, /* 10 */ 221 5, 7, 9, 11, 13, // 10
221 15, 18, 21, 24, 27, /* 15 */ 222 15, 18, 21, 24, 27, // 15
222 30, 35, 40, 45, 50 /* 20 */ 223 30, 35, 40, 45, 50 // 20
223}; 224};
224 225
225int 226int
226get_power_from_ench (int ench) 227get_power_from_ench (int ench)
227{ 228{
352 if (op->flag [FLAG_MAKE_INVIS ]) enc += 1; 353 if (op->flag [FLAG_MAKE_INVIS ]) enc += 1;
353 354
354 return get_power_from_ench (enc); 355 return get_power_from_ench (enc);
355} 356}
356 357
358static 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
357/* 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
358 * isn't one, returns NULL */ 375 * isn't one, returns NULL */
359const typedata * 376const typedata *
360get_typedata (int itemtype) 377get_typedata (int itemtype)
361{ 378{
362 for (int i = 0; i < item_types_size; i++) 379 return get_typedata_ (itemtype);
363 if (item_types[i].number == itemtype)
364 return &item_types[i];
365
366 return NULL;
367} 380}
368 381
369/* 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
370 * 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
371 * one return NULL */ 384 * one return NULL */
482 { 495 {
483 for (attr = 0; attr < NUM_STATS; attr++) 496 for (attr = 0; attr < NUM_STATS; attr++)
484 if ((val = op->stats.stat (attr))) 497 if ((val = op->stats.stat (attr)))
485 buf.printf ("(%s%+d)", short_stat_name[attr], val); 498 buf.printf ("(%s%+d)", short_stat_name[attr], val);
486 499
487 if (op->stats.exp) buf.printf ("(speed %+lld)", (long long)op->stats.exp); 500 if (op->stats.exp) buf.printf ("(speed %+d)", (int)op->stats.exp);
488 if (op->stats.wc) buf.printf ("(wc%+d)", op->stats.wc); 501 if (op->stats.wc) buf.printf ("(wc%+d)", op->stats.wc);
489 if (op->stats.dam) buf.printf ("(dam%+d)", op->stats.dam); 502 if (op->stats.dam) buf.printf ("(dam%+d)", op->stats.dam);
490 if (op->stats.ac) buf.printf ("(ac%+d)", op->stats.ac); 503 if (op->stats.ac) buf.printf ("(ac%+d)", op->stats.ac);
491 504
492 buf << describe_resistance (op, 0); 505 buf << describe_resistance (op, 0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines