MCPcopy Create free account
hub / github.com/ddnet/ddnet / CServerBrowserPingCache

Method CServerBrowserPingCache

src/engine/client/serverbrowser_ping_cache.cpp:43–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41};
42
43CServerBrowserPingCache::CServerBrowserPingCache(IConsole *pConsole, IStorage *pStorage) :
44 m_pConsole(pConsole)
45{
46 m_pDisk = SqliteOpen(pConsole, pStorage, "ddnet-cache.sqlite3");
47 if(!m_pDisk)
48 {
49 pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "serverbrowse_ping_cache", "failed to open ddnet-cache.sqlite3");
50 return;
51 }
52 sqlite3 *pSqlite = m_pDisk.get();
53 static const char TABLE[] = "CREATE TABLE IF NOT EXISTS server_pings (ip_address TEXT PRIMARY KEY NOT NULL, ping INTEGER NOT NULL, utc_timestamp TEXT NOT NULL)";
54 if(SQLITE_HANDLE_ERROR(sqlite3_exec(pSqlite, TABLE, nullptr, nullptr, nullptr)))
55 {
56 m_pDisk = nullptr;
57 pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "serverbrowse_ping_cache", "failed to create server_pings table");
58 return;
59 }
60 m_pLoadStmt = SqlitePrepare(pConsole, pSqlite, "SELECT ip_address, ping FROM server_pings");
61 m_pStoreStmt = SqlitePrepare(pConsole, pSqlite, "INSERT OR REPLACE INTO server_pings (ip_address, ping, utc_timestamp) VALUES (?, ?, datetime('now'))");
62}
63
64void CServerBrowserPingCache::Load()
65{

Callers

nothing calls this directly

Calls 4

SqliteOpenFunction · 0.85
SqlitePrepareFunction · 0.85
getMethod · 0.80
PrintMethod · 0.45

Tested by

no test coverage detected