diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-05-23 00:12:24 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-05-23 00:12:24 +0300 |
commit | e1a2b8f600ff9845ecff0f06c85d4d2c29970414 (patch) | |
tree | 6b948bf2bb238232f2d6faea84b70bafb8eaae89 /src/client.cpp | |
parent | 4a6b9a6ac1b07239474bce8d3ebf772ce75e862e (diff) | |
parent | a8a3271470299820c5322523dc439415bc1ff8a0 (diff) | |
download | minetest-e1a2b8f600ff9845ecff0f06c85d4d2c29970414.tar.gz minetest-e1a2b8f600ff9845ecff0f06c85d4d2c29970414.tar.bz2 minetest-e1a2b8f600ff9845ecff0f06c85d4d2c29970414.zip |
merged password change menu
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); |