Skip to content

Commit

Permalink
chillpw: add reload
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon committed Sep 18, 2024
1 parent b4b86b3 commit 0ca5a8d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/game/client/components/chillerbot/chillpw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ void CChillPw::OnMapLoad()

void CChillPw::OnConsoleInit()
{
Console()->Register("chillpw", "?s[status|dump_host]", CFGFLAG_CLIENT, ConChillpw, this, "");
Console()->Register("chillpw", "?s[status|dump_host|reload]", CFGFLAG_CLIENT, ConChillpw, this, "");
}

void CChillPw::ConReload()
{
LoadPasswords();
}

void CChillPw::ConStatus()
Expand Down Expand Up @@ -135,6 +140,8 @@ void CChillPw::ConChillpw(IConsole::IResult *pResult, void *pUserData)

if(!str_comp_nocase(pResult->GetString(0), "dump_host"))
pSelf->ConDumpHost();
else if(!str_comp_nocase(pResult->GetString(0), "reload"))
pSelf->ConReload();
else
pSelf->ConStatus();
}
Expand Down Expand Up @@ -166,7 +173,7 @@ void CChillPw::OnRender()
}
}

void CChillPw::OnInit()
void CChillPw::LoadPasswords()
{
m_NumLoadedPasswords = 0;
IOHANDLE File = Storage()->OpenFile(g_Config.m_ClPasswordFile, IOFLAG_READ, IStorage::TYPE_ALL);
Expand All @@ -187,6 +194,11 @@ void CChillPw::OnInit()
return;
}

for(char *aPassword : m_aaPasswords)
aPassword[0] = '\0';
for(char *aHostname : m_aaHostnames)
aHostname[0] = '\0';

const char *pLine;
while((pLine = LineReader.Get()) && Line < MAX_PASSWORDS)
{
Expand Down Expand Up @@ -226,6 +238,11 @@ void CChillPw::OnInit()
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chillerbot", aBuf);
}

void CChillPw::OnInit()
{
LoadPasswords();
}

void CChillPw::SavePassword(const char *pServer, const char *pPassword)
{
IOHANDLE File = Storage()->OpenFile(g_Config.m_ClPasswordFile, IOFLAG_WRITE, IStorage::TYPE_SAVE);
Expand Down
3 changes: 3 additions & 0 deletions src/game/client/components/chillerbot/chillpw.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ class CChillPw : public CComponent
void OnInit() override;
void OnConsoleInit() override;

void LoadPasswords();

static void ConChillpw(IConsole::IResult *pResult, void *pUserData);

void ConStatus();
void ConDumpHost();
void ConReload();

bool AuthChatAccount(int Dummy, int Offset);
void SavePassword(const char *pServer, const char *pPassword);
Expand Down

0 comments on commit 0ca5a8d

Please sign in to comment.