summaryrefslogtreecommitdiff
path: root/src/serverlist.cpp
Commit message (Collapse)AuthorAge
* Server list cleanupShadowNinja2017-03-18
| | | | This removes the hacky server_dedicated pseudo-setting.
* Fixes for compiling with a newer (system) jsoncpp (#4429)Rogier-52016-08-10
| | | | | | | | | | | | | | | | | | | | | | | * Move included json code to jsoncpp subdirectory This is needed to avoid having to specify the minetest src directory as a system include when fixing the json includes. * Fix json includes They used "", so that the compiler searches the project's directory first. The result was that when compiling with a system jsoncpp, the project's own version of json.h was still included, instead of the system version. The includes now use <>, so a system location, or one specified with '-Ilocation' is searched only. * Fix for jsoncpp deprecated function warning When compiling with a newer version of jsoncpp (and ENABLE_SYSTEM_JSONCPP=true), jsoncpp emits a warning about a deprecated function that minetest uses.
* Add option to not send pre v25 init packetest312016-03-15
| | | | | | | | | | | | | | | | | The legacy init packet (pre v25) sends information about the client's password that a server could use to log in to other servers if the username and password are the same. All the other benefits of SRP of protocol v25 are missed if the legacy init packet is still sent during connection creation. This patch adds an option to not send the v25 init packet. Not sending the v25 packet means breaking compat with pre v25 servers, but as the option is not enabled by default, no servers are affected unless the user explicitly flips the switch. More than 90% of the servers on the serverlist support post v25 protocols. The patch also fixes a bug with greying out of non compliant servers being done wrongly, the min and max params were mixed.
* Change i++ to ++iDavid Jones2015-08-25
|
* Move globals from main.cpp to more sane locationsCraig Robbins2015-04-01
| | | | | | | | | | | | Move debug streams to log.cpp|h Move GUI-related globals to clientlauncher Move g_settings and g_settings_path to settings.cpp|h Move g_menuclouds to clouds.cpp|h Move g_profiler to profiler.cpp|h
* Clean up and tweak build systemShadowNinja2015-03-27
| | | | | | | | | | | | | | | | * Combine client and server man pages. * Update unit test options and available databases in man page. * Add `--worldname` to man page. * Fix a bunch of places where `"Minetest"` was used directly instead of `PROJECT_NAME`. * Disable server build by default on all operating systems. * Make `ENABLE_FREETYPE` not fail if FreeType isn't found. * Enable LevelDB, Redis, and FreeType detection by default. * Remove the `VERSION_PATCH_ORIG` hack. * Add option to search for and use system JSONCPP. * Remove broken LuaJIT version detection. * Rename `DISABLE_LUAJIT` to `ENABLE_LUAJIT`. * Rename `minetest_*` variables in `version.{h,cpp}` to `g_*`. * Clean up style of CMake files.
* Server: announce MIN/MAX protocol version supported to serverlist. Client: ↵est312015-02-18
| | | | | | | check serverlist Client now informs about incompatible servers from the list, this permits to prevent the protocol movements. Server announces its supported protocol versions to master server
* Send real port to server listShadowNinja2015-01-23
|
* Serverlist: announce mg_name from map_meta.txt instead of minetest.confKahrl2014-11-10
|
* Replace setting unlimited_player_transfer_distance with player_transfer_distanceSmallJoker2014-11-08
|
* Reduce indentation of HTTPFetchOngoingShadowNinja2014-09-18
| | | | Also clean up some related things.
* Fix serverlist code style, const-correctness, and typesShadowNinja2014-06-30
|
* Fix server list boolean typing and alignmentShadowNinja2014-06-30
|
* Add support for multipart/form-data to HTTPFetch for server announcingShadowNinja2014-06-30
|
* Remove ugly curl struct pointer from jsonFetchValue signaturesapier2014-06-19
|
* Remove a lot of superfluous ifndef USE_CURL checkssapier2014-06-19
|
* Remove liquid_finite and weatherproller2014-04-18
|
* Fix wrong named masterserver announce variableproller2014-01-07
|
* Send long announce as POST, show OS in useragentproller2014-01-07
| | | | | Add lag reporting to masterserver (average dtime) StyledWriter -> FastWriter in masterserver announce
* Use httpfetch_async in serverlist announce codeKahrl2013-12-13
|
* Rename names -> can_see_far_names in announceproller2013-12-03
|
* Remove link to #, add unlimited_player_transfer_distance to announceproller2013-12-03
|
* Correct useragent in http queriesproller2013-11-06
| | | | Net struct init
* Masterserver show privs and js autoloadproller2013-11-04
|
* Masterserver updateproller2013-10-18
|
* Show git hash in version string at top left corner of windowKahrl2013-09-28
|
* Dont write directly to files but rather write and copy a tmp filePilzAdam2013-08-13
|
* More info in serverlistproller2013-08-03
|
* Masterserver mods announse, ipv6, better curl errorsproller2013-07-13
|
* Replace C++ mainmenu by formspec powered onesapier2013-07-02
|
* Fix favorite Server List on WindowsSfan52013-05-04
|
* Fix serverlist on -DRUN_IN_PLACE=0 (use path_user instead of path_share)Zeg92013-04-25
|
* Masterserver: report gameid, uptime, cosmetic fixes on server web pageproller2013-03-30
|
* Add one more curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);Ilya Zhuravlev2013-03-03
|
* Fix "longjmp causes uninitialized stack frame" (serverlist.cpp)Ilya Zhuravlev2013-03-01
|
* Update Copyright YearsSfan52013-02-24
|
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
|
* new auto masterserverproller2013-02-22
|
* Add a list of servers to the "Multiplayer" tabJeija2013-01-21
If USE_CURL is set, it also downloads a list from a remote server. The url of this list is configurable in minetest.conf using the setting "serverlist_url" The local list of favorite servers is saved in client/serverlist/filename filename is also configureable using the setting "serverlist_file"
an class="hl com"> -- For static signals, this function should be completely omitted -- If this function is omitted, it won't be possible to use -- route setting on this signal. end, supported_aspects = { -- A table which tells which different types of aspects this signal -- is able to display. It is used to construct the "aspect editing" -- formspec for route programming (and others) It should always be -- present alongside with set_aspect. If this is not specified but -- set_aspect is, the user will be allowed to select any aspect. -- Any of the fields marked with <boolean/nil> support 3 types of values: nil: if this signal can switch between free/blocked false: always shows "blocked", unchangable true: always shows "free", unchangable -- Any of the "speed" fields should contain a list of possible values -- to be set as restriction. If omitted, the value of the described -- field is always assumed to be false (no information) -- A speed of 0 means that the signal can show a "blocked" aspect -- (which is probably the case for most signals) -- If the signal can signal "no information" on one of the fields -- (thus false is an acceptable value), include false in the list -- If your signal can only display a single speed (may it be -1), -- always enclose that single value into a list. (such as {-1}) main = {<speed1>, ..., <speedn>} or nil, dst = {<speed1>, ..., <speedn>} or nil, shunt = <boolean/nil>, call_on = <boolean/nil>, dead_end = <boolean/nil>, w_speed = {<speed1>, ..., <speedn>} or nil, }, Example for supported_aspects: supported_aspects = { main = {0, 6, -1}, -- can show either "Section blocked", "Proceed at speed 6" or "Proceed at maximum speed" dst = {0, false}, -- can show only if next signal shows "blocked", no other information. shunt = false, -- shunting by this signal is never allowed. call_on = false, dead_end = false, w_speed = nil, -- none of the information can be shown by the signal }, get_aspect = function(pos, node) -- This function gets called by the train safety system. It should return the aspect that this signal actually displays, not preferably the input of set_aspect. -- For regular, full-featured light signals, they will probably honor all entries in the original aspect, however, e.g. simple shunt signals always return main=false regardless of the set_aspect input because they can not signal "Halt" to train moves. -- advtrains.interlocking.DANGER contains a default "all-danger" aspect. -- If your signal does not cover certain sub-tables of the aspect, the following reasonable defaults are automatically assumed: main = false (unchanged) dst = false (unchanged) shunt = false (shunting not allowed) info = {} (no further information) end, } on_rightclick = advtrains.interlocking.signal_rc_handler can_dig = advtrains.interlocking.signal_can_dig after_dig_node = advtrains.interlocking.signal_after_dig (If you need to specify custom can_dig or after_dig_node callbacks, please call those functions anyway!) Important note: If your signal should support external ways to set its aspect (e.g. via mesecons), there are some things that need to be considered: - advtrains.interlocking.signal_get_supposed_aspect(pos) won't respect this - Whenever you change the signal aspect, and that aspect change did not happen through a call to advtrains.interlocking.signal_set_aspect(pos, asp), you are *required* to call this function: advtrains.interlocking.signal_on_aspect_changed(pos) in order to notify trains about the aspect change. This function will query get_aspect to retrieve the new aspect. ]]-- local DANGER = { main = 0, dst = false, shunt = false, } advtrains.interlocking.DANGER = DANGER advtrains.interlocking.GENERIC_FREE = { main = -1, shunt = false, dst = false, } local function convert_aspect_if_necessary(asp) if type(asp.main) == "table" then local newasp = {} if asp.main.free then newasp.main = asp.main.speed else newasp.main = 0 end if asp.dst and asp.dst.free then newasp.dst = asp.dst.speed else newasp.dst = 0 end newasp.proceed_as_main = asp.shunt.proceed_as_main newasp.shunt = asp.shunt.free -- Note: info table not transferred, it's not used right now return newasp end return asp end function advtrains.interlocking.update_signal_aspect(tcbs) if tcbs.signal then local asp = tcbs.aspect or DANGER advtrains.interlocking.signal_set_aspect(tcbs.signal, asp) end end function advtrains.interlocking.signal_can_dig(pos) return not advtrains.interlocking.db.get_sigd_for_signal(pos) end function advtrains.interlocking.signal_after_dig(pos) -- clear influence point advtrains.interlocking.db.clear_ip_by_signalpos(pos) end function advtrains.interlocking.signal_set_aspect(pos, asp) asp = convert_aspect_if_necessary(asp) local node=advtrains.ndb.get_node(pos) local ndef=minetest.registered_nodes[node.name] if ndef and ndef.advtrains and ndef.advtrains.set_aspect then ndef.advtrains.set_aspect(pos, node, asp) advtrains.interlocking.signal_on_aspect_changed(pos) end end -- should be called when aspect has changed on this signal. function advtrains.interlocking.signal_on_aspect_changed(pos) local ipts, iconn = advtrains.interlocking.db.get_ip_by_signalpos(pos) if not ipts then return end local ipos = minetest.string_to_pos(ipts) advtrains.invalidate_all_paths_ahead(ipos) end function advtrains.interlocking.signal_rc_handler(pos, node, player, itemstack, pointed_thing) local pname = player:get_player_name() local control = player:get_player_control() if control.aux1 then advtrains.interlocking.show_ip_form(pos, pname) return end local sigd = advtrains.interlocking.db.get_sigd_for_signal(pos) if sigd then advtrains.interlocking.show_signalling_form(sigd, pname) else local ndef = minetest.registered_nodes[node.name] if ndef.advtrains and ndef.advtrains.set_aspect then -- permit to set aspect manually local function callback(pname, aspect) advtrains.interlocking.signal_set_aspect(pos, aspect) end local isasp = ndef.advtrains.get_aspect(pos, node) advtrains.interlocking.show_signal_aspect_selector( pname, ndef.advtrains.supported_aspects, "Set aspect manually", callback, isasp) else --static signal - only IP advtrains.interlocking.show_ip_form(pos, pname) end end end -- Returns the aspect the signal at pos is supposed to show function advtrains.interlocking.signal_get_supposed_aspect(pos) local sigd = advtrains.interlocking.db.get_sigd_for_signal(pos) if sigd then local tcbs = advtrains.interlocking.db.get_tcbs(sigd) if tcbs.aspect then return convert_aspect_if_necessary(tcbs.aspect) end end return DANGER; end -- Returns the actual aspect of the signal at position, as returned by the nodedef. -- returns nil when there's no signal at the position function advtrains.interlocking.signal_get_aspect(pos) local node=advtrains.ndb.get_node(pos) local ndef=minetest.registered_nodes[node.name] if ndef and ndef.advtrains and ndef.advtrains.get_aspect then local asp = ndef.advtrains.get_aspect(pos, node) if not asp then asp = DANGER end return convert_aspect_if_necessary(asp) end return nil end -- Returns the "supported_aspects" of the signal at position, as returned by the nodedef. -- returns nil when there's no signal at the position function advtrains.interlocking.signal_get_supported_aspects(pos) local node=advtrains.ndb.get_node(pos) local ndef=minetest.registered_nodes[node.name] if ndef and ndef.advtrains and ndef.advtrains.supported_aspects then local asp = ndef.advtrains.supported_aspects return asp end return nil end local players_assign_ip = {} local function ipmarker(ipos, connid) local node_ok, conns, rhe = advtrains.get_rail_info_at(ipos, advtrains.all_tracktypes) if not node_ok then return end local yaw = advtrains.dir_to_angle(conns[connid].c) -- using tcbmarker here local obj = minetest.add_entity(vector.add(ipos, {x=0, y=0.2, z=0}), "advtrains_interlocking:tcbmarker") if not obj then return end obj:set_yaw(yaw) obj:set_properties({ textures = { "at_il_signal_ip.png" }, }) end -- shows small info form for signal IP state/assignment -- only_notset: show only if it is not set yet (used by signal tcb assignment) function advtrains.interlocking.show_ip_form(pos, pname, only_notset) if not minetest.check_player_privs(pname, "interlocking") then return end local form = "size[7,5]label[0.5,0.5;Signal at "..minetest.pos_to_string(pos).."]" local pts, connid = advtrains.interlocking.db.get_ip_by_signalpos(pos) if pts then form = form.."label[0.5,1.5;Influence point is set at "..pts.."/"..connid.."]" form = form.."button_exit[0.5,2.5; 5,1;set;Move]" form = form.."button_exit[0.5,3.5; 5,1;clear;Clear]" local ipos = minetest.string_to_pos(pts) ipmarker(ipos, connid) else form = form.."label[0.5,1.5;Influence point is not set.]" form = form.."label[0.5,2.0;It is recommended to set an influence point.]" form = form.."label[0.5,2.5;This is the point where trains will obey the signal.]" form = form.."button_exit[0.5,3.5; 5,1;set;Set]" end if not only_notset or not pts then minetest.show_formspec(pname, "at_il_ipassign_"..minetest.pos_to_string(pos), form) end end minetest.register_on_player_receive_fields(function(player, formname, fields) local pname = player:get_player_name() if not minetest.check_player_privs(pname, {train_operator=true, interlocking=true}) then return end local pts = string.match(formname, "^at_il_ipassign_([^_]+)$") local pos if pts then pos = minetest.string_to_pos(pts) end if pos then if fields.set then advtrains.interlocking.signal_init_ip_assign(pos, pname) elseif fields.clear then advtrains.interlocking.db.clear_ip_by_signalpos(pos) end end end) -- inits the signal IP assignment process function advtrains.interlocking.signal_init_ip_assign(pos, pname) if not minetest.check_player_privs(pname, "interlocking") then minetest.chat_send_player(pname, "Insufficient privileges to use this!") return end --remove old IP --advtrains.interlocking.db.clear_ip_by_signalpos(pos) minetest.chat_send_player(pname, "Configuring Signal: Please look in train's driving direction and punch rail to set influence point.") players_assign_ip[pname] = pos end minetest.register_on_punchnode(function(pos, node, player, pointed_thing) local pname = player:get_player_name() if not minetest.check_player_privs(pname, "interlocking") then return end -- IP assignment local signalpos = players_assign_ip[pname] if signalpos then if vector.distance(pos, signalpos)<=50 then local node_ok, conns, rhe = advtrains.get_rail_info_at(pos, advtrains.all_tracktypes) if node_ok and #conns == 2 then local yaw = player:get_look_horizontal() local plconnid = advtrains.yawToClosestConn(yaw, conns) -- add assignment if not already present. local pts = advtrains.roundfloorpts(pos) if not advtrains.interlocking.db.get_ip_signal_asp(pts, plconnid) then advtrains.interlocking.db.set_ip_signal(pts, plconnid, signalpos) ipmarker(pos, plconnid) minetest.chat_send_player(pname, "Configuring Signal: Successfully set influence point") else minetest.chat_send_player(pname, "Configuring Signal: Influence point of another signal is already present!") end else minetest.chat_send_player(pname, "Configuring Signal: This is not a normal two-connection rail! Aborted.") end else minetest.chat_send_player(pname, "Configuring Signal: Node is too far away. Aborted.") end players_assign_ip[pname] = nil end end) --== aspect selector ==-- local players_aspsel = {} --[[ suppasp: "supported_aspects" table purpose: form title string callback: func(pname, aspect) called on form submit isasp: aspect currently set ]] function advtrains.interlocking.show_signal_aspect_selector(pname, p_suppasp, p_purpose, callback, isasp) local suppasp = p_suppasp or { main = {0, -1}, dst = {false}, shunt = false, info = {}, } local purpose = p_purpose or "" local form = "size[7,5]label[0.5,0.5;Select Signal Aspect:]" form = form.."label[0.5,1;"..purpose.."]" form = form.."label[0.5,1.5;== Main Signal ==]" local selid = 1 local entries = {} for idx, spv in ipairs(suppasp.main) do local entry if spv == 0 then entry = "Halt" elseif spv == -1 then entry = "Continue at maximum speed" elseif not spv then entry = "Continue\\, speed limit unchanged (no info)" else entry = "Continue at speed of "..spv end -- hack: the crappy formspec system returns the label, not the index. save the index in it. entries[idx] = idx.."| "..entry if isasp and spv == (isasp.main or false) then selid = idx end end form = form.."dropdown[0.5,2;6;main;"..table.concat(entries, ",")..";"..selid.."]" form = form.."label[0.5,3;== Shunting ==]" if suppasp.shunt == nil then local st = 1 if isasp and isasp.shunt then st=2 end form = form.."dropdown[0.5,3.5;6;shunt_free;---,allowed;"..st.."]" end form = form.."button_exit[0.5,4.5; 5,1;save;OK]" local token = advtrains.random_id() minetest.show_formspec(pname, "at_il_sigaspdia_"..token, form) minetest.after(1, function() players_aspsel[pname] = { suppasp = suppasp, callback = callback, token = token, } end) end local function usebool(sup, val, free) if sup == nil then return val==free else return sup end end -- other side of hack: extract the index local function ddindex(val) return tonumber(string.match(val, "^(%d+)|")) end -- TODO use non-hacky way to parse outputs minetest.register_on_player_receive_fields(function(player, formname, fields) local pname = player:get_player_name() local psl = players_aspsel[pname] if psl then if formname == "at_il_sigaspdia_"..psl.token then if fields.save then local maini = ddindex(fields.main) if not maini then return end local asp = { main = psl.suppasp.main[maini], dst = false, shunt = usebool(psl.suppasp.shunt, fields.shunt_free, "allowed"), info = {} } psl.callback(pname, asp) end else players_aspsel[pname] = nil end end end)