Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
map.qh File Reference
#include "int.qh"
Include dependency graph for map.qh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define db_remove(db, key)
#define HM_DELETE(this)
#define HM_gets(this, k)
#define HM_NEW(this)
#define HM_sets(this, key, val)

Typedefs

using HashMap = int

Functions

ERASEABLE void db_close (int db)
ERASEABLE int db_create ()
ERASEABLE void db_dump (int db, string filename)
ERASEABLE string db_get (int db, string key)
ERASEABLE int db_load (string filename)
ERASEABLE void db_put (int db, string key, string value)
ERASEABLE void db_save (int db, string filename)

Variables

const int DB_BUCKETS = 8192

Macro Definition Documentation

◆ db_remove

#define db_remove ( db,
key )
Value:
db_put(db, key, "")
ERASEABLE void db_put(int db, string key, string value)
Definition map.qh:103

Definition at line 100 of file map.qh.

Referenced by ignore_clearall(), ignore_remove_player(), race_deleteTime(), and uid2name().

◆ HM_DELETE

#define HM_DELETE ( this)
Value:
db_close(this)
ERASEABLE void db_close(int db)
Definition map.qh:86

Definition at line 90 of file map.qh.

Referenced by SHUTDOWN().

◆ HM_gets

#define HM_gets ( this,
k )
Value:
db_get(this, k)
ERASEABLE string db_get(int db, string key)
Definition map.qh:93

Definition at line 98 of file map.qh.

Referenced by CTX().

◆ HM_NEW

#define HM_NEW ( this)
Value:
(this = db_create())
ERASEABLE int db_create()
Definition map.qh:25

Definition at line 29 of file map.qh.

Referenced by STATIC_INIT().

◆ HM_sets

#define HM_sets ( this,
key,
val )
Value:
db_put(this, key, val)

Definition at line 108 of file map.qh.

Referenced by CTX().

Typedef Documentation

◆ HashMap

using HashMap = int

Definition at line 22 of file map.qh.

Function Documentation

◆ db_close()

◆ db_create()

◆ db_dump()

ERASEABLE void db_dump ( int db,
string filename )

Definition at line 70 of file map.qh.

71{
72 int fh = fopen(filename, FILE_WRITE);
73 if (fh < 0)
74 LOG_FATALF("Can't dump DB to %s", filename);
75 fputs(fh, "0\n");
76 for (int m, j, i = 0, n = buf_getsize(db); i < n; ++i)
77 {
78 m = tokenizebyseparator(bufstr_get(db, i), "\\");
79 for (j = 2; j < m; j += 2)
80 fputs(fh, strcat("\\", argv(j - 1), "\\", argv(j), "\n"));
81 }
82 fclose(fh);
83}
const float FILE_WRITE
#define tokenizebyseparator
#define LOG_FATALF(...)
Definition log.qh:51
void fclose(float fhandle)
void fputs(float fhandle, string s)
float fopen(string filename, float mode)
string argv(float n)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))

References argv(), fclose(), FILE_WRITE, fopen(), fputs(), LOG_FATALF, strcat(), and tokenizebyseparator.

Referenced by GameCommand_database(), and Shutdown().

◆ db_get()

◆ db_load()

ERASEABLE int db_load ( string filename)

Definition at line 35 of file map.qh.

36{
37 int db = buf_create();
38 if (db < 0)
39 return -1;
40 int fh = fopen(filename, FILE_READ);
41 if (fh < 0)
42 return db;
43 string l = fgets(fh);
44 if (stoi(l) == DB_BUCKETS)
45 {
46 for (int i = 0; (l = fgets(fh)); ++i)
47 if (l != "")
48 bufstr_set(db, i, l);
49 }
50 else
51 {
52 // different count of buckets, or a dump?
53 // need to reorganize the database then (SLOW)
54 //
55 // note: we also parse the first line (l) in case the DB file is
56 // missing the bucket count
57 do
58 {
59 int n = tokenizebyseparator(l, "\\");
60 for (int j = 2; j < n; j += 2)
61 db_put(db, argv(j - 1), uri_unescape(argv(j)));
62 }
63 while ((l = fgets(fh)));
64 }
65 fclose(fh);
66 return db;
67}
const float FILE_READ
#define stoi(s)
Definition int.qh:4
string fgets(float fhandle)

References argv(), buf_create, DB_BUCKETS, db_put(), fclose(), fgets(), FILE_READ, fopen(), stoi, and tokenizebyseparator.

Referenced by CSQC_Init(), GameCommand_database(), GenericCommand_rpn(), RestoreGame(), and spawnfunc().

◆ db_put()

◆ db_save()

ERASEABLE void db_save ( int db,
string filename )

Definition at line 8 of file map.qh.

9{
10 int fh = fopen(filename, FILE_WRITE);
11 if (fh < 0)
12 {
13 LOG_WARNF("^1Can't write DB to %s", filename);
14 return;
15 }
16 fputs(fh, strcat(ftos(DB_BUCKETS), "\n"));
17 for (int i = 0, n = buf_getsize(db); i < n; ++i)
18 fputs(fh, strcat(bufstr_get(db, i), "\n"));
19 fclose(fh);
20}
#define LOG_WARNF(...)
Definition log.qh:59
string ftos(float f)

References DB_BUCKETS, fclose(), FILE_WRITE, fopen(), fputs(), ftos(), LOG_WARNF, and strcat().

Referenced by GameCommand_database(), GenericCommand_rpn(), and Shutdown().

Variable Documentation

◆ DB_BUCKETS

const int DB_BUCKETS = 8192

Definition at line 6 of file map.qh.

Referenced by db_get(), db_load(), db_put(), and db_save().