1 | /* |
1 | /* |
2 | * static char *rcsid_hiscore_c = |
2 | * static char *rcsid_hiscore_c = |
3 | * "$Id: hiscore.C,v 1.2 2006/08/29 08:01:37 root Exp $"; |
3 | * "$Id: hiscore.C,v 1.3 2006/08/30 16:30:37 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
218 | if(old_score.position!=-1&&old_score.exp>=new_score->exp) |
218 | if(old_score.position!=-1&&old_score.exp>=new_score->exp) |
219 | return &old_score; /* Did not beat old score */ |
219 | return &old_score; /* Did not beat old score */ |
220 | if(!flag&&nrofscores<HIGHSCORE_LENGTH) |
220 | if(!flag&&nrofscores<HIGHSCORE_LENGTH) |
221 | copy_score(new_score,&pscore[nrofscores++]); |
221 | copy_score(new_score,&pscore[nrofscores++]); |
222 | if((fp=fopen(filename,"w"))==NULL) { |
222 | if((fp=fopen(filename,"w"))==NULL) { |
223 | LOG(llevError, "Cannot write to highscore file %s: %s\n", filename, strerror_local(errno)); |
223 | LOG(llevError, "Cannot write to highscore file %s: %s\n", filename, strerror(errno)); |
224 | return NULL; |
224 | return NULL; |
225 | } |
225 | } |
226 | for(i=0;i<nrofscores;i++) { |
226 | for(i=0;i<nrofscores;i++) { |
227 | bp=put_score(&pscore[i]); |
227 | bp=put_score(&pscore[i]); |
228 | fprintf(fp,"%s\n",bp); |
228 | fprintf(fp,"%s\n",bp); |
… | |
… | |
330 | int i=0,j=0,comp; |
330 | int i=0,j=0,comp; |
331 | score *sc; |
331 | score *sc; |
332 | |
332 | |
333 | sprintf(buf,"%s/%s",settings.localdir,HIGHSCORE); |
333 | sprintf(buf,"%s/%s",settings.localdir,HIGHSCORE); |
334 | if((fp=open_and_uncompress(buf,0,&comp))==NULL) { |
334 | if((fp=open_and_uncompress(buf,0,&comp))==NULL) { |
335 | LOG(llevError, "Cannot open highscore file %s: %s\n", buf, strerror_local(errno)); |
335 | LOG(llevError, "Cannot open highscore file %s: %s\n", buf, strerror(errno)); |
336 | if(op!=NULL) |
336 | if(op!=NULL) |
337 | new_draw_info(NDI_UNIQUE, 0,op,"There is no highscore file."); |
337 | new_draw_info(NDI_UNIQUE, 0,op,"There is no highscore file."); |
338 | return; |
338 | return; |
339 | } |
339 | } |
340 | if(op != NULL) |
340 | if(op != NULL) |