| 76 | } |
| 77 | |
| 78 | CScore::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 | |
| 114 | void CScore::LoadBestTime() |
| 115 | { |
nothing calls this directly
no test coverage detected