diff options
author | kwolekr <kwolekr@minetest.net> | 2015-05-19 02:24:14 -0400 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2015-05-19 16:10:49 -0400 |
commit | da34a2b33e1f600ec11172f599384b9a92835403 (patch) | |
tree | f09a158be783f0486447d0c61750a7509760d83b /src/script/cpp_api/s_player.cpp | |
parent | 603297cc352cab685dd01dcd645999624ad17c0b (diff) | |
download | hax-minetest-server-da34a2b33e1f600ec11172f599384b9a92835403.tar.gz hax-minetest-server-da34a2b33e1f600ec11172f599384b9a92835403.zip |
Replace instances of std::map<std::string, std::string> with StringMap
Also, clean up surrounding code style
Replace by-value parameter passing with const refs when possible
Fix post-increment of iterators
Diffstat (limited to '')
-rw-r--r-- | src/script/cpp_api/s_player.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/script/cpp_api/s_player.cpp b/src/script/cpp_api/s_player.cpp index d56766824..9b2c3753c 100644 --- a/src/script/cpp_api/s_player.cpp +++ b/src/script/cpp_api/s_player.cpp @@ -83,7 +83,10 @@ bool ScriptApiPlayer::on_respawnplayer(ServerActiveObject *player) return positioning_handled_by_some; } -bool ScriptApiPlayer::on_prejoinplayer(std::string name, std::string ip, std::string &reason) +bool ScriptApiPlayer::on_prejoinplayer( + const std::string &name, + const std::string &ip, + std::string *reason) { SCRIPTAPI_PRECHECKHEADER @@ -94,7 +97,7 @@ bool ScriptApiPlayer::on_prejoinplayer(std::string name, std::string ip, std::st lua_pushstring(L, ip.c_str()); script_run_callbacks(L, 2, RUN_CALLBACKS_MODE_OR); if (lua_isstring(L, -1)) { - reason.assign(lua_tostring(L, -1)); + reason->assign(lua_tostring(L, -1)); return true; } return false; @@ -142,7 +145,7 @@ void ScriptApiPlayer::on_cheat(ServerActiveObject *player, void ScriptApiPlayer::on_playerReceiveFields(ServerActiveObject *player, const std::string &formname, - const std::map<std::string, std::string> &fields) + const StringMap &fields) { SCRIPTAPI_PRECHECKHEADER @@ -156,17 +159,19 @@ void ScriptApiPlayer::on_playerReceiveFields(ServerActiveObject *player, lua_pushstring(L, formname.c_str()); // param 3 lua_newtable(L); - for(std::map<std::string, std::string>::const_iterator - i = fields.begin(); i != fields.end(); i++){ - const std::string &name = i->first; - const std::string &value = i->second; + StringMap::const_iterator it; + for (it = fields.begin(); it != fields.end(); ++it) { + const std::string &name = it->first; + const std::string &value = it->second; lua_pushstring(L, name.c_str()); lua_pushlstring(L, value.c_str(), value.size()); lua_settable(L, -3); } script_run_callbacks(L, 3, RUN_CALLBACKS_MODE_OR_SC); } -ScriptApiPlayer::~ScriptApiPlayer() { + +ScriptApiPlayer::~ScriptApiPlayer() +{ } |