View Single Post
  #12  
Old 02-14-2008, 09:39 AM
Knightly
Accomplished Programmer
 
Join Date: Nov 2006
Location: Honolulu, HI
Posts: 91
Default

PHP Code:
// ----Resume from previous post
    
function getRecipeName($func_recipeid$func_database) {
        if (
$func_recipeid == Null) {
            return 
"an error";
        }
        else {
            
$func_query "SELECT name FROM `$func_database`.`tradeskill_recipe` WHERE id = $func_recipeid;";
            
$func_result mysql_query($func_query)
                or die(
mysql_error());
            
$func_row mysql_fetch_assoc($func_result);
            return 
$func_row['name'];
        }
    }
    
    function 
getItemName($func_itemid$func_database) {
        if (
$func_itemid == Null) {
            return 
"an error";
        }
        else {
            
$func_query "SELECT name FROM `$func_database`.`items` WHERE id = $func_itemid;";
            
$func_result mysql_query($func_query)
            or die(
mysql_error());
            
$func_row mysql_fetch_assoc($func_result);
            return 
$func_row['name'];
        }
    }

    function 
getRecipeComponents($func_recipeid$func_database$func_newformat false) {
        if (
$func_recipeid == Null) {
            return 
"an error";
        }
        else {
            
$func_query "SELECT item_id, componentcount FROM `$func_database`.`tradeskill_recipe_entries` WHERE recipe_id = $func_recipeid AND componentcount > 0 AND isnewrecipe=";
            if (
$func_newformat == true) {
                
$func_query $func_query "1 ";
            }
            else {
                
$func_query $func_query "0 ";
            }
            
$func_query $func_query "ORDER BY item_id;";
            
$func_result mysql_query($func_query)
            or die(
mysql_error());
            
$returnstring "";
            
//For old recipe calculations
            
$currentitemid = -1;
            
$currentitemcount 1;
            while (
$func_row mysql_fetch_assoc($func_result)) {
                
//account for the old recipes giving you back 1 and 1 and 1 of an item instead of 3 of an item
                
if ($func_newformat == false) {
                    if (
$currentitemid == $func_row['item_id']) {
                        
$currentitemcount $currentitemcount $func_row['componentcount'];
                    }
                    else {
                        if  (!(
$currentitemid == -1)) {
                            
$returnstring " " $returnstring $currentitemcount " of item #" $currentitemid " (" $currentitemcount "x" getItemName($currentitemid$func_database) . ") ";
                        }
                        
$currentitemid $func_row['item_id'];
                        
$currentitemcount $func_row['componentcount'];
                    }
                }
                else {
                    
$returnstring " " $returnstring $func_row['componentcount'] . " of item #" $func_row['item_id'] . " (" $func_row['componentcount'] . "x" getItemName($func_row['item_id'], $func_database) . ") ";
                }
            }
            if (
$func_newformat == false) {
                
$returnstring " " $returnstring $currentitemcount " of item #" $currentitemid " (" $currentitemcount "x" getItemName($currentitemid$func_database) . ") ";
            }
            if (
$returnstring == ""){
                
$returnstring "an error";
            }
            return 
$returnstring;
        }
    }

    function 
getContainer($func_recipeid$func_database$func_newformat false) {
        if (
$func_recipeid == Null) {
            return 
"an error";
        }
        else {
            
$func_query "SELECT item_id FROM `$func_database`.`tradeskill_recipe_entries` WHERE recipe_id = $func_recipeid AND iscontainer = 1 AND isnewrecipe=";
            if (
$func_newformat == true) {
                
$func_query $func_query "1 ";
            }
            else {
                
$func_query $func_query "0 ";
            }
            
$func_query $func_query "ORDER BY item_id;";
            
$func_result mysql_query($func_query)
            or die(
mysql_error());
            
$func_row mysql_fetch_assoc($func_result);
            return 
$func_row['item_id'] . " (" getItemName($func_row['item_id'], $func_database) . ")";
        }
    }

    function 
getOldFailures($func_recipeid$func_database) {
        if (
$func_recipeid == Null) {
            return 
"an error";
        }
        else {
            
//This is the query from the current EQEMU code, with two modifications:
            //1.  The ORDER BY clause has been added so that we can make the items we want come up first which makes the sentence we're forming easier to compare.
            //2.  The isnewrecipe identifier has been added since we only want to pull information from old recipies
            
$func_query "SELECT item_id, failcount FROM `$func_database`.`tradeskill_recipe_entries` WHERE failcount>0 AND componentcount=0 AND recipe_id=$func_recipeid AND isnewrecipe=0 ORDER BY item_id;";
            
$func_result mysql_query($func_query)
            or die(
mysql_error());
            
$returnstring "";
            while (
$func_row mysql_fetch_assoc($func_result)) {
                
$returnstring " " $returnstring $func_row['failcount'] . " of item #" $func_row['item_id'] . " (" $func_row['failcount'] . "x" getItemName($func_row['item_id'], $func_database) . ")";
            }
            if (
$returnstring == "") {
                
$returnstring "nothing";
            }
            return 
$returnstring;
        }
    }

    function 
getNewFailures($func_recipeid$func_database) {
        if (
$func_recipeid == Null) {
            return 
"an error";
        }
        else {
            
//This is the query from the proposed EQEMU code, with two modifications:
            //1.  The ORDER BY clause has been added so that we can make the items we want come up first which makes the sentence we're forming easier to compare.
            //2.  The isnewrecipe identifier has been added since we only want to pull information from new recipies
            
$func_query "SELECT item_id, failcount FROM `$func_database`.`tradeskill_recipe_entries` WHERE recipe_id=$func_recipeid AND failcount>0 AND isnewrecipe=1 ORDER BY item_id;";
            
$func_result mysql_query($func_query)
            or die(
mysql_error());
            
$returnstring "";
            while (
$func_row mysql_fetch_assoc($func_result)) {
                
$returnstring " " $returnstring $func_row['failcount'] . " of item #" $func_row['item_id'] . " (" $func_row['failcount'] . "x" getItemName($func_row['item_id'], $func_database) . ")";
            }
            if (
$returnstring == "") {
                
$returnstring "nothing";
            }
            return 
$returnstring;
        }
    }

    function 
getOldSuccesses($func_recipeid$func_database) {
        if (
$func_recipeid == Null) {
            return 
"an error";
        }
        else {
            
//This is the query from the current EQEMU code, with two modifications:
            //1.  The ORDER BY clause has been added so that we can make the items we want come up first which makes the sentence we're forming easier to compare.
            //2.  The isnewrecipe identifier has been added since we only want to pull information from old recipies
            
$func_query "SELECT item_id, successcount FROM `$func_database`.`tradeskill_recipe_entries` WHERE successcount>0 AND componentcount=0 AND recipe_id=$func_recipeid AND isnewrecipe=0 ORDER BY item_id;";
            
$func_result mysql_query($func_query)
            or die(
mysql_error());
            
$returnstring "";
            
$currentitemid = -1;
            
$currentitemcount 1;
            while (
$func_row mysql_fetch_assoc($func_result)) {
                if (
$currentitemid == $func_row['item_id']) {
                    
$currentitemcount $currentitemcount $func_row['successcount'];
                }
                else {
                    if  (!(
$currentitemid == -1)) {
                        
$returnstring " " $returnstring $currentitemcount " of item #" $currentitemid " (" $currentitemcount "x" getItemName($currentitemid$func_database) . ") ";
                    }
                    
$currentitemid $func_row['item_id'];
                    
$currentitemcount $func_row['successcount'];
                }
            }
            
$returnstring " " $returnstring $currentitemcount " of item #" $currentitemid " (" $currentitemcount "x" getItemName($currentitemid$func_database) . ") ";
            
//$returnstring = " " . $returnstring . $func_row['successcount'] . " of item #" . $func_row['item_id'] . " (" . $func_row['successcount'] . "x" . getItemName($func_row['item_id'], $func_database) . ") ";
            
if ($returnstring == "") {
                
$returnstring "an error";
            }
            return 
$returnstring;
        }
    }
    
    function 
getNewSuccesses($func_recipeid$func_database) {
        if (
$func_recipeid == Null) {
            return 
"an error";
        }
        else {
            
//This is the query from the proposed EQEMU code, with two modifications:
            //1.  The ORDER BY clause has been added so that we can make the items we want come up first which makes the sentence we're forming easier to compare.
            //2.  The isnewrecipe identifier has been added since we only want to pull information from new recipies
            
$func_query "SELECT item_id, successcount FROM `$func_database`.`tradeskill_recipe_entries` WHERE recipe_id=$func_recipeid AND successcount>0 AND isnewrecipe=1 ORDER BY item_id;";
            
$func_result mysql_query($func_query)
            or die(
mysql_error());
            
$returnstring "";
            while (
$func_row mysql_fetch_assoc($func_result)) {
                
$returnstring " " $returnstring $func_row['successcount'] . " of item #" $func_row['item_id'] . " (" $func_row['successcount'] . "x" getItemName($func_row['item_id'], $func_database) . ") ";
            }
            if (
$returnstring == "") {
                
$returnstring "an error";
            }
            return 
$returnstring;
        }
    }
?> 

Note: This will show you any place where your recipes do not match. You just need to look at the web page that is generated and make sure that it is correct. It will also generate errors for some recipes, you just need to check to make sure these errors are legitimate. For example: PEQ has some test recipes that don't have containers...those recipes will generate an error here. As long as the error is the same for "Old" as "New" then the conversion worked. The conversion converts broken recipes just the same as it converts working recipes.
Reply With Quote