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

Comparing deliantra/server/common/treasure.C (file contents):
Revision 1.74 by root, Mon Apr 21 23:35:24 2008 UTC vs.
Revision 1.84 by root, Thu Jan 1 11:41:17 2009 UTC

45typedef std::tr1::unordered_map< 45typedef std::tr1::unordered_map<
46 const char *, 46 const char *,
47 treasurelist *, 47 treasurelist *,
48 str_hash, 48 str_hash,
49 str_equal, 49 str_equal,
50 slice_allocator< std::pair<const char *const, treasurelist *> >, 50 slice_allocator< std::pair<const char *const, treasurelist *> >
51 true
52> tl_map_t; 51> tl_map_t;
53 52
54static tl_map_t tl_map; 53static tl_map_t tl_map;
55 54
56/* 55/*
255 return; 254 return;
256 } 255 }
257 256
258 op->expand_tail (); 257 op->expand_tail ();
259 258
260 if (op->blocked (creator->map, creator->x, creator->y)) 259 if (!creator->is_on_map () || op->blocked (creator->map, creator->x, creator->y))
261 op->destroy (); 260 op->destroy ();
262 else 261 else
263 { 262 {
264 SET_FLAG (op, FLAG_OBJ_ORIGINAL); 263 SET_FLAG (op, FLAG_OBJ_ORIGINAL);
265 op->insert_at (creator, creator, INS_NO_MERGE | INS_NO_WALK_ON); 264 op->insert_at (creator, creator, INS_NO_MERGE | INS_NO_WALK_ON);
269 { 268 {
270 op = creator->insert (op); 269 op = creator->insert (op);
271 270
272 if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) 271 if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER))
273 monster_check_apply (creator, op); 272 monster_check_apply (creator, op);
274
275 if (flags & GT_UPDATE_INV)
276 if (object *tmp = creator->in_player ())
277 esrv_send_item (tmp, op);
278 } 273 }
279} 274}
280 275
281/* if there are change_xxx commands in the treasure, we include the changes 276/* if there are change_xxx commands in the treasure, we include the changes
282 * in the generated object 277 * in the generated object
446 441
447 if (ob->inv) 442 if (ob->inv)
448 LOG (llevError, "In generate treasure, created multiple objects.\n"); 443 LOG (llevError, "In generate treasure, created multiple objects.\n");
449 444
450 ob->destroy (); 445 ob->destroy ();
446
451 return tmp; 447 return tmp;
452} 448}
453 449
454/* 450/*
455 * This is a new way of calculating the chance for an item to have 451 * This is a new way of calculating the chance for an item to have
582 if (op->type == ARMOUR) 578 if (op->type == ARMOUR)
583 ARMOUR_SPEED (op) = (ARMOUR_SPEED (op->arch) * (100 + magic * 10)) / 100; 579 ARMOUR_SPEED (op) = (ARMOUR_SPEED (op->arch) * (100 + magic * 10)) / 100;
584 580
585 if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ 581 if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */
586 magic = (-magic); 582 magic = (-magic);
583
587 op->weight = (op->arch->weight * (100 - magic * 10)) / 100; 584 op->weight = (op->arch->weight * (100 - magic * 10)) / 100;
588 } 585 }
589 else 586 else
590 { 587 {
591 if (op->type == ARMOUR) 588 if (op->type == ARMOUR)
592 ARMOUR_SPEED (op) = (ARMOUR_SPEED (op) * (100 + magic * 10)) / 100; 589 ARMOUR_SPEED (op) = (ARMOUR_SPEED (op) * (100 + magic * 10)) / 100;
590
593 if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ 591 if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */
594 magic = (-magic); 592 magic = (-magic);
593
595 op->weight = (op->weight * (100 - magic * 10)) / 100; 594 op->weight = (op->weight * (100 - magic * 10)) / 100;
596 } 595 }
597} 596}
598 597
599/* 598/*
967 case AMULET: 966 case AMULET:
968 if (IS_ARCH (op->arch, amulet)) 967 if (IS_ARCH (op->arch, amulet))
969 op->value *= 5; /* Since it's not just decoration */ 968 op->value *= 5; /* Since it's not just decoration */
970 969
971 case RING: 970 case RING:
972 if (!op->arch) // wtf? schmorp
973 {
974 op->destroy ();
975 op = 0;
976 break;
977 }
978
979 if (!IS_ARCH (op->arch, ring) && !IS_ARCH (op->arch, amulet)) /* It's a special artifact! */ 971 if (!IS_ARCH (op->arch, ring) && !IS_ARCH (op->arch, amulet)) /* It's a special artifact! */
980 break; 972 break;
981 973
982 if (!(flags & GT_ONLY_GOOD) && !(rndm (3))) 974 if (!(flags & GT_ONLY_GOOD) && !(rndm (3)))
983 SET_FLAG (op, FLAG_CURSED); 975 SET_FLAG (op, FLAG_CURSED);
1355 * to cast. So convert that to into a spell and put it into 1347 * to cast. So convert that to into a spell and put it into
1356 * this object. 1348 * this object.
1357 */ 1349 */
1358 if (op->type == HORN || op->type == POTION) 1350 if (op->type == HORN || op->type == POTION)
1359 { 1351 {
1360 object *tmp_obj;
1361
1362 /* Remove any spells this object currently has in it */ 1352 /* Remove any spells this object currently has in it */
1363 while (op->inv)
1364 op->inv->destroy (); 1353 op->destroy_inv (false);
1365 1354
1366 tmp_obj = arch_to_object (change->other_arch); 1355 object *tmp = arch_to_object (change->other_arch);
1367 insert_ob_in_ob (tmp_obj, op); 1356 insert_ob_in_ob (tmp, op);
1368 } 1357 }
1369 /* No harm setting this for potions/horns */ 1358 /* No harm setting this for potions/horns */
1370 op->other_arch = change->other_arch; 1359 op->other_arch = change->other_arch;
1371 } 1360 }
1372 1361
1577#if 1 1566#if 1
1578 LOG (llevError, "Got null entry and non zero roll in generate_artifact, type %d\n", op->type); 1567 LOG (llevError, "Got null entry and non zero roll in generate_artifact, type %d\n", op->type);
1579#endif 1568#endif
1580 return; 1569 return;
1581 } 1570 }
1582 if (!strcmp (art->item->name, "NONE")) 1571
1572 if (art->item->name == shstr_NONE)
1583 return; 1573 return;
1574
1584 if (FABS (op->magic) < art->item->magic) 1575 if (fabs (op->magic) < art->item->magic)
1585 continue; /* Not magic enough to be this item */ 1576 continue; /* Not magic enough to be this item */
1586 1577
1587 /* Map difficulty not high enough */ 1578 /* Map difficulty not high enough */
1588 if (difficulty < art->difficulty) 1579 if (difficulty < art->difficulty)
1589 continue; 1580 continue;
1640 item->level = donor->level; 1631 item->level = donor->level;
1641 1632
1642 /* if donor has some attacktypes, the flesh is poisonous */ 1633 /* if donor has some attacktypes, the flesh is poisonous */
1643 if (donor->attacktype & AT_POISON) 1634 if (donor->attacktype & AT_POISON)
1644 item->type = POISON; 1635 item->type = POISON;
1636
1645 if (donor->attacktype & AT_ACID) 1637 if (donor->attacktype & AT_ACID)
1646 item->stats.hp = -1 * item->stats.food; 1638 item->stats.hp = -1 * item->stats.food;
1639
1647 SET_FLAG (item, FLAG_NO_STEAL); 1640 SET_FLAG (item, FLAG_NO_STEAL);
1648 } 1641 }
1649} 1642}
1650 1643
1651/* special_potion() - so that old potion code is still done right. */ 1644/* special_potion() - so that old potion code is still done right. */
1688free_artifact (artifact *at) 1681free_artifact (artifact *at)
1689{ 1682{
1690 if (at->next) free_artifact (at->next); 1683 if (at->next) free_artifact (at->next);
1691 if (at->allowed) free_charlinks (at->allowed); 1684 if (at->allowed) free_charlinks (at->allowed);
1692 1685
1693 at->item->destroy (1); 1686 at->item->destroy ();
1694 1687
1695 sfree (at); 1688 sfree (at);
1696} 1689}
1697 1690
1698void 1691void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines