Skip to content
Permalink
Browse files

added tool for geokret waypoint tables consistency check

  • Loading branch information...
following5 committed Jun 11, 2013
1 parent 51c4629 commit 3c985331242f211ea43e7caf3abee8d30d43b2c8
@@ -0,0 +1,4 @@
<FilesMatch ".*">
Order Deny,Allow
Deny from All
</FilesMatch>
@@ -0,0 +1,53 @@
<?php
/***************************************************************************
* For license information see doc/license.txt
*
* Unicode Reminder メモ
*
* Tests for consistency of gk_item_waypoint und gk_move_waypoint tables.
*
***************************************************************************/
$opt['rootpath'] = '../../';
require_once($opt['rootpath'] . 'lib2/cli.inc.php');
$itemwps = array();
// Get item waypoints
$rs = sql("SELECT `id` AS `itemid`, `wp` FROM `gk_item_waypoint`");
while ($r = sql_fetch_assoc($rs))
$itemwps[$r['itemid']][$r['wp']]['itemwp'] = true;
sql_free_result($rs);
// Get move waypoints
$rsItems = sql("SELECT DISTINCT `itemid` AS `id` FROM `gk_move`");
while ($rItem = sql_fetch_assoc($rsItems))
{
$lastmove = sql_value("
SELECT `id` FROM `gk_move`
WHERE `itemid`='&1'
ORDER BY `datemoved` DESC, `id` DESC
LIMIT 1",
0, $rItem['id']);
$rsWp = sql("
SELECT `wp` FROM `gk_move_waypoint`
LEFT JOIN `gk_move` ON `gk_move`.`id`=`gk_move_waypoint`.`id`
WHERE `gk_move`.`id`='&1' AND `logtypeid` IN (0,3)",
$lastmove);
while ($rWp = sql_fetch_assoc($rsWp))
$itemwps[$rItem['id']][$rWp['wp']]['movewp'] = true;
sql_free_result($rsWp);
}
sql_free_result($rsItems);
// test for missing waypoints
ksort($itemwps);
foreach ($itemwps as $itemid => $wps)
foreach ($wps as $wp => $flags)
if (isset($flags['itemwp']) && !isset($flags['movewp']))
echo "item ".$itemid.": ".$wp." is not the current wp in gk_move_waypoint\n";
else if (isset($flags['movewp']) && !isset($flags['itemwp']))
echo "item ".$itemid.": current wp ".$wp." is missing in gk_item_waypoint\n";
?>
@@ -12,7 +12,7 @@
***************************************************************************/
$opt['rootpath'] = '../../';
require_once($opt['rootpath'] . 'lib2/web.inc.php');
require_once($opt['rootpath'] . 'lib2/cli.inc.php');
require_once($opt['rootpath'] . 'lib2/logic/user.class.php');
$login->admin = ADMIN_USER;

0 comments on commit 3c98533

Please sign in to comment.
You can’t perform that action at this time.