diff options
author | lapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-22 18:31:13 +0200 |
---|---|---|
committer | lapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-22 18:31:13 +0200 |
commit | 886c7f5624470c1545fef32c6b048739d131d47b (patch) | |
tree | 1db005dbbd33bce5f29a69cfbf2d66f8adccfb3c | |
parent | WebAdmin should not cause crashes anymore (diff) | |
download | cuberite-886c7f5624470c1545fef32c6b048739d131d47b.tar cuberite-886c7f5624470c1545fef32c6b048739d131d47b.tar.gz cuberite-886c7f5624470c1545fef32c6b048739d131d47b.tar.bz2 cuberite-886c7f5624470c1545fef32c6b048739d131d47b.tar.lz cuberite-886c7f5624470c1545fef32c6b048739d131d47b.tar.xz cuberite-886c7f5624470c1545fef32c6b048739d131d47b.tar.zst cuberite-886c7f5624470c1545fef32c6b048739d131d47b.zip |
-rw-r--r-- | VC2010/MCServer.vcxproj | 2 | ||||
-rw-r--r-- | VC2010/MCServer.vcxproj.filters | 9 | ||||
-rw-r--r-- | VC2010/MCServer.vcxproj.user | 4 | ||||
-rw-r--r-- | source/blocks/Block.cpp | 6 | ||||
-rw-r--r-- | source/blocks/Block.h | 35 | ||||
-rw-r--r-- | source/cPlugin_NewLua.h | 1 | ||||
-rw-r--r-- | source/cWebAdmin.cpp | 4 | ||||
-rw-r--r-- | source/items/Item.h | 13 |
8 files changed, 46 insertions, 28 deletions
diff --git a/VC2010/MCServer.vcxproj b/VC2010/MCServer.vcxproj index 382b6597f..58e1a83d4 100644 --- a/VC2010/MCServer.vcxproj +++ b/VC2010/MCServer.vcxproj @@ -395,7 +395,6 @@ <ClCompile Include="..\source\cWaterSimulator.cpp" />
<ClCompile Include="..\Source\cWebAdmin.cpp" />
<ClCompile Include="..\Source\cWebPlugin.cpp" />
- <ClCompile Include="..\source\cWebPlugin_Lua.cpp" />
<ClCompile Include="..\source\cWindow.cpp" />
<ClCompile Include="..\source\cWolf.cpp" />
<ClCompile Include="..\source\cZombie.cpp" />
@@ -630,7 +629,6 @@ <ClInclude Include="..\source\cWaterSimulator.h" />
<ClInclude Include="..\Source\cWebAdmin.h" />
<ClInclude Include="..\Source\cWebPlugin.h" />
- <ClInclude Include="..\source\cWebPlugin_Lua.h" />
<ClInclude Include="..\source\cWindow.h" />
<ClInclude Include="..\source\cWindowOwner.h" />
<ClInclude Include="..\source\cWolf.h" />
diff --git a/VC2010/MCServer.vcxproj.filters b/VC2010/MCServer.vcxproj.filters index 0104cde21..fff2cf419 100644 --- a/VC2010/MCServer.vcxproj.filters +++ b/VC2010/MCServer.vcxproj.filters @@ -421,9 +421,6 @@ <Filter Include="cPlugin\cPlugin_NewLua">
<UniqueIdentifier>{fb282bd3-cf18-44b3-8ccc-9a5a89701a6d}</UniqueIdentifier>
</Filter>
- <Filter Include="cWebAdmin\cWebPlugin\cWebPlugin">
- <UniqueIdentifier>{31f2d7f9-9684-456b-9d70-011a10e894fd}</UniqueIdentifier>
- </Filter>
<Filter Include="Simulator\cSimulator\cRedstoneSimulator">
<UniqueIdentifier>{4b3b7b43-8e8b-4823-b112-2259fdfff7d3}</UniqueIdentifier>
</Filter>
@@ -859,9 +856,6 @@ <ClCompile Include="..\source\cPlugin_NewLua.cpp">
<Filter>cPlugin\cPlugin_NewLua</Filter>
</ClCompile>
- <ClCompile Include="..\source\cWebPlugin_Lua.cpp">
- <Filter>cWebAdmin\cWebPlugin\cWebPlugin</Filter>
- </ClCompile>
<ClCompile Include="..\source\Globals.cpp" />
<ClCompile Include="..\source\cFile.cpp" />
<ClCompile Include="..\source\StringUtils.cpp" />
@@ -1403,9 +1397,6 @@ <ClInclude Include="..\source\cPlugin_NewLua.h">
<Filter>cPlugin\cPlugin_NewLua</Filter>
</ClInclude>
- <ClInclude Include="..\source\cWebPlugin_Lua.h">
- <Filter>cWebAdmin\cWebPlugin\cWebPlugin</Filter>
- </ClInclude>
<ClInclude Include="..\source\Globals.h" />
<ClInclude Include="..\source\cFile.h" />
<ClInclude Include="..\source\StringUtils.h" />
diff --git a/VC2010/MCServer.vcxproj.user b/VC2010/MCServer.vcxproj.user index 61612b15b..8b9b8fedb 100644 --- a/VC2010/MCServer.vcxproj.user +++ b/VC2010/MCServer.vcxproj.user @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
+ <LocalDebuggerWorkingDirectory>..\MCServer</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommand>$(TargetDir)\$(TargetName)_debug$(TargetExt)</LocalDebuggerCommand>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
+ <LocalDebuggerWorkingDirectory>..\MCServer</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug with optimized Noise|Win32'">
diff --git a/source/blocks/Block.cpp b/source/blocks/Block.cpp index 6bd984d8d..400727e80 100644 --- a/source/blocks/Block.cpp +++ b/source/blocks/Block.cpp @@ -238,12 +238,6 @@ void cBlockHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_ OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
}
-
-int cBlockHandler::GetTickRate()
-{
- return 10;
-}
-
char cBlockHandler::GetDropCount()
{
return 1;
diff --git a/source/blocks/Block.h b/source/blocks/Block.h index 2683cc3b5..ef22e01b5 100644 --- a/source/blocks/Block.h +++ b/source/blocks/Block.h @@ -10,26 +10,43 @@ class cBlockHandler {
public:
cBlockHandler(BLOCKTYPE a_BlockID);
- //Called when the block gets ticked
+
+ // Called when the block gets ticked either by a random tick or by a queued tick
virtual void OnUpdate(cWorld *a_World, int a_X, int a_Y, int a_Z);
+
+ // Will be called by cBlockHandler::PlaceBlock after the player has placed a new block
virtual void OnPlacedByPlayer(cWorld *a_World, cPlayer * a_Player, int a_X, int a_Y, int a_Z, int a_Dir);
+ // Will be called before the player has destroyed a block
virtual void OnDestroyedByPlayer(cWorld *a_World, cPlayer * a_Player, int a_X, int a_Y, int a_Z);
+ // Will be called when a new block was placed. Will be called before OnPlacedByPlayer
virtual void OnPlaced(cWorld *a_World, int a_X, int a_Y, int a_Z, int a_Dir);
+ // Will be called before a block gets destroyed / replaced with air
virtual void OnDestroyed(cWorld *a_World, int a_X, int a_Y, int a_Z);
+ // Will be called when a direct neighbor of this block has been changed (The position is the own position, not the neighbor position)
virtual void OnNeighborChanged(cWorld *a_World, int a_X, int a_Y, int a_Z);
+ // Notifies all neighbors of the give block about a change
static void NeighborChanged(cWorld *a_World, int a_X, int a_Y, int a_Z);
+ // Will be called while the player diggs the block.
virtual void OnDigging(cWorld *a_World, cPlayer *a_Player, int a_X, int a_Y, int a_Z);
+ // Will be called if the user right clicks the block and the block is useable
virtual void OnUse(cWorld *a_World, cPlayer *a_Player, int a_X, int a_Y, int a_Z);
+ // This function handles the real block placement for the give block by a player and also calls the OnPlacedByPlayer function
virtual void PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir);
- virtual int GetTickRate();
+ // Indicates how much items are dropped DEFAULT: 1
virtual char GetDropCount();
+ // Indicates the id dropped by this block DEFAULT: BlockID
virtual int GetDropID();
+ // Indicates the Drop Meta data based on the block meta DEFAULT: BlockMeta
virtual NIBBLETYPE GetDropMeta(NIBBLETYPE a_BlockMeta);
- virtual bool NeedsRandomTicks();
+ // This function handles the dropping of a block based on the Drop id, drop count and drop meta. This will not destroy the block
virtual void DropBlock(cWorld *a_World, int a_X, int a_Y, int a_Z);
+
- /// Checks if the block can stay at the specified coords in the
+ // Indicates whether this block needs random ticks DEFAULT: False
+ virtual bool NeedsRandomTicks();
+
+ /// Checks if the block can stay at the specified coords in the world
virtual bool CanBeAt(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ);
/// Checks if the block can be placed at this point. Default: CanBeAt(...) NOTE: This call doesn't actually place the block
@@ -38,11 +55,13 @@ public: /// Called when the player tries to place a block on top of this block (Only if he aims directly on this block); return false to disallow
virtual bool AllowBlockOnTop(void);
- /// Called to check whether this block supports a rclk action. If it returns true, OnClicked() is called
+ /// Called to check whether this block supports a rclk action. If it returns true, OnUse() is called
virtual bool IsUseable(void);
+ // Indicates whether the client will click through this block. For example digging a fire will hit the block below the fire so fire is clicked through
virtual bool IsClickedThrough(void);
+ // Checks if the player can build "inside" this block. For example blocks placed "on" snow will be placed at the same position. So: Snow ignores Build collision
virtual bool IgnoreBuildCollision(void);
/// Indicates this block can be placed on the side of other blocks. Default: true
@@ -51,16 +70,20 @@ public: /// Does this block drop if it gets destroyed by an unsuitable situation? Default: true
virtual bool DropOnUnsuitable();
+
+ // Static function to get the blockhandler for an specific block id
static cBlockHandler * GetBlockHandler(BLOCKTYPE a_BlockID);
+ // Deletes all initialised block handlers
static void Deinit();
protected:
BLOCKTYPE m_BlockID;
+ // Creates a new blockhandler for the given block id. For internal use only, use GetBlockHandler instead.
static cBlockHandler *CreateBlockHandler(BLOCKTYPE a_BlockID);
static cBlockHandler *m_BlockHandler[256];
static bool m_HandlerInitialized; //used to detect if the blockhandlers are initialized
};
-
+// Shortcut to get the blockhandler for a specific block
inline cBlockHandler *BlockHandler(BLOCKTYPE a_BlockID) { return cBlockHandler::GetBlockHandler(a_BlockID); }
\ No newline at end of file diff --git a/source/cPlugin_NewLua.h b/source/cPlugin_NewLua.h index d48c38127..a2eddf89b 100644 --- a/source/cPlugin_NewLua.h +++ b/source/cPlugin_NewLua.h @@ -9,7 +9,6 @@ typedef struct lua_State lua_State; -class cWebPlugin_Lua; diff --git a/source/cWebAdmin.cpp b/source/cWebAdmin.cpp index e70d60f7f..b12428711 100644 --- a/source/cWebAdmin.cpp +++ b/source/cWebAdmin.cpp @@ -5,7 +5,6 @@ #include "cStringMap.h" #include "cWebPlugin.h" -#include "cWebPlugin_Lua.h" #include "cPluginManager.h" #include "cPlugin.h" @@ -196,11 +195,14 @@ void cWebAdmin::Request_Handler(webserver::http_request* r) Content = (*itr)->HandleWebRequest( &Request ); cWebPlugin* WebPlugin = *itr; FoundPlugin = WebPlugin->GetName(); + /* + TODO: Is this needed anymore? cWebPlugin_Lua* LuaPlugin = dynamic_cast< cWebPlugin_Lua* >( WebPlugin ); if( LuaPlugin ) { FoundPlugin += " - " + LuaPlugin->GetTabNameForRequest( &Request ).first; } + */ break; } } diff --git a/source/items/Item.h b/source/items/Item.h index f3d5842b8..67935ecb4 100644 --- a/source/items/Item.h +++ b/source/items/Item.h @@ -18,9 +18,13 @@ class cItemHandler {
public:
cItemHandler(int a_ItemID);
+ // Called when the player tries to use the item. Return false to make the item unusable. DEFAULT: False
virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z, char a_Dir); //eg for fishing or hoes
+ // Called while the player diggs a block using this item
virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, cItem * a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace);
+ // Called when the player destroys a block using this item. This also calls the drop function for the destroyed block
virtual void OnBlockDestroyed(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z);
+ // Called after the player has eaten this item.
virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item);
/// Returns the maximum stack size for a given item
@@ -39,20 +43,27 @@ public: char PoisionChance; //0 - 100
};
+ // Returns the FoodInfo for this item. (FoodRecovery, Saturation and PoisionChance)
virtual FoodInfo GetFoodInfo();
+ // Lets the player eat a selected item. Returns true if the player ate the item
virtual bool EatItem(cPlayer *a_Player, cItem *a_Item);
+ // Places the current block and removes the item from the player inventory
virtual void PlaceBlock(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z, char a_Dir);
+ // Indicates if this item is a tool
virtual bool IsTool();
+ // Indicates if this item is food
virtual bool IsFood();
//Blocks simply get placed
virtual bool IsPlaceable();
+ // Returns the block type on placement
virtual BLOCKTYPE GetBlockType();
+ //Returns the block meta on placement
virtual NIBBLETYPE GetBlockMeta(short a_ItemDamage);
-
+ // Returns whether this tool/item can harvest a specific block (e.g. wooden pickaxe can harvest stone, but wood can´t) DEFAULT: False
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockID);
static cItemHandler *GetItemHandler(int a_ItemID);
|