1 | |
|
|
2 | /* |
|
|
3 | * static char *rcs_treasure_c = |
|
|
4 | * "$Id: treasure.C,v 1.16 2006/09/10 16:00:23 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)) |
… | |
… | |
259 | */ |
253 | */ |
260 | |
254 | |
261 | treasurelist * |
255 | treasurelist * |
262 | find_treasurelist (const char *name) |
256 | find_treasurelist (const char *name) |
263 | { |
257 | { |
264 | /* Special cases - randomitems of NULL is to override default. If |
258 | shstr_cmp name_ (name); |
265 | * first_treasurelist is null, it means we are on the first pass of |
259 | |
266 | * of loading archetypes, so for now, just return - second pass will |
|
|
267 | * init these values. |
|
|
268 | */ |
|
|
269 | if (!name) |
260 | if (!name_) |
270 | return 0; |
261 | return 0; |
271 | |
262 | |
272 | if (const char *tmp = shstr::find (name)) |
|
|
273 | for (treasurelist * tl = first_treasurelist; tl != 0; tl = tl->next) |
263 | for (treasurelist * tl = first_treasurelist; tl != 0; tl = tl->next) |
274 | if (tmp == tl->name) |
264 | if (name_ == tl->name) |
275 | return tl; |
265 | return tl; |
276 | |
266 | |
277 | if (first_treasurelist) |
267 | if (first_treasurelist) |
278 | LOG (llevError, "Couldn't find treasurelist %s\n", name); |
268 | LOG (llevError, "Couldn't find treasurelist %s\n", name); |
279 | |
269 | |
280 | return 0; |
270 | return 0; |
… | |
… | |
468 | |
458 | |
469 | /* 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 */ |
470 | tmp = ob->inv; |
460 | tmp = ob->inv; |
471 | if (tmp != NULL) |
461 | if (tmp != NULL) |
472 | remove_ob (tmp); |
462 | remove_ob (tmp); |
|
|
463 | |
473 | if (ob->inv) |
464 | if (ob->inv) |
474 | { |
|
|
475 | LOG (llevError, "In generate treasure, created multiple objects.\n"); |
465 | LOG (llevError, "In generate treasure, created multiple objects.\n"); |
476 | } |
466 | |
477 | free_object (ob); |
467 | free_object (ob); |
478 | return tmp; |
468 | return tmp; |
479 | } |
469 | } |
480 | |
470 | |
481 | /* |
471 | /* |
… | |
… | |
1566 | op->gen_sp_armour = (op->gen_sp_armour * (change->gen_sp_armour)) / 100; |
1556 | op->gen_sp_armour = (op->gen_sp_armour * (change->gen_sp_armour)) / 100; |
1567 | |
1557 | |
1568 | op->item_power = change->item_power; |
1558 | op->item_power = change->item_power; |
1569 | |
1559 | |
1570 | for (i = 0; i < NROFATTACKS; i++) |
1560 | for (i = 0; i < NROFATTACKS; i++) |
1571 | { |
|
|
1572 | if (change->resist[i]) |
1561 | if (change->resist[i]) |
1573 | { |
|
|
1574 | op->resist[i] += change->resist[i]; |
1562 | op->resist[i] += change->resist[i]; |
1575 | } |
|
|
1576 | } |
|
|
1577 | |
1563 | |
1578 | if (change->stats.dam) |
1564 | if (change->stats.dam) |
1579 | { |
1565 | { |
1580 | if (change->stats.dam < 0) |
1566 | if (change->stats.dam < 0) |
1581 | op->stats.dam = (-change->stats.dam); |
1567 | op->stats.dam = (-change->stats.dam); |
… | |
… | |
1859 | free_artifact (at->next); |
1845 | free_artifact (at->next); |
1860 | |
1846 | |
1861 | if (at->allowed) |
1847 | if (at->allowed) |
1862 | free_charlinks (at->allowed); |
1848 | free_charlinks (at->allowed); |
1863 | |
1849 | |
1864 | at->item->free (1); |
1850 | at->item->destroy (1); |
1865 | |
1851 | |
1866 | delete at; |
1852 | delete at; |
1867 | } |
1853 | } |
1868 | |
1854 | |
1869 | void |
1855 | void |
1870 | free_artifactlist (artifactlist * al) |
1856 | free_artifactlist (artifactlist * al) |
1871 | { |
1857 | { |
1872 | artifactlist *nextal; |
1858 | artifactlist *nextal; |
1873 | |
1859 | |
1874 | for (al = first_artifactlist; al != NULL; al = nextal) |
1860 | for (al = first_artifactlist; al; al = nextal) |
1875 | { |
1861 | { |
1876 | nextal = al->next; |
1862 | nextal = al->next; |
1877 | |
1863 | |
1878 | if (al->items) |
1864 | if (al->items) |
1879 | free_artifact (al->items); |
1865 | free_artifact (al->items); |