|
VoltMod
C++23 framework for CS2 server plugins
|
Per-player-slot value store that never leaks state across occupants. More...
#include <PerSlot.hpp>
Public Member Functions | |
| PerSlot ()=default | |
| PerSlot (SlotEvents &slots) | |
| ~PerSlot () | |
| PerSlot (const PerSlot &)=delete | |
| PerSlot & | operator= (const PerSlot &)=delete |
| T & | operator[] (int slot) |
| const T & | operator[] (int slot) const |
| void | Reset (int slot) |
| void | ResetAll () |
Per-player-slot value store that never leaks state across occupants.
A plain std::array<T, MaxPlayers>. Constructed with the slot-change feed, the entry for a slot is value-reset whenever a player joins or leaves it: PerSlot<State> _state{runtime.Slots};. Default construction is inert, for an owner that resets entries itself.
Takes SlotEvents rather than the runtime so a plugin translation unit that includes only this header still compiles.
Definition at line 24 of file PerSlot.hpp.
|
default |
|
inlineexplicit |
Resets a slot's entry on player connect/disconnect. slots must outlive this object.
Definition at line 29 of file PerSlot.hpp.
References VoltMod::ReadFile(), and VoltMod::PerSlot< T >::Reset().
|
inline |
Unsubscribes directly, so the feed cannot reset entries that are going away.
Definition at line 31 of file PerSlot.hpp.
References VoltMod::Subscription::Reset().
|
delete |
|
inline |
Definition at line 37 of file PerSlot.hpp.
References VoltMod::IsValidSlot(), and VoltMod::ReadFile().
|
inline |
Definition at line 42 of file PerSlot.hpp.
References VoltMod::IsValidSlot(), and VoltMod::ReadFile().
Definition at line 48 of file PerSlot.hpp.
References VoltMod::IsValidSlot(), VoltMod::ReadFile(), and VoltMod::T.
Referenced by VoltMod::PerSlot< T >::PerSlot(), VoltMod::WriteCache::RemoveSlot(), and VoltMod::LanguageTable::Reset().
|
inline |
Assigned one by one rather than through fill, which would copy: the common T here is move-only (a Subscription), and dropping one is exactly what cancels it.
Definition at line 58 of file PerSlot.hpp.
References VoltMod::ReadFile(), and VoltMod::T.
Referenced by VoltMod::WriteCache::Clear().