|
|
 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
|
 |
|
 |

02-14-2008, 09:38 AM
|
Accomplished Programmer
|
|
Join Date: Nov 2006
Location: Honolulu, HI
Posts: 91
|
|
Step 3 -- Compare recipes using the old format to recipes using the new format: (CompareTradeskillMethods.php)
PHP Code:
<?php
//Modify the following variables to match your database
$dbhost = "localhost";
$database = "projecteq";
$username = "databaseuser";
$password = "databasepass";
$timeout = 600; // in seconds
//stop editing here
set_time_limit($timeout);
$link = mysql_connect($dbhost, $username, $password)
or die('Could not connect: ' . mysql_error());
//First we get all of the old recipe_id information
$query = "SELECT DISTINCT recipe_id FROM `$database`.`tradeskill_recipe_entries` WHERE isnewrecipe=0;";
$result = mysql_query($query)
or die(mysql_error());
echo "<html>";
echo "<body>";
//Now we need to loop through all of those IDs we just got:
while($row = mysql_fetch_assoc($result)) {
$oldstring = "This is the old string.";
$newstring = "This is the new string.";
$recipeid = $row['recipe_id'];
//I realize this is a run on sentence, sue me.
$oldcomponents = "To make recipe #$recipeid (" . getRecipeName($recipeid, $database) . ") you need" . getRecipeComponents($recipeid, $database);
$newcomponents = "To make recipe #$recipeid (" . getRecipeName($recipeid, $database) . ") you need" . getRecipeComponents($recipeid, $database, true);
$oldcontainer = " inside item #" . getContainer($recipeid, $database);
$newcontainer = " inside item #" . getContainer($recipeid, $database, true);
$oldfails = " and if you fail you get back " . getOldFailures($recipeid, $database);
$newfails = " and if you fail you get back " . getNewFailures($recipeid, $database);
$oldsuccess = " but if you succeed you get back " . getOldSuccesses($recipeid, $database) . ".";
$newsuccess = " but if you succeed you get back " . getNewSuccesses($recipeid, $database) . ".";
$oldstring = $oldcomponents . $oldcontainer . $oldfails . $oldsuccess;
$newstring = $newcomponents . $newcontainer . $newfails . $newsuccess;
if ($oldstring == $newstring) {
if (!(strpos($oldstring, "an error") === false) && !(strpos($newstring, "an error") === false)) {
echo "<br />Error in recipe #$recipeid<br />";
echo "Old Method: $oldstring<br />";
echo "New Method: $newstring<br />";
}
}
else {
echo "<br />Recipe mismatch for recipe #$recipeid:<br />";
echo "Old Method: $oldstring<br />";
echo "New Method: $newstring<br />";
if (!($oldcomponents == $newcomponents)) {
echo "Mismatch in components:<br />";
echo "Old Method: $oldcomponents<br />";
echo "New Method: $newcomponents<br />";
}
if (!($oldcontainer == $newcontainer)) {
echo "Mismatch in container:<br />";
echo "Old Method: $oldcontainer<br />";
echo "New Method: $newcontainer<br />";
}
if (!($oldfails == $newfails)) {
echo "Mismatch in fails:<br />";
echo "Old Method: $oldfails<br />";
echo "New Method: $newfails<br />";
}
if (!($oldsuccess == $newsuccess)) {
echo "Mismatch in successes:<br />";
echo "Old Method: $oldsuccess<br />";
echo "New Method: $newsuccess<br />";
}
}
}
echo "End";
echo "</body>";
echo "</html>";
// ----Break for character limit -- See next post
Last edited by Knightly; 02-14-2008 at 05:41 PM..
|
 |
|
 |
 |
|
 |

02-14-2008, 09:39 AM
|
Accomplished Programmer
|
|
Join Date: Nov 2006
Location: Honolulu, HI
Posts: 91
|
|
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.
|
 |
|
 |

02-14-2008, 09:40 AM
|
Accomplished Programmer
|
|
Join Date: Nov 2006
Location: Honolulu, HI
Posts: 91
|
|
Step 4 -- Remove old recipes and modify table:
Code:
DELETE FROM `tradeskill_recipe_entries` WHERE isnewrecipe=0;
ALTER TABLE `tradeskill_recipe_entries` DROP COLUMN `isnewrecipe`;
Step 5 -- Modify EQEmu code (will post this later)
|

02-14-2008, 10:30 AM
|
 |
The PEQ Dude
|
|
Join Date: Apr 2003
Location: -
Posts: 1,988
|
|
I'll certainly give this a try and get back to you as to how it works! If it does indeed do the trick, then I have no problem making this change on PEQ after the correction code has been added to developer SVN.
Last edited by cavedude; 02-14-2008 at 06:32 PM..
|

02-14-2008, 10:44 AM
|
Accomplished Programmer
|
|
Join Date: Nov 2006
Location: Honolulu, HI
Posts: 91
|
|
Step 5 -- Step 5: Open Tradeskills.cpp and make the following changes:
Change:
Code:
//Pull the on-success items...
qlen = MakeAnyLenString(&query, "SELECT item_id,successcount FROM tradeskill_recipe_entries"
" WHERE successcount>0 AND componentcount=0 AND recipe_id=%u", recipe_id);
To:
Code:
//Pull the on-success items...
qlen = MakeAnyLenString(&query, "SELECT item_id,successcount FROM tradeskill_recipe_entries"
" WHERE successcount>0 AND recipe_id=%u", recipe_id);
Change:
Code:
//Pull the on-fail items...
qlen = MakeAnyLenString(&query, "SELECT item_id,failcount FROM tradeskill_recipe_entries"
" WHERE failcount>0 AND componentcount=0 AND recipe_id=%u", recipe_id);
To:
Code:
//Pull the on-fail items...
qlen = MakeAnyLenString(&query, "SELECT item_id,failcount FROM tradeskill_recipe_entries"
" WHERE failcount>0 AND recipe_id=%u", recipe_id);
|
Thread Tools |
|
Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 03:35 AM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |