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.18 by pippijn, Mon Jan 15 21:06:20 2007 UTC vs.
Revision 1.23 by root, Thu Nov 8 19:43:27 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game for X-windows 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * 20 *
22 * The authors can be reached via e-mail at <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 22 */
24 23
25#include <global.h> 24#include <global.h>
26#include <sproto.h> 25#include <sproto.h>
27 26
41 40
42/* 41/*
43 * spool works mostly like strtok(char *, ":"), but it can also 42 * spool works mostly like strtok(char *, ":"), but it can also
44 * log a specified error message if something goes wrong. 43 * log a specified error message if something goes wrong.
45 */ 44 */
46
47char * 45char *
48spool (char *bp, char *error) 46spool (char *bp, const char *error)
49{ 47{
50 static char *prev_pos = NULL; 48 static char *prev_pos = NULL;
51 char *next_pos; 49 char *next_pos;
52 50
53 if (bp == NULL) 51 if (bp == NULL)
76 74
77/* 75/*
78 * Does what it says, copies the contents of the first score structure 76 * Does what it says, copies the contents of the first score structure
79 * to the second one. 77 * to the second one.
80 */ 78 */
81
82static void 79static void
83copy_score (score *sc1, score *sc2) 80copy_score (score *sc1, score *sc2)
84{ 81{
85 assign (sc2->name , sc1->name); 82 assign (sc2->name , sc1->name);
86 assign (sc2->title , sc1->title); 83 assign (sc2->title , sc1->title);
94 91
95/* 92/*
96 * Writes the given score structure to a static buffer, and returns 93 * Writes the given score structure to a static buffer, and returns
97 * a pointer to it. 94 * a pointer to it.
98 */ 95 */
99
100static char * 96static char *
101put_score (score *sc) 97put_score (score *sc)
102{ 98{
103 static char buf[MAX_BUF]; 99 static char buf[MAX_BUF];
104 100
326 LOG (llevError, "Cannot open highscore file %s: %s\n", buf, strerror (errno)); 322 LOG (llevError, "Cannot open highscore file %s: %s\n", buf, strerror (errno));
327 if (op != NULL) 323 if (op != NULL)
328 new_draw_info (NDI_UNIQUE, 0, op, "There is no highscore file."); 324 new_draw_info (NDI_UNIQUE, 0, op, "There is no highscore file.");
329 return; 325 return;
330 } 326 }
331 if (op != NULL) 327
332 clear_win_info (op);
333 new_draw_info (NDI_UNIQUE, 0, op, "Nr Score Who [max hp][max sp][max grace]"); 328 new_draw_info (NDI_UNIQUE, 0, op, "Nr Score Who [max hp][max sp][max grace]");
334 329
335 while (fgets (buf, MAX_BUF, fp) != NULL) 330 while (fgets (buf, MAX_BUF, fp) != NULL)
336 { 331 {
337 if (j >= HIGHSCORE_LENGTH || i >= (max - 1)) 332 if (j >= HIGHSCORE_LENGTH || i >= (max - 1))
338 break; 333 break;
334
339 if ((sc = get_score (buf)) == NULL) 335 if ((sc = get_score (buf)) == NULL)
340 break; 336 break;
337
341 sc->position = ++j; 338 sc->position = ++j;
342 if (match == NULL) 339 if (match == NULL)
343 { 340 {
344 scorebuf = draw_one_high_score (sc); 341 scorebuf = draw_one_high_score (sc);
345 i++; 342 i++;
352 i++; 349 i++;
353 } 350 }
354 else 351 else
355 continue; 352 continue;
356 } 353 }
354
357 /* Replaced what seemed to an overly complicated word wrap method 355 /* Replaced what seemed to an overly complicated word wrap method
358 * still word wraps, but assumes at most 2 lines of data. 356 * still word wraps, but assumes at most 2 lines of data.
359 * mw - 2-12-97 357 * mw - 2-12-97
360 */ 358 */
361 assign (buf, scorebuf); 359 assign (buf, scorebuf);
384 new_draw_info (NDI_UNIQUE, 0, op, buf); 382 new_draw_info (NDI_UNIQUE, 0, op, buf);
385 } 383 }
386 384
387 close_and_delete (fp, comp); 385 close_and_delete (fp, comp);
388} 386}
387

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines