From 0a568a6037a6e97ffff747fbb7bcb04d0f9c4b16 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Thu, 21 Mar 2013 19:45:13 +0200 Subject: Update buildwin32.sh to get minetest/common --- util/buildbot/buildwin32.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'util') diff --git a/util/buildbot/buildwin32.sh b/util/buildbot/buildwin32.sh index fc42db8a7..0c0d7cf21 100755 --- a/util/buildbot/buildwin32.sh +++ b/util/buildbot/buildwin32.sh @@ -53,6 +53,9 @@ cd $builddir wget http://github.com/minetest/minetest/zipball/master \ -c -O $packagedir/minetest.zip --tries=3 || (echo "Please download http://github.com/minetest/minetest/zipball/master manually and save it as $packagedir/minetest.zip"; read -s) [ -e $packagedir/minetest.zip ] || (echo "minetest.zip not found"; exit 1) +wget http://github.com/minetest/common/zipball/master \ + -c -O $packagedir/common.zip --tries=3 || (echo "Please download http://github.com/minetest/common/zipball/master manually and save it as $packagedir/common.zip"; read -s) +[ -e $packagedir/common.zip ] || (echo "common.zip not found"; exit 1) wget http://github.com/minetest/minetest_game/zipball/master \ -c -O $packagedir/minetest_game.zip --tries=3 || (echo "Please download http://github.com/minetest/minetest_game/zipball/master manually and save it as $packagedir/minetest_game.zip"; read -s) [ -e $packagedir/minetest_game.zip ] || (echo "minetest_game.zip not found"; exit 1) @@ -66,6 +69,7 @@ wget http://github.com/minetest/minetest_game/zipball/master \ minetestdirname=`unzip -l $packagedir/minetest.zip | head -n 7 | tail -n 1 | sed -e 's/^[^m]*//' -e 's/\/.*$//'` minetestdir=$builddir/$minetestdirname || exit 1 git_hash=`echo $minetestdirname | sed -e 's/minetest-minetest-//'` +commondirname=`unzip -l $packagedir/common.zip | head -n 7 | tail -n 1 | sed -e 's/^[^m]*//' -e 's/\/.*$//'` minetest_gamedirname=`unzip -l $packagedir/minetest_game.zip | head -n 7 | tail -n 1 | sed -e 's/^[^m]*//' -e 's/\/.*$//'` # Extract stuff @@ -86,6 +90,13 @@ unzip -o $packagedir/minetest.zip || exit 1 rm -rf $builddir/minetest ln -s $minetestdir $builddir/minetest +# Extract common +cd $minetestdir/games || exit 1 +rm -rf common || exit 1 +unzip -o $packagedir/common.zip || exit 1 +commondir=$minetestdir/games/$commondirname || exit 1 +mv $commondir $minetestdir/games/common || exit 1 + # Extract minetest_game cd $minetestdir/games || exit 1 rm -rf minetest_game || exit 1 -- cgit v1.2.3 From 16c11eb4a3bb46a388c645b7db738762e444cde8 Mon Sep 17 00:00:00 2001 From: proller Date: Sat, 30 Mar 2013 02:03:24 +0400 Subject: Masterserver: report gameid, uptime, cosmetic fixes on server web page --- src/server.cpp | 2 +- src/serverlist.cpp | 5 ++++- src/serverlist.h | 2 +- util/master/list.js | 36 ++++++++++++++++++------------------ util/master/master.cgi | 5 +++++ 5 files changed, 29 insertions(+), 21 deletions(-) (limited to 'util') diff --git a/src/server.cpp b/src/server.cpp index 6bdebcec4..c4dd0ab0f 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1243,7 +1243,7 @@ void Server::AsyncRunStep() float &counter = m_masterserver_timer; if((!counter || counter >= 300.0) && g_settings->getBool("server_announce") == true) { - ServerList::sendAnnounce(!counter ? "start" : "update", m_clients_number); + ServerList::sendAnnounce(!counter ? "start" : "update", m_clients_number, m_uptime.get(), m_gamespec.id); counter = 0.01; } counter += dtime; diff --git a/src/serverlist.cpp b/src/serverlist.cpp index 3dfc79f50..93f9d2435 100644 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -232,7 +232,7 @@ static size_t ServerAnnounceCallback(void *contents, size_t size, size_t nmemb, //((std::string*)userp)->append((char*)contents, size * nmemb); //return size * nmemb; } -void sendAnnounce(std::string action, u16 clients) { +void sendAnnounce(std::string action, u16 clients, double uptime, std::string gameid) { Json::Value server; if (action.size()) server["action"] = action; @@ -250,6 +250,9 @@ void sendAnnounce(std::string action, u16 clients) { server["pvp"] = g_settings->getBool("enable_pvp"); server["clients"] = clients; server["clients_max"] = g_settings->get("max_users"); + if (uptime >=1) server["uptime"] = (int)uptime; + if (gameid!="") server["gameid"] = gameid; + } if(server["action"] == "start") actionstream << "announcing to " << g_settings->get("serverlist_url") << std::endl; diff --git a/src/serverlist.h b/src/serverlist.h index e81e64c5b..d01415c50 100644 --- a/src/serverlist.h +++ b/src/serverlist.h @@ -39,7 +39,7 @@ namespace ServerList std::vector deSerializeJson(std::string liststring); std::string serializeJson(std::vector); #if USE_CURL - void sendAnnounce(std::string action = "", u16 clients = 0); + void sendAnnounce(std::string action = "", u16 clients = 0, double uptime = 0, std::string gameid = ""); #endif } //ServerList namespace diff --git a/util/master/list.js b/util/master/list.js index dcc30e091..18cbc4b68 100644 --- a/util/master/list.js +++ b/util/master/list.js @@ -2,11 +2,12 @@ function e(s) { if (typeof s === "undefined") s = ''; return s.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); //mc" } -function human_time(t) { + +function human_time(t, abs) { var n = 's'; if (!t || t < 0) t = 0; var f = 0; - var s = parseInt((new Date().getTime() / 1000 - (t || 0))); + var s = parseInt(abs ? (t || 0) : (new Date().getTime() / 1000 - (t || 0))); if (!s || s <= 0) s = 0; if (s == 0) return 'now'; if (s >= 60) { @@ -35,38 +36,37 @@ function human_time(t) { } return ((f ? parseFloat(s).toFixed(1) : parseInt(s)) + n); } + function success(r) { if (!r || !r.list) return; - var h = ''; + var h = '
ip:portclients, maxversionnamedescflagsupdated/startedping
'; for (var i = 0; i < r.list.length; ++i) { var s = r.list[i]; if (!s) continue; - h += ''; - h += ''; - h += ''; - h += ''; - h += ''; + h += ''; + h += ''; + h += ''; + h += ''; - h += ''; - h += ''; + h += ''; + h += ''; if (!s.time || s.time < 0) s.time = 0; if (!s.start || s.start < 0) s.start = 0; - h += ''; - h += ''; + h += ''; + h += ''; h += ''; } h += '
ip[:port]clients/maxversion gameidnamedescflagsuptimeping
' + e(s.address) + ':' + e(s.port) + '' + e(s.clients) + (s.clients_max ? '/' + e(s.clients_max) : '') + (s.clients_top ? ', ' + s.clients_top : '') + '' + e(s.version) + ''; + h += '
' + e(s.address) + (s.port != 30000 ? (':' + e(s.port)) : '') + '' + e(s.clients) + (s.clients_max ? '/' + e(s.clients_max) : '') + (s.clients_top ? ', ' + s.clients_top : '') + '' + e(s.version) + ' ' + e(s.gameid) + ''; if (s.url) h += ''; h += e(s.name || s.url); if (s.url) h += ''; h += '' + e(s.description) + '' + e(s.password ? 'Pwd ' : '') + (s.creative ? 'Cre ' : '') + (s.damage ? 'Dmg ' : '') + (s.pvp ? 'Pvp ' : '') + (s.dedicated ? 'Ded ' : '') + '' + e(s.description) + '' + e(s.password ? 'Pwd ' : '') + (s.creative ? 'Cre ' : '') + (s.damage ? 'Dmg ' : '') + (s.pvp ? 'Pvp ' : '') + (s.dedicated ? 'Ded ' : '') + '' + human_time(s.time) + (s.start ? '/' + human_time(s.start) : '') + '' + (s.ping ? parseFloat(s.ping).toFixed(3)*1000 : '') + '' + (s.uptime ? human_time(s.uptime, 1) : '') + '' + (s.ping ? parseFloat(s.ping).toFixed(3) * 1000 : '') + '
' jQuery('#table').html(h); } +var master_root; + function get() { - jQuery.ajax({ - url: 'list', - dataType: 'json', - success: success - }); + jQuery.getJSON((master_root || '') + 'list', success); setTimeout(get, 60000); } -get(); \ No newline at end of file +get(); diff --git a/util/master/master.cgi b/util/master/master.cgi index b918876bd..0e456ed0c 100755 --- a/util/master/master.cgi +++ b/util/master/master.cgi @@ -18,6 +18,7 @@ nginx: location / { index index.html; + add_header Access-Control-Allow-Origin *; } location /announce { fastcgi_pass unix:/var/run/fcgiwrap/fcgiwrap.sock; @@ -35,6 +36,10 @@ apache .htaccess: Allow from all Deny from all + + Header set Access-Control-Allow-Origin: * + + =cut -- cgit v1.2.3 From 177ca4f4d55368718eb295f1010ad5c81660af57 Mon Sep 17 00:00:00 2001 From: proller Date: Sat, 30 Mar 2013 02:36:06 +0400 Subject: Fix backward compatibility for server uptime in master server web page --- util/master/list.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'util') diff --git a/util/master/list.js b/util/master/list.js index 18cbc4b68..990bb6ded 100644 --- a/util/master/list.js +++ b/util/master/list.js @@ -54,9 +54,8 @@ function success(r) { h += ''; h += '' + e(s.description) + ''; h += '' + e(s.password ? 'Pwd ' : '') + (s.creative ? 'Cre ' : '') + (s.damage ? 'Dmg ' : '') + (s.pvp ? 'Pvp ' : '') + (s.dedicated ? 'Ded ' : '') + ''; - if (!s.time || s.time < 0) s.time = 0; if (!s.start || s.start < 0) s.start = 0; - h += '' + (s.uptime ? human_time(s.uptime, 1) : '') + ''; + h += '' + (s.uptime ? human_time(s.uptime, 1) : s.start ? human_time(s.start) : '') + ''; h += '' + (s.ping ? parseFloat(s.ping).toFixed(3) * 1000 : '') + ''; h += ''; } -- cgit v1.2.3