removed SEH

This commit is contained in:
jeefo 2015-07-05 18:53:58 +03:00
commit 6847bd34a6
6 changed files with 18 additions and 64 deletions

View file

@ -62,7 +62,6 @@ using namespace Math;
#if defined (COMPILER_VISUALC) && (COMPILER_VISUALC > 1000) #if defined (COMPILER_VISUALC) && (COMPILER_VISUALC > 1000)
#pragma comment (linker, "/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1") #pragma comment (linker, "/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1")
#pragma comment (linker, "/SECTION:.data,RW") #pragma comment (linker, "/SECTION:.data,RW")
#pragma warning (disable : 4288)
#endif #endif
typedef int (FAR *EntityAPI_t) (gamefuncs_t *, int); typedef int (FAR *EntityAPI_t) (gamefuncs_t *, int);
@ -173,7 +172,7 @@ public:
#include <corelib.h> #include <corelib.h>
// defines bots tasks // defines bots tasks
enum TaskId_t enum TaskID
{ {
TASK_NORMAL, TASK_NORMAL,
TASK_PAUSE, TASK_PAUSE,
@ -622,7 +621,7 @@ struct KeywordFactory
// tasks definition // tasks definition
struct TaskItem struct TaskItem
{ {
TaskId_t id; // major task/action carried out TaskID id; // major task/action carried out
float desire; // desire (filled in) for this task float desire; // desire (filled in) for this task
int data; // additional data (waypoint index) int data; // additional data (waypoint index)
float time; // time task expires float time; // time task expires
@ -1244,12 +1243,12 @@ public:
void DeleteSearchNodes (void); void DeleteSearchNodes (void);
void VerifyBreakable (edict_t *touch); void VerifyBreakable (edict_t *touch);
void RemoveCertainTask (TaskId_t id); void RemoveCertainTask (TaskID id);
void StartTask (TaskId_t id, float desire, int data, float time, bool canContinue); void StartTask (TaskID id, float desire, int data, float time, bool canContinue);
void ResetTasks (void); void ResetTasks (void);
TaskItem *GetTask (void); TaskItem *GetTask (void);
inline TaskId_t GetTaskId (void) { return GetTask ()->id; }; inline TaskID GetTaskId (void) { return GetTask ()->id; };
void TakeDamage (edict_t *inflictor, int damage, int armor, int bits); void TakeDamage (edict_t *inflictor, int damage, int armor, int bits);
void TakeBlinded (const Vector &fade, int alpha); void TakeBlinded (const Vector &fade, int alpha);

View file

@ -21,10 +21,6 @@
#include <math.h> #include <math.h>
#include <assert.h> #include <assert.h>
#if defined (PLATFORM_WIN32)
#pragma warning (disable : 4100 4189 4239 4996 4244 383 473 981)
#endif
// //
// Title: Utility Classes Header // Title: Utility Classes Header
// //
@ -1059,9 +1055,7 @@ template <typename T> class Array
{ {
private: private:
T *m_elements; T *m_elements;
T m_failed;
private:
int m_resizeStep; int m_resizeStep;
int m_itemSize; int m_itemSize;
int m_itemCount; int m_itemCount;
@ -1084,8 +1078,6 @@ public:
m_itemSize = 0; m_itemSize = 0;
m_itemCount = 0; m_itemCount = 0;
m_resizeStep = resizeStep; m_resizeStep = resizeStep;
m_failed = T ();
} }
// //
@ -1101,7 +1093,6 @@ public:
m_itemSize = 0; m_itemSize = 0;
m_itemCount = 0; m_itemCount = 0;
m_resizeStep = 0; m_resizeStep = 0;
m_failed = T ();
AssignFrom (other); AssignFrom (other);
} }
@ -1277,11 +1268,6 @@ public:
// //
T &GetAt (int index) T &GetAt (int index)
{ {
if (index >= m_itemCount)
{
m_failed = T ();
return m_failed;
}
return m_elements[index]; return m_elements[index];
} }
@ -1546,9 +1532,6 @@ public:
// //
T Pop (void) T Pop (void)
{ {
if (m_itemCount <= 0)
return m_failed;
T element = m_elements[m_itemCount - 1]; T element = m_elements[m_itemCount - 1];
RemoveAt (m_itemCount - 1); RemoveAt (m_itemCount - 1);
@ -1557,9 +1540,6 @@ public:
T &Last (void) T &Last (void)
{ {
if (m_itemCount <= 0)
return m_failed;
return m_elements[m_itemCount - 1]; return m_elements[m_itemCount - 1];
} }
@ -2740,11 +2720,6 @@ public:
return static_cast <double> (ToFloat ()); return static_cast <double> (ToFloat ());
} }
String *operator -> (void) const
{
return (String *const) this;
}
friend String operator + (const String &s1, const String &s2) friend String operator + (const String &s1, const String &s2)
{ {
String result (s1); String result (s1);

View file

@ -126,4 +126,4 @@ static inline bool IsEntityNull (const edict_t *ent)
static inline int GetTeam (edict_t *ent) static inline int GetTeam (edict_t *ent)
{ {
return g_clients[IndexOfEntity (ent) - 1].team; return g_clients[IndexOfEntity (ent) - 1].team;
} }

View file

@ -2185,7 +2185,7 @@ void Bot::ResetTasks (void)
m_tasks.RemoveAll (); m_tasks.RemoveAll ();
} }
void Bot::StartTask (TaskId_t id, float desire, int data, float time, bool resume) void Bot::StartTask (TaskID id, float desire, int data, float time, bool resume)
{ {
if (!m_tasks.IsEmpty ()) if (!m_tasks.IsEmpty ())
{ {
@ -2268,7 +2268,7 @@ TaskItem *Bot::GetTask (void)
return &m_tasks.Last (); return &m_tasks.Last ();
} }
void Bot::RemoveCertainTask (TaskId_t id) void Bot::RemoveCertainTask (TaskID id)
{ {
// this function removes one task from the bot task stack. // this function removes one task from the bot task stack.
@ -2418,7 +2418,7 @@ void Bot::CheckRadioCommands (void)
m_targetEntity = m_radioEntity; m_targetEntity = m_radioEntity;
// don't pause/camp/follow anymore // don't pause/camp/follow anymore
TaskId_t taskID = GetTaskId (); TaskID taskID = GetTaskId ();
if (taskID == TASK_PAUSE || taskID == TASK_CAMP) if (taskID == TASK_PAUSE || taskID == TASK_CAMP)
GetTask ()->time = GetWorldTime (); GetTask ()->time = GetWorldTime ();
@ -2537,7 +2537,7 @@ void Bot::CheckRadioCommands (void)
} }
else if ((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 2048) else if ((IsEntityNull (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 2048)
{ {
TaskId_t taskID = GetTaskId (); TaskID taskID = GetTaskId ();
if (taskID == TASK_PAUSE || taskID == TASK_CAMP) if (taskID == TASK_PAUSE || taskID == TASK_CAMP)
{ {
@ -2603,7 +2603,7 @@ void Bot::CheckRadioCommands (void)
RadioMessage (Radio_Affirmative); RadioMessage (Radio_Affirmative);
// don't pause/camp anymore // don't pause/camp anymore
TaskId_t taskID = GetTaskId (); TaskID taskID = GetTaskId ();
if (taskID == TASK_PAUSE || taskID == TASK_CAMP) if (taskID == TASK_PAUSE || taskID == TASK_CAMP)
GetTask ()->time = GetWorldTime (); GetTask ()->time = GetWorldTime ();
@ -2646,7 +2646,7 @@ void Bot::CheckRadioCommands (void)
else else
{ {
// don't pause/camp anymore // don't pause/camp anymore
TaskId_t taskID = GetTaskId (); TaskID taskID = GetTaskId ();
if (taskID == TASK_PAUSE) if (taskID == TASK_PAUSE)
GetTask ()->time = GetWorldTime (); GetTask ()->time = GetWorldTime ();
@ -2743,7 +2743,7 @@ void Bot::CheckRadioCommands (void)
else else
{ {
// don't pause anymore // don't pause anymore
TaskId_t taskID = GetTaskId (); TaskID taskID = GetTaskId ();
if (taskID == TASK_PAUSE) if (taskID == TASK_PAUSE)
GetTask ()->time = GetWorldTime (); GetTask ()->time = GetWorldTime ();
@ -2795,7 +2795,7 @@ void Bot::CheckRadioCommands (void)
void Bot::TryHeadTowardRadioEntity (void) void Bot::TryHeadTowardRadioEntity (void)
{ {
TaskId_t taskID = GetTaskId (); TaskID taskID = GetTaskId ();
if (taskID == TASK_MOVETOPOSITION || m_headedTime + 15.0f < GetWorldTime () || !IsAlive (m_radioEntity) || m_hasC4) if (taskID == TASK_MOVETOPOSITION || m_headedTime + 15.0f < GetWorldTime () || !IsAlive (m_radioEntity) || m_hasC4)
return; return;

View file

@ -3002,7 +3002,7 @@ struct DirectoryTransition
DirectoryTransition (const String &oldName, const String &newName) DirectoryTransition (const String &oldName, const String &newName)
{ {
String rootPath; String rootPath;
rootPath->AssignFormat ("%s/addons/yapb/", GetModName ()); rootPath.AssignFormat ("%s/addons/yapb/", GetModName ());
this->oldName = rootPath + oldName; this->oldName = rootPath + oldName;
this->newName = rootPath + newName; this->newName = rootPath + newName;
@ -3010,8 +3010,8 @@ struct DirectoryTransition
void TryToRename (void) void TryToRename (void)
{ {
if (access (oldName->GetBuffer (), 00) != -1) if (access (oldName.GetBuffer (), 00) != -1)
rename (oldName->GetBuffer (), newName->GetBuffer ()); rename (oldName.GetBuffer (), newName.GetBuffer ());
} }
}; };

View file

@ -232,32 +232,12 @@ Bot *BotManager::FindOneValidAliveBot (void)
void BotManager::Think (void) void BotManager::Think (void)
{ {
// this function calls think () function for all available at call moment bots, and // this function calls think () function for all available at call moment bots
// try to catch internal error if such shit occurs
for (int i = 0; i < GetMaxClients (); i++) for (int i = 0; i < GetMaxClients (); i++)
{ {
if (m_bots[i] != NULL) if (m_bots[i] != NULL)
{
// use these try-catch blocks to prevent server crashes when error occurs
#if defined (NDEBUG) && !defined (PLATFORM_LINUX) && !defined (PLATFORM_OSX)
try
{
m_bots[i]->Think ();
}
catch (...)
{
// error occurred. kick off all bots and then print a warning message
RemoveAll ();
ServerPrint ("**** INTERNAL BOT ERROR! PLEASE SHUTDOWN AND RESTART YOUR SERVER! ****");
}
#else
m_bots[i]->Think (); m_bots[i]->Think ();
#endif
}
} }
} }