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.2 by root, Sun Aug 27 16:15:11 2006 UTC vs.
Revision 1.3 by root, Mon Aug 28 14:05:24 2006 UTC

1 1
2/* 2/*
3 * static char *rcs_treasure_c = 3 * static char *rcs_treasure_c =
4 * "$Id: treasure.C,v 1.2 2006/08/27 16:15:11 root 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
1273void init_artifacts(void) { 1273void 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;
1281 1281
1282 object_thawer thawer;
1283
1284 if (has_been_inited) return; 1282 if (has_been_inited) return;
1285 else has_been_inited = 1; 1283 else has_been_inited = 1;
1286 1284
1287 sprintf(filename, "%s/artifacts", settings.datadir); 1285 sprintf(filename, "%s/artifacts", settings.datadir);
1288 LOG(llevDebug, "Reading artifacts from %s...",filename); 1286 LOG(llevDebug, "Reading artifacts from %s...",filename);
1289 if ((fp = open_and_uncompress(filename, 0, &comp)) == NULL) { 1287 if ((fp_ = open_and_uncompress(filename, 0, &comp)) == NULL) {
1290 LOG(llevError, "Can't open %s.\n", filename); 1288 LOG(llevError, "Can't open %s.\n", filename);
1291 return; 1289 return;
1292 } 1290 }
1291
1292 object_thawer fp (fp_);
1293 1293
1294 while (fgets(buf, HUGE_BUF, fp)!=NULL) { 1294 while (fgets(buf, HUGE_BUF, fp)!=NULL) {
1295 if (*buf=='#') continue; 1295 if (*buf=='#') continue;
1296 if((cp=strchr(buf,'\n'))!=NULL) 1296 if((cp=strchr(buf,'\n'))!=NULL)
1297 *cp='\0'; 1297 *cp='\0';
1323 else if (sscanf(cp, "difficulty %d", &value)) 1323 else if (sscanf(cp, "difficulty %d", &value))
1324 art->difficulty = (uint8) value; 1324 art->difficulty = (uint8) value;
1325 else if (!strncmp(cp, "Object",6)) { 1325 else if (!strncmp(cp, "Object",6)) {
1326 art->item = (object *) calloc(1, sizeof(object)); 1326 art->item = (object *) calloc(1, sizeof(object));
1327 reset_object(art->item); 1327 reset_object(art->item);
1328 if (!load_object(fp, thawer, art->item,LO_LINEMODE,0)) 1328 if (!load_object(fp, art->item,LO_LINEMODE,0))
1329 LOG(llevError,"Init_Artifacts: Could not load object.\n"); 1329 LOG(llevError,"Init_Artifacts: Could not load object.\n");
1330 art->item->name = add_string((strchr(cp, ' ')+1)); 1330 art->item->name = add_string((strchr(cp, ' ')+1));
1331 al=find_artifactlist(art->item->type); 1331 al=find_artifactlist(art->item->type);
1332 if (al==NULL) { 1332 if (al==NULL) {
1333 al = get_empty_artifactlist(); 1333 al = get_empty_artifactlist();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines