|
11 | 11 |
|
12 | 12 |
|
13 | 13 | #define BANMGR_FILEVERSION 1
|
14 |
| -char const* g_pBanMgrFilename = "abcenchance/voice_ban.dt"; |
| 14 | +char const g_pBanMgrFilename[] = "abcenchance/"; |
15 | 15 |
|
16 | 16 | CVoiceBanMgr::CVoiceBanMgr(){
|
17 | 17 | Clear();
|
18 | 18 | }
|
19 | 19 | bool CVoiceBanMgr::Init(){
|
20 | 20 | char filename[MAX_PATH];
|
21 |
| - vgui::filesystem()->GetLocalPath(g_pBanMgrFilename, filename, MAX_PATH); |
22 |
| - std::ifstream ifs(filename, std::ios::binary); |
23 |
| - if (ifs.is_open()) { |
24 |
| - while (!ifs.eof()) { |
25 |
| - uint64 steamid = 0; |
26 |
| - ifs.read(reinterpret_cast<char*>(&steamid), sizeof(uint64)); |
27 |
| - m_aryBannedPlayer.push_back(steamid); |
| 21 | + const char* result = vgui::filesystem()->GetLocalPath(g_pBanMgrFilename, filename, MAX_PATH); |
| 22 | + if (result != nullptr) { |
| 23 | + Q_snprintf(filename, MAX_PATH, "%s/voice_ban.dt", filename); |
| 24 | + std::ifstream ifs(filename, std::ios::binary); |
| 25 | + if (ifs.is_open()) { |
| 26 | + while (!ifs.eof()) { |
| 27 | + uint64 steamid = 0; |
| 28 | + ifs.read(reinterpret_cast<char*>(&steamid), sizeof(uint64)); |
| 29 | + m_aryBannedPlayer.push_back(steamid); |
| 30 | + } |
| 31 | + ifs.close(); |
28 | 32 | }
|
29 |
| - ifs.close(); |
| 33 | + return true; |
30 | 34 | }
|
31 |
| - return true; |
| 35 | + return false; |
32 | 36 | }
|
33 | 37 | void CVoiceBanMgr::Save(){
|
34 | 38 | char filename[MAX_PATH];
|
35 |
| - vgui::filesystem()->GetLocalPath(g_pBanMgrFilename, filename, MAX_PATH); |
36 |
| - std::ofstream ofs(filename, std::ios::binary); |
37 |
| - if (ofs.is_open()) { |
38 |
| - for (auto iter = m_aryBannedPlayer.begin(); iter != m_aryBannedPlayer.end(); iter++) { |
39 |
| - uint64 steamid = *iter; |
40 |
| - ofs.write(reinterpret_cast<char*>(steamid), sizeof(uint64)); |
| 39 | + const char* result = vgui::filesystem()->GetLocalPath(g_pBanMgrFilename, filename, MAX_PATH); |
| 40 | + if (result != nullptr) { |
| 41 | + Q_snprintf(filename, MAX_PATH, "%s/voice_ban.dt", filename); |
| 42 | + std::ofstream ofs(filename, std::ios::binary); |
| 43 | + if (ofs.is_open()) { |
| 44 | + for (auto iter = m_aryBannedPlayer.begin(); iter != m_aryBannedPlayer.end(); iter++) { |
| 45 | + uint64 steamid = *iter; |
| 46 | + ofs.write(reinterpret_cast<char*>(steamid), sizeof(uint64)); |
| 47 | + } |
| 48 | + ofs.close(); |
41 | 49 | }
|
42 |
| - ofs.close(); |
43 | 50 | }
|
44 | 51 | }
|
45 | 52 | bool CVoiceBanMgr::GetPlayerBan(uint64 steamid){
|
|
0 commit comments