Skip to content
Permalink
Browse files
new auto masterserver
  • Loading branch information
proller authored and Ilya Zhuravlev committed Feb 21, 2013
1 parent ef6b8be commit ee07c3f7cf638e854518d2cfcb9c11a64412cc72
Show file tree
Hide file tree
Showing 20 changed files with 6,919 additions and 49 deletions.
@@ -40,6 +40,8 @@ src/cguittfont/CMakeFiles/
src/cguittfont/libcguittfont.a
src/cguittfont/cmake_install.cmake
src/cguittfont/Makefile
src/json/CMakeFiles/
src/json/libjson.a
CMakeCache.txt
CPackConfig.cmake
CPackSourceConfig.cmake
@@ -0,0 +1,18 @@
# Look for json, use our own if not found

#FIND_PATH(JSON_INCLUDE_DIR json.h)

#FIND_LIBRARY(JSON_LIBRARY NAMES json)

#IF(JSON_LIBRARY AND JSON_INCLUDE_DIR)
# SET( JSON_FOUND TRUE )
#ENDIF(JSON_LIBRARY AND JSON_INCLUDE_DIR)

#IF(JSON_FOUND)
# MESSAGE(STATUS "Found system json header file in ${JSON_INCLUDE_DIR}")
# MESSAGE(STATUS "Found system json library ${JSON_LIBRARY}")
#ELSE(JSON_FOUND)
SET(JSON_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/json)
SET(JSON_LIBRARY json)
MESSAGE(STATUS "Using project json library")
#ENDIF(JSON_FOUND)
@@ -159,7 +159,7 @@
#media_fetch_threads = 8

# Url to the server list displayed in the Multiplayer Tab
#serverlist_url = servers.minetest.ru/server.list
#serverlist_url = servers.minetest.net
# File in client/serverlist/ that contains your favorite servers displayed in the Multiplayer Tab
#serverlist_file = favoriteservers.txt

@@ -172,6 +172,16 @@
# Server stuff
#

# Name of server
#server_name = Minetest server
# Description of server
#server_description = mine here
# Domain name of server
#server_address = game.minetest.net
# Homepage of server
#server_url = http://minetest.net
# Automaticaly report to masterserver
#server_announce = 0
# Default game (default when creating a new world)
#default_game = minetest
# World directory (everything in the world is stored here)
@@ -5,6 +5,7 @@ cmake_minimum_required( VERSION 2.6 )
mark_as_advanced(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
mark_as_advanced(JTHREAD_INCLUDE_DIR JTHREAD_LIBRARY)
mark_as_advanced(SQLITE3_INCLUDE_DIR SQLITE3_LIBRARY)
mark_as_advanced(JSON_INCLUDE_DIR JSON_LIBRARY)

option(ENABLE_CURL "Enable cURL support for fetching media" 1)

@@ -170,6 +171,7 @@ endif()

find_package(Jthread REQUIRED)
find_package(Sqlite3 REQUIRED)
find_package(Json REQUIRED)

if(USE_FREETYPE)
find_package(Freetype REQUIRED)
@@ -242,6 +244,7 @@ set(common_SRCS
biome.cpp
clientserver.cpp
staticobject.cpp
serverlist.cpp
util/serialize.cpp
util/directiontables.cpp
util/numeric.cpp
@@ -303,7 +306,6 @@ set(minetest_SRCS
filecache.cpp
tile.cpp
shader.cpp
serverlist.cpp
game.cpp
main.cpp
)
@@ -332,6 +334,7 @@ include_directories(
${JTHREAD_INCLUDE_DIR}
${SQLITE3_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
${JSON_INCLUDE_DIR}
)

if(USE_FREETYPE)
@@ -341,6 +344,12 @@ if(USE_FREETYPE)
)
endif(USE_FREETYPE)

if(USE_CURL)
include_directories(
${CURL_INCLUDE_DIR}
)
endif(USE_CURL)

set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")

if(BUILD_CLIENT)
@@ -359,18 +368,15 @@ if(BUILD_CLIENT)
${JTHREAD_LIBRARY}
${SQLITE3_LIBRARY}
${LUA_LIBRARY}
${JSON_LIBRARY}
${PLATFORM_LIBS}
${CLIENT_PLATFORM_LIBS}
)

if(USE_CURL)
target_link_libraries(
${PROJECT_NAME}
${CURL_LIBRARY}
)
include_directories(
${CURL_INCLUDE_DIR}
)
endif(USE_CURL)
if(USE_FREETYPE)
target_link_libraries(
@@ -388,12 +394,20 @@ if(BUILD_SERVER)
${ZLIB_LIBRARIES}
${JTHREAD_LIBRARY}
${SQLITE3_LIBRARY}
${JSON_LIBRARY}
${GETTEXT_LIBRARY}
${LUA_LIBRARY}
${PLATFORM_LIBS}
)
if(USE_CURL)
target_link_libraries(
${PROJECT_NAME}server
${CURL_LIBRARY}
)
endif(USE_CURL)
endif(BUILD_SERVER)


#
# Set some optimizations and tweaks
#
@@ -569,4 +583,9 @@ else (LUA_FOUND)
add_subdirectory(lua)
endif (LUA_FOUND)

if (JSON_FOUND)
else (JSON_FOUND)
add_subdirectory(json)
endif (JSON_FOUND)

#end
@@ -130,8 +130,13 @@ void set_default_settings(Settings *settings)

settings->setDefault("media_fetch_threads", "8");

settings->setDefault("serverlist_url", "servers.minetest.ru/server.list");
settings->setDefault("serverlist_url", "servers.minetest.net");
settings->setDefault("serverlist_file", "favoriteservers.txt");
settings->setDefault("server_announce", "false");
settings->setDefault("server_url", "");
settings->setDefault("server_address", "");
settings->setDefault("server_name", "");
settings->setDefault("server_description", "");

settings->setDefault("font_path", porting::getDataPath("fonts" DIR_DELIM "liberationsans.ttf"));
settings->setDefault("font_size", "13");
@@ -108,6 +108,7 @@ enum
GUI_ID_ENABLE_PARTICLES_CB,
GUI_ID_DAMAGE_CB,
GUI_ID_CREATIVE_CB,
GUI_ID_PUBLIC_CB,
GUI_ID_JOIN_GAME_BUTTON,
GUI_ID_CHANGE_KEYS_BUTTON,
GUI_ID_DELETE_WORLD_BUTTON,
@@ -562,6 +563,14 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
Environment->addCheckBox(m_data->enable_damage, rect, this, GUI_ID_DAMAGE_CB,
wgettext("Enable Damage"));
}
#if USE_CURL
{
core::rect<s32> rect(0, 0, 250, 30);
rect += m_topleft_server + v2s32(30+20+250+20, 60);
Environment->addCheckBox(m_data->enable_public, rect, this, GUI_ID_PUBLIC_CB,
wgettext("Public"));
}
#endif
// Delete world button
{
core::rect<s32> rect(0, 0, 130, 30);
@@ -841,6 +850,11 @@ void GUIMainMenu::readInput(MainMenuData *dst)
if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
dst->enable_damage = ((gui::IGUICheckBox*)e)->isChecked();
}
{
gui::IGUIElement *e = getElementFromId(GUI_ID_PUBLIC_CB);
if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
dst->enable_public = ((gui::IGUICheckBox*)e)->isChecked();
}
{
gui::IGUIElement *e = getElementFromId(GUI_ID_FANCYTREE_CB);
if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
@@ -912,8 +926,8 @@ void GUIMainMenu::readInput(MainMenuData *dst)
{
ServerListSpec server =
getServerListSpec(wide_to_narrow(dst->address), wide_to_narrow(dst->port));
dst->servername = server.name;
dst->serverdescription = server.description;
dst->servername = server["name"].asString();
dst->serverdescription = server["description"].asString();
}
}

@@ -1174,13 +1188,31 @@ void GUIMainMenu::updateGuiServerList()
i != m_data->servers.end(); i++)
{
std::string text;
if (i->name != "" && i->description != "")
text = i->name + " (" + i->description + ")";
else if (i->name !="")
text = i->name;
else
text = i->address + ":" + i->port;

if ((*i)["clients"].asString().size())
text += (*i)["clients"].asString();
if ((*i)["clients_max"].asString().size())
text += "/" + (*i)["clients_max"].asString();
text += " ";
if ((*i)["version"].asString().size())
text += (*i)["version"].asString() + " ";
if ((*i)["password"].asString().size())
text += "*";
if ((*i)["creative"].asString().size())
text += "C";
if ((*i)["damage"].asString().size())
text += "D";
if ((*i)["pvp"].asString().size())
text += "P";
text += " ";

if ((*i)["name"] != "" && (*i)["description"] != "")
text += (*i)["name"].asString() + " (" + (*i)["description"].asString() + ")";
else if ((*i)["name"] !="")
text += (*i)["name"].asString();
else
text += (*i)["address"].asString() + ":" + (*i)["port"].asString();

serverlist->addItem(narrow_to_wide(text).c_str());
}
}
@@ -1191,26 +1223,26 @@ void GUIMainMenu::serverListOnSelected()
{
gui::IGUIListBox *serverlist = (gui::IGUIListBox*)getElementFromId(GUI_ID_SERVERLIST);
u16 id = serverlist->getSelected();
if (id < 0) return;
//if (id < 0) return; // u16>0!
((gui::IGUIEditBox*)getElementFromId(GUI_ID_ADDRESS_INPUT))
->setText(narrow_to_wide(m_data->servers[id].address).c_str());
->setText(narrow_to_wide(m_data->servers[id]["address"].asString()).c_str());
((gui::IGUIEditBox*)getElementFromId(GUI_ID_PORT_INPUT))
->setText(narrow_to_wide(m_data->servers[id].port).c_str());
->setText(narrow_to_wide(m_data->servers[id]["port"].asString()).c_str());
}
}

ServerListSpec GUIMainMenu::getServerListSpec(std::string address, std::string port)
{
ServerListSpec server;
server.address = address;
server.port = port;
server["address"] = address;
server["port"] = port;
for(std::vector<ServerListSpec>::iterator i = m_data->servers.begin();
i != m_data->servers.end(); i++)
{
if (i->address == address && i->port == port)
if ((*i)["address"] == address && (*i)["port"] == port)
{
server.description = i->description;
server.name = i->name;
server["description"] = (*i)["description"];
server["name"] = (*i)["name"];
break;
}
}
@@ -55,6 +55,7 @@ struct MainMenuData
// Server options
bool creative_mode;
bool enable_damage;
bool enable_public;
int selected_world;
bool simple_singleplayer_mode;
// Actions
@@ -77,6 +78,7 @@ struct MainMenuData
// Server opts
creative_mode(false),
enable_damage(false),
enable_public(false),
selected_world(0),
simple_singleplayer_mode(false),
// Actions
@@ -0,0 +1,14 @@
if( UNIX )
set(json_SRCS jsoncpp.cpp)
set(json_platform_LIBS "")
else( UNIX )
set(json_SRCS jsoncpp.cpp)
set(json_platform_LIBS "")
endif( UNIX )

add_library(json ${json_SRCS})

target_link_libraries(
json
${json_platform_LIBS}
)
@@ -0,0 +1,16 @@
#!/bin/sh
cd ..
svn co https://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/trunk/jsoncpp jsoncpp
svn up jsoncpp
cd jsoncpp
python amalgamate.py
cp -R dist/json ..
cp dist/jsoncpp.cpp ../json

# maybe you need to patch:
# src/json/jsoncpp.cpp:
# -#include <json/json.h>
# +#include "json/json.h"

#svn export --force https://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/trunk/jsoncpp/src/lib_json json
#svn export --force https://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/trunk/jsoncpp/include/json json

0 comments on commit ee07c3f

Please sign in to comment.