예제 #1
0
 private function check()
 {
     Logger::debug("Checking for new match (current matchs: " . count($this->matchs) . ")");
     $sql = mysql_query("SELECT m.team_a_name as team_a_name, m.team_b_name as team_b_name, m.id as match_id, m.config_authkey as config_authkey, t_a.name as team_a, t_b.name as team_b, s.id as server_id, s.ip as server_ip, s.rcon as server_rcon FROM `matchs` m LEFT JOIN `servers` s ON s.id = m.server_id LEFT JOIN `teams` t_a ON t_a.id = m.team_a LEFT JOIN `teams` t_b ON t_b.id = m.team_b WHERE m.`status` >= " . Match::STATUS_STARTING . " AND m.`status` < " . Match::STATUS_END_MATCH . " AND m.`enable` = 1") or die(mysql_error());
     while ($req = mysql_fetch_assoc($sql)) {
         if (!@$this->matchs[$req['server_ip']]) {
             try {
                 $teamA = $this->getTeamDetails($req['team_a'], 'a', $req);
                 $teamB = $this->getTeamDetails($req['team_a'], 'b', $req);
                 Logger::log("New match detected - " . $teamA['name'] . " vs " . $teamB['name'] . " on " . $req['server_ip']);
                 $this->newMatch($req["match_id"], $req['server_ip'], $req['server_rcon'], $req['config_authkey']);
             } catch (MatchException $ex) {
                 Logger::error("Error while creating the match");
                 mysql_query("UPDATE `matchs` SET enable=0 WHERE id = '" . $req['match_id'] . "'") or die(mysql_error());
             } catch (\Exception $ex) {
                 if ($ex->getMessage() == "SERVER_BUSY") {
                     Logger::error($req["server_ip"] . " is busy for " . (time() - $this->busyServers[$req['server_ip']]));
                 } elseif ($ex->getMessage() == "MATCH_ALREADY_PLAY_ON_THIS_SERVER") {
                     Logger::error("A match is already playing on " . $req["server_ip"]);
                 }
             }
         }
     }
     TaskManager::getInstance()->addTask(new Task($this, self::CHECK_NEW_MATCH, microtime(true) + 3), true);
     Logger::debug("End checking (current matchs: " . count($this->matchs) . ")");
 }
예제 #2
0
파일: Config.php 프로젝트: heew/eBot-CSGO
 public function __construct()
 {
     Logger::debug("Loading " . APP_ROOT . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "config.ini");
     if (file_exists(APP_ROOT . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "config.ini")) {
         $config = parse_ini_file(APP_ROOT . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "config.ini");
         $this->mysql_ip = $config["MYSQL_IP"];
         $this->mysql_port = $config["MYSQL_PORT"];
         $this->mysql_user = $config["MYSQL_USER"];
         $this->mysql_pass = $config["MYSQL_PASS"];
         $this->mysql_base = $config["MYSQL_BASE"];
         $this->bot_ip = $config["BOT_IP"];
         $this->bot_port = $config["BOT_PORT"];
         $this->delay_busy_server = $config["DELAY_BUSY_SERVER"];
         $this->maps = $config["MAP"];
         $this->workshop = $config["WORKSHOP"];
         $this->lo3_method = $config["LO3_METHOD"];
         $this->ko3_method = $config["KO3_METHOD"];
         $this->demo_download = (bool) $config["DEMO_DOWNLOAD"];
         $this->pause_method = $config["PAUSE_METHOD"];
         $this->config_stop_disabled = (bool) $config['COMMAND_STOP_DISABLED'];
         $this->config_knife_method = $config['RECORD_METHOD'] == "knifestart" ? "knifestart" : "matchstart";
         $this->delay_ready = (bool) $config['DELAY_READY'];
         if (isset($config['DAMAGE_REPORT']) && is_bool((bool) $config['DAMAGE_REPORT'])) {
             $this->damage_report = (bool) $config['DAMAGE_REPORT'];
         }
         if (isset($config['REMIND_RECORD']) && is_bool((bool) $config['REMIND_RECORD'])) {
             $this->remember_recordmsg = (bool) $config['REMIND_RECORD'];
         }
         Logger::debug("Configuration loaded");
     }
 }
예제 #3
0
 /**
  *
  * @param Task $task
  * @param boolean $uniq
  */
 public function addTask(&$task, $uniq = false)
 {
     if (get_class($task) == "eTools\\Task\\Task") {
         Logger::debug("Try adding task for " . get_class($task->getObjet()));
         $ok = true;
         if ($uniq) {
             $paramTask = $task->getParam();
             foreach ($this->tasklist as $v) {
                 if ($v->getObjet() == $task->getObjet()) {
                     if ($v->getStatus() == Task::NOT_RUNNING) {
                         if ($v->getFunctionName() == $task->getFunctionName()) {
                             $param = $v->getParam();
                             if (count($param) == count($paramTask)) {
                                 $ok = false;
                                 foreach ($param as $k => $v) {
                                     if ($paramTask[$k] != $param[$k]) {
                                         $ok = true;
                                         break;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if ($ok) {
             Logger::debug("Added task " . get_class($task->getObjet()));
             array_push($this->tasklist, $task);
         }
     }
 }
예제 #4
0
 public function __construct($scoreData)
 {
     Logger::debug("Creating score " . $scoreData["id"]);
     $this->setTypeScore($scoreData["type_score"]);
     $this->setScore1Side1($scoreData["score1_side1"]);
     $this->setScore1Side2($scoreData["score1_side2"]);
     $this->setScore2Side1($scoreData["score2_side1"]);
     $this->setScore2Side2($scoreData["score2_side2"]);
     $this->setId($scoreData["id"]);
 }
예제 #5
0
 public function __construct(&$obj, $functionName, $time)
 {
     Logger::debug("Creating task for " . get_class($obj) . "::taskExecute({$functionName}) at {$time}");
     $this->obj = $obj;
     $this->functionName = $functionName;
     $this->time = $time;
     $this->status = self::NOT_RUNNING;
     if (func_num_args() > 3) {
         for ($i = 3; $i < func_num_args(); $i++) {
             $this->param[] = func_get_arg($i);
         }
     }
 }
예제 #6
0
 public function dispatchEvent(Event $event)
 {
     Logger::debug("Dispatching event " . get_class($event));
     if (@$this->listeners[get_class($event)]) {
         foreach ($this->listeners[get_class($event)] as $plugin) {
             try {
                 $plugin->onEvent($event);
             } catch (\Exception $ex) {
                 Logger::error("Error while executing " . get_class($event) . " on " . get_class($plugin));
             }
         }
     }
 }
예제 #7
0
 public function __construct($bot_ip, $bot_port)
 {
     Logger::debug("Creating {$bot_ip}:{$bot_port}");
     $this->socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
     if ($this->socket) {
         if (socket_bind($this->socket, $bot_ip, $bot_port)) {
             if (!socket_set_nonblock($this->socket)) {
                 throw new SocketException("Can't set non-block mode !");
             }
         } else {
             throw new SocketException("Can't bind the socket");
         }
     } else {
         throw new SocketException("Can't create the socket");
     }
 }
예제 #8
0
 public function setStatus($newStatus, $save = false)
 {
     $this->status = $newStatus;
     if ($save) {
         Logger::debug("Updating status to " . $this->getStatusText() . " in database");
         mysql_query("UPDATE `maps` SET status='" . $newStatus . "' WHERE id='" . $this->map_id . "'");
     }
 }
예제 #9
0
 public function adminSkipMap()
 {
     $backupMap = $this->currentMap;
     $this->currentMap = null;
     if ($backupMap->getMapsFor() == "team1") {
         $mapFor = "team2";
     } elseif ($backupMap->getMapsFor() == "team2") {
         $mapFor = "default";
     }
     foreach ($this->maps as $map) {
         if ($map->getMapsFor() == $mapFor) {
             if ($map->getStatus() == Map::STATUS_NOT_STARTED) {
                 $this->currentMap = $map;
                 break;
             }
         }
     }
     foreach ($this->maps as $map) {
         if ($map->getStatus() == Map::STATUS_NOT_STARTED) {
             if ($map->getMapsFor() == $mapFor) {
                 $this->currentMap = $map;
                 break;
             }
         }
     }
     if ($this->currentMap != null) {
         $this->currentMap->setStatus(Map::STATUS_STARTING, true);
         $this->setStatus(self::STATUS_STARTING, true);
         \mysql_query("UPDATE `matchs` SET `current_map` = '" . $this->currentMap->getMapId() . "' WHERE `id` = '" . $this->match_id . "'");
         Logger::debug("Setting need knife round on map");
         $this->currentMap->setNeedKnifeRound(true);
         $this->nbOT = 0;
         $this->score["team_a"] = 0;
         $this->score["team_b"] = 0;
         $this->addLog("Engaging next map " . $this->currentMap->getMapName());
         $this->addMatchLog("Engaging next map " . $this->currentMap->getMapName());
         $time = microtime(true);
         $this->timeEngageMap = $time;
         $this->addLog("Skipping Map");
         TaskManager::getInstance()->addTask(new Task($this, self::TASK_ENGAGE_MAP, $time));
     } else {
         $this->setStatus(self::STATUS_END_MATCH, true);
         Logger::error("Not map found");
         $this->addLog("Match is closed");
     }
     return true;
 }
예제 #10
0
 public function setIp($ip)
 {
     $this->ip = $ip;
     Logger::debug("Setting {$ip} to " . $this->steamid . " (players #" . $this->mysql_id . ")");
     mysql_query("UPDATE `player` SET ip='{$ip}' WHERE id='{$this->mysql_id}'");
 }
예제 #11
0
 public function __construct($name)
 {
     $this->name = $name;
     Logger::debug("Creating MessageManager {$name}");
 }
예제 #12
0
 public function stopAll()
 {
     foreach ($this->plugins as $plugin) {
         try {
             Logger::debug("Starting plugin " . get_class($plugin));
             $plugin->stop();
         } catch (\Exception $ex) {
             Logger::error("Error while starting " . get_class($plugin));
         }
     }
 }