private function prepareCircle($start, $end) { $server = Neuron_GameServer::getServer(); $this->checkForCorrectDistances(); echo "GOAL: Preparing a " . $end . " radius, starting from " . $start . "...\n"; // Move in small steps (25 radius max) // this makes sure that the results are saved // even if the process stops. $inc = ceil(1000 / max(30, $start)); // Only run this for 60 minutes $time = time(); for ($s = $start; $s < $end; $s += $inc) { echo "[" . date("d/m/Y H:i:s") . "]" . " Preparing a " . ($s + $inc) . " radius, starting from " . $s . "...\n"; $tiles = $this->countTiles(); $this->doPrepareCircle($s, $s + $inc); $newtiles = $this->countTiles(); echo "[" . date("d/m/Y H:i:s") . "]" . " There are {$newtiles} tiles now, that's " . ($newtiles - $tiles) . " new onces!\n"; // Done? Let's put this in the database! $server->setData('prepRadD', $s); $inc = ceil(1000 / max(30, $s)); if ($time < time() - self::MAX_EXECUTION_TIME) { break; } } }
public function __construct($sTable) { $this->sTable = $sTable; $db = Neuron_DB_Database::getInstance(); $this->dbObj = $db->getConnection(); //$this->dbObj = new Mysqli (DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE); $this->objMemcache = Neuron_Core_Memcache::getInstance(); $server = Neuron_GameServer::getServer(); $this->iServer = $server->getServerId(); }
protected function winnerBenefits(Dolumar_Underworld_Models_Side $side) { $server = Neuron_GameServer::getServer(); // Load clans $side = $this->getMission()->getSideFromSide($side); foreach ($side->getClans() as $v) { $winner = $v->getId(); } $server->setData('winner', $winner); $server->setData('gamestate', Dolumar_Players_Server::GAMESTATE_ENDGAME_FINISHED); }
public function getContent() { $server = Neuron_GameServer::getServer(); $page = new Neuron_Core_Template(); if ($server->getEndgameStartDate() > time()) { $page->set('endgame_start', Neuron_Core_Tools::getCountdown($server->getEndgameStartDate())); } else { $page->set('endgame_start', '<strong>already started</strong>'); } return $page->parse('dolumar/serversettings.phpt'); }
public function execute($a = null, $b = null, $c = null) { $village = $this->getVillage(); // Add mission $mission = new Dolumar_Underworld_Models_Mission(null); $mission->setMapName('dordaedeloth.map'); $mission->setObjectiveName('DorDaedeloth'); Dolumar_Underworld_Mappers_MissionMapper::create($mission, true); // Update server status $server = Neuron_GameServer::getServer(); $server->setData('gamestate', Dolumar_Players_Server::GAMESTATE_ENDGAME_RUNNING); // And notify all players Neuron_GameServer_Player_Guide::addPublicMessage('end_casted', array($village->getOwner(), $village), 'guide', 'neutral'); }
public final function getContent($ignoreInitialLoad = true) { $login = Neuron_Core_Login::__getInstance(); $server = Neuron_GameServer::getServer(); if (!$server->isOnline()) { return $this->getClosedGame($server); } else { // Don't show window unless actually wanted $data = $this->getRequestData(); if ($login->isLogin()) { $me = Neuron_GameServer::getPlayer(); // isPlaying: Did this player select race etc. if ($me->isPlaying()) { if ($ignoreInitialLoad && isset($data['load']) && strpos($data['load'], 'autoload') !== false) { return false; } else { $html = $this->showMyAccount(); if (isset($_SESSION['just_registered']) && $_SESSION['just_registered']) { $html .= '<iframe src="' . htmlentities($me->getTrackerUrl('registration')) . '" width="1" ' . 'height="1" border="0" class="hidden-iframe"></iframe>'; } } } else { // Select a nickname //$username = $me->getNickname (); if (!$me->isNicknameSet()) { $html = $this->chooseNickname(); } else { $html = $this->getPlayerInitialization(); $_SESSION['just_registered'] = true; } } return $html; } else { return $this->showLoginForm(); } } }
//$output['content']['players']['sponsors'] = Neuron_GameServer::getServer()->countSponsors (); // Villages $output['content']['villages'] = array(); $output['content']['villages']['total'] = Neuron_GameServer::getServer()->countVillages(); $output['content']['villages']['active'] = Neuron_GameServer::getServer()->countVillages(false); $output['content']['villages']['races'] = array(); foreach (Dolumar_Races_Race::getRaces() as $k => $v) { $output['content']['villages']['races'][$v] = Neuron_GameServer::getServer()->countVillagesFromRace($k); } // Invitations //$output['content']['invitations'] = Neuron_GameServer::getServer()->countInvitations (); // Auth types //$output['content']['auths'] = Neuron_GameServer::getServer()->countAuthTypes (); break; case 'clearcache': $output['content'] = Neuron_GameServer::getServer()->clearCache(isset($_GET['clearMapCache']) && $_GET['clearMapCache'] == 'yes'); break; case 'ranking': // Ranking is handling its own output. include 'ranking.php'; exit; break; case 'rss': $text = Neuron_Core_Text::__getInstance(); $output_type = 'xml'; $xml_name = 'rss'; $xml_version = '2.0'; // Check for login if ($login->isLogin()) { $myself = Neuron_GameServer::getPlayer(); $output['content']['channel'] = array();
protected function getPlayerInitialization($registrationTracker = false) { // Check if we can actually register $server = Neuron_GameServer::getServer(); if (!$server->canRegister()) { return '<p>This server has gone into "endgame" mode. You can not register here anymore. But stay tuned, a new game will start soon.</p>'; } $data = $this->getInputData(); $me = Neuron_GameServer::getPlayer(); if (isset($data['race'])) { // Check for clans $clan = isset($data['clan']) ? intval($data['clan']) : 0; $location = isset($data['location']) ? $data['location'] : null; $objClan = false; if ($clan > 0) { $objClan = new Dolumar_Players_Clan($clan); if ($objClan->isFound()) { // Check for password if ($objClan->isPasswordProtected()) { // Break out of the function if the password is not correct. if (!isset($data['password']) || !$objClan->checkPassword($data['password'])) { return $this->requestClanPassword($data['race'], $objClan); } } $members = $objClan->getMembers(); if (count($members) > 0) { $member = $members[rand(0, count($members) - 1)]; // Fetch towncenter $village = $member->getMainVillage(); if ($village) { // Overwrite location with the location of this towncenter. $location = $village->buildings->getTownCenterLocation(); } else { $location = array(0, 0); } } else { $location = array(0, 0); } } } if ($me->initializeAccount($data['race'], $location, $objClan)) { // Scroll to the right location $me = Neuron_GameServer::getPlayer(); $home = $me->getHomeLocation(); $this->mapJump($home[0], $home[1]); // Reload area $this->reloadLocation($home[0], $home[1]); reloadEverything(); return $this->getContent(false); } else { //return $this->getPlayerInitialization (); } } $text = Neuron_Core_Text::__getInstance(); $text->setFile('account'); $text->setSection('selectRace'); $data = $this->getInputData(); // Show form $page = new Neuron_Core_Template(); $error = Neuron_GameServer::getPlayer()->getError(); if (!empty($error)) { $page->set('error', $text->get($error, 'errors', 'account', $error)); } // Loop trough races foreach (Dolumar_Races_Race::getRaces() as $k => $v) { $race = Dolumar_Races_Race::getFromId($k); if ($race->canPlayerSelect(Neuron_GameServer::getPlayer())) { $page->addListValue('races', array($text->get($v, 'races', 'races', $v), $text->get($v, 'desc', 'races', 'null'), $k)); } } $page->sortList('races'); // Some text values $page->set('submit', $text->get('submit')); $page->set('select', $text->get('select')); $page->set('location', $text->get('location')); if ($registrationTracker === true) { $tracker = Neuron_GameServer::getPlayer()->getTrackerUrl('registration'); $page->set('tracker_url', htmlentities($tracker)); } // Locations $page->addListValue('directions', array($text->get('r', 'directions', 'main'), 'r')); $page->addListValue('directions', array($text->get('n', 'directions', 'main'), 'n')); $page->addListValue('directions', array($text->get('ne', 'directions', 'main'), 'ne')); $page->addListValue('directions', array($text->get('e', 'directions', 'main'), 'e')); $page->addListValue('directions', array($text->get('es', 'directions', 'main'), 'es')); $page->addListValue('directions', array($text->get('s', 'directions', 'main'), 's')); $page->addListValue('directions', array($text->get('sw', 'directions', 'main'), 'sw')); $page->addListValue('directions', array($text->get('w', 'directions', 'main'), 'w')); $page->addListValue('directions', array($text->get('wn', 'directions', 'main'), 'wn')); // Fetch a list of all clans $db = Neuron_Core_Database::__getInstance(); $clans = $db->select('clans', array('*')); // Add a list of all clans ;-) foreach ($clans as $v) { $clan = new Dolumar_Players_Clan($v['c_id'], $v); $page->addListValue('clans', array('id' => $clan->getId(), 'name' => Neuron_Core_Tools::output_varchar($clan->getName()), 'isLocked' => $clan->isPasswordProtected(), 'isFull' => $clan->isFull())); } return $page->parse('account/selectRace.phpt'); }
<!DOCTYPE html> <html> <head> <title>Online Players</title> <meta http-equiv="refresh" content="30"> </head> <body style="background: #eee;"> <p style="position: absolute; top: 50%; margin-top: -100px; left: 50%; margin-left: -200px; color: gray; width: 400px; text-align: center; font-size: 150px; font-family: Verdana;"> <?php echo Neuron_GameServer::getServer()->countOnlineUsers(); ?> </p> </body> </html>
public function getCustomOutput() { $server = Neuron_GameServer::getServer(); $launchdate = null; if (defined('LAUNCH_DATE')) { $launchdate = LAUNCH_DATE; } // Get launch date in db $dblaunchdate = $server->getData('launchdate'); if ($dblaunchdate && $dblaunchdate > $launchdate) { $launchdate = $dblaunchdate; } // Check for the Final Countdown! if (isset($launchdate) && !isset($_GET['DEBUG']) && !isset($_SESSION['debug'])) { header("Content-Type:text/html;charset=utf-8"); if (isset($_GET['debug'])) { $_SESSION['debug'] = true; } if ($launchdate > time()) { $page = new Neuron_Core_Template(); $page->set('launchdate', Neuron_Core_Tools::getCountdown($launchdate)); $page->set('name', $server->getData('servername')); return $page->parse('launchdate.phpt'); } } if ($server->getData('gamestate') >= Dolumar_Players_Server::GAMESTATE_ENDGAME_FINISHED) { header("Content-Type:text/html;charset=utf-8"); $page = new Neuron_Core_Template(); $page->set('name', $server->getData('servername')); $winner = $this->getWinner(); $page->set('winner', $winner); return $page->parse('finished.phpt'); } }
} // close the socket connection: fclose($fp); // split the result header from the content $result = explode("\r\n\r\n", $result, 2); $header = isset($result[0]) ? $result[0] : ''; $content = isset($result[1]) ? $result[1] : ''; echo "Content:\n"; echo $content; echo "\n\n"; // return as array: //return array ($header, $content); $data = json_decode($content, true); return is_array($data) ? $data : false; } $server = Neuron_GameServer::getServer(); // If the server is not installed, install the server. // The master server will assign an ID if (!$server->isInstalled()) { if (defined('DISABLE_RESTART')) { echo 'This server is scheduled for shut down.'; exit; } if (SERVERLIST_URL) { echo "Contacting " . SERVERLIST_URL . " to initiate server.\n"; // Install the server $request = postRequest(SERVERLIST_URL, ABSOLUTE_URL, array('action' => 'initialize', 'server' => ABSOLUTE_URL, 'visible' => SERVERLIST_VISIBLE ? 1 : 0)); if ($request && isset($request['id']) && isset($request['name'])) { $server->setServerName($request['id'], $request['name']); } } else {
protected function getFreeEffects() { $out = array(new Dolumar_Effects_Boost_RainSeason(), new Dolumar_Effects_Battle_Fireball()); // End game? End effect! $server = Neuron_GameServer::getServer(); if ($server->getData('gamestate') == Dolumar_Players_Server::GAMESTATE_ENDGAME_STARTED) { $out[] = new Dolumar_Effects_Instant_DorDaedeloth(); } return $out; }
/** * Determine if it's time to take a step forwards */ public function updateStatus() { $state = $this->getData('gamestate'); if (!$state) { $this->setData('gamestate', self::GAMESTATE_PLAYING); return; } switch ($state) { case self::GAMESTATE_PLAYING: // If the server has been running for xxx months, go to next step $duration = GAME_RUNNING_DURATION; $start = $this->getStartDate(); $timepassed = time() - $start; if ($timepassed > $duration) { // Initiate end game $this->setData('gamestate', self::GAMESTATE_ENDGAME_STARTED); // And notify all players Neuron_GameServer_Player_Guide::addPublicMessage('end_scroll', array(), 'guide', 'scared'); } break; case self::GAMESTATE_ENDGAME_FINISHED: $this->setData('end_date', time()); $this->setData('gamestate', self::GAMESTATE_WAITINGFORRESET); $server = Neuron_GameServer::getServer(); $out = array(); $out['winner'] = ''; $out['members'] = ''; $out['ranking'] = ''; $out['members'] = ''; $out['villages'] = ''; $out['clans'] = ''; $out['players'] = ''; $winner = $server->getData('winner'); if ($winner) { $clan = Dolumar_Players_Clan::getFromId($winner); if ($clan) { $out['winner'] = Neuron_Core_Tools::output_varchar($clan->getName()); foreach ($clan->getMembers() as $v) { $out['members'] .= "- " . Neuron_Core_Tools::output_varchar($v->getName()) . "\n"; } } } // Ranking $players = Dolumar_Players_Ranking::getPlayerRanking(0, 5); $i = 0; foreach ($players as $v) { $i++; $out['players'] .= $i . ". " . $v->getName() . ' (' . $v->getScore() . ')' . "\n"; } $villages = Dolumar_Players_Ranking::getRanking(0, 5); $i = 0; foreach ($villages as $v) { $i++; $out['villages'] .= $i . ". " . $v->getName() . ' (' . $v->getNetworth() . ')' . "\n"; } $ranking = Dolumar_Players_Ranking::getClanRanking(0, 5); $i = 0; foreach ($ranking as $v) { $i++; $out['clans'] .= $i . ". " . $v->getName() . ' (' . $v->getNetworth() . ')' . "\n"; } $out['servername'] = $this->getServerName(); $out['serverurl'] = ABSOLUTE_URL; // Send out the bloody newsletter if (!defined('IS_TESTSERVER') || !IS_TESTSERVER) { $this->sendNewsletter('serverreset', $out); } break; case self::GAMESTATE_WAITINGFORRESET: if ($this->getData('end_date') <= NOW - 60 * 60 * 23) { $this->reset(); } break; } }
public function getContent() { $page = new Neuron_Core_Template(); $page->set('donation_url', Neuron_GameServer::getServer()->getDonationUrl()); return $page->parse('donations.tpl'); }
/** * @param $user * @param bool $cookies * @param string $email * @return bool * @throws Neuron_Exceptions_InvalidParameter */ public function doLogin($user, $cookies = false, $email = null) { $server = Neuron_GameServer::getServer(); if (!$server->isOnline()) { $this->warning = 'server_not_online'; return false; } if (!is_object($user) && is_numeric($user)) { $user = Neuron_GameServer::getPlayer(intval($user)); } /** * @var Neuron_GameServer_Player $user */ // Login is accepted if ($user) { if ($email) { $user->setEmail($email); } $admins = getAdminUserEmailAddresses(); $email = strtolower($user->getEmail()); if (isset($admins[$email]) && $user->getAdminStatus() !== $admins[$email]) { $user->setAdminStatus($admins[$email]); } $_SESSION['just_logged_in'] = true; $this->uid = $user->getId(); $this->name = $user->getNickname(); $_SESSION['plid'] = $this->uid; $this->logLogin($this->uid); // Set the cookies if ($cookies) { setcookie('dolumar_plid' . $this->level, $this->uid, time() + COOKIE_LIFETIME, '/'); setcookie('dolumar_pass' . $this->level, $user->getPasswordHash(), time() + COOKIE_LIFETIME, '/'); } // Set current language $text = Neuron_Core_Text::getInstance(); $user->setLanguage($text->getCurrentLanguage()); return true; } else { $this->warning = 'user_not_found'; return false; } }
private function __construct() { $this->objMemcache = Neuron_Core_Memcache::getInstance(); $server = Neuron_GameServer::getServer(); $this->iServer = $server->getServerId(); }