Refactor code to make it easier to do 'nopredict' inside of any function without having a dependency on world model.
This commit is contained in:
@@ -226,6 +226,13 @@ int LuaTypeTagValue(lua_State *L) { return 0; }
|
||||
#define LUA_TT_GLOBALDB 22
|
||||
#define LUA_TT_CLASS 23
|
||||
|
||||
// World types enum.
|
||||
|
||||
enum WorldType {
|
||||
WORLD_TYPE_MASTER = 1,
|
||||
WORLD_TYPE_PREDICTIVE = 2,
|
||||
};
|
||||
|
||||
// We use lightuserdata to store 'tokens': short
|
||||
// strings of 8 characters or less. These tokens
|
||||
// are useful as unique markers. The 8 characters
|
||||
@@ -517,6 +524,17 @@ public:
|
||||
bool getvisited(LuaSlot tab) const;
|
||||
void setvisited(LuaSlot tab, bool visited) const;
|
||||
|
||||
// Return the world type (from the registry).
|
||||
WorldType world_type() const;
|
||||
|
||||
// World types that are authoritative.
|
||||
static bool is_authoritative(WorldType t) { return (t == WORLD_TYPE_MASTER); }
|
||||
bool is_authoritative() { return is_authoritative(world_type()); }
|
||||
|
||||
// Stop execution of this thread if in a nonauth model,
|
||||
// and if the thread is not a probe.
|
||||
void guard_nopredict(const char *fn);
|
||||
|
||||
// Return true if the int64 value can be stored as a lua number.
|
||||
static bool int64_storable(int64_t v) { return (v <= MAXINT) && (v >= -MAXINT); }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user