Minor refactoring.
This commit is contained in:
parent
d7b8098719
commit
9eaca5a27b
12 changed files with 165 additions and 162 deletions
|
|
@ -359,6 +359,10 @@ public:
|
|||
inline float getFloat (float low, float high) {
|
||||
return static_cast <float> (random () * (static_cast <double> (high) - static_cast <double> (low)) / (m_divider - 1) + static_cast <double> (low));
|
||||
}
|
||||
|
||||
template <typename U> inline bool chance (const U max, const U maxChance = 100) {
|
||||
return getInt <U> (0, maxChance) < max;
|
||||
}
|
||||
};
|
||||
|
||||
class SimpleColor final : private NonCopyable {
|
||||
|
|
@ -590,11 +594,13 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class Library {
|
||||
class Library final : private NonCopyable {
|
||||
private:
|
||||
void *m_ptr;
|
||||
|
||||
public:
|
||||
explicit Library (void) : m_ptr (nullptr) { }
|
||||
|
||||
Library (const char *filename) : m_ptr (nullptr) {
|
||||
if (!filename) {
|
||||
return;
|
||||
|
|
@ -603,6 +609,20 @@ public:
|
|||
}
|
||||
|
||||
virtual ~Library (void) {
|
||||
unload ();
|
||||
}
|
||||
|
||||
public:
|
||||
inline void *load (const char *filename) noexcept {
|
||||
#ifdef PLATFORM_WIN32
|
||||
m_ptr = LoadLibrary (filename);
|
||||
#else
|
||||
m_ptr = dlopen (filename, RTLD_NOW);
|
||||
#endif
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
inline void unload (void) noexcept {
|
||||
if (!isValid ()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -613,16 +633,6 @@ public:
|
|||
#endif
|
||||
}
|
||||
|
||||
public:
|
||||
inline void *load (const char *filename) {
|
||||
#ifdef PLATFORM_WIN32
|
||||
m_ptr = LoadLibrary (filename);
|
||||
#else
|
||||
m_ptr = dlopen (filename, RTLD_NOW);
|
||||
#endif
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
template <typename R> R resolve (const char *function) {
|
||||
if (!isValid ()) {
|
||||
return nullptr;
|
||||
|
|
@ -650,7 +660,7 @@ public:
|
|||
B second;
|
||||
|
||||
public:
|
||||
Pair (const A &a, const B &b) : first (a), second (b) {
|
||||
Pair (const A &a, const B &b) : first (cr::move (a)), second (cr::move (b)) {
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
@ -865,9 +875,7 @@ public:
|
|||
T *buffer = new T[m_length];
|
||||
|
||||
if (m_data != nullptr) {
|
||||
for (size_t i = 0; i < m_length; i++) {
|
||||
transfer (buffer, m_data);
|
||||
}
|
||||
transfer (buffer, m_data);
|
||||
delete[] m_data;
|
||||
}
|
||||
m_data = move (buffer);
|
||||
|
|
@ -1829,5 +1837,3 @@ using StringArray = cr::classes::Array <cr::classes::String>;
|
|||
using IntArray = cr::classes::Array <int>;
|
||||
|
||||
}}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -46,10 +46,10 @@ extern int g_lastRadio[MAX_TEAM_COUNT];
|
|||
extern int g_storeAddbotVars[4];
|
||||
extern int *g_weaponPrefs[];
|
||||
|
||||
extern Array<StringArray> g_chatFactory;
|
||||
extern Array<Array<ChatterItem>> g_chatterFactory;
|
||||
extern Array<BotName> g_botNames;
|
||||
extern Array<KeywordFactory> g_replyFactory;
|
||||
extern Array <StringArray> g_chatFactory;
|
||||
extern Array <Array <ChatterItem>> g_chatterFactory;
|
||||
extern Array <BotName> g_botNames;
|
||||
extern Array <KeywordFactory> g_replyFactory;
|
||||
|
||||
extern WeaponSelect g_weaponSelect[NUM_WEAPONS + 1];
|
||||
extern WeaponProperty g_weaponDefs[MAX_WEAPONS + 1];
|
||||
|
|
@ -61,7 +61,7 @@ extern Task g_taskFilters[TASK_MAX];
|
|||
extern Experience *g_experienceData;
|
||||
|
||||
extern edict_t *g_hostEntity;
|
||||
extern Library *g_gameLib;
|
||||
extern Library g_gameLib;
|
||||
|
||||
extern gamefuncs_t g_functionTable;
|
||||
|
||||
|
|
|
|||
|
|
@ -1037,7 +1037,7 @@ private:
|
|||
Vector isBombAudible (void);
|
||||
|
||||
const Vector &getEnemyBodyOffset (void);
|
||||
Vector getBodyOffserError (float distance);
|
||||
Vector getBodyOffsetError (float distance);
|
||||
float getEnemyBodyOffsetCorrection (float distance);
|
||||
|
||||
void processTeamCommands (void);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue