1 | |
1 | |
2 | /* |
2 | /* |
3 | * static char *rcs_treasure_c = |
3 | * static char *rcs_treasure_c = |
4 | * "$Id: treasure.C,v 1.1 2006/08/13 17:16:01 elmex Exp $"; |
4 | * "$Id: treasure.C,v 1.3 2006/08/28 14:05:24 root Exp $"; |
5 | */ |
5 | */ |
6 | |
6 | |
7 | /* |
7 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
8 | CrossFire, A Multiplayer game for X-windows |
9 | |
9 | |
… | |
… | |
1270 | * Builds up the lists of artifacts from the file in the libdir. |
1270 | * Builds up the lists of artifacts from the file in the libdir. |
1271 | */ |
1271 | */ |
1272 | |
1272 | |
1273 | void init_artifacts(void) { |
1273 | void init_artifacts(void) { |
1274 | static int has_been_inited=0; |
1274 | static int has_been_inited=0; |
1275 | FILE *fp; |
1275 | FILE *fp_; |
1276 | char filename[MAX_BUF], buf[HUGE_BUF], *cp, *next; |
1276 | char filename[MAX_BUF], buf[HUGE_BUF], *cp, *next; |
1277 | artifact *art=NULL; |
1277 | artifact *art=NULL; |
1278 | linked_char *tmp; |
1278 | linked_char *tmp; |
1279 | int value, comp; |
1279 | int value, comp; |
1280 | artifactlist *al; |
1280 | artifactlist *al; |
… | |
… | |
1282 | if (has_been_inited) return; |
1282 | if (has_been_inited) return; |
1283 | else has_been_inited = 1; |
1283 | else has_been_inited = 1; |
1284 | |
1284 | |
1285 | sprintf(filename, "%s/artifacts", settings.datadir); |
1285 | sprintf(filename, "%s/artifacts", settings.datadir); |
1286 | LOG(llevDebug, "Reading artifacts from %s...",filename); |
1286 | LOG(llevDebug, "Reading artifacts from %s...",filename); |
1287 | if ((fp = open_and_uncompress(filename, 0, &comp)) == NULL) { |
1287 | if ((fp_ = open_and_uncompress(filename, 0, &comp)) == NULL) { |
1288 | LOG(llevError, "Can't open %s.\n", filename); |
1288 | LOG(llevError, "Can't open %s.\n", filename); |
1289 | return; |
1289 | return; |
1290 | } |
1290 | } |
|
|
1291 | |
|
|
1292 | object_thawer fp (fp_); |
1291 | |
1293 | |
1292 | while (fgets(buf, HUGE_BUF, fp)!=NULL) { |
1294 | while (fgets(buf, HUGE_BUF, fp)!=NULL) { |
1293 | if (*buf=='#') continue; |
1295 | if (*buf=='#') continue; |
1294 | if((cp=strchr(buf,'\n'))!=NULL) |
1296 | if((cp=strchr(buf,'\n'))!=NULL) |
1295 | *cp='\0'; |
1297 | *cp='\0'; |