WholeProgramOptimization="true"\r
AdditionalIncludeDirectories=""C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include";"..\jthread\jthread-1.2.1\src";"..\irrlicht\irrlicht-1.7.1\include";"..\zlib\zlib-1.2.5""\r
PreprocessorDefinitions="WIN32;_HAS_ITERATOR_DEBUGGING=0,UNITTEST_DISABLE,_CRT_SECURE_NO_DEPRECATE"\r
+ ExceptionHandling="2"\r
BufferSecurityCheck="false"\r
EnableEnhancedInstructionSet="1"\r
FloatingPointModel="2"\r
ThreadStarted();
DSTACK(__FUNCTION_NAME);
-
-#if CATCH_UNHANDLED_EXCEPTIONS
- try
+
+ BEGIN_DEBUG_EXCEPTION_HANDLER
+
+ while(getRun())
{
-#endif
- while(getRun())
- {
- m_client->asyncStep();
+ m_client->asyncStep();
- //m_client->updateSomeExpiredMeshes();
+ //m_client->updateSomeExpiredMeshes();
- bool was = m_client->AsyncProcessData();
+ bool was = m_client->AsyncProcessData();
- if(was == false)
- sleep_ms(10);
- }
-#if CATCH_UNHANDLED_EXCEPTIONS
+ if(was == false)
+ sleep_ms(10);
}
- /*
- This is what has to be done in threads to get suitable debug info
- */
- catch(std::exception &e)
- {
- dstream<<std::endl<<DTIME<<"An unhandled exception occurred: "
- <<e.what()<<std::endl;
- assert(0);
- }
-#endif
+
+ END_DEBUG_EXCEPTION_HANDLER
return NULL;
}
}
}
+
+#ifdef _WIN32
+void se_trans_func(unsigned int u, EXCEPTION_POINTERS* pExp)
+{
+ dstream<<"In trans_func.\n";
+ if(u == EXCEPTION_ACCESS_VIOLATION)
+ {
+ PEXCEPTION_RECORD r = pExp->ExceptionRecord;
+ dstream<<"Access violation at "<<r->ExceptionAddress
+ <<" write?="<<r->ExceptionInformation[0]
+ <<" address="<<r->ExceptionInformation[1]
+ <<std::endl;
+ throw FatalSystemException
+ ("Access violation");
+ }
+ if(u == EXCEPTION_STACK_OVERFLOW)
+ {
+ throw FatalSystemException
+ ("Stack overflow");
+ }
+ if(u == EXCEPTION_ILLEGAL_INSTRUCTION)
+ {
+ throw FatalSystemException
+ ("Illegal instruction");
+ }
+}
+#endif
+
+
+
#include "common_irrlicht.h"
#include "threads.h"
#include "gettime.h"
+#include "constants.h"
+#include "exceptions.h"
+
+#ifdef _WIN32
+ #define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ #include <eh.h>
+#else
+#endif
/*
Debug output
core::map<u16, u16> m_packets;
};
+/*
+ These should be put into every thread
+*/
+
+#if CATCH_UNHANDLED_EXCEPTIONS == 1
+ #define BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER try{
+ #define END_PORTABLE_DEBUG_EXCEPTION_HANDLER\
+ }catch(std::exception &e){\
+ dstream<<std::endl<<DTIME\
+ <<"ERROR: An unhandled exception occurred: "\
+ <<e.what()<<std::endl;\
+ assert(0);\
+ }
+ #ifdef _WIN32 // Windows
+
+/*class SE_Exception : public std::exception
+{
+private:
+ unsigned int nSE;
+public:
+ SE_Exception() {}
+ SE_Exception( unsigned int n ) : nSE( n ) {}
+ ~SE_Exception() {}
+ unsigned int getSeNumber() { return nSE; }
+};*/
+
+void se_trans_func(unsigned int, EXCEPTION_POINTERS*);
+
+class FatalSystemException : public BaseException
+{
+public:
+ FatalSystemException(const char *s):
+ BaseException(s)
+ {}
+};
+
+ #define BEGIN_DEBUG_EXCEPTION_HANDLER \
+ BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER\
+ _set_se_translator(se_trans_func);
+
+ #define END_DEBUG_EXCEPTION_HANDLER \
+ END_PORTABLE_DEBUG_EXCEPTION_HANDLER
+
+ #else // Posix
+ #define BEGIN_DEBUG_EXCEPTION_HANDLER\
+ BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER
+ #define END_DEBUG_EXCEPTION_HANDLER\
+ END_PORTABLE_DEBUG_EXCEPTION_HANDLER
+ #endif
+#else
+ // Dummy ones
+ #define BEGIN_DEBUG_EXCEPTION_HANDLER
+ #define END_DEBUG_EXCEPTION_HANDLER
+#endif
#endif // DEBUG_HEADER
\r
TODO: Make the video backend selectable\r
\r
+TODO: Copy the text of the last picked sign to inventory in creative\r
+ mode\r
+\r
+TODO: Get rid of GotSplitPacketException\r
+\r
+TODO: Check what goes wrong with caching map to disk (Kray)\r
+\r
Block object server side:\r
- A "near blocks" buffer, in which some nearby blocks are stored.\r
- For all blocks in the buffer, objects are stepped(). This\r
- TODO: For incoming blocks, time difference is calculated and\r
objects are stepped according to it.\r
\r
-TODO: Copy the text of the last picked sign to inventory in creative\r
- mode\r
-\r
-TODO: Get rid of GotSplitPacketException\r
-\r
-TODO: Check what goes wrong with caching map to disk (Kray)\r
-\r
-TODO: Remove LazyMeshUpdater. It is not used as supposed.\r
-\r
-TODO: TOSERVER_LEAVE\r
-\r
TODO: Better handling of objects and mobs\r
- Scripting?\r
- There has to be some way to do it with less spaghetti code\r
\r
TODO: Check if the usage of Client::isFetchingBlocks() in\r
updateViewingRange() actually does something\r
+ NOTE: It isn't used anymore after the rewrite.\r
\r
TODO: Make an option to the server to disable building and digging near\r
the starting position\r
TODO: There has to be some better way to handle static objects than to\r
send them all the time. This affects signs and item objects.\r
\r
-Doing now:\r
-======================================================================\r
-\r
TODO: When server sees that client is removing an inexistent block or\r
adding a block to an existent position, resend the MapBlock.\r
\r
-TODO: Fix viewing range updater's oscillation when there is large non-\r
- linearity in range-speed relation\r
+TODO: Map generator: add other materials underground (mud)\r
+\r
+Doing now:\r
+======================================================================\r
\r
======================================================================\r
\r
\r
initializeMaterialProperties();\r
\r
+ BEGIN_DEBUG_EXCEPTION_HANDLER\r
+\r
try\r
{\r
\r
/*\r
This changes the minimum allowed number of vertices in a VBO\r
*/\r
- //driver->setMinHardwareBufferVertexCount(1);\r
+ //driver->setMinHardwareBufferVertexCount(50);\r
\r
scene::ISceneManager* smgr = device->getSceneManager();\r
\r
menu->drop();\r
}*/\r
}\r
-#if CATCH_UNHANDLED_EXCEPTIONS\r
- /*\r
- This is what has to be done in every thread to get suitable debug info\r
- */\r
- catch(std::exception &e)\r
- {\r
- dstream<<std::endl<<DTIME<<"An unhandled exception occurred: "\r
- <<e.what()<<std::endl;\r
- assert(0);\r
- }\r
-#endif\r
\r
+ END_DEBUG_EXCEPTION_HANDLER\r
+ \r
debugstreams_deinit();\r
\r
return 0;\r
*/
TileSpec MapBlock::getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir)
{
+ // DEBUG
+ u16 *ptr = NULL;
+ *ptr = 7357;
+
TileSpec spec;
/*//DEBUG
collector.fillMesh(mesh_new);
// Use VBO for mesh (this just would set this for ever buffer)
+ // This will lead to infinite memory usage because or irrlicht.
//mesh_new->setHardwareMappingHint(scene::EHM_STATIC);
/*std::cout<<"MapBlock has "<<fastfaces_new->getSize()<<" faces "
public:
MaterialProperties()
{
- dstream<<__FUNCTION_NAME<<std::endl;
}
void setDiggingProperties(const std::string toolname,
DSTACK(__FUNCTION_NAME);
+ BEGIN_DEBUG_EXCEPTION_HANDLER
+
while(getRun())
{
try{
catch(con::NoIncomingDataException &e)
{
}
-#if CATCH_UNHANDLED_EXCEPTIONS
- /*
- This is what has to be done in threads to get suitable debug info
- */
- catch(std::exception &e)
- {
- dstream<<std::endl<<DTIME<<"An unhandled exception occurred: "
- <<e.what()<<std::endl;
- assert(0);
- }
-#endif
}
+ END_DEBUG_EXCEPTION_HANDLER
return NULL;
}
DSTACK(__FUNCTION_NAME);
bool debug=false;
-#if CATCH_UNHANDLED_EXCEPTIONS
- try
- {
-#endif
+ BEGIN_DEBUG_EXCEPTION_HANDLER
+
/*
Get block info from queue, emerge them and send them
to clients.
}
}
-#if CATCH_UNHANDLED_EXCEPTIONS
- }//try
- /*
- This is what has to be done in threads to get suitable debug info
- */
- catch(std::exception &e)
- {
- dstream<<std::endl<<DTIME<<"An unhandled exception occurred: "
- <<e.what()<<std::endl;
- assert(0);
- }
-#endif
+
+ END_DEBUG_EXCEPTION_HANDLER
return NULL;
}
initializeMaterialProperties();
+ BEGIN_DEBUG_EXCEPTION_HANDLER
+
try
{
{
dstream<<DTIME<<"Connection timed out."<<std::endl;
}
-#if CATCH_UNHANDLED_EXCEPTIONS
- /*
- This is what has to be done in every thread to get suitable debug info
- */
- catch(std::exception &e)
- {
- dstream<<std::endl<<DTIME<<"An unhandled exception occurred: "
- <<e.what()<<std::endl;
- assert(0);
- }
-#endif
+
+ END_DEBUG_EXCEPTION_HANDLER
debugstreams_deinit();