mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-22 23:06:18 +00:00
merged with compatibility-develop
This commit is contained in:
parent
db771f1d2b
commit
095bc1b04c
15 changed files with 102 additions and 102 deletions
|
@ -131,20 +131,20 @@ public:
|
||||||
CRyzomTime()
|
CRyzomTime()
|
||||||
{
|
{
|
||||||
_RyzomDay = 0;
|
_RyzomDay = 0;
|
||||||
_RyzomTime = 0;
|
_RyzomTime = 0.f;
|
||||||
|
_LocalTime = 0.0;
|
||||||
_TickOffset = 0;
|
_TickOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update ryzom clock when tick occurs, local time must be given if localUpdateRyzomClock() and getLocalRyzomTime() is used
|
// Update ryzom clock when tick occurs, local time must be given if localUpdateRyzomClock() and getLocalRyzomTime() is used
|
||||||
void updateRyzomClock( uint32 gameCyle, double localTime = 0 )
|
void updateRyzomClock( uint32 gameCyle, double localTime = 0 )
|
||||||
{
|
{
|
||||||
float time = ( gameCyle + _TickOffset ) / float(RYZOM_HOURS_IN_TICKS);
|
float hours = ( gameCyle + _TickOffset ) / float(RYZOM_HOURS_IN_TICKS);
|
||||||
_RyzomDay = (uint32) ( time / RYZOM_DAY_IN_HOUR ) - RYZOM_START_SPRING;
|
_RyzomDay = ( (uint)hours / RYZOM_DAY_IN_HOUR ) - RYZOM_START_SPRING;
|
||||||
_RyzomTime = (float) fmod( time, RYZOM_DAY_IN_HOUR );
|
_RyzomTime = (float) fmod( hours, (float)RYZOM_DAY_IN_HOUR );
|
||||||
_LocalTime = localTime;
|
_LocalTime = localTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// get ryzom time (synchronized with server)
|
// get ryzom time (synchronized with server)
|
||||||
inline float getRyzomTime() const { return _RyzomTime; }
|
inline float getRyzomTime() const { return _RyzomTime; }
|
||||||
|
|
||||||
|
|
|
@ -1686,7 +1686,9 @@ NLMISC_COMMAND(getDatasetId,"get datasetid of bots with name matchiong the given
|
||||||
FOREACH(itBot, vector<CBot*>, bots)
|
FOREACH(itBot, vector<CBot*>, bots)
|
||||||
{
|
{
|
||||||
CBot* bot = *itBot;
|
CBot* bot = *itBot;
|
||||||
DatasetIds += bot->getSpawnObj()->dataSetRow().toString()+"|";
|
CSpawnBot* spawnBot = bot->getSpawnObj();
|
||||||
|
if (spawnBot!=NULL)
|
||||||
|
DatasetIds += spawnBot->dataSetRow().toString()+"|";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,14 +44,14 @@ class CStateInstance
|
||||||
public:
|
public:
|
||||||
inline
|
inline
|
||||||
CStateInstance(CAIState* startState);
|
CStateInstance(CAIState* startState);
|
||||||
|
|
||||||
void init(CAIState* startState);
|
void init(CAIState* startState);
|
||||||
|
|
||||||
virtual CPersistentStateInstance* getPersistentStateInstance();
|
virtual CPersistentStateInstance* getPersistentStateInstance();
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// State Persistent.
|
// State Persistent.
|
||||||
|
|
||||||
struct CStatePersistentObjEntry
|
struct CStatePersistentObjEntry
|
||||||
{
|
{
|
||||||
CStatePersistentObjEntry();
|
CStatePersistentObjEntry();
|
||||||
|
@ -61,78 +61,78 @@ public:
|
||||||
NLMISC::CSmartPtr<NLMISC::CVirtualRefCount> _Obj;
|
NLMISC::CSmartPtr<NLMISC::CVirtualRefCount> _Obj;
|
||||||
};
|
};
|
||||||
typedef std::vector<CStatePersistentObjEntry> TStatePersistentObjList;
|
typedef std::vector<CStatePersistentObjEntry> TStatePersistentObjList;
|
||||||
|
|
||||||
TStatePersistentObjList _StatePersistentObjList;
|
TStatePersistentObjList _StatePersistentObjList;
|
||||||
|
|
||||||
// Made to allow obj with life time less or equal to state affectation life time.
|
// Made to allow obj with life time less or equal to state affectation life time.
|
||||||
void addStatePersistentObj(CAIState const* keyState, NLMISC::CSmartPtr<NLMISC::CVirtualRefCount> anyObj);
|
void addStatePersistentObj(CAIState const* keyState, NLMISC::CSmartPtr<NLMISC::CVirtualRefCount> anyObj);
|
||||||
void removeExceptForState(CAIState const* keyState);
|
void removeExceptForState(CAIState const* keyState);
|
||||||
|
|
||||||
/** Try to obtain a group interface from the CStateInstance. Can return NULL if the
|
/** Try to obtain a group interface from the CStateInstance. Can return NULL if the
|
||||||
* CStateInstance if not implemeted by a group related objet.
|
* CStateInstance if not implemeted by a group related objet.
|
||||||
*/
|
*/
|
||||||
// Bad, Bad, Bad ..
|
// Bad, Bad, Bad ..
|
||||||
virtual CGroup* getGroup() = 0;
|
virtual CGroup* getGroup() = 0;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
CAITimerExtended& timerStateTimeout() { return _StateTimeout; }
|
CAITimerExtended& timerStateTimeout() { return _StateTimeout; }
|
||||||
CAITimerExtended& timerPunctTimeout() { return _PunctualStateTimeout; }
|
CAITimerExtended& timerPunctTimeout() { return _PunctualStateTimeout; }
|
||||||
CAITimerExtended& timerUser(uint idx);
|
CAITimerExtended& timerUser(uint idx);
|
||||||
|
|
||||||
CAIState* getCAIState();
|
CAIState* getCAIState();
|
||||||
|
|
||||||
virtual CAliasTreeOwner* aliasTreeOwner() = 0;
|
virtual CAliasTreeOwner* aliasTreeOwner() = 0;
|
||||||
|
|
||||||
virtual void stateChange(CAIState const* oldState, CAIState const* newState) = 0;
|
virtual void stateChange(CAIState const* oldState, CAIState const* newState) = 0;
|
||||||
|
|
||||||
CAIState* getState() const { return _state; }
|
CAIState* getState() const { return _state; }
|
||||||
void setNextState(CAIState*);
|
void setNextState(CAIState*);
|
||||||
|
|
||||||
CAIState* getPunctualState() const { return _PunctualState; }
|
CAIState* getPunctualState() const { return _PunctualState; }
|
||||||
CAIState* getNextPunctualState() const { return _NextPunctualState; }
|
CAIState* getNextPunctualState() const { return _NextPunctualState; }
|
||||||
void setNextPunctualState(CAIState* state);
|
void setNextPunctualState(CAIState* state);
|
||||||
void cancelPunctualState() { _CancelPunctualState = true; }
|
void cancelPunctualState() { _CancelPunctualState = true; }
|
||||||
|
|
||||||
std::string buidStateInstanceDebugString() const;
|
std::string buidStateInstanceDebugString() const;
|
||||||
|
|
||||||
void dumpVarsAndFunctions(CStringWriter& sw) const;
|
void dumpVarsAndFunctions(CStringWriter& sw) const;
|
||||||
|
|
||||||
virtual CDebugHistory* getDebugHistory () = 0;
|
virtual CDebugHistory* getDebugHistory () = 0;
|
||||||
|
|
||||||
CAIState const* getActiveState() const;
|
CAIState const* getActiveState() const;
|
||||||
|
|
||||||
sint32 getUserTimer(uint timerId);
|
sint32 getUserTimer(uint timerId);
|
||||||
void setUserTimer(uint timerId, sint32 time);
|
void setUserTimer(uint timerId, sint32 time);
|
||||||
|
|
||||||
void logicVarsToString(std::string& str) const;
|
void logicVarsToString(std::string& str) const;
|
||||||
|
|
||||||
float getNelVar(std::string const& varId);
|
float getNelVar(std::string const& varId);
|
||||||
void setNelVar(std::string const& varId, float value);
|
void setNelVar(std::string const& varId, float value);
|
||||||
void delNelVar(std::string const& varId);
|
void delNelVar(std::string const& varId);
|
||||||
|
|
||||||
std::string getStrNelVar(std::string const& varId);
|
std::string getStrNelVar(std::string const& varId);
|
||||||
void setStrNelVar(std::string const& varId, std::string const& value);
|
void setStrNelVar(std::string const& varId, std::string const& value);
|
||||||
void delStrNelVar(std::string const& varId);
|
void delStrNelVar(std::string const& varId);
|
||||||
|
|
||||||
static void setGlobalNelVar(std::string const& varId, float value);
|
static void setGlobalNelVar(std::string const& varId, float value);
|
||||||
static void setGlobalNelVar(std::string const& varId, std::string value);
|
static void setGlobalNelVar(std::string const& varId, std::string value);
|
||||||
|
|
||||||
CAITimerExtended const& userTimer (uint32 index) const;
|
CAITimerExtended const& userTimer (uint32 index) const;
|
||||||
|
|
||||||
bool advanceUserTimer(uint32 nbTicks);
|
bool advanceUserTimer(uint32 nbTicks);
|
||||||
|
|
||||||
void processStateEvent(CAIEvent const& stateEvent, CAIState const* state = NULL);
|
void processStateEvent(CAIEvent const& stateEvent, CAIState const* state = NULL);
|
||||||
|
|
||||||
// callerStateInstance could be NULL;
|
// callerStateInstance could be NULL;
|
||||||
void interpretCode(AIVM::IScriptContext* callerStateInstance, AIVM::CByteCodeEntry const& codeScriptEntry);
|
void interpretCode(AIVM::IScriptContext* callerStateInstance, AIVM::CByteCodeEntry const& codeScriptEntry);
|
||||||
void interpretCode(AIVM::IScriptContext* callerStateInstance, NLMISC::CSmartPtr<AIVM::CByteCode const> const& codeScript);
|
void interpretCode(AIVM::IScriptContext* callerStateInstance, NLMISC::CSmartPtr<AIVM::CByteCode const> const& codeScript);
|
||||||
|
|
||||||
/// @name IScriptContext implementation
|
/// @name IScriptContext implementation
|
||||||
//@{
|
//@{
|
||||||
virtual std::string getContextName();
|
virtual std::string getContextName();
|
||||||
virtual void interpretCodeOnChildren(AIVM::CByteCodeEntry const& codeScriptEntry);
|
virtual void interpretCodeOnChildren(AIVM::CByteCodeEntry const& codeScriptEntry);
|
||||||
|
|
||||||
float getLogicVar(NLMISC::TStringId varId);
|
float getLogicVar(NLMISC::TStringId varId);
|
||||||
void setLogicVar(NLMISC::TStringId varId, float value);
|
void setLogicVar(NLMISC::TStringId varId, float value);
|
||||||
std::string getStrLogicVar(NLMISC::TStringId varId);
|
std::string getStrLogicVar(NLMISC::TStringId varId);
|
||||||
|
@ -140,19 +140,19 @@ public:
|
||||||
AIVM::IScriptContext* getCtxLogicVar(NLMISC::TStringId varId);
|
AIVM::IScriptContext* getCtxLogicVar(NLMISC::TStringId varId);
|
||||||
void setCtxLogicVar(NLMISC::TStringId varId, AIVM::IScriptContext* value);
|
void setCtxLogicVar(NLMISC::TStringId varId, AIVM::IScriptContext* value);
|
||||||
void setFirstBotSpawned();
|
void setFirstBotSpawned();
|
||||||
|
|
||||||
virtual AIVM::IScriptContext* findContext(NLMISC::TStringId const strId);
|
virtual AIVM::IScriptContext* findContext(NLMISC::TStringId const strId);
|
||||||
|
|
||||||
virtual void setScriptCallBack(NLMISC::TStringId const& eventName, AIVM::CByteCodeEntry const& codeScriptEntry);
|
virtual void setScriptCallBack(NLMISC::TStringId const& eventName, AIVM::CByteCodeEntry const& codeScriptEntry);
|
||||||
virtual AIVM::CByteCodeEntry const* getScriptCallBackPtr(NLMISC::TStringId const& eventName) const;
|
virtual AIVM::CByteCodeEntry const* getScriptCallBackPtr(NLMISC::TStringId const& eventName) const;
|
||||||
virtual void callScriptCallBack(AIVM::IScriptContext* caller, NLMISC::TStringId const& funcName, int mode = 0, std::string const& inParamsSig = "", std::string const& outParamsSig = "", AIVM::CScriptStack* stack = NULL);
|
virtual void callScriptCallBack(AIVM::IScriptContext* caller, NLMISC::TStringId const& funcName, int mode = 0, std::string const& inParamsSig = "", std::string const& outParamsSig = "", AIVM::CScriptStack* stack = NULL);
|
||||||
virtual void callNativeCallBack(AIVM::IScriptContext* caller, std::string const& funcName, int mode = 0, std::string const& inParamsSig = "", std::string const& outParamsSig = "", AIVM::CScriptStack* stack = NULL);
|
virtual void callNativeCallBack(AIVM::IScriptContext* caller, std::string const& funcName, int mode = 0, std::string const& inParamsSig = "", std::string const& outParamsSig = "", AIVM::CScriptStack* stack = NULL);
|
||||||
|
|
||||||
void blockUserEvent(uint32 eventId);
|
void blockUserEvent(uint32 eventId);
|
||||||
void unblockUserEvent(uint32 eventId);
|
void unblockUserEvent(uint32 eventId);
|
||||||
bool isUserEventBlocked(uint32 eventId) const;
|
bool isUserEventBlocked(uint32 eventId) const;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Logic variables
|
/// Logic variables
|
||||||
typedef std::map<NLMISC::TStringId, float> TLogicVarList;
|
typedef std::map<NLMISC::TStringId, float> TLogicVarList;
|
||||||
|
@ -162,38 +162,38 @@ protected:
|
||||||
TLogicVarList _LogicVar;
|
TLogicVarList _LogicVar;
|
||||||
TStrLogicVarList _StrLogicVar;
|
TStrLogicVarList _StrLogicVar;
|
||||||
TCtxLogicVarList _CtxLogicVar;
|
TCtxLogicVarList _CtxLogicVar;
|
||||||
|
|
||||||
// Nel variables
|
// Nel variables
|
||||||
typedef std::map<std::string, NLMISC::CVariable<float>*> TNelVarList;
|
typedef std::map<std::string, NLMISC::CVariable<float>*> TNelVarList;
|
||||||
typedef std::map<std::string, NLMISC::CVariable<std::string>*> TStrNelVarList;
|
typedef std::map<std::string, NLMISC::CVariable<std::string>*> TStrNelVarList;
|
||||||
TNelVarList _NelVar;
|
TNelVarList _NelVar;
|
||||||
TStrNelVarList _StrNelVar;
|
TStrNelVarList _StrNelVar;
|
||||||
|
|
||||||
// Callbacks (?)
|
// Callbacks (?)
|
||||||
typedef std::map<NLMISC::TStringId, AIVM::CByteCodeEntry> TCallBackList;
|
typedef std::map<NLMISC::TStringId, AIVM::CByteCodeEntry> TCallBackList;
|
||||||
TCallBackList _CallBacks;
|
TCallBackList _CallBacks;
|
||||||
|
|
||||||
/// Flag for variable modification
|
/// Flag for variable modification
|
||||||
bool _LogicVarChanged;
|
bool _LogicVarChanged;
|
||||||
bool _LogicVarChangedList[4];
|
bool _LogicVarChangedList[4];
|
||||||
//TLogicVarIndex _VarIndex;
|
//TLogicVarIndex _VarIndex;
|
||||||
// update logic timers ---------------------------------------------
|
// update logic timers ---------------------------------------------
|
||||||
/// 4 timers available for user logic
|
/// 4 timers available for user logic
|
||||||
CAITimerExtended _UserTimer[4];
|
CAITimerExtended _UserTimer[4];
|
||||||
|
|
||||||
/// timer for timing positional states
|
/// timer for timing positional states
|
||||||
CAITimerExtended _StateTimeout;
|
CAITimerExtended _StateTimeout;
|
||||||
/// current state (index into manager's state vector)
|
/// current state (index into manager's state vector)
|
||||||
CAIState* _state;
|
CAIState* _state;
|
||||||
/// variable set to request a state change (std::numeric_limits<uint32>::max() otherwise)
|
/// variable set to request a state change (std::numeric_limits<uint32>::max() otherwise)
|
||||||
CAIState* _NextState;
|
CAIState* _NextState;
|
||||||
|
|
||||||
/// timer for timing punctual states
|
/// timer for timing punctual states
|
||||||
CAITimerExtended _PunctualStateTimeout;
|
CAITimerExtended _PunctualStateTimeout;
|
||||||
|
|
||||||
CAIState* _PunctualState;
|
CAIState* _PunctualState;
|
||||||
CAIState* _NextPunctualState;
|
CAIState* _NextPunctualState;
|
||||||
|
|
||||||
/// Flag for leaving the punctual state, returning to normal behavior
|
/// Flag for leaving the punctual state, returning to normal behavior
|
||||||
bool _CancelPunctualState;
|
bool _CancelPunctualState;
|
||||||
bool _FirstBotSpawned;
|
bool _FirstBotSpawned;
|
||||||
|
@ -213,35 +213,35 @@ class CPersistentStateInstance
|
||||||
public:
|
public:
|
||||||
CPersistentStateInstance(CStateMachine& reactionContainer);
|
CPersistentStateInstance(CStateMachine& reactionContainer);
|
||||||
virtual ~CPersistentStateInstance();
|
virtual ~CPersistentStateInstance();
|
||||||
|
|
||||||
typedef std::vector<NLMISC::CDbgPtr<CPersistentStateInstance> > TChildList;
|
typedef std::vector<NLMISC::CDbgPtr<CPersistentStateInstance> > TChildList;
|
||||||
|
|
||||||
void setParentStateInstance(CPersistentStateInstance* parentStateInstance);
|
void setParentStateInstance(CPersistentStateInstance* parentStateInstance);
|
||||||
|
|
||||||
CPersistentStateInstance* getParentStateInstance() const { return _ParentStateInstance; }
|
CPersistentStateInstance* getParentStateInstance() const { return _ParentStateInstance; }
|
||||||
|
|
||||||
void addChildStateInstance(CPersistentStateInstance* parentStateInstance);
|
void addChildStateInstance(CPersistentStateInstance* parentStateInstance);
|
||||||
|
|
||||||
void removeChildStateInstance(CPersistentStateInstance* parentStateInstance);
|
void removeChildStateInstance(CPersistentStateInstance* parentStateInstance);
|
||||||
|
|
||||||
TChildList& childs() { return _PSIChilds; }
|
TChildList& childs() { return _PSIChilds; }
|
||||||
|
|
||||||
TChildList _PSIChilds;
|
TChildList _PSIChilds;
|
||||||
|
|
||||||
// Interface to state status variables -----------------------------
|
// Interface to state status variables -----------------------------
|
||||||
CAIState* getStartState() { return _StartState; }
|
CAIState* getStartState() { return _StartState; }
|
||||||
void setStartState(CAIState* state);
|
void setStartState(CAIState* state);
|
||||||
|
|
||||||
CStateMachine& getEventContainer() { return _Container; }
|
CStateMachine& getEventContainer() { return _Container; }
|
||||||
|
|
||||||
void updateStateInstance();
|
void updateStateInstance();
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// CStateInstance
|
// CStateInstance
|
||||||
CPersistentStateInstance* getPersistentStateInstance() { return this; }
|
CPersistentStateInstance* getPersistentStateInstance() { return this; }
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// id of the state to use at startup
|
/// id of the state to use at startup
|
||||||
NLMISC::CDbgPtr<CAIState> _StartState;
|
NLMISC::CDbgPtr<CAIState> _StartState;
|
||||||
|
@ -330,9 +330,9 @@ void CStateInstance::setLogicVar(NLMISC::TStringId varId, float value)
|
||||||
//_VarIndex[varId]
|
//_VarIndex[varId]
|
||||||
_LogicVarChangedList[static_cast<uint32>(index)] = true;
|
_LogicVarChangedList[static_cast<uint32>(index)] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
@ -354,7 +354,7 @@ void CStateInstance::setStrLogicVar(NLMISC::TStringId varId, std::string const&
|
||||||
//_VarIndex[varId]
|
//_VarIndex[varId]
|
||||||
_LogicVarChangedList[static_cast<uint32>(index)] = true;
|
_LogicVarChangedList[static_cast<uint32>(index)] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//_LogicVarChangedList[_VarIndex[varId]] = true;
|
//_LogicVarChangedList[_VarIndex[varId]] = true;
|
||||||
}
|
}
|
||||||
|
@ -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());
|
||||||
{
|
return 0.f;
|
||||||
nlwarning("Nel variable \"%s\" exists outside of this state instance", varId.c_str());
|
|
||||||
return 0.f;
|
|
||||||
}
|
|
||||||
_NelVar[varId] = new NLMISC::CVariable<float>("StateInstance", varId.c_str(), "", 0.f);
|
|
||||||
_NelVar[varId]->get();
|
|
||||||
}
|
}
|
||||||
return it->second->get();
|
|
||||||
|
_NelVar[varId] = new NLMISC::CVariable<float>("StateInstance", varId.c_str(), "", 0.f);
|
||||||
|
return _NelVar[varId]->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());
|
||||||
{
|
return "";
|
||||||
nlwarning("Nel variable \"%s\" exists outside of this state instance", varId.c_str());
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
_StrNelVar[varId] = new NLMISC::CVariable<std::string>("StateInstanceVar", varId.c_str(), "", std::string());
|
|
||||||
_NelVar[varId]->get();
|
|
||||||
}
|
}
|
||||||
return it->second->get();
|
|
||||||
|
_StrNelVar[varId] = new NLMISC::CVariable<std::string>("StateInstanceStrVar", varId.c_str(), "", std::string());
|
||||||
|
return _StrNelVar[varId]->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
@ -483,7 +481,7 @@ bool CStateInstance::advanceUserTimer(uint32 nbTicks)
|
||||||
setUserTimer(k, (t>nbTicks)?(t-nbTicks):0);
|
setUserTimer(k, (t>nbTicks)?(t-nbTicks):0);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void CStateInstance::processStateEvent(CAIEvent const& stateEvent, CAIState const* state)
|
void CStateInstance::processStateEvent(CAIEvent const& stateEvent, CAIState const* state)
|
||||||
|
@ -496,7 +494,7 @@ void CStateInstance::processStateEvent(CAIEvent const& stateEvent, CAIState cons
|
||||||
if (!state)
|
if (!state)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool foundReaction=false;
|
bool foundReaction=false;
|
||||||
// nlassert(_mgr);
|
// nlassert(_mgr);
|
||||||
for (uint i=0;i<stateEvent.reactionList().size();++i)
|
for (uint i=0;i<stateEvent.reactionList().size();++i)
|
||||||
|
@ -504,12 +502,12 @@ void CStateInstance::processStateEvent(CAIEvent const& stateEvent, CAIState cons
|
||||||
const CAIEventReaction &reaction=*stateEvent.reactionList()[i];
|
const CAIEventReaction &reaction=*stateEvent.reactionList()[i];
|
||||||
if (!reaction.testCompatibility(this,state))
|
if (!reaction.testCompatibility(this,state))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
getDebugHistory()->addHistory("STATE: '%s' EVENT: '%s' REACTION: '%s'", state->getAliasNode()->fullName().c_str(),
|
getDebugHistory()->addHistory("STATE: '%s' EVENT: '%s' REACTION: '%s'", state->getAliasNode()->fullName().c_str(),
|
||||||
stateEvent.getName().c_str(), reaction.getAliasNode()->fullName().c_str());
|
stateEvent.getName().c_str(), reaction.getAliasNode()->fullName().c_str());
|
||||||
|
|
||||||
foundReaction=true;
|
foundReaction=true;
|
||||||
|
|
||||||
if (!reaction.getAction())
|
if (!reaction.getAction())
|
||||||
{
|
{
|
||||||
nlwarning("Failed to find action for event: %s",reaction.getAliasNode()->fullName().c_str());
|
nlwarning("Failed to find action for event: %s",reaction.getAliasNode()->fullName().c_str());
|
||||||
|
@ -521,14 +519,14 @@ void CStateInstance::processStateEvent(CAIEvent const& stateEvent, CAIState cons
|
||||||
aliasTreeOwner()->getAliasNode()->fullName().c_str(), state->getAliasNode()->fullName().c_str());
|
aliasTreeOwner()->getAliasNode()->fullName().c_str(), state->getAliasNode()->fullName().c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!foundReaction)
|
if (!foundReaction)
|
||||||
{
|
{
|
||||||
getDebugHistory()->addHistory("STATE: '%s' EVENT: '%s' NO REACTION", state->getAliasNode()->fullName().c_str(),
|
getDebugHistory()->addHistory("STATE: '%s' EVENT: '%s' NO REACTION", state->getAliasNode()->fullName().c_str(),
|
||||||
stateEvent.getName().c_str());
|
stateEvent.getName().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
@ -540,38 +538,38 @@ void CStateInstance::setNextState(CAIState* state)
|
||||||
_NextState = state;
|
_NextState = state;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure the state is positional (not punctual)
|
// make sure the state is positional (not punctual)
|
||||||
if (!state->isPositional())
|
if (!state->isPositional())
|
||||||
{
|
{
|
||||||
nlwarning("setNextState(): State should not be punctual '%s'%s - setting state to std::numeric_limits<uint32>::max()",
|
nlwarning("setNextState(): State should not be punctual '%s'%s - setting state to std::numeric_limits<uint32>::max()",
|
||||||
state->getAliasNode()->fullName().c_str(),
|
state->getAliasNode()->fullName().c_str(),
|
||||||
state->getAliasString().c_str());
|
state->getAliasString().c_str());
|
||||||
_NextState = NULL;
|
_NextState = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the next state
|
// set the next state
|
||||||
_NextState = state;
|
_NextState = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void CStateInstance::setNextPunctualState(CAIState* state)
|
void CStateInstance::setNextPunctualState(CAIState* state)
|
||||||
{
|
{
|
||||||
// we're allowed to set state to 'no state'
|
// we're allowed to set state to 'no state'
|
||||||
if (!state)
|
if (!state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// make sure the state is not positional (ie punctual)
|
// make sure the state is not positional (ie punctual)
|
||||||
if (state->isPositional())
|
if (state->isPositional())
|
||||||
{
|
{
|
||||||
nlwarning("CStateInstance::setNextPunctualState(): State should be punctual '%s'%s - setting state to std::numeric_limits<uint32>::max()",
|
nlwarning("CStateInstance::setNextPunctualState(): State should be punctual '%s'%s - setting state to std::numeric_limits<uint32>::max()",
|
||||||
state->getAliasNode()->fullName().c_str(),
|
state->getAliasNode()->fullName().c_str(),
|
||||||
state->getAliasString().c_str());
|
state->getAliasString().c_str());
|
||||||
state = NULL;
|
state = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the next state
|
// set the next state
|
||||||
_NextPunctualState = state;
|
_NextPunctualState = state;
|
||||||
}
|
}
|
||||||
|
@ -626,7 +624,7 @@ void CPersistentStateInstance::removeChildStateInstance(CPersistentStateInstance
|
||||||
TChildList::iterator it = std::find(_PSIChilds.begin(), _PSIChilds.end(), NLMISC::CDbgPtr<CPersistentStateInstance>(parentStateInstance));
|
TChildList::iterator it = std::find(_PSIChilds.begin(), _PSIChilds.end(), NLMISC::CDbgPtr<CPersistentStateInstance>(parentStateInstance));
|
||||||
#if !FINAL_VERSION
|
#if !FINAL_VERSION
|
||||||
nlassert(it!=_PSIChilds.end());
|
nlassert(it!=_PSIChilds.end());
|
||||||
#endif
|
#endif
|
||||||
if (it!=_PSIChilds.end())
|
if (it!=_PSIChilds.end())
|
||||||
_PSIChilds.erase(it);
|
_PSIChilds.erase(it);
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue