Merge branch 'develop' into ryzomclassic-develop

ryzomclassic-develop
Jan Boon 5 years ago
commit 6cdee90e4e

@ -100,8 +100,8 @@ public:
public: public:
EBadBind() {} EBadBind() {}
~EBadBind() throw () {} virtual ~EBadBind() NL_OVERRIDE {}
virtual const char *what() const throw(); virtual const char *what() const throw() NL_OVERRIDE;
}; };

@ -88,7 +88,7 @@ namespace NLGUI
{ {
public: public:
ELuaError() { CLuaStackChecker::incrementExceptionContextCounter(); } ELuaError() { CLuaStackChecker::incrementExceptionContextCounter(); }
virtual ~ELuaError() throw() { CLuaStackChecker::decrementExceptionContextCounter(); } virtual ~ELuaError() NL_OVERRIDE { CLuaStackChecker::decrementExceptionContextCounter(); }
ELuaError(const std::string &reason) : Exception(reason) { CLuaStackChecker::incrementExceptionContextCounter(); } ELuaError(const std::string &reason) : Exception(reason) { CLuaStackChecker::incrementExceptionContextCounter(); }
// what(), plus append the Reason // what(), plus append the Reason
virtual std::string luaWhat() const throw() {return NLMISC::toString("LUAError: %s", what());} virtual std::string luaWhat() const throw() {return NLMISC::toString("LUAError: %s", what());}
@ -100,9 +100,9 @@ namespace NLGUI
public: public:
ELuaParseError() {} ELuaParseError() {}
ELuaParseError(const std::string &reason) : ELuaError(reason) {} ELuaParseError(const std::string &reason) : ELuaError(reason) {}
virtual ~ELuaParseError() throw() { } virtual ~ELuaParseError() NL_OVERRIDE { }
// what(), plus append the Reason // what(), plus append the Reason
virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaParseError: %s", what());} virtual std::string luaWhat() const throw() NL_OVERRIDE {return NLMISC::toString("ELuaParseError: %s", what());}
}; };
/** Exception thrown when something went wrong inside a wrapped function called by lua /** Exception thrown when something went wrong inside a wrapped function called by lua
@ -113,8 +113,8 @@ namespace NLGUI
ELuaWrappedFunctionException(CLuaState *luaState); ELuaWrappedFunctionException(CLuaState *luaState);
ELuaWrappedFunctionException(CLuaState *luaState, const std::string &reason); ELuaWrappedFunctionException(CLuaState *luaState, const std::string &reason);
ELuaWrappedFunctionException(CLuaState *luaState, const char *format, ...); ELuaWrappedFunctionException(CLuaState *luaState, const char *format, ...);
virtual ~ELuaWrappedFunctionException() throw() { } virtual ~ELuaWrappedFunctionException() NL_OVERRIDE { }
virtual const char *what() const throw() {return _Reason.c_str();} virtual const char *what() const throw() NL_OVERRIDE {return _Reason.c_str();}
protected: protected:
void init(CLuaState *ls, const std::string &reason); void init(CLuaState *ls, const std::string &reason);
protected: protected:
@ -127,9 +127,9 @@ namespace NLGUI
public: public:
ELuaExecuteError() {} ELuaExecuteError() {}
ELuaExecuteError(const std::string &reason) : ELuaError(reason) {} ELuaExecuteError(const std::string &reason) : ELuaError(reason) {}
virtual ~ELuaExecuteError() throw() { } virtual ~ELuaExecuteError() NL_OVERRIDE { }
// what(), plus append the Reason // what(), plus append the Reason
virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaExecuteError: %s", what());} virtual std::string luaWhat() const throw() NL_OVERRIDE {return NLMISC::toString("ELuaExecuteError: %s", what());}
}; };
// A bad cast occurred when using lua_checkcast // A bad cast occurred when using lua_checkcast

@ -368,8 +368,8 @@ public:
Exception(); Exception();
Exception(const std::string &reason); Exception(const std::string &reason);
Exception(const char *format, ...); Exception(const char *format, ...);
virtual ~Exception() throw() {} virtual ~Exception() NL_OVERRIDE {}
virtual const char *what() const throw(); virtual const char *what() const throw() NL_OVERRIDE;
}; };

@ -368,13 +368,19 @@ extern bool _assertex_stop_1(bool &ignoreNextTime);
// removed because we always check assert (even in release mode) #if defined(NL_DEBUG) // removed because we always check assert (even in release mode) #if defined(NL_DEBUG)
#if defined(_MSC_VER) && _MSC_VER >= 1900
#define nlassume(exp) do { __analysis_assume(exp); } while (0) // __analysis_assume doesn't evaluate the expression at runtime
#else
#define nlassume(exp) do { ) while (0)
#endif
#ifdef NL_NO_DEBUG #ifdef NL_NO_DEBUG
# define nlassert(exp) if(false) # define nlassert(exp) nlassume(exp)
# define nlassertonce(exp) if(false) # define nlassertonce(exp) nlassume(exp)
# define nlassertex(exp, str) if(false) # define nlassertex(exp, str) nlassume(exp)
# define nlverify(exp) { exp; } # define nlverify(exp) do { exp; nlassume(exp); } while (0)
# define nlverifyonce(exp) { exp; } # define nlverifyonce(exp) do { exp; nlassume(exp); } while (0)
# define nlverifyex(exp, str) { exp; } # define nlverifyex(exp, str) do { exp; nlassume(exp); } while (0)
#else // NL_NO_DEBUG #else // NL_NO_DEBUG
# ifdef NL_OS_UNIX # ifdef NL_OS_UNIX
@ -383,25 +389,29 @@ extern bool _assertex_stop_1(bool &ignoreNextTime);
#define nlassert(exp) \ #define nlassert(exp) \
do { \ do { \
if (!(exp)) { \ bool _expResult_ = (exp) ? true : false; \
if (!(_expResult_)) { \
NLMISC::createDebug (); \ NLMISC::createDebug (); \
NLMISC::INelContext::getInstance().getAssertLog()->setPosition (__LINE__, __FILE__, __FUNCTION__); \ NLMISC::INelContext::getInstance().getAssertLog()->setPosition (__LINE__, __FILE__, __FUNCTION__); \
NLMISC::INelContext::getInstance().getAssertLog()->displayNL ("\"%s\" ", #exp); \ NLMISC::INelContext::getInstance().getAssertLog()->displayNL ("\"%s\" ", #exp); \
NLMISC_BREAKPOINT; \ NLMISC_BREAKPOINT; \
} \ } \
nlassume(_expResult_); \
} while(0) } while(0)
#define nlassertonce(exp) nlassert(exp) #define nlassertonce(exp) nlassert(exp)
#define nlassertex(exp, str) \ #define nlassertex(exp, str) \
do { \ do { \
if (!(exp)) { \ bool _expResult_ = (exp) ? true : false; \
if (!(_expResult_)) { \
NLMISC::createDebug (); \ NLMISC::createDebug (); \
NLMISC::INelContext::getInstance().getAssertLog()->setPosition (__LINE__, __FILE__, __FUNCTION__); \ NLMISC::INelContext::getInstance().getAssertLog()->setPosition (__LINE__, __FILE__, __FUNCTION__); \
NLMISC::INelContext::getInstance().getAssertLog()->displayNL ("\"%s\" ", #exp); \ NLMISC::INelContext::getInstance().getAssertLog()->displayNL ("\"%s\" ", #exp); \
NLMISC::INelContext::getInstance().getAssertLog()->displayRawNL str; \ NLMISC::INelContext::getInstance().getAssertLog()->displayRawNL str; \
NLMISC_BREAKPOINT; \ NLMISC_BREAKPOINT; \
} \ } \
nlassume(_expResult_); \
} while(0) } while(0)
#define nlverify(exp) nlassert(exp) #define nlverify(exp) nlassert(exp)
@ -419,16 +429,19 @@ do { \
NLMISC_BREAKPOINT; \ NLMISC_BREAKPOINT; \
} \ } \
ASSERT_THROW_EXCEPTION_CODE_EX(_expResult_, #exp) \ ASSERT_THROW_EXCEPTION_CODE_EX(_expResult_, #exp) \
nlassume(_expResult_); \
} while(0) } while(0)
#define nlassertonce(exp) \ #define nlassertonce(exp) \
do { \ do { \
static bool ignoreNextTime = false; \ static bool ignoreNextTime = false; \
if (!ignoreNextTime && !(exp)) { \ bool _expResult_ = (exp) ? true : false; \
if (!ignoreNextTime && !(_expResult_)) { \
ignoreNextTime = true; \ ignoreNextTime = true; \
if(NLMISC::_assert_stop(ignoreNextTime, __LINE__, __FILE__, __FUNCTION__, #exp)) \ if(NLMISC::_assert_stop(ignoreNextTime, __LINE__, __FILE__, __FUNCTION__, #exp)) \
NLMISC_BREAKPOINT; \ NLMISC_BREAKPOINT; \
} \ } \
nlassume(_expResult_); \
} while(0) } while(0)
#define nlassertex(exp, str) \ #define nlassertex(exp, str) \
@ -442,6 +455,7 @@ do { \
NLMISC_BREAKPOINT; \ NLMISC_BREAKPOINT; \
} \ } \
ASSERT_THROW_EXCEPTION_CODE_EX(_expResult_, #exp) \ ASSERT_THROW_EXCEPTION_CODE_EX(_expResult_, #exp) \
nlassume(_expResult_); \
} while(0) } while(0)
#define nlverify(exp) \ #define nlverify(exp) \
@ -453,6 +467,7 @@ do { \
NLMISC_BREAKPOINT; \ NLMISC_BREAKPOINT; \
} \ } \
ASSERT_THROW_EXCEPTION_CODE_EX(_expResult_, #exp) \ ASSERT_THROW_EXCEPTION_CODE_EX(_expResult_, #exp) \
nlassume(_expResult_); \
} while(0) } while(0)
#define nlverifyonce(exp) \ #define nlverifyonce(exp) \
@ -464,6 +479,7 @@ do { \
if(NLMISC::_assert_stop(ignoreNextTime, __LINE__, __FILE__, __FUNCTION__, #exp)) \ if(NLMISC::_assert_stop(ignoreNextTime, __LINE__, __FILE__, __FUNCTION__, #exp)) \
NLMISC_BREAKPOINT; \ NLMISC_BREAKPOINT; \
} \ } \
nlassume(_expResult_); \
} while(0) } while(0)
#define nlverifyex(exp, str) \ #define nlverifyex(exp, str) \
@ -477,6 +493,7 @@ do { \
NLMISC_BREAKPOINT; \ NLMISC_BREAKPOINT; \
} \ } \
ASSERT_THROW_EXCEPTION_CODE_EX(_expResult_, #exp) \ ASSERT_THROW_EXCEPTION_CODE_EX(_expResult_, #exp) \
nlassume(_expResult_); \
} while(0) } while(0)
# endif // NL_OS_UNIX # endif // NL_OS_UNIX

@ -38,7 +38,7 @@ struct EFile : public EStream
EFile (const std::string& filename) : EStream( "Unknown file error in '"+filename+"'" ), Filename(filename) {} EFile (const std::string& filename) : EStream( "Unknown file error in '"+filename+"'" ), Filename(filename) {}
EFile (const std::string& filename, const std::string& text, bool ) : EStream( text ), Filename(filename) {} EFile (const std::string& filename, const std::string& text, bool ) : EStream( text ), Filename(filename) {}
virtual ~EFile() throw() {} virtual ~EFile() NL_OVERRIDE {}
std::string Filename; std::string Filename;
}; };

@ -78,7 +78,7 @@ struct EStream : public Exception
EStream( const IStream &f, const std::string& str ); EStream( const IStream &f, const std::string& str );
virtual ~EStream() throw() {} virtual ~EStream() NL_OVERRIDE {}
// May Not be Filled... // May Not be Filled...
std::string StreamName; std::string StreamName;

@ -246,6 +246,7 @@
# pragma warning (disable : 4005) // don't warn on redefinitions caused by xp platform sdk # pragma warning (disable : 4005) // don't warn on redefinitions caused by xp platform sdk
# endif // NL_COMP_VC8 || NL_COMP_VC9 # endif // NL_COMP_VC8 || NL_COMP_VC9
# pragma warning (disable : 26495) // Variable is uninitialized. Always initialize a member variable. (On purpose for performance.) # pragma warning (disable : 26495) // Variable is uninitialized. Always initialize a member variable. (On purpose for performance.)
# pragma warning (disable : 26812) // The enum type is unscoped. Prefer 'enum class' over 'enum' (Enum.3).
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS

@ -197,6 +197,7 @@ CDriverD3D::CDriverD3D()
_BackBuffer = NULL; _BackBuffer = NULL;
_Maximized = false; _Maximized = false;
_HandlePossibleSizeChangeNextSize = false; _HandlePossibleSizeChangeNextSize = false;
_WindowFocus = true;
_Interval = 1; _Interval = 1;
_AGPMemoryAllocated = 0; _AGPMemoryAllocated = 0;
_VRAMMemoryAllocated = 0; _VRAMMemoryAllocated = 0;
@ -1164,6 +1165,14 @@ void D3DWndProc(CDriverD3D *driver, HWND hWnd, UINT message, WPARAM wParam, LPAR
} }
} }
if ((message == WM_SETFOCUS) || (message == WM_KILLFOCUS))
{
if (driver != NULL)
{
driver->_WindowFocus = (message == WM_SETFOCUS);
}
}
if (driver->_EventEmitter.getNumEmitters() > 0) if (driver->_EventEmitter.getNumEmitters() > 0)
{ {
CWinEventEmitter *we = NLMISC::safe_cast<CWinEventEmitter *>(driver->_EventEmitter.getEmitter(0)); CWinEventEmitter *we = NLMISC::safe_cast<CWinEventEmitter *>(driver->_EventEmitter.getEmitter(0));
@ -1370,6 +1379,7 @@ bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool r
// Reset window state // Reset window state
_Maximized = false; _Maximized = false;
_HandlePossibleSizeChangeNextSize = false; _HandlePossibleSizeChangeNextSize = false;
_WindowFocus = true;
if (_HWnd) if (_HWnd)
{ {

@ -2324,6 +2324,7 @@ private:
sint32 _WindowY; sint32 _WindowY;
bool _DestroyWindow; bool _DestroyWindow;
bool _Maximized; bool _Maximized;
bool _WindowFocus;
bool _HandlePossibleSizeChangeNextSize; bool _HandlePossibleSizeChangeNextSize;
GfxMode _CurrentMode; GfxMode _CurrentMode;
uint _Interval; uint _Interval;

@ -374,7 +374,7 @@ void CDriverD3D::setMousePos(float x, float y)
{ {
H_AUTO_D3D(CDriverD3D_setMousePos); H_AUTO_D3D(CDriverD3D_setMousePos);
if (_HWnd == EmptyWindow) if (_HWnd == EmptyWindow || !_WindowFocus)
return; return;
// convert position size from float to pixels // convert position size from float to pixels

@ -234,6 +234,7 @@ CDriverGL::CDriverGL()
_win = EmptyWindow; _win = EmptyWindow;
_WindowX = 0; _WindowX = 0;
_WindowY = 0; _WindowY = 0;
_WindowFocus = true;
_WindowVisible = true; _WindowVisible = true;
_DestroyWindow = false; _DestroyWindow = false;
_Maximized = false; _Maximized = false;

@ -700,6 +700,7 @@ public:
GfxMode _CurrentMode; GfxMode _CurrentMode;
sint32 _WindowX; sint32 _WindowX;
sint32 _WindowY; sint32 _WindowY;
bool _WindowFocus;
#ifdef NL_OS_MAC #ifdef NL_OS_MAC
NLMISC::CCocoaEventEmitter _EventEmitter; NLMISC::CCocoaEventEmitter _EventEmitter;

@ -509,7 +509,7 @@ void CDriverGL::setMousePos(float x, float y)
{ {
H_AUTO_OGL(CDriverGL_setMousePos) H_AUTO_OGL(CDriverGL_setMousePos)
if (_win == EmptyWindow) if (_win == EmptyWindow || !_WindowFocus)
return; return;
sint x1 = (sint)((float)_CurrentMode.Width*x); sint x1 = (sint)((float)_CurrentMode.Width*x);
@ -612,6 +612,7 @@ bool CDriverGL::isSystemCursorInClientArea()
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
return IsWindowVisible(_win) != FALSE; return IsWindowVisible(_win) != FALSE;
#endif #endif
return _WindowFocus;
} }
else else
{ {
@ -650,7 +651,13 @@ bool CDriverGL::isSystemCursorInClientArea()
{ {
return false; return false;
} }
#elif defined(NL_OS_MAC)
// TODO: implement this
#elif defined (NL_OS_UNIX)
// TODO: implement this
#endif #endif
// TODO: probably wrong if NeL window is docked inside parent (ie QT widget)
return _WindowFocus;
} }
return true; return true;

@ -106,6 +106,13 @@ bool GlWndProc(CDriverGL *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM
driver->_WndActive = true; driver->_WndActive = true;
} }
} }
else if ((message == WM_SETFOCUS) || (message == WM_KILLFOCUS))
{
if (driver != NULL)
{
driver->_WindowFocus = (message == WM_SETFOCUS);
}
}
bool trapMessage = false; bool trapMessage = false;
if (driver->_EventEmitter.getNumEmitters() > 0) if (driver->_EventEmitter.getNumEmitters() > 0)
@ -291,6 +298,18 @@ bool GlWndProc(CDriverGL *driver, XEvent &e)
break; break;
case FocusIn:
{
driver->_WindowFocus = true;
return driver->_EventEmitter.processMessage(e);
}
case FocusOut:
{
driver->_WindowFocus = false;
return driver->_EventEmitter.processMessage(e);
}
default: default:
// Process the message by the emitter // Process the message by the emitter
@ -2681,8 +2700,11 @@ IDriver::TMessageBoxId CDriverGL::systemMessageBox (const char* message, const c
} }
nlstop; nlstop;
#else // NL_OS_WINDOWS #else // NL_OS_WINDOWS
// Call the console version! // TODO: if user did not launch from console, then program "freezes" without explanation or possibility to continue
IDriver::systemMessageBox (message, title, type, icon); //IDriver::systemMessageBox (message, title, type, icon);
// log only
printf("%s:%s\n", title, message);
nlwarning("%s: %s", title, message);
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
return okId; return okId;
} }

@ -40,5 +40,7 @@ using NL3D::CDriverGL;
- (id)initWithDriver:(CDriverGL*)driver; - (id)initWithDriver:(CDriverGL*)driver;
- (void)windowDidMove:(NSNotification*)notification; - (void)windowDidMove:(NSNotification*)notification;
- (void)windowDidBecomeKey:(NSNotification *)notification;
- (void)windowDidResignKey:(NSNotification *)notification;
@end @end

@ -55,4 +55,19 @@ static void windowDidMove(NSWindow* window, CDriverGL* driver)
windowDidMove([notification object], _driver); windowDidMove([notification object], _driver);
} }
- (void)windowDidBecomeKey:(NSNotification *)notification
{
if (!_driver)
return;
_driver->_WindowFocus = true;
}
- (void)windowDidResignKey:(NSNotification *)notification;
{
if(!_driver)
return;
_driver->_WindowFocus = false;
}
@end @end

@ -492,7 +492,7 @@ static void computeRastersUnion(const CPolygon2D::TRasterVect &inRaster0, CPolyg
{ {
if (inRaster1.empty()) if (inRaster1.empty())
{ {
outRaster.empty(); outRaster.clear();
finalMinY = -1; finalMinY = -1;
return; return;
} }

@ -134,13 +134,13 @@ void CForm::write (xmlDocPtr doc, const std::string &filename)
} }
// Write elements // Write elements
Elements.write (node, this, NULL, true); Elements.write (node, this, std::string(), true);
// Write held elements // Write held elements
uint i; uint i;
for (i=0; i<HeldElementCount; i++) for (i=0; i<HeldElementCount; i++)
{ {
HeldElements[i]->write (node, this, NULL, true); HeldElements[i]->write (node, this, std::string(), true);
} }
// Header // Header
@ -273,7 +273,7 @@ void CForm::write (NLMISC::IStream &stream)
xmlStream.init (&stream); xmlStream.init (&stream);
// Write the file // Write the file
write (xmlStream.getDocument (), NULL); write (xmlStream.getDocument (), std::string());
} }
// *************************************************************************** // ***************************************************************************

@ -599,7 +599,7 @@ bool CType::getValue (string &result, const CForm *form, const CFormElmAtom *nod
else if (evaluate == UFormElm::Eval) else if (evaluate == UFormElm::Eval)
{ {
// Evaluate numerical expression // Evaluate numerical expression
if ((Type == Double) || (Type == SignedInt) || (Type == UnsignedInt) || (Type == UnsignedInt)) if ((Type == Double) || (Type == SignedInt) || (Type == UnsignedInt))
{ {
// Evaluate predefinition // Evaluate predefinition
uint i; uint i;

@ -49,7 +49,7 @@ namespace NLGUI
_Aligned = 1; _Aligned = 1;
_TrackPos = 0; _TrackPos = 0;
_TrackDispPos = 0; _TrackDispPos = 0;
_TrackSize = _TrackSizeMin = 16; _TrackSize = _TrackSizeMin = 8;
_Min = 0; _Min = 0;
_Max = 100; _Max = 100;
_Value = 0; _Value = 0;
@ -1348,6 +1348,7 @@ namespace NLGUI
} }
else else
{ {
hs[hsIndex] = Hotspot_Bx;
CLuaIHM::fails(ls, "%s : couldn't parse hotspot for vertical scrollbar", funcName); CLuaIHM::fails(ls, "%s : couldn't parse hotspot for vertical scrollbar", funcName);
} }
} }
@ -1369,6 +1370,7 @@ namespace NLGUI
} }
else else
{ {
hs[hsIndex] = Hotspot_xL;
CLuaIHM::fails(ls, "%s : couldn't parse hotspot for horizontal scrollbar", funcName); CLuaIHM::fails(ls, "%s : couldn't parse hotspot for horizontal scrollbar", funcName);
} }
} }

@ -179,6 +179,7 @@ namespace NLGUI
while (limitingParent && (limitingParent->getResizeFromChildH() || dynamic_cast<CGroupList *>(limitingParent))) while (limitingParent && (limitingParent->getResizeFromChildH() || dynamic_cast<CGroupList *>(limitingParent)))
limitingParent = limitingParent->getParent(); limitingParent = limitingParent->getParent();
nlassert(limitingParent);
getParentContainer()->setH(col->getH() + getParentContainer()->getHReal() - limitingParent->getHReal()); getParentContainer()->setH(col->getH() + getParentContainer()->getHReal() - limitingParent->getHReal());
} }
} }

@ -622,12 +622,29 @@ namespace NLGUI
{ {
std::string parentId; std::string parentId;
if( value != "parent" ){ if (value != "parent")
{
if (_Parent != NULL) if (_Parent != NULL)
{
parentId = _Parent->getId() + ":" + value; parentId = _Parent->getId() + ":" + value;
}
else
{
parentId = "ui:" + value;
}
}
else else
{
if (_Parent)
{
parentId = _Parent->getId(); parentId = _Parent->getId();
} }
else
{
parentId = value;
}
}
CWidgetManager::getInstance()->getParser()->addParentSizeMaxAssociation(this, parentId); CWidgetManager::getInstance()->getParser()->addParentSizeMaxAssociation(this, parentId);
return; return;
} }
@ -1523,6 +1540,7 @@ namespace NLGUI
for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++)
{ {
CViewBase *pIE = *ite; CViewBase *pIE = *ite;
nlassert(pIE);
if (pIE->getActive()) if (pIE->getActive())
{ {
const CInterfaceElement *el = pIE->getParentPos() ? pIE->getParentPos() : pIE->getParent(); const CInterfaceElement *el = pIE->getParentPos() ? pIE->getParentPos() : pIE->getParent();

@ -667,6 +667,7 @@ namespace NLGUI
string elt = Target.substr(0,Target.rfind(':')); string elt = Target.substr(0,Target.rfind(':'));
CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(elt); CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(elt);
CInterfaceGroup *pIG = dynamic_cast<CInterfaceGroup*>(pIE); CInterfaceGroup *pIG = dynamic_cast<CInterfaceGroup*>(pIE);
nlassert(pIE);
if (pIG == NULL) if (pIG == NULL)
pIG = pIE->getParent(); pIG = pIE->getParent();

@ -741,7 +741,7 @@ namespace NLGUI
} }
// because this is a method, first parameter is the 'this' // because this is a method, first parameter is the 'this'
CReflectableRefPtrTarget *pRPT = getReflectableOnStack(*state, 1); CReflectableRefPtrTarget *pRPT = getReflectableOnStack(*state, 1);
if (pRPT == NULL) if (!pRPT)
{ {
state->push(NLMISC::toString("Error while calling lua method %s:%s : 'self' pointer is nil or of bad type, can't make the call.", state->push(NLMISC::toString("Error while calling lua method %s:%s : 'self' pointer is nil or of bad type, can't make the call.",
prop->ParentClass->ClassName.c_str(), prop->Name.c_str()) prop->ParentClass->ClassName.c_str(), prop->Name.c_str())
@ -752,6 +752,8 @@ namespace NLGUI
state->remove(1); // remove 'self' reference from parameters stack state->remove(1); // remove 'self' reference from parameters stack
// //
sint numResults = 0; sint numResults = 0;
if (pRPT)
{
sint initialStackSize = state->getTop(); sint initialStackSize = state->getTop();
try try
{ {
@ -766,6 +768,7 @@ namespace NLGUI
// TODO : see if this is safe to call lua error there" ... (it does a long jump) // TODO : see if this is safe to call lua error there" ... (it does a long jump)
lua_error(ls); lua_error(ls);
} }
}
return numResults; return numResults;
} }
@ -787,6 +790,7 @@ namespace NLGUI
CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1);
std::string script; std::string script;
ls.toString(2, script); ls.toString(2, script);
nlassert(pIE);
// must be a group // must be a group
CInterfaceGroup *group= dynamic_cast<CInterfaceGroup*>(pIE); CInterfaceGroup *group= dynamic_cast<CInterfaceGroup*>(pIE);
@ -845,6 +849,7 @@ namespace NLGUI
std::string dbList, script; std::string dbList, script;
ls.toString(2, dbList); ls.toString(2, dbList);
ls.toString(3, script); ls.toString(3, script);
nlassert(pIE);
// must be a group // must be a group
CInterfaceGroup *group= dynamic_cast<CInterfaceGroup*>(pIE); CInterfaceGroup *group= dynamic_cast<CInterfaceGroup*>(pIE);
@ -873,6 +878,7 @@ namespace NLGUI
CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1);
std::string dbList; std::string dbList;
ls.toString(2, dbList); ls.toString(2, dbList);
nlassert(pIE);
// must be a group // must be a group
CInterfaceGroup *group= dynamic_cast<CInterfaceGroup*>(pIE); CInterfaceGroup *group= dynamic_cast<CInterfaceGroup*>(pIE);

@ -887,7 +887,7 @@ namespace NLGUI
while (!iFile.eof()) while (!iFile.eof())
{ {
iFile.getline (bufTmp, 256); iFile.getline (bufTmp, 256);
sscanf (bufTmp, "%s %f %f %f %f", tgaName, &uvMinU, &uvMinV, &uvMaxU, &uvMaxV); sscanf (bufTmp, "%s %f %f %f %f", tgaName, &uvMinU, &uvMinV, &uvMaxU, &uvMaxV); // FIXME: Return value ignored, tgaName may be uninitialized
SImage image; SImage image;
image.UVMin.U = uvMinU; image.UVMin.U = uvMinU;
image.UVMin.V = uvMinV; image.UVMin.V = uvMinV;

@ -2387,6 +2387,7 @@ namespace NLGUI
// make sure all parent windows are active // make sure all parent windows are active
CCtrlBase *cb = getCaptureKeyboard(); CCtrlBase *cb = getCaptureKeyboard();
CGroupContainer *lastContainer = NULL; CGroupContainer *lastContainer = NULL;
nlassert(cb);
for(;;) for(;;)
{ {
CGroupContainer *gc = dynamic_cast<CGroupContainer *>(cb); CGroupContainer *gc = dynamic_cast<CGroupContainer *>(cb);
@ -3241,6 +3242,7 @@ namespace NLGUI
for( j = 0; j < mg.Group->getNumGroup(); j++ ) for( j = 0; j < mg.Group->getNumGroup(); j++ )
{ {
CInterfaceGroup *g = mg.Group->getGroup( j ); CInterfaceGroup *g = mg.Group->getGroup( j );
nlassert(g);
if( dynamic_cast< CGroupModal* >( g ) != NULL ) if( dynamic_cast< CGroupModal* >( g ) != NULL )
continue; continue;

@ -1255,6 +1255,7 @@ const IPrimitive *IPrimitive::getPrimitive (const std::string &absoluteOrRelativ
for (childIndex=0;childIndex<cursor->getNumChildren();childIndex++) for (childIndex=0;childIndex<cursor->getNumChildren();childIndex++)
{ {
cursor->getChild(child,childIndex); cursor->getChild(child,childIndex);
nlassert(child);
string name; string name;
if ( child->getPropertyByName("class", name) if ( child->getPropertyByName("class", name)
&& toUpper(name)==childName ) && toUpper(name)==childName )

@ -2046,7 +2046,7 @@ void CBitmap::resamplePicture32 (const NLMISC::CRGBA *pSrc, NLMISC::CRGBA *pDest
sint32 nDestWidth, sint32 nDestHeight) sint32 nDestWidth, sint32 nDestHeight)
{ {
//logResample("RP32: 0 pSrc=%p pDest=%p, Src=%d x %d Dest=%d x %d", pSrc, pDest, nSrcWidth, nSrcHeight, nDestWidth, nDestHeight); //logResample("RP32: 0 pSrc=%p pDest=%p, Src=%d x %d Dest=%d x %d", pSrc, pDest, nSrcWidth, nSrcHeight, nDestWidth, nDestHeight);
if ((nSrcWidth<=0)||(nSrcHeight<=0)||(nDestHeight<=0)||(nDestHeight<=0)) if ((nSrcWidth<=0)||(nSrcHeight<=0)||(nDestWidth<=0)||(nDestHeight<=0))
return; return;
// If we're reducing it by 2, call the fast resample // If we're reducing it by 2, call the fast resample
@ -2268,7 +2268,7 @@ void CBitmap::resamplePicture8 (const uint8 *pSrc, uint8 *pDest,
sint32 nDestWidth, sint32 nDestHeight) sint32 nDestWidth, sint32 nDestHeight)
{ {
//logResample("RP8: 0 pSrc=%p pDest=%p, Src=%d x %d Dest=%d x %d", pSrc, pDest, nSrcWidth, nSrcHeight, nDestWidth, nDestHeight); //logResample("RP8: 0 pSrc=%p pDest=%p, Src=%d x %d Dest=%d x %d", pSrc, pDest, nSrcWidth, nSrcHeight, nDestWidth, nDestHeight);
if ((nSrcWidth<=0)||(nSrcHeight<=0)||(nDestHeight<=0)||(nDestHeight<=0)) if ((nSrcWidth<=0)||(nSrcHeight<=0)||(nDestWidth<=0)||(nDestHeight<=0))
return; return;
// If we're reducing it by 2, call the fast resample // If we're reducing it by 2, call the fast resample

@ -449,7 +449,7 @@ public:
EDebug() { _Reason = "Nothing about EDebug"; } EDebug() { _Reason = "Nothing about EDebug"; }
virtual ~EDebug() throw() {} virtual ~EDebug() NL_OVERRIDE {}
EDebug(EXCEPTION_POINTERS * pexp) : m_pexp(pexp) { nlassert(pexp != 0); createWhat(); } EDebug(EXCEPTION_POINTERS * pexp) : m_pexp(pexp) { nlassert(pexp != 0); createWhat(); }
EDebug(const EDebug& se) : m_pexp(se.m_pexp) { createWhat(); } EDebug(const EDebug& se) : m_pexp(se.m_pexp) { createWhat(); }
@ -863,9 +863,10 @@ public:
cleanType (type, displayType); cleanType (type, displayType);
char tmp[1024]; char tmp[1024];
tmp[0]='\0';
if(type == "void") if(type == "void")
{ {
tmp[0]='\0'; // tmp[0]='\0';
} }
else if(type == "int") else if(type == "int")
{ {
@ -1716,6 +1717,7 @@ NLMISC_CATEGORISED_COMMAND(nel, writeaccess, "write a uint8 value in an invalid
#endif #endif
} }
if(args.size() >= 2) NLMISC::fromString(args[1], val); if(args.size() >= 2) NLMISC::fromString(args[1], val);
nlassume(adr);
*adr = val; *adr = val;
return true; return true;
} }
@ -1736,6 +1738,7 @@ NLMISC_CATEGORISED_COMMAND(nel, readaccess, "read a uint8 value in an invalid ad
adr = (uint8*)addr32; adr = (uint8*)addr32;
#endif #endif
} }
nlassume(adr);
val = *adr; val = *adr;
log.displayNL("value is %hu", (uint16)val); log.displayNL("value is %hu", (uint16)val);
return true; return true;

@ -570,7 +570,7 @@ string CEntityIdTranslator::getUserName (uint32 uid)
return entity.UserName; return entity.UserName;
} }
} }
return 0; return string();
} }
void CEntityIdTranslator::getEntityIdInfo (const CEntityId &eid, ucstring &entityName, sint8 &entitySlot, uint32 &uid, string &userName, bool &online, std::string* additional) void CEntityIdTranslator::getEntityIdInfo (const CEntityId &eid, ucstring &entityName, sint8 &entitySlot, uint32 &uid, string &userName, bool &online, std::string* additional)

@ -171,8 +171,7 @@ bool CIXml::init (IStream &stream)
// Try binary mode // Try binary mode
if (_TryBinaryMode) if (_TryBinaryMode)
{ {
string header; char header[4];
header.resize(4);
header[0] = buffer[0]; header[0] = buffer[0];
header[1] = buffer[1]; header[1] = buffer[1];
header[2] = buffer[2]; header[2] = buffer[2];
@ -180,7 +179,7 @@ bool CIXml::init (IStream &stream)
toLower(header); toLower(header);
// Does it a xml stream ? // Does it a xml stream ?
if (header != "<?xm") if (!strcmp(header, "<?xm"))
{ {
// NO ! Go in binary mode // NO ! Go in binary mode
_BinaryStream = &stream; _BinaryStream = &stream;

@ -1421,6 +1421,7 @@ bool CSystemInfo::hasHyperThreading()
// get vendor string from cpuid // get vendor string from cpuid
char vendor_id[32]; char vendor_id[32];
vendor_id[31] = '\0';
memset(vendor_id, 0, sizeof(vendor_id)); memset(vendor_id, 0, sizeof(vendor_id));
nlcpuid(CPUInfo, 0); nlcpuid(CPUInfo, 0);
memcpy(vendor_id, &CPUInfo[1], sizeof(sint32)); memcpy(vendor_id, &CPUInfo[1], sizeof(sint32));

@ -168,12 +168,12 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
str += *pos2; str += *pos2;
} }
*pos2++; pos2++;
} }
// eat the \n // eat the \n
if (*pos2 == '\n') if (*pos2 == '\n')
*pos2++; pos2++;
if (!str.empty()) if (!str.empty())
{ {

@ -212,6 +212,7 @@ void followBorder(CInteriorSurface &surface, uint first, uint edge, uint sens, v
else else
{ {
// if the next element is inside the surface, then go to the next element // if the next element is inside the surface, then go to the next element
nlassert(next);
nlassert(next->InternalSurface == currentSurfId); nlassert(next->InternalSurface == currentSurfId);
for (oedge=0; oedge<3 && next->Edge[oedge]!=currentFace; ++oedge) for (oedge=0; oedge<3 && next->Edge[oedge]!=currentFace; ++oedge)

@ -533,7 +533,7 @@ std::string rz_crypt(register const char *key, register const char *setting, cha
keyblock.b[i] = t; keyblock.b[i] = t;
} }
if (rz_des_setkey((char *)keyblock.b)) /* also initializes "a64toi" */ if (rz_des_setkey((char *)keyblock.b)) /* also initializes "a64toi" */
return (NULL); return std::string();
encp = &cryptresult[0]; encp = &cryptresult[0];
switch (*setting) { switch (*setting) {
@ -544,14 +544,14 @@ std::string rz_crypt(register const char *key, register const char *setting, cha
while (*key) { while (*key) {
if (rz_des_cipher((char *)&keyblock, if (rz_des_cipher((char *)&keyblock,
(char *)&keyblock, 0L, 1)) (char *)&keyblock, 0L, 1))
return (NULL); return std::string();
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
if ((t = 2*(unsigned char)(*key)) != 0) if ((t = 2*(unsigned char)(*key)) != 0)
key++; key++;
keyblock.b[i] ^= t; keyblock.b[i] ^= t;
} }
if (rz_des_setkey((char *)keyblock.b)) if (rz_des_setkey((char *)keyblock.b))
return (NULL); return std::string();
} }
*encp++ = *setting++; *encp++ = *setting++;
@ -583,7 +583,7 @@ std::string rz_crypt(register const char *key, register const char *setting, cha
encp += salt_size; encp += salt_size;
if (rz_des_cipher((char *)&constdatablock, (char *)&rsltblock, if (rz_des_cipher((char *)&constdatablock, (char *)&rsltblock,
salt, num_iter)) salt, num_iter))
return ""; return std::string();
/* /*
* Encode the 64 cipher bits as 11 ascii characters. * Encode the 64 cipher bits as 11 ascii characters.

@ -1763,6 +1763,7 @@ void CMirroredDataSet::getValueToString( const TDataSetRow& entityIndex, TPro
} }
default: default:
result = toString( "<Invalid type> (%s/E%d/P%hd)", name().c_str(), entityIndex.getIndex(), propIndex ); result = toString( "<Invalid type> (%s/E%d/P%hd)", name().c_str(), entityIndex.getIndex(), propIndex );
return;
} }
result = string(tmpStr); result = string(tmpStr);
} }

@ -1120,7 +1120,7 @@ CObject* CObjectTable::clone() const
TContainer::const_iterator first(_Value.begin()), last(_Value.end()); TContainer::const_iterator first(_Value.begin()), last(_Value.end());
for ( ;first != last; ++first ) for ( ;first != last; ++first )
{ {
BOMB_IF(!first->second, "Try to clone a table with an NULL component", return 0) BOMB_IF(!first->second, "Try to clone a table with an NULL component", return 0);
nlassert(first->second->getGhost() == this->getGhost()); nlassert(first->second->getGhost() == this->getGhost());
CObject* clone = first->second->clone(); CObject* clone = first->second->clone();
if (clone) { clone->setParent(0); } if (clone) { clone->setParent(0); }
@ -1480,7 +1480,7 @@ bool CObjectTable::canTake(sint32 position) const
{ {
CObject* parent = getParent(); CObject* parent = getParent();
if (parent) //try to take the root of a tree if (!parent) //try to take the root of a tree
{ {
return true; return true;
} }

@ -667,11 +667,12 @@ void CAttributeToProperty::setAiStateName(const std::string& prefix)
std::string name; std::string name;
CObject* tmp=_Object->getAttr("Id"); CObject* tmp=_Object->getAttr("Id");
if( !(tmp&&tmp->isString())&&((name = tmp->toString()).length()!=0)) if (!tmp || !tmp->isString())
{ {
nlwarning("R2Ani: invalide rtData"); nlwarning("R2Ani: invalide rtData");
return; return;
} }
name = tmp->toString();
_Primitive->addPropertyByName("name", new CPropertyString(prefix + name)); _Primitive->addPropertyByName("name", new CPropertyString(prefix + name));

@ -424,7 +424,7 @@ inline void CTimerEvent::set(CTimer* owner,NLMISC::TGameCycle time,uint32 variat
_Time = time + i; _Time = time + i;
} }
} }
BOMB_IF(best==NULL,"BUG: This can never happen!",return) BOMB_IF(best == NULL, "BUG: This can never happen!", return);
best->push_back(this); best->push_back(this);
} }
@ -452,7 +452,7 @@ inline void CTimerEvent::clear()
inline void CTimerEvent::processEvent() inline void CTimerEvent::processEvent()
{ {
CTimer* owner=_Owner; CTimer* owner=_Owner;
BOMB_IF(owner==NULL,"Attempt to process an event that no longer has a valid owner",return) BOMB_IF(owner == NULL, "Attempt to process an event that no longer has a valid owner", return);
// mark the event as expired - the state may be chnaged during the timer callback... // mark the event as expired - the state may be chnaged during the timer callback...
// NOTE: This operation results in '_Owner' being set to NULL // NOTE: This operation results in '_Owner' being set to NULL

@ -122,8 +122,8 @@ inline ucstring capitalize(const ucstring & s)
#define GIVEUP_IF(condition,msg,action) if (!(condition));else GIVEUP(msg,action) #define GIVEUP_IF(condition,msg,action) if (!(condition));else GIVEUP(msg,action)
#define WARN_IF(condition,msg) if (!(condition));else WARN(msg) #define WARN_IF(condition,msg) if (!(condition));else WARN(msg)
#define DROP_IF(condition,msg,action) if (!(condition));else DROP(msg,action) #define DROP_IF(condition,msg,action) if (!(condition));else DROP(msg,action)
#define BOMB_IF(condition,msg,action) if (!(condition));else BOMB(msg,action) #define BOMB_IF(condition,msg,action) if (!(condition));else BOMB(msg,action); do { nlassume(condition); } while (0)
#define STOP_IF(condition,msg) if (!(condition));else STOP(msg) #define STOP_IF(condition,msg) if (!(condition));else STOP(msg); do { nlassume(condition); } while (0)
// testing for variable value changes // testing for variable value changes
#define ON_CHANGE(type,var,code)\ #define ON_CHANGE(type,var,code)\

Loading…
Cancel
Save