1 | /* |
1 | /* |
2 | * static char *rcsid_hiscore_c = |
2 | * static char *rcsid_hiscore_c = |
3 | * "$Id: hiscore.C,v 1.3 2006/08/30 16:30:37 root Exp $"; |
3 | * "$Id: hiscore.C,v 1.4 2006/09/03 00:18:42 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 | |
… | |
… | |
97 | * a pointer to it. |
97 | * a pointer to it. |
98 | */ |
98 | */ |
99 | |
99 | |
100 | static char *put_score(score *sc) { |
100 | static char *put_score(score *sc) { |
101 | static char buf[MAX_BUF]; |
101 | static char buf[MAX_BUF]; |
102 | #ifndef WIN32 |
|
|
103 | sprintf(buf,"%s:%s:%lld:%s:%s:%d:%d:%d",sc->name,sc->title,sc->exp,sc->killer,sc->maplevel, |
102 | sprintf(buf,"%s:%s:%lld:%s:%s:%d:%d:%d",sc->name,sc->title, (long long)sc->exp,sc->killer,sc->maplevel, |
104 | sc->maxhp,sc->maxsp,sc->maxgrace); |
103 | sc->maxhp,sc->maxsp,sc->maxgrace); |
105 | #else |
|
|
106 | sprintf(buf,"%s:%s:%I64d:%s:%s:%d:%d:%d",sc->name,sc->title,sc->exp,sc->killer,sc->maplevel, |
|
|
107 | sc->maxhp,sc->maxsp,sc->maxgrace); |
|
|
108 | #endif |
|
|
109 | return buf; |
104 | return buf; |
110 | } |
105 | } |
111 | |
106 | |
112 | /* |
107 | /* |
113 | * The oposite of put_score, get_score reads from the given buffer into |
108 | * The oposite of put_score, get_score reads from the given buffer into |
… | |
… | |
131 | strncpy(sc.title,cp,BIG_NAME); |
126 | strncpy(sc.title,cp,BIG_NAME); |
132 | sc.title[BIG_NAME - 1] = '\0'; |
127 | sc.title[BIG_NAME - 1] = '\0'; |
133 | |
128 | |
134 | if ((cp = spool(NULL, "score")) == NULL) |
129 | if ((cp = spool(NULL, "score")) == NULL) |
135 | return NULL; |
130 | return NULL; |
136 | #ifndef WIN32 |
131 | long long exp; |
137 | sscanf(cp,"%lld",&sc.exp); |
132 | sscanf(cp,"%lld", &exp); sc.exp = exp; |
138 | #else |
|
|
139 | sscanf(cp,"%I64d",&sc.exp); |
|
|
140 | #endif |
|
|
141 | |
133 | |
142 | if ((cp = spool(NULL, "killer")) == NULL) |
134 | if ((cp = spool(NULL, "killer")) == NULL) |
143 | return NULL; |
135 | return NULL; |
144 | strncpy(sc.killer, cp, BIG_NAME); |
136 | strncpy(sc.killer, cp, BIG_NAME); |
145 | sc.killer[BIG_NAME - 1] = '\0'; |
137 | sc.killer[BIG_NAME - 1] = '\0'; |
… | |
… | |
166 | static char * draw_one_high_score(score *sc) { |
158 | static char * draw_one_high_score(score *sc) { |
167 | static char retbuf[MAX_BUF]; |
159 | static char retbuf[MAX_BUF]; |
168 | |
160 | |
169 | if(!strncmp(sc->killer,"quit",MAX_NAME)) |
161 | if(!strncmp(sc->killer,"quit",MAX_NAME)) |
170 | sprintf(retbuf,"%3d %10lld %s the %s quit the game on map %s [%d][%d][%d].", |
162 | sprintf(retbuf,"%3d %10lld %s the %s quit the game on map %s [%d][%d][%d].", |
171 | sc->position,sc->exp,sc->name,sc->title,sc->maplevel,sc->maxhp,sc->maxsp, |
163 | sc->position, (long long)sc->exp,sc->name,sc->title,sc->maplevel,sc->maxhp,sc->maxsp, |
172 | sc->maxgrace); |
164 | sc->maxgrace); |
173 | else if(!strncmp(sc->killer,"left",MAX_NAME)) |
165 | else if(!strncmp(sc->killer,"left",MAX_NAME)) |
174 | sprintf(retbuf,"%3d %10lld %s the %s left the game on map %s [%d][%d][%d].", |
166 | sprintf(retbuf,"%3d %10lld %s the %s left the game on map %s [%d][%d][%d].", |
175 | sc->position,sc->exp,sc->name,sc->title,sc->maplevel,sc->maxhp,sc->maxsp, |
167 | sc->position, (long long)sc->exp,sc->name,sc->title,sc->maplevel,sc->maxhp,sc->maxsp, |
176 | sc->maxgrace); |
168 | sc->maxgrace); |
177 | else |
169 | else |
178 | sprintf(retbuf,"%3d %10lld %s the %s was killed by %s on map %s [%d][%d][%d].", |
170 | sprintf(retbuf,"%3d %10lld %s the %s was killed by %s on map %s [%d][%d][%d].", |
179 | sc->position,sc->exp,sc->name,sc->title,sc->killer,sc->maplevel, |
171 | sc->position, (long long)sc->exp,sc->name,sc->title,sc->killer,sc->maplevel, |
180 | sc->maxhp,sc->maxsp,sc->maxgrace); |
172 | sc->maxhp,sc->maxsp,sc->maxgrace); |
181 | return retbuf; |
173 | return retbuf; |
182 | } |
174 | } |
183 | /* |
175 | /* |
184 | * add_score() adds the given score-structure to the high-score list, but |
176 | * add_score() adds the given score-structure to the high-score list, but |