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:101

Definition at line 98 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:84

Definition at line 88 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:91

Definition at line 96 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 106 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 69 of file map.qh.

70{
71 int fh = fopen(filename, FILE_WRITE);
72 if (fh < 0) LOG_FATALF("Can't dump DB to %s", filename);
73 fputs(fh, "0\n");
74 for (int i = 0, n = buf_getsize(db); i < n; ++i)
75 {
76 int m = tokenizebyseparator(bufstr_get(db, i), "\\");
77 for (int j = 2; j < m; j += 2)
78 fputs(fh, strcat("\\", argv(j - 1), "\\", argv(j), "\n"));
79 }
80 fclose(fh);
81}
const float FILE_WRITE
#define tokenizebyseparator
#define LOG_FATALF(...)
Definition log.qh:54
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) return -1;
39 int fh = fopen(filename, FILE_READ);
40 if (fh < 0) return db;
41 string l = fgets(fh);
42 if (stoi(l) == DB_BUCKETS)
43 {
44 for (int i = 0; (l = fgets(fh)); ++i)
45 {
46 if (l != "") bufstr_set(db, i, l);
47 }
48 }
49 else
50 {
51 // different count of buckets, or a dump?
52 // need to reorganize the database then (SLOW)
53 //
54 // note: we also parse the first line (l) in case the DB file is
55 // missing the bucket count
56 do
57 {
58 int n = tokenizebyseparator(l, "\\");
59 for (int j = 2; j < n; j += 2)
60 db_put(db, argv(j - 1), uri_unescape(argv(j)));
61 }
62 while ((l = fgets(fh)));
63 }
64 fclose(fh);
65 return db;
66}
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:62
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().