Skip to content

Commit

Permalink
Fix parsing of fire rates (#22)
Browse files Browse the repository at this point in the history
* Fix parsing of fire rates

* Parse any whitespace between terms

instead of only spaces

* Parse multiplication of terms
  • Loading branch information
lL1l1 authored Aug 11, 2024
1 parent 8f58e74 commit 2818f31
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions www/res/scripts/luaToPhp.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ function trimval(string)
function trimval($str)
{
$str = trim($str);

// Evaluated numbers used in fire rates like '10/10'
if (preg_match('/^((?:[0-9\.]+\w*[\*\/+-]\w*)*[0-9\.]+),?$/', $str, $matches))
{
eval('$str = ' . $matches[1] . ';');
return (float)$str == (int)$str ? (int)$str : (float)$str;
}

if (substr($str,0,1)=="\""){

$str = trim(substr($str,1,strlen($str)));
Expand Down

0 comments on commit 2818f31

Please sign in to comment.