[Radar] Rework mAge code

This commit is contained in:
Lirusaito
2019-03-12 14:16:38 -04:00
parent 68fd65b55a
commit e0ec2bd886

View File

@@ -159,38 +159,40 @@ LLAvatarListEntry::~LLAvatarListEntry()
// virtual // virtual
void LLAvatarListEntry::processProperties(void* data, EAvatarProcessorType type) void LLAvatarListEntry::processProperties(void* data, EAvatarProcessorType type)
{ {
if (type == APT_PROPERTIES) // If one wanted more information that gets displayed on profiles to be displayed, here would be the place to do it.
switch(type)
{
case APT_PROPERTIES:
if (mAge == -1)
{ {
LLAvatarPropertiesProcessor& inst(LLAvatarPropertiesProcessor::instance()); LLAvatarPropertiesProcessor& inst(LLAvatarPropertiesProcessor::instance());
inst.removeObserver(mID, this);
const LLAvatarData* pAvatarData = static_cast<const LLAvatarData*>(data); const LLAvatarData* pAvatarData = static_cast<const LLAvatarData*>(data);
if (pAvatarData && (pAvatarData->avatar_id != LLUUID::null)) if (pAvatarData && (pAvatarData->avatar_id.notNull()))
{ {
using namespace boost::gregorian; using namespace boost::gregorian;
int year, month, day; int year, month, day;
sscanf(pAvatarData->born_on.c_str(),"%d/%d/%d",&month,&day,&year); if (sscanf(pAvatarData->born_on.c_str(),"%d/%d/%d",&month,&day,&year) == 3)
try try
{ {
mAge = (day_clock::local_day() - date(year, month, day)).days(); mAge = (day_clock::local_day() - date(year, month, day)).days();
} }
catch(const std::exception&) catch(const std::out_of_range&) {} // date throws this, so we didn't assign
{
LL_WARNS() << "Failed to extract age from APT_PROPERTIES for " << mID << ", received \"" << pAvatarData->born_on << "\". Requesting properties again." << LL_ENDL; if (mAge >= 0)
inst.addObserver(mID, this);
inst.sendAvatarPropertiesRequest(mID);
return;
}
if (!mStats[STAT_TYPE_AGE] && mAge >= 0) //Only announce age once per entry.
{ {
static const LLCachedControl<U32> sAvatarAgeAlertDays(gSavedSettings, "AvatarAgeAlertDays"); static const LLCachedControl<U32> sAvatarAgeAlertDays(gSavedSettings, "AvatarAgeAlertDays");
if ((U32)mAge < sAvatarAgeAlertDays) if (!mStats[STAT_TYPE_AGE] && (U32)mAge < sAvatarAgeAlertDays) //Only announce age once per entry.
{
chat_avatar_status(mName, mID, STAT_TYPE_AGE, mStats[STAT_TYPE_AGE] = true, (mPosition - gAgent.getPositionGlobal()).magVec()); chat_avatar_status(mName, mID, STAT_TYPE_AGE, mStats[STAT_TYPE_AGE] = true, (mPosition - gAgent.getPositionGlobal()).magVec());
} }
else // Something failed, resend request
{
LL_WARNS() << "Failed to extract age from APT_PROPERTIES for " << mID << ", received \"" << pAvatarData->born_on << "\". Requesting properties again." << LL_ENDL;
inst.sendAvatarPropertiesRequest(mID);
} }
// If one wanted more information that gets displayed on profiles to be displayed, here would be the place to do it.
} }
} }
break;
}
} }
void LLAvatarListEntry::setPosition(const LLVector3d& position, const F32& dist, bool drawn, bool flood) void LLAvatarListEntry::setPosition(const LLVector3d& position, const F32& dist, bool drawn, bool flood)