merging to lirria

This commit is contained in:
Yann 2016-02-09 21:32:08 +01:00
commit 3fa275e64d
18 changed files with 121 additions and 137 deletions

View file

@ -876,12 +876,8 @@ class CAHGuildSheetOpen : public IActionHandler
rt.updateRyzomClock(rGuildMembers[i].EnterDate);
ucstring str = toString("%03d", (sint)RT.getRyzomWeek()) + " ";
str += CI18N::get("ui"+WEEKDAY::toString( (WEEKDAY::EWeekDay)RT.getRyzomDayOfWeek() )) + " - ";
ucstring year = CI18N::get("uiYear");
if (year.length() == 0) {
str += toString("%04d", RT.getRyzomYear()) + " - ";
} else {
str += year + " - ";
}
ucstring year = RT.getRyzomYearStr();
str += year + " - "
str += CI18N::get("uiEon");
pViewEnterDate->setText(str);
}

View file

@ -1487,12 +1487,8 @@ void CInterfaceManager::updateFrameEvents()
str += toString("%02d", (sint)RT.getRyzomTime()) + CI18N::get("uiMissionTimerHour") + " - ";
str += toString("%d", (sint)RT.getRyzomWeek()) + " ";
str += CI18N::get("ui"+WEEKDAY::toString( (WEEKDAY::EWeekDay)RT.getRyzomDayOfWeek() )) + " - ";
ucstring year = CI18N::get("uiYear");
if (year.length() == 0) {
str += toString("%04d", RT.getRyzomYear()) + " - ";
} else {
str += year + " - ";
}
ucstring year = RT.getRyzomYearStr();
str += year + " - ";
str += CI18N::get("uiEon");
pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:time"));

View file

@ -20,6 +20,7 @@
#define RY_TIME_AND_SEASON_H
#include "nel/misc/types_nl.h"
#include "nel/misc/i18n.h"
const uint RYZOM_HOURS_IN_TICKS = 9000;
const uint RYZOM_DAY_IN_HOUR = 24;
@ -130,20 +131,20 @@ public:
CRyzomTime()
{
_RyzomDay = 0;
_RyzomTime = 0;
_RyzomTime = 0.f;
_LocalTime = 0.0;
_TickOffset = 0;
}
// Update ryzom clock when tick occurs, local time must be given if localUpdateRyzomClock() and getLocalRyzomTime() is used
void updateRyzomClock( uint32 gameCyle, double localTime = 0 )
{
float time = ( gameCyle + _TickOffset ) / float(RYZOM_HOURS_IN_TICKS);
_RyzomDay = (uint32) ( time / RYZOM_DAY_IN_HOUR ) - RYZOM_START_SPRING;
_RyzomTime = (float) fmod( time, RYZOM_DAY_IN_HOUR );
float hours = ( gameCyle + _TickOffset ) / float(RYZOM_HOURS_IN_TICKS);
_RyzomDay = ( (uint)hours / RYZOM_DAY_IN_HOUR ) - RYZOM_START_SPRING;
_RyzomTime = (float) fmod( hours, (float)RYZOM_DAY_IN_HOUR );
_LocalTime = localTime;
}
// get ryzom time (synchronized with server)
inline float getRyzomTime() const { return _RyzomTime; }
@ -153,6 +154,9 @@ public:
// get ryzom Year
inline uint32 getRyzomYear() const { return _RyzomDay / RYZOM_YEAR_IN_DAY + RYZOM_START_YEAR; }
// get ryzom Year as string
inline ucstring getRyzomYearStr() const { return NLMISC::CI18N::get("uiYear").length()==0?NLMISC::toString(_RyzomDay / RYZOM_YEAR_IN_DAY + RYZOM_START_YEAR):NLMISC::CI18N::get("uiYear"); }
// get ryzom week
inline uint32 getRyzomWeek() const { return (_RyzomDay % RYZOM_YEAR_IN_DAY) / RYZOM_WEEK_IN_DAY; }

View file

@ -39,7 +39,7 @@
#include "fx_entity_manager.h"
#include "ai_script_data_manager.h"
#include "commands.h"
#include "nel/misc/i18n.h"
#include "ais_user_models.h"
extern bool GrpHistoryRecordLog;
@ -1686,7 +1686,9 @@ NLMISC_COMMAND(getDatasetId,"get datasetid of bots with name matchiong the given
FOREACH(itBot, vector<CBot*>, bots)
{
CBot* bot = *itBot;
DatasetIds += bot->getSpawnObj()->dataSetRow().toString()+"|";
CSpawnBot* spawnBot = bot->getSpawnObj();
if (spawnBot!=NULL)
DatasetIds += spawnBot->dataSetRow().toString()+"|";
}
}
@ -3065,19 +3067,13 @@ static void displayTime(const CRyzomTime &rt, NLMISC::CLog &log)
log.displayNL(result.c_str());
std::string week = toString("%03d", rt.getRyzomWeek());
std::string dayName = CI18N::get("ui"+WEEKDAY::toString((WEEKDAY::EWeekDay) rt.getRyzomDayOfWeek())).toUtf8();
std::string year;
std::string year = rt.getRyzomYearStr().toUtf8();
std::string eon = CI18N::get("uiEon").toUtf8();
ucstring yearBool = CI18N::get("uiYear");
if (yearBool.length() == 0) {
year = toString("%04d", rt.getRyzomYear());
} else {
year = yearBool.toUtf8();
}
result = NLMISC::toString("week:day:year:eon = %s:%s:%s:%s",
week,
dayName,
year,
eon);
week.c_str(),
dayName.c_str(),
year.c_str(),
eon.c_str());
log.displayNL(result.c_str());
log.displayNL("day of year = %d/%d", (int) (rt.getRyzomDayOfYear() + 1), (int) RYZOM_YEAR_IN_DAY);
log.displayNL("season = %d/4 (%s)", (int) rt.getRyzomSeason() + 1, EGSPD::CSeason::toString(rt.getRyzomSeason()).c_str());

View file

@ -3366,19 +3366,13 @@ void getRyzomDateStr__s(CStateInstance* entity, CScriptStack& stack)
std::string week = toString("%03d", rt.getRyzomWeek());
std::string dayName = CI18N::get("ui"+WEEKDAY::toString((WEEKDAY::EWeekDay) rt.getRyzomDayOfWeek())).toUtf8();
std::string year;
std::string year = toString(rt.getRyzomYearStr());
std::string eon = CI18N::get("uiEon").toUtf8();
ucstring yearBool = CI18N::get("uiYear");
if (yearBool.length() == 0) {
year = toString("%04d", rt.getRyzomYear());
} else {
year = yearBool.toUtf8();
}
result += NLMISC::toString(" / %s %s - %s - %s",
week,
dayName,
year,
eon);
week.c_str(),
dayName.c_str(),
year.c_str(),
eon.c_str());
stack.push( result );
}

View file

@ -44,14 +44,14 @@ class CStateInstance
public:
inline
CStateInstance(CAIState* startState);
void init(CAIState* startState);
virtual CPersistentStateInstance* getPersistentStateInstance();
//////////////////////////////////////////////////////////////////////////
// State Persistent.
struct CStatePersistentObjEntry
{
CStatePersistentObjEntry();
@ -61,78 +61,78 @@ public:
NLMISC::CSmartPtr<NLMISC::CVirtualRefCount> _Obj;
};
typedef std::vector<CStatePersistentObjEntry> TStatePersistentObjList;
TStatePersistentObjList _StatePersistentObjList;
// 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 removeExceptForState(CAIState const* keyState);
/** Try to obtain a group interface from the CStateInstance. Can return NULL if the
* CStateInstance if not implemeted by a group related objet.
*/
// Bad, Bad, Bad ..
virtual CGroup* getGroup() = 0;
//////////////////////////////////////////////////////////////////////////
CAITimerExtended& timerStateTimeout() { return _StateTimeout; }
CAITimerExtended& timerPunctTimeout() { return _PunctualStateTimeout; }
CAITimerExtended& timerStateTimeout() { return _StateTimeout; }
CAITimerExtended& timerPunctTimeout() { return _PunctualStateTimeout; }
CAITimerExtended& timerUser(uint idx);
CAIState* getCAIState();
virtual CAliasTreeOwner* aliasTreeOwner() = 0;
virtual void stateChange(CAIState const* oldState, CAIState const* newState) = 0;
CAIState* getState() const { return _state; }
void setNextState(CAIState*);
CAIState* getPunctualState() const { return _PunctualState; }
CAIState* getNextPunctualState() const { return _NextPunctualState; }
void setNextPunctualState(CAIState* state);
void cancelPunctualState() { _CancelPunctualState = true; }
std::string buidStateInstanceDebugString() const;
void dumpVarsAndFunctions(CStringWriter& sw) const;
virtual CDebugHistory* getDebugHistory () = 0;
CAIState const* getActiveState() const;
sint32 getUserTimer(uint timerId);
void setUserTimer(uint timerId, sint32 time);
void logicVarsToString(std::string& str) const;
float getNelVar(std::string const& varId);
void setNelVar(std::string const& varId, float value);
void delNelVar(std::string const& varId);
std::string getStrNelVar(std::string const& varId);
void setStrNelVar(std::string const& varId, std::string const& value);
void delStrNelVar(std::string const& varId);
static void setGlobalNelVar(std::string const& varId, float value);
static void setGlobalNelVar(std::string const& varId, std::string value);
CAITimerExtended const& userTimer (uint32 index) const;
bool advanceUserTimer(uint32 nbTicks);
void processStateEvent(CAIEvent const& stateEvent, CAIState const* state = NULL);
// callerStateInstance could be NULL;
void interpretCode(AIVM::IScriptContext* callerStateInstance, AIVM::CByteCodeEntry const& codeScriptEntry);
void interpretCode(AIVM::IScriptContext* callerStateInstance, NLMISC::CSmartPtr<AIVM::CByteCode const> const& codeScript);
/// @name IScriptContext implementation
//@{
virtual std::string getContextName();
virtual void interpretCodeOnChildren(AIVM::CByteCodeEntry const& codeScriptEntry);
float getLogicVar(NLMISC::TStringId varId);
void setLogicVar(NLMISC::TStringId varId, float value);
std::string getStrLogicVar(NLMISC::TStringId varId);
@ -140,19 +140,19 @@ public:
AIVM::IScriptContext* getCtxLogicVar(NLMISC::TStringId varId);
void setCtxLogicVar(NLMISC::TStringId varId, AIVM::IScriptContext* value);
void setFirstBotSpawned();
virtual AIVM::IScriptContext* findContext(NLMISC::TStringId const strId);
virtual void setScriptCallBack(NLMISC::TStringId const& eventName, AIVM::CByteCodeEntry const& codeScriptEntry);
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 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 unblockUserEvent(uint32 eventId);
bool isUserEventBlocked(uint32 eventId) const;
//@}
protected:
/// Logic variables
typedef std::map<NLMISC::TStringId, float> TLogicVarList;
@ -162,38 +162,38 @@ protected:
TLogicVarList _LogicVar;
TStrLogicVarList _StrLogicVar;
TCtxLogicVarList _CtxLogicVar;
// Nel variables
typedef std::map<std::string, NLMISC::CVariable<float>*> TNelVarList;
typedef std::map<std::string, NLMISC::CVariable<std::string>*> TStrNelVarList;
TNelVarList _NelVar;
TStrNelVarList _StrNelVar;
// Callbacks (?)
typedef std::map<NLMISC::TStringId, AIVM::CByteCodeEntry> TCallBackList;
TCallBackList _CallBacks;
/// Flag for variable modification
bool _LogicVarChanged;
bool _LogicVarChangedList[4];
//TLogicVarIndex _VarIndex;
// update logic timers ---------------------------------------------
/// 4 timers available for user logic
CAITimerExtended _UserTimer[4];
CAITimerExtended _UserTimer[4];
/// timer for timing positional states
CAITimerExtended _StateTimeout;
/// current state (index into manager's state vector)
CAITimerExtended _StateTimeout;
/// current state (index into manager's state vector)
CAIState* _state;
/// variable set to request a state change (std::numeric_limits<uint32>::max() otherwise)
CAIState* _NextState;
/// timer for timing punctual states
CAITimerExtended _PunctualStateTimeout;
CAIState* _PunctualState;
CAIState* _NextPunctualState;
/// Flag for leaving the punctual state, returning to normal behavior
bool _CancelPunctualState;
bool _FirstBotSpawned;
@ -213,35 +213,35 @@ class CPersistentStateInstance
public:
CPersistentStateInstance(CStateMachine& reactionContainer);
virtual ~CPersistentStateInstance();
typedef std::vector<NLMISC::CDbgPtr<CPersistentStateInstance> > TChildList;
void setParentStateInstance(CPersistentStateInstance* parentStateInstance);
CPersistentStateInstance* getParentStateInstance() const { return _ParentStateInstance; }
void addChildStateInstance(CPersistentStateInstance* parentStateInstance);
void removeChildStateInstance(CPersistentStateInstance* parentStateInstance);
TChildList& childs() { return _PSIChilds; }
TChildList _PSIChilds;
// Interface to state status variables -----------------------------
CAIState* getStartState() { return _StartState; }
void setStartState(CAIState* state);
CStateMachine& getEventContainer() { return _Container; }
void updateStateInstance();
//////////////////////////////////////////////////////////////////////////
// CStateInstance
CPersistentStateInstance* getPersistentStateInstance() { return this; }
//////////////////////////////////////////////////////////////////////////
private:
/// id of the state to use at startup
NLMISC::CDbgPtr<CAIState> _StartState;
@ -330,9 +330,9 @@ void CStateInstance::setLogicVar(NLMISC::TStringId varId, float value)
//_VarIndex[varId]
_LogicVarChangedList[static_cast<uint32>(index)] = true;
}
}
}
inline
@ -354,7 +354,7 @@ void CStateInstance::setStrLogicVar(NLMISC::TStringId varId, std::string const&
//_VarIndex[varId]
_LogicVarChangedList[static_cast<uint32>(index)] = true;
}
}
//_LogicVarChangedList[_VarIndex[varId]] = true;
}
@ -376,17 +376,16 @@ inline
float CStateInstance::getNelVar(std::string const& 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;
}
_NelVar[varId] = new NLMISC::CVariable<float>("StateInstance", varId.c_str(), "", 0.f);
_NelVar[varId]->get();
nlwarning("Nel variable \"%s\" exists outside of this state instance", varId.c_str());
return 0.f;
}
return it->second->get();
_NelVar[varId] = new NLMISC::CVariable<float>("StateInstance", varId.c_str(), "", 0.f);
return _NelVar[varId]->get();
}
inline
@ -424,17 +423,16 @@ inline
std::string CStateInstance::getStrNelVar(std::string const& 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 "";
}
_StrNelVar[varId] = new NLMISC::CVariable<std::string>("StateInstanceVar", varId.c_str(), "", std::string());
_NelVar[varId]->get();
nlwarning("Nel variable \"%s\" exists outside of this state instance", varId.c_str());
return "";
}
return it->second->get();
_StrNelVar[varId] = new NLMISC::CVariable<std::string>("StateInstanceStrVar", varId.c_str(), "", std::string());
return _StrNelVar[varId]->get();
}
inline
@ -483,7 +481,7 @@ bool CStateInstance::advanceUserTimer(uint32 nbTicks)
setUserTimer(k, (t>nbTicks)?(t-nbTicks):0);
}
return true;
}
}
inline
void CStateInstance::processStateEvent(CAIEvent const& stateEvent, CAIState const* state)
@ -496,7 +494,7 @@ void CStateInstance::processStateEvent(CAIEvent const& stateEvent, CAIState cons
if (!state)
return;
}
bool foundReaction=false;
// nlassert(_mgr);
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];
if (!reaction.testCompatibility(this,state))
continue;
getDebugHistory()->addHistory("STATE: '%s' EVENT: '%s' REACTION: '%s'", state->getAliasNode()->fullName().c_str(),
stateEvent.getName().c_str(), reaction.getAliasNode()->fullName().c_str());
foundReaction=true;
if (!reaction.getAction())
{
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());
continue;
}
}
if (!foundReaction)
{
getDebugHistory()->addHistory("STATE: '%s' EVENT: '%s' NO REACTION", state->getAliasNode()->fullName().c_str(),
stateEvent.getName().c_str());
}
}
inline
@ -540,38 +538,38 @@ void CStateInstance::setNextState(CAIState* state)
_NextState = state;
return;
}
// 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()",
state->getAliasNode()->fullName().c_str(),
state->getAliasString().c_str());
_NextState = NULL;
return;
}
// set the next state
_NextState = state;
}
inline
void CStateInstance::setNextPunctualState(CAIState* state)
{
{
// we're allowed to set state to 'no state'
if (!state)
return;
// 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()",
state->getAliasNode()->fullName().c_str(),
state->getAliasString().c_str());
state = NULL;
return;
}
}
// set the next state
_NextPunctualState = state;
}
@ -626,7 +624,7 @@ void CPersistentStateInstance::removeChildStateInstance(CPersistentStateInstance
TChildList::iterator it = std::find(_PSIChilds.begin(), _PSIChilds.end(), NLMISC::CDbgPtr<CPersistentStateInstance>(parentStateInstance));
#if !FINAL_VERSION
nlassert(it!=_PSIChilds.end());
#endif
#endif
if (it!=_PSIChilds.end())
_PSIChilds.erase(it);
}