… | |
… | |
192 | //-GPL |
192 | //-GPL |
193 | |
193 | |
194 | void |
194 | void |
195 | load_materials () |
195 | load_materials () |
196 | { |
196 | { |
197 | char filename[MAX_BUF]; |
|
|
198 | |
|
|
199 | sprintf (filename, "%s/materials", settings.datadir); |
|
|
200 | LOG (llevDebug, "Reading material type data from %s...\n", filename); |
|
|
201 | |
|
|
202 | //TODO: somehow free old materials, or update them in-place |
197 | //TODO: somehow free old materials, or update them in-place |
203 | // currently we effectively leak them. |
198 | // currently we effectively leak them. |
204 | material_null.next = 0; materialt = &material_null; |
199 | material_null.next = 0; materialt = &material_null; |
205 | |
200 | |
206 | object_thawer thawer (filename); |
201 | object_thawer thawer (settings.datadir, "materials"); |
207 | |
202 | |
208 | if (!thawer) |
203 | if (!thawer) |
209 | { |
204 | { |
210 | LOG (llevError, "Cannot open %s for reading\n", filename); |
205 | LOG (llevError, "Cannot open %s for reading\n", thawer.name); |
211 | goto done; |
206 | goto done; |
212 | } |
207 | } |
213 | |
208 | |
214 | while (thawer.kw != KW_name) |
209 | while (thawer.kw != KW_name) |
215 | { |
210 | { |
… | |
… | |
298 | |
293 | |
299 | case KW_EOF: |
294 | case KW_EOF: |
300 | goto done; |
295 | goto done; |
301 | |
296 | |
302 | default: |
297 | default: |
303 | if (!thawer.parse_error ("materials file", "materials")) |
298 | if (!thawer.parse_error ("materials file")) |
304 | goto done; |
299 | goto done; |
305 | break; |
300 | break; |
306 | } |
301 | } |
307 | |
302 | |
308 | thawer.next (); |
303 | thawer.next (); |