summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-12 22:03:46 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-12 22:03:46 +0200
commit5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e (patch)
treedffb59765b1325e416cd79a7d20030b62178e4b7
parentFixed an error (diff)
downloadcuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar
cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar.gz
cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar.bz2
cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar.lz
cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar.xz
cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar.zst
cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.zip
-rw-r--r--VC2008/MCServer.vcproj8
-rw-r--r--VC2010/MCServer.vcxproj2
-rw-r--r--VC2010/MCServer.vcxproj.filters9
-rw-r--r--recipes.txt338
-rw-r--r--source/AllToLua.pkg3
-rw-r--r--source/Bindings.cpp960
-rw-r--r--source/Bindings.h2
-rw-r--r--source/CraftingRecipes.cpp271
-rw-r--r--source/CraftingRecipes.h95
-rw-r--r--source/cCraftingWindow.cpp41
-rw-r--r--source/cCreativeInventory.cpp1
-rw-r--r--source/cInventory.cpp85
-rw-r--r--source/cItem.h61
-rw-r--r--source/cRecipeChecker.cpp467
-rw-r--r--source/cRecipeChecker.h39
-rw-r--r--source/cRoot.cpp4
-rw-r--r--source/cRoot.h3
-rw-r--r--source/cServer.cpp1
-rw-r--r--source/cSurvivalInventory.cpp35
19 files changed, 1393 insertions, 1032 deletions
diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj
index 50c984873..c4387bf7f 100644
--- a/VC2008/MCServer.vcproj
+++ b/VC2008/MCServer.vcproj
@@ -468,14 +468,6 @@
>
</File>
<File
- RelativePath="..\source\cRecipeChecker.cpp"
- >
- </File>
- <File
- RelativePath="..\source\cRecipeChecker.h"
- >
- </File>
- <File
RelativePath="..\source\cRedstone.cpp"
>
</File>
diff --git a/VC2010/MCServer.vcxproj b/VC2010/MCServer.vcxproj
index aeb539e3d..6768105cc 100644
--- a/VC2010/MCServer.vcxproj
+++ b/VC2010/MCServer.vcxproj
@@ -357,7 +357,6 @@
<ClCompile Include="..\Source\cPluginManager.cpp" />
<ClCompile Include="..\source\cPlugin_NewLua.cpp" />
<ClCompile Include="..\source\CraftingRecipes.cpp" />
- <ClCompile Include="..\Source\cRecipeChecker.cpp" />
<ClCompile Include="..\source\cRedstone.cpp" />
<ClCompile Include="..\source\cRedstoneSimulator.cpp" />
<ClCompile Include="..\Source\cReferenceManager.cpp" />
@@ -539,7 +538,6 @@
<ClInclude Include="..\Source\cPluginManager.h" />
<ClInclude Include="..\source\cPlugin_NewLua.h" />
<ClInclude Include="..\source\CraftingRecipes.h" />
- <ClInclude Include="..\Source\cRecipeChecker.h" />
<ClInclude Include="..\source\cRedstone.h" />
<ClInclude Include="..\source\cRedstoneSimulator.h" />
<ClInclude Include="..\Source\cReferenceManager.h" />
diff --git a/VC2010/MCServer.vcxproj.filters b/VC2010/MCServer.vcxproj.filters
index 1457fac9e..0db247c6c 100644
--- a/VC2010/MCServer.vcxproj.filters
+++ b/VC2010/MCServer.vcxproj.filters
@@ -55,9 +55,6 @@
<Filter Include="cWindow\cWindowOwner">
<UniqueIdentifier>{014bf50c-1589-4fda-8b62-1a8100e451f2}</UniqueIdentifier>
</Filter>
- <Filter Include="cRecipeChecker">
- <UniqueIdentifier>{f7875f7a-f596-4690-8f0d-678989b9d7c3}</UniqueIdentifier>
- </Filter>
<Filter Include="cWindow\cCraftingWindow">
<UniqueIdentifier>{0047a86b-b12e-4b61-987f-1e558719226f}</UniqueIdentifier>
</Filter>
@@ -490,9 +487,6 @@
<ClCompile Include="..\source\cWindow.cpp">
<Filter>cWindow</Filter>
</ClCompile>
- <ClCompile Include="..\Source\cRecipeChecker.cpp">
- <Filter>cRecipeChecker</Filter>
- </ClCompile>
<ClCompile Include="..\source\cCraftingWindow.cpp">
<Filter>cWindow\cCraftingWindow</Filter>
</ClCompile>
@@ -975,9 +969,6 @@
<Filter>cWindow\cWindowOwner</Filter>
</ClInclude>
<ClInclude Include="..\Source\MemoryLeak.h" />
- <ClInclude Include="..\Source\cRecipeChecker.h">
- <Filter>cRecipeChecker</Filter>
- </ClInclude>
<ClInclude Include="..\source\cCraftingWindow.h">
<Filter>cWindow\cCraftingWindow</Filter>
</ClInclude>
diff --git a/recipes.txt b/recipes.txt
deleted file mode 100644
index c6b229f99..000000000
--- a/recipes.txt
+++ /dev/null
@@ -1,338 +0,0 @@
-#***********************************#
-# Default Crafting Recipes #
-#***********************************#
-# #
-# Coded by: FakeTruth #
-# Written by: Aelux #
-# #
-# Contributors: Luksor #
-# xoft #
-# #
-#***********************************#
-
-
-
-#******************************************************#
-# Basic Notation Help
-#
-# 1x1,1:1:17:1@5:4 -> Produces 4 Planks
-#
-#
-# --How does the above notation work?
-#
-# Ans- Think about the crafting table as coordiantes
-# on a graph where you have an "X" axis and a
-# "Y" axis. The "X" is the horizantle axis and
-# the "Y" is the vertical axis.
-#
-# Syntax: <dimensions>,<ingredient1>,<ingredient2>,...<ingredientN>@<result>
-# <dimensions> = <Width>x<Height>
-# <ingredientN> = x:y:<ItemID>:<Amount>
-# <result> = <ResultingItemID>:<Amount>
-
-
-#--------------------Basic EXAMPLE---------------------
-#
-# Example- 3x3,2:3:280:8@5:2
-#
-# Recipe- w=3,h=3,x=2,y=3,Item=Stick,Amount=8
-# Result- 2 Wood Planks (2 of ItemID 5)
-#
-# Table grid is set to 3 by 3 (O = empty, X = full)
-# +---+
-# |OOO|
-# |OOO|
-# |OXO|
-# +---+
-#
-# --How does the above example work?
-#
-# Ans- This means, if you place a stack of 8 sticks
-# at that exact location on the Work Bench,
-# which is a 3x3 grid, you will recieve 2 Wood
-# Planks PER 8 sticks.
-#
-#
-#
-#******************************************************
-
-
-#---------------Grid Abstraction EXAMPLE------------------#
-#
-# Example- 1x1,1:1:280:8@5:2
-# Recipe- w=1,h=1,x=1,y=1,Item=Stick,Amount=8
-# Result- 2 Wood Planks (2 of ItemID 5)
-#
-# Table grid is set to 1 by 1 (O = empty,X = full)
-# +-+
-# |X|
-# +-+
-#
-# -- How does the above example compare to the Basic
-# example?
-#
-# Ans- This means, you can place a stack of 8 sticks
-# ANYwhere a 1x1 grid can fit. Obviously since a 1x1
-# grid is a single slot, it can be abstracted to fill
-# any single slot on any size grid.
-#
-# There are 9 positions for the 1x1 grid in the
-# work bench (3x3) and 4 positions within the
-# inventory grid (2x2).
-#********************************************************
-
-
-
-
-
-
-#******************************************************#
-# Utilities
-#
-3x2,1:2:265:1,2:3:265:1@325:1 # -> Bucket
-1x2,1:1:265:1,1:2:318:1@259:1 # -> Lighter
-3x3,1:3:280:1,2:2:280:1,3:1:280:1,3:2:287:1,3:3:287:1@346:1 # -> Fishing Rod
-3x3,1:2:265:1,2:1:265:1,2:2:331:1,3:2:265:1,2:3:265:1@345:1 # -> Compass
-3x3,1:2:266:1,2:1:266:1,2:2:331:1,3:2:266:1,2:3:266:1@345:1 # -> Watch
-3x3,1:*:287:1,2:1:280:1,3:2:280:1,2:3:280:1@261:1 # -> Bow
-1x3,1:1:318:1,1:2:280:1,1:3:288:1@262:4 # -> Arrow
-2x3,*:*:5:1@64:1 # -> Wooden Door
-3x3,*:1:280:-1@85:2 # -> Fence
-3x2,*:*:265:1@101:16 # -> Iron Bars
-3x2,*:*:20:1@102:16 # -> Glass Pane
-3x3,1:*:280:1,3:*:280:1,2:2:280:1@65:1 # -> Ladder
-3x2,*:*:5:1,2:3:280:1@323:1 # -> Sign
-1x2,1:1:368:1,1:2:377:1@381:1 # -> Eye of Ender
-3x2,1:1:20:1,2:2:20:1,3:1:20:1@374:3 # -> Glass Bottle
-3x3,1:*:265:1,2:3:265:1,3:*:265:1@380:1 # -> Cauldron
-3x2,2:1:369:1,*:2:4:1@379:1 # -> Brewing Stand
-
-
-
-
-
-#******************************************************#
-# Travel Utilities
-#
-3x3,1:*:265:1,3:*:265:1,2:2:280:1@66:16 # -> Rails
-3x3,1:*:266:1,3:*:266:1,2:2:280:1,2:3:331:1@27:6 # -> Powered Rail
-3x3,1:*:265:1,3:*:265:1,2:2:70:1,2:3:331:1@28:6 # -> Detector Rail
-3x2,1:2:265:1,3:2:265:1,*:3:265:1@328:1 # -> Minecart
-1x2,1:1:61:1,1:2:328:1@343:1 # -> Powered Minecart
-1x2,1:1:54:1,1:2:328:1@342:1 # -> Storage Minecart
-3x2,1:2:5:1,3:2:5:1,*:3:5:1@333:1 # -> Boat
-
-
-
-
-
-#******************************************************#
-# Control Utilities
-#
-1x2,1:1:331:1,1:2:280:1@76:1 # -> Redstone Torch
-1x2,1:1:280:1,1:2:4:1@69:1 # -> Lever
-2x1,*:*:5:1@72:1 # -> Wooden Preassure Plate
-2x1,*:*:4:1@70:1 # -> Stone Preassure Plate
-1x2,1:1:1:1,1:2:1:1@77:1 # -> Button
-2x3,*:*:265:1@71:1 # -> Iron Door
-3x2,*:2:1:1,1:1:76:1,2:1:331:1,3:1:76:1@356:1 # -> Repeater
-3x3,2:1:331:1,1:2:331:1,2:2:89:1,3:2:331:1,2:3:331:1@123:1 # -> Lamp
-3x3,*:1:5:1,1:2:4:1,2:2:265:1,3:2:4:1,1:3:4:1,2:3:331:1,3:3:4:1@33:1 # -> Piston
-1x2,1:1:341:1,1:2:33:1@29:1 # -> Sticky Piston
-
-
-
-
-
-#******************************************************#
-# Material Blocks
-#
-3x3,*:*:265:1@42:1 # -> Iron
-3x3,*:*:266:1@41:1 # -> Gold
-3x3,*:*:264:1@57:1 # -> Diamond
-2x2,*:*:287:1@35:1 # -> Wool
-2x2,*:*:337:1@82:1 # -> Clay
-2x2,*:*:336:1@45:1 # -> Brick
-2x2,*:*:341:1@80:1 # -> Snow
-
-
-
-
-
-#******************************************************#
-# Special Blocks
-#
-3x1,*:*:1:1@44:3 # -> Stone Step
-3x3,*:3:5:1,1:1:5:1,1:2:5:1,2:2:5:1@53:4 # -> Wood Stairs
-3x3,*:3:4:1,1:1:4:1,1:2:4:1,2:2:4:1@67:4 # -> Cobblestone Stairs
-3x3,1:1:289:1,3:1:289:1,2:2:289:1,1:3:289:1,3:3:289:1,2:1:12:1,1:2:12:1,3:2:12:1,2:3:12:1@46:1 # -> TNT
-3x3,2:2:5:-1,2:2:264:1@84:1 # -> Jukebox
-2x2,*:*:348:1@89:1 # -> Glow Stone
-2x2,*:*:1:1@98:4 # -> Stone Brick
-2x2,*:*:12:1@24:1 # -> Sandstone
-3x2,*:1:35:1,*:2:5:1@355:1 # -> Bed
-3x3,2:1:340:1,1:2:264:1,2:2:49:1,3:2:264:1,*:3:49:1@116:1 # -> Enchantment Table
-
-
-
-
-
-#******************************************************#
-# Block To Ingot
-#
-1x1,1:1:42:1@265:9 # -> Iron
-1x1,1:1:41:1@266:9 # -> Gold
-3x3,*:*:371:1@266:1 # -> Gold (from Nuggets)
-1x1,1:1:57:1@264:9 # -> Diamond
-
-
-
-
-
-#******************************************************#
-# Shovel
-#
-1x3,1:1:5:1,1:2:280:1,1:3:280:1@269:1 # -> Wooden
-1x3,1:1:4:1,1:2:280:1,1:3:280:1@273:1 # -> Stone
-1x3,1:1:266:1,1:2:280:1,1:3:280:1@284:1 # -> Gold
-1x3,1:1:265:1,1:2:280:1,1:3:280:1@256:1 # -> Iron
-1x3,1:1:264:1,1:2:280:1,1:3:280:1@277:1 #.-> Diamond
-
-
-
-
-
-#******************************************************#
-# Pickaxe
-#
-3x3,*:1:5:1,2:2:280:1,2:3:280:1@270:1 # -> Wooden
-3x3,*:1:4:1,2:2:280:1,2:3:280:1@274:1 # -> Stone
-3x3,*:1:266:1,2:2:280:1,2:3:280:1@285:1 # -> Gold
-3x3,*:1:265:1,2:2:280:1,2:3:280:1@257:1 # -> Iron
-3x3,*:1:264:1,2:2:280:1,2:3:280:1@278:1 # -> Diamond
-
-
-
-
-
-#******************************************************#
-# Axe
-#
-2x2,2:2:5:-1,2:2:280:1,2:3:280:1@271:1 # -> Wooden (L)
-2x2,1:2:5:-1,1:2:280:1,1:3:280:1@271:1 # -> Wooden (R)
-2x2,2:2:4:-1,2:2:280:1,2:3:280:1@275:1 # -> Stone (L)
-2x2,1:2:4:-1,1:2:280:1,1:3:280:1@275:1 # -> Stone (R)
-2x2,2:2:266:-1,2:2:280:1,2:3:280:1@286:1 # -> Gold (L)
-2x2,1:2:266:-1,1:2:280:1,1:3:280:1@286:1 # -> Gold (R)
-2x2,2:2:265:-1,2:2:280:1,2:3:280:1@258:1 # -> Iron (L)
-2x2,1:2:265:-1,1:2:280:1,1:3:280:1@258:1 #.-> Iron (R)
-2x2,2:2:264:-1,2:2:280:1,2:3:280:1@279:1 #.-> Diamond (L)
-2x2,1:2:264:-1,1:2:280:1,1:3:280:1@279:1 #.-> Diamond (R)
-
-
-
-
-
-#******************************************************#
-# Sword
-#
-1x2,*:*:5:1,1:3:280:1@268:1 # -> Wooden
-1x2,*:*:4:1,1:3:280:1@272:1 # -> Stone
-1x2,*:*:266:1,1:3:280:1@283:1 # -> Gold
-1x2,*:*:265:1,1:3:280:1@267:1 # -> Iron
-1x2,*:*:264:1,1:3:280:1@276:1 # -> Diamond
-
-
-
-
-
-#******************************************************#
-# Hoe
-#
-2x1,*:*:5:1,2:2:280:1,2:3:280:1@290:1 # -> Wooden (L)
-2x1,*:*:5:1,1:2:280:1,1:3:280:1@290:1 # -> Wooden (R)
-2x1,*:*:4:1,2:2:280:1,2:3:280:1@291:1 # -> Stone (L)
-2x1,*:*:4:1,1:2:280:1,1:3:280:1@291:1 # -> Stone (R)
-2x1,*:*:266:1,2:2:280:1,2:3:280:1@294:1 # -> Gold (L)
-2x1,*:*:266:1,1:2:280:1,1:3:280:1@294:1 # -> Gold (R)
-2x1,*:*:265:1,2:2:280:1,2:3:280:1@292:1 # -> Iron (L)
-2x1,*:*:265:1,1:2:280:1,1:3:280:1@292:1 # -> Iron (R)
-2x1,*:*:264:1,2:2:280:1,2:3:280:1@293:1 # -> Diamond (L)
-2x1,*:*:264:1,1:2:280:1,1:3:280:1@293:1 # -> Diamond (R)
-
-
-
-
-
-#******************************************************#
-# Leather Armor
-#
-3x2,2:2:334:-1@298:1 #-> Helmet
-3x3,2:1:334:-1@299:1 #-> Chest Piece
-3x3,1:*:334:1,3:*:334:1,2:1:334:1@300:1 #-> Leggings
-3x2,2:*:334:-1@301:1 #-> Boots
-
-
-
-
-
-#*******************************************************#
-# Gold Armor
-#
-3x2,2:2:266:-1@314:1 #-> Helmet
-3x3,2:1:266:-1@315:1 #-> Chest Piece
-3x3,1:*:266:1,3:*:266:1,2:1:266:1@316:1 #-> Leggings
-3x2,2:*:266:-1@317:1 #-> Boots
-
-
-
-
-
-#*******************************************************#
-# Iron Armor
-#
-3x2,2:2:265:-1@306:1 #-> Helmet
-3x3,2:1:265:-1@307:1 #-> Chest Piece
-3x3,1:*:265:1,3:*:265:1,2:1:265:1@308:1 #-> Leggings
-3x2,2:*:265:-1@309:1 #-> Boots
-
-
-
-
-
-#*******************************************************#
-# Diamond Armor
-#
-3x2,2:2:264:-1@310:1 #-> Helmet
-3x3,2:1:264:-1@311:1 #-> Chest Piece
-3x3,1:*:264:1,3:*:264:1,2:1:264:1@312:1 #-> Leggings
-3x2,2:*:264:-1@313:1 #-> Boots
-
-
-
-
-
-#*******************************************************#
-# Decorative
-#
-3x1,*:3:338:1@339:3 #-> Paper
-1x3,2:*:338:1@340:1 #-> Book
-3x3,*:1:5:1,*:2:349:1,*:3:5:1@47:1 #-> Book Shelf
-3x3,2:2:280:-1,2:2:35:1@321:1 #-> Painting
-1x2,1:1:86:1,1:2:50:1@91:1 #-> Jack-O-Lantern
-
-
-
-
-
-#*******************************************************#
-# O t h e r I t e m s
-#
-1x1,1:1:369:1@377:2 #-> Blaze Powder
-1x2,1:1:341:1,1:2:377:1@378:1 #-> Magma Cream
-1x1,1:1:266:1@371:9 #-> Gold Nugget
-
-
-
-
-
diff --git a/source/AllToLua.pkg b/source/AllToLua.pkg
index 9ccb0eb1d..c6e0f0565 100644
--- a/source/AllToLua.pkg
+++ b/source/AllToLua.pkg
@@ -45,4 +45,5 @@ $cfile "cGroup.h"
$cfile "packets/cPacket_Login.h"
$cfile "packets/cPacket_BlockDig.h"
$cfile "packets/cPacket_BlockPlace.h"
-$cfile "cLuaChunk.h" \ No newline at end of file
+$cfile "cLuaChunk.h"
+$cfile "CraftingRecipes.h"
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 07adbea1e..56f27fd32 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 06/10/12 15:55:56.
+** Generated automatically by tolua++-1.0.92 on 06/12/12 21:57:04.
*/
#ifndef __cplusplus
@@ -56,10 +56,18 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S);
#include "packets/cPacket_BlockDig.h"
#include "packets/cPacket_BlockPlace.h"
#include "cLuaChunk.h"
+#include "CraftingRecipes.h"
/* function to release collected object via destructor */
#ifdef __cplusplus
+static int tolua_collect_cMCLogger (lua_State* tolua_S)
+{
+ cMCLogger* self = (cMCLogger*) tolua_tousertype(tolua_S,1,0);
+ Mtolua_delete(self);
+ return 0;
+}
+
static int tolua_collect_cItem (lua_State* tolua_S)
{
cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
@@ -109,9 +117,9 @@ static int tolua_collect_cPlugin (lua_State* tolua_S)
return 0;
}
-static int tolua_collect_cMCLogger (lua_State* tolua_S)
+static int tolua_collect_cCraftingGrid (lua_State* tolua_S)
{
- cMCLogger* self = (cMCLogger*) tolua_tousertype(tolua_S,1,0);
+ cCraftingGrid* self = (cCraftingGrid*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
@@ -164,32 +172,33 @@ static int tolua_collect_Vector3d (lua_State* tolua_S)
static void tolua_reg_types (lua_State* tolua_S)
{
tolua_usertype(tolua_S,"TakeDamageInfo");
+ tolua_usertype(tolua_S,"cCraftingRecipe");
tolua_usertype(tolua_S,"cPlugin");
- tolua_usertype(tolua_S,"cLuaChunk");
+ tolua_usertype(tolua_S,"cCraftingGrid");
tolua_usertype(tolua_S,"cStringMap");
+ tolua_usertype(tolua_S,"cLuaChunk");
tolua_usertype(tolua_S,"Lua__cEntity");
tolua_usertype(tolua_S,"Lua__cPacket_BlockDig");
- tolua_usertype(tolua_S,"cTCPLink");
tolua_usertype(tolua_S,"Json::Value");
tolua_usertype(tolua_S,"cInventory");
tolua_usertype(tolua_S,"cRoot");
tolua_usertype(tolua_S,"Lua__cTCPLink");
- tolua_usertype(tolua_S,"cMCLogger");
- tolua_usertype(tolua_S,"cGroup");
+ tolua_usertype(tolua_S,"cPlugin_NewLua");
+ tolua_usertype(tolua_S,"cTracer");
tolua_usertype(tolua_S,"cPlugin::CommandStruct");
tolua_usertype(tolua_S,"cPickup");
- tolua_usertype(tolua_S,"cTracer");
+ tolua_usertype(tolua_S,"cGroup");
tolua_usertype(tolua_S,"cPacket_Login");
tolua_usertype(tolua_S,"cClientHandle");
tolua_usertype(tolua_S,"cStep");
tolua_usertype(tolua_S,"cFurnaceRecipe");
- tolua_usertype(tolua_S,"cCuboid");
+ tolua_usertype(tolua_S,"cMCLogger");
tolua_usertype(tolua_S,"cChatColor");
- tolua_usertype(tolua_S,"Vector3i");
+ tolua_usertype(tolua_S,"cCuboid");
tolua_usertype(tolua_S,"cPacket_PickupSpawn");
tolua_usertype(tolua_S,"Lua__cWebPlugin");
tolua_usertype(tolua_S,"Lua__cPawn");
- tolua_usertype(tolua_S,"cPlugin_NewLua");
+ tolua_usertype(tolua_S,"Vector3i");
tolua_usertype(tolua_S,"cItem");
tolua_usertype(tolua_S,"Vector3f");
tolua_usertype(tolua_S,"cPlugin_Lua");
@@ -198,9 +207,9 @@ static void tolua_reg_types (lua_State* tolua_S)
tolua_usertype(tolua_S,"cPacket");
tolua_usertype(tolua_S,"cPacket_BlockDig");
tolua_usertype(tolua_S,"cWebAdmin");
- tolua_usertype(tolua_S,"cCraftingRecipes");
+ tolua_usertype(tolua_S,"cTCPLink");
tolua_usertype(tolua_S,"cBlockEntity");
- tolua_usertype(tolua_S,"cRecipeChecker");
+ tolua_usertype(tolua_S,"cCraftingRecipes");
tolua_usertype(tolua_S,"cGroupManager");
tolua_usertype(tolua_S,"Lua__cPlugin");
tolua_usertype(tolua_S,"Lua__cPickup");
@@ -11493,6 +11502,37 @@ static int tolua_AllToLua_cItem_Empty00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: Clear of class cItem */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItem_Clear00
+static int tolua_AllToLua_cItem_Clear00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Clear'", NULL);
+#endif
+ {
+ self->Clear();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Clear'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: IsEmpty of class cItem */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItem_IsEmpty00
static int tolua_AllToLua_cItem_IsEmpty00(lua_State* tolua_S)
@@ -11559,6 +11599,102 @@ static int tolua_AllToLua_cItem_Equals00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: GetMaxDuration of class cItem */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItem_GetMaxDuration00
+static int tolua_AllToLua_cItem_GetMaxDuration00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cItem* self = (const cItem*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetMaxDuration'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->GetMaxDuration();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetMaxDuration'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: DamageItem of class cItem */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItem_DamageItem00
+static int tolua_AllToLua_cItem_DamageItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'DamageItem'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->DamageItem();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'DamageItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: HasDuration of class cItem */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItem_HasDuration00
+static int tolua_AllToLua_cItem_HasDuration00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cItem",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'HasDuration'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->HasDuration();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'HasDuration'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: GetJson of class cItem */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cItem_GetJson00
static int tolua_AllToLua_cItem_GetJson00(lua_State* tolua_S)
@@ -11625,6 +11761,36 @@ static int tolua_AllToLua_cItem_FromJson00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: IsEnchantable of class cItem */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cItem_IsEnchantable00
+static int tolua_AllToLua_cItem_IsEnchantable00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cItem",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ ENUM_ITEM_ID item = ((ENUM_ITEM_ID) (int) tolua_tonumber(tolua_S,2,0));
+ {
+ bool tolua_ret = (bool) cItem::IsEnchantable(item);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsEnchantable'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* get function: m_ItemID of class cItem */
#ifndef TOLUA_DISABLE_tolua_get_cItem_m_ItemID
static int tolua_get_cItem_m_ItemID(lua_State* tolua_S)
@@ -12943,38 +13109,6 @@ static int tolua_AllToLua_cRoot_GetGroupManager00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetRecipeChecker of class cRoot */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cRoot_GetRecipeChecker00
-static int tolua_AllToLua_cRoot_GetRecipeChecker00(lua_State* tolua_S)
-{
-#ifndef TOLUA_RELEASE
- tolua_Error tolua_err;
- if (
- !tolua_isusertype(tolua_S,1,"cRoot",0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,2,&tolua_err)
- )
- goto tolua_lerror;
- else
-#endif
- {
- cRoot* self = (cRoot*) tolua_tousertype(tolua_S,1,0);
-#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetRecipeChecker'", NULL);
-#endif
- {
- cRecipeChecker* tolua_ret = (cRecipeChecker*) self->GetRecipeChecker();
- tolua_pushusertype(tolua_S,(void*)tolua_ret,"cRecipeChecker");
- }
- }
- return 1;
-#ifndef TOLUA_RELEASE
- tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'GetRecipeChecker'.",&tolua_err);
- return 0;
-#endif
-}
-#endif //#ifndef TOLUA_DISABLE
-
/* method: GetCraftingRecipes of class cRoot */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cRoot_GetCraftingRecipes00
static int tolua_AllToLua_cRoot_GetCraftingRecipes00(lua_State* tolua_S)
@@ -17598,6 +17732,704 @@ static int tolua_AllToLua_cLuaChunk_FillBlocks00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: new of class cCraftingGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingGrid_new00
+static int tolua_AllToLua_cCraftingGrid_new00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cCraftingGrid",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ int a_Width = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_Height = ((int) tolua_tonumber(tolua_S,3,0));
+ {
+ cCraftingGrid* tolua_ret = (cCraftingGrid*) Mtolua_new((cCraftingGrid)(a_Width,a_Height));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cCraftingGrid");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: new_local of class cCraftingGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingGrid_new00_local
+static int tolua_AllToLua_cCraftingGrid_new00_local(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertable(tolua_S,1,"cCraftingGrid",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ int a_Width = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_Height = ((int) tolua_tonumber(tolua_S,3,0));
+ {
+ cCraftingGrid* tolua_ret = (cCraftingGrid*) Mtolua_new((cCraftingGrid)(a_Width,a_Height));
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cCraftingGrid");
+ tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetWidth of class cCraftingGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingGrid_GetWidth00
+static int tolua_AllToLua_cCraftingGrid_GetWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cCraftingGrid",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cCraftingGrid* self = (const cCraftingGrid*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetWidth'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->GetWidth();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetHeight of class cCraftingGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingGrid_GetHeight00
+static int tolua_AllToLua_cCraftingGrid_GetHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cCraftingGrid",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cCraftingGrid* self = (const cCraftingGrid*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetHeight'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->GetHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetItem of class cCraftingGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingGrid_GetItem00
+static int tolua_AllToLua_cCraftingGrid_GetItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cCraftingGrid",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cCraftingGrid* self = (const cCraftingGrid*) tolua_tousertype(tolua_S,1,0);
+ int x = ((int) tolua_tonumber(tolua_S,2,0));
+ int y = ((int) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetItem'", NULL);
+#endif
+ {
+ cItem& tolua_ret = (cItem&) self->GetItem(x,y);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"cItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetItem of class cCraftingGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingGrid_SetItem00
+static int tolua_AllToLua_cCraftingGrid_SetItem00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cCraftingGrid",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,6,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,7,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cCraftingGrid* self = (cCraftingGrid*) tolua_tousertype(tolua_S,1,0);
+ int x = ((int) tolua_tonumber(tolua_S,2,0));
+ int y = ((int) tolua_tonumber(tolua_S,3,0));
+ ENUM_ITEM_ID a_ItemType = ((ENUM_ITEM_ID) (int) tolua_tonumber(tolua_S,4,0));
+ short a_ItemHealth = ((short) tolua_tonumber(tolua_S,5,0));
+ int a_ItemCount = ((int) tolua_tonumber(tolua_S,6,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetItem'", NULL);
+#endif
+ {
+ self->SetItem(x,y,a_ItemType,a_ItemHealth,a_ItemCount);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetItem'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetItem of class cCraftingGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingGrid_SetItem01
+static int tolua_AllToLua_cCraftingGrid_SetItem01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cCraftingGrid",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,4,&tolua_err) || !tolua_isusertype(tolua_S,4,"const cItem",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cCraftingGrid* self = (cCraftingGrid*) tolua_tousertype(tolua_S,1,0);
+ int x = ((int) tolua_tonumber(tolua_S,2,0));
+ int y = ((int) tolua_tonumber(tolua_S,3,0));
+ const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetItem'", NULL);
+#endif
+ {
+ self->SetItem(x,y,*a_Item);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_AllToLua_cCraftingGrid_SetItem00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Clear of class cCraftingGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingGrid_Clear00
+static int tolua_AllToLua_cCraftingGrid_Clear00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cCraftingGrid",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cCraftingGrid* self = (cCraftingGrid*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Clear'", NULL);
+#endif
+ {
+ self->Clear();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Clear'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ConsumeGrid of class cCraftingGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingGrid_ConsumeGrid00
+static int tolua_AllToLua_cCraftingGrid_ConsumeGrid00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cCraftingGrid",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cCraftingGrid",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cCraftingGrid* self = (cCraftingGrid*) tolua_tousertype(tolua_S,1,0);
+ const cCraftingGrid* a_Grid = ((const cCraftingGrid*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ConsumeGrid'", NULL);
+#endif
+ {
+ self->ConsumeGrid(*a_Grid);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'ConsumeGrid'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Dump of class cCraftingGrid */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingGrid_Dump00
+static int tolua_AllToLua_cCraftingGrid_Dump00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cCraftingGrid",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cCraftingGrid* self = (cCraftingGrid*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Dump'", NULL);
+#endif
+ {
+ self->Dump();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Dump'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Clear of class cCraftingRecipe */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingRecipe_Clear00
+static int tolua_AllToLua_cCraftingRecipe_Clear00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cCraftingRecipe",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cCraftingRecipe* self = (cCraftingRecipe*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Clear'", NULL);
+#endif
+ {
+ self->Clear();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Clear'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetIngredientsWidth of class cCraftingRecipe */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingRecipe_GetIngredientsWidth00
+static int tolua_AllToLua_cCraftingRecipe_GetIngredientsWidth00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cCraftingRecipe",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cCraftingRecipe* self = (const cCraftingRecipe*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetIngredientsWidth'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->GetIngredientsWidth();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetIngredientsWidth'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetIngredientsHeight of class cCraftingRecipe */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingRecipe_GetIngredientsHeight00
+static int tolua_AllToLua_cCraftingRecipe_GetIngredientsHeight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cCraftingRecipe",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cCraftingRecipe* self = (const cCraftingRecipe*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetIngredientsHeight'", NULL);
+#endif
+ {
+ int tolua_ret = (int) self->GetIngredientsHeight();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetIngredientsHeight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetIngredient of class cCraftingRecipe */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingRecipe_GetIngredient00
+static int tolua_AllToLua_cCraftingRecipe_GetIngredient00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cCraftingRecipe",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cCraftingRecipe* self = (const cCraftingRecipe*) tolua_tousertype(tolua_S,1,0);
+ int x = ((int) tolua_tonumber(tolua_S,2,0));
+ int y = ((int) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetIngredient'", NULL);
+#endif
+ {
+ cItem& tolua_ret = (cItem&) self->GetIngredient(x,y);
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"cItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetIngredient'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetResult of class cCraftingRecipe */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingRecipe_GetResult00
+static int tolua_AllToLua_cCraftingRecipe_GetResult00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cCraftingRecipe",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cCraftingRecipe* self = (const cCraftingRecipe*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetResult'", NULL);
+#endif
+ {
+ const cItem& tolua_ret = (const cItem&) self->GetResult();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const cItem");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetResult'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetResult of class cCraftingRecipe */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingRecipe_SetResult00
+static int tolua_AllToLua_cCraftingRecipe_SetResult00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cCraftingRecipe",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cCraftingRecipe* self = (cCraftingRecipe*) tolua_tousertype(tolua_S,1,0);
+ ENUM_ITEM_ID a_ItemType = ((ENUM_ITEM_ID) (int) tolua_tonumber(tolua_S,2,0));
+ short a_ItemHealth = ((short) tolua_tonumber(tolua_S,3,0));
+ int a_ItemCount = ((int) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetResult'", NULL);
+#endif
+ {
+ self->SetResult(a_ItemType,a_ItemHealth,a_ItemCount);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetResult'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetResult of class cCraftingRecipe */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingRecipe_SetResult01
+static int tolua_AllToLua_cCraftingRecipe_SetResult01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cCraftingRecipe",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cItem",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cCraftingRecipe* self = (cCraftingRecipe*) tolua_tousertype(tolua_S,1,0);
+ const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetResult'", NULL);
+#endif
+ {
+ self->SetResult(*a_Item);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_AllToLua_cCraftingRecipe_SetResult00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetIngredient of class cCraftingRecipe */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingRecipe_SetIngredient00
+static int tolua_AllToLua_cCraftingRecipe_SetIngredient00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cCraftingRecipe",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,6,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,7,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cCraftingRecipe* self = (cCraftingRecipe*) tolua_tousertype(tolua_S,1,0);
+ int x = ((int) tolua_tonumber(tolua_S,2,0));
+ int y = ((int) tolua_tonumber(tolua_S,3,0));
+ ENUM_ITEM_ID a_ItemType = ((ENUM_ITEM_ID) (int) tolua_tonumber(tolua_S,4,0));
+ short a_ItemHealth = ((short) tolua_tonumber(tolua_S,5,0));
+ int a_ItemCount = ((int) tolua_tonumber(tolua_S,6,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetIngredient'", NULL);
+#endif
+ {
+ self->SetIngredient(x,y,a_ItemType,a_ItemHealth,a_ItemCount);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetIngredient'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetIngredient of class cCraftingRecipe */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingRecipe_SetIngredient01
+static int tolua_AllToLua_cCraftingRecipe_SetIngredient01(lua_State* tolua_S)
+{
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cCraftingRecipe",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,4,&tolua_err) || !tolua_isusertype(tolua_S,4,"const cItem",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+ {
+ cCraftingRecipe* self = (cCraftingRecipe*) tolua_tousertype(tolua_S,1,0);
+ int x = ((int) tolua_tonumber(tolua_S,2,0));
+ int y = ((int) tolua_tonumber(tolua_S,3,0));
+ const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetIngredient'", NULL);
+#endif
+ {
+ self->SetIngredient(x,y,*a_Item);
+ }
+ }
+ return 0;
+tolua_lerror:
+ return tolua_AllToLua_cCraftingRecipe_SetIngredient00(tolua_S);
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: ConsumeIngredients of class cCraftingRecipe */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingRecipe_ConsumeIngredients00
+static int tolua_AllToLua_cCraftingRecipe_ConsumeIngredients00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cCraftingRecipe",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"cCraftingGrid",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cCraftingRecipe* self = (cCraftingRecipe*) tolua_tousertype(tolua_S,1,0);
+ cCraftingGrid* a_CraftingGrid = ((cCraftingGrid*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ConsumeIngredients'", NULL);
+#endif
+ {
+ self->ConsumeIngredients(*a_CraftingGrid);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'ConsumeIngredients'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: Dump of class cCraftingRecipe */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingRecipe_Dump00
+static int tolua_AllToLua_cCraftingRecipe_Dump00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cCraftingRecipe",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cCraftingRecipe* self = (cCraftingRecipe*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Dump'", NULL);
+#endif
+ {
+ self->Dump();
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'Dump'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* Open function */
TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
{
@@ -18647,10 +19479,15 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"new_local",tolua_AllToLua_cItem_new00_local);
tolua_function(tolua_S,".call",tolua_AllToLua_cItem_new00_local);
tolua_function(tolua_S,"Empty",tolua_AllToLua_cItem_Empty00);
+ tolua_function(tolua_S,"Clear",tolua_AllToLua_cItem_Clear00);
tolua_function(tolua_S,"IsEmpty",tolua_AllToLua_cItem_IsEmpty00);
tolua_function(tolua_S,"Equals",tolua_AllToLua_cItem_Equals00);
+ tolua_function(tolua_S,"GetMaxDuration",tolua_AllToLua_cItem_GetMaxDuration00);
+ tolua_function(tolua_S,"DamageItem",tolua_AllToLua_cItem_DamageItem00);
+ tolua_function(tolua_S,"HasDuration",tolua_AllToLua_cItem_HasDuration00);
tolua_function(tolua_S,"GetJson",tolua_AllToLua_cItem_GetJson00);
tolua_function(tolua_S,"FromJson",tolua_AllToLua_cItem_FromJson00);
+ tolua_function(tolua_S,"IsEnchantable",tolua_AllToLua_cItem_IsEnchantable00);
tolua_variable(tolua_S,"m_ItemID",tolua_get_cItem_m_ItemID,tolua_set_cItem_m_ItemID);
tolua_variable(tolua_S,"m_ItemCount",tolua_get_cItem_m_ItemCount,tolua_set_cItem_m_ItemCount);
tolua_variable(tolua_S,"m_ItemHealth",tolua_get_cItem_m_ItemHealth,tolua_set_cItem_m_ItemHealth);
@@ -18733,7 +19570,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"GetDefaultWorld",tolua_AllToLua_cRoot_GetDefaultWorld00);
tolua_function(tolua_S,"GetWorld",tolua_AllToLua_cRoot_GetWorld00);
tolua_function(tolua_S,"GetGroupManager",tolua_AllToLua_cRoot_GetGroupManager00);
- tolua_function(tolua_S,"GetRecipeChecker",tolua_AllToLua_cRoot_GetRecipeChecker00);
tolua_function(tolua_S,"GetCraftingRecipes",tolua_AllToLua_cRoot_GetCraftingRecipes00);
tolua_function(tolua_S,"GetFurnaceRecipe",tolua_AllToLua_cRoot_GetFurnaceRecipe00);
tolua_function(tolua_S,"GetWebAdmin",tolua_AllToLua_cRoot_GetWebAdmin00);
@@ -18982,6 +19818,38 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"SetBlock",tolua_AllToLua_cLuaChunk_SetBlock00);
tolua_function(tolua_S,"FillBlocks",tolua_AllToLua_cLuaChunk_FillBlocks00);
tolua_endmodule(tolua_S);
+ #ifdef __cplusplus
+ tolua_cclass(tolua_S,"cCraftingGrid","cCraftingGrid","",tolua_collect_cCraftingGrid);
+ #else
+ tolua_cclass(tolua_S,"cCraftingGrid","cCraftingGrid","",NULL);
+ #endif
+ tolua_beginmodule(tolua_S,"cCraftingGrid");
+ tolua_function(tolua_S,"new",tolua_AllToLua_cCraftingGrid_new00);
+ tolua_function(tolua_S,"new_local",tolua_AllToLua_cCraftingGrid_new00_local);
+ tolua_function(tolua_S,".call",tolua_AllToLua_cCraftingGrid_new00_local);
+ tolua_function(tolua_S,"GetWidth",tolua_AllToLua_cCraftingGrid_GetWidth00);
+ tolua_function(tolua_S,"GetHeight",tolua_AllToLua_cCraftingGrid_GetHeight00);
+ tolua_function(tolua_S,"GetItem",tolua_AllToLua_cCraftingGrid_GetItem00);
+ tolua_function(tolua_S,"SetItem",tolua_AllToLua_cCraftingGrid_SetItem00);
+ tolua_function(tolua_S,"SetItem",tolua_AllToLua_cCraftingGrid_SetItem01);
+ tolua_function(tolua_S,"Clear",tolua_AllToLua_cCraftingGrid_Clear00);
+ tolua_function(tolua_S,"ConsumeGrid",tolua_AllToLua_cCraftingGrid_ConsumeGrid00);
+ tolua_function(tolua_S,"Dump",tolua_AllToLua_cCraftingGrid_Dump00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cCraftingRecipe","cCraftingRecipe","",NULL);
+ tolua_beginmodule(tolua_S,"cCraftingRecipe");
+ tolua_function(tolua_S,"Clear",tolua_AllToLua_cCraftingRecipe_Clear00);
+ tolua_function(tolua_S,"GetIngredientsWidth",tolua_AllToLua_cCraftingRecipe_GetIngredientsWidth00);
+ tolua_function(tolua_S,"GetIngredientsHeight",tolua_AllToLua_cCraftingRecipe_GetIngredientsHeight00);
+ tolua_function(tolua_S,"GetIngredient",tolua_AllToLua_cCraftingRecipe_GetIngredient00);
+ tolua_function(tolua_S,"GetResult",tolua_AllToLua_cCraftingRecipe_GetResult00);
+ tolua_function(tolua_S,"SetResult",tolua_AllToLua_cCraftingRecipe_SetResult00);
+ tolua_function(tolua_S,"SetResult",tolua_AllToLua_cCraftingRecipe_SetResult01);
+ tolua_function(tolua_S,"SetIngredient",tolua_AllToLua_cCraftingRecipe_SetIngredient00);
+ tolua_function(tolua_S,"SetIngredient",tolua_AllToLua_cCraftingRecipe_SetIngredient01);
+ tolua_function(tolua_S,"ConsumeIngredients",tolua_AllToLua_cCraftingRecipe_ConsumeIngredients00);
+ tolua_function(tolua_S,"Dump",tolua_AllToLua_cCraftingRecipe_Dump00);
+ tolua_endmodule(tolua_S);
tolua_endmodule(tolua_S);
return 1;
}
diff --git a/source/Bindings.h b/source/Bindings.h
index 436844c7c..f3691a252 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 06/10/12 15:55:56.
+** Generated automatically by tolua++-1.0.92 on 06/12/12 21:57:04.
*/
/* Exported function */
diff --git a/source/CraftingRecipes.cpp b/source/CraftingRecipes.cpp
index 37d82965e..5fb705296 100644
--- a/source/CraftingRecipes.cpp
+++ b/source/CraftingRecipes.cpp
@@ -10,60 +10,287 @@
-cCraftingRecipes::cCraftingRecipes(void)
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cCraftingGrid:
+
+cCraftingGrid::cCraftingGrid(int a_Width, int a_Height) :
+ m_Width(a_Width),
+ m_Height(a_Height),
+ m_Items(new cItem[a_Width * a_Height])
{
- LoadRecipes();
}
-cCraftingRecipes::~cCraftingRecipes()
+cCraftingGrid::cCraftingGrid(cItem * a_Items, int a_Width, int a_Height) :
+ m_Width(a_Width),
+ m_Height(a_Height),
+ m_Items(new cItem[a_Width * a_Height])
{
- ClearRecipes();
+ for (int i = a_Width * a_Height - 1; i >= 0; i--)
+ {
+ m_Items[i] = a_Items[i];
+ }
}
-/// Offers an item resulting from the crafting grid setup. Doesn't modify the grid
-cItem cCraftingRecipes::Offer(const cItem * a_CraftingGrid, int a_GridWidth, int a_GridHeight)
+cCraftingGrid::cCraftingGrid(const cCraftingGrid & a_Original) :
+ m_Width(a_Original.m_Width),
+ m_Height(a_Original.m_Height),
+ m_Items(new cItem[a_Original.m_Width * a_Original.m_Height])
{
- std::auto_ptr<cRecipe> Recipe(FindRecipe(a_CraftingGrid, a_GridWidth, a_GridHeight));
- if (Recipe.get() == NULL)
+ for (int i = m_Width * m_Height - 1; i >= 0; i--)
{
- return cItem();
+ m_Items[i] = a_Original.m_Items[i];
+ }
+}
+
+
+
+
+
+cCraftingGrid::~cCraftingGrid()
+{
+ delete[] m_Items;
+}
+
+
+
+
+
+cItem & cCraftingGrid::GetItem(int x, int y) const
+{
+ // Accessible through scripting, must verify parameters:
+ if ((x < 0) || (x >= m_Width) || (y < 0) || (y >= m_Height))
+ {
+ LOGERROR("Attempted to get an invalid item from a crafting grid: (%d, %d), grid dimensions: (%d, %d).",
+ x, y, m_Width, m_Height
+ );
+ return m_Items[0];
+ }
+ return m_Items[x + m_Width * y];
+}
+
+
+
+
+
+void cCraftingGrid::SetItem(int x, int y, ENUM_ITEM_ID a_ItemType, short a_ItemHealth, int a_ItemCount)
+{
+ // Accessible through scripting, must verify parameters:
+ if ((x < 0) || (x >= m_Width) || (y < 0) || (y >= m_Height))
+ {
+ LOGERROR("Attempted to set an invalid item in a crafting grid: (%d, %d), grid dimensions: (%d, %d).",
+ x, y, m_Width, m_Height
+ );
+ return;
}
- return Recipe->m_Result;
+ m_Items[x + m_Width * y] = cItem(a_ItemType, a_ItemCount, a_ItemHealth);
}
-/// Crafts the item resulting from the crafting grid setup. Modifies the grid, returns the crafted item
-cItem cCraftingRecipes::Craft(cItem * a_CraftingGrid, int a_GridWidth, int a_GridHeight)
+void cCraftingGrid::SetItem(int x, int y, const cItem & a_Item)
{
- std::auto_ptr<cRecipe> Recipe(FindRecipe(a_CraftingGrid, a_GridWidth, a_GridHeight));
- if (Recipe.get() == NULL)
+ // Accessible through scripting, must verify parameters:
+ if ((x < 0) || (x >= m_Width) || (y < 0) || (y >= m_Height))
{
- return cItem();
+ LOGERROR("Attempted to set an invalid item in a crafting grid: (%d, %d), grid dimensions: (%d, %d).",
+ x, y, m_Width, m_Height
+ );
+ return;
}
- // Consume the ingredients from the grid:
- for (cRecipeSlots::const_iterator itr = Recipe->m_Ingredients.begin(); itr != Recipe->m_Ingredients.end(); ++itr)
+ m_Items[x + m_Width * y] = a_Item;
+}
+
+
+
+
+
+void cCraftingGrid::Clear(void)
+{
+ for (int y = 0; y < m_Height; y++) for (int x = 0; x < m_Width; x++)
{
- int GridIdx = itr->x + a_GridWidth * itr->y;
- a_CraftingGrid[GridIdx].m_ItemCount -= itr->m_Item.m_ItemCount;
- if (a_CraftingGrid[GridIdx].m_ItemCount <= 0)
+ m_Items[x + m_Width * y].Empty();
+ }
+}
+
+
+
+
+
+void cCraftingGrid::ConsumeGrid(const cCraftingGrid & a_Grid)
+{
+ if ((a_Grid.m_Width != m_Width) || (a_Grid.m_Height != m_Height))
+ {
+ LOGWARNING("Consuming a grid of different dimensions: (%d, %d) vs (%d, %d)",
+ a_Grid.m_Width, a_Grid.m_Height, m_Width, m_Height
+ );
+ }
+ int MinX = std::min(a_Grid.m_Width, m_Width);
+ int MinY = std::min(a_Grid.m_Height, m_Height);
+ for (int y = 0; y < MinY; y++) for (int x = 0; x < MinX; x++)
+ {
+ int ThatIdx = x + a_Grid.m_Width * y;
+ if (a_Grid.m_Items[ThatIdx].IsEmpty())
{
- a_CraftingGrid[GridIdx].Empty();
+ continue;
}
+ int ThisIdx = x + m_Width * y;
+ if (a_Grid.m_Items[ThatIdx].m_ItemID != m_Items[ThisIdx].m_ItemID)
+ {
+ LOGWARNING("Consuming incompatible grids: item at (%d, %d) is %d in grid and %d in ingredients. Item not consumed.",
+ x, y, m_Items[ThisIdx].m_ItemID, a_Grid.m_Items[ThatIdx].m_ItemID
+ );
+ continue;
+ }
+ char NumWantedItems = a_Grid.m_Items[ThatIdx].m_ItemCount;
+ if (NumWantedItems > m_Items[ThisIdx].m_ItemCount)
+ {
+ LOGWARNING("Consuming more items than there actually are in slot (%d, %d), item %d (want %d, have %d). Item zeroed out.",
+ x, y, m_Items[ThisIdx].m_ItemID,
+ NumWantedItems, m_Items[ThisIdx].m_ItemCount
+ );
+ NumWantedItems = m_Items[ThisIdx].m_ItemCount;
+ }
+ m_Items[ThisIdx].m_ItemCount -= NumWantedItems;
+ if (m_Items[ThisIdx].m_ItemCount == 0)
+ {
+ m_Items[ThisIdx].Clear();
+ }
+ } // for x, for y
+}
+
+
+
+
+
+void cCraftingGrid::CopyToItems(cItem * a_Items) const
+{
+ for (int i = m_Height * m_Width - 1; i >= 0; i--)
+ {
+ a_Items[i] = m_Items[i];
+ } // for x, for y
+}
+
+
+
+
+
+void cCraftingGrid::Dump(void)
+{
+ for (int y = 0; y < m_Height; y++) for (int x = 0; x < m_Width; x++)
+ {
+ int idx = x + m_Width * y;
+ LOGD("Slot (%d, %d): Type %d, health %d, count %d",
+ x, y, m_Items[idx].m_ItemID, m_Items[idx].m_ItemHealth, m_Items[idx].m_ItemCount
+ );
}
- return Recipe->m_Result;
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cCraftingRecipe:
+
+cCraftingRecipe::cCraftingRecipe(const cCraftingGrid & a_CraftingGrid) :
+ m_Ingredients(a_CraftingGrid)
+{
+}
+
+
+
+
+
+void cCraftingRecipe::Clear(void)
+{
+ m_Ingredients.Clear();
+ m_Result.Clear();
+}
+
+
+
+
+
+void cCraftingRecipe::SetResult(ENUM_ITEM_ID a_ItemType, short a_ItemHealth, int a_ItemCount)
+{
+ m_Result = cItem(a_ItemType, a_ItemCount, a_ItemHealth);
+}
+
+
+
+
+
+void cCraftingRecipe::ConsumeIngredients(cCraftingGrid & a_CraftingGrid)
+{
+ a_CraftingGrid.ConsumeGrid(m_Ingredients);
+}
+
+
+
+
+
+void cCraftingRecipe::Dump(void)
+{
+ LOGD("Recipe ingredients:");
+ m_Ingredients.Dump();
+ LOGD("Result: Type %d, health %d, count %d",
+ m_Result.m_ItemID, m_Result.m_ItemHealth, m_Result.m_ItemCount
+ );
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cCraftingRecipes:
+
+cCraftingRecipes::cCraftingRecipes(void)
+{
+ LoadRecipes();
+}
+
+
+
+
+
+cCraftingRecipes::~cCraftingRecipes()
+{
+ ClearRecipes();
+}
+
+
+
+
+
+void cCraftingRecipes::GetRecipe(const cCraftingGrid & a_CraftingGrid, cCraftingRecipe & a_Recipe)
+{
+ // TODO: Allow plugins to intercept recipes, add a pre-craft hook here
+ std::auto_ptr<cRecipe> Recipe(FindRecipe(a_CraftingGrid.GetItems(), a_CraftingGrid.GetWidth(), a_CraftingGrid.GetHeight()));
+ a_Recipe.Clear();
+ if (Recipe.get() == NULL)
+ {
+ // TODO: Allow plugins to intercept recipes, add a post-craft hook here
+ return;
+ }
+ for (cRecipeSlots::const_iterator itr = Recipe->m_Ingredients.begin(); itr != Recipe->m_Ingredients.end(); ++itr)
+ {
+ a_Recipe.SetIngredient(itr->x, itr->y, itr->m_Item);
+ } // for itr
+ a_Recipe.SetResult(Recipe->m_Result);
+ // TODO: Allow plugins to intercept recipes, add a post-craft hook here
}
diff --git a/source/CraftingRecipes.h b/source/CraftingRecipes.h
index bf85534b1..3d55a3476 100644
--- a/source/CraftingRecipes.h
+++ b/source/CraftingRecipes.h
@@ -14,6 +14,90 @@
+class cCraftingGrid // tolua_export
+{ // tolua_export
+public:
+ cCraftingGrid(const cCraftingGrid & a_Original);
+ cCraftingGrid(int a_Width, int a_Height); // tolua_export
+ cCraftingGrid(cItem * a_Items, int a_Width, int a_Height);
+ ~cCraftingGrid();
+
+ // tolua_begin
+ int GetWidth (void) const {return m_Width; }
+ int GetHeight(void) const {return m_Height; }
+ cItem & GetItem (int x, int y) const;
+ void SetItem (int x, int y, ENUM_ITEM_ID a_ItemType, short a_ItemHealth, int a_ItemCount);
+ void SetItem (int x, int y, const cItem & a_Item);
+ void Clear (void);
+
+ /// Removes items in a_Grid from m_Items[] (used by cCraftingRecipe::ConsumeIngredients())
+ void ConsumeGrid(const cCraftingGrid & a_Grid);
+
+ /// Dumps the entire crafting grid using LOGD()
+ void Dump(void);
+
+ // tolua_end
+
+ cItem * GetItems(void) const {return m_Items; }
+
+ /// Copies internal contents into the item array specified. Assumes that the array has the same dimensions as self
+ void CopyToItems(cItem * a_Items) const;
+
+protected:
+
+ int m_Width;
+ int m_Height;
+ cItem * m_Items;
+} ; // tolua_export
+
+
+
+
+
+class cCraftingRecipe // tolua_export
+{ // tolua_export
+public:
+ cCraftingRecipe(const cCraftingGrid & a_CraftingGrid);
+
+ // tolua_begin
+ void Clear (void);
+ int GetIngredientsWidth (void) const {return m_Ingredients.GetWidth(); }
+ int GetIngredientsHeight(void) const {return m_Ingredients.GetHeight(); }
+ cItem & GetIngredient (int x, int y) const {return m_Ingredients.GetItem(x, y); }
+ const cItem & GetResult (void) const {return m_Result; }
+ void SetResult (ENUM_ITEM_ID a_ItemType, short a_ItemHealth, int a_ItemCount);
+ void SetResult (const cItem & a_Item)
+ {
+ m_Result = a_Item;
+ }
+
+ void SetIngredient (int x, int y, ENUM_ITEM_ID a_ItemType, short a_ItemHealth, int a_ItemCount)
+ {
+ m_Ingredients.SetItem(x, y, a_ItemType, a_ItemHealth, a_ItemCount);
+ }
+
+ void SetIngredient (int x, int y, const cItem & a_Item)
+ {
+ m_Ingredients.SetItem(x, y, a_Item);
+ }
+
+ /// Consumes ingredients from the crafting grid specified
+ void ConsumeIngredients(cCraftingGrid & a_CraftingGrid);
+
+ /// Dumps the entire recipe using LOGD()
+ void Dump(void);
+ // tolua_end
+
+protected:
+
+ cCraftingGrid m_Ingredients; // Adjusted to correspond to the input crafting grid!
+ cItem m_Result;
+} ; // tolua_export
+
+
+
+
+
class cCraftingRecipes
{
public:
@@ -23,11 +107,8 @@ public:
cCraftingRecipes(void);
~cCraftingRecipes();
- /// Offers an item resulting from the crafting grid setup. Doesn't modify the grid
- cItem Offer(const cItem * a_CraftingGrid, int a_GridWidth, int a_GridHeight);
-
- /// Crafts the item resulting from the crafting grid setup. Modifies the grid, returns the crafted item
- cItem Craft(cItem * a_CraftingGrid, int a_GridWidth, int a_GridHeight);
+ /// Returns the recipe for current crafting grid. Doesn't modify the grid. Clears a_Recipe if no recipe found.
+ void GetRecipe(const cCraftingGrid & a_CraftingGrid, cCraftingRecipe & a_Recipe);
protected:
@@ -38,7 +119,9 @@ protected:
} ;
typedef std::vector<cRecipeSlot> cRecipeSlots;
- // A single recipe, stored. Each recipe is normalized right after parsing (NormalizeIngredients())
+ /** A single recipe, stored. Each recipe is normalized right after parsing (NormalizeIngredients())
+ A normalized recipe starts at (0,0)
+ */
struct cRecipe
{
cRecipeSlots m_Ingredients;
diff --git a/source/cCraftingWindow.cpp b/source/cCraftingWindow.cpp
index 8d499c514..c84121a06 100644
--- a/source/cCraftingWindow.cpp
+++ b/source/cCraftingWindow.cpp
@@ -3,7 +3,6 @@
#include "cCraftingWindow.h"
#include "cItem.h"
-#include "cRecipeChecker.h"
#include "CraftingRecipes.h"
#include "cPlayer.h"
#include "cClientHandle.h"
@@ -71,34 +70,24 @@ void cCraftingWindow::Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_P
if ((a_ClickPacket->m_SlotNum >= 0) && (a_ClickPacket->m_SlotNum < 10))
{
- cItem CookedItem;
+ cCraftingGrid Grid(GetSlots() + 1, 3, 3);
+ cCraftingRecipe Recipe(Grid);
+
+ cRoot::Get()->GetCraftingRecipes()->GetRecipe(Grid, Recipe);
+
if ((a_ClickPacket->m_SlotNum == 0) && !bDontCook)
{
- // Consume the ingredients from the crafting grid:
- CookedItem = cRoot::Get()->GetCraftingRecipes()->Craft(GetSlots() + 1, 3, 3);
- LOGD("New recipes crafted: %i x %i", CookedItem.m_ItemID, CookedItem.m_ItemCount);
- // Upgrade the crafting result from the new crafting grid contents:
- CookedItem = cRoot::Get()->GetCraftingRecipes()->Offer(GetSlots() + 1, 3, 3);
- if (CookedItem.IsEmpty())
- {
- // Fallback to the old recipes:
- CookedItem = cRoot::Get()->GetRecipeChecker()->CookIngredients( GetSlots()+1, 3, 3, true );
- LOGD("Old recipes crafted: %i x %i", CookedItem.m_ItemID, CookedItem.m_ItemCount );
- }
- }
- else
- {
- CookedItem = cRoot::Get()->GetCraftingRecipes()->Offer(GetSlots() + 1, 3, 3);
- LOGD("New recipes offer: %i x %i", CookedItem.m_ItemID, CookedItem.m_ItemCount );
- if (CookedItem.IsEmpty())
- {
- // Fallback to the old recipes
- CookedItem = cRoot::Get()->GetRecipeChecker()->CookIngredients( GetSlots()+1, 3, 3 );
- LOGD("Old recipes offer: %i x %i", CookedItem.m_ItemID, CookedItem.m_ItemCount );
- }
+ // Consume the items from the crafting grid:
+ Recipe.ConsumeIngredients(Grid);
+
+ // Propagate grid back to m_Slots:
+ Grid.CopyToItems(GetSlots() + 1);
+
+ // Get the recipe for the new grid contents:
+ cRoot::Get()->GetCraftingRecipes()->GetRecipe(Grid, Recipe);
}
- *GetSlot(0) = CookedItem;
- LOG("You cooked: %i x %i !!", GetSlot(0)->m_ItemID, GetSlot(0)->m_ItemCount );
+ *GetSlot(0) = Recipe.GetResult();
+ LOGD("You cooked: %i x %i !!", GetSlot(0)->m_ItemID, GetSlot(0)->m_ItemCount );
}
SendWholeWindow( a_Player.GetClientHandle() );
a_Player.GetInventory().SendWholeInventory( a_Player.GetClientHandle() );
diff --git a/source/cCreativeInventory.cpp b/source/cCreativeInventory.cpp
index f19051c5e..51f4a26ed 100644
--- a/source/cCreativeInventory.cpp
+++ b/source/cCreativeInventory.cpp
@@ -6,7 +6,6 @@
#include "cClientHandle.h"
#include "cWindow.h"
#include "cItem.h"
-#include "cRecipeChecker.h"
#include "cRoot.h"
#include <json/json.h>
diff --git a/source/cInventory.cpp b/source/cInventory.cpp
index 93edf2c57..e3c92f307 100644
--- a/source/cInventory.cpp
+++ b/source/cInventory.cpp
@@ -6,7 +6,6 @@
#include "cClientHandle.h"
#include "cWindow.h"
#include "cItem.h"
-#include "cRecipeChecker.h"
#include "cRoot.h"
#include <json/json.h>
@@ -27,6 +26,10 @@ cInventory::~cInventory()
CloseWindow();
}
+
+
+
+
cInventory::cInventory(cPlayer* a_Owner)
{
m_Owner = a_Owner;
@@ -52,6 +55,10 @@ cInventory::cInventory(cPlayer* a_Owner)
}
}
+
+
+
+
bool cInventory::AddItem( cItem & a_Item )
{
cItem BackupSlots[c_NumSlots];
@@ -84,6 +91,10 @@ bool cInventory::AddItem( cItem & a_Item )
return (a_Item.m_ItemCount == 0);
}
+
+
+
+
// TODO: Right now if you dont have enough items, the items you did have are removed, and the function returns false anyway
bool cInventory::RemoveItem( cItem & a_Item )
{
@@ -138,13 +149,21 @@ bool cInventory::RemoveItem( cItem & a_Item )
return false;
}
+
+
+
+
void cInventory::Clear()
{
for(unsigned int i = 0; i < c_NumSlots; i++)
m_Slots[i].Empty();
}
-cItem* cInventory::GetSlotsForType( int a_Type )
+
+
+
+
+cItem * cInventory::GetSlotsForType( int a_Type )
{
switch( a_Type )
{
@@ -158,19 +177,26 @@ cItem* cInventory::GetSlotsForType( int a_Type )
return 0;
}
+
+
+
+
int cInventory::GetSlotCountForType( int a_Type )
{
- switch( a_Type )
+ switch (a_Type)
{
- case -1:
- return 36;
- case -2:
- case -3:
- return 4;
+ case -1:
+ return 36;
+ case -2:
+ case -3:
+ return 4;
}
return 0;
}
-
+
+
+
+
cItem* cInventory::GetSlot( int a_SlotNum )
{
@@ -178,18 +204,33 @@ cItem* cInventory::GetSlot( int a_SlotNum )
return &m_Slots[a_SlotNum];
}
+
+
+
+
cItem* cInventory::GetFromHotBar( int a_SlotNum )
{
- if( a_SlotNum < 0 || a_SlotNum >= 9 ) return 0;
+ if ((a_SlotNum < 0) || (a_SlotNum >= 9))
+ {
+ return NULL;
+ }
return &m_HotSlots[a_SlotNum];
}
+
+
+
+
void cInventory::SetEquippedSlot( int a_SlotNum )
{
if( a_SlotNum < 0 || a_SlotNum >= 9 ) m_EquippedSlot = 0;
else m_EquippedSlot = (short)a_SlotNum;
}
+
+
+
+
cItem & cInventory::GetEquippedItem()
{
cItem* Item = GetFromHotBar( m_EquippedSlot );
@@ -205,12 +246,20 @@ cItem & cInventory::GetEquippedItem()
return *m_EquippedItem;
}
+
+
+
+
void cInventory::SendWholeInventory( cClientHandle* a_Client )
{
cPacket_WholeInventory Inventory( this );
a_Client->Send( Inventory );
}
+
+
+
+
void cInventory::SendSlot( int a_SlotNum )
{
cItem* Item = GetSlot( a_SlotNum );
@@ -226,6 +275,10 @@ void cInventory::SendSlot( int a_SlotNum )
}
}
+
+
+
+
bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode /* = 0 */ )
{
// Fill already present stacks
@@ -273,6 +326,10 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size,
return true;
}
+
+
+
+
void cInventory::SaveToJson(Json::Value & a_Value)
{
for(unsigned int i = 0; i < c_NumSlots; i++)
@@ -283,6 +340,10 @@ void cInventory::SaveToJson(Json::Value & a_Value)
}
}
+
+
+
+
bool cInventory::LoadFromJson(Json::Value & a_Value)
{
int SlotIdx = 0;
@@ -293,3 +354,7 @@ bool cInventory::LoadFromJson(Json::Value & a_Value)
}
return true;
}
+
+
+
+
diff --git a/source/cItem.h b/source/cItem.h
index 4311cc3f0..28eed0d42 100644
--- a/source/cItem.h
+++ b/source/cItem.h
@@ -12,34 +12,41 @@ namespace Json
-class cItem //tolua_export
-{ //tolua_export
+// tolua_begin
+class cItem
+{
public:
- cItem( ENUM_ITEM_ID a_ItemID = E_ITEM_EMPTY, char a_ItemCount = 0, short a_ItemHealth = 0 ) //tolua_export
+ cItem( ENUM_ITEM_ID a_ItemID = E_ITEM_EMPTY, char a_ItemCount = 0, short a_ItemHealth = 0 )
: m_ItemID ( a_ItemID )
, m_ItemCount ( a_ItemCount )
, m_ItemHealth ( a_ItemHealth )
- { //tolua_export
+ {
if(!IsValidItem( m_ItemID ) ) m_ItemID = E_ITEM_EMPTY;
- } //tolua_export
- void Empty() //tolua_export
- { //tolua_export
+ }
+ void Empty()
+ {
+ m_ItemID = E_ITEM_EMPTY;
+ m_ItemCount = 0;
+ m_ItemHealth = 0;
+ }
+ void Clear(void)
+ {
m_ItemID = E_ITEM_EMPTY;
m_ItemCount = 0;
m_ItemHealth = 0;
- } //tolua_export
- bool IsEmpty(void) const //tolua_export
- { //tolua_export
+ }
+ bool IsEmpty(void) const
+ {
return (m_ItemID <= 0 || m_ItemCount <= 0);
- } //tolua_export
- bool Equals( cItem & a_Item ) const //tolua_export
- { //tolua_export
+ }
+ bool Equals( cItem & a_Item ) const
+ {
return ( (m_ItemID == a_Item.m_ItemID) && (m_ItemHealth == a_Item.m_ItemHealth) );
- } //tolua_export
+ }
- //TODO Sorry for writing the functions in the header. But somehow it doesn´t worked when I put them into the cpp File :s
+ // TODO Sorry for writing the functions in the header. But somehow it doesn´t worked when I put them into the cpp File :s
- inline int GetMaxDuration()
+ inline int GetMaxDuration(void) const
{
switch(m_ItemID)
{
@@ -74,31 +81,31 @@ public:
}
}
- //Damages a weapon. Returns true when destroyed
- inline bool DamageItem() {
- if(HasDuration())
+ // Damages a weapon / tool. Returns true when destroyed
+ inline bool DamageItem()
+ {
+ if (HasDuration())
{
m_ItemHealth++;
-
if(m_ItemHealth >= GetMaxDuration())
return true;
-
}
return false;
}
inline bool HasDuration() { return GetMaxDuration() > 0; }
- void GetJson( Json::Value & a_OutValue ) const; //tolua_export
- void FromJson( const Json::Value & a_Value ); //tolua_export
+ void GetJson( Json::Value & a_OutValue ) const;
+ void FromJson( const Json::Value & a_Value );
static bool IsEnchantable(ENUM_ITEM_ID item);
- ENUM_ITEM_ID m_ItemID; //tolua_export
- char m_ItemCount; //tolua_export
- short m_ItemHealth; //tolua_export
+ ENUM_ITEM_ID m_ItemID;
+ char m_ItemCount;
+ short m_ItemHealth;
-}; //tolua_export
+};
+// tolua_end
typedef std::vector<cItem> cItems;
diff --git a/source/cRecipeChecker.cpp b/source/cRecipeChecker.cpp
deleted file mode 100644
index 2052ba97d..000000000
--- a/source/cRecipeChecker.cpp
+++ /dev/null
@@ -1,467 +0,0 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "cRecipeChecker.h"
-
-#include <fstream>
-#include <sstream>
-
-#ifndef _WIN32
- #include <cstdlib>
-#endif
-
-#include "Defines.h"
-#include "cRoot.h"
-
-
-
-
-
-typedef std::list< cRecipeChecker::Recipe* > RecipeList;
-
-struct cRecipeChecker::sRecipeCheckerState
-{
- RecipeList Recipes;
-};
-
-
-
-
-
-cRecipeChecker* cRecipeChecker::GetRecipeChecker()
-{
- LOGWARN("WARNING: Using deprecated function cRecipeChecker::GetRecipeChecker() use cRoot::Get()->GetRecipeChecker() instead!");
- return cRoot::Get()->GetRecipeChecker();
-}
-
-
-
-
-
-cRecipeChecker::Recipe::~Recipe()
-{
- delete [] Slots;
- Slots = 0;
-}
-
-
-
-
-
-cRecipeChecker::~cRecipeChecker()
-{
- ClearRecipes();
- delete m_pState;
-}
-
-
-
-
-
-cRecipeChecker::cRecipeChecker()
- : m_pState( new sRecipeCheckerState )
-{
- ReloadRecipes();
-}
-
-
-
-
-
-void cRecipeChecker::ClearRecipes()
-{
- while( m_pState->Recipes.size() > 0 )
- {
- delete *m_pState->Recipes.begin();
- m_pState->Recipes.remove( *m_pState->Recipes.begin() );
- }
-}
-
-
-
-
-
-void PrintRecipe( std::vector< cRecipeChecker::RecipeSlot > & RecipeSlots )
-{
- LOG("Recipe:");
- for(unsigned int i = 0; i < RecipeSlots.size(); i++)
- {
- cRecipeChecker::RecipeSlot Slot = RecipeSlots[i];
- LOG("x:%i y:%i id:%i #%i", Slot.x, Slot.y, Slot.Item.m_ItemID, Slot.Item.m_ItemCount );
- }
-}
-
-
-
-
-
-void PrintNear( std::ifstream & f, int a_History = 64 )
-{
- f.clear();
-
- // Calculate how far we can move pointer back
- std::streamoff Position = f.tellg();
- f.seekg( 0, std::ios_base::beg );
- std::streamoff Difference = Position - f.tellg();
- if( Difference > a_History ) Difference = a_History;
- f.seekg( Position - Difference, std::ios_base::beg );
-
- std::string Near;
- if( f.good() )
- {
- while( f.good() && Near.size() < (unsigned int)Difference )
- {
- char c;
- f.get(c);
- Near.push_back( c );
- }
- }
- LOGERROR("Error near: \"%s\"", Near.c_str() );
-}
-
-
-
-
-
-void cRecipeChecker::ReloadRecipes()
-{
- LOG("-- Loading recipes from recipes.txt --");
- ClearRecipes();
-
- std::ifstream f;
-
- char a_File[] = "recipes.txt";
- f.open(a_File, std::ios::in);
- std::string input;
-
- if( !f.good() )
- {
- f.close();
- LOG("Could not open file for recipes: %s", a_File);
- return;
- }
-
- std::vector< RecipeSlot > RecipeSlots;
-
- bool bError = false;
- while( f.good() )
- {
- bool bLoadSlot = false;
- bool bLoadResult = false;
-
- char c;
- f >> c;
- f.unget();
- if( c == '#' )
- {
- //LOG("Ignoring comment");
- while( f.good() && c != '\n' )
- {
- f.get( c );
- }
- continue;
- }
-
- f.get( c );
- while( f.good() && ( c == '\n' || c == '\r' ) ) { f.get( c ); }
- if( f.eof() ) break;
- f.unget();
-
- int width, height;
- f >> width;
- f >> c; if( c != 'x' ) { bError=true; break; }
- f >> height;
- f >> c;
- if( c == ',' ) bLoadSlot = true;
-
- while( f.good() && bLoadSlot )
- {
- bool bDontAddRecipe = false;
- int x, y, ItemID, Amount;
- if( f.peek() == '*' )
- {
- f >> c;
- x = -1;
- }
- else
- {
- f >> x;
- }
- f >> c; if( c != ':' ) { bError=true; break; }
- if( f.peek() == '*' )
- {
- f >> c;
- y = -1;
- }
- else
- {
- f >> y;
- }
- f >> c; if( c != ':' ) { bError=true; break; }
- f >> ItemID;
- f >> c; if( c != ':' ) { bError=true; break; }
- f >> Amount;
-
- f >> c;
- if( c == '@' ) bLoadResult = true;
- if( c != ',' ) bLoadSlot = false;
-
- if( !IsValidItem( ItemID ) )
- {
- LOGERROR("Error in recipes file (%s): Invalid Item ID %i", a_File, ItemID );
- bDontAddRecipe = true;
- }
- if( x < 0 && y < 0 )
- {
- if( Amount < 0 )
- {
- LOGERROR("Error in recipes file (%s): Invalid use of negative amount on wildcard coordinates", a_File );
- bDontAddRecipe = true;
- }
- for(int x = 0; x < width; ++x) for(int y = 0; y < height; ++y )
- {
- cItem Item( (ENUM_ITEM_ID)ItemID, (char)Amount );
- RecipeSlot Slot;
- Slot.Item = Item;
- Slot.x = x;
- Slot.y = y;
- RecipeSlots.push_back( Slot );
- }
- }
- else if( x < 0 )
- {
- if( Amount < 0 )
- {
- for(int x = 0; x < width; ++x) for(int yy = 0; yy < height; ++yy )
- {
- if( yy == y-1 ) continue;
- cItem Item( (ENUM_ITEM_ID)ItemID, (char)abs(Amount) );
- RecipeSlot Slot;
- Slot.Item = Item;
- Slot.x = x;
- Slot.y = yy;
- RecipeSlots.push_back( Slot );
- }
- }
- else
- {
- for(int x = 0; x < width; ++x)
- {
- cItem Item( (ENUM_ITEM_ID)ItemID, (char)Amount );
- RecipeSlot Slot;
- Slot.Item = Item;
- Slot.x = x;
- Slot.y = y-1;
- RecipeSlots.push_back( Slot );
- }
- }
- }
- else if( y < 0 )
- {
- if( Amount < 0 )
- {
- for(int xx = 0; xx < width; ++xx) for(int y = 0; y < height; ++y )
- {
- if( xx == x-1 ) continue;
- cItem Item( (ENUM_ITEM_ID)ItemID, (char)abs(Amount) );
- RecipeSlot Slot;
- Slot.Item = Item;
- Slot.x = xx;
- Slot.y = y;
- RecipeSlots.push_back( Slot );
- }
- }
- else
- {
- for(int y = 0; y < height; ++y)
- {
- cItem Item( (ENUM_ITEM_ID)ItemID, (char)Amount );
- RecipeSlot Slot;
- Slot.Item = Item;
- Slot.x = x-1;
- Slot.y = y;
- RecipeSlots.push_back( Slot );
- }
- }
- }
- else
- {
- if( Amount < 0 )
- {
- for(int xx = 0; xx < width; ++xx) for(int yy = 0; yy < height; ++yy )
- {
- if( xx == x-1 && yy == y-1 ) continue;
- cItem Item( (ENUM_ITEM_ID)ItemID, (char)abs(Amount) );
- RecipeSlot Slot;
- Slot.Item = Item;
- Slot.x = xx;
- Slot.y = yy;
- RecipeSlots.push_back( Slot );
- }
- }
- else
- {
- cItem Item( (ENUM_ITEM_ID)ItemID, (char)Amount );
- RecipeSlot Slot;
- Slot.Item = Item;
- Slot.x = x-1;
- Slot.y = y-1;
- RecipeSlots.push_back( Slot );
- }
- }
- //LOG("%i %i %i %i", x, y, ItemID, Amount );
-
- if( bLoadResult )
- {
- bLoadResult = false;
- f >> ItemID;
- f >> c; if( c != ':' ) { bError=true; break; }
- f >> Amount;
- //LOG("%i %i", ItemID, Amount );
- if( !IsValidItem( ItemID ) )
- {
- LOGERROR("Error in recipes file (%s): Invalid Item ID %i", a_File, ItemID );
- bDontAddRecipe = true;
- }
-
- // Do a sanity check - Handshake algorithm :)
- bool bDuplicateEntries = false;
- for(unsigned int i = 0; i < RecipeSlots.size(); i++)
- {
- for(unsigned int j = i+1; j < RecipeSlots.size(); j++)
- {
- if( RecipeSlots[i].x == RecipeSlots[j].x && RecipeSlots[i].y == RecipeSlots[j].y )
- {
- LOGERROR("Error in recipes file (%s): Duplicate item on coordinates %i:%i", a_File, RecipeSlots[i].x+1, RecipeSlots[i].y+1 );
- bDontAddRecipe = true;
- bDuplicateEntries = true;
- break;
- }
- }
- }
- if( bDuplicateEntries )
- {
- PrintNear( f, 64 );
- PrintRecipe( RecipeSlots );
- }
-
- if( bDontAddRecipe == false )
- {
- cItem Item( (ENUM_ITEM_ID)ItemID, (char)Amount );
- Recipe* recipe = new Recipe;
- recipe->Result = Item;
- recipe->NumItems = RecipeSlots.size();
- recipe->Slots = new RecipeSlot[ recipe->NumItems ];
- memcpy( recipe->Slots, &RecipeSlots[0], sizeof(RecipeSlot)*recipe->NumItems );
- m_pState->Recipes.push_back( recipe );
- //LOG("Loaded recipe for %i times %i", Amount, ItemID );
- }
-
- RecipeSlots.clear();
- }
- }
- if( bError ) break;
- }
- if( bError || ( !f.eof() && !f.good() ) )
- {
- LOGERROR("Error: Wrong format");
- PrintNear( f, 128 );
- }
- f.close();
-
- LOG("-- Done loading recipes, found %i recipes --", m_pState->Recipes.size() );
-}
-
-
-
-
-
-cItem cRecipeChecker::CookIngredients( cItem* a_Items, int a_Width, int a_Height, bool a_bConsumeIngredients /* = false */ )
-{
- int iLeft = 999, iTop = 999;
- int iRight = 0, iBottom = 0;
- for(int y = 0; y < a_Height; y++ ) for(int x = 0; x < a_Width; x++)
- {
- cItem Item = a_Items[x + y*a_Width];
- if( Item.m_ItemID != E_ITEM_EMPTY && Item.m_ItemCount > 0 )
- {
- iRight = MAX(x, iRight);
- iBottom = MAX(y, iBottom);
- iLeft = MIN(x, iLeft);
- iTop = MIN(y, iTop);
- }
- }
-
- for(RecipeList::iterator itr = m_pState->Recipes.begin(); itr != m_pState->Recipes.end(); ++itr )
- {
- Recipe* recipe = (*itr);
- int Left = 999, Top = 999;
- int Right = 0, Bottom = 0;
- for(unsigned int i = 0; i < recipe->NumItems; i++)
- {
- Right = MAX(recipe->Slots[i].x, Right);
- Bottom = MAX(recipe->Slots[i].y, Bottom);
- Left = MIN(recipe->Slots[i].x, Left);
- Top = MIN(recipe->Slots[i].y, Top);
- }
- if( Right-Left != iRight-iLeft || Bottom-Top != iBottom-iTop ) continue;
- // it has the right dimensions
-
- // Check for empty spaces
- unsigned int Hash = 0;
- for(unsigned int i = 0; i < recipe->NumItems; i++)
- {
- int x = recipe->Slots[i].x - Left + iLeft +1;
- int y = recipe->Slots[i].y - Top + iTop +1;
- Hash += x + y * a_Width;
- }
- for(int y = 0; y < a_Height; y++ ) for(int x = 0; x < a_Width; x++)
- {
- cItem & Item = a_Items[x + y*a_Width];
- if( Item.m_ItemID != E_ITEM_EMPTY && Item.m_ItemCount > 0 )
- {
- Hash -= (x+1) + (y+1)*a_Width;
- }
- }
- if( Hash != 0 ) continue; // Empty spaces not in right place
-
- bool bWrong = false;
- for(unsigned int i = 0; i < recipe->NumItems; i++)
- {
- int x = recipe->Slots[i].x - Left + iLeft;
- int y = recipe->Slots[i].y - Top + iTop;
- cItem Item = a_Items[x + y*a_Width];
- if( Item.m_ItemID != recipe->Slots[i].Item.m_ItemID
- || Item.m_ItemCount < recipe->Slots[i].Item.m_ItemCount )
- {
- bWrong = true;
- break;
- }
- }
- if( bWrong ) continue;
-
- cItem Dish = recipe->Result;
-
- // else
- if( a_bConsumeIngredients )
- {
- // Consume! nomnom~
- for(unsigned int i = 0; i < recipe->NumItems; i++)
- {
- int x = recipe->Slots[i].x - Left + iLeft;
- int y = recipe->Slots[i].y - Top + iTop;
- a_Items[x + y*a_Width].m_ItemCount -= recipe->Slots[i].Item.m_ItemCount;
- if( a_Items[x + y*a_Width].m_ItemCount <= 0 ) a_Items[x + y*a_Width].Empty();
- }
- Dish = CookIngredients( a_Items, a_Width, a_Height, false );
- }
-
- // Return the resulting dish!
- return Dish;
- }
- return cItem();
-}
-
-
-
-
diff --git a/source/cRecipeChecker.h b/source/cRecipeChecker.h
deleted file mode 100644
index 91084b7de..000000000
--- a/source/cRecipeChecker.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#pragma once
-
-#include "cItem.h"
-
-class cRecipeChecker
-{
-public:
- static cRecipeChecker * GetRecipeChecker();
-
- // Grid of cItems of a_Width width and a_Height Height
- cItem CookIngredients( cItem* a_Items, int a_Width, int a_Height, bool a_bConsumeIngredients = false );
-
- struct RecipeSlot
- {
- cItem Item;
- int x, y;
- };
-
- struct Recipe
- {
- Recipe() : Slots( 0 ), NumItems( 0 ) {}
- ~Recipe();
- RecipeSlot* Slots; // Array of RecipeSlots
- unsigned int NumItems;
- cItem Result;
- };
-
- void ReloadRecipes();
- static void DeleteMe();
-private:
- friend class cRoot;
- cRecipeChecker();
- ~cRecipeChecker();
-
- struct sRecipeCheckerState;
- sRecipeCheckerState* m_pState;
-
- void ClearRecipes();
-}; \ No newline at end of file
diff --git a/source/cRoot.cpp b/source/cRoot.cpp
index 41a1a2432..59f0e47f4 100644
--- a/source/cRoot.cpp
+++ b/source/cRoot.cpp
@@ -7,7 +7,6 @@
#include "cWebAdmin.h"
#include "cFurnaceRecipe.h"
#include "cGroupManager.h"
-#include "cRecipeChecker.h"
#include "CraftingRecipes.h"
#include "cPluginManager.h"
#include "cMonsterConfig.h"
@@ -41,7 +40,6 @@ cRoot::cRoot()
: m_Server( 0 )
, m_MonsterConfig( 0 )
, m_GroupManager( 0 )
- , m_RecipeChecker(NULL)
, m_CraftingRecipes(NULL)
, m_FurnaceRecipe( 0 )
, m_WebAdmin( 0 )
@@ -125,7 +123,6 @@ void cRoot::Start()
LOG("Loading settings...");
m_GroupManager = new cGroupManager();
- m_RecipeChecker = new cRecipeChecker();
m_CraftingRecipes = new cCraftingRecipes;
m_FurnaceRecipe = new cFurnaceRecipe();
@@ -175,7 +172,6 @@ void cRoot::Start()
delete m_WebAdmin; m_WebAdmin = 0;
LOG("Unloading recipes...");
delete m_FurnaceRecipe; m_FurnaceRecipe = NULL;
- delete m_RecipeChecker; m_RecipeChecker = NULL;
delete m_CraftingRecipes; m_CraftingRecipes = NULL;
LOG("Forgetting groups...");
delete m_GroupManager; m_GroupManager = 0;
diff --git a/source/cRoot.h b/source/cRoot.h
index 95edfe73a..7b0a7ea18 100644
--- a/source/cRoot.h
+++ b/source/cRoot.h
@@ -13,7 +13,6 @@
class cThread;
class cMonsterConfig;
class cGroupManager;
-class cRecipeChecker;
class cCraftingRecipes;
class cFurnaceRecipe;
class cWebAdmin;
@@ -48,7 +47,6 @@ public:
cMonsterConfig * GetMonsterConfig() { return m_MonsterConfig; }
cGroupManager * GetGroupManager (void) { return m_GroupManager; } // tolua_export
- cRecipeChecker * GetRecipeChecker (void) { return m_RecipeChecker; } // tolua_export
cCraftingRecipes * GetCraftingRecipes(void) { return m_CraftingRecipes; } // tolua_export
cFurnaceRecipe * GetFurnaceRecipe (void) { return m_FurnaceRecipe; } // tolua_export
cWebAdmin * GetWebAdmin (void) { return m_WebAdmin; } // tolua_export
@@ -86,7 +84,6 @@ private:
cMonsterConfig * m_MonsterConfig;
cGroupManager * m_GroupManager;
- cRecipeChecker * m_RecipeChecker;
cCraftingRecipes * m_CraftingRecipes;
cFurnaceRecipe * m_FurnaceRecipe;
cWebAdmin * m_WebAdmin;
diff --git a/source/cServer.cpp b/source/cServer.cpp
index 8f8d28e7b..c0b38c88b 100644
--- a/source/cServer.cpp
+++ b/source/cServer.cpp
@@ -18,7 +18,6 @@
#include "cPlayer.h"
#include "cInventory.h"
#include "cItem.h"
-#include "cRecipeChecker.h"
#include "cFurnaceRecipe.h"
#include "cTracer.h"
#include "cWebAdmin.h"
diff --git a/source/cSurvivalInventory.cpp b/source/cSurvivalInventory.cpp
index a39cc6b59..cd7b96ad8 100644
--- a/source/cSurvivalInventory.cpp
+++ b/source/cSurvivalInventory.cpp
@@ -6,7 +6,6 @@
#include "cClientHandle.h"
#include "cWindow.h"
#include "cItem.h"
-#include "cRecipeChecker.h"
#include "CraftingRecipes.h"
#include "cRoot.h"
#include "packets/cPacket_WindowClick.h"
@@ -72,30 +71,24 @@ void cSurvivalInventory::Clicked( cPacket* a_ClickPacket )
if ((Packet->m_SlotNum >= (short)c_CraftOffset) && (Packet->m_SlotNum < (short)(c_CraftOffset + c_CraftSlots + 1)))
{
- cItem CookedItem;
+ cCraftingGrid Grid(m_Slots + c_CraftOffset + 1, 2, 2);
+ cCraftingRecipe Recipe(Grid);
+
+ cRoot::Get()->GetCraftingRecipes()->GetRecipe(Grid, Recipe);
+
if ((Packet->m_SlotNum == 0) && !bDontCook)
{
// Consume the items from the crafting grid:
- CookedItem = cRoot::Get()->GetCraftingRecipes()->Craft(m_Slots + c_CraftOffset + 1, 2, 2);
- // Upgrade the crafting result from the new crafting grid contents:
- CookedItem = cRoot::Get()->GetCraftingRecipes()->Offer(m_Slots + c_CraftOffset + 1, 2, 2);
- if (CookedItem.IsEmpty())
- {
- // Fallback to the old recipes:
- CookedItem = cRoot::Get()->GetRecipeChecker()->CookIngredients( m_Slots+c_CraftOffset+1, 2, 2, true );
- }
- }
- else
- {
- CookedItem = cRoot::Get()->GetCraftingRecipes()->Offer(m_Slots + c_CraftOffset + 1, 2, 2);
- if (CookedItem.IsEmpty())
- {
- // Fallback to the old recipes:
- CookedItem = cRoot::Get()->GetRecipeChecker()->CookIngredients( m_Slots+c_CraftOffset+1, 2, 2 );
- }
+ Recipe.ConsumeIngredients(Grid);
+
+ // Propagate grid back to m_Slots:
+ Grid.CopyToItems(m_Slots + c_CraftOffset + 1);
+
+ // Get the recipe for the new grid contents:
+ cRoot::Get()->GetCraftingRecipes()->GetRecipe(Grid, Recipe);
}
- m_Slots[c_CraftOffset] = CookedItem;
- LOG("You cooked: %i x %i !!", m_Slots[c_CraftOffset].m_ItemID, m_Slots[c_CraftOffset].m_ItemCount );
+ m_Slots[c_CraftOffset] = Recipe.GetResult();
+ LOGD("You cooked: %i x %i !!", m_Slots[c_CraftOffset].m_ItemID, m_Slots[c_CraftOffset].m_ItemCount );
SendWholeInventory( m_Owner->GetClientHandle() );
}
SendSlot( 0 );