GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with WOT Game. If not, see <http://www.gnu.org/licenses/>. */ if (!isset($ugamela_root_path)) { $ugamela_root_path = ''; } if (!defined('RELATIVE_LW_DIR')) { define('RELATIVE_LW_DIR', $ugamela_root_path . ''); } if (!defined('RELATIVE_WCF_DIR')) { define('RELATIVE_WCF_DIR', RELATIVE_LW_DIR . 'wcf/'); } if (!defined('TIMEZONE')) { define('TIMEZONE', 2); } // include config require_once dirname(__FILE__) . '/config.inc.php'; // include WCF require_once RELATIVE_WCF_DIR . 'global.php'; // include ZF set_include_path(get_include_path() . PATH_SEPARATOR . LW_DIR . '../zf/library'); require_once 'Zend/Loader/Autoloader.php'; Zend_Loader_Autoloader::getInstance(); spl_autoload_register('__autoload'); // starting wot core require_once LW_DIR . 'lib/system/LWCore.class.php'; new LWCore(); WOTUtil::initDone();
/** * Reads the needed class from the database and returns the planet object * * @param int planet id * @param array planet row * @param bool update last activity * * @return Planet planet */ public static function getInstance($planetID = null, $row = null, $updateLastActivity = true) { if ($planetID !== null) { $planetID = intval($planetID); } $opened = false; if (isset(self::$planets[$planetID])) { $planet = self::$planets[$planetID]; } else { if (isset(self::$planets[$row['id']])) { $planet = self::$planets[$row['id']]; } else { if ($planetID === null) { WCF::getDB()->sendQuery("START TRANSACTION"); $opened = true; $planetID = $row['id']; $sql = "SELECT *\n\t\t\t\t\tFROM ugml" . LW_N . "_planets\n\t\t\t\t\tWHERE id = " . intval($planetID) . " LIMIT 1 OFFSET 0 FOR UPDATE"; $row = WCF::getDB()->getFirstRow($sql); $className = $row['className']; if (!$row) { $className = self::STANDARD_CLASS; } require_once LW_DIR . 'lib/data/planet/' . $className . '.class.php'; $planet = new $className($planetID, $row); } else { WCF::getDB()->sendQuery("START TRANSACTION"); $opened = true; $sql = "SELECT *\n\t\t \t\tFROM ugml" . LW_N . "_planets\n\t\t \t\tWHERE id = " . intval($planetID) . " LIMIT 1 OFFSET 0 FOR UPDATE"; $row = WCF::getDB()->getFirstRow($sql); $className = $row['className']; if (!$row) { $className = self::STANDARD_CLASS; } require_once LW_DIR . 'lib/data/planet/' . $className . '.class.php'; $planet = new $className($planetID, $row); } } } // workaround for Orbit [::] Bug if (!is_numeric($planetID)) { return $planet; } self::$planets[$planetID] = $planet; // update resources and activity if ($updateLastActivity) { if (class_exists('WOTEventExecuteDaemon')) { if ($planet->last_update != time()) { $planet->calculateResources(time()); } } else { WOTUtil::callAfterInit(array($planet, 'initDoneCallback')); } } if ($opened) { WCF::getDB()->sendQuery("COMMIT"); } return $planet; }