… | |
… | |
76 | |
76 | |
77 | warn_archetypes = prev_warn; |
77 | warn_archetypes = prev_warn; |
78 | } |
78 | } |
79 | |
79 | |
80 | /* |
80 | /* |
81 | * Searches for the given treasurelist in the globally linked list |
81 | * Searches for the given treasurelist |
82 | * of treasurelists which has been built by load_treasures(). |
|
|
83 | */ |
82 | */ |
84 | treasurelist * |
83 | treasurelist * |
85 | treasurelist::find (const char *name) |
84 | treasurelist::find (const char *name) |
86 | { |
85 | { |
87 | if (!name) |
86 | if (!name) |
88 | return 0; |
87 | return 0; |
89 | |
88 | |
90 | AUTODECL (i, tl_map.find (name)); |
89 | auto (i, tl_map.find (name)); |
91 | |
90 | |
92 | if (i == tl_map.end ()) |
91 | if (i == tl_map.end ()) |
93 | return 0; |
92 | return 0; |
94 | |
93 | |
95 | return i->second; |
94 | return i->second; |
… | |
… | |
125 | if (tl->items) |
124 | if (tl->items) |
126 | { |
125 | { |
127 | free_treasurestruct (tl->items); |
126 | free_treasurestruct (tl->items); |
128 | tl->items = 0; |
127 | tl->items = 0; |
129 | } |
128 | } |
|
|
129 | |
|
|
130 | tl->total_chance = 0; |
130 | } |
131 | } |
131 | |
132 | |
132 | /* |
133 | /* |
133 | * Reads the lib/treasure file from disk, and parses the contents |
134 | * Reads the lib/treasure file from disk, and parses the contents |
134 | * into an internal treasure structure (very linked lists) |
135 | * into an internal treasure structure (very linked lists) |
… | |
… | |
141 | |
142 | |
142 | nroftreasures++; |
143 | nroftreasures++; |
143 | |
144 | |
144 | for (;;) |
145 | for (;;) |
145 | { |
146 | { |
146 | coroapi::cede_every (10); |
147 | coroapi::cede_to_tick_every (10); |
147 | |
148 | |
148 | f.next (); |
149 | f.next (); |
149 | |
150 | |
150 | switch (f.kw) |
151 | switch (f.kw) |
151 | { |
152 | { |
… | |
… | |
205 | /* |
206 | /* |
206 | * Opens LIBDIR/treasure and reads all treasure-declarations from it. |
207 | * Opens LIBDIR/treasure and reads all treasure-declarations from it. |
207 | * Each treasure is parsed with the help of load_treasure(). |
208 | * Each treasure is parsed with the help of load_treasure(). |
208 | */ |
209 | */ |
209 | bool |
210 | bool |
210 | load_treasures () |
211 | load_treasure_file (const char *filename) |
211 | { |
212 | { |
212 | treasure *t; |
213 | treasure *t; |
213 | int comp, line = 0; |
214 | int comp, line = 0; |
214 | |
|
|
215 | char filename[MAX_BUF]; |
|
|
216 | sprintf (filename, "%s/%s", settings.datadir, settings.treasures); |
|
|
217 | |
215 | |
218 | object_thawer f (filename); |
216 | object_thawer f (filename); |
219 | |
217 | |
220 | if (!f) |
218 | if (!f) |
221 | { |
219 | { |