projects
/
rock.divinelegy.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
46bc590
)
SimfileParser should return bools for fgChanges etc, not strings.
author
Cameron Ball
<cameron@getapproved.com.au>
Wed, 26 Nov 2014 08:31:27 +0000
(16:31 +0800)
committer
Cameron Ball
<cameron@getapproved.com.au>
Wed, 26 Nov 2014 08:31:27 +0000
(16:31 +0800)
Services/SimfileParser.php
patch
|
blob
|
history
diff --git
a/Services/SimfileParser.php
b/Services/SimfileParser.php
index
b2438d0
..
1413acc
100644
(file)
--- a/
Services/SimfileParser.php
+++ b/
Services/SimfileParser.php
@@
-46,18
+46,19
@@
class SimfileParser implements ISimfileParser
public function stops()
{
public function stops()
{
- $stops = $this->extractKey('STOPS')
? 'Yes' : 'No'
;
- if(
!$stops
) throw new Exception ('Invalid SM file. STOPS missing');
+ $stops = $this->extractKey('STOPS');
+ if(
$stops === false
) throw new Exception ('Invalid SM file. STOPS missing');
- return $stops;
+ return
(bool)
$stops;
}
public function fgChanges()
{
}
public function fgChanges()
{
- $fgChanges = $this->extractKey('FGCHANGES') ? 'Yes' : 'No';
- if(!$fgChanges) throw new Exception ('Invalid SM file. FGCHANGES missing');
+ $fgChanges = $this->extractKey('FGCHANGES');
+ //XXX: Looks like fgChanges is allowed to be missing.
+ //if($fgChanges === false) throw new Exception ('Invalid SM file. FGCHANGES missing');
- return $fgChanges;
+ return
(bool)
$fgChanges;
}
public function bpm()
}
public function bpm()
@@
-79,18
+80,20
@@
class SimfileParser implements ISimfileParser
public function bgChanges()
{
public function bgChanges()
{
- $bgChanges = $this->extractKey('BGCHANGES')
? 'Yes' : 'No'
;
- if(
!$bgChanges
) throw new Exception ('Invalid SM file. BGCHANGES missing');
+ $bgChanges = $this->extractKey('BGCHANGES');
+ if(
$bgChanges === false
) throw new Exception ('Invalid SM file. BGCHANGES missing');
- return $bgChanges;
+ return
(bool)
$bgChanges;
}
public function bpmChanges()
{
}
public function bpmChanges()
{
- $bpm
Changes = $this->extractKey('BPMS') ? 'Yes' : 'No'
;
- if(!$bpm
Change
s) throw new Exception ('Invalid SM file. BPMS missing');
+ $bpm
s = $this->extractKey('BPMS')
;
+ if(!$bpms) throw new Exception ('Invalid SM file. BPMS missing');
- return $bpmChanges;
+ $bpmRange = $this->parseBpms($bpms);
+ //XXX: We have bpm changes when the high and low bpms are different.
+ return $bpmRange[0] != $bpmRange[1];
}
public function subtitle()
}
public function subtitle()
@@
-140,6
+143,8
@@
class SimfileParser implements ISimfileParser
$pos = strpos($line, '#' . $key . ':');
if ($pos !== false) return trim(substr($line, $pos + strlen($key) + 2));
}
$pos = strpos($line, '#' . $key . ':');
if ($pos !== false) return trim(substr($line, $pos + strlen($key) + 2));
}
+
+ return false;
}
private function parseBpms($bpms)
}
private function parseBpms($bpms)