Skip to content

Commit a875379

Browse files
committed
Refactoring
1 parent d11a75a commit a875379

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/lgsl_class.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -981,8 +981,8 @@ public function getMapImage($check_exists = true) {
981981
return "#LGSL_DEFAULT_IMAGES_MISSING#";
982982
}
983983
public function getGameFormatted() {
984-
global $lgsl_config;
985-
return "[ {$lgsl_config['text']['typ']}: {$this->getType()} ] [ {$lgsl_config['text']['gme']}: {$this->getGame()} ]";
984+
$config = new Config();
985+
return "[ {$config['text']['typ']}: {$this->getType()} ] [ {$config['text']['gme']}: {$this->getGame()} ]";
986986
}
987987
public function getGameIcon($path = '') {
988988
$type = LGSL::normalizeString($this->getType());
@@ -1001,17 +1001,18 @@ public function getGameIcon($path = '') {
10011001
return "{$path}other/icon_unknown.gif";
10021002
}
10031003
public function getStatusIcon($path = '') {
1004+
$path .= 'other/';
10041005
switch ($this->getStatus()) {
1005-
case self::PENDING: return "{$path}other/icon_unknown.gif";
1006-
case self::ERROR: return "{$path}other/icon_unknown.gif";
1007-
case self::OFFLINE: return "{$path}other/icon_no_response.gif";
1008-
case self::PASSWORDED: return "{$path}other/icon_online_password.gif";
1009-
default: return "{$path}other/icon_online.gif";
1006+
case self::PENDING: return "{$path}icon_unknown.gif";
1007+
case self::ERROR: return "{$path}icon_unknown.gif";
1008+
case self::OFFLINE: return "{$path}icon_no_response.gif";
1009+
case self::PASSWORDED: return "{$path}icon_online_password.gif";
1010+
default: return "{$path}icon_online.gif";
10101011
}
10111012
}
10121013
public function getLocationFormatted() {
1013-
global $lgsl_config;
1014-
return "{$lgsl_config['text']['loc']} {$this->getLocation()}";
1014+
$config = new Config();
1015+
return "{$config['text']['loc']} {$this->getLocation()}";
10151016
}
10161017
public function getLocation() {
10171018
return $this->_other['location'] ?? "XX";
@@ -1021,11 +1022,11 @@ public function getTimestamp($type = Timestamp::SERVER) {
10211022
}
10221023
public function getTimestampFormatted($type = Timestamp::SERVER) {
10231024
$time = $this->getTimestamp($type);
1024-
global $lgsl_config;
1025+
$config = new Config();
10251026
if ($time > 0) {
1026-
return Date($lgsl_config['text']['tzn'], $time);
1027+
return Date($config['text']['tzn'], $time);
10271028
}
1028-
return $lgsl_config['text']['pen'];
1029+
return $config['text']['pen'];
10291030
}
10301031
public function setTimestamp($type, $time) {
10311032
$this->_server['cache_time']->set($type, $time);
@@ -1056,10 +1057,9 @@ public function setAdditionalData($data): void {
10561057
}
10571058
}
10581059
public function checkTimestamps($request = "") {
1059-
global $lgsl_config;
10601060
$needed = "";
10611061
foreach ([Timestamp::SERVER, Timestamp::EXTRAS, Timestamp::PLAYERS] as $stamp) {
1062-
if (LGSL::requestHas($request, $stamp) && time() > ($this->getTimestamp($stamp) + $lgsl_config['cache_time'])) { $needed .= $stamp; }
1062+
if (LGSL::requestHas($request, $stamp) && time() > ($this->getTimestamp($stamp) + (new Config())['cache_time'])) { $needed .= $stamp; }
10631063
}
10641064
return $needed;
10651065
}

src/lgsl_protocol.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3296,8 +3296,8 @@ static function lgslParseColor($string, $type, $needRemove = true) {
32963296
$string[$i] = chr($char);
32973297
}
32983298
} else {
3299-
$colors = ['0' => '888888', '1' => 'ff0000', '2' => '00ff00', '3' => 'DDCC00', '4' => '3377EE', '5' => '00eeee', '6' => 'DD55DD', '7' => 'ffffff', '8' => '808080', '9' => '808080'];
3300-
$pattern = '/\^(\d{1})([0-9a-zA-Z !@$%&-*+|\/\.]+)?/';
3299+
$colors = ['0' => '888888', '1' => 'ff0000', '2' => '00ff00', '3' => 'DDCC00', '4' => '3377EE', '5' => '00eeee', '6' => 'DD55DD', '7' => 'ffffff', '8' => '808080', '9' => '808080', 'a' => 'ff7f00'];
3300+
$pattern = '/\^([a0-9])([0-9a-zA-Z !@$%&-*+|\/\.]+)?/';
33013301
return Helper::lgslColorParser($string, $pattern, $colors);
33023302
}
33033303
break;

0 commit comments

Comments
 (0)