summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Plugins/Core/coords.lua4
-rw-r--r--Plugins/Core/main.lua8
-rw-r--r--Plugins/Core/regeneratechunk.lua18
-rw-r--r--Plugins/Core/viewdistance.lua10
-rw-r--r--source/ManualBindings.cpp6
-rw-r--r--source/cClientHandle.h1
-rw-r--r--source/cEntity.h6
-rw-r--r--source/cServer.cpp60
-rw-r--r--source/cWorld.h2
9 files changed, 50 insertions, 65 deletions
diff --git a/Plugins/Core/coords.lua b/Plugins/Core/coords.lua
new file mode 100644
index 000000000..07cda1a92
--- /dev/null
+++ b/Plugins/Core/coords.lua
@@ -0,0 +1,4 @@
+function HandleCoordsCommand( Split, Player )
+ Player:SendMessage(cChatColor.Green .. string.format("[X:%0.2f] [Y:%0.2f] [Z:%0.2f]", Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() ) )
+ return true
+end \ No newline at end of file
diff --git a/Plugins/Core/main.lua b/Plugins/Core/main.lua
index 2706a6846..4ef67e424 100644
--- a/Plugins/Core/main.lua
+++ b/Plugins/Core/main.lua
@@ -37,7 +37,10 @@ function Initialize( Plugin )
Plugin:AddCommand("/top", " - Teleport yourself to the top most block", "core.top")
Plugin:AddCommand("/gm", " - [Gamemode (0|1)] - Change your gamemode", "core.changegm")
Plugin:AddCommand("/gotoworld", " - Move to a different world!", "core.gotoworld")
-
+ Plugin:AddCommand("/coords", " - Show your current server coordinates", "core.coords")
+ Plugin:AddCommand("/viewdistance", " - [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."] - Change your view distance", "core.viewdistance")
+ Plugin:AddCommand("/regeneratechunk", " - <X [Z]> - Regenerates a chunk", "core.regeneratechunk")
+
Plugin:BindCommand( "/help", "core.help", HandleHelpCommand )
Plugin:BindCommand( "/pluginlist", "core.pluginlist", HandlePluginListCommand )
Plugin:BindCommand( "/tp", "core.teleport", HandleTPCommand )
@@ -57,6 +60,9 @@ function Initialize( Plugin )
Plugin:BindCommand( "/top", "core.top", HandleTopCommand )
Plugin:BindCommand( "/gm", "core.changegm", HandleChangeGMCommand )
Plugin:BindCommand( "/gotoworld", "core.gotoworld", HandleGotoWorldCommand )
+ Plugin:BindCommand( "/coords", "core.coords", HandleCoordsCommand )
+ Plugin:BindCommand( "/viewdistance","core.viewdistance", HandleViewDistanceCommand )
+ Plugin:BindCommand( "/regeneratechunk","core.regeneratechunk", HandleRegenerateChunkCommand )
local IniFile = cIniFile("settings.ini")
diff --git a/Plugins/Core/regeneratechunk.lua b/Plugins/Core/regeneratechunk.lua
new file mode 100644
index 000000000..b4b2874fc
--- /dev/null
+++ b/Plugins/Core/regeneratechunk.lua
@@ -0,0 +1,18 @@
+function HandleRegenerateChunkCommand( Split, Player )
+ if( (#Split == 2) or (#Split > 3) ) then
+ Player:SendMessage( cChatColor.Green .. "Usage: /regeneratechunk <X [Z]>" )
+ return true
+ end
+
+ local X = Player:GetChunkX()
+ local Z = Player:GetChunkZ()
+
+ if( #Split == 3 ) then
+ X = Split[2]
+ Z = Split[3]
+ end
+
+ Player:SendMessage(cChatColor.Green .. "Regenerating chunk ["..X..", "..Z.."]")
+ Player:GetWorld():RegenerateChunk(X, Z)
+ return true
+end \ No newline at end of file
diff --git a/Plugins/Core/viewdistance.lua b/Plugins/Core/viewdistance.lua
new file mode 100644
index 000000000..43d2a7de8
--- /dev/null
+++ b/Plugins/Core/viewdistance.lua
@@ -0,0 +1,10 @@
+function HandleViewDistanceCommand( Split, Player )
+ if( #Split ~= 2 ) then
+ Player:SendMessage( cChatColor.Green .. "Usage: /viewdistance [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."]" )
+ return true
+ end
+
+ Player:GetClientHandle():SetViewDistance( Split[2] )
+ Player:SendMessage(cChatColor.Green .. "Your viewdistance has been set to " .. Player:GetClientHandle():GetViewDistance() )
+ return true
+end \ No newline at end of file
diff --git a/source/ManualBindings.cpp b/source/ManualBindings.cpp
index 34934eebd..ba3b99e14 100644
--- a/source/ManualBindings.cpp
+++ b/source/ManualBindings.cpp
@@ -13,6 +13,7 @@
#include "cPlayer.h"
#include "cWebAdmin.h"
#include "cStringMap.h"
+#include "cClientHandle.h"
#include "md5/md5.h"
@@ -507,6 +508,11 @@ void ManualBindings::Bind( lua_State* tolua_S )
tolua_variable(tolua_S,"FormData",tolua_get_HTTPRequest_FormData,0);
tolua_endmodule(tolua_S);
+ tolua_beginmodule(tolua_S,"cClientHandle");
+ tolua_constant(tolua_S,"MIN_VIEW_DISTANCE",cClientHandle::MIN_VIEW_DISTANCE);
+ tolua_constant(tolua_S,"MAX_VIEW_DISTANCE",cClientHandle::MAX_VIEW_DISTANCE);
+ tolua_endmodule(tolua_S);
+
tolua_function(tolua_S,"md5",tolua_md5);
tolua_endmodule(tolua_S);
diff --git a/source/cClientHandle.h b/source/cClientHandle.h
index 05ec39f07..dd5094222 100644
--- a/source/cClientHandle.h
+++ b/source/cClientHandle.h
@@ -106,6 +106,7 @@ public:
inline short GetPing() const { return m_Ping; } //tolua_export
void SetViewDistance(int a_ViewDistance); //tolua_export
+ int GetViewDistance() { return m_ViewDistance; }//tolua_export
int GetUniqueID() const { return m_UniqueID; } //tolua_export
diff --git a/source/cEntity.h b/source/cEntity.h
index 1b26f46be..34c878abd 100644
--- a/source/cEntity.h
+++ b/source/cEntity.h
@@ -80,9 +80,9 @@ public: //tolua_export
float GetRoll (void) const {return m_Rot.z; } //tolua_export
Vector3f GetLookVector(); //tolua_export
- int GetChunkX(void) const {return m_ChunkX; }
- int GetChunkY(void) const {return m_ChunkY; }
- int GetChunkZ(void) const {return m_ChunkZ; }
+ int GetChunkX(void) const {return m_ChunkX; } //tolua_export
+ int GetChunkY(void) const {return m_ChunkY; } //tolua_export
+ int GetChunkZ(void) const {return m_ChunkZ; } //tolua_export
void SetPosX( const double & a_PosX ); //tolua_export
void SetPosY( const double & a_PosY ); //tolua_export
diff --git a/source/cServer.cpp b/source/cServer.cpp
index d8e3506dc..332631b47 100644
--- a/source/cServer.cpp
+++ b/source/cServer.cpp
@@ -464,66 +464,6 @@ bool cServer::Command( cClientHandle & a_Client, const char* a_Cmd )
{
return true;
}
-
- std::string Command( a_Cmd );
- if( Command.length() <= 0 ) return false;
- if( Command[0] != '/' ) return false;
-
- AStringVector split = StringSplit( Command, " " );
- if( split.size() == 0 )
- return false;
-
- if (split[0].compare("/coords") == 0)
- {
- AString Pos;
- Printf(Pos, "[X:%0.2f] [Y:%0.2f] [Z:%0.2f]", a_Client.GetPlayer()->GetPosX(), a_Client.GetPlayer()->GetPosY(), a_Client.GetPlayer()->GetPosZ() );
- a_Client.Send( cPacket_Chat(cChatColor::Green + Pos));
- return true;
- }
-
- if (split[0].compare("/viewdistance") == 0)
- {
- if (split.size() != 2)
- {
- a_Client.Send(cPacket_Chat(cChatColor::Green + "Invalid syntax, expected 1 parameter, the number of chunks to stream"));
- return false;
- }
- int dist = atol(split[1].c_str());
- a_Client.SetViewDistance(dist);
- return true;
- }
-
- if (split[0].compare("/regeneratechunk") == 0)
- {
- if (!a_Client.GetPlayer()->HasPermission("builtin.regeneratechunk"))
- {
- a_Client.Send(cPacket_Chat(cChatColor::Green + "You don't have permissions to regenerate chunks"));
- return true;
- }
- int ChunkX, ChunkZ;
- if (split.size() == 1)
- {
- // Regenerate current chunk
- ChunkX = a_Client.GetPlayer()->GetChunkX();
- ChunkZ = a_Client.GetPlayer()->GetChunkZ();
- }
- else if (split.size() == 3)
- {
- // Regenerate chunk in params
- ChunkX = atoi(split[1].c_str());
- ChunkZ = atoi(split[2].c_str());
- }
- else
- {
- a_Client.Send(cPacket_Chat(cChatColor::Green + "Invalid syntax, expected either 0 (current chunk) or 2 (x, z) parameters"));
- return false;
- }
- AString Msg;
- Printf(Msg, "Regenerating chunk [%d, %d]", ChunkX, ChunkZ);
- a_Client.Send(cPacket_Chat(cChatColor::Green + Msg));
- a_Client.GetPlayer()->GetWorld()->RegenerateChunk(ChunkX, ChunkZ);
- return true;
- }
return false;
}
diff --git a/source/cWorld.h b/source/cWorld.h
index 29b7fce72..d5916807a 100644
--- a/source/cWorld.h
+++ b/source/cWorld.h
@@ -177,7 +177,7 @@ public:
void ChunksStay(const cChunkCoordsList & a_Chunks, bool a_Stay = true);
/// Regenerate the given chunk:
- void RegenerateChunk(int a_ChunkX, int a_ChunkZ);
+ void RegenerateChunk(int a_ChunkX, int a_ChunkZ); //tolua_export
// TODO: Export to Lua
bool DoWithEntity( int a_UniqueID, cEntityCallback & a_Callback );