Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Testicular Slingshot
Alchemy Viewer
Commits
cf590645
Commit
cf590645
authored
Feb 19, 2020
by
Rye Mutt
🍞
Browse files
Fix experience log depending on brain dead sorted LLSD map behavior
parent
c6d2c831
Changes
3
Hide whitespace changes
Inline
Side-by-side
indra/newview/llexperiencelog.cpp
View file @
cf590645
...
...
@@ -90,7 +90,8 @@ void LLExperienceLog::handleExperienceMessage(LLSD& message)
std
::
string
day
=
daybuf
;
if
(
!
mEvents
.
has
(
day
))
auto
iter
=
mEvents
.
find
(
day
);
if
(
iter
==
mEvents
.
end
())
{
mEvents
[
day
]
=
LLSD
::
emptyArray
();
}
...
...
@@ -178,7 +179,12 @@ void LLExperienceLog::saveEvents()
{
eraseExpired
();
std
::
string
filename
=
getFilename
();
LLSD
settings
=
LLSD
::
emptyMap
().
with
(
"Events"
,
mEvents
);
LLSD
temp_events
;
for
(
const
auto
&
event_pair
:
mEvents
)
{
temp_events
[
event_pair
.
first
]
=
event_pair
.
second
;
}
LLSD
settings
=
LLSD
::
emptyMap
().
with
(
"Events"
,
temp_events
);
settings
[
"MaxDays"
]
=
(
int
)
mMaxDays
;
settings
[
"Notify"
]
=
mNotifyNewEvent
;
...
...
@@ -212,7 +218,11 @@ void LLExperienceLog::loadEvents()
mEvents
.
clear
();
if
(
mMaxDays
>
0
&&
settings
.
has
(
"Events"
))
{
mEvents
=
settings
[
"Events"
];
const
auto
&
events
=
settings
[
"Events"
];
for
(
auto
iter
=
events
.
beginMap
(),
end
=
events
.
endMap
();
iter
!=
end
;
++
iter
)
{
mEvents
[
iter
->
first
]
=
iter
->
second
;
}
}
eraseExpired
();
...
...
@@ -225,21 +235,14 @@ LLExperienceLog::~LLExperienceLog()
void
LLExperienceLog
::
eraseExpired
()
{
std
::
vector
<
std
::
string
>
expired
;
std
::
for_each
(
mEvents
.
beginMap
(),
mEvents
.
endMap
(),
[
&
](
const
auto
&
event_pair
)
for
(
auto
it
=
mEvents
.
begin
(),
end
=
mEvents
.
end
();
it
!=
end
;)
{
const
std
::
string
&
date
=
event_pair
.
first
;
if
(
isExpired
(
date
))
auto
event_it
=
it
++
;
if
(
isExpired
(
event_it
->
first
))
{
expired
.
push_back
(
date
);
mEvents
.
erase
(
event_it
);
}
});
for
(
const
auto
&
date
:
expired
)
{
mEvents
.
erase
(
date
);
}
}
}
bool
LLExperienceLog
::
isExpired
(
const
std
::
string
&
date
)
...
...
@@ -256,11 +259,6 @@ bool LLExperienceLog::isExpired(const std::string& date)
return
event_date
.
secondsSinceEpoch
()
<=
(
LLDate
::
now
().
secondsSinceEpoch
()
-
F64
(
getMaxDays
()
*
86400U
));
}
const
LLSD
&
LLExperienceLog
::
getEvents
()
const
{
return
mEvents
;
}
void
LLExperienceLog
::
clear
()
{
mEvents
.
clear
();
...
...
indra/newview/llexperiencelog.h
View file @
cf590645
...
...
@@ -50,7 +50,7 @@ public:
U32
getPageSize
()
const
{
return
mPageSize
;
}
void
setPageSize
(
U32
val
)
{
mPageSize
=
val
;
}
const
LLSD
&
getEvents
()
const
;
const
auto
&
getEvents
()
const
{
return
mEvents
;
}
;
void
clear
();
virtual
~
LLExperienceLog
();
...
...
@@ -67,7 +67,7 @@ protected:
void
saveEvents
();
void
eraseExpired
();
LLSD
mEvents
;
std
::
map
<
std
::
string
,
LLSD
>
mEvents
;
callback_signal_t
mSignals
;
callback_connection_t
mNotifyConnection
;
U32
mMaxDays
;
...
...
indra/newview/llpanelexperiencelog.cpp
View file @
cf590645
...
...
@@ -94,9 +94,9 @@ void LLPanelExperienceLog::refresh()
{
S32
selected
=
mEventList
->
getFirstSelectedIndex
();
mEventList
->
deleteAllItems
();
const
LLSD
events
=
LLExperienceLog
::
instance
().
getEvents
();
const
auto
&
events
=
LLExperienceLog
::
instance
().
getEvents
();
if
(
events
.
size
()
==
0
)
if
(
events
.
empty
()
)
{
mEventList
->
setCommentText
(
getString
(
"no_events"
));
return
;
...
...
@@ -112,62 +112,58 @@ void LLPanelExperienceLog::refresh()
U32
items
=
0
;
bool
moreItems
=
false
;
if
(
!
events
.
emptyMap
()
)
for
(
auto
day
=
events
.
crbegin
(),
end_day
=
events
.
crend
();
day
!=
end_day
;
++
day
)
{
LLSD
::
map_const_iterator
da
y
=
events
.
endMap
()
;
do
const
std
::
string
da
te
=
day
->
first
;
if
(
LLExperienceLog
::
instance
().
isExpired
(
date
))
{
--
day
;
const
std
::
string
&
date
=
day
->
first
;
if
(
LLExperienceLog
::
instance
().
isExpired
(
date
))
{
continue
;
}
const
LLSD
&
dayArray
=
day
->
second
;
int
size
=
dayArray
.
size
();
if
(
itemsToSkip
>
size
)
{
itemsToSkip
-=
size
;
continue
;
}
if
(
items
>=
mPageSize
&&
size
>
0
)
continue
;
}
const
LLSD
&
dayArray
=
day
->
second
;
int
size
=
dayArray
.
size
();
if
(
itemsToSkip
>
size
)
{
itemsToSkip
-=
size
;
continue
;
}
if
(
items
>=
mPageSize
&&
size
>
0
)
{
moreItems
=
true
;
break
;
}
for
(
int
i
=
dayArray
.
size
()
-
itemsToSkip
-
1
;
i
>=
0
;
i
--
)
{
if
(
items
>=
mPageSize
)
{
moreItems
=
true
;
break
;
}
for
(
int
i
=
dayArray
.
size
()
-
itemsToSkip
-
1
;
i
>=
0
;
i
--
)
const
LLSD
event
=
dayArray
[
i
];
LLUUID
id
=
event
[
LLExperienceCache
::
EXPERIENCE_ID
].
asUUID
();
const
LLSD
&
experience
=
LLExperienceCache
::
instance
().
get
(
id
);
if
(
experience
.
isUndefined
())
{
waiting
=
true
;
waiting_id
=
id
;
}
if
(
!
waiting
)
{
if
(
items
>=
mPageSize
)
{
moreItems
=
true
;
break
;
}
const
LLSD
event
=
dayArray
[
i
];
LLUUID
id
=
event
[
LLExperienceCache
::
EXPERIENCE_ID
].
asUUID
();
const
LLSD
&
experience
=
LLExperienceCache
::
instance
().
get
(
id
);
if
(
experience
.
isUndefined
()){
waiting
=
true
;
waiting_id
=
id
;
}
if
(
!
waiting
)
{
item
[
"id"
]
=
event
;
LLSD
&
columns
=
item
[
"columns"
];
columns
[
0
][
"column"
]
=
"time"
;
columns
[
0
][
"value"
]
=
day
->
first
+
event
[
"Time"
].
asString
();
columns
[
1
][
"column"
]
=
"event"
;
columns
[
1
][
"value"
]
=
LLExperienceLog
::
getPermissionString
(
event
,
"ExperiencePermissionShort"
);
columns
[
2
][
"column"
]
=
"experience_name"
;
columns
[
2
][
"value"
]
=
experience
[
LLExperienceCache
::
NAME
].
asString
();
columns
[
3
][
"column"
]
=
"object_name"
;
columns
[
3
][
"value"
]
=
event
[
"ObjectName"
].
asString
();
mEventList
->
addElement
(
item
);
}
++
items
;
item
[
"id"
]
=
event
;
LLSD
&
columns
=
item
[
"columns"
];
columns
[
0
][
"column"
]
=
"time"
;
columns
[
0
][
"value"
]
=
day
->
first
+
event
[
"Time"
].
asString
();
columns
[
1
][
"column"
]
=
"event"
;
columns
[
1
][
"value"
]
=
LLExperienceLog
::
getPermissionString
(
event
,
"ExperiencePermissionShort"
);
columns
[
2
][
"column"
]
=
"experience_name"
;
columns
[
2
][
"value"
]
=
experience
[
LLExperienceCache
::
NAME
].
asString
();
columns
[
3
][
"column"
]
=
"object_name"
;
columns
[
3
][
"value"
]
=
event
[
"ObjectName"
].
asString
();
mEventList
->
addElement
(
item
);
}
}
while
(
day
!=
events
.
beginMap
());
++
items
;
}
}
if
(
waiting
)
{
mEventList
->
deleteAllItems
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment