Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tltneon committed Feb 26, 2025
1 parent d11a75a commit a875379
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
28 changes: 14 additions & 14 deletions src/lgsl_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -981,8 +981,8 @@ public function getMapImage($check_exists = true) {
return "#LGSL_DEFAULT_IMAGES_MISSING#";
}
public function getGameFormatted() {
global $lgsl_config;
return "[ {$lgsl_config['text']['typ']}: {$this->getType()} ] [ {$lgsl_config['text']['gme']}: {$this->getGame()} ]";
$config = new Config();
return "[ {$config['text']['typ']}: {$this->getType()} ] [ {$config['text']['gme']}: {$this->getGame()} ]";
}
public function getGameIcon($path = '') {
$type = LGSL::normalizeString($this->getType());
Expand All @@ -1001,17 +1001,18 @@ public function getGameIcon($path = '') {
return "{$path}other/icon_unknown.gif";
}
public function getStatusIcon($path = '') {
$path .= 'other/';
switch ($this->getStatus()) {
case self::PENDING: return "{$path}other/icon_unknown.gif";
case self::ERROR: return "{$path}other/icon_unknown.gif";
case self::OFFLINE: return "{$path}other/icon_no_response.gif";
case self::PASSWORDED: return "{$path}other/icon_online_password.gif";
default: return "{$path}other/icon_online.gif";
case self::PENDING: return "{$path}icon_unknown.gif";
case self::ERROR: return "{$path}icon_unknown.gif";
case self::OFFLINE: return "{$path}icon_no_response.gif";
case self::PASSWORDED: return "{$path}icon_online_password.gif";
default: return "{$path}icon_online.gif";
}
}
public function getLocationFormatted() {
global $lgsl_config;
return "{$lgsl_config['text']['loc']} {$this->getLocation()}";
$config = new Config();
return "{$config['text']['loc']} {$this->getLocation()}";
}
public function getLocation() {
return $this->_other['location'] ?? "XX";
Expand All @@ -1021,11 +1022,11 @@ public function getTimestamp($type = Timestamp::SERVER) {
}
public function getTimestampFormatted($type = Timestamp::SERVER) {
$time = $this->getTimestamp($type);
global $lgsl_config;
$config = new Config();
if ($time > 0) {
return Date($lgsl_config['text']['tzn'], $time);
return Date($config['text']['tzn'], $time);
}
return $lgsl_config['text']['pen'];
return $config['text']['pen'];
}
public function setTimestamp($type, $time) {
$this->_server['cache_time']->set($type, $time);
Expand Down Expand Up @@ -1056,10 +1057,9 @@ public function setAdditionalData($data): void {
}
}
public function checkTimestamps($request = "") {
global $lgsl_config;
$needed = "";
foreach ([Timestamp::SERVER, Timestamp::EXTRAS, Timestamp::PLAYERS] as $stamp) {
if (LGSL::requestHas($request, $stamp) && time() > ($this->getTimestamp($stamp) + $lgsl_config['cache_time'])) { $needed .= $stamp; }
if (LGSL::requestHas($request, $stamp) && time() > ($this->getTimestamp($stamp) + (new Config())['cache_time'])) { $needed .= $stamp; }
}
return $needed;
}
Expand Down
4 changes: 2 additions & 2 deletions src/lgsl_protocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -3296,8 +3296,8 @@ static function lgslParseColor($string, $type, $needRemove = true) {
$string[$i] = chr($char);
}
} else {
$colors = ['0' => '888888', '1' => 'ff0000', '2' => '00ff00', '3' => 'DDCC00', '4' => '3377EE', '5' => '00eeee', '6' => 'DD55DD', '7' => 'ffffff', '8' => '808080', '9' => '808080'];
$pattern = '/\^(\d{1})([0-9a-zA-Z !@$%&-*+|\/\.]+)?/';
$colors = ['0' => '888888', '1' => 'ff0000', '2' => '00ff00', '3' => 'DDCC00', '4' => '3377EE', '5' => '00eeee', '6' => 'DD55DD', '7' => 'ffffff', '8' => '808080', '9' => '808080', 'a' => 'ff7f00'];
$pattern = '/\^([a0-9])([0-9a-zA-Z !@$%&-*+|\/\.]+)?/';
return Helper::lgslColorParser($string, $pattern, $colors);
}
break;
Expand Down

0 comments on commit a875379

Please sign in to comment.