aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/script/lua_api/l_mainmenu.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp
index ff0d52774..498ac0383 100644
--- a/src/script/lua_api/l_mainmenu.cpp
+++ b/src/script/lua_api/l_mainmenu.cpp
@@ -453,12 +453,11 @@ int ModApiMainMenu::l_get_favorites(lua_State *L)
int top_lvl2 = lua_gettop(L);
if (servers[i]["clients"].asString().size()) {
-
- const char* clients_raw = servers[i]["clients"].asString().c_str();
+ std::string clients_raw = servers[i]["clients"].asString();
char* endptr = 0;
- int numbervalue = strtol(clients_raw,&endptr,10);
+ int numbervalue = strtol(clients_raw.c_str(),&endptr,10);
- if ((*clients_raw != 0) && (*endptr == 0)) {
+ if ((clients_raw != "") && (*endptr == 0)) {
lua_pushstring(L,"clients");
lua_pushnumber(L,numbervalue);
lua_settable(L, top_lvl2);
@@ -467,11 +466,11 @@ int ModApiMainMenu::l_get_favorites(lua_State *L)
if (servers[i]["clients_max"].asString().size()) {
- const char* clients_max_raw = servers[i]["clients_max"].asString().c_str();
+ std::string clients_max_raw = servers[i]["clients_max"].asString();
char* endptr = 0;
- int numbervalue = strtol(clients_max_raw,&endptr,10);
+ int numbervalue = strtol(clients_max_raw.c_str(),&endptr,10);
- if ((*clients_max_raw != 0) && (*endptr == 0)) {
+ if ((clients_max_raw != "") && (*endptr == 0)) {
lua_pushstring(L,"clients_max");
lua_pushnumber(L,numbervalue);
lua_settable(L, top_lvl2);
@@ -480,7 +479,8 @@ int ModApiMainMenu::l_get_favorites(lua_State *L)
if (servers[i]["version"].asString().size()) {
lua_pushstring(L,"version");
- lua_pushstring(L,servers[i]["version"].asString().c_str());
+ std::string topush = servers[i]["version"].asString();
+ lua_pushstring(L,topush.c_str());
lua_settable(L, top_lvl2);
}
@@ -510,25 +510,29 @@ int ModApiMainMenu::l_get_favorites(lua_State *L)
if (servers[i]["description"].asString().size()) {
lua_pushstring(L,"description");
- lua_pushstring(L,servers[i]["description"].asString().c_str());
+ std::string topush = servers[i]["description"].asString();
+ lua_pushstring(L,topush.c_str());
lua_settable(L, top_lvl2);
}
if (servers[i]["name"].asString().size()) {
lua_pushstring(L,"name");
- lua_pushstring(L,servers[i]["name"].asString().c_str());
+ std::string topush = servers[i]["name"].asString();
+ lua_pushstring(L,topush.c_str());
lua_settable(L, top_lvl2);
}
if (servers[i]["address"].asString().size()) {
lua_pushstring(L,"address");
- lua_pushstring(L,servers[i]["address"].asString().c_str());
+ std::string topush = servers[i]["address"].asString();
+ lua_pushstring(L,topush.c_str());
lua_settable(L, top_lvl2);
}
if (servers[i]["port"].asString().size()) {
lua_pushstring(L,"port");
- lua_pushstring(L,servers[i]["port"].asString().c_str());
+ std::string topush = servers[i]["port"].asString();
+ lua_pushstring(L,topush.c_str());
lua_settable(L, top_lvl2);
}