Fix serverlist not beeing escaped correctly
authorsapier <Sapier at GMX dot net>
Mon, 8 Jul 2013 21:45:14 +0000 (23:45 +0200)
committerkwolekr <kwolekr@minetest.net>
Mon, 8 Jul 2013 23:58:17 +0000 (19:58 -0400)
Always use address for server
Fix first (empty) element beeing selected after deleting last world

builtin/mainmenu.lua
builtin/mainmenu_helper.lua
src/guiFormSpecMenu.cpp

index 30cff823e5b99a5335e13a12f32fac300b947d56..3e8ec60576669e30d85c45af41e43e6ce27b1f15 100644 (file)
@@ -52,12 +52,6 @@ function render_favourite(spec)
                details = details .. " "
        end
        
-       if spec.port ~= nil then
-               text = text .. ":" .. spec.port:trim()
-       else
-               text = text .. ":??"
-       end
-       
        return text
 end
 
@@ -119,6 +113,8 @@ function cleanup_path(temppath)
        return temppath
 end
 
+--------------------------------------------------------------------------------
+
 function menu.set_texture(identifier,gamedetails)
        local texture_set = false
        if menu.texturepack ~= nil then
@@ -696,10 +692,7 @@ function tabbuilder.handle_multiplayer_buttons(fields)
                end
                
                if event.typ == "CHG" then
-                       local address = menu.favorites[event.index].name
-                       if address == nil then
-                               address = menu.favorites[event.index].address
-                       end
+                       local address = menu.favorites[event.index].address
                        local port = menu.favorites[event.index].port
                        
                        if address ~= nil and
@@ -1137,8 +1130,7 @@ function tabbuilder.tab_multiplayer()
                        retval = retval .. "," .. render_favourite(menu.favorites[i])
                end
        end
-       
-       print("cfav: " .. dump(menu.fav_selected))
+
        if menu.fav_selected ~= nil then
                retval = retval .. ";" .. menu.fav_selected .. "]"
        else
@@ -1181,9 +1173,10 @@ function tabbuilder.tab_server()
                        retval = retval .. "," .. menu.worldlist[i].name .. 
                                                " \\[" .. menu.worldlist[i].gameid .. "\\]"
                end
+               retval = retval .. ";" .. index .. "]"
+       else
+               retval = retval .. ";0]"
        end
-                               
-       retval = retval .. ";" .. index .. "]"
                
        return retval
 end
@@ -1213,7 +1206,8 @@ end
 function tabbuilder.tab_singleplayer()
        local index = engine.setting_get("main_menu_singleplayer_world_idx")
 
-       if index == nil then
+       if index == nil or
+               #menu.filtered_game_list_raw() == 0 then
                index = 0
        end
 
index a204b4a37abf206d4a16ed8338ae14578a261590..25ad072fd43bf679e393ddc05aa09b32a0f12fad 100644 (file)
@@ -77,9 +77,11 @@ function fs_escape_string(text)
                        text = newtext
                end
                
-               text = text:gsub("%[","\\%[")
-               text = text:gsub("]","\\]")
-               text = text:gsub(";","\\;")
+               text = string.gsub(text,"\\","\\\\")
+               text = string.gsub(text,"%]","\\]")
+               text = string.gsub(text,"%[","\\[")
+               text = string.gsub(text,";","\\;")
+               text = string.gsub(text,",","\\,")
        end
        return text
 end
index abe519798ed404b34e997ae5d21e70cba8f80a8a..1a99d696be3d0a02b246daae8454f875a8c83f3b 100644 (file)
@@ -611,7 +611,7 @@ void GUIFormSpecMenu::parseTextList(parserData* data,std::string element) {
                std::vector<std::string> v_pos = split(parts[0],',');
                std::vector<std::string> v_geom = split(parts[1],',');
                std::string name = parts[2];
-               std::vector<std::string> items = split(parts[3],',');
+               std::vector<std::string> items = split(parts[3],',',true);
                std::string str_initial_selection = "";
                std::string str_transparent = "false";
 
@@ -1352,6 +1352,7 @@ void GUIFormSpecMenu::parseBox(parserData* data,std::string element) {
 }
 
 void GUIFormSpecMenu::parseElement(parserData* data,std::string element) {
+
        //some prechecks
        if (element == "")
                return;