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.18 by root, Thu Sep 14 21:16:11 2006 UTC vs.
Revision 1.25 by root, Tue Dec 12 22:37:05 2006 UTC

1
2/*
3 * static char *rcs_treasure_c =
4 * "$Id: treasure.C,v 1.18 2006/09/14 21:16:11 root Exp $";
5 */
6
7/* 1/*
8 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
9 3
10 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
11 Copyright (C) 1992 Frank Tore Johansen 5 Copyright (C) 1992 Frank Tore Johansen
22 16
23 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 20
27 The authors can be reached via e-mail at crossfire-devel@real-time.com 21 The authors can be reached via e-mail at <crossfire@schmorp.de>
28*/ 22*/
29 23
30#define ALLOWED_COMBINATION 24#define ALLOWED_COMBINATION
31 25
32/* TREASURE_DEBUG does some checking on the treasurelists after loading. 26/* TREASURE_DEBUG does some checking on the treasurelists after loading.
454 * it instead takes a treasurelist. It is really just a wrapper around 448 * it instead takes a treasurelist. It is really just a wrapper around
455 * create_treasure. We create a dummy object that the treasure gets 449 * create_treasure. We create a dummy object that the treasure gets
456 * inserted into, and then return that treausre 450 * inserted into, and then return that treausre
457 */ 451 */
458object * 452object *
459generate_treasure (treasurelist * t, int difficulty) 453generate_treasure (treasurelist *t, int difficulty)
460{ 454{
455 difficulty = clamp (difficulty, 1, settings.max_level);
456
461 object *ob = get_object (), *tmp; 457 object *ob = object::create (), *tmp;
462 458
463 create_treasure (t, ob, 0, difficulty, 0); 459 create_treasure (t, ob, 0, difficulty, 0);
464 460
465 /* Don't want to free the object we are about to return */ 461 /* Don't want to free the object we are about to return */
466 tmp = ob->inv; 462 tmp = ob->inv;
467 if (tmp != NULL) 463 if (tmp != NULL)
468 remove_ob (tmp); 464 tmp->remove ();
465
469 if (ob->inv) 466 if (ob->inv)
470 {
471 LOG (llevError, "In generate treasure, created multiple objects.\n"); 467 LOG (llevError, "In generate treasure, created multiple objects.\n");
472 } 468
473 free_object (ob); 469 ob->destroy ();
474 return tmp; 470 return tmp;
475} 471}
476 472
477/* 473/*
478 * This is a new way of calculating the chance for an item to have 474 * This is a new way of calculating the chance for an item to have
855 } 851 }
856 852
857 if (difficulty < 1) 853 if (difficulty < 1)
858 difficulty = 1; 854 difficulty = 1;
859 855
856 if (INVOKE_OBJECT (ADD_BONUS, op,
857 ARG_OBJECT (creator != op ? creator : 0),
858 ARG_INT (difficulty), ARG_INT (max_magic),
859 ARG_INT (flags)))
860 return;
861
860 if (!(flags & GT_MINIMAL)) 862 if (!(flags & GT_MINIMAL))
861 { 863 {
862 if (op->arch == crown_arch) 864 if (op->arch == crown_arch)
863 { 865 {
864 set_magic (difficulty, op, max_magic, flags); 866 set_magic (difficulty, op, max_magic, flags);
999 op->value *= 5; /* Since it's not just decoration */ 1001 op->value *= 5; /* Since it's not just decoration */
1000 1002
1001 case RING: 1003 case RING:
1002 if (op->arch == NULL) 1004 if (op->arch == NULL)
1003 { 1005 {
1004 remove_ob (op); 1006 op->destroy ();
1005 free_object (op);
1006 op = NULL; 1007 op = 0;
1007 break; 1008 break;
1008 } 1009 }
1009 1010
1010 if (op->arch != ring_arch && op->arch != amulet_arch) /* It's a special artifact! */ 1011 if (op->arch != ring_arch && op->arch != amulet_arch) /* It's a special artifact! */
1011 break; 1012 break;
1390 art->chance = (uint16) value; 1391 art->chance = (uint16) value;
1391 else if (sscanf (cp, "difficulty %d", &value)) 1392 else if (sscanf (cp, "difficulty %d", &value))
1392 art->difficulty = (uint8) value; 1393 art->difficulty = (uint8) value;
1393 else if (!strncmp (cp, "Object", 6)) 1394 else if (!strncmp (cp, "Object", 6))
1394 { 1395 {
1395 art->item = get_object (); 1396 art->item = object::create ();
1396 1397
1397 if (!load_object (thawer, art->item, 0)) 1398 if (!load_object (thawer, art->item, 0))
1398 LOG (llevError, "Init_Artifacts: Could not load object.\n"); 1399 LOG (llevError, "Init_Artifacts: Could not load object.\n");
1399 1400
1400 art->item->name = strchr (cp, ' ') + 1; 1401 art->item->name = strchr (cp, ' ') + 1;
1511 { 1512 {
1512 object *tmp_obj; 1513 object *tmp_obj;
1513 1514
1514 /* Remove any spells this object currently has in it */ 1515 /* Remove any spells this object currently has in it */
1515 while (op->inv) 1516 while (op->inv)
1516 { 1517 op->inv->destroy ();
1517 tmp_obj = op->inv;
1518 remove_ob (tmp_obj);
1519 free_object (tmp_obj);
1520 }
1521 1518
1522 tmp_obj = arch_to_object (change->other_arch); 1519 tmp_obj = arch_to_object (change->other_arch);
1523 insert_ob_in_ob (tmp_obj, op); 1520 insert_ob_in_ob (tmp_obj, op);
1524 } 1521 }
1525 /* No harm setting this for potions/horns */ 1522 /* No harm setting this for potions/horns */
1562 op->gen_sp_armour = (op->gen_sp_armour * (change->gen_sp_armour)) / 100; 1559 op->gen_sp_armour = (op->gen_sp_armour * (change->gen_sp_armour)) / 100;
1563 1560
1564 op->item_power = change->item_power; 1561 op->item_power = change->item_power;
1565 1562
1566 for (i = 0; i < NROFATTACKS; i++) 1563 for (i = 0; i < NROFATTACKS; i++)
1567 {
1568 if (change->resist[i]) 1564 if (change->resist[i])
1569 {
1570 op->resist[i] += change->resist[i]; 1565 op->resist[i] += change->resist[i];
1571 }
1572 }
1573 1566
1574 if (change->stats.dam) 1567 if (change->stats.dam)
1575 { 1568 {
1576 if (change->stats.dam < 0) 1569 if (change->stats.dam < 0)
1577 op->stats.dam = (-change->stats.dam); 1570 op->stats.dam = (-change->stats.dam);
1855 free_artifact (at->next); 1848 free_artifact (at->next);
1856 1849
1857 if (at->allowed) 1850 if (at->allowed)
1858 free_charlinks (at->allowed); 1851 free_charlinks (at->allowed);
1859 1852
1860 at->item->free (1); 1853 at->item->destroy (1);
1861 1854
1862 delete at; 1855 delete at;
1863} 1856}
1864 1857
1865void 1858void
1866free_artifactlist (artifactlist * al) 1859free_artifactlist (artifactlist * al)
1867{ 1860{
1868 artifactlist *nextal; 1861 artifactlist *nextal;
1869 1862
1870 for (al = first_artifactlist; al != NULL; al = nextal) 1863 for (al = first_artifactlist; al; al = nextal)
1871 { 1864 {
1872 nextal = al->next; 1865 nextal = al->next;
1873 1866
1874 if (al->items) 1867 if (al->items)
1875 free_artifact (al->items); 1868 free_artifact (al->items);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines