summaryrefslogtreecommitdiffstats
path: root/source/cRecipeChecker.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-01-30 23:48:38 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-01-30 23:48:38 +0100
commitf4583fda98b578966969db7d94a0bae3c87b0c80 (patch)
tree7edca3f33014046fa95a330a8809497d4fa52e3d /source/cRecipeChecker.cpp
parentFixed a problem in cCSLock (sorry); reverted cChunk (diff)
downloadcuberite-f4583fda98b578966969db7d94a0bae3c87b0c80.tar
cuberite-f4583fda98b578966969db7d94a0bae3c87b0c80.tar.gz
cuberite-f4583fda98b578966969db7d94a0bae3c87b0c80.tar.bz2
cuberite-f4583fda98b578966969db7d94a0bae3c87b0c80.tar.lz
cuberite-f4583fda98b578966969db7d94a0bae3c87b0c80.tar.xz
cuberite-f4583fda98b578966969db7d94a0bae3c87b0c80.tar.zst
cuberite-f4583fda98b578966969db7d94a0bae3c87b0c80.zip
Diffstat (limited to 'source/cRecipeChecker.cpp')
-rw-r--r--source/cRecipeChecker.cpp77
1 files changed, 42 insertions, 35 deletions
diff --git a/source/cRecipeChecker.cpp b/source/cRecipeChecker.cpp
index d26d8d9df..ac90c7a00 100644
--- a/source/cRecipeChecker.cpp
+++ b/source/cRecipeChecker.cpp
@@ -19,35 +19,56 @@
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 )
@@ -57,6 +78,10 @@ void cRecipeChecker::ClearRecipes()
}
}
+
+
+
+
void PrintRecipe( std::vector< cRecipeChecker::RecipeSlot > & RecipeSlots )
{
LOG("Recipe:");
@@ -67,6 +92,10 @@ void PrintRecipe( std::vector< cRecipeChecker::RecipeSlot > & RecipeSlots )
}
}
+
+
+
+
void PrintNear( std::ifstream & f, int a_History = 64 )
{
f.clear();
@@ -91,34 +120,14 @@ void PrintNear( std::ifstream & f, int a_History = 64 )
LOGERROR("Error near: \"%s\"", Near.c_str() );
}
-void cRecipeChecker::ReloadRecipes()
-{
- LOG("--Loading recipes--");
- ClearRecipes();
- /*
- char a_File[] = "recipes.txt";
- FILE* f = 0;
- #ifdef _WIN32
- if( fopen_s(&f, a_File, "rb" ) == 0 ) // no error
- #else
- if( (f = fopen(a_File, "rb" )) != 0 ) // no error
- #endif
- {
- char c;
- while( fread( &c, sizeof(char), 1, f) == 1 )
- {
- }
- }
- else
- {
- LOG("Could not open file for recipes: %s", a_File);
- return;
- }
- */
+void cRecipeChecker::ReloadRecipes()
+{
+ LOG("--Loading recipes--");
+ ClearRecipes();
std::ifstream f;
@@ -361,19 +370,13 @@ void cRecipeChecker::ReloadRecipes()
}
f.close();
- LOG("Found %i recipes", m_pState->Recipes.size() );
-// for(RecipeList::iterator itr = m_pState->Recipes.begin(); itr != m_pState->Recipes.end(); ++itr )
-// {
-// LOG("Recipe for %i times %i", (*itr)->Result.m_ItemCount, (*itr)->Result.m_ItemID );
-// for(unsigned int j = 0; j < (*itr)->NumItems; j++)
-// {
-// RecipeSlot Slot = (*itr)->Slots[j];
-// LOG("%i %i %i %i", Slot.x, Slot.y, Slot.Item.m_ItemID, Slot.Item.m_ItemCount );
-// }
-// }
- LOG("--Done loading recipes--");
+ 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;
@@ -459,3 +462,7 @@ cItem cRecipeChecker::CookIngredients( cItem* a_Items, int a_Width, int a_Height
}
return cItem();
}
+
+
+
+