summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--GETTING-STARTED.md2
-rw-r--r--MCServer/Plugins/APIDump/APIDesc.lua1
-rw-r--r--MCServer/Plugins/APIDump/InfoFile.html246
-rw-r--r--MCServer/Plugins/ChunkWorx/chunkworx_web.lua2
-rw-r--r--src/Bindings/.gitignore1
-rw-r--r--src/Bindings/PluginManager.cpp464
-rw-r--r--src/Bindings/lua51.dllbin167424 -> 0 bytes
-rw-r--r--src/Bindings/tolua++.exebin200704 -> 0 bytes
-rw-r--r--src/CMakeLists.txt195
-rw-r--r--src/Entities/Entity.cpp38
-rw-r--r--src/Entities/Entity.h35
-rw-r--r--src/Entities/Player.cpp11
-rw-r--r--src/Entities/Player.h6
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.cpp65
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.h2
-rw-r--r--src/World.h1
16 files changed, 635 insertions, 434 deletions
diff --git a/GETTING-STARTED.md b/GETTING-STARTED.md
index eb7d1b713..d78b2f84f 100644
--- a/GETTING-STARTED.md
+++ b/GETTING-STARTED.md
@@ -3,7 +3,7 @@ Hello! Thanks for wanting to work on this project :smile:, and I hope that this
Minecraft Basics
----------------
-If you don't play Minecraft or don't have a great knowledge of the basic systems, you should get to know them. The [Minecraft Wiki](http://minecraft.gamepedia.com/Minecraft_Wiki) is quite useful for this task, although some youtubers are also fairly good at teaching the basics and just playing is quite good too. It is possabile to contribute without knowing minecraft in detail though.
+If you don't play Minecraft or don't have a great knowledge of the basic systems, you should get to know them. The [Minecraft Wiki](http://minecraft.gamepedia.com/Minecraft_Wiki) is quite useful for this task, although some youtubers are also fairly good at teaching the basics and just playing is quite good too. It is possible to contribute without knowing minecraft in detail though.
I'd say that the important topics are:
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index c97e2dbf8..19ca971e2 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -2934,6 +2934,7 @@ end
{
-- No sorting is provided for these, they will be output in the same order as defined here
{ FileName = "Writing-a-MCServer-plugin.html", Title = "Writing a MCServer plugin" },
+ { FileName = "InfoFile.html", Title = "Using the Info.lua file" },
{ FileName = "SettingUpDecoda.html", Title = "Setting up the Decoda Lua IDE" },
{ FileName = "SettingUpZeroBrane.html", Title = "Setting up the ZeroBrane Studio Lua IDE" },
{ FileName = "UsingChunkStays.html", Title = "Using ChunkStays" },
diff --git a/MCServer/Plugins/APIDump/InfoFile.html b/MCServer/Plugins/APIDump/InfoFile.html
new file mode 100644
index 000000000..3fff06d20
--- /dev/null
+++ b/MCServer/Plugins/APIDump/InfoFile.html
@@ -0,0 +1,246 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>MCServer - Info.lua file</title>
+ <link rel="stylesheet" type="text/css" href="main.css" />
+ <link rel="stylesheet" type="text/css" href="prettify.css" />
+ <script src="prettify.js"></script>
+ <script src="lang-lua.js"></script>
+ <meta charset="UTF-8">
+ </head>
+ <body>
+ <div id="content">
+ <h1>Info.lua file</h1>
+ <h2>Contents</h2>
+ <ul>
+ <li><a href="#Introduction">Introduction</a></li>
+ <li><a href="#Overall">The overall structure</a></li>
+ <li><a href="#AdditionalInformation">AdditionalInformation table</a></li>
+ <li><a href="#Commands">Commands table</a></li>
+ <li><a href="#ConsoleCommands">ConsoleCommands table</a></li>
+ <li><a href="#Permissions">Permissions table</a></li>
+ <li><a href="#Using">Using the file in code</a></li>
+ <li><a href="#Examples">Examples</a></li>
+ </ul>
+
+
+ <hr />
+ <a name="Introduction"><h2>Introduction</h2></a>
+
+ <p>For a long time MCServer plugins were plagued by poor documentation. The plugins worked, people who wrote them knew how to use them, but for anyone new to the plugin it was a terrible ordeal learning how to use it. Most of the times, the plugin authors only wrote what commands the plugin supported, sometimes not even that. Then, there was a call to action to put an end to this, to make documenting the plugins easy and at the same time centralized. Thus, the Info.lua file was born.</p>
+
+ <p>Most plugins have some parts that are the same across all the plugins. These are commands, console commands and their permissions. If a plugin implemented a command, it would practically copy &amp; paste the same code over and over again. So it makes sense to extract only unique information, centralize it and automate all the parts around it. This was another reason for the Info.lua file - it is a central hub of commands, console commands and their permissions.</p>
+
+ <p>Last, but not least, we want to make a plugin repository on the web in the future, a repository that would store plugins, their descriptions, comments. It makes sense that the centralized information can be parsed by the repository automatically, so that advanced things, such as searching for a plugin based on a command, or determining whether two plugins collide command-wise, are possible.</p>
+
+ <p>After this file format has been devised, a tool has been written that allows for an easy generation of the documentation for the plugin in various formats. It outputs the documentation in a format that is perfect for pasting into the forum. It generates documentation in a Markup format to use in README.md on GitHub and similar sites. The clever thing is that you don't need to keep all those formats in sync manually - you edit the Info.lua file and this tool will re-generate the documentation for you.</p>
+
+ <p>So to sum up, the Info.lua file contains the plugins' commands, console commands, their permissions and possibly the overall plugin documentation, in a structured manner that can be parsed by a program, yet is human readable and editable.</p>
+
+
+ <hr />
+ <a name="Overall"><h2>The overall structure</h2></a>
+
+ <p>The file consist of a declaration of a single Lua table, g_PluginInfo. This table contains all the information, structured, as its members. Each member can be a structure by itself. The entire file is a valid Lua source file, so any tool that syntax-checks Lua source can syntax-check this file. The file is somewhat forward- and backward- compatible, in the sense that it can be extended in any way without breaking.</p>
+ <p>Here's a skeleton of the file:</p>
+<pre class="prettyprint lang-lua">
+g_PluginInfo =
+{
+ Name = "Example Plugin",
+ Date = "2014-06-12",
+ Description = "This is an example plugin that shows how to use the Info.lua file",
+
+ -- The following members will be documented in greater detail later:
+ AdditionalInformation = {},
+ Commands = {},
+ ConsoleCommands = {},
+ Permissions = {},
+}
+</pre>
+ <p>As you can see, the structure is pretty straightforward. Note that the order of the elements inside the table is not important (Lua property).</p>
+
+ <p>The first few elements are for book-keeping. They declare the plugin's name, the date in ISO-format, representing the version of the plugin, and the description. The idea is that the description sums up what the plugin is all about, within some two or three sentences.</p>
+
+
+ <hr />
+ <a name="AdditionalInformation"><h2>AdditionalInformation table</h2></a>
+
+ <p>This table is used for more detailed description of the plugin. If there is any non-trivial setup process, dependencies, describe them here. This is where the description should get detailed. Don't worry about using several paragraphs of text here, if it makes the plugin easier to understand.</p>
+
+ <p>The table should have the following layout:</p>
+<pre class="prettyprint lang-lua">
+AdditionalInformation =
+{
+ {
+ Title = "Chapter 1",
+ Contents = "Describe one big aspect of the plugin here",
+ },
+ {
+ Title = "Chapter 2",
+ Contents = "Describe another big topic",
+ },
+}
+</pre>
+ <p>The idea here is that the tool that is used to generate the documentation from the Info.lua file will create a linkified table of contents and then each of the information elements' contents. This information should be all that is needed to successfully configure, run and manage the plugin.</p>
+
+
+ <hr />
+ <a name="Commands"><h2>Commands table</h2></a>
+
+ <p>The commands table lists all the commands that the plugin implements, together with their handler functions, required permissions, help strings and further information. The table supports recursion, which allows plugins to create multi-word commands easily (such as "//schematic load" and "//schematic save"), each having its own separate handler.</p>
+
+ <p>The table uses structure similar to the following:</p>
+<pre class="prettyprint lang-lua">
+Commands =
+{
+ ["/cmd1"] =
+ {
+ HelpString = "Performs the first action",
+ Permission = "firstplugin.cmds.1",
+ Alias = "/c1",
+ Handler = HandleCmd1,
+ ParameterCombinations =
+ {
+ {
+ Params = "x y z",
+ Help = "Performs the first action at the specified coordinates",
+ },
+ {
+ Params = "-p",
+ Help = "Performs the first action at the player's coordinates",
+ }
+ },
+ },
+ ["/cmd2"] =
+ {
+ Alias = {"/c2", "//c2" },
+ Subcommands =
+ {
+ sub1 = -- This declares a "/cmd2 sub1" command
+ {
+ HelpString = "Performs the second action's first subcommand",
+ Permission = "firstplugin.cmds.2.1",
+ Alias = "1",
+ Handler = HandleCmd2Sub1,
+ ParameterCombinations =
+ {
+ {
+ Params = "x y z",
+ Help = "Performs the second action's first subcommand at the specified coordinates",
+ },
+ {
+ Params = "-p",
+ Help = "Performs the second action's first subcommand at the player's coordinates",
+ }
+ },
+ },
+ sub2 = -- Declares a "/cmd2 sub2" command
+ {
+ HelpString = "Performs the second action's second subcommand",
+ Permission = "firstplugin.cmds.2.2",
+ Handler = HandleCmd2Sub2,
+ },
+ },
+ },
+}
+</pre>
+
+ <p>Although it may seem overwhelming at first, there is a "method to this madness". Each element of the Commands table defines one command. Most commands start with a slash, so the special Lua syntax for table elements with non-standard names needs to be applied (<code>["/cmd1"] =</code>). The command can either specify subcommands, or a handler function (specifying both is UndefinedBehavior). Subcommands uses the same structure as the entire Commands table, recursively.</p>
+
+ <p>The permission element specifies that the command is only available with the specified permission. Note that the permission for subcommand's parent isn't checked when the subcommand is called. This means that specifying the permission for a command that has subcommands has no effect whatsoever, but is discouraged because we may add processing for that in the future.</p>
+
+ <p>The ParameterCombinations table is used only for generating the documentation, it lists the various combinations of parameters that the command supports. It's worth specifying even if the command supports only one combination, because that combination will get documented this way.</p>
+
+ <p>The Alias member specifies any possible aliases for the command. Each alias is registered separately and if there is a subcommand table, it is applied to all aliases, just as one would expect. You can specify either a single string as the value (if there's only one alias), or a table of strings for multiple aliases. Commands with no aliases do not need to specify this member at all.</p>
+
+
+ <hr />
+ <a name="ConsoleCommands"><h2>ConsoleCommands table</h2>
+
+ <p>This table serves a purpose similar to that of the Commands table, only these commands are provided for the server console. Therefore, there are no permissions specified for these commands. Since most console commands don't use a leading slash, the command names don't need the special syntax. Also, the handler function doesn't receive the Player parameter.</p>
+
+ <p>Here's an example of a ConsoleCommands table:</p>
+<pre class="prettyprint lang-lua">
+ConsoleCommands =
+{
+ concmd =
+ {
+ HelpString = "Performs the console action",
+ Subcommands =
+ {
+ sub1 =
+ {
+ HelpString = "Performs the console action's first subcommand",
+ Handler = HandleConCmdSub1,
+ ParameterCombinations =
+ {
+ {
+ Params = "x y z",
+ Help = "Performs the console action's first subcommand at the specified coordinates",
+ },
+ },
+ },
+ sub2 =
+ {
+ HelpString = "Performs the console action's second subcommand",
+ Handler = HandleConCmdSub2,
+ },
+ },
+ },
+}
+</pre>
+
+
+ <hr />
+ <a name="Permissions"><h2>Permissions table</h2></a>
+
+ <p>The purpose of this table is to document permissions that the plugin uses. The documentation generator automatically collects the permissions specified in the Command table; the Permissions table adds a description for these permissions and may declare other permissions that aren't specifically included in the Command table.</p>
+
+<pre class="prettyprint lang-lua">
+Permissions =
+{
+ ["firstplugin.cmd.1.1"] =
+ {
+ Description = "Allows the players to build high towers using the first action.",
+ RecommendedGroups = "players",
+ },
+ ["firstplugin.cmd.2.1"] =
+ {
+ Description = "Allows the players to kill entities using the second action. Note that this may be misused to kill other players, too.",
+ RecommendedGroups = "admins, mods",
+ },
+}
+</pre>
+
+ <p>The RecommendedGroup element lists, in plain English, the intended groups for which the permission should be enabled on a typical server. Plugin authors are advised to create reasonable defaults, prefering security to openness, so that admins using these settings blindly don't expose their servers to malicious users.</p>
+
+
+ <hr />
+ <a name="Using"><h2>Using the file in code</h2></a>
+
+ <p>Just writing the Info.lua file and saving it to the plugin folder is not enough for it to actually be used. Your plugin needs to include the following boilerplate code, preferably in its Initialize() function:</p>
+<pre class="prettyprint lang-lua">
+-- Use the InfoReg shared library to process the Info.lua file:
+dofile(cPluginManager:GetPluginsPath() .. "/InfoReg.lua")
+RegisterPluginInfoCommands()
+RegisterPluginInfoConsoleCommands()
+</pre>
+
+ <p>Of course, if your plugin doesn't have any console commands, it doesn't need to call the RegisterPluginInfoConsoleCommands() function, and similarly if it doesn't have any in-game commands, it doesn't need to call the RegisterPluginInfoCommands() function.</p>
+
+
+ <hr />
+ <a name="Examples"><h2>Examples</h2></a>
+
+ <p>There are several plugins that already implement this approach. You can visit them for inspiration and to see what the generated documentation looks like:</p>
+ <ul>
+ <li>Gallery plugin: <a href="https://github.com/mc-server/Gallery/blob/master/Info.lua">Info.lua</a>, <a href="http://forum.mc-server.org/showthread.php?tid=1306">Forum</a> documentation</li>
+ <li>WorldEdit plugin: <a href="https://github.com/mc-server/WorldEdit/blob/master/Info.lua">Info.lua</a>, <a href="http://forum.mc-server.org/showthread.php?tid=870">Forum</a> and <a href="https://github.com/mc-server/WorldEdit">MarkDown</a> documentation</li>
+ </ul>
+
+ <script>
+ prettyPrint();
+ </script>
+ </div>
+ </body>
+</html>
diff --git a/MCServer/Plugins/ChunkWorx/chunkworx_web.lua b/MCServer/Plugins/ChunkWorx/chunkworx_web.lua
index 6c5eab676..9aec38b12 100644
--- a/MCServer/Plugins/ChunkWorx/chunkworx_web.lua
+++ b/MCServer/Plugins/ChunkWorx/chunkworx_web.lua
@@ -43,7 +43,7 @@ function HandleRequest_Generation( Request )
local Content = ""
if (Request.PostParams["AGHRRRR"] ~= nil) then
GENERATION_STATE = 0
- WW_instance:SaveAllChunks()
+ WW_instance:QueueSaveAllChunks()
WW_instance:QueueUnloadUnusedChunks()
LOGERROR("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": works ABORTED by admin")
end
diff --git a/src/Bindings/.gitignore b/src/Bindings/.gitignore
new file mode 100644
index 000000000..af8aa76fa
--- /dev/null
+++ b/src/Bindings/.gitignore
@@ -0,0 +1 @@
+lua51.dll
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index acfc91bf8..9bcd8e3b7 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -14,6 +14,13 @@
#include "inifile/iniFile.h"
#include "../Entities/Player.h"
+#define FIND_HOOK(a_HookName) HookMap::iterator Plugins = m_Hooks.find(a_HookName);
+#define VERIFY_HOOK \
+ if (Plugins == m_Hooks.end()) \
+ { \
+ return false; \
+ }
+
@@ -192,7 +199,7 @@ void cPluginManager::Tick(float a_Dt)
ReloadPluginsNow();
}
- HookMap::iterator Plugins = m_Hooks.find(HOOK_TICK);
+ FIND_HOOK(HOOK_TICK);
if (Plugins != m_Hooks.end())
{
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
@@ -208,11 +215,9 @@ void cPluginManager::Tick(float a_Dt)
bool cPluginManager::CallHookBlockSpread(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_BLOCK_SPREAD);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_BLOCK_SPREAD);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnBlockSpread(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Source))
@@ -233,11 +238,9 @@ bool cPluginManager::CallHookBlockToPickups(
cItems & a_Pickups
)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_BLOCK_TO_PICKUPS);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_BLOCK_TO_PICKUPS);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_Pickups))
@@ -275,11 +278,8 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
return true; // Cancel sending
}
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHAT);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHAT);
+ VERIFY_HOOK;
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
@@ -298,11 +298,9 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
bool cPluginManager::CallHookChunkAvailable(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_AVAILABLE);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHUNK_AVAILABLE);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkAvailable(a_World, a_ChunkX, a_ChunkZ))
@@ -319,11 +317,9 @@ bool cPluginManager::CallHookChunkAvailable(cWorld * a_World, int a_ChunkX, int
bool cPluginManager::CallHookChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_GENERATED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHUNK_GENERATED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc))
@@ -340,11 +336,9 @@ bool cPluginManager::CallHookChunkGenerated(cWorld * a_World, int a_ChunkX, int
bool cPluginManager::CallHookChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_GENERATING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHUNK_GENERATING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkGenerating(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc))
@@ -361,11 +355,9 @@ bool cPluginManager::CallHookChunkGenerating(cWorld * a_World, int a_ChunkX, int
bool cPluginManager::CallHookChunkUnloaded(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_UNLOADED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHUNK_UNLOADED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkUnloaded(a_World, a_ChunkX, a_ChunkZ))
@@ -382,11 +374,9 @@ bool cPluginManager::CallHookChunkUnloaded(cWorld * a_World, int a_ChunkX, int a
bool cPluginManager::CallHookChunkUnloading(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_UNLOADING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHUNK_UNLOADING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkUnloading(a_World, a_ChunkX, a_ChunkZ))
@@ -403,11 +393,9 @@ bool cPluginManager::CallHookChunkUnloading(cWorld * a_World, int a_ChunkX, int
bool cPluginManager::CallHookCollectingPickup(cPlayer * a_Player, cPickup & a_Pickup)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_COLLECTING_PICKUP);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_COLLECTING_PICKUP);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnCollectingPickup(a_Player, &a_Pickup))
@@ -424,11 +412,9 @@ bool cPluginManager::CallHookCollectingPickup(cPlayer * a_Player, cPickup & a_Pi
bool cPluginManager::CallHookCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CRAFTING_NO_RECIPE);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CRAFTING_NO_RECIPE);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnCraftingNoRecipe(a_Player, a_Grid, a_Recipe))
@@ -445,11 +431,9 @@ bool cPluginManager::CallHookCraftingNoRecipe(const cPlayer * a_Player, const cC
bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString & a_Reason)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_DISCONNECT);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_DISCONNECT);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnDisconnect(a_Client, a_Reason))
@@ -466,11 +450,9 @@ bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString
bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_EXECUTE_COMMAND);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_EXECUTE_COMMAND);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnExecuteCommand(a_Player, a_Split))
@@ -487,11 +469,9 @@ bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVec
bool cPluginManager::CallHookExploded(cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_EXPLODED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_EXPLODED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnExploded(a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData))
@@ -508,11 +488,9 @@ bool cPluginManager::CallHookExploded(cWorld & a_World, double a_ExplosionSize,
bool cPluginManager::CallHookExploding(cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_EXPLODING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_EXPLODING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnExploding(a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData))
@@ -529,11 +507,9 @@ bool cPluginManager::CallHookExploding(cWorld & a_World, double & a_ExplosionSiz
bool cPluginManager::CallHookHandshake(cClientHandle * a_ClientHandle, const AString & a_Username)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_HANDSHAKE);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_HANDSHAKE);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnHandshake(a_ClientHandle, a_Username))
@@ -550,11 +526,9 @@ bool cPluginManager::CallHookHandshake(cClientHandle * a_ClientHandle, const ASt
bool cPluginManager::CallHookHopperPullingItem(cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_HOPPER_PULLING_ITEM);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_HOPPER_PULLING_ITEM);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnHopperPullingItem(a_World, a_Hopper, a_DstSlotNum, a_SrcEntity, a_SrcSlotNum))
@@ -571,11 +545,9 @@ bool cPluginManager::CallHookHopperPullingItem(cWorld & a_World, cHopperEntity &
bool cPluginManager::CallHookHopperPushingItem(cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_HOPPER_PUSHING_ITEM);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_HOPPER_PUSHING_ITEM);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnHopperPushingItem(a_World, a_Hopper, a_SrcSlotNum, a_DstEntity, a_DstSlotNum))
@@ -592,11 +564,9 @@ bool cPluginManager::CallHookHopperPushingItem(cWorld & a_World, cHopperEntity &
bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_KILLING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_KILLING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnKilling(a_Victim, a_Killer))
@@ -613,11 +583,9 @@ bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer)
bool cPluginManager::CallHookLogin(cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_LOGIN);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_LOGIN);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnLogin(a_Client, a_ProtocolVersion, a_Username))
@@ -634,11 +602,9 @@ bool cPluginManager::CallHookLogin(cClientHandle * a_Client, int a_ProtocolVersi
bool cPluginManager::CallHookPlayerAnimation(cPlayer & a_Player, int a_Animation)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_ANIMATION);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_ANIMATION);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerAnimation(a_Player, a_Animation))
@@ -655,11 +621,9 @@ bool cPluginManager::CallHookPlayerAnimation(cPlayer & a_Player, int a_Animation
bool cPluginManager::CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_BREAKING_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_BREAKING_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerBreakingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta))
@@ -676,11 +640,9 @@ bool cPluginManager::CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_Block
bool cPluginManager::CallHookPlayerBrokenBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_BROKEN_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_BROKEN_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerBrokenBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta))
@@ -697,11 +659,9 @@ bool cPluginManager::CallHookPlayerBrokenBlock(cPlayer & a_Player, int a_BlockX,
bool cPluginManager::CallHookPlayerDestroyed(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_DESTROYED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_DESTROYED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerDestroyed(a_Player))
@@ -718,11 +678,9 @@ bool cPluginManager::CallHookPlayerDestroyed(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_EATING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_EATING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerEating(a_Player))
@@ -739,11 +697,9 @@ bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems a_Reward)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_FISHED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_FISHED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerFished(a_Player, a_Reward))
@@ -760,11 +716,9 @@ bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems a_Rew
bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, cItems a_Reward)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_FISHING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_FISHING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerFishing(a_Player, a_Reward))
@@ -781,11 +735,9 @@ bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, cItems a_Reward)
bool cPluginManager::CallHookPlayerJoined(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_JOINED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_JOINED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerJoined(a_Player))
@@ -802,11 +754,9 @@ bool cPluginManager::CallHookPlayerJoined(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerLeftClick(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_LEFT_CLICK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_LEFT_CLICK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerLeftClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status))
@@ -823,11 +773,9 @@ bool cPluginManager::CallHookPlayerLeftClick(cPlayer & a_Player, int a_BlockX, i
bool cPluginManager::CallHookPlayerMoving(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_MOVING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_MOVING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerMoved(a_Player))
@@ -844,11 +792,9 @@ bool cPluginManager::CallHookPlayerMoving(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerPlacedBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_PLACED_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_PLACED_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerPlacedBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta))
@@ -865,11 +811,9 @@ bool cPluginManager::CallHookPlayerPlacedBlock(cPlayer & a_Player, int a_BlockX,
bool cPluginManager::CallHookPlayerPlacingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_PLACING_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_PLACING_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerPlacingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta))
@@ -886,11 +830,9 @@ bool cPluginManager::CallHookPlayerPlacingBlock(cPlayer & a_Player, int a_BlockX
bool cPluginManager::CallHookPlayerRightClick(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_RIGHT_CLICK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_RIGHT_CLICK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerRightClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
@@ -907,11 +849,9 @@ bool cPluginManager::CallHookPlayerRightClick(cPlayer & a_Player, int a_BlockX,
bool cPluginManager::CallHookPlayerRightClickingEntity(cPlayer & a_Player, cEntity & a_Entity)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_RIGHT_CLICKING_ENTITY);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_RIGHT_CLICKING_ENTITY);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerRightClickingEntity(a_Player, a_Entity))
@@ -928,11 +868,9 @@ bool cPluginManager::CallHookPlayerRightClickingEntity(cPlayer & a_Player, cEnti
bool cPluginManager::CallHookPlayerShooting(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_SHOOTING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_SHOOTING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerShooting(a_Player))
@@ -949,11 +887,9 @@ bool cPluginManager::CallHookPlayerShooting(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerSpawned(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_SPAWNED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_SPAWNED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerSpawned(a_Player))
@@ -970,11 +906,9 @@ bool cPluginManager::CallHookPlayerSpawned(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerTossingItem(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_TOSSING_ITEM);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_TOSSING_ITEM);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerTossingItem(a_Player))
@@ -991,11 +925,9 @@ bool cPluginManager::CallHookPlayerTossingItem(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_USED_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_USED_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerUsedBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta))
@@ -1012,11 +944,9 @@ bool cPluginManager::CallHookPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, i
bool cPluginManager::CallHookPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_USED_ITEM);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_USED_ITEM);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerUsedItem(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
@@ -1033,11 +963,9 @@ bool cPluginManager::CallHookPlayerUsedItem(cPlayer & a_Player, int a_BlockX, in
bool cPluginManager::CallHookPlayerUsingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_USING_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_USING_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerUsingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta))
@@ -1054,11 +982,9 @@ bool cPluginManager::CallHookPlayerUsingBlock(cPlayer & a_Player, int a_BlockX,
bool cPluginManager::CallHookPlayerUsingItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_USING_ITEM);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_USING_ITEM);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerUsingItem(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
@@ -1075,11 +1001,9 @@ bool cPluginManager::CallHookPlayerUsingItem(cPlayer & a_Player, int a_BlockX, i
bool cPluginManager::CallHookPluginMessage(cClientHandle & a_Client, const AString & a_Channel, const AString & a_Message)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLUGIN_MESSAGE);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLUGIN_MESSAGE);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPluginMessage(a_Client, a_Channel, a_Message))
@@ -1096,11 +1020,9 @@ bool cPluginManager::CallHookPluginMessage(cClientHandle & a_Client, const AStri
bool cPluginManager::CallHookPluginsLoaded(void)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLUGINS_LOADED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLUGINS_LOADED);
+ VERIFY_HOOK;
+
bool res = false;
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
@@ -1115,11 +1037,9 @@ bool cPluginManager::CallHookPluginsLoaded(void)
bool cPluginManager::CallHookPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_POST_CRAFTING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_POST_CRAFTING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPostCrafting(a_Player, a_Grid, a_Recipe))
@@ -1136,11 +1056,9 @@ bool cPluginManager::CallHookPostCrafting(const cPlayer * a_Player, const cCraft
bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PRE_CRAFTING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PRE_CRAFTING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPreCrafting(a_Player, a_Grid, a_Recipe))
@@ -1157,11 +1075,9 @@ bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCrafti
bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PROJECTILE_HIT_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PROJECTILE_HIT_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnProjectileHitBlock(a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, a_BlockHitPos))
@@ -1178,11 +1094,9 @@ bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile
bool cPluginManager::CallHookProjectileHitEntity(cProjectileEntity & a_Projectile, cEntity & a_HitEntity)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PROJECTILE_HIT_ENTITY);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PROJECTILE_HIT_ENTITY);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnProjectileHitEntity(a_Projectile, a_HitEntity))
@@ -1199,11 +1113,9 @@ bool cPluginManager::CallHookProjectileHitEntity(cProjectileEntity & a_Projectil
bool cPluginManager::CallHookSpawnedEntity(cWorld & a_World, cEntity & a_Entity)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_SPAWNED_ENTITY);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_SPAWNED_ENTITY);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnSpawnedEntity(a_World, a_Entity))
@@ -1219,11 +1131,9 @@ bool cPluginManager::CallHookSpawnedEntity(cWorld & a_World, cEntity & a_Entity)
bool cPluginManager::CallHookSpawnedMonster(cWorld & a_World, cMonster & a_Monster)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_SPAWNED_MONSTER);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_SPAWNED_MONSTER);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnSpawnedMonster(a_World, a_Monster))
@@ -1239,11 +1149,9 @@ bool cPluginManager::CallHookSpawnedMonster(cWorld & a_World, cMonster & a_Monst
bool cPluginManager::CallHookSpawningEntity(cWorld & a_World, cEntity & a_Entity)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_SPAWNING_ENTITY);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_SPAWNING_ENTITY);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnSpawningEntity(a_World, a_Entity))
@@ -1260,11 +1168,9 @@ bool cPluginManager::CallHookSpawningEntity(cWorld & a_World, cEntity & a_Entity
bool cPluginManager::CallHookSpawningMonster(cWorld & a_World, cMonster & a_Monster)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_SPAWNING_MONSTER);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_SPAWNING_MONSTER);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnSpawningMonster(a_World, a_Monster))
@@ -1281,11 +1187,9 @@ bool cPluginManager::CallHookSpawningMonster(cWorld & a_World, cMonster & a_Mons
bool cPluginManager::CallHookTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a_TDI)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_TAKE_DAMAGE);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_TAKE_DAMAGE);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnTakeDamage(a_Receiver, a_TDI))
@@ -1302,11 +1206,9 @@ bool cPluginManager::CallHookTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a
bool cPluginManager::CallHookUpdatingSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_UPDATING_SIGN);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_UPDATING_SIGN);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnUpdatingSign(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player))
@@ -1323,11 +1225,9 @@ bool cPluginManager::CallHookUpdatingSign(cWorld * a_World, int a_BlockX, int a_
bool cPluginManager::CallHookUpdatedSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_UPDATED_SIGN);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_UPDATED_SIGN);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnUpdatedSign(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player))
@@ -1344,11 +1244,9 @@ bool cPluginManager::CallHookUpdatedSign(cWorld * a_World, int a_BlockX, int a_B
bool cPluginManager::CallHookWeatherChanged(cWorld & a_World)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_WEATHER_CHANGED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_WEATHER_CHANGED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnWeatherChanged(a_World))
@@ -1365,11 +1263,9 @@ bool cPluginManager::CallHookWeatherChanged(cWorld & a_World)
bool cPluginManager::CallHookWeatherChanging(cWorld & a_World, eWeather & a_NewWeather)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_WEATHER_CHANGING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_WEATHER_CHANGING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnWeatherChanging(a_World, a_NewWeather))
@@ -1386,11 +1282,9 @@ bool cPluginManager::CallHookWeatherChanging(cWorld & a_World, eWeather & a_NewW
bool cPluginManager::CallHookWorldStarted(cWorld & a_World)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_WORLD_STARTED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_WORLD_STARTED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnWorldStarted(a_World))
@@ -1407,11 +1301,9 @@ bool cPluginManager::CallHookWorldStarted(cWorld & a_World)
bool cPluginManager::CallHookWorldTick(cWorld & a_World, float a_Dt, int a_LastTickDurationMSec)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_WORLD_TICK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_WORLD_TICK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnWorldTick(a_World, a_Dt, a_LastTickDurationMSec))
diff --git a/src/Bindings/lua51.dll b/src/Bindings/lua51.dll
deleted file mode 100644
index 515cf8b30..000000000
--- a/src/Bindings/lua51.dll
+++ /dev/null
Binary files differ
diff --git a/src/Bindings/tolua++.exe b/src/Bindings/tolua++.exe
deleted file mode 100644
index ba3a6b0c7..000000000
--- a/src/Bindings/tolua++.exe
+++ /dev/null
Binary files differ
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 900577526..335ce8315 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -8,98 +8,118 @@ include_directories (SYSTEM "${PROJECT_SOURCE_DIR}/../lib/polarssl/include")
set(FOLDERS OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++)
set(FOLDERS ${FOLDERS} WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs)
+set(BINDING_DEPENDECIES
+ tolua
+ ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/virtual_method_hooks.lua
+ ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/AllToLua.pkg
+ Bindings/LuaFunctions.h
+ Bindings/LuaWindow.h
+ Bindings/Plugin.h
+ Bindings/PluginLua.h
+ Bindings/PluginManager.h
+ Bindings/WebPlugin.h
+ BiomeDef.h
+ BlockArea.h
+ BlockEntities/BlockEntity.h
+ BlockEntities/BlockEntityWithItems.h
+ BlockEntities/ChestEntity.h
+ BlockEntities/DispenserEntity.h
+ BlockEntities/DropSpenserEntity.h
+ BlockEntities/DropperEntity.h
+ BlockEntities/FurnaceEntity.h
+ BlockEntities/HopperEntity.h
+ BlockEntities/JukeboxEntity.h
+ BlockEntities/NoteEntity.h
+ BlockEntities/SignEntity.h
+ BlockEntities/MobHeadEntity.h
+ BlockEntities/FlowerPotEntity.h
+ BlockID.h
+ BoundingBox.h
+ ChatColor.h
+ ChunkDef.h
+ ClientHandle.h
+ CraftingRecipes.h
+ Cuboid.h
+ Defines.h
+ Enchantments.h
+ Entities/Effects.h
+ Entities/Entity.h
+ Entities/Floater.h
+ Entities/Pawn.h
+ Entities/Painting.h
+ Entities/Pickup.h
+ Entities/Player.h
+ Entities/ProjectileEntity.h
+ Entities/ArrowEntity.h
+ Entities/ThrownEggEntity.h
+ Entities/ThrownEnderPearlEntity.h
+ Entities/ExpBottleEntity.h
+ Entities/ThrownSnowballEntity.h
+ Entities/FireChargeEntity.h
+ Entities/FireworkEntity.h
+ Entities/GhastFireballEntity.h
+ Entities/TNTEntity.h
+ Entities/ExpOrb.h
+ Entities/HangingEntity.h
+ Entities/ItemFrame.h
+ Generating/ChunkDesc.h
+ Group.h
+ Inventory.h
+ Item.h
+ ItemGrid.h
+ Mobs/Monster.h
+ OSSupport/File.h
+ Root.h
+ Server.h
+ StringUtils.h
+ Tracer.h
+ UI/Window.h
+ Vector3.h
+ WebAdmin.h
+ World.h
+)
-if (NOT MSVC)
+include_directories(Bindings)
+include_directories(.)
- # Bindings need to reference other folders, so they are done here instead
-
- # lib dependencies are not included
-
- set(BINDING_DEPENDECIES
- tolua
- ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/virtual_method_hooks.lua
- ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/AllToLua.pkg
- Bindings/LuaFunctions.h
- Bindings/LuaWindow.h
- Bindings/Plugin.h
- Bindings/PluginLua.h
- Bindings/PluginManager.h
- Bindings/WebPlugin.h
- BiomeDef.h
- BlockArea.h
- BlockEntities/BlockEntity.h
- BlockEntities/BlockEntityWithItems.h
- BlockEntities/ChestEntity.h
- BlockEntities/DispenserEntity.h
- BlockEntities/DropSpenserEntity.h
- BlockEntities/DropperEntity.h
- BlockEntities/FurnaceEntity.h
- BlockEntities/HopperEntity.h
- BlockEntities/JukeboxEntity.h
- BlockEntities/NoteEntity.h
- BlockEntities/SignEntity.h
- BlockEntities/MobHeadEntity.h
- BlockEntities/FlowerPotEntity.h
- BlockID.h
- BoundingBox.h
- ChatColor.h
- ChunkDef.h
- ClientHandle.h
- CraftingRecipes.h
- Cuboid.h
- Defines.h
- Enchantments.h
- Entities/Effects.h
- Entities/Entity.h
- Entities/Floater.h
- Entities/Pawn.h
- Entities/Painting.h
- Entities/Pickup.h
- Entities/Player.h
- Entities/ProjectileEntity.h
- Entities/ArrowEntity.h
- Entities/ThrownEggEntity.h
- Entities/ThrownEnderPearlEntity.h
- Entities/ExpBottleEntity.h
- Entities/ThrownSnowballEntity.h
- Entities/FireChargeEntity.h
- Entities/FireworkEntity.h
- Entities/GhastFireballEntity.h
- Entities/TNTEntity.h
- Entities/ExpOrb.h
- Entities/HangingEntity.h
- Entities/ItemFrame.h
- Generating/ChunkDesc.h
- Group.h
- Inventory.h
- Item.h
- ItemGrid.h
- Mobs/Monster.h
- OSSupport/File.h
- Root.h
- Server.h
- StringUtils.h
- Tracer.h
- UI/Window.h
- Vector3.h
- WebAdmin.h
- World.h
+if (WIN32)
+ ADD_CUSTOM_COMMAND(
+ # add any new generated bindings here
+ OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h
+
+ # Copy the Lua DLL into the Bindings folder, so that tolua can run from there:
+ COMMAND copy /y ..\\..\\MCServer\\lua51.dll .
+
+ # Regenerate bindings:
+ COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
+
+ # add any new generation dependencies here
+ DEPENDS ${BINDING_DEPENDECIES}
)
-
- include_directories(Bindings)
- include_directories(.)
-
+else ()
ADD_CUSTOM_COMMAND(
# add any new generated bindings here
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h
-
- # command execuded to regerate bindings
+
+ # Regenerate bindings:
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
-
+
# add any new generation dependencies here
DEPENDS ${BINDING_DEPENDECIES}
)
+endif ()
+set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE)
+set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE)
+
+if (NOT MSVC)
+
+ # Bindings need to reference other folders, so they are done here instead
+
+ # lib dependencies are not included
+
+
#add cpp files here
add_library(Bindings
Bindings/Bindings
@@ -148,16 +168,6 @@ if (NOT MSVC)
else ()
# MSVC-specific handling: Put all files into one project, separate by the folders:
- # Generate the Bindings if they don't exist:
- if (NOT EXISTS "${PROJECT_SOURCE_DIR}/Bindings/Bindings.cpp")
- message("Bindings.cpp not found, generating now")
- set(tolua_executable ${PROJECT_SOURCE_DIR}/Bindings/tolua++.exe)
- execute_process(
- COMMAND ${tolua_executable} -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Bindings
- )
- endif()
-
# Get all files in this folder:
file(GLOB_RECURSE SOURCE
"*.cpp"
@@ -166,6 +176,9 @@ else ()
)
source_group("" FILES ${SOURCE})
+ LIST(APPEND SOURCE "Bindings/Bindings.cpp" "Bindings/Bindings.h")
+ source_group(Bindings FILES "Bindings/Bindings.cpp" "Bindings/Bindings.h")
+
# Add all subfolders as solution-folders:
list(APPEND FOLDERS "Resources")
list(APPEND FOLDERS "Bindings")
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 8f736a269..ee7ce06ac 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -179,14 +179,9 @@ void cEntity::WrapRotation(void)
void cEntity::WrapSpeed(void)
{
- // There shoudn't be a need for flipping the flag on because this function is called
- // after any update, so the flag is already turned on
- if (m_Speed.x > 78.0f) m_Speed.x = 78.0f;
- else if (m_Speed.x < -78.0f) m_Speed.x = -78.0f;
- if (m_Speed.y > 78.0f) m_Speed.y = 78.0f;
- else if (m_Speed.y < -78.0f) m_Speed.y = -78.0f;
- if (m_Speed.z > 78.0f) m_Speed.z = 78.0f;
- else if (m_Speed.z < -78.0f) m_Speed.z = -78.0f;
+ m_Speed.x = Clamp(m_Speed.x, -78.0, 78.0);
+ m_Speed.y = Clamp(m_Speed.y, -78.0, 78.0);
+ m_Speed.z = Clamp(m_Speed.z, -78.0, 78.0);
}
@@ -1076,6 +1071,17 @@ void cEntity::SetSwimState(cChunk & a_Chunk)
+void cEntity::DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
+{
+ m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ);
+
+ WrapSpeed();
+}
+
+
+
+
+
void cEntity::HandleAir(void)
{
// Ref.: http://www.minecraftwiki.net/wiki/Chunk_format
@@ -1428,9 +1434,7 @@ void cEntity::SetRoll(double a_Roll)
void cEntity::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
{
- m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ);
-
- WrapSpeed();
+ DoSetSpeed(a_SpeedX, a_SpeedY, a_SpeedZ);
}
@@ -1438,9 +1442,7 @@ void cEntity::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
void cEntity::SetSpeedX(double a_SpeedX)
{
- m_Speed.x = a_SpeedX;
-
- WrapSpeed();
+ SetSpeed(a_SpeedX, m_Speed.y, m_Speed.z);
}
@@ -1448,9 +1450,7 @@ void cEntity::SetSpeedX(double a_SpeedX)
void cEntity::SetSpeedY(double a_SpeedY)
{
- m_Speed.y = a_SpeedY;
-
- WrapSpeed();
+ SetSpeed(m_Speed.x, a_SpeedY, m_Speed.z);
}
@@ -1458,9 +1458,7 @@ void cEntity::SetSpeedY(double a_SpeedY)
void cEntity::SetSpeedZ(double a_SpeedZ)
{
- m_Speed.z = a_SpeedZ;
-
- WrapSpeed();
+ SetSpeed(m_Speed.x, m_Speed.y, a_SpeedZ);
}
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 85ad42d54..2df66e353 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -215,11 +215,22 @@ public:
void SetYaw (double a_Yaw); // In degrees, normalizes to [-180, +180)
void SetPitch (double a_Pitch); // In degrees, normalizes to [-180, +180)
void SetRoll (double a_Roll); // In degrees, normalizes to [-180, +180)
- void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ);
- void SetSpeed (const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); }
- void SetSpeedX (double a_SpeedX);
- void SetSpeedY (double a_SpeedY);
- void SetSpeedZ (double a_SpeedZ);
+
+ /** Sets the speed of the entity, measured in m / sec */
+ void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ);
+
+ /** Sets the speed of the entity, measured in m / sec */
+ void SetSpeed(const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); }
+
+ /** Sets the speed in the X axis, leaving the other speed components intact. Measured in m / sec. */
+ void SetSpeedX(double a_SpeedX);
+
+ /** Sets the speed in the Y axis, leaving the other speed components intact. Measured in m / sec. */
+ void SetSpeedY(double a_SpeedY);
+
+ /** Sets the speed in the Z axis, leaving the other speed components intact. Measured in m / sec. */
+ void SetSpeedZ(double a_SpeedZ);
+
void SetWidth (double a_Width);
void AddPosX (double a_AddPosX);
@@ -429,6 +440,9 @@ protected:
static cCriticalSection m_CSCount;
static int m_EntityCount;
+ /** Measured in meter/second (m/s) */
+ Vector3d m_Speed;
+
int m_UniqueID;
int m_Health;
@@ -486,11 +500,15 @@ protected:
/// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void.
int m_TicksSinceLastVoidDamage;
-
+
+ /** Does the actual speed-setting. The default implementation just sets the member variable value;
+ overrides can provide further processing, such as forcing players to move at the given speed. */
+ virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ);
+
virtual void Destroyed(void) {} // Called after the entity has been destroyed
/** Called in each tick to handle air-related processing i.e. drowning */
- virtual void HandleAir();
+ virtual void HandleAir(void);
/** Called once per tick to set IsSwimming and IsSubmerged */
virtual void SetSwimState(cChunk & a_Chunk);
@@ -506,9 +524,6 @@ private:
/** Measured in degrees, [-180, +180) */
double m_HeadYaw;
- /** Measured in meter/second (m/s) */
- Vector3d m_Speed;
-
/** Measured in degrees, [-180, +180) */
Vector3d m_Rot;
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index cffdd71b1..fdc0bb390 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1274,6 +1274,17 @@ Vector3d cPlayer::GetThrowSpeed(double a_SpeedCoeff) const
void cPlayer::ForceSetSpeed(const Vector3d & a_Speed)
{
SetSpeed(a_Speed);
+}
+
+
+
+
+
+void cPlayer::DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
+{
+ super::DoSetSpeed(a_SpeedX, a_SpeedY, a_SpeedZ);
+
+ // Send the speed to the client so he actualy moves
m_ClientHandle->SendEntityVelocity(*this);
}
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index a9acf6efc..b2142a18b 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -194,7 +194,8 @@ public:
// Sets the current gamemode, doesn't check validity, doesn't send update packets to client
void LoginSetGameMode(eGameMode a_GameMode);
- /** Forces the player to move in the given direction. */
+ /** Forces the player to move in the given direction.
+ @deprecated Use SetSpeed instead. */
void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export
/** Tries to move to a new position, with attachment-related checks (y == -999) */
@@ -511,6 +512,9 @@ protected:
+ /** Sets the speed and sends it to the client, so that they are forced to move so. */
+ virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override;
+
void ResolvePermissions(void);
void ResolveGroups(void);
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index eff11bd01..69c8b9f56 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -59,19 +59,21 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
int RelZ = 0;
BLOCKTYPE Block;
NIBBLETYPE Meta;
+ cChunk * Chunk;
if (a_OtherChunk != NULL)
{
RelX = a_BlockX - a_OtherChunk->GetPosX() * cChunkDef::Width;
RelZ = a_BlockZ - a_OtherChunk->GetPosZ() * cChunkDef::Width;
a_OtherChunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta);
- a_OtherChunk->SetIsRedstoneDirty(true);
+ Chunk = a_OtherChunk;
}
else
{
RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
a_Chunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta);
+ Chunk = a_Chunk;
}
// Every time a block is changed (AddBlock called), we want to go through all lists and check to see if the coordiantes stored within are still valid
@@ -90,7 +92,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
{
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list as it no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
itr = PoweredBlocks->erase(itr);
- a_Chunk->SetIsRedstoneDirty(true);
+ Chunk->SetIsRedstoneDirty(true);
continue;
}
else if (
@@ -105,9 +107,25 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
{
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
itr = PoweredBlocks->erase(itr);
- a_Chunk->SetIsRedstoneDirty(true);
+ Chunk->SetIsRedstoneDirty(true);
continue;
}
+ else if (Block == E_BLOCK_DAYLIGHT_SENSOR)
+ {
+ if (!m_World.IsChunkLighted(Chunk->GetPosX(), Chunk->GetPosZ()))
+ {
+ m_World.QueueLightChunk(Chunk->GetPosX(), Chunk->GetPosZ());
+ }
+ else
+ {
+ if (Chunk->GetTimeAlteredLight(Chunk->GetSkyLight(RelX, a_BlockY + 1, RelZ)) <= 7)
+ {
+ itr = PoweredBlocks->erase(itr);
+ Chunk->SetIsRedstoneDirty(true);
+ continue;
+ }
+ }
+ }
++itr;
}
@@ -121,7 +139,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
{
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
itr = LinkedPoweredBlocks->erase(itr);
- a_Chunk->SetIsRedstoneDirty(true);
+ Chunk->SetIsRedstoneDirty(true);
continue;
}
else if (
@@ -135,7 +153,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
{
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
itr = LinkedPoweredBlocks->erase(itr);
- a_Chunk->SetIsRedstoneDirty(true);
+ Chunk->SetIsRedstoneDirty(true);
continue;
}
}
@@ -145,7 +163,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
{
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer powered through a valid middle block", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
itr = LinkedPoweredBlocks->erase(itr);
- a_Chunk->SetIsRedstoneDirty(true);
+ Chunk->SetIsRedstoneDirty(true);
continue;
}
}
@@ -788,12 +806,12 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int
{
WereItrsChanged = QueueRepeaterPowerChange(a_RelBlockX, a_RelBlockY, a_RelBlockZ, a_Meta, false);
}
- else
+ else if (a_Itr == m_RepeatersDelayList->end())
{
return;
}
}
- else
+ else if (a_Itr == m_RepeatersDelayList->end())
{
return;
}
@@ -1145,6 +1163,10 @@ void cIncrementalRedstoneSimulator::HandleDaylightSensor(int a_RelBlockX, int a_
{
SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
}
+ else
+ {
+ WakeUp(BlockX, a_RelBlockY, BlockZ, m_Chunk);
+ }
}
}
@@ -1429,8 +1451,7 @@ bool cIncrementalRedstoneSimulator::AreCoordsLinkedPowered(int a_RelBlockX, int
-// IsRepeaterPowered tests if a repeater should be powered by testing for power sources behind the repeater.
-// It takes the coordinates of the repeater the the meta value.
+
bool cIncrementalRedstoneSimulator::IsRepeaterPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta)
{
// Repeaters cannot be powered by any face except their back; verify that this is true for a source
@@ -1510,19 +1531,19 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelB
case 0x0:
case 0x2:
{
- // Check if eastern(right) neighbor is a powered on repeater who is facing us.
+ // Check if eastern(right) neighbor is a powered on repeater who is facing us
BLOCKTYPE Block = 0;
if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) // Is right neighbor a powered repeater?
{
NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ) & 0x3;
- if (OtherRepeaterDir == 0x3) { return true; } // If so, I am latched/locked.
+ if (OtherRepeaterDir == 0x3) { return true; } // If so, I am latched/locked
}
- // Check if western(left) neighbor is a powered on repeater who is facing us.
+ // Check if western(left) neighbor is a powered on repeater who is facing us
if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON))
{
NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX -1, a_RelBlockY, a_RelBlockZ) & 0x3;
- if (OtherRepeaterDir == 0x1) { return true; } // If so, I am latched/locked.
+ if (OtherRepeaterDir == 0x1) { return true; } // If so, I am latched/locked
}
break;
@@ -1532,26 +1553,26 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelB
case 0x1:
case 0x3:
{
- // Check if southern(down) neighbor is a powered on repeater who is facing us.
+ // Check if southern(down) neighbor is a powered on repeater who is facing us
BLOCKTYPE Block = 0;
if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON))
{
NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1) & 0x3;
- if (OtherRepeaterDir == 0x0) { return true; } // If so, am latched/locked.
+ if (OtherRepeaterDir == 0x0) { return true; } // If so, am latched/locked
}
- // Check if northern(up) neighbor is a powered on repeater who is facing us.
+ // Check if northern(up) neighbor is a powered on repeater who is facing us
if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON))
{
NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1) & 0x3;
- if (OtherRepeaterDir == 0x2) { return true; } // If so, I am latched/locked.
+ if (OtherRepeaterDir == 0x2) { return true; } // If so, I am latched/locked
}
break;
}
}
- return false; // None of the checks succeeded, I am not a locked repeater.
+ return false; // None of the checks succeeded, I am not a locked repeater
}
@@ -1610,7 +1631,7 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc
{
continue;
}
- a_PowerLevel = std::max(a_PowerLevel, itr->a_PowerLevel);
+ a_PowerLevel = itr->a_PowerLevel;
}
for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr) // Check linked powered list
@@ -1619,10 +1640,10 @@ bool cIncrementalRedstoneSimulator::IsWirePowered(int a_RelBlockX, int a_RelBloc
{
continue;
}
- a_PowerLevel = std::max(a_PowerLevel, itr->a_PowerLevel);
+ a_PowerLevel = itr->a_PowerLevel;
}
- return (a_PowerLevel != 0); // Source was in front of the piston's front face
+ return (a_PowerLevel != 0); // Answer the inital question: is the wire powered?
}
diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h
index 83076311a..1d6a49aca 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.h
+++ b/src/Simulator/IncrementalRedstoneSimulator.h
@@ -156,7 +156,7 @@ private:
bool AreCoordsLinkedPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ);
/** Returns if a coordinate was marked as simulated (for blocks toggleable by players) */
bool AreCoordsSimulated(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, bool IsCurrentStatePowered);
- /** Returns if a repeater is powered */
+ /** Returns if a repeater is powered by testing for power sources behind the repeater */
bool IsRepeaterPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta);
/** Returns if a repeater is locked */
bool IsRepeaterLocked(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, NIBBLETYPE a_Meta);
diff --git a/src/World.h b/src/World.h
index 0a8dcffc4..3e63e2b8c 100644
--- a/src/World.h
+++ b/src/World.h
@@ -47,7 +47,6 @@ class cFlowerPotEntity;
class cFurnaceEntity;
class cNoteEntity;
class cMobHeadEntity;
-class cMobCensus;
class cCompositeChat;
class cCuboid;