Blame


1 11a5e2cf 2024-01-16 benni /* $NetBSD: scores.h,v 1.5 2009/05/25 08:33:57 dholland Exp $ */
2 11a5e2cf 2024-01-16 benni
3 11a5e2cf 2024-01-16 benni /*-
4 11a5e2cf 2024-01-16 benni * Copyright (c) 1992, 1993
5 11a5e2cf 2024-01-16 benni * The Regents of the University of California. All rights reserved.
6 11a5e2cf 2024-01-16 benni *
7 11a5e2cf 2024-01-16 benni * This code is derived from software contributed to Berkeley by
8 11a5e2cf 2024-01-16 benni * Chris Torek and Darren F. Provine.
9 11a5e2cf 2024-01-16 benni *
10 11a5e2cf 2024-01-16 benni * Redistribution and use in source and binary forms, with or without
11 11a5e2cf 2024-01-16 benni * modification, are permitted provided that the following conditions
12 11a5e2cf 2024-01-16 benni * are met:
13 11a5e2cf 2024-01-16 benni * 1. Redistributions of source code must retain the above copyright
14 11a5e2cf 2024-01-16 benni * notice, this list of conditions and the following disclaimer.
15 11a5e2cf 2024-01-16 benni * 2. Redistributions in binary form must reproduce the above copyright
16 11a5e2cf 2024-01-16 benni * notice, this list of conditions and the following disclaimer in the
17 11a5e2cf 2024-01-16 benni * documentation and/or other materials provided with the distribution.
18 11a5e2cf 2024-01-16 benni * 3. Neither the name of the University nor the names of its contributors
19 11a5e2cf 2024-01-16 benni * may be used to endorse or promote products derived from this software
20 11a5e2cf 2024-01-16 benni * without specific prior written permission.
21 11a5e2cf 2024-01-16 benni *
22 11a5e2cf 2024-01-16 benni * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 11a5e2cf 2024-01-16 benni * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 11a5e2cf 2024-01-16 benni * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 11a5e2cf 2024-01-16 benni * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 11a5e2cf 2024-01-16 benni * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 11a5e2cf 2024-01-16 benni * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 11a5e2cf 2024-01-16 benni * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 11a5e2cf 2024-01-16 benni * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 11a5e2cf 2024-01-16 benni * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 11a5e2cf 2024-01-16 benni * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 11a5e2cf 2024-01-16 benni * SUCH DAMAGE.
33 11a5e2cf 2024-01-16 benni *
34 11a5e2cf 2024-01-16 benni * @(#)scores.h 8.1 (Berkeley) 5/31/93
35 11a5e2cf 2024-01-16 benni */
36 11a5e2cf 2024-01-16 benni
37 11a5e2cf 2024-01-16 benni /*
38 11a5e2cf 2024-01-16 benni * Tetris scores.
39 11a5e2cf 2024-01-16 benni */
40 11a5e2cf 2024-01-16 benni
41 11a5e2cf 2024-01-16 benni /* Header for high score file. */
42 11a5e2cf 2024-01-16 benni #define HSH_MAGIC_SIZE 8
43 11a5e2cf 2024-01-16 benni struct highscore_header {
44 11a5e2cf 2024-01-16 benni char hsh_magic[HSH_MAGIC_SIZE];
45 11a5e2cf 2024-01-16 benni uint32_t hsh_endiantag;
46 11a5e2cf 2024-01-16 benni uint32_t hsh_version;
47 11a5e2cf 2024-01-16 benni };
48 11a5e2cf 2024-01-16 benni
49 11a5e2cf 2024-01-16 benni /* Current on-disk high score record. */
50 11a5e2cf 2024-01-16 benni struct highscore_ondisk {
51 11a5e2cf 2024-01-16 benni char hso_name[20];
52 11a5e2cf 2024-01-16 benni int32_t hso_score;
53 11a5e2cf 2024-01-16 benni int32_t hso_level;
54 11a5e2cf 2024-01-16 benni int32_t hso_pad;
55 11a5e2cf 2024-01-16 benni int64_t hso_time;
56 11a5e2cf 2024-01-16 benni };
57 11a5e2cf 2024-01-16 benni
58 11a5e2cf 2024-01-16 benni /* 5.99.x after time_t change, on 32-bit machines */
59 11a5e2cf 2024-01-16 benni struct highscore_ondisk_599 {
60 11a5e2cf 2024-01-16 benni char hso599_name[20];
61 11a5e2cf 2024-01-16 benni int32_t hso599_score;
62 11a5e2cf 2024-01-16 benni int32_t hso599_level;
63 11a5e2cf 2024-01-16 benni int32_t hso599_time[2];
64 11a5e2cf 2024-01-16 benni };
65 11a5e2cf 2024-01-16 benni
66 11a5e2cf 2024-01-16 benni /* 5.0 and earlier on-disk high score record. */
67 11a5e2cf 2024-01-16 benni struct highscore_ondisk_50 {
68 11a5e2cf 2024-01-16 benni char hso50_name[20];
69 11a5e2cf 2024-01-16 benni int32_t hso50_score;
70 11a5e2cf 2024-01-16 benni int32_t hso50_level;
71 11a5e2cf 2024-01-16 benni int32_t hso50_time;
72 11a5e2cf 2024-01-16 benni };
73 11a5e2cf 2024-01-16 benni
74 11a5e2cf 2024-01-16 benni /* In-memory high score record. */
75 11a5e2cf 2024-01-16 benni struct highscore {
76 11a5e2cf 2024-01-16 benni char hs_name[20]; /* login name */
77 11a5e2cf 2024-01-16 benni int hs_score; /* raw score */
78 11a5e2cf 2024-01-16 benni int hs_level; /* play level */
79 11a5e2cf 2024-01-16 benni time_t hs_time; /* time at game end */
80 11a5e2cf 2024-01-16 benni };
81 11a5e2cf 2024-01-16 benni
82 11a5e2cf 2024-01-16 benni #define MAXHISCORES 80
83 11a5e2cf 2024-01-16 benni #define MAXSCORES 9 /* maximum high score entries per person */
84 11a5e2cf 2024-01-16 benni #define EXPIRATION (5L * 365 * 24 * 60 * 60)
85 11a5e2cf 2024-01-16 benni
86 11a5e2cf 2024-01-16 benni void savescore(int);
87 11a5e2cf 2024-01-16 benni void showscores(int);