Compare commits
45 Commits
cheat-mast
...
cheat
Author | SHA1 | Date |
---|---|---|
zaoqi | 3d64507ac3 | |
zaoqi | ce0ab6cc16 | |
zaoqi | 13f1e60af5 | |
zaoqi | 565a6749ae | |
zaoqi | 8234903374 | |
zaoqi | e4c7012246 | |
zaoqi | deeee5e453 | |
zaoqi | ae25322acc | |
zaoqi | 5a53ee48eb | |
zaoqi | aee5cfa626 | |
zaoqi | 6e9ed10ace | |
zaoqi | 342516c010 | |
zaoqi | 195620363b | |
ShadowNinja | caecdb681c | |
est31 | 81d56b9491 | |
est31 | 8077612dcb | |
est31 | 07fddf1f6c | |
Loic Blot | 315b00d150 | |
est31 | 0c0248a19c | |
Loic Blot | 0429ec4cfd | |
Craig Robbins | a740a48f62 | |
Loic Blot | b12f569fc6 | |
Perttu Ahola | 7993a403f2 | |
Novatux | b0df67d9c0 | |
Loic Blot | 45ff8569d7 | |
est31 | 82bfa2ee7b | |
fz72 | 9ef2e5000f | |
BlockMen | 678546308e | |
BlockMen | 6f688c50ee | |
Perttu Ahola | bb603ff18e | |
Loic Blot | 4208fdfd22 | |
Kahrl | 4875213168 | |
Loic Blot | f92540e8ad | |
Jakub Vaněk | ec0bf899ed | |
ngosang | 2b635a892c | |
Loic Blot | 7f6fc148bd | |
ngosang | 878e9f7594 | |
Rui | c7249f5983 | |
Rui | 7f07858209 | |
ShadowNinja | 9e9688fc61 | |
Markus Koschany | 93e5ab367a | |
est31 | 60fa5807b9 | |
ngosang | 9dbca41385 | |
est31 | 61588a43dd | |
BlockMen | e62927ed71 |
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)`
|
||||
|
|
|
@ -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;
|
||||
|
|
16
src/client.h
16
src/client.h
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue