mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 07:23:51 +00:00
Expression parser: Try to parse strings as number literals (bug #5097)
This commit is contained in:
parent
7b0cf868af
commit
138a7ac434
2 changed files with 17 additions and 0 deletions
|
@ -127,6 +127,7 @@
|
||||||
Bug #5089: Swimming/Underwater creatures only swim around ground level
|
Bug #5089: Swimming/Underwater creatures only swim around ground level
|
||||||
Bug #5092: NPCs with enchanted weapons play sound when out of charges
|
Bug #5092: NPCs with enchanted weapons play sound when out of charges
|
||||||
Bug #5093: Hand to hand sound plays on knocked out enemies
|
Bug #5093: Hand to hand sound plays on knocked out enemies
|
||||||
|
Bug #5097: String arguments can't be parsed as number literals in scripts
|
||||||
Bug #5099: Non-swimming enemies will enter water if player is water walking
|
Bug #5099: Non-swimming enemies will enter water if player is water walking
|
||||||
Bug #5103: Sneaking state behavior is still inconsistent
|
Bug #5103: Sneaking state behavior is still inconsistent
|
||||||
Bug #5104: Black Dart's enchantment doesn't trigger at low Enchant levels
|
Bug #5104: Black Dart's enchantment doesn't trigger at low Enchant levels
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
|
|
||||||
|
@ -324,6 +325,21 @@ namespace Compiler
|
||||||
mExplicit = name2;
|
mExplicit = name2;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is terrible, but of course we must have this for legacy content.
|
||||||
|
// Convert the string to a number even if it's impossible and use it as a number literal.
|
||||||
|
// Can't use stof/atof or to_string out of locale concerns.
|
||||||
|
float number;
|
||||||
|
std::stringstream stream(name2);
|
||||||
|
stream >> number;
|
||||||
|
stream.str(std::string());
|
||||||
|
stream.clear();
|
||||||
|
stream << number;
|
||||||
|
|
||||||
|
pushFloatLiteral(number);
|
||||||
|
mTokenLoc = loc;
|
||||||
|
getErrorHandler().warning ("Parsing a non-variable string as a number: " + stream.str(), loc);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue