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

Method CScore

src/game/server/score.cpp:78–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78CScore::CScore(CGameContext *pGameServer, CDbConnectionPool *pPool) :
79 m_pPool(pPool),
80 m_pGameServer(pGameServer),
81 m_pServer(pGameServer->Server())
82{
83 LoadBestTime();
84
85 uint64_t aSeed[2];
86 secure_random_fill(aSeed, sizeof(aSeed));
87 m_Prng.Seed(aSeed);
88
89 CLineReader LineReader;
90 if(LineReader.OpenFile(GameServer()->Storage()->OpenFile("wordlist.txt", IOFLAG_READ, IStorage::TYPE_ALL)))
91 {
92 while(const char *pLine = LineReader.Get())
93 {
94 char aWord[32] = {0};
95 sscanf(pLine, "%*s %31s", aWord);
96 aWord[31] = 0;
97 m_vWordlist.emplace_back(aWord);
98 }
99 }
100 else
101 {
102 dbg_msg("sql", "failed to open wordlist, using fallback");
103 m_vWordlist.assign(std::begin(g_aFallbackWordlist), std::end(g_aFallbackWordlist));
104 }
105
106 if(m_vWordlist.size() < 1000)
107 {
108 dbg_msg("sql", "too few words in wordlist");
109 Server()->SetErrorShutdown("sql too few words in wordlist");
110 return;
111 }
112}
113
114void CScore::LoadBestTime()
115{

Callers

nothing calls this directly

Calls 9

secure_random_fillFunction · 0.85
dbg_msgFunction · 0.85
SeedMethod · 0.80
SetErrorShutdownMethod · 0.80
ServerClass · 0.50
ServerMethod · 0.45
OpenFileMethod · 0.45
StorageMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected