linije

Клон игре Color lines
git clone https://git.sr.ht/~strahinja/linije
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

hiscore.h (1470B)


      1 /* This program is licensed under the terms of GNU GPL v3 or (at your option)
      2  * any later version. Copyright (C) 2025  Страхиња Радић.
      3  * See the file LICENSE for exact copyright and license details. */
      4 
      5 #define DEFAULT_TIMESTAMP     "1970-01-01 00:00"
      6 #define HI_SCORE_DEFAULT_NAME "Unknown player"
      7 #define HI_SCORE_MAX	      10
      8 #define HI_SCORE_NAME_MAX     40
      9 #define TIMESTAMP_MAX	      17
     10 
     11 #ifndef PATH_MAX
     12 #define PATH_MAX _POSIX_PATH_MAX
     13 #endif
     14 
     15 #define GETBYTENOF4(x, n) \
     16 	((uint8_t)(((x) & (0x000000FF << (8 * (3 - (n))))) >> (8 * (3 - (n)))))
     17 #define SETBYTENOF4(x, n) ((x) << (8 * (3 - (n))))
     18 
     19 struct HiScoreEntry {
     20 	char* name;
     21 	int name_len;
     22 	char timestamp[TIMESTAMP_MAX];
     23 	unsigned long int score;
     24 };
     25 
     26 int hs_add(struct HiScoreEntry** table, const char* name, const int name_len,
     27 	const unsigned long int score, const char* timestamp);
     28 int hs_add_now(struct HiScoreEntry** table, const char* name,
     29 	const int name_len, const unsigned long int score);
     30 int hs_assign(const struct HiScoreEntry* source, struct HiScoreEntry* dest);
     31 int hs_assign_ps(const char* name, const int name_len,
     32 	const unsigned long int score, const char* timestamp,
     33 	struct HiScoreEntry* dest);
     34 int hs_assign_ss(const struct HiScoreEntry* source, struct HiScoreEntry* dest);
     35 char* hs_get_hofdir(void);
     36 int hs_init(struct HiScoreEntry** table);
     37 int hs_load(struct HiScoreEntry** table, const char* hofdir);
     38 int hs_write(struct HiScoreEntry* table, const char* hofdir);