diff --git a/heart/heartbeat.py b/heart/heartbeat.py index c634319..9214b49 100644 --- a/heart/heartbeat.py +++ b/heart/heartbeat.py @@ -115,7 +115,7 @@ class HTTPClient: s += "" s += "" + sanestr(d["address"]) + "" s += "" + sanestr(d["port"]) + "" - s += "" + sanestr(d["name"]) + "" + s += "" + "" + sanestr(d["name"]) + "" + "" s += "" + sanestr(d["version"]) + "" s += "" + sanestr(d["players_current"]) + " / " + sanestr(d["players_max"]) + "" s += "" + sanestr(d["mode"]) + "" diff --git a/include/common.h b/include/common.h index 920cb30..66d05dc 100644 --- a/include/common.h +++ b/include/common.h @@ -19,7 +19,7 @@ #define VERSION_X 1 #define VERSION_Y 1 #define VERSION_A 0 -#define VERSION_Z 7 +#define VERSION_Z 8 // Remember to bump "Z" basically every time you change the engine! // Remember to bump the version in Lua too! // Remember to document API changes in a new version! @@ -467,6 +467,7 @@ extern int force_redraw; extern int net_port; extern char *net_addr; +extern char net_addr_xbuf[]; extern int boot_mode; extern char *mod_basedir; diff --git a/pkg/base/lib_util.lua b/pkg/base/lib_util.lua index 3738c14..2e4424b 100644 --- a/pkg/base/lib_util.lua +++ b/pkg/base/lib_util.lua @@ -101,12 +101,15 @@ function string.trim(s, sep) return string.triml(string.trimr(s, sep), sep) end -function parse_commandline_options(options) - local user_toggles = {} -- toggle options (key is name, value is position) - local user_settings = {} -- key-value pairs - local loose = {} -- loose strings, filenames, etc. +function parse_commandline_options(options, nocheckdash, na, nb, nc) + local loose = na or {} -- loose strings, filenames, etc. + local user_toggles = nb or {} -- toggle options (key is name, value is position) + local user_settings = nc or {} -- key-value pairs for k, v in pairs(options) do + if nocheckdash then + v = "-" .. v + end local setting_pair = string.split(v, "=") local first = string.byte(v,1) if first==string.byte('-') then -- we are toggling an option or setting a value @@ -116,6 +119,17 @@ function parse_commandline_options(options) else user_toggles[string.triml(v, '-')]=k end + elseif first == string.byte('/') then -- optional extra arg on URI + -- look for a ? thing + local npair = string.split(v:sub(2), "?") + if npair[1] ~= "" then + user_settings[" "] = npair[1] + end + if npair[2] then + -- TODO: URI-decode + local nopts = string.split(npair[2], "&") + parse_commandline_options(nopts, true, loose, user_toggles, user_settings) + end else -- add to the loose values loose[#loose+1] = v end diff --git a/pkg/base/version.lua b/pkg/base/version.lua index 928ebcf..49d4870 100644 --- a/pkg/base/version.lua +++ b/pkg/base/version.lua @@ -16,9 +16,9 @@ ]] VERSION_ENGINE = { - cmp={0,1,1,0,5}, - num=4227072+5, - str="0.1.1-5", + cmp={0,1,1,0,8}, + num=4227072+8, + str="0.1.1-8", } -- 0.1: 4194304 @@ -108,5 +108,6 @@ VERSION_BUGS = { {renderer="softgm", intro=4227072+5, fix=4227072+7, msg="[softgm] Image scaling not supported"}, {intro=4227072+5, fix=4227072+6, msg="Image scaling accidentally only supported integers for scale parameters"}, {intro=4227072+5, fix=4227072+7, msg="Incompatible semantics for image scaling"}, +{intro=nil, fix=4227072+8, msg="iceball:// URL scheme not supported"}, } diff --git a/src/lua.c b/src/lua.c index 90a84cd..d9ac857 100644 --- a/src/lua.c +++ b/src/lua.c @@ -289,6 +289,11 @@ int icelua_initfetch(void) printf("Client loaded! Initialising...\n"); for(i = 0; i < argct; i++) lua_pushstring(lstate_client, main_argv[i+main_largstart]); + if((boot_mode & 1) && net_addr_xbuf[1] != '\x00') + { + lua_pushstring(lstate_client, net_addr_xbuf); + argct++; + } if(lua_pcall(lstate_client, argct, 0, 0) != 0) { printf("ERROR running client Lua: %s\n", lua_tostring(lstate_client, -1)); diff --git a/src/main.c b/src/main.c index 6206b79..c24d62a 100644 --- a/src/main.c +++ b/src/main.c @@ -46,6 +46,8 @@ int boot_mode = 0; char *mod_basedir = NULL; char *net_addr; +char net_addr_buf[1024]; +char net_addr_xbuf[1024]; int net_port; int main_argc; @@ -564,8 +566,10 @@ int print_usage(char *rname) fprintf(stderr, "usage:\n" #ifndef DEDI "\tfor clients:\n" - "\t\t%s -c address port {clargs} <-- connect via ENet protocol (UDP)\n" - "\t\t%s -C address port {clargs} <-- connect via TCP protocol\n" + "\t\t%s -c iceball://address:port {clargs} <-,_ connect via ENet protocol (UDP)\n" + "\t\t%s -c address port {clargs} <-'\n" + "\t\t%s -C iceball://address:port {clargs} <-,_ connect via TCP protocol\n" + "\t\t%s -C address port {clargs} <-'\n" "\tfor servers (quick-start, not recommended for anything serious!):\n" "\t\t%s -s port mod {args}\n" #endif @@ -590,7 +594,7 @@ int print_usage(char *rname) #endif "\targs: arguments to send to the server Lua script\n" #ifndef DEDI - ,rname,rname,rname + ,rname,rname,rname,rname,rname #endif ,rname,rname); @@ -630,25 +634,45 @@ int main_dbghelper(int argc, char *argv[]) if((!strcmp(argv[1], "-h")) || (!strcmp(argv[1], "/?")) || (!strcmp(argv[1], "-?")) || (!strcmp(argv[1], "--help"))) { return print_usage(argv[0]); } else if(!strcmp(argv[1], "-c")) { - if(argc <= 3) + if(argc <= 2 || (argc <= 3 && memcmp(argv[2], "iceball://", 10))) return print_usage(argv[0]); - net_addr = argv[2]; - net_port = atoi(argv[3]); + net_port = 20737; + main_largstart = 3; + net_addr = net_addr_buf; + net_addr_xbuf[0] = '/'; + net_addr_xbuf[1] = '\x00'; + if(sscanf(argv[2], "iceball://%[^:]:%i/%s", net_addr, &net_port, &net_addr_xbuf[1]) < 1) + { + if(argc <= 3) + return print_usage(argv[0]); + net_addr = argv[2]; + net_port = atoi(argv[3]); + main_largstart = 4; + } printf("Connecting to \"%s\" port %i (ENet mode)\n", net_addr, net_port); mod_basedir = NULL; - main_largstart = 4; boot_mode = 1 | 16; } else if(!strcmp(argv[1], "-C")) { - if(argc <= 3) + if(argc <= 2 || (argc <= 3 && memcmp(argv[2], "iceball://", 10))) return print_usage(argv[0]); - net_addr = argv[2]; - net_port = atoi(argv[3]); + net_port = 20737; + main_largstart = 3; + net_addr = net_addr_buf; + net_addr_xbuf[0] = '/'; + net_addr_xbuf[1] = '\x00'; + if(sscanf(argv[2], "iceball://%[^:]:%i/%s", net_addr, &net_port, &net_addr_xbuf[1]) < 1) + { + if(argc <= 3) + return print_usage(argv[0]); + net_addr = argv[2]; + net_port = atoi(argv[3]); + main_largstart = 4; + } printf("Connecting to \"%s\" port %i (TCP mode)\n", net_addr, net_port); mod_basedir = NULL; - main_largstart = 4; boot_mode = 1; //return 101; diff --git a/url-set-unix-gnome.sh b/url-set-unix-gnome.sh new file mode 100755 index 0000000..446a3be --- /dev/null +++ b/url-set-unix-gnome.sh @@ -0,0 +1,5 @@ +#!/bin/sh +gconftool-2 -s /desktop/gnome/url-handlers/iceball/command "$(pwd)/iceball-gl -c %s" --type String +gconftool-2 -s /desktop/gnome/url-handlers/iceball/enabled --type Boolean true +gconftool-2 -s /desktop/gnome/url-handlers/iceball/needs-terminal --type Boolean true +