We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | exit; |
89 | 89 | } |
90 | 90 | $account->addAuthMethod($_SESSION['socialLogin']->getLoginType(), |
91 | - $_SESSION['socialLogin']->getUserID()); |
|
91 | + $_SESSION['socialLogin']->getUserID()); |
|
92 | 92 | session_destroy(); |
93 | 93 | } |
94 | 94 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | // save session (incase we forward) |
114 | 114 | SmrSession::update(); |
115 | 115 | if (($disabled['Reason'] != CLOSE_ACCOUNT_INVALID_EMAIL_REASON) && |
116 | - ($disabled['Reason'] != CLOSE_ACCOUNT_BY_REQUEST_REASON)) { |
|
116 | + ($disabled['Reason'] != CLOSE_ACCOUNT_BY_REQUEST_REASON)) { |
|
117 | 117 | forward(create_container('disabled.php')); |
118 | 118 | } |
119 | 119 | } |
@@ -3,7 +3,7 @@ |
||
3 | 3 | function get_turns_message($player) { |
4 | 4 | // turns only update when the player is active, so calculate current turns |
5 | 5 | $turns = min($player->getTurns() + $player->getTurnsGained(time(), true), |
6 | - $player->getMaxTurns()); |
|
6 | + $player->getMaxTurns()); |
|
7 | 7 | $msg = $player->getPlayerName() . " has $turns/" . $player->getMaxTurns() . " turns."; |
8 | 8 | |
9 | 9 | // Calculate time to max turns if under the max |
@@ -17,7 +17,9 @@ discard block |
||
17 | 17 | |
18 | 18 | $fn_turns = function($message) { |
19 | 19 | $link = new GameLink($message->channel, $message->author); |
20 | - if (!$link->valid) return; |
|
20 | + if (!$link->valid) { |
|
21 | + return; |
|
22 | + } |
|
21 | 23 | |
22 | 24 | $msg = get_turns_message($link->player); |
23 | 25 | $message->channel->sendMessage($msg); |
@@ -25,7 +27,9 @@ discard block |
||
25 | 27 | |
26 | 28 | $fn_turns_all = function($message) { |
27 | 29 | $link = new GameLink($message->channel, $message->author); |
28 | - if (!$link->valid) return; |
|
30 | + if (!$link->valid) { |
|
31 | + return; |
|
32 | + } |
|
29 | 33 | $player = $link->player; |
30 | 34 | |
31 | 35 | $results = array_map('get_turns_message', $player->getSharingPlayers(true)); |
@@ -3,11 +3,11 @@ discard block |
||
3 | 3 | // Holds information linking the received message and the game data |
4 | 4 | class GameLink |
5 | 5 | { |
6 | - public $valid = false; // identifies if the message is linked to game data |
|
7 | - public $user; // Discord user associated with the message |
|
8 | - public $account; // SmrAccount instance |
|
9 | - public $alliance; // SmrAlliance instance |
|
10 | - public $player; // SmrPlayer instance |
|
6 | + public $valid = false; // identifies if the message is linked to game data |
|
7 | + public $user; // Discord user associated with the message |
|
8 | + public $account; // SmrAccount instance |
|
9 | + public $alliance; // SmrAlliance instance |
|
10 | + public $player; // SmrPlayer instance |
|
11 | 11 | |
12 | 12 | // Takes the following arguments: |
13 | 13 | // channel = Discord\Parts\Channel\Channel instance |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | $this->player = SmrPlayer::getPlayer($this->account->getAccountID(), $this->alliance->getGameID(), true); |
62 | 62 | if ($this->player->getAllianceID() != $this->alliance->getAllianceID()) { |
63 | - $channel->sendMessage("Player `".$this->player->getPlayerName()."` is not a member of alliance `".$this->alliance->getAllianceName()."`"); |
|
63 | + $channel->sendMessage("Player `" . $this->player->getPlayerName() . "` is not a member of alliance `" . $this->alliance->getAllianceName() . "`"); |
|
64 | 64 | return; |
65 | 65 | } |
66 | 66 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | continue; |
25 | 25 | } |
26 | 26 | $turns = min($attendeePlayer->getTurns() + $attendeePlayer->getTurnsGained(time(), true), |
27 | - $attendeePlayer->getMaxTurns()); |
|
27 | + $attendeePlayer->getMaxTurns()); |
|
28 | 28 | $oppers[$attendeePlayer->getPlayerName()] = $turns; |
29 | 29 | } |
30 | 30 |
@@ -79,8 +79,7 @@ |
||
79 | 79 | fclose($toEngine); |
80 | 80 | fclose($fromEngine); |
81 | 81 | proc_close($engine); |
82 | -} |
|
83 | -catch(Throwable $e) { |
|
82 | +} catch(Throwable $e) { |
|
84 | 83 | logException($e); |
85 | 84 | exit; |
86 | 85 | } |
@@ -10,22 +10,22 @@ discard block |
||
10 | 10 | |
11 | 11 | debug('Script started'); |
12 | 12 | define('SCRIPT_ID', $db->getInsertID()); |
13 | - $db->query('UPDATE npc_logs SET script_id='.SCRIPT_ID.' WHERE log_id='.SCRIPT_ID); |
|
13 | + $db->query('UPDATE npc_logs SET script_id=' . SCRIPT_ID . ' WHERE log_id=' . SCRIPT_ID); |
|
14 | 14 | |
15 | 15 | define('NPC_SCRIPT', true); |
16 | 16 | |
17 | 17 | $descriptorSpec = array( |
18 | - 0 => array("pipe", "r"), // stdin is a pipe that the child will read from |
|
18 | + 0 => array("pipe", "r"), // stdin is a pipe that the child will read from |
|
19 | 19 | 1 => array("pipe", "w") // stdout is a pipe that the child will write to |
20 | 20 | ); |
21 | 21 | $engine = proc_open(UCI_CHESS_ENGINE, $descriptorSpec, $pipes); |
22 | - $toEngine =& $pipes[0]; |
|
23 | - $fromEngine =& $pipes[1]; |
|
22 | + $toEngine = & $pipes[0]; |
|
23 | + $fromEngine = & $pipes[1]; |
|
24 | 24 | |
25 | 25 | function readFromEngine($block = true) { |
26 | 26 | global $fromEngine; |
27 | 27 | stream_set_blocking($fromEngine, $block == true ? 1 : 0); |
28 | - while(($s = fgets($fromEngine)) !== false) { |
|
28 | + while (($s = fgets($fromEngine)) !== false) { |
|
29 | 29 | debug('<-- ' . trim($s)); |
30 | 30 | stream_set_blocking($fromEngine, 0); |
31 | 31 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | global $toEngine; |
35 | 35 | debug('--> ' . $s); |
36 | 36 | fputs($toEngine, $s . EOL); |
37 | - if($read === true) { |
|
37 | + if ($read === true) { |
|
38 | 38 | readFromEngine($block); |
39 | 39 | } |
40 | 40 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | writeToEngine('isready'); |
46 | 46 | writeToEngine('ucinewgame', false); |
47 | 47 | |
48 | - while(true) { |
|
48 | + while (true) { |
|
49 | 49 | //Redefine MICRO_TIME and TIME, the rest of the game expects them to be the single point in time that the script is executing, with it being redefined for each page load - unfortunately NPCs are one consistent script so we have to do a hack and redefine it (or change every instance of the TIME constant). |
50 | 50 | runkit_constant_redefine('MICRO_TIME', microtime(true)); |
51 | 51 | runkit_constant_redefine('TIME', IFloor(MICRO_TIME)); |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | writeToEngine('position fen ' . $chessGame->getFENString(), false); |
56 | 56 | writeToEngine('go ' . ($chessGame->getCurrentTurnColour() == ChessGame::PLAYER_WHITE ? 'w' : 'b') . 'time ' . UCI_TIME_PER_MOVE_MS, true, false); |
57 | 57 | stream_set_blocking($fromEngine, 1); |
58 | - while(stripos($move = trim(fgets($fromEngine)), 'bestmove') !== 0) { |
|
58 | + while (stripos($move = trim(fgets($fromEngine)), 'bestmove') !== 0) { |
|
59 | 59 | debug('<-- ' . $move); |
60 | - if(stripos($move, 'Seg') === 0) { |
|
60 | + if (stripos($move, 'Seg') === 0) { |
|
61 | 61 | // Segfault |
62 | 62 | debug('UCI engine segfaulted?'); |
63 | 63 | exit; |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | fclose($fromEngine); |
79 | 79 | proc_close($engine); |
80 | 80 | } |
81 | -catch(Throwable $e) { |
|
81 | +catch (Throwable $e) { |
|
82 | 82 | logException($e); |
83 | 83 | exit; |
84 | 84 | } |
85 | 85 | function debug($message, $debugObject = null) { |
86 | - global $account,$var,$db; |
|
87 | - echo date('Y-m-d H:i:s - ').$message.($debugObject!==null?EOL.var_export($debugObject,true):'').EOL; |
|
88 | - $db->query('INSERT INTO npc_logs (script_id, npc_id, time, message, debug_info, var) VALUES ('.(defined('SCRIPT_ID')?SCRIPT_ID:0).', '.(is_object($account)?$account->getAccountID():0).',NOW(),'.$db->escapeString($message).','.$db->escapeString(var_export($debugObject,true)).','.$db->escapeString(var_export($var,true)).')'); |
|
86 | + global $account, $var, $db; |
|
87 | + echo date('Y-m-d H:i:s - ') . $message . ($debugObject !== null ?EOL.var_export($debugObject, true) : '') . EOL; |
|
88 | + $db->query('INSERT INTO npc_logs (script_id, npc_id, time, message, debug_info, var) VALUES (' . (defined('SCRIPT_ID') ?SCRIPT_ID:0) . ', ' . (is_object($account) ? $account->getAccountID() : 0) . ',NOW(),' . $db->escapeString($message) . ',' . $db->escapeString(var_export($debugObject, true)) . ',' . $db->escapeString(var_export($var, true)) . ')'); |
|
89 | 89 | } |
@@ -21,6 +21,6 @@ |
||
21 | 21 | //} |
22 | 22 | |
23 | 23 | $db->query('SELECT result,log_id FROM combat_logs'); |
24 | -while($db->nextRecord()) { |
|
25 | - $db2->query('UPDATE combat_logs SET result='.$db2->escapeBinary(gzcompress(serialize(unserialize(gzuncompress($db->getField('result')))))).' WHERE log_id='.$db->getField('log_id')); |
|
24 | +while ($db->nextRecord()) { |
|
25 | + $db2->query('UPDATE combat_logs SET result=' . $db2->escapeBinary(gzcompress(serialize(unserialize(gzuncompress($db->getField('result')))))) . ' WHERE log_id=' . $db->getField('log_id')); |
|
26 | 26 | } |
@@ -100,7 +100,7 @@ |
||
100 | 100 | |
101 | 101 | safefputs($fp, 'NICKSERV IDENTIFY ' . IRC_BOT_PASS . EOL); |
102 | 102 | |
103 | - sleep(5); |
|
103 | + sleep(5); |
|
104 | 104 | |
105 | 105 | // join our public channel |
106 | 106 | if (!IRC_DEBUGGING) { |
@@ -52,7 +52,7 @@ |
||
52 | 52 | foreach ($alliance_vs_ids as $id) { |
53 | 53 | $row_alliance = SmrAlliance::getAlliance($id, $player->getGameID()); |
54 | 54 | $showRed = (!$curr_alliance->isNone() && $curr_alliance->hasDisbanded()) || |
55 | - (!$row_alliance->isNone() && $row_alliance->hasDisbanded()); |
|
55 | + (!$row_alliance->isNone() && $row_alliance->hasDisbanded()); |
|
56 | 56 | $showBold = $curr_id == $player->getAllianceID() || $id == $player->getAllianceID(); |
57 | 57 | $style = ''; |
58 | 58 | if ($curr_id == $id && !$row_alliance->isNone()) { |
@@ -62,8 +62,7 @@ discard block |
||
62 | 62 | } elseif ($showBold) { |
63 | 63 | $style = 'class="bold"'; |
64 | 64 | } |
65 | - } |
|
66 | - else { |
|
65 | + } else { |
|
67 | 66 | $db2->query('SELECT kills FROM alliance_vs_alliance |
68 | 67 | WHERE alliance_id_2 = ' . $db2->escapeNumber($curr_id) . ' |
69 | 68 | AND alliance_id_1 = ' . $db2->escapeNumber($id) . ' |
@@ -104,11 +103,15 @@ discard block |
||
104 | 103 | if ($id > 0) { |
105 | 104 | $killer_alliance = SmrAlliance::getAlliance($id, $player->getGameID()); |
106 | 105 | $alliance_name = $killer_alliance->getAllianceDisplayName(); |
106 | + } elseif ($id == 0) { |
|
107 | + $alliance_name = 'No Alliance'; |
|
108 | + } elseif ($id == ALLIANCE_VS_FORCES) { |
|
109 | + $alliance_name = '<span class="yellow">Forces</span>'; |
|
110 | + } elseif ($id == ALLIANCE_VS_PLANETS) { |
|
111 | + $alliance_name = '<span class="yellow">Planets</span>'; |
|
112 | + } elseif ($id == ALLIANCE_VS_PORTS) { |
|
113 | + $alliance_name = '<span class="yellow">Ports</span>'; |
|
107 | 114 | } |
108 | - elseif ($id == 0) $alliance_name = 'No Alliance'; |
|
109 | - elseif ($id == ALLIANCE_VS_FORCES) $alliance_name = '<span class="yellow">Forces</span>'; |
|
110 | - elseif ($id == ALLIANCE_VS_PLANETS) $alliance_name = '<span class="yellow">Planets</span>'; |
|
111 | - elseif ($id == ALLIANCE_VS_PORTS) $alliance_name = '<span class="yellow">Ports</span>'; |
|
112 | 115 | |
113 | 116 | $kills[] = [ |
114 | 117 | 'Name' => $alliance_name, |
@@ -126,11 +129,15 @@ discard block |
||
126 | 129 | if ($id > 0) { |
127 | 130 | $killer_alliance = SmrAlliance::getAlliance($id, $player->getGameID()); |
128 | 131 | $alliance_name = $killer_alliance->getAllianceDisplayName(); |
132 | + } elseif ($id == 0) { |
|
133 | + $alliance_name = 'No Alliance'; |
|
134 | + } elseif ($id == ALLIANCE_VS_FORCES) { |
|
135 | + $alliance_name = '<span class="yellow">Forces</span>'; |
|
136 | + } elseif ($id == ALLIANCE_VS_PLANETS) { |
|
137 | + $alliance_name = '<span class="yellow">Planets</span>'; |
|
138 | + } elseif ($id == ALLIANCE_VS_PORTS) { |
|
139 | + $alliance_name = '<span class="yellow">Ports</span>'; |
|
129 | 140 | } |
130 | - elseif ($id == 0) $alliance_name = 'No Alliance'; |
|
131 | - elseif ($id == ALLIANCE_VS_FORCES) $alliance_name = '<span class="yellow">Forces</span>'; |
|
132 | - elseif ($id == ALLIANCE_VS_PLANETS) $alliance_name = '<span class="yellow">Planets</span>'; |
|
133 | - elseif ($id == ALLIANCE_VS_PORTS) $alliance_name = '<span class="yellow">Ports</span>'; |
|
134 | 141 | |
135 | 142 | $deaths[] = [ |
136 | 143 | 'Name' => $alliance_name, |
@@ -33,12 +33,24 @@ |
||
33 | 33 | $template->assign('HardwareHREF', SmrSession::getNewHREF($container)); |
34 | 34 | |
35 | 35 | $hardware = []; |
36 | -if ($ship->canHaveScanner()) $hardware[] = 'Scanner'; |
|
37 | -if ($ship->canHaveIllusion()) $hardware[] = 'Illusion Generator'; |
|
38 | -if ($ship->canHaveCloak()) $hardware[] = 'Cloaking Device'; |
|
39 | -if ($ship->canHaveJump()) $hardware[] = 'Jump Drive'; |
|
40 | -if ($ship->canHaveDCS()) $hardware[] = 'Drone Scrambler'; |
|
41 | -if (empty($hardware)) $hardware[] = 'none'; |
|
36 | +if ($ship->canHaveScanner()) { |
|
37 | + $hardware[] = 'Scanner'; |
|
38 | +} |
|
39 | +if ($ship->canHaveIllusion()) { |
|
40 | + $hardware[] = 'Illusion Generator'; |
|
41 | +} |
|
42 | +if ($ship->canHaveCloak()) { |
|
43 | + $hardware[] = 'Cloaking Device'; |
|
44 | +} |
|
45 | +if ($ship->canHaveJump()) { |
|
46 | + $hardware[] = 'Jump Drive'; |
|
47 | +} |
|
48 | +if ($ship->canHaveDCS()) { |
|
49 | + $hardware[] = 'Drone Scrambler'; |
|
50 | +} |
|
51 | +if (empty($hardware)) { |
|
52 | + $hardware[] = 'none'; |
|
53 | +} |
|
42 | 54 | $template->assign('Hardware', $hardware); |
43 | 55 | |
44 | 56 | $db->query('SELECT level_name,requirement FROM level WHERE requirement>' . $db->escapeNumber($player->getExperience()) . ' ORDER BY requirement ASC LIMIT 1'); |