| 1 | #cxx . . $ `<file>/src/highscores.cpp`/include "snipe2d.h"cxx . . $ `<file>/src/snipe2d.h`/ |
| 2 | #include <pwd.h> |
| 3 | |
| 4 | extern PREFScxx . . $ PREFS# gPrefscxx . . $ gPrefs.; |
| 5 | char uNamecxx . . $ uName.[9]; |
| 6 | char namescxx . . $ names.[10][9]; |
| 7 | int scorescxx . . $ scores.[10]; |
| 8 | |
| 9 | extern void fillrectcxx . . $ fillrect(1559a299834bcdd5). (int x1, int y1, int x2, int y2, int color); |
| 10 | |
| 11 | |
| 12 | void |
| 13 | oes_fillrectcxx . . $ oes_fillrect(fa5faf37b232239e). (SDL_Surface *screen, int x1, int y1, int x2, int y2, int color) |
| 14 | { |
| 15 | SDL_Rect r; |
| 16 | r.x = x1; |
| 17 | r.y = y1; |
| 18 | r.w = x2-x1; |
| 19 | r.h = y2-y1; |
| 20 | int sdlcolor = SDL_MapRGB(screen->format, |
| 21 | (color >> 16) & 0xff, |
| 22 | (color >> 8) & 0xff, |
| 23 | (color >> 0) & 0xff); |
| 24 | SDL_FillRect(screen, &r, sdlcolor); |
| 25 | } |
| 26 | |
| 27 | |
| 28 | int |
| 29 | draw_hiscorescxx . . $ draw_hiscores(715989be3a25e77e). (SDL_Surface *screen, const SDL_Rect *r) |
| 30 | { |
| 31 | char score[256]; |
| 32 | FILEcxx . . $ FILE# *f; |
| 33 | int i; |
| 34 | int row, toprow; |
| 35 | int col; |
| 36 | int x, y, w, h; |
| 37 | int xp, xq; /* horizontal scale factor (p/q) */ |
| 38 | int yp, yq; /* vertical scale factor (p/q) */ |
| 39 | |
| 40 | if ((f = fopen(gPrefscxx . . $ gPrefs..scorepathcxx . . $ prefs_#scorepath., "rb"))) |
| 41 | { |
| 42 | fread(&Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore., sizeof(SCOREScxx . . $ SCORES#), 1, f); |
| 43 | fclose(f); |
| 44 | } |
| 45 | |
| 46 | x = r->x; y = r->y; w = r->w; h = r->h; |
| 47 | /* map 640 * p/q => screen->w */ |
| 48 | xp = screen->w; |
| 49 | yp = screen->h; |
| 50 | xq = 640; |
| 51 | yq = 480; |
| 52 | #define Xcxx . . $ `src/highscores.cpp:52:9`!(n) (x + (n * xp / xq)) |
| 53 | #define Ycxx . . $ `src/highscores.cpp:53:9`!(n) (y + (n * yp / yq)) |
| 54 | oes_fillrectcxx . . $ oes_fillrect(fa5faf37b232239e).(screen, Xcxx . . $ `src/highscores.cpp:52:9`!(0), Ycxx . . $ `src/highscores.cpp:53:9`!(0), Xcxx . . $ `src/highscores.cpp:52:9`!(640), Ycxx . . $ `src/highscores.cpp:53:9`!(480), 0); |
| 55 | oes_fillrectcxx . . $ oes_fillrect(fa5faf37b232239e).(screen, Xcxx . . $ `src/highscores.cpp:52:9`!(19), Ycxx . . $ `src/highscores.cpp:53:9`!(59), Xcxx . . $ `src/highscores.cpp:52:9`!(621), Ycxx . . $ `src/highscores.cpp:53:9`!(421), 0x007f00); |
| 56 | oes_fillrectcxx . . $ oes_fillrect(fa5faf37b232239e).(screen, Xcxx . . $ `src/highscores.cpp:52:9`!(20), Ycxx . . $ `src/highscores.cpp:53:9`!(60), Xcxx . . $ `src/highscores.cpp:52:9`!(620), Ycxx . . $ `src/highscores.cpp:53:9`!(420), 0x003f00); |
| 57 | oes_fillrectcxx . . $ oes_fillrect(fa5faf37b232239e).(screen, Xcxx . . $ `src/highscores.cpp:52:9`!(19), Ycxx . . $ `src/highscores.cpp:53:9`!(80), Xcxx . . $ `src/highscores.cpp:52:9`!(621), Ycxx . . $ `src/highscores.cpp:53:9`!(81), 0x007f00); |
| 58 | printcxx . . $ print(e6b86272566182ce).(Xcxx . . $ `src/highscores.cpp:52:9`!(224 + 12), Ycxx . . $ `src/highscores.cpp:53:9`!(412), COLOR_GREENcxx . . $ COLOR_GREEN., "click to play | press ESC to quit"); |
| 59 | toprow = 88 + 40; |
| 60 | |
| 61 | row = toprow; |
| 62 | printShadowcxx . . $ printShadow(9514e36549094170).(Xcxx . . $ `src/highscores.cpp:52:9`!(30), Ycxx . . $ `src/highscores.cpp:53:9`!(row), " Top Ten (Difficulty: Easy"); |
| 63 | row += 8; |
| 64 | for (i = 0; i < 10; i ++) |
| 65 | { |
| 66 | col = 24; |
| 67 | printShadowcxx . . $ printShadow(9514e36549094170).(Xcxx . . $ `src/highscores.cpp:52:9`!(col), Ycxx . . $ `src/highscores.cpp:53:9`!(row), Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..easy_ncxx . . $ scores_#easy_n.[i]); |
| 68 | snprintf(score, sizeof(score), "%d", Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..easy_scxx . . $ scores_#easy_s.[i]); |
| 69 | if (Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..easy_scxx . . $ scores_#easy_s.[i]) |
| 70 | printShadowcxx . . $ printShadow(9514e36549094170).(Xcxx . . $ `src/highscores.cpp:52:9`!(col + 48), Ycxx . . $ `src/highscores.cpp:53:9`!(row), score); |
| 71 | row += 8; |
| 72 | } |
| 73 | |
| 74 | row = toprow; |
| 75 | printShadowcxx . . $ printShadow(9514e36549094170).(Xcxx . . $ `src/highscores.cpp:52:9`!(250), Ycxx . . $ `src/highscores.cpp:53:9`!(row), "Top Ten (Difficulty: Medium)"); |
| 76 | row += 8; |
| 77 | for (i = 0; i < 10; i++) |
| 78 | { |
| 79 | col = 250; |
| 80 | printShadowcxx . . $ printShadow(9514e36549094170).(Xcxx . . $ `src/highscores.cpp:52:9`!(col), Ycxx . . $ `src/highscores.cpp:53:9`!(row), Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..medium_ncxx . . $ scores_#medium_n.[i]); |
| 81 | snprintf(score, sizeof(score), "%d", Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..medium_scxx . . $ scores_#medium_s.[i]); |
| 82 | if (Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..medium_scxx . . $ scores_#medium_s.[i]) |
| 83 | printShadowcxx . . $ printShadow(9514e36549094170).(Xcxx . . $ `src/highscores.cpp:52:9`!(col + 48), Ycxx . . $ `src/highscores.cpp:53:9`!(row), score); |
| 84 | row += 8; |
| 85 | } |
| 86 | |
| 87 | row = toprow; |
| 88 | printShadowcxx . . $ printShadow(9514e36549094170).(Xcxx . . $ `src/highscores.cpp:52:9`!(476), Ycxx . . $ `src/highscores.cpp:53:9`!(row), " Top Ten (Difficulty: Hard)"); |
| 89 | row += 8; |
| 90 | for (i = 0; i < 10; i++) |
| 91 | { |
| 92 | col = 476; |
| 93 | printShadowcxx . . $ printShadow(9514e36549094170).(Xcxx . . $ `src/highscores.cpp:52:9`!(col), Ycxx . . $ `src/highscores.cpp:53:9`!(row), Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..hard_ncxx . . $ scores_#hard_n.[i]); |
| 94 | snprintf(score, sizeof(score), "%d", Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..hard_scxx . . $ scores_#hard_s.[i]); |
| 95 | if (Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..hard_scxx . . $ scores_#hard_s.[i]) |
| 96 | printShadowcxx . . $ printShadow(9514e36549094170).(Xcxx . . $ `src/highscores.cpp:52:9`!(col + 48), Ycxx . . $ `src/highscores.cpp:53:9`!(row), score); |
| 97 | row += 8; |
| 98 | } |
| 99 | |
| 100 | row = toprow; |
| 101 | |
| 102 | #undef Xcxx . . $ `src/highscores.cpp:52:9`! |
| 103 | #undef Ycxx . . $ `src/highscores.cpp:53:9`! |
| 104 | return 1; |
| 105 | } |
| 106 | |
| 107 | #if 0 |
| 108 | void show_hiscores() |
| 109 | { |
| 110 | char score[256]; |
| 111 | FILE *f; |
| 112 | int i; |
| 113 | |
| 114 | Game.GameState = 0; |
| 115 | SDL_ShowCursor (1); |
| 116 | if ((f = fopen (gPrefs.scorepath, "rb"))) |
| 117 | { |
| 118 | fread (&Game.HiScore, sizeof(SCORES), 1, f); |
| 119 | fclose (f); |
| 120 | } |
| 121 | |
| 122 | Game.GameState = 0; |
| 123 | fillrect(0,0,640,480,0); |
| 124 | fillrect(19,59,621,421,0x007f00); |
| 125 | fillrect(20,60,620,420,0x003f00); |
| 126 | fillrect(19,80,621,81,0x007f00); |
| 127 | print(224 + 12, 412, COLOR_GREEN, "click to play | press ESC to quit"); |
| 128 | int row = 88 +40; |
| 129 | |
| 130 | printShadow (30, row, " Top Ten (Difficulty: Easy"); |
| 131 | row += 8; |
| 132 | for (i = 0; i < 10; i++) |
| 133 | { |
| 134 | printShadow (24, row, Game.HiScore.easy_n[i]); |
| 135 | snprintf (score, sizeof(score), "%d", Game.HiScore.easy_s[i]); |
| 136 | if (Game.HiScore.easy_s[i]) |
| 137 | printShadow (24+48, row, score); |
| 138 | row += 8; |
| 139 | } |
| 140 | row = 88+40; |
| 141 | |
| 142 | printShadow (250, row, "Top Ten (Difficulty: Medium)"); |
| 143 | row += 8; |
| 144 | for (i = 0; i < 10; i++) |
| 145 | { |
| 146 | printShadow (250, row, Game.HiScore.medium_n[i]); |
| 147 | snprintf (score, sizeof(score), "%d", Game.HiScore.medium_s[i]); |
| 148 | if (Game.HiScore.medium_s[i]) |
| 149 | printShadow (298, row, score); |
| 150 | row += 8; |
| 151 | } |
| 152 | row = 88+40; |
| 153 | |
| 154 | printShadow (476, row, " Top Ten (Difficulty: Hard)"); |
| 155 | row += 8; |
| 156 | for (i = 0; i < 10; i++) |
| 157 | { |
| 158 | printShadow (476, row, Game.HiScore.hard_n[i]); |
| 159 | snprintf (score, sizeof(score), "%d", Game.HiScore.hard_s[i]); |
| 160 | if (Game.HiScore.hard_s[i]) |
| 161 | printShadow (476+48, row, score); |
| 162 | row += 8; |
| 163 | } |
| 164 | row = 88+40; |
| 165 | |
| 166 | SDL_Flip (Game.Screen); |
| 167 | } |
| 168 | #endif /* 0 */ |
| 169 | |
| 170 | void shove_hiscorescxx . . $ shove_hiscores(d4f767463ce0a6b3).(int pos) // Shift scorecard down, bump last one. |
| 171 | { |
| 172 | int i; |
| 173 | |
| 174 | for (i = 9; i > pos; i--) |
| 175 | if (i > 0) |
| 176 | { |
| 177 | snprintf (namescxx . . $ names.[i], 9, "%s", namescxx . . $ names.[i-1]); |
| 178 | namescxx . . $ names.[i][8] = '\0'; |
| 179 | scorescxx . . $ scores.[i] = scorescxx . . $ scores.[i-1]; |
| 180 | } |
| 181 | |
| 182 | scorescxx . . $ scores.[i] = Gamecxx . . $ Game..Scorecxx . . $ orbitalsniper_t#Score.; |
| 183 | snprintf (namescxx . . $ names.[i], 9, "%s", uNamecxx . . $ uName.); |
| 184 | namescxx . . $ names.[i][8] = '\0'; |
| 185 | } |
| 186 | |
| 187 | void init_hiscorescxx . . $ init_hiscores(49f6e7a06ebc5aa8).() |
| 188 | { |
| 189 | char path[256]; |
| 190 | struct passwd *pw_ent = getpwuid (geteuid()); |
| 191 | FILEcxx . . $ FILE# *f; |
| 192 | |
| 193 | memset (&Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore., 0, sizeof(SCOREScxx . . $ SCORES#)); |
| 194 | snprintf (uNamecxx . . $ uName., 9, "%s", getenv("USER")); |
| 195 | uNamecxx . . $ uName.[8] = '\0'; |
| 196 | |
| 197 | snprintf (path, 256, "%s/.oes/scores.bin", pw_ent->pw_dir); |
| 198 | path[255] = '\0'; |
| 199 | f = fopen (path, "rb"); |
| 200 | if (f) |
| 201 | { |
| 202 | fread (&Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore., sizeof(SCOREScxx . . $ SCORES#), 1, f); |
| 203 | fclose (f); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | void save_hiscorescxx . . $ save_hiscores(49f6e7a06ebc5aa8).() |
| 208 | { |
| 209 | FILEcxx . . $ FILE# *f; |
| 210 | if (!(f = fopen(gPrefscxx . . $ gPrefs..scorepathcxx . . $ prefs_#scorepath., "wb"))) |
| 211 | { |
| 212 | fprintf (stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Unable to open hiscore file. Ignoring...\n"); |
| 213 | return; |
| 214 | } |
| 215 | fwrite (&Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore., sizeof (SCOREScxx . . $ SCORES#), 1, f); |
| 216 | fclose (f); |
| 217 | } |
| 218 | |
| 219 | void process_hiscorecxx . . $ process_hiscore(49f6e7a06ebc5aa8).() |
| 220 | { |
| 221 | int i; |
| 222 | |
| 223 | if (Gamecxx . . $ Game..Scorecxx . . $ orbitalsniper_t#Score. < 0) |
| 224 | return; |
| 225 | if (gPrefscxx . . $ gPrefs..difficultycxx . . $ prefs_#difficulty. == 1) |
| 226 | { |
| 227 | memcpy (&scorescxx . . $ scores., &Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..easy_scxx . . $ scores_#easy_s., sizeof(int)*10); |
| 228 | memcpy (&namescxx . . $ names., &Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..easy_ncxx . . $ scores_#easy_n., sizeof(char)*90); |
| 229 | } |
| 230 | else if (gPrefscxx . . $ gPrefs..difficultycxx . . $ prefs_#difficulty. == 2) |
| 231 | { |
| 232 | memcpy (&scorescxx . . $ scores., &Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..medium_scxx . . $ scores_#medium_s., sizeof(int)*10); |
| 233 | memcpy (&namescxx . . $ names., &Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..medium_ncxx . . $ scores_#medium_n., sizeof(char)*90); |
| 234 | } |
| 235 | else |
| 236 | { |
| 237 | memcpy (&scorescxx . . $ scores., &Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..hard_scxx . . $ scores_#hard_s., sizeof(int)*10); |
| 238 | memcpy (&namescxx . . $ names., &Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..hard_ncxx . . $ scores_#hard_n., sizeof(char)*90); |
| 239 | } |
| 240 | for (i = 0; i < 10; i++) |
| 241 | if (Gamecxx . . $ Game..Scorecxx . . $ orbitalsniper_t#Score. > scorescxx . . $ scores.[i]) |
| 242 | break; |
| 243 | |
| 244 | if (i > 9) |
| 245 | return; |
| 246 | |
| 247 | shove_hiscorescxx . . $ shove_hiscores(d4f767463ce0a6b3).(i); |
| 248 | |
| 249 | if (gPrefscxx . . $ gPrefs..difficultycxx . . $ prefs_#difficulty. == 1) |
| 250 | { |
| 251 | memcpy (&Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..easy_scxx . . $ scores_#easy_s., &scorescxx . . $ scores., sizeof(int)*10); |
| 252 | memcpy (&Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..easy_ncxx . . $ scores_#easy_n., &namescxx . . $ names., sizeof(char)*90); |
| 253 | } |
| 254 | else if (gPrefscxx . . $ gPrefs..difficultycxx . . $ prefs_#difficulty. == 2) |
| 255 | { |
| 256 | memcpy (&Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..medium_scxx . . $ scores_#medium_s., &scorescxx . . $ scores., sizeof(int)*10); |
| 257 | memcpy (&Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..medium_ncxx . . $ scores_#medium_n., &namescxx . . $ names., sizeof(char)*90); |
| 258 | } |
| 259 | else |
| 260 | { |
| 261 | memcpy (&Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..hard_scxx . . $ scores_#hard_s., &scorescxx . . $ scores., sizeof(int)*10); |
| 262 | memcpy (&Gamecxx . . $ Game..HiScorecxx . . $ orbitalsniper_t#HiScore..hard_ncxx . . $ scores_#hard_n., &namescxx . . $ names., sizeof(char)*90); |
| 263 | } |
| 264 | |
| 265 | save_hiscorescxx . . $ save_hiscores(49f6e7a06ebc5aa8).(); |
| 266 | } |
| 267 | |
| 268 |