diff options
author | Ciaran Gultnieks <ciaran@ciarang.com> | 2011-05-22 21:09:12 +0100 |
---|---|---|
committer | Ciaran Gultnieks <ciaran@ciarang.com> | 2011-05-22 21:09:12 +0100 |
commit | a8a3271470299820c5322523dc439415bc1ff8a0 (patch) | |
tree | a397578ce7032efe25298b4c653a3dcebd180579 /src/client.cpp | |
parent | e0329a3caee863a2302748f710401bfc0dfa78db (diff) | |
download | minetest-a8a3271470299820c5322523dc439415bc1ff8a0.tar.gz minetest-a8a3271470299820c5322523dc439415bc1ff8a0.tar.bz2 minetest-a8a3271470299820c5322523dc439415bc1ff8a0.zip |
Added the ability to change your password (via pause menu)
--HG--
extra : rebase_source : e8ec407f60711d42d33be4811b2880088f617b5b
Diffstat (limited to 'src/client.cpp')
-rw-r--r-- | src/client.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/client.cpp b/src/client.cpp index c85d6e9e2..5869dc77b 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1602,6 +1602,43 @@ void Client::sendChatMessage(const std::wstring &message) Send(0, data, true); } +void Client::sendChangePassword(const std::wstring oldpassword, + const std::wstring newpassword) +{ + Player *player = m_env.getLocalPlayer(); + if(player == NULL) + return; + + std::string playername = player->getName(); + std::string oldpwd = translatePassword(playername, oldpassword); + std::string newpwd = translatePassword(playername, newpassword); + + std::ostringstream os(std::ios_base::binary); + u8 buf[2+PASSWORD_SIZE*2]; + /* + [0] u16 TOSERVER_PASSWORD + [2] u8[28] old password + [30] u8[28] new password + */ + + writeU16(buf, TOSERVER_PASSWORD); + for(u32 i=0;i<PASSWORD_SIZE-1;i++) + { + buf[2+i] = i<oldpwd.length()?oldpwd[i]:0; + buf[30+i] = i<newpwd.length()?newpwd[i]:0; + } + buf[2+PASSWORD_SIZE-1] = 0; + buf[30+PASSWORD_SIZE-1] = 0; + os.write((char*)buf, 2+PASSWORD_SIZE*2); + + // Make data buffer + std::string s = os.str(); + SharedBuffer<u8> data((u8*)s.c_str(), s.size()); + // Send as reliable + Send(0, data, true); +} + + void Client::sendDamage(u8 damage) { DSTACK(__FUNCTION_NAME); |