ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cf.schmorp.de/server/common/utils.C
(Generate patch)

Comparing cf.schmorp.de/server/common/utils.C (file contents):
Revision 1.45 by root, Sat Jan 27 02:19:36 2007 UTC vs.
Revision 1.47 by root, Wed Feb 7 02:04:46 2007 UTC

251 if (op->stats.food < 0) 251 if (op->stats.food < 0)
252 destroy = 1; 252 destroy = 1;
253 } 253 }
254 else 254 else
255 { 255 {
256 int mat = op->material; 256 int mat = op->materials;
257 257
258 if (mat & M_PAPER 258 if (mat & M_PAPER
259 || mat & M_LEATHER 259 || mat & M_LEATHER
260 || mat & M_WOOD 260 || mat & M_WOOD
261 || mat & M_ORGANIC 261 || mat & M_ORGANIC
276} 276}
277 277
278/* convert materialname to materialtype_t */ 278/* convert materialname to materialtype_t */
279 279
280materialtype_t * 280materialtype_t *
281name_to_material (const char *name) 281name_to_material (const shstr &name)
282{ 282{
283 materialtype_t *mt, *nmt; 283 for (materialtype_t *mt = materialt; mt && mt->next; mt = mt->next)
284 284 if (name == mt->name)
285 mt = NULL;
286 for (nmt = materialt; nmt != NULL && nmt->next != NULL; nmt = nmt->next)
287 {
288 if (strcmp (name, nmt->name) == 0)
289 {
290 mt = nmt;
291 break;
292 }
293 }
294 return mt; 285 return mt;
286
287 return materialt;
295} 288}
296 289
297/* when doing transmutation of objects, we have to recheck the resistances, 290/* when doing transmutation of objects, we have to recheck the resistances,
298 * as some that did not apply previously, may apply now. 291 * as some that did not apply previously, may apply now.
299 */ 292 */
348 341
349 if (nmt == NULL) 342 if (nmt == NULL)
350 { 343 {
351 lmt = NULL; 344 lmt = NULL;
352#ifndef NEW_MATERIAL_CODE 345#ifndef NEW_MATERIAL_CODE
353 for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next) 346 for (mt = materialt; mt && mt->next; mt = mt->next)
354 { 347 {
355 if (op->material & mt->material) 348 if (op->materials & mt->material)
356 { 349 {
357 lmt = mt; 350 lmt = mt;
358 break; 351 break;
359 } 352 }
360 } 353 }
361 354
362#else 355#else
363 for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next) 356 for (mt = materialt; mt && mt->next; mt = mt->next)
364 { 357 {
365 if (op->material & mt->material && rndm (1, 100) <= mt->chance && 358 if (op->materials & mt->material && rndm (1, 100) <= mt->chance &&
366 difficulty >= mt->difficulty && (op->magic >= mt->magic || mt->magic == 0)) 359 difficulty >= mt->difficulty && (op->magic >= mt->magic || mt->magic == 0))
367 { 360 {
368 lmt = mt; 361 lmt = mt;
369 if (!(op->is_weapon () || op->is_armor ())) 362 if (!(op->is_weapon () || op->is_armor ()))
370 break; 363 break;
388 { 381 {
389 op->stats.dam += lmt->damage; 382 op->stats.dam += lmt->damage;
390 if (op->stats.dam < 1) 383 if (op->stats.dam < 1)
391 op->stats.dam = 1; 384 op->stats.dam = 1;
392 } 385 }
386
393 if (op->stats.sp && op->type == BOW) 387 if (op->stats.sp && op->type == BOW)
394 op->stats.sp += lmt->sp; 388 op->stats.sp += lmt->sp;
395 if (op->stats.wc && op->is_weapon ()) 389 if (op->stats.wc && op->is_weapon ())
396 op->stats.wc += lmt->wc; 390 op->stats.wc += lmt->wc;
397 if (op->is_armor ()) 391 if (op->is_armor ())
406 op->resist[j] = 100; 400 op->resist[j] = 100;
407 if (op->resist[j] < -100) 401 if (op->resist[j] < -100)
408 op->resist[j] = -100; 402 op->resist[j] = -100;
409 } 403 }
410 } 404 }
411 op->materialname = add_string (lmt->name); 405 op->materialname = lmt->name;
412 /* dont make it unstackable if it doesn't need to be */ 406 /* dont make it unstackable if it doesn't need to be */
413 if (op->is_weapon () || op->is_armor ()) 407 if (op->is_weapon () || op->is_armor ())
414 { 408 {
415 op->weight = (op->weight * lmt->weight) / 100; 409 op->weight = (op->weight * lmt->weight) / 100;
416 op->value = (op->value * lmt->value) / 100; 410 op->value = (op->value * lmt->value) / 100;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines