Ajout d'une étape de linting dans DroneCi (#3)
All checks were successful
continuous-integration/drone/push Build is passing

Corrige un doublons laissé par le rebase semi-manuel

Ajout d'une étape de linting dans DroneCi

Fix linting

Co-authored-by: Nigel Sheldon <nigelsheldon@live.fr>
Reviewed-on: https://gitea.nemunai.re/halo-battle/game/pulls/3
This commit is contained in:
Nigel 2020-11-21 18:54:32 +00:00
commit dd61d3b66b
263 changed files with 45327 additions and 42695 deletions

View file

@ -11,13 +11,13 @@
//------------------------------------------------------------
// Defines for the different basic sizes of flags
//------------------------------------------------------------
DEFINE('FLAGSIZE1',1);
DEFINE('FLAGSIZE2',2);
DEFINE('FLAGSIZE3',3);
DEFINE('FLAGSIZE4',4);
class FlagImages {
DEFINE('FLAGSIZE1', 1);
DEFINE('FLAGSIZE2', 2);
DEFINE('FLAGSIZE3', 3);
DEFINE('FLAGSIZE4', 4);
class FlagImages
{
public $iCountryNameMap = array(
'Afghanistan' => 'afgh',
'Republic of Angola' => 'agla',
@ -258,119 +258,114 @@ class FlagImages {
private $iFlagCount = -1;
private $iFlagSetMap = array(
FLAGSIZE1 => 'flags_thumb35x35',
FLAGSIZE2 => 'flags_thumb60x60',
FLAGSIZE3 => 'flags_thumb100x100',
FLAGSIZE4 => 'flags'
);
FLAGSIZE1 => 'flags_thumb35x35',
FLAGSIZE2 => 'flags_thumb60x60',
FLAGSIZE3 => 'flags_thumb100x100',
FLAGSIZE4 => 'flags'
);
private $iFlagData ;
private $iOrdIdx=array();
function FlagImages($aSize=FLAGSIZE1) {
switch($aSize) {
case FLAGSIZE1 :
case FLAGSIZE2 :
case FLAGSIZE3 :
case FLAGSIZE4 :
$file = dirname(__FILE__).'/'.$this->iFlagSetMap[$aSize].'.dat';
$fp = fopen($file,'rb');
$rawdata = fread($fp,filesize($file));
$this->iFlagData = unserialize($rawdata);
break;
default:
JpGraphError::RaiseL(5001,$aSize);
public function FlagImages($aSize=FLAGSIZE1)
{
switch ($aSize) {
case FLAGSIZE1:
case FLAGSIZE2:
case FLAGSIZE3:
case FLAGSIZE4:
$file = dirname(__FILE__).'/'.$this->iFlagSetMap[$aSize].'.dat';
$fp = fopen($file, 'rb');
$rawdata = fread($fp, filesize($file));
$this->iFlagData = unserialize($rawdata);
break;
default:
JpGraphError::RaiseL(5001, $aSize);
//('Unknown flag size. ('.$aSize.')');
}
$this->iFlagCount = count($this->iCountryNameMap);
}
$this->iFlagCount = count($this->iCountryNameMap);
}
function GetNum() {
return $this->iFlagCount;
public function GetNum()
{
return $this->iFlagCount;
}
function GetImgByName($aName,&$outFullName) {
$idx = $this->GetIdxByName($aName,$outFullName);
return $this->GetImgByIdx($idx);
public function GetImgByName($aName, &$outFullName)
{
$idx = $this->GetIdxByName($aName, $outFullName);
return $this->GetImgByIdx($idx);
}
function GetImgByIdx($aIdx) {
if( array_key_exists($aIdx,$this->iFlagData) ) {
$d = $this->iFlagData[$aIdx][1];
return Image::CreateFromString($d);
}
else {
JpGraphError::RaiseL(5002,$aIdx);
//("Flag index \" $aIdx\" does not exist.");
}
public function GetImgByIdx($aIdx)
{
if (array_key_exists($aIdx, $this->iFlagData)) {
$d = $this->iFlagData[$aIdx][1];
return Image::CreateFromString($d);
} else {
JpGraphError::RaiseL(5002, $aIdx);
//("Flag index \" $aIdx\" does not exist.");
}
}
function GetIdxByOrdinal($aOrd,&$outFullName) {
$aOrd--;
$n = count($this->iOrdIdx);
if( $n == 0 ) {
reset($this->iCountryNameMap);
$this->iOrdIdx=array();
$i=0;
while( list($key,$val) = each($this->iCountryNameMap) ) {
$this->iOrdIdx[$i++] = array($val,$key);
}
$tmp=$this->iOrdIdx[$aOrd];
$outFullName = $tmp[1];
return $tmp[0];
}
elseif( $aOrd >= 0 && $aOrd < $n ) {
$tmp=$this->iOrdIdx[$aOrd];
$outFullName = $tmp[1];
return $tmp[0];
}
else {
JpGraphError::RaiseL(5003,$aOrd);
//('Invalid ordinal number specified for flag index.');
}
public function GetIdxByOrdinal($aOrd, &$outFullName)
{
$aOrd--;
$n = count($this->iOrdIdx);
if ($n == 0) {
reset($this->iCountryNameMap);
$this->iOrdIdx=array();
$i=0;
while (list($key, $val) = each($this->iCountryNameMap)) {
$this->iOrdIdx[$i++] = array($val,$key);
}
$tmp=$this->iOrdIdx[$aOrd];
$outFullName = $tmp[1];
return $tmp[0];
} elseif ($aOrd >= 0 && $aOrd < $n) {
$tmp=$this->iOrdIdx[$aOrd];
$outFullName = $tmp[1];
return $tmp[0];
} else {
JpGraphError::RaiseL(5003, $aOrd);
//('Invalid ordinal number specified for flag index.');
}
}
function GetIdxByName($aName,&$outFullName) {
public function GetIdxByName($aName, &$outFullName)
{
if (is_integer($aName)) {
$idx = $this->GetIdxByOrdinal($aName, $outFullName);
return $idx;
}
if( is_integer($aName) ) {
$idx = $this->GetIdxByOrdinal($aName,$outFullName);
return $idx;
}
$found=false;
$aName = strtolower($aName);
$nlen = strlen($aName);
reset($this->iCountryNameMap);
// Start by trying to match exact index name
while( list($key,$val) = each($this->iCountryNameMap) ) {
if( $nlen == strlen($val) && $val == $aName ) {
$found=true;
break;
}
}
if( !$found ) {
reset($this->iCountryNameMap);
// If the exact index doesn't work try a (partial) full name
while( list($key,$val) = each($this->iCountryNameMap) ) {
if( strpos(strtolower($key), $aName) !== false ) {
$found=true;
break;
}
}
}
if( $found ) {
$outFullName = $key;
return $val;
}
else {
JpGraphError::RaiseL(5004,$aName);
//("The (partial) country name \"$aName\" does not have a cooresponding flag image. The flag may still exist but under another name, e.g. insted of \"usa\" try \"united states\".");
}
$found=false;
$aName = strtolower($aName);
$nlen = strlen($aName);
reset($this->iCountryNameMap);
// Start by trying to match exact index name
while (list($key, $val) = each($this->iCountryNameMap)) {
if ($nlen == strlen($val) && $val == $aName) {
$found=true;
break;
}
}
if (!$found) {
reset($this->iCountryNameMap);
// If the exact index doesn't work try a (partial) full name
while (list($key, $val) = each($this->iCountryNameMap)) {
if (strpos(strtolower($key), $aName) !== false) {
$found=true;
break;
}
}
}
if ($found) {
$outFullName = $key;
return $val;
} else {
JpGraphError::RaiseL(5004, $aName);
//("The (partial) country name \"$aName\" does not have a cooresponding flag image. The flag may still exist but under another name, e.g. insted of \"usa\" try \"united states\".");
}
}
}
?>