Fixed linux listenserver startup problems
Fixed multiple buffer overruns and memory leaks.
This commit is contained in:
parent
c5031315bf
commit
74f1ab866b
29 changed files with 371 additions and 254 deletions
|
|
@ -33,7 +33,7 @@ public:
|
|||
Handler handler = nullptr;
|
||||
|
||||
public:
|
||||
BotCmd () = default;
|
||||
explicit BotCmd () = default;
|
||||
|
||||
BotCmd (StringRef name, StringRef format, StringRef help, Handler handler) : name (name), format (format), help (help), handler (cr::move (handler))
|
||||
{ }
|
||||
|
|
@ -46,7 +46,7 @@ public:
|
|||
MenuHandler handler;
|
||||
|
||||
public:
|
||||
BotMenu (int ident, int slots, StringRef text, MenuHandler handler) : ident (ident), slots (slots), text (text), handler (cr::move (handler))
|
||||
explicit BotMenu (int ident, int slots, StringRef text, MenuHandler handler) : ident (ident), slots (slots), text (text), handler (cr::move (handler))
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ public:
|
|||
String text;
|
||||
|
||||
public:
|
||||
PrintQueue () = default;
|
||||
explicit PrintQueue () = default;
|
||||
|
||||
PrintQueue (int32 destination, StringRef text) : destination (destination), text (text)
|
||||
{ }
|
||||
|
|
|
|||
50
inc/engine.h
50
inc/engine.h
|
|
@ -642,26 +642,29 @@ public:
|
|||
class EntityLinkage : public Singleton <EntityLinkage> {
|
||||
private:
|
||||
#if defined (CR_WINDOWS)
|
||||
# define DETOUR_FUNCTION GetProcAddress
|
||||
# define DETOUR_RETURN FARPROC
|
||||
# define DETOUR_HANDLE HMODULE
|
||||
# define DLSYM_FUNCTION GetProcAddress
|
||||
# define DLSYM_RETURN FARPROC
|
||||
# define DLSYM_HANDLE HMODULE
|
||||
#else
|
||||
# define DETOUR_FUNCTION dlsym
|
||||
# define DETOUR_RETURN SharedLibrary::Handle
|
||||
# define DETOUR_HANDLE SharedLibrary::Handle
|
||||
# define DLSYM_FUNCTION dlsym
|
||||
# define DLSYM_RETURN SharedLibrary::Handle
|
||||
# define DLSYM_HANDLE SharedLibrary::Handle
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool m_paused { false };
|
||||
|
||||
Detour <decltype (DLSYM_FUNCTION)> m_dlsym;
|
||||
HashMap <StringRef, DLSYM_RETURN> m_exports;
|
||||
|
||||
SharedLibrary m_self;
|
||||
Detour <decltype (DETOUR_FUNCTION)> m_dlsym { "kernel32.dll", "GetProcAddress", DETOUR_FUNCTION };
|
||||
HashMap <StringRef, DETOUR_RETURN> m_exports;
|
||||
|
||||
public:
|
||||
EntityLinkage () = default;
|
||||
|
||||
public:
|
||||
void initialize ();
|
||||
DETOUR_RETURN lookup (SharedLibrary::Handle module, const char *function);
|
||||
DLSYM_RETURN lookup (SharedLibrary::Handle module, const char *function);
|
||||
|
||||
public:
|
||||
void callPlayerFunction (edict_t *ent) {
|
||||
|
|
@ -673,7 +676,30 @@ public:
|
|||
}
|
||||
|
||||
public:
|
||||
static DETOUR_RETURN CR_STDCALL replacement (SharedLibrary::Handle module, const char *function) {
|
||||
void enable () {
|
||||
if (m_dlsym.detoured ()) {
|
||||
return;
|
||||
}
|
||||
m_dlsym.detour ();
|
||||
}
|
||||
|
||||
void disable () {
|
||||
if (!m_dlsym.detoured ()) {
|
||||
return;
|
||||
}
|
||||
m_dlsym.restore ();
|
||||
}
|
||||
|
||||
void setPaused (bool what) {
|
||||
m_paused = what;
|
||||
}
|
||||
|
||||
bool isPaused () const {
|
||||
return m_paused;
|
||||
}
|
||||
|
||||
public:
|
||||
static DLSYM_RETURN CR_STDCALL replacement (SharedLibrary::Handle module, const char *function) {
|
||||
return EntityLinkage::instance ().lookup (module, function);
|
||||
}
|
||||
|
||||
|
|
@ -681,6 +707,10 @@ public:
|
|||
void clearExportTable () {
|
||||
m_exports.clear ();
|
||||
}
|
||||
|
||||
bool isWorkaroundNeeded () {
|
||||
return !plat.win32 && !Game::instance ().isDedicated ();
|
||||
}
|
||||
};
|
||||
|
||||
// expose globals
|
||||
|
|
|
|||
36
inc/graph.h
36
inc/graph.h
|
|
@ -177,7 +177,9 @@ struct PODPath {
|
|||
class PathWalk final : public DenyCopying {
|
||||
private:
|
||||
size_t m_cursor = 0;
|
||||
Array <int, ReservePolicy::Single, kMaxRouteLength> m_storage;
|
||||
size_t m_length = 0;
|
||||
|
||||
UniquePtr <int32[]> m_path;
|
||||
|
||||
public:
|
||||
explicit PathWalk () = default;
|
||||
|
|
@ -193,11 +195,11 @@ public:
|
|||
}
|
||||
|
||||
int32 &last () {
|
||||
return m_storage.last ();
|
||||
return at (length () - 1);
|
||||
}
|
||||
|
||||
int32 &at (size_t index) {
|
||||
return m_storage.at (m_cursor + index);
|
||||
return m_path[m_cursor + index];
|
||||
}
|
||||
|
||||
void shift () {
|
||||
|
|
@ -205,31 +207,39 @@ public:
|
|||
}
|
||||
|
||||
void reverse () {
|
||||
m_storage.reverse ();
|
||||
for (size_t i = 0; i < m_length / 2; ++i) {
|
||||
cr::swap (m_path[i], m_path[m_length - 1 - i]);
|
||||
}
|
||||
}
|
||||
|
||||
size_t length () const {
|
||||
if (m_cursor > m_storage.length ()) {
|
||||
if (m_cursor >= m_length) {
|
||||
return 0;
|
||||
}
|
||||
return m_storage.length () - m_cursor;
|
||||
return m_length - m_cursor;
|
||||
}
|
||||
|
||||
bool hasNext () const {
|
||||
return m_cursor < m_storage.length ();
|
||||
return length () > m_cursor;
|
||||
}
|
||||
|
||||
bool empty () const {
|
||||
return !length ();
|
||||
}
|
||||
|
||||
void push (int node) {
|
||||
m_storage.push (node);
|
||||
void add (int32 node) {
|
||||
m_path[m_length++] = node;
|
||||
}
|
||||
|
||||
void clear () {
|
||||
m_cursor = 0;
|
||||
m_storage.clear ();
|
||||
m_length = 0;
|
||||
|
||||
m_path[0] = 0;
|
||||
}
|
||||
|
||||
void init (size_t length) {
|
||||
m_path = cr::makeUnique <int32 []> (length);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -250,7 +260,7 @@ private:
|
|||
int m_lastJumpNode;
|
||||
int m_findWPIndex;
|
||||
int m_facingAtIndex;
|
||||
int m_highestDamage[kGameTeamNum];
|
||||
int m_highestDamage[kGameTeamNum] {};
|
||||
|
||||
float m_timeJumpStarted;
|
||||
float m_autoPathDistance;
|
||||
|
|
@ -373,6 +383,10 @@ public:
|
|||
const SmallArray <int32> &getNodesInBucket (const Vector &pos);
|
||||
|
||||
public:
|
||||
size_t getMaxRouteLength () const {
|
||||
return m_paths.length () / 2;
|
||||
}
|
||||
|
||||
int getHighestDamageForTeam (int team) const {
|
||||
return m_highestDamage[team];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -453,7 +453,6 @@ constexpr int kMaxNodeLinks = 8;
|
|||
constexpr int kMaxPracticeDamageValue = 2040;
|
||||
constexpr int kMaxPracticeGoalValue = 2040;
|
||||
constexpr int kMaxNodes = 2048;
|
||||
constexpr int kMaxRouteLength = kMaxNodes / 2;
|
||||
constexpr int kMaxWeapons = 32;
|
||||
constexpr int kNumWeapons = 26;
|
||||
constexpr int kMaxCollideMoves = 3;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue