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); rt.updateRyzomClock(rGuildMembers[i].EnterDate);
ucstring str = toString("%03d", (sint)RT.getRyzomWeek()) + " "; ucstring str = toString("%03d", (sint)RT.getRyzomWeek()) + " ";
str += CI18N::get("ui"+WEEKDAY::toString( (WEEKDAY::EWeekDay)RT.getRyzomDayOfWeek() )) + " - "; str += CI18N::get("ui"+WEEKDAY::toString( (WEEKDAY::EWeekDay)RT.getRyzomDayOfWeek() )) + " - ";
ucstring year = CI18N::get("uiYear"); ucstring year = RT.getRyzomYearStr();
if (year.length() == 0) { str += year + " - "
str += toString("%04d", RT.getRyzomYear()) + " - ";
} else {
str += year + " - ";
}
str += CI18N::get("uiEon"); str += CI18N::get("uiEon");
pViewEnterDate->setText(str); pViewEnterDate->setText(str);
} }

View file

@ -1487,12 +1487,8 @@ void CInterfaceManager::updateFrameEvents()
str += toString("%02d", (sint)RT.getRyzomTime()) + CI18N::get("uiMissionTimerHour") + " - "; str += toString("%02d", (sint)RT.getRyzomTime()) + CI18N::get("uiMissionTimerHour") + " - ";
str += toString("%d", (sint)RT.getRyzomWeek()) + " "; str += toString("%d", (sint)RT.getRyzomWeek()) + " ";
str += CI18N::get("ui"+WEEKDAY::toString( (WEEKDAY::EWeekDay)RT.getRyzomDayOfWeek() )) + " - "; str += CI18N::get("ui"+WEEKDAY::toString( (WEEKDAY::EWeekDay)RT.getRyzomDayOfWeek() )) + " - ";
ucstring year = CI18N::get("uiYear"); ucstring year = RT.getRyzomYearStr();
if (year.length() == 0) { str += year + " - ";
str += toString("%04d", RT.getRyzomYear()) + " - ";
} else {
str += year + " - ";
}
str += CI18N::get("uiEon"); str += CI18N::get("uiEon");
pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:time")); 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 #define RY_TIME_AND_SEASON_H
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "nel/misc/i18n.h"
const uint RYZOM_HOURS_IN_TICKS = 9000; const uint RYZOM_HOURS_IN_TICKS = 9000;
const uint RYZOM_DAY_IN_HOUR = 24; const uint RYZOM_DAY_IN_HOUR = 24;
@ -130,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; }
@ -153,6 +154,9 @@ public:
// get ryzom Year // get ryzom Year
inline uint32 getRyzomYear() const { return _RyzomDay / RYZOM_YEAR_IN_DAY + RYZOM_START_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 // get ryzom week
inline uint32 getRyzomWeek() const { return (_RyzomDay % RYZOM_YEAR_IN_DAY) / RYZOM_WEEK_IN_DAY; } 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 "fx_entity_manager.h"
#include "ai_script_data_manager.h" #include "ai_script_data_manager.h"
#include "commands.h" #include "commands.h"
#include "nel/misc/i18n.h"
#include "ais_user_models.h" #include "ais_user_models.h"
extern bool GrpHistoryRecordLog; extern bool GrpHistoryRecordLog;
@ -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()+"|";
} }
} }
@ -3065,19 +3067,13 @@ static void displayTime(const CRyzomTime &rt, NLMISC::CLog &log)
log.displayNL(result.c_str()); log.displayNL(result.c_str());
std::string week = toString("%03d", rt.getRyzomWeek()); std::string week = toString("%03d", rt.getRyzomWeek());
std::string dayName = CI18N::get("ui"+WEEKDAY::toString((WEEKDAY::EWeekDay) rt.getRyzomDayOfWeek())).toUtf8(); 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(); 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", result = NLMISC::toString("week:day:year:eon = %s:%s:%s:%s",
week, week.c_str(),
dayName, dayName.c_str(),
year, year.c_str(),
eon); eon.c_str());
log.displayNL(result.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("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()); 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 week = toString("%03d", rt.getRyzomWeek());
std::string dayName = CI18N::get("ui"+WEEKDAY::toString((WEEKDAY::EWeekDay) rt.getRyzomDayOfWeek())).toUtf8(); 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(); 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", result += NLMISC::toString(" / %s %s - %s - %s",
week, week.c_str(),
dayName, dayName.c_str(),
year, year.c_str(),
eon); eon.c_str());
stack.push( result ); stack.push( result );
} }

View file

@ -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