Fixed: AIS crash if variable not initialized (a big thanks to depyraken to finding it)
This commit is contained in:
parent
976ebabf74
commit
7ab17400e7
1 changed files with 16 additions and 18 deletions
|
@ -376,17 +376,16 @@ inline
|
||||||
float CStateInstance::getNelVar(std::string const& varId)
|
float CStateInstance::getNelVar(std::string const& varId)
|
||||||
{
|
{
|
||||||
TNelVarList::iterator it = _NelVar.find(varId);
|
TNelVarList::iterator it = _NelVar.find(varId);
|
||||||
if (it==_NelVar.end())
|
if (it != _NelVar.end()) return it->second->get()
|
||||||
{
|
|
||||||
if (NLMISC::CVariable<float>::exists(varId))
|
if (NLMISC::CVariable<float>::exists(varId))
|
||||||
{
|
{
|
||||||
nlwarning("Nel variable \"%s\" exists outside of this state instance", varId.c_str());
|
nlwarning("Nel variable \"%s\" exists outside of this state instance", varId.c_str());
|
||||||
return 0.f;
|
return 0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
_NelVar[varId] = new NLMISC::CVariable<float>("StateInstance", varId.c_str(), "", 0.f);
|
_NelVar[varId] = new NLMISC::CVariable<float>("StateInstance", varId.c_str(), "", 0.f);
|
||||||
_NelVar[varId]->get();
|
return _NelVar[varId]->get();
|
||||||
}
|
|
||||||
return it->second->get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
@ -424,17 +423,16 @@ inline
|
||||||
std::string CStateInstance::getStrNelVar(std::string const& varId)
|
std::string CStateInstance::getStrNelVar(std::string const& varId)
|
||||||
{
|
{
|
||||||
TStrNelVarList::iterator it = _StrNelVar.find(varId);
|
TStrNelVarList::iterator it = _StrNelVar.find(varId);
|
||||||
if (it==_StrNelVar.end())
|
if (it!=_StrNelVar.end()) return it->second->get();
|
||||||
{
|
|
||||||
if (NLMISC::CVariable<float>::exists(varId))
|
if (NLMISC::CVariable<float>::exists(varId))
|
||||||
{
|
{
|
||||||
nlwarning("Nel variable \"%s\" exists outside of this state instance", varId.c_str());
|
nlwarning("Nel variable \"%s\" exists outside of this state instance", varId.c_str());
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
_StrNelVar[varId] = new NLMISC::CVariable<std::string>("StateInstanceVar", varId.c_str(), "", std::string());
|
_StrNelVar[varId] = new NLMISC::CVariable<std::string>("StateInstanceVar", varId.c_str(), "", std::string());
|
||||||
_NelVar[varId]->get();
|
return _NelVar[varId]->get();
|
||||||
}
|
|
||||||
return it->second->get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
|
Loading…
Reference in a new issue