3333#include " packets/roe_update.h"
3434
3535std::array<RoeCheckHandler, ROE_NONE> RoeHandlers;
36- RoeCache roeutils::RoeBitmaps ;
36+ RoeSystemData roeutils::RoeCache ;
3737
3838namespace roeutils
3939{
@@ -84,8 +84,9 @@ int32 RegisterHandler(lua_State* L)
8484
8585int32 ParseRecords (lua_State* L)
8686{
87- roeutils::RoeBitmaps.ImplementedRecords .reset ();
88- roeutils::RoeBitmaps.RepeatableRecords .reset ();
87+ roeutils::RoeCache.ImplementedRecords .reset ();
88+ roeutils::RoeCache.RepeatableRecords .reset ();
89+ roeutils::RoeCache.NotifyThresholds .fill (1 );
8990
9091 if (lua_isnil (L, -1 ) || !lua_istable (L, -1 ))
9192 return 0 ;
@@ -96,7 +97,13 @@ int32 ParseRecords(lua_State* L)
9697 {
9798 // Set Implemented bit.
9899 uint32 recordID = static_cast <uint32>(lua_tointeger (L, -2 ));
99- roeutils::RoeBitmaps.ImplementedRecords .set (recordID);
100+ roeutils::RoeCache.ImplementedRecords .set (recordID);
101+
102+ // Set notification threshold
103+ lua_getfield (L, -1 , " notify" );
104+ if (!lua_isnil (L, -1 ))
105+ roeutils::RoeCache.NotifyThresholds [recordID] = static_cast <uint32>((lua_tointeger (L, -1 )));
106+ lua_pop (L, 1 );
100107
101108 // Set repeatability bit
102109 lua_getfield (L, -1 , " reward" );
@@ -105,7 +112,7 @@ int32 ParseRecords(lua_State* L)
105112 lua_getfield (L, -1 , " repeatable" );
106113 if (lua_toboolean (L, -1 ))
107114 {
108- roeutils::RoeBitmaps .RepeatableRecords .set (recordID);
115+ roeutils::RoeCache .RepeatableRecords .set (recordID);
109116 }
110117 lua_pop (L, 1 );
111118 }
@@ -129,6 +136,7 @@ bool event(ROE_EVENT eventID, CCharEntity* PChar, RoeDatagramList payload)
129136 return 0 ;
130137
131138 lua_State* L = luautils::LuaHandle;
139+ uint32 stackTop = lua_gettop (L);
132140 lua_getglobal (L, " tpz" );
133141 lua_getfield (L, -1 , " roe" );
134142
@@ -183,6 +191,7 @@ bool event(ROE_EVENT eventID, CCharEntity* PChar, RoeDatagramList payload)
183191 }
184192 }
185193 }
194+ lua_settop (L, stackTop);
186195 return true ;
187196}
188197
@@ -198,7 +207,7 @@ bool event(ROE_EVENT eventID, CCharEntity* PChar) // shorthand for no-datagram c
198207
199208void SetEminenceRecordCompletion (CCharEntity* PChar, uint16 recordID, bool newStatus)
200209{
201- uint8 page = recordID / 8 ;
210+ uint16 page = recordID / 8 ;
202211 uint8 bit = recordID % 8 ;
203212 if (newStatus)
204213 PChar->m_eminenceLog .complete [page] |= (1 << bit);
@@ -214,32 +223,24 @@ void SetEminenceRecordCompletion(CCharEntity* PChar, uint16 recordID, bool newSt
214223
215224bool GetEminenceRecordCompletion (CCharEntity* PChar, uint16 recordID)
216225{
217- uint8 page = recordID / 8 ;
226+ uint16 page = recordID / 8 ;
218227 uint8 bit = recordID % 8 ;
219228 return PChar->m_eminenceLog .complete [page] & (1 << bit);
220229}
221230
222231bool AddEminenceRecord (CCharEntity* PChar, uint16 recordID)
223232{
224- // TODO: Time limited records aren't implemented yet and can't be accepted normally.
225- // For now we are refusing their IDs outright and protecting its slot from use here.
226- if (recordID > 2047 )
227- {
228- std::string message = " Special Event/Timed Records can not be taken." ;
229- PChar->pushPacket (new CChatMessagePacket (PChar, MESSAGE_NS_SAY, message, " RoE System" ));
230- return false ;
231- }
232233
233234 // We deny taking records which aren't implemented in the Lua
234- if (!roeutils::RoeBitmaps .ImplementedRecords .test (recordID))
235+ if (!roeutils::RoeCache .ImplementedRecords .test (recordID))
235236 {
236237 std::string message = " The record #" + std::to_string (recordID) + " is not implemented at this time." ;
237238 PChar->pushPacket (new CChatMessagePacket (PChar, MESSAGE_NS_SAY, message, " RoE System" ));
238239 return false ;
239240 }
240241
241242 // Prevent packet-injection for re-taking completed records which aren't marked repeatable.
242- if (roeutils::GetEminenceRecordCompletion (PChar, recordID) && !roeutils::RoeBitmaps .RepeatableRecords .test (recordID))
243+ if (roeutils::GetEminenceRecordCompletion (PChar, recordID) && !roeutils::RoeCache .RepeatableRecords .test (recordID))
243244 return false ;
244245
245246 // Per above, this i < 30 is correct.
0 commit comments