object_use_texture_alpha = true,
object_independent_selectionbox = true,
httpfetch_binary_data = true,
+ formspec_version_element = true,
}
function core.has_feature(arg)
Elements
--------
+### `formspec_version[<version>]`
+
+* Set the formspec version to a certain number. If not specified,
+ version 1 is assumed.
+* Must be specified before `size` element.
+* Clients older than this version can neither show newer elements nor display
+ elements with new arguments correctly.
+* Available since feature `formspec_version_element`.
+
### `size[<W>,<H>,<fixed_size>]`
* Define the size of the menu in inventory slots
### `real_coordinates[<bool>]`
+* INFORMATION: Enable it automatically using `formspec_version` version 2 or newer.
* When set to true, all following formspec elements will use the new coordinate system.
* If used immediately after `size`, `position`, `anchor`, and `no_prepend` elements
(if present), the form size will use the new coordinate system.
image shall be sized 8 times 16px times 4 times 16px
* If `auto_clip` is `true`, the background is clipped to the formspec size
(`x` and `y` are used as offset values, `w` and `h` are ignored)
+* Available since formspec version 2
### `pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]`
-- Specifies whether binary data can be uploaded or downloaded using
-- the HTTP API (5.1.0)
httpfetch_binary_data = true,
+ -- Whether formspec_version[<version>] may be used (5.1.0)
+ formspec_version_element = true,
}
* `minetest.has_feature(arg)`: returns `boolean, missing_features`
avg_jitter = 0.03, -- average packet time jitter
connection_uptime = 200, -- seconds since client connected
protocol_version = 32, -- protocol version used by client
+ formspec_version = 2, -- supported formspec version
-- following information is available on debug build only!!!
-- DO NOT USE IN MODS
--ser_vers = 26, -- serialization version used by client
void Client::sendReady()
{
NetworkPacket pkt(TOSERVER_CLIENT_READY,
- 1 + 1 + 1 + 1 + 2 + sizeof(char) * strlen(g_version_hash));
+ 1 + 1 + 1 + 1 + 2 + sizeof(char) * strlen(g_version_hash) + 2);
pkt << (u8) VERSION_MAJOR << (u8) VERSION_MINOR << (u8) VERSION_PATCH
<< (u8) 0 << (u16) strlen(g_version_hash);
pkt.putRawString(g_version_hash, (u16) strlen(g_version_hash));
+ pkt << (u16)FORMSPEC_API_VERSION;
Send(&pkt);
}
float ypos = simple_singleplayer_mode ? 0.7f : 0.1f;
std::ostringstream os;
- os << FORMSPEC_VERSION_STRING << SIZE_TAG
+ os << FORMSPEC_VERSION_STRING << SIZE_TAG
<< "button_exit[4," << (ypos++) << ";3,0.5;btn_continue;"
<< strgettext("Continue") << "]";
if (element.empty())
return;
+ if (parseVersionDirect(element))
+ return;
+
std::vector<std::string> parts = split(element,'[');
// ugly workaround to keep compatibility
}
/* Copy of the "real_coordinates" element for after the form size. */
- mydata.real_coordinates = false;
+ mydata.real_coordinates = m_formspec_version >= 2;
for (; i < elements.size(); i++) {
std::vector<std::string> parts = split(elements[i], '[');
std::string name = trim(parts[0]);
if (enable_prepends) {
// Backup the coordinates so that prepends can use the coordinates of choice.
bool rc_backup = mydata.real_coordinates;
+ bool version_backup = m_formspec_version;
mydata.real_coordinates = false; // Old coordinates by default.
+
std::vector<std::string> prepend_elements = split(m_formspec_prepend, ']');
for (const auto &element : prepend_elements)
parseElement(&mydata, element);
+
+ m_formspec_version = version_backup;
mydata.real_coordinates = rc_backup; // Restore coordinates
}
private:
IFormSource *m_form_src;
TextDest *m_text_dst;
- u32 m_formspec_version = 0;
+ u16 m_formspec_version = 1;
std::string m_focused_element = "";
JoystickController *m_joystick;
void setForm(const std::string &formspec)
{
- m_formspec = FORMSPEC_VERSION_STRING + formspec;
+ m_formspec = formspec;
}
const std::string &getForm() const
PROTOCOL VERSION 38:
Incremental inventory sending mode
Unknown inventory serialization fields no longer throw an error
+ Mod-specific formspec version
*/
#define LATEST_PROTOCOL_VERSION 38
#define PASSWORD_SIZE 28 // Maximum password length. Allows for
// base64-encoded SHA-1 (27+\0).
-#define FORMSPEC_API_VERSION 1
+/*
+ Changes by FORMSPEC_API_VERSION:
+
+ FORMSPEC VERSION 1:
+ (too much)
+ FORMSPEC VERSION 2:
+ Forced real coordinates
+ background[]: 9-slice scaling parameters
+*/
+#define FORMSPEC_API_VERSION 2
#define FORMSPEC_VERSION_STRING "formspec_version[" TOSTRING(FORMSPEC_API_VERSION) "]"
#define TEXTURENAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.-"
peer_id, major_ver, minor_ver, patch_ver,
full_ver);
+ if (pkt->getRemainingBytes() >= 2)
+ *pkt >> playersao->getPlayer()->formspec_version;
+
const std::vector<std::string> &players = m_clients.getPlayerNames();
NetworkPacket list_pkt(TOCLIENT_UPDATE_PLAYER_LIST, 0, peer_id);
list_pkt << (u8) PLAYER_LIST_INIT << (u16) players.size();
u16 protocol_version = 0;
+ // v1 for clients older than 5.1.0-dev
+ u16 formspec_version = 1;
+
session_t getPeerId() const { return m_peer_id; }
void setPeerId(session_t peer_id) { m_peer_id = peer_id; }
lua_pushnumber(L, prot_vers);
lua_settable(L, table);
+ lua_pushstring(L, "formspec_version");
+ lua_pushnumber(L, player->formspec_version);
+ lua_settable(L, table);
+
#ifndef NDEBUG
lua_pushstring(L,"serialization_version");
lua_pushnumber(L, ser_vers);
void Server::SendShowFormspecMessage(session_t peer_id, const std::string &formspec,
const std::string &formname)
{
- NetworkPacket pkt(TOCLIENT_SHOW_FORMSPEC, 0 , peer_id);
+ NetworkPacket pkt(TOCLIENT_SHOW_FORMSPEC, 0, peer_id);
if (formspec.empty()){
//the client should close the formspec
//but make sure there wasn't another one open in meantime
pkt.putLongString("");
} else {
m_formspec_state_data[peer_id] = formname;
- pkt.putLongString(FORMSPEC_VERSION_STRING + formspec);
+ pkt.putLongString(formspec);
}
pkt << formname;
return;
NetworkPacket pkt(TOCLIENT_INVENTORY_FORMSPEC, 0, peer_id);
- pkt.putLongString(FORMSPEC_VERSION_STRING + player->inventory_formspec);
+ pkt.putLongString(player->inventory_formspec);
+
Send(&pkt);
}
return;
NetworkPacket pkt(TOCLIENT_FORMSPEC_PREPEND, 0, peer_id);
- pkt << FORMSPEC_VERSION_STRING + player->formspec_prepend;
+ pkt << player->formspec_prepend;
Send(&pkt);
}