Compare commits

...

45 Commits

Author SHA1 Message Date
zaoqi 3d64507ac3 on_add_node 2017-08-29 14:22:13 +08:00
zaoqi ce0ab6cc16 修复 2017-08-19 21:59:15 +08:00
zaoqi 13f1e60af5 修复minetest.send_damage(damage) 2017-07-30 17:11:52 +08:00
zaoqi 565a6749ae 支持快速移动 2017-07-30 14:27:03 +08:00
zaoqi 8234903374 修复 2017-07-29 12:32:27 +08:00
zaoqi e4c7012246 minetest.dig_node(pos) 2017-07-06 16:33:33 +08:00
zaoqi deeee5e453 minetest.punch_all() 2017-07-05 21:43:38 +08:00
zaoqi ae25322acc lock_pos,min-damage,punch_last 2017-07-03 16:51:39 +08:00
zaoqi 5a53ee48eb 客户端:minetest.send_damage(damage) 2017-06-18 19:18:52 +08:00
zaoqi aee5cfa626 客户端:minetest.set_node(pos) 2017-06-18 18:06:59 +08:00
zaoqi 6e9ed10ace 客户端:minetest.show_node(pos, node) 2017-06-18 16:20:05 +08:00
zaoqi 342516c010 不死 2017-06-17 15:10:47 +08:00
zaoqi 195620363b 使客户端认为得到所有权限 2017-06-16 22:19:13 +08:00
ShadowNinja caecdb681c Merge 0.4.16 into stable-0.4 2017-06-03 14:55:10 -04:00
est31 81d56b9491 Merge 0.4.15 changes into stable-0.4
0.4.15 release!
2016-12-22 23:16:00 +01:00
est31 8077612dcb Merge 0.4.14 changes into stable-0.4
0.4.14 release!
2016-05-15 15:20:25 +02:00
est31 07fddf1f6c Merge 0.4.13 changes into stable-0.4
0.4.13 release!
2015-08-20 21:02:42 +02:00
Loic Blot 315b00d150 Bump android version code 2015-03-16 20:37:07 +01:00
est31 0c0248a19c Android: Fix auto-entry of server address and port in mainmenu
Fixes #2497.
2015-03-16 19:46:54 +01:00
Loic Blot 0429ec4cfd Android: update makefile and backport language fix from master 2015-03-15 11:01:39 +01:00
Craig Robbins a740a48f62 Fix narrow_to_wide_c (ANDROID)
* Ensure converted string is NUL terminated
* Restore logic to that used prior to 9e2a9b5
2015-03-15 10:17:09 +01:00
Loic Blot b12f569fc6 Releasing android 2015-03-14 19:57:21 +01:00
Perttu Ahola 7993a403f2 Bump version to 0.4.12 2015-02-18 19:50:37 +02:00
Novatux b0df67d9c0 Add modname convention checking
Fixes #2037
2015-02-18 17:06:09 +01:00
Loic Blot 45ff8569d7 Fix serverlist include 2015-02-18 16:26:23 +01:00
est31 82bfa2ee7b Server: announce MIN/MAX protocol version supported to serverlist. Client: 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
2015-02-18 16:17:03 +01:00
fz72 9ef2e5000f Fix map_seed not changed when creating a new world after login to another 2015-02-18 14:02:30 +02:00
BlockMen 678546308e Increase default font_size 2015-02-18 12:59:16 +01:00
BlockMen 6f688c50ee Fix font_size under windows 2015-02-18 12:59:07 +01:00
Perttu Ahola bb603ff18e Use fixed size for builtin menus on non-android platforms 2015-02-18 13:57:54 +02:00
Loic Blot 4208fdfd22 Fix unused (and so, broken) enable_rollback_recording. This option must be reloaded at server loop but loaded when server starts, for data consistency (not a hot load variable) 2015-02-18 09:36:42 +01:00
Kahrl 4875213168 Grab GUIChatConsole::m_font, fixes segfault when changing font_size 2015-02-18 00:40:11 +10:00
Loic Blot f92540e8ad Add german and french translation for minetest.desktop
This fixes #1573
2015-02-14 13:12:08 +01:00
Jakub Vaněk ec0bf899ed Update czech translation 2015-02-14 13:11:50 +01:00
ngosang 2b635a892c Minor fixes in translations 2015-02-14 13:11:33 +01:00
Loic Blot 7f6fc148bd Fix issue #2279. ok @zeno- 2015-02-14 21:02:19 +10:00
ngosang 878e9f7594 Fix .zip extraction (mod store) 2015-02-14 21:00:13 +10:00
Rui c7249f5983 Fix store.lua bug: default screenshot 2015-02-14 21:00:06 +10:00
Rui 7f07858209 Fix tab_mods.lua: default screenshot patch
https://forum.minetest.net/viewtopic.php?f=6&t=11201
Fixed this bug.
2015-02-14 21:00:01 +10:00
ShadowNinja 9e9688fc61 Fix Android build of narrow_to_wide 2015-02-14 20:59:45 +10:00
Markus Koschany 93e5ab367a Fix FTBFS on GNU/Hurd platform
Minetest fails to build on GNU/Hurd due to a name clash with OSX/Apple,
both are defining the __MACH__ keyword. This commit fixes the issue.
2015-02-14 20:59:35 +10:00
est31 60fa5807b9 README.txt: Simplify initial build steps by using git to fetch sources
Also simplify wget steps and apt-get install zlib1g-dev libjsoncpp-dev
2015-02-14 20:59:00 +10:00
ngosang 9dbca41385 Fix Exit to OS button focus in Pause Menu 2015-02-14 20:58:39 +10:00
est31 61588a43dd Fix crash on passing false as value in table to table.copy(t)
Fixes #2293.
2015-02-14 15:24:09 +10:00
BlockMen e62927ed71 Fix gettext on MSVC 2015-02-13 01:23:30 +10:00
12 changed files with 229 additions and 19 deletions

View File

@ -60,6 +60,13 @@ core.register_chatcommand("clear_chat_queue", {
end,
})
core.register_chatcommand("respawn", {
description = core.gettext("Respawn"),
func = function(param)
core.send_respawn()
end,
})
function core.run_server_chatcommand(cmd, param)
core.send_chat_message("/" .. cmd .. " " .. param)
end

View File

@ -10,14 +10,5 @@ dofile(clientpath .. "chatcommands.lua")
dofile(commonpath .. "vector.lua")
core.register_on_death(function()
core.display_chat_message("You died.")
local formspec = "size[11,5.5]bgcolor[#320000b4;true]" ..
"label[4.85,1.35;" .. fgettext("You died.") .. "]button_exit[4,3;3,0.5;btn_respawn;".. fgettext("Respawn") .."]"
core.show_formspec("bultin:death", formspec)
end)
core.register_on_formspec_input(function(formname, fields)
if formname == "bultin:death" then
core.send_respawn()
end
core.display_chat_message("You died.Respawn: .respawn")
end)

View File

@ -71,3 +71,5 @@ core.registered_on_dignode, core.register_on_dignode = make_registration()
core.registered_on_punchnode, core.register_on_punchnode = make_registration()
core.registered_on_placenode, core.register_on_placenode = make_registration()
core.registered_on_item_use, core.register_on_item_use = make_registration()
core.registered_on_add_node, core.register_on_add_node = make_registration()

View File

@ -639,6 +639,7 @@ Minetest namespace reference
### Global callback registration functions
Call these functions only at load time!
* `minetest.register_on_add_node(func(pos, node))`
* `minetest.register_globalstep(func(dtime))`
* Called every client environment step, usually interval of 0.1s
* `minetest.register_on_shutdown(func())`
@ -700,6 +701,9 @@ Call these functions only at load time!
* Returns the time of day: `0` for midnight, `0.5` for midday
### Map
* `minetest.set_node(pos)`
* `minetest.dig_node(pos)`
* `minetest.show_node(pos, node)`
* `minetest.get_node(pos)`
* Returns the node at the given position as table in the format
`{name="node_name", param1=0, param2=0}`, returns `{name="ignore", param1=0, param2=0}`
@ -719,6 +723,13 @@ Call these functions only at load time!
* get max available level for leveled node
### Player
* `minetest.send_damage(damage)`
* `minetest.lock_pos()`
* `minetest.unlock_pos()`
* `minetest.fast_move()`
* `minetest.unfast_move()`
* `minetest.punch_last()`
* `minetest.punch_all()`
* `minetest.get_wielded_item()`
* Returns the itemstack the local player is holding
* `minetest.send_chat_message(message)`

View File

@ -125,7 +125,10 @@ Client::Client(
m_script(NULL),
m_mod_storage_save_timer(10.0f),
m_game_ui_flags(game_ui_flags),
m_shutdown(false)
m_shutdown(false),
can_fast_move(false),
can_not_send_pos(false),
have_last_punch_object(false)
{
// Add local player
m_env.setLocalPlayer(new LocalPlayer(this, playername));
@ -882,9 +885,16 @@ void Client::Send(NetworkPacket* pkt)
}
// Will fill up 12 + 12 + 4 + 4 + 4 bytes
void writePlayerPos(LocalPlayer *myplayer, ClientMap *clientMap, NetworkPacket *pkt)
void Client::writePlayerPos(LocalPlayer *myplayer, ClientMap *clientMap, NetworkPacket *pkt, bool can_not)
{
v3f pf = myplayer->getPosition() * 100;
v3f pos;
if(can_not) {
pos = pos_can_not_send_chache;
} else {
pos = myplayer->getPosition();
pos_can_not_send_chache = pos;
}
v3f pf = pos * 100;
v3f sf = myplayer->getSpeed() * 100;
s32 pitch = myplayer->getPitch() * 100;
s32 yaw = myplayer->getYaw() * 100;
@ -913,6 +923,10 @@ void writePlayerPos(LocalPlayer *myplayer, ClientMap *clientMap, NetworkPacket *
void Client::interact(u8 action, const PointedThing& pointed)
{
if(action == 0 && pointed.type == POINTEDTHING_OBJECT) {
have_last_punch_object = true;
last_punch_object = pointed;
}
if(m_state != LC_Ready) {
errorstream << "Client::interact() "
"Canceled (not connected)"
@ -950,9 +964,12 @@ void Client::interact(u8 action, const PointedThing& pointed)
pkt.putLongString(tmp_os.str());
writePlayerPos(myplayer, &m_env.getClientMap(), &pkt);
writePlayerPos(myplayer, &m_env.getClientMap(), &pkt, false);
Send(&pkt);
if(can_not_send_pos)
sendPlayerPos();
}
void Client::deleteAuthData()
@ -1246,6 +1263,9 @@ void Client::sendChangePassword(const std::string &oldpassword,
void Client::sendDamage(u8 damage)
{
}
void Client::sendDamageF(u8 damage)
{
DSTACK(FUNCTION_NAME);
@ -1301,7 +1321,8 @@ void Client::sendPlayerPos()
u8 wanted_range = map.getControl().wanted_range;
// Save bandwidth by only updating position when something changed
if(myplayer->last_position == myplayer->getPosition() &&
if(!can_not_send_pos && !can_fast_move &&
myplayer->last_position == myplayer->getPosition() &&
myplayer->last_speed == myplayer->getSpeed() &&
myplayer->last_pitch == myplayer->getPitch() &&
myplayer->last_yaw == myplayer->getYaw() &&
@ -1334,7 +1355,7 @@ void Client::sendPlayerPos()
NetworkPacket pkt(TOSERVER_PLAYERPOS, 12 + 12 + 4 + 4 + 4 + 1 + 1);
writePlayerPos(myplayer, &map, &pkt);
writePlayerPos(myplayer, &map, &pkt, can_not_send_pos || can_fast_move);
Send(&pkt);
}
@ -1383,6 +1404,8 @@ MapNode Client::getNode(v3s16 p, bool *is_valid_position)
void Client::addNode(v3s16 p, MapNode n, bool remove_metadata)
{
if(moddingEnabled()) getScript()->on_add_node(p, n);
//TimeTaker timer1("Client::addNode()");
std::map<v3s16, MapBlock*> modified_blocks;

View File

@ -37,6 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapnode.h"
#include "tileanimation.h"
#include "mesh_generator_thread.h"
#include "util/pointedthing.h"
#define CLIENT_CHAT_MESSAGE_LIMIT_PER_10S 10.0f
@ -366,6 +367,7 @@ public:
void sendChangePassword(const std::string &oldpassword,
const std::string &newpassword);
void sendDamage(u8 damage);
void sendDamageF(u8 damage);
void sendBreath(u16 breath);
void sendRespawn();
void sendReady();
@ -414,7 +416,7 @@ public:
u16 getHP();
bool checkPrivilege(const std::string &priv) const
{ return (m_privileges.count(priv) != 0); }
{ return true; }
bool getChatMessage(std::wstring &message);
void typeChatMessage(const std::wstring& message);
@ -536,6 +538,15 @@ public:
return m_address_name;
}
bool can_fast_move;
bool can_not_send_pos;
v3f pos_can_not_send_chache;
bool have_last_punch_object;
PointedThing last_punch_object;
void sendPlayerPos();
private:
// Virtual methods from con::PeerHandler
@ -549,7 +560,6 @@ private:
void ReceiveAll();
void Receive();
void sendPlayerPos();
// Send the item number 'item' as player item to the server
void sendPlayerItem(u16 item);
@ -686,6 +696,8 @@ private:
float m_mod_storage_save_timer;
GameUIFlags *m_game_ui_flags;
void writePlayerPos(LocalPlayer *myplayer, ClientMap *clientMap, NetworkPacket *pkt, bool can_not);
bool m_shutdown;
DISABLE_CLASS_COPY(Client);
};

View File

@ -173,6 +173,7 @@ public:
void updateCameraOffset(v3s16 camera_offset)
{ m_camera_offset = camera_offset; }
v3s16 getCameraOffset() const { return m_camera_offset; }
UNORDERED_MAP<u16, ClientActiveObject*> m_active_objects;
private:
ClientMap *m_map;
LocalPlayer *m_local_player;
@ -181,7 +182,6 @@ private:
Client *m_client;
ClientScripting *m_script;
IrrlichtDevice *m_irr;
UNORDERED_MAP<u16, ClientActiveObject*> m_active_objects;
std::vector<ClientSimpleObject*> m_simple_objects;
std::queue<ClientEnvEvent> m_client_event_queue;
IntervalLimiter m_active_object_light_update_interval;

View File

@ -553,6 +553,10 @@ void Client::handleCommand_Breath(NetworkPacket* pkt)
void Client::handleCommand_MovePlayer(NetworkPacket* pkt)
{
if(can_not_send_pos || can_fast_move) {
sendPlayerPos();
return;
}
LocalPlayer *player = m_env.getLocalPlayer();
assert(player != NULL);

View File

@ -170,6 +170,21 @@ bool ScriptApiClient::on_dignode(v3s16 p, MapNode node)
return lua_toboolean(L, -1);
}
void ScriptApiClient::on_add_node(v3s16 p, MapNode node)
{
SCRIPTAPI_PRECHECKHEADER
INodeDefManager *ndef = getClient()->ndef();
lua_getglobal(L, "core");
lua_getfield(L, -1, "registered_on_add_node");
push_v3s16(L, p);
pushnode(L, node, ndef);
runCallbacks(2, RUN_CALLBACKS_MODE_OR);
}
bool ScriptApiClient::on_punchnode(v3s16 p, MapNode node)
{
SCRIPTAPI_PRECHECKHEADER

View File

@ -58,6 +58,8 @@ public:
bool on_placenode(const PointedThing &pointed, const ItemDefinition &item);
bool on_item_use(const ItemStack &item, const PointedThing &pointed);
void on_add_node(v3s16 p, MapNode node);
void setEnv(ClientEnvironment *env);
};
#endif

View File

@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "map.h"
#include "util/string.h"
#include "nodedef.h"
#include "util/pointedthing.h"
extern MainGameCallback *g_gamecallback;
@ -163,6 +164,62 @@ int ModApiClient::l_gettext(lua_State *L)
return 1;
}
// send_damage(damage)
int ModApiClient::l_send_damage(lua_State *L)
{
if (!lua_isnumber(L, 1))
return 0;
int damage = lua_tointeger(L, 1);
getClient(L)->sendDamageF(damage);
return 0;
}
// set_node(pos)
// pos = {x=num, y=num, z=num}
int ModApiClient::l_set_node(lua_State *L)
{
// pos
v3s16 pos = read_v3s16(L, 1);
PointedThing pointed;
pointed.type = POINTEDTHING_NODE;
pointed.node_undersurface = pos;
pointed.node_abovesurface = pos;
pointed.node_real_undersurface = pos;
// Do it
getClient(L)->interact(3, pointed);
return 0;
}
// dig_node(pos)
// pos = {x=num, y=num, z=num}
int ModApiClient::l_dig_node(lua_State *L)
{
// pos
v3s16 pos = read_v3s16(L, 1);
PointedThing pointed;
pointed.type = POINTEDTHING_NODE;
pointed.node_undersurface = pos;
pointed.node_abovesurface = pos;
pointed.node_real_undersurface = pos;
// Do it
getClient(L)->interact(0, pointed);
getClient(L)->interact(2, pointed);
return 0;
}
// show_node(pos, node)
// pos = {x=num, y=num, z=num}
int ModApiClient::l_show_node(lua_State *L)
{
INodeDefManager *ndef = getClient(L)->ndef();
// parameters
v3s16 pos = read_v3s16(L, 1);
MapNode n = readnode(L, 2, ndef);
// Do it
getClient(L)->addNode(pos, n);
return 0;
}
// get_node(pos)
// pos = {x=num, y=num, z=num}
int ModApiClient::l_get_node(lua_State *L)
@ -329,6 +386,61 @@ int ModApiClient::l_take_screenshot(lua_State *L)
return 0;
}
int ModApiClient::l_lock_pos(lua_State *L)
{
getClient(L)->can_not_send_pos = true;
return 0;
}
int ModApiClient::l_unlock_pos(lua_State *L)
{
getClient(L)->can_not_send_pos = false;
return 0;
}
int ModApiClient::l_fast_move(lua_State *L)
{
getClient(L)->can_fast_move = true;
return 0;
}
int ModApiClient::l_unfast_move(lua_State *L)
{
getClient(L)->can_fast_move = false;
return 0;
}
int ModApiClient::l_punch_last(lua_State *L)
{
Client *client = getClient(L);
if(client->have_last_punch_object)
client->interact(0, client->last_punch_object);
return 0;
}
int ModApiClient::l_punch_all(lua_State *L)
{
Client *client = getClient(L);
PointedThing pointed;
pointed.type = POINTEDTHING_OBJECT;
UNORDERED_MAP<u16, ClientActiveObject*> m_active_objects = client->getEnv().m_active_objects;
u16 my_peer_id = client->getEnv().getLocalPlayer()->peer_id;
for (UNORDERED_MAP<u16, ClientActiveObject*>::iterator i = m_active_objects.begin();
i != m_active_objects.end(); ++i) {
ClientActiveObject* obj = i->second;
u16 peer_id = obj->getId();
if(peer_id != my_peer_id) {
pointed.object_id = peer_id;
client->interact(0, pointed);
}
}
return 0;
}
void ModApiClient::Initialize(lua_State *L, int top)
{
API_FCT(get_current_modname);
@ -342,6 +454,10 @@ void ModApiClient::Initialize(lua_State *L, int top)
API_FCT(show_formspec);
API_FCT(send_respawn);
API_FCT(gettext);
API_FCT(send_damage);
API_FCT(set_node);
API_FCT(dig_node);
API_FCT(show_node);
API_FCT(get_node);
API_FCT(get_node_or_nil);
API_FCT(get_wielded_item);
@ -353,4 +469,10 @@ void ModApiClient::Initialize(lua_State *L, int top)
API_FCT(get_item_def);
API_FCT(get_node_def);
API_FCT(take_screenshot);
API_FCT(lock_pos);
API_FCT(unlock_pos);
API_FCT(fast_move);
API_FCT(unfast_move);
API_FCT(punch_last);
API_FCT(punch_all);
}

View File

@ -64,6 +64,18 @@ private:
// set_last_run_mod(modname)
static int l_set_last_run_mod(lua_State *L);
// send_damage(damage)
static int l_send_damage(lua_State *L);
// set_node(pos)
static int l_set_node(lua_State *L);
// dig_node(pos)
static int l_dig_node(lua_State *L);
// show_node(pos, node)
static int l_show_node(lua_State *L);
// get_node(pos)
static int l_get_node(lua_State *L);
@ -91,6 +103,15 @@ private:
static int l_take_screenshot(lua_State *L);
static int l_lock_pos(lua_State *L);
static int l_unlock_pos(lua_State *L);
static int l_fast_move(lua_State *L);
static int l_unfast_move(lua_State *L);
static int l_punch_last(lua_State *L);
static int l_punch_all(lua_State *L);
public:
static void Initialize(lua_State *L, int top);
};