ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/hiscore.C
(Generate patch)

Comparing deliantra/server/server/hiscore.C (file contents):
Revision 1.6 by root, Tue Sep 12 18:17:34 2006 UTC vs.
Revision 1.7 by root, Tue Sep 12 19:20:08 2006 UTC

82 */ 82 */
83 83
84static void 84static void
85copy_score (score *sc1, score *sc2) 85copy_score (score *sc1, score *sc2)
86{ 86{
87 strncpy (sc2->name, sc1->name, BIG_NAME); 87 assign (sc2->name , sc1->name);
88 sc2->name[BIG_NAME - 1] = '\0'; 88 assign (sc2->title , sc1->title);
89 strncpy (sc2->title, sc1->title, BIG_NAME);
90 sc2->title[BIG_NAME - 1] = '\0';
91 strncpy (sc2->killer, sc1->killer, BIG_NAME); 89 assign (sc2->killer , sc1->killer);
92 sc2->killer[BIG_NAME - 1] = '\0'; 90 assign (sc2->maplevel, sc1->maplevel);
93 sc2->exp = sc1->exp; 91 sc2->exp = sc1->exp;
94 strcpy (sc2->maplevel, sc1->maplevel);
95 sc2->maxhp = sc1->maxhp; 92 sc2->maxhp = sc1->maxhp;
96 sc2->maxsp = sc1->maxsp; 93 sc2->maxsp = sc1->maxsp;
97 sc2->maxgrace = sc1->maxgrace; 94 sc2->maxgrace = sc1->maxgrace;
98} 95}
99 96
125 122
126 if ((cp = strchr (bp, '\n')) != NULL) 123 if ((cp = strchr (bp, '\n')) != NULL)
127 *cp = '\0'; 124 *cp = '\0';
128 125
129 if ((cp = spool (bp, "name")) == NULL) 126 if ((cp = spool (bp, "name")) == NULL)
130 return NULL; 127 return 0;
131 strncpy (sc.name, cp, BIG_NAME);
132 sc.name[BIG_NAME - 1] = '\0';
133 128
129 assign (sc.name, cp);
130
134 if ((cp = spool (NULL, "title")) == NULL) 131 if ((cp = spool (0, "title")) == NULL)
135 return NULL; 132 return 0;
136 strncpy (sc.title, cp, BIG_NAME);
137 sc.title[BIG_NAME - 1] = '\0';
138 133
134 assign (sc.title, cp);
135
139 if ((cp = spool (NULL, "score")) == NULL) 136 if ((cp = spool (0, "score")) == NULL)
140 return NULL; 137 return 0;
138
141 long long exp; 139 long long exp;
142
143 sscanf (cp, "%lld", &exp); 140 sscanf (cp, "%lld", &exp);
144 sc.exp = exp; 141 sc.exp = exp;
145 142
146 if ((cp = spool (NULL, "killer")) == NULL) 143 if ((cp = spool (0, "killer")) == NULL)
147 return NULL; 144 return 0;
148 strncpy (sc.killer, cp, BIG_NAME);
149 sc.killer[BIG_NAME - 1] = '\0';
150 145
146 assign (sc.killer, cp);
147
151 if ((cp = spool (NULL, "map")) == NULL) 148 if ((cp = spool (0, "map")) == NULL)
152 return NULL; 149 return 0;
153 strncpy (sc.maplevel, cp, BIG_NAME);
154 sc.maplevel[BIG_NAME - 1] = '\0';
155 150
151 assign (sc.maplevel, cp);
152
156 if ((cp = spool (NULL, "maxhp")) == NULL) 153 if ((cp = spool (0, "maxhp")) == NULL)
157 return NULL; 154 return 0;
155
158 sscanf (cp, "%d", &sc.maxhp); 156 sscanf (cp, "%d", &sc.maxhp);
159 157
160 if ((cp = spool (NULL, "maxsp")) == NULL) 158 if ((cp = spool (0, "maxsp")) == NULL)
161 return NULL; 159 return 0;
160
162 sscanf (cp, "%d", &sc.maxsp); 161 sscanf (cp, "%d", &sc.maxsp);
163 162
164 if ((cp = spool (NULL, "maxgrace")) == NULL) 163 if ((cp = spool (0, "maxgrace")) == NULL)
165 return NULL; 164 return 0;
165
166 sscanf (cp, "%d", &sc.maxgrace); 166 sscanf (cp, "%d", &sc.maxgrace);
167 return ≻ 167 return ≻
168} 168}
169 169
170static char * 170static char *
290 { 290 {
291 new_draw_info (NDI_UNIQUE, 0, op, "Since you were in explore mode,"); 291 new_draw_info (NDI_UNIQUE, 0, op, "Since you were in explore mode,");
292 new_draw_info (NDI_UNIQUE, 0, op, "you can't enter the high-score list."); 292 new_draw_info (NDI_UNIQUE, 0, op, "you can't enter the high-score list.");
293 return; 293 return;
294 } 294 }
295
295 strncpy (new_score.name, op->name, BIG_NAME); 296 assign (new_score.name, op->name);
296 new_score.name[BIG_NAME - 1] = '\0'; 297 assign (new_score.title, op->title.length () ? &op->title : op->contr->title);
297 strncpy (new_score.title, op->contr->own_title, BIG_NAME); 298 assign (new_score.killer, op->contr->killer[0] ? op->contr->killer : "a dungeon collapse");
298 if (new_score.title[0] == '\0') 299 assign (new_score.maplevel, op->map ? op->map->name ? op->map->name : op->map->path : "");
299 strncpy (new_score.title, op->contr->title, BIG_NAME); 300
300 new_score.title[BIG_NAME - 1] = '\0';
301 strncpy (new_score.killer, op->contr->killer, BIG_NAME);
302 if (new_score.killer[0] == '\0')
303 strcpy (new_score.killer, "a dungeon collapse");
304 new_score.killer[BIG_NAME - 1] = '\0';
305 new_score.exp = op->stats.exp; 301 new_score.exp = op->stats.exp;
306 if (op->map == NULL)
307 *new_score.maplevel = '\0';
308 else
309 {
310 strncpy (new_score.maplevel, op->map->name ? op->map->name : op->map->path, BIG_NAME - 1);
311 new_score.maplevel[BIG_NAME - 1] = '\0';
312 }
313 new_score.maxhp = (int) op->stats.maxhp; 302 new_score.maxhp = op->stats.maxhp;
314 new_score.maxsp = (int) op->stats.maxsp; 303 new_score.maxsp = op->stats.maxsp;
315 new_score.maxgrace = (int) op->stats.maxgrace; 304 new_score.maxgrace = op->stats.maxgrace;
305
316 if ((old_score = add_score (&new_score)) == NULL) 306 if ((old_score = add_score (&new_score)) == NULL)
317 { 307 {
318 new_draw_info (NDI_UNIQUE, 0, op, "Error in the highscore list."); 308 new_draw_info (NDI_UNIQUE, 0, op, "Error in the highscore list.");
319 return; 309 return;
320 } 310 }
311
321 if (new_score.position == -1) 312 if (new_score.position == -1)
322 { 313 {
323 new_score.position = HIGHSCORE_LENGTH + 1; /* Not strictly correct... */ 314 new_score.position = HIGHSCORE_LENGTH + 1; /* Not strictly correct... */
324 if (!strcmp (old_score->name, new_score.name)) 315 if (!strcmp (old_score->name, new_score.name))
325 new_draw_info (NDI_UNIQUE, 0, op, "You didn't beat your last highscore:"); 316 new_draw_info (NDI_UNIQUE, 0, op, "You didn't beat your last highscore:");
327 new_draw_info (NDI_UNIQUE, 0, op, "You didn't enter the highscore list:"); 318 new_draw_info (NDI_UNIQUE, 0, op, "You didn't enter the highscore list:");
328 new_draw_info (NDI_UNIQUE, 0, op, draw_one_high_score (old_score)); 319 new_draw_info (NDI_UNIQUE, 0, op, draw_one_high_score (old_score));
329 new_draw_info (NDI_UNIQUE, 0, op, draw_one_high_score (&new_score)); 320 new_draw_info (NDI_UNIQUE, 0, op, draw_one_high_score (&new_score));
330 return; 321 return;
331 } 322 }
323
332 if (old_score->exp >= new_score.exp) 324 if (old_score->exp >= new_score.exp)
333 new_draw_info (NDI_UNIQUE, 0, op, "You didn't beat your last score:"); 325 new_draw_info (NDI_UNIQUE, 0, op, "You didn't beat your last score:");
334 else 326 else
335 new_draw_info (NDI_UNIQUE, 0, op, "You beat your last score:"); 327 new_draw_info (NDI_UNIQUE, 0, op, "You beat your last score:");
336 328
337 new_draw_info (NDI_UNIQUE, 0, op, draw_one_high_score (old_score)); 329 new_draw_info (NDI_UNIQUE, 0, op, draw_one_high_score (old_score));
338 new_draw_info (NDI_UNIQUE, 0, op, draw_one_high_score (&new_score)); 330 new_draw_info (NDI_UNIQUE, 0, op, draw_one_high_score (&new_score));
339} 331}
340
341
342 332
343/* displays the high score file. object is the calling object 333/* displays the high score file. object is the calling object
344 * (null if being called via command line.) max is the maximum 334 * (null if being called via command line.) max is the maximum
345 * number of scores to display. match, if set, is the name or class 335 * number of scores to display. match, if set, is the name or class
346 * to match to. 336 * to match to.
391 } 381 }
392 /* Replaced what seemed to an overly complicated word wrap method 382 /* Replaced what seemed to an overly complicated word wrap method
393 * still word wraps, but assumes at most 2 lines of data. 383 * still word wraps, but assumes at most 2 lines of data.
394 * mw - 2-12-97 384 * mw - 2-12-97
395 */ 385 */
396 strncpy (buf, scorebuf, MAX_BUF); 386 assign (buf, scorebuf);
397 buf[MAX_BUF - 1] = '\0'; 387
398 cp = buf; 388 cp = buf;
399 while (strlen (cp) > maxchar) 389 while (strlen (cp) > maxchar)
400 { 390 {
401 bp = cp + maxchar - 1; 391 bp = cp + maxchar - 1;
402 while (*bp != ' ' && bp > cp) 392 while (*bp != ' ' && bp > cp)
403 bp--; 393 bp--;
404 *bp = '\0'; 394 *bp = '\0';
395
405 if (op == NULL) 396 if (op == NULL)
406 {
407 LOG (llevDebug, "%s\n", cp); 397 LOG (llevDebug, "%s\n", cp);
408 }
409 else 398 else
410 {
411 new_draw_info (NDI_UNIQUE, 0, op, cp); 399 new_draw_info (NDI_UNIQUE, 0, op, cp);
412 } 400
413 sprintf (buf, " %s", bp + 1); 401 sprintf (buf, " %s", bp + 1);
414 cp = buf; 402 cp = buf;
415 i++; 403 i++;
416 } 404 }
405
417 if (op == NULL) 406 if (op == NULL)
418 LOG (llevDebug, "%s\n", buf); 407 LOG (llevDebug, "%s\n", buf);
419 else 408 else
420 new_draw_info (NDI_UNIQUE, 0, op, buf); 409 new_draw_info (NDI_UNIQUE, 0, op, buf);
421 } 410 }
411
422 close_and_delete (fp, comp); 412 close_and_delete (fp, comp);
423} 413}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines