Skip to content

Commit

Permalink
fix a error
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr.Abc committed Jul 17, 2024
1 parent b03051d commit cffe1b3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Source/Var/voice_banmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ bool CVoiceBanMgr::Init(){
const char* result = vgui::filesystem()->GetLocalPath(g_pBanMgrFilename, filename, MAX_PATH);
if (result != nullptr) {
Q_snprintf(filename, MAX_PATH, "%s/voice_ban.dt", filename);
std::ifstream ifs(filename, std::ios::binary);
std::ifstream ifs(filename, std::ios::in | std::ios::binary);
if (ifs.is_open()) {
while (!ifs.eof()) {
uint64 steamid = 0;
ifs.read(reinterpret_cast<char*>(&steamid), sizeof(uint64));
m_aryBannedPlayer.push_back(steamid);
if(steamid != 0)
m_aryBannedPlayer.push_back(steamid);
}
ifs.close();
}
Expand All @@ -39,11 +40,11 @@ void CVoiceBanMgr::Save(){
const char* result = vgui::filesystem()->GetLocalPath(g_pBanMgrFilename, filename, MAX_PATH);
if (result != nullptr) {
Q_snprintf(filename, MAX_PATH, "%s/voice_ban.dt", filename);
std::ofstream ofs(filename, std::ios::binary);
std::ofstream ofs(filename, std::ios::out | std::ios::binary);
if (ofs.is_open()) {
for (auto iter = m_aryBannedPlayer.begin(); iter != m_aryBannedPlayer.end(); iter++) {
uint64 steamid = *iter;
ofs.write(reinterpret_cast<char*>(steamid), sizeof(uint64));
ofs.write(reinterpret_cast<char*>(&steamid), sizeof(uint64));
}
ofs.close();
}
Expand Down

0 comments on commit cffe1b3

Please sign in to comment.