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.17 by root, Tue Sep 12 18:15:34 2006 UTC vs.
Revision 1.23 by root, Tue Dec 12 20:53:02 2006 UTC

1
2/*
3 * static char *rcs_treasure_c =
4 * "$Id: treasure.C,v 1.17 2006/09/12 18:15:34 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.
58{ 52{
59 int prev_warn = warn_archetypes; 53 int prev_warn = warn_archetypes;
60 54
61 warn_archetypes = 1; 55 warn_archetypes = 1;
62 if (ring_arch == NULL) 56 if (ring_arch == NULL)
63 ring_arch = find_archetype ("ring"); 57 ring_arch = archetype::find ("ring");
64 if (amulet_arch == NULL) 58 if (amulet_arch == NULL)
65 amulet_arch = find_archetype ("amulet"); 59 amulet_arch = archetype::find ("amulet");
66 if (staff_arch == NULL) 60 if (staff_arch == NULL)
67 staff_arch = find_archetype ("staff"); 61 staff_arch = archetype::find ("staff");
68 if (crown_arch == NULL) 62 if (crown_arch == NULL)
69 crown_arch = find_archetype ("crown"); 63 crown_arch = archetype::find ("crown");
70 warn_archetypes = prev_warn; 64 warn_archetypes = prev_warn;
71} 65}
72 66
73/* 67/*
74 * Allocate and return the pointer to an empty treasurelist structure. 68 * Allocate and return the pointer to an empty treasurelist structure.
119 while (isspace (*cp)) /* Skip blanks */ 113 while (isspace (*cp)) /* Skip blanks */
120 cp++; 114 cp++;
121 115
122 if (sscanf (cp, "arch %s", variable)) 116 if (sscanf (cp, "arch %s", variable))
123 { 117 {
124 if ((t->item = find_archetype (variable)) == NULL) 118 if ((t->item = archetype::find (variable)) == NULL)
125 LOG (llevError, "Treasure lacks archetype: %s\n", variable); 119 LOG (llevError, "Treasure lacks archetype: %s\n", variable);
126 } 120 }
127 else if (sscanf (cp, "list %s", variable)) 121 else if (sscanf (cp, "list %s", variable))
128 t->name = variable; 122 t->name = variable;
129 else if (sscanf (cp, "change_name %s", variable)) 123 else if (sscanf (cp, "change_name %s", variable))
463 create_treasure (t, ob, 0, difficulty, 0); 457 create_treasure (t, ob, 0, difficulty, 0);
464 458
465 /* Don't want to free the object we are about to return */ 459 /* Don't want to free the object we are about to return */
466 tmp = ob->inv; 460 tmp = ob->inv;
467 if (tmp != NULL) 461 if (tmp != NULL)
468 remove_ob (tmp); 462 tmp->remove ();
463
469 if (ob->inv) 464 if (ob->inv)
470 {
471 LOG (llevError, "In generate treasure, created multiple objects.\n"); 465 LOG (llevError, "In generate treasure, created multiple objects.\n");
472 } 466
473 free_object (ob); 467 ob->destroy (0);
474 return tmp; 468 return tmp;
475} 469}
476 470
477/* 471/*
478 * This is a new way of calculating the chance for an item to have 472 * This is a new way of calculating the chance for an item to have
855 } 849 }
856 850
857 if (difficulty < 1) 851 if (difficulty < 1)
858 difficulty = 1; 852 difficulty = 1;
859 853
854 if (INVOKE_OBJECT (ADD_BONUS, op,
855 ARG_OBJECT (creator != op ? creator : 0),
856 ARG_INT (difficulty), ARG_INT (max_magic),
857 ARG_INT (flags)))
858 return;
859
860 if (!(flags & GT_MINIMAL)) 860 if (!(flags & GT_MINIMAL))
861 { 861 {
862 if (op->arch == crown_arch) 862 if (op->arch == crown_arch)
863 { 863 {
864 set_magic (difficulty, op, max_magic, flags); 864 set_magic (difficulty, op, max_magic, flags);
999 op->value *= 5; /* Since it's not just decoration */ 999 op->value *= 5; /* Since it's not just decoration */
1000 1000
1001 case RING: 1001 case RING:
1002 if (op->arch == NULL) 1002 if (op->arch == NULL)
1003 { 1003 {
1004 remove_ob (op); 1004 op->remove ();
1005 free_object (op); 1005 op->destroy (0);
1006 op = NULL; 1006 op = NULL;
1007 break; 1007 break;
1008 } 1008 }
1009 1009
1010 if (op->arch != ring_arch && op->arch != amulet_arch) /* It's a special artifact! */ 1010 if (op->arch != ring_arch && op->arch != amulet_arch) /* It's a special artifact! */
1513 1513
1514 /* Remove any spells this object currently has in it */ 1514 /* Remove any spells this object currently has in it */
1515 while (op->inv) 1515 while (op->inv)
1516 { 1516 {
1517 tmp_obj = op->inv; 1517 tmp_obj = op->inv;
1518 remove_ob (tmp_obj); 1518 tmp_obj->remove ();
1519 free_object (tmp_obj); 1519 tmp_obj->destroy (0);
1520 } 1520 }
1521 1521
1522 tmp_obj = arch_to_object (change->other_arch); 1522 tmp_obj = arch_to_object (change->other_arch);
1523 insert_ob_in_ob (tmp_obj, op); 1523 insert_ob_in_ob (tmp_obj, op);
1524 } 1524 }
1562 op->gen_sp_armour = (op->gen_sp_armour * (change->gen_sp_armour)) / 100; 1562 op->gen_sp_armour = (op->gen_sp_armour * (change->gen_sp_armour)) / 100;
1563 1563
1564 op->item_power = change->item_power; 1564 op->item_power = change->item_power;
1565 1565
1566 for (i = 0; i < NROFATTACKS; i++) 1566 for (i = 0; i < NROFATTACKS; i++)
1567 {
1568 if (change->resist[i]) 1567 if (change->resist[i])
1569 {
1570 op->resist[i] += change->resist[i]; 1568 op->resist[i] += change->resist[i];
1571 }
1572 }
1573 1569
1574 if (change->stats.dam) 1570 if (change->stats.dam)
1575 { 1571 {
1576 if (change->stats.dam < 0) 1572 if (change->stats.dam < 0)
1577 op->stats.dam = (-change->stats.dam); 1573 op->stats.dam = (-change->stats.dam);
1855 free_artifact (at->next); 1851 free_artifact (at->next);
1856 1852
1857 if (at->allowed) 1853 if (at->allowed)
1858 free_charlinks (at->allowed); 1854 free_charlinks (at->allowed);
1859 1855
1860 at->item->free (1); 1856 at->item->destroy (1);
1861 1857
1862 delete at; 1858 delete at;
1863} 1859}
1864 1860
1865void 1861void
1866free_artifactlist (artifactlist * al) 1862free_artifactlist (artifactlist * al)
1867{ 1863{
1868 artifactlist *nextal; 1864 artifactlist *nextal;
1869 1865
1870 for (al = first_artifactlist; al != NULL; al = nextal) 1866 for (al = first_artifactlist; al; al = nextal)
1871 { 1867 {
1872 nextal = al->next; 1868 nextal = al->next;
1873 1869
1874 if (al->items) 1870 if (al->items)
1875 free_artifact (al->items); 1871 free_artifact (al->items);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines