145 lines
4.1 KiB
PHP
145 lines
4.1 KiB
PHP
<?php
|
|
|
|
$g_conf_mysql_cluster = require('../config/game2001api.mysql.cluster.php');
|
|
$g_conf_redis_cluster = require('../config/game2001api.redis.cluster.php');
|
|
|
|
|
|
function checkMysqlConfig()
|
|
{
|
|
$instance_id = 1;
|
|
global $g_conf_mysql_cluster;
|
|
foreach ($g_conf_mysql_cluster as $instance) {
|
|
if ($instance_id != $instance['instance_id']) {
|
|
error_log('game2001api.mysql.cluster.php config error');
|
|
die();
|
|
}
|
|
$instance_id++;
|
|
}
|
|
}
|
|
|
|
|
|
function checkRedisConfig()
|
|
{
|
|
$instance_id = 1;
|
|
global $g_conf_redis_cluster;
|
|
foreach ($g_conf_redis_cluster as $instance) {
|
|
if ($instance_id != $instance['instance_id']) {
|
|
error_log('game2001api.redis.cluster.php config error');
|
|
die();
|
|
}
|
|
$instance_id++;
|
|
}
|
|
}
|
|
|
|
|
|
function getMysqlConfig($hash_value)
|
|
{
|
|
if ($hash_value < 0) {
|
|
error_log('callstack:' . json_encode(debug_backtrace(), JSON_PRETTY_PRINT));
|
|
die('hash_value < 0 ' . $hash_value);
|
|
}
|
|
global $g_conf_mysql_cluster;
|
|
$idx = $hash_value % count($g_conf_mysql_cluster);
|
|
return $g_conf_mysql_cluster[$idx];
|
|
}
|
|
|
|
function getRedisConfig($hash_value)
|
|
{
|
|
if ($hash_value < 0) {
|
|
error_log('callstack:' . json_encode(debug_backtrace(), JSON_PRETTY_PRINT));
|
|
die('hash_value < 0 ' . $hash_value);
|
|
}
|
|
global $g_conf_redis_cluster;
|
|
$idx = $hash_value % count($g_conf_redis_cluster);
|
|
return $g_conf_redis_cluster[$idx];
|
|
}
|
|
|
|
function getSkinConfig($skin_table ,$item_id)
|
|
{
|
|
$item_id = (int)$item_id;
|
|
return array_key_exists($item_id, $skin_table) ? $skin_table[$item_id] : null;
|
|
}
|
|
|
|
function getEquipConfig($equip_table, $item_id)
|
|
{
|
|
return array_key_exists($item_id, $equip_table) ? $equip_table[$item_id] : null;
|
|
}
|
|
|
|
function getSupplyConfig($supply_table, $box_id)
|
|
{
|
|
$box_id = (int)$box_id;
|
|
return array_key_exists($box_id, $supply_table) ? $supply_table[$box_id] : null;
|
|
}
|
|
|
|
function getDropConfig($drop_table, $drop_id)
|
|
{
|
|
$drop_id = (int)$drop_id;
|
|
return array_key_exists($drop_id, $drop_table) ? $drop_table[$drop_id] : null;
|
|
}
|
|
|
|
function getSignConfig($sign_table, $sign_id)
|
|
{
|
|
$sign_id = (int)$sign_id;
|
|
return array_key_exists($sign_id, $sign_table) ? $sign_table[$sign_id] : null;
|
|
}
|
|
|
|
function getQuestConfig($quest_table, $quest_id)
|
|
{
|
|
$quest_id = (int)$quest_id;
|
|
return array_key_exists($quest_id, $quest_table) ? $quest_table[$quest_id] : null;
|
|
}
|
|
|
|
function getTaskRewardConfig($taskReward_table, $taskReward_id)
|
|
{
|
|
$taskReward_id = (int)$taskReward_id;
|
|
return array_key_exists($taskReward_id, $taskReward_table) ? $taskReward_table[$taskReward_id] : null;
|
|
}
|
|
|
|
function getActivityConfig($activity_table, $activity_id)
|
|
{
|
|
$activity_id = (int)$activity_id;
|
|
return array_key_exists($activity_id, $activity_table) ? $activity_table[$activity_id] : null;
|
|
}
|
|
|
|
function getActivityRewardConfig($activityReward_table, $activityReward_id)
|
|
{
|
|
$activityReward_id = (int)$activityReward_id;
|
|
return array_key_exists($activityReward_id, $activityReward_table) ? $activityReward_table[$activityReward_id] : null;
|
|
}
|
|
|
|
function getParameterConfig($p_table, $p_id)
|
|
{
|
|
$p_id = (int)$p_id;
|
|
return array_key_exists($p_id, $p_table) ? $p_table[$p_id] : null;
|
|
}
|
|
|
|
function getDressUpgradeConfig($dressUp_table, $dressUp_id)
|
|
{
|
|
return array_key_exists($dressUp_id, $dressUp_table) ? $dressUp_table[$dressUp_id] : null;
|
|
}
|
|
|
|
function getRewardTimesConfig($rewardTimes_table, $rewardTimes_id)
|
|
{
|
|
return array_key_exists((int)$rewardTimes_id, $rewardTimes_table) ? $rewardTimes_table[(int)$rewardTimes_id] : null;
|
|
}
|
|
|
|
function getShopConfig($shop_table, $shop_id)
|
|
{
|
|
$shop_id = (int)$shop_id;
|
|
return array_key_exists($shop_id, $shop_table) ? $shop_table[$shop_id] : null;
|
|
}
|
|
|
|
function getItemConfig($item_table, $item_id)
|
|
{
|
|
$item_id = (int)$item_id;
|
|
return array_key_exists($item_id, $item_table) ? $item_table[$item_id] : null;
|
|
}
|
|
|
|
function getShareConfig($share_table, $share_id)
|
|
{
|
|
$share_id = (int)$share_id;
|
|
return array_key_exists($share_id, $share_table) ? $share_table[$share_id] : null;
|
|
}
|
|
checkMysqlConfig();
|
|
checkRedisConfig();
|