Merge with develop

--HG--
branch : compatibility-develop
hg/compatibility-develop
kervala 10 years ago
commit 97eac497ff

@ -112,16 +112,20 @@ IF(WITH_STATIC_LIBXML2)
SET(LIBXML2_DEFINITIONS ${LIBXML2_DEFINITIONS} -DLIBXML_STATIC)
ENDIF(WITH_STATIC_LIBXML2)
IF(WITH_LIBXML2_ICONV)
FIND_PACKAGE(Iconv REQUIRED)
INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${ICONV_LIBRARIES})
ENDIF(WITH_LIBXML2_ICONV)
IF(WITH_STATIC)
# libxml2 could need winsock2 library
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${WINSOCK2_LIB})
# on Mac OS X libxml2 requires iconv and liblzma
IF(APPLE)
FIND_PACKAGE(Iconv REQUIRED)
FIND_PACKAGE(LibLZMA REQUIRED)
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${ICONV_LIBRARIES} ${LIBLZMA_LIBRARIES})
INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${LIBLZMA_LIBRARIES})
ENDIF(APPLE)
ENDIF(WITH_STATIC)
@ -152,9 +156,11 @@ IF(WITH_NEL)
FIND_PACKAGE(Luabind REQUIRED)
FIND_PACKAGE(CURL REQUIRED)
IF(WIN32 OR CURL_LIBRARIES MATCHES "\\.a")
IF((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL)
SET(CURL_STATIC ON)
ENDIF(WIN32 OR CURL_LIBRARIES MATCHES "\\.a")
ELSE((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL)
SET(CURL_STATIC OFF)
ENDIF((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL)
IF(CURL_STATIC)
SET(CURL_DEFINITIONS -DCURL_STATICLIB)

@ -1,4 +1,4 @@
# - Try to find Iconv on Mac OS X
# - Try to find Iconv
# Once done this will define
#
# ICONV_FOUND - system has Iconv
@ -6,78 +6,59 @@
# ICONV_LIBRARIES - Link these to use Iconv
# ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
#
include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
IF(APPLE)
include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
# Already in cache, be silent
SET(ICONV_FIND_QUIETLY TRUE)
ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
IF(APPLE)
FIND_PATH(ICONV_INCLUDE_DIR iconv.h
PATHS
/opt/local/include/
NO_CMAKE_SYSTEM_PATH
)
FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv c
PATHS
/opt/local/lib/
NO_CMAKE_SYSTEM_PATH
)
ENDIF(APPLE)
FIND_PATH(ICONV_INCLUDE_DIR iconv.h PATHS /opt/local/include /sw/include)
string(REGEX REPLACE "(.*)/include/?" "\\1" ICONV_INCLUDE_BASE_DIR "${ICONV_INCLUDE_DIR}")
FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv c HINTS "${ICONV_INCLUDE_BASE_DIR}/lib" PATHS /opt/local/lib)
IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
SET(ICONV_FOUND TRUE)
ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
IF(ICONV_FOUND)
check_c_compiler_flag("-Werror" ICONV_HAVE_WERROR)
set (CMAKE_C_FLAGS_BACKUP "${CMAKE_C_FLAGS}")
if(ICONV_HAVE_WERROR)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif(ICONV_HAVE_WERROR)
check_c_source_compiles("
#include <iconv.h>
int main(){
iconv_t conv = 0;
const char* in = 0;
size_t ilen = 0;
char* out = 0;
size_t olen = 0;
iconv(conv, &in, &ilen, &out, &olen);
return 0;
}
" ICONV_SECOND_ARGUMENT_IS_CONST )
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_BACKUP}")
ENDIF(ICONV_FOUND)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES)
IF(ICONV_FOUND)
IF(NOT ICONV_FIND_QUIETLY)
MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
ENDIF(NOT ICONV_FIND_QUIETLY)
ELSE(ICONV_FOUND)
IF(Iconv_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Iconv")
ENDIF(Iconv_FIND_REQUIRED)
ENDIF(ICONV_FOUND)
MARK_AS_ADVANCED(
ICONV_INCLUDE_DIR
ICONV_LIBRARIES
ICONV_SECOND_ARGUMENT_IS_CONST
)
ENDIF(APPLE)
IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
# Already in cache, be silent
SET(ICONV_FIND_QUIETLY TRUE)
ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
FIND_PATH(ICONV_INCLUDE_DIR iconv.h HINTS /sw/include/ PATHS /opt/local)
FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv c PATHS /opt/local)
IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
SET(ICONV_FOUND TRUE)
ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
IF(ICONV_FOUND)
check_c_compiler_flag("-Werror" ICONV_HAVE_WERROR)
set (CMAKE_C_FLAGS_BACKUP "${CMAKE_C_FLAGS}")
if(ICONV_HAVE_WERROR)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif(ICONV_HAVE_WERROR)
check_c_source_compiles("
#include <iconv.h>
int main(){
iconv_t conv = 0;
const char* in = 0;
size_t ilen = 0;
char* out = 0;
size_t olen = 0;
iconv(conv, &in, &ilen, &out, &olen);
return 0;
}
" ICONV_SECOND_ARGUMENT_IS_CONST )
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_BACKUP}")
ENDIF(ICONV_FOUND)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES)
IF(ICONV_FOUND)
IF(NOT ICONV_FIND_QUIETLY)
MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
ENDIF(NOT ICONV_FIND_QUIETLY)
ELSE(ICONV_FOUND)
IF(Iconv_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Iconv")
ENDIF(Iconv_FIND_REQUIRED)
ENDIF(ICONV_FOUND)
MARK_AS_ADVANCED(
ICONV_INCLUDE_DIR
ICONV_LIBRARIES
ICONV_SECOND_ARGUMENT_IS_CONST
)

@ -38,7 +38,7 @@ ELSEIF(WIN32)
ENDIF(UNIX)
FIND_LIBRARY(LIBOVR_LIBRARY
NAMES ovr
NAMES ovr libovr
PATHS
$ENV{LIBOVR_DIR}/${LIBOVR_LIBRARY_BUILD_PATH}
/usr/local/lib

@ -62,7 +62,7 @@ IF(MSVC12)
IF(NOT MSVC12_REDIST_DIR)
# If you have VC++ 2013 Express, put x64/Microsoft.VC120.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC12_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC11_REDIST_DIR)
ENDIF(NOT MSVC12_REDIST_DIR)
ELSEIF(MSVC11)
DETECT_VC_VERSION("11.0")
SET(MSVC_TOOLSET "110")

@ -255,6 +255,16 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
ELSE(WITH_STATIC)
OPTION(WITH_STATIC_LIBXML2 "With static libxml2" OFF)
ENDIF(WITH_STATIC)
IF (WITH_STATIC)
OPTION(WITH_STATIC_CURL "With static curl" ON )
ELSE(WITH_STATIC)
OPTION(WITH_STATIC_CURL "With static curl" OFF)
ENDIF(WITH_STATIC)
IF(APPLE)
OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" ON )
ELSE(APPLE)
OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" OFF)
ENDIF(APPLE)
OPTION(WITH_STATIC_DRIVERS "With static drivers." OFF)
IF(WIN32)
OPTION(WITH_EXTERNAL "With provided external." ON )
@ -558,9 +568,15 @@ MACRO(NL_SETUP_BUILD)
# Ignore default include paths
ADD_PLATFORM_FLAGS("/X")
IF(MSVC11)
IF(MSVC12)
ADD_PLATFORM_FLAGS("/Gy- /MP")
# /Ox is working with VC++ 2010, but custom optimizations don't exist
# /Ox is working with VC++ 2013, but custom optimizations don't exist
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
ELSEIF(MSVC11)
ADD_PLATFORM_FLAGS("/Gy- /MP")
# /Ox is working with VC++ 2012, but custom optimizations don't exist
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
@ -582,9 +598,9 @@ MACRO(NL_SETUP_BUILD)
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 ${DEBUG_CFLAGS}")
ELSE(MSVC11)
ELSE(MSVC12)
MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}")
ENDIF(MSVC11)
ENDIF(MSVC12)
ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /Zm1000 /wd4250")

@ -83,4 +83,3 @@ IF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN)
ENDIF(WITH_NEL_TOOLS)
ADD_SUBDIRECTORY(tools)
ENDIF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN)

@ -60,7 +60,7 @@ namespace NLGUI
void setText(uint i, const ucstring &text);
void insertText(uint i, const ucstring &text);
const ucstring &getText(uint i) const;
const uint &getTextId(uint i) const;
uint getTextId(uint i) const;
uint getTextPos(uint nId) const;
const ucstring &getTexture(uint i) const;
void removeText(uint nPos);

@ -17,7 +17,6 @@
#ifndef CL_GROUP_HTML_H
#define CL_GROUP_HTML_H
#define CURL_STATICLIB 1
#include <curl/curl.h>
#include "nel/misc/types_nl.h"

@ -285,8 +285,7 @@ namespace NLGUI
class CLuaHashMapTraits
{
public:
static const size_t bucket_size = 4;
static const size_t min_buckets = 8;
enum { bucket_size = 4, min_buckets = 8, };
CLuaHashMapTraits()
{}

@ -88,6 +88,8 @@ namespace NLMISC
virtual void setNoAssert(bool noAssert) =0;
virtual bool getAlreadyCreateSharedAmongThreads() =0;
virtual void setAlreadyCreateSharedAmongThreads(bool b) =0;
virtual bool isWindowedApplication() = 0;
virtual void setWindowedApplication(bool b = true) = 0;
//@}
protected:
/// Called by derived class to finalize initialisation of context
@ -131,6 +133,8 @@ namespace NLMISC
virtual void setNoAssert(bool noAssert);
virtual bool getAlreadyCreateSharedAmongThreads();
virtual void setAlreadyCreateSharedAmongThreads(bool b);
virtual bool isWindowedApplication();
virtual void setWindowedApplication(bool b);
private:
/// Singleton registry
@ -147,6 +151,7 @@ namespace NLMISC
bool DebugNeedAssert;
bool NoAssert;
bool AlreadyCreateSharedAmongThreads;
bool WindowedApplication;
};
/** This class implements the context interface for the a library module.
@ -183,6 +188,8 @@ namespace NLMISC
virtual void setNoAssert(bool noAssert);
virtual bool getAlreadyCreateSharedAmongThreads();
virtual void setAlreadyCreateSharedAmongThreads(bool b);
virtual bool isWindowedApplication();
virtual void setWindowedApplication(bool b);
private:
/// Pointer to the application context.

@ -61,8 +61,7 @@ public:
class CClassIdHashMapTraits
{
public:
static const size_t bucket_size = 4;
static const size_t min_buckets = 8;
enum { bucket_size = 4, min_buckets = 8, };
inline size_t operator() ( const CClassId& classId ) const
{
return ((((uint64)classId >> 32)|0xFFFFFFFF) ^ (((uint64)classId|0xFFFFFFFF) & 0xFFFFFFFF));

@ -347,7 +347,7 @@ std::string formatThousands(const std::string& s);
/// This function executes a program in the background and returns instantly (used for example to launch services in AES).
/// The program will be launched in the current directory
bool launchProgram (const std::string &programName, const std::string &arguments);
bool launchProgram (const std::string &programName, const std::string &arguments, bool log = true);
/// This function kills a program using his pid (on unix, it uses the kill() POSIX function)
bool killProgram(uint32 pid);

@ -350,8 +350,10 @@ void setCrashAlreadyReported(bool state);
*/
// removed because we always check assert (even in release mode) #if defined (NL_OS_WINDOWS) && defined (NL_DEBUG)
#if defined (NL_OS_WINDOWS)
#define NLMISC_BREAKPOINT __debugbreak();
#if defined(NL_OS_WINDOWS)
#define NLMISC_BREAKPOINT __debugbreak()
#elif defined(NL_OS_UNIX) && defined(NL_COMP_GCC)
#define NLMISC_BREAKPOINT __builtin_trap()
#else
#define NLMISC_BREAKPOINT abort()
#endif

@ -22,6 +22,21 @@
#ifdef NL_OS_WINDOWS // for win32 os only
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#ifndef _WIN32_WINDOWS
# define _WIN32_WINDOWS 0x0410
#endif
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0400
#endif
#ifndef WINVER
# define WINVER 0x0400
#endif
#ifndef NOMINMAX
# define NOMINMAX
#endif
#include <windows.h>

@ -575,8 +575,7 @@ public:
// Traits for hash_map using CEntityId
struct CEntityIdHashMapTraits
{
static const size_t bucket_size = 4;
static const size_t min_buckets = 8;
enum { bucket_size = 4, min_buckets = 8, };
CEntityIdHashMapTraits() { }
size_t operator() (const NLMISC::CEntityId &id ) const
{

@ -42,11 +42,7 @@ class CGtkDisplayer : public NLMISC::CWindowDisplayer
{
public:
CGtkDisplayer (const char *displayerName = "") : CWindowDisplayer(displayerName)
{
needSlashR = false;
createLabel ("@Clear|CLEAR");
}
CGtkDisplayer (const char *displayerName = "");
virtual ~CGtkDisplayer ();

@ -27,6 +27,21 @@
#include "nel/misc/mem_stream.h"
#include "nel/misc/dummy_window.h"
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#ifndef _WIN32_WINDOWS
# define _WIN32_WINDOWS 0x0410
#endif
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0400
#endif
#ifndef WINVER
# define WINVER 0x0400
#endif
#ifndef NOMINMAX
# define NOMINMAX
#endif
#include <windows.h>
namespace NLMISC

@ -21,25 +21,38 @@
namespace NLMISC {
/** Display a custom message box.
#if FINAL_VERSION
#define NL_REPORT_SYNCHRONOUS false
#define NL_REPORT_DEFAULT NLMISC::ReportAbort
#else
#define NL_REPORT_SYNCHRONOUS true
#define NL_REPORT_DEFAULT NLMISC::ReportBreak
#endif
enum TReportResult
{
// See also crash_report_widget.h EReturnValue
ReportAlwaysIgnore = 21,
ReportIgnore = 22,
ReportAbort = 23,
ReportBreak = 24
};
/** Display a crash report
*
* \param title set the title of the report. If empty, it'll display "NeL report".
* \param header message displayed before the edit text box. If empty, it displays the default message.
* \param body message displayed in the edit text box. This string will be sent by email.
* \param debugButton 0 for disabling it, 1 for enable with default behaviors (generate a breakpoint), 2 for enable with no behavior
* \param title set the title of the report. If empty, it'll display "NeL report"
* \param subject extended title of the report
* \param body message displayed in the edit text box. This string will be sent to the crash report tool
* \param attachment binary file to attach. This is a filename
* \param synchronous use system() and wait for the crash tool exit code, passes -dev flag; otherwise return defaultResult immediately
* \param sendReport hide 'dont send' button, or auto enable 'send report' checkbox
*
*
*
* \return the button clicked or error
* \return the button clicked or defaultResult
*/
TReportResult report(const std::string &title, const std::string &subject, const std::string &body, const std::string &attachment, bool synchronous, bool sendReport, TReportResult defaultResult);
enum TReportResult { ReportDebug, ReportIgnore, ReportQuit, ReportError };
TReportResult report (const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const std::string &attachedFile = "");
/** call this in the main of your appli to enable email: setReportEmailFunction (sendEmail);
*/
void setReportEmailFunction (void *emailFunction);
/// Set the Url of the web service used to post crash reports to. String is copied
void setReportPostUrl(const char *postUrl);
} // NLMISC

@ -248,8 +248,7 @@ private :
class CSheetIdHashMapTraits
{
public:
static const size_t bucket_size = 4;
static const size_t min_buckets = 8;
enum { bucket_size = 4, min_buckets = 8, };
inline size_t operator() ( const CSheetId& sheetId ) const
{
return sheetId.asInt() >> 5;

@ -937,21 +937,21 @@ inline CSString operator+(const CSString& s0,const CSString& s1)
*/
inline CSString operator+(char s0,const CSString& s1)
{
return CSString(s0)+s1;
return CSString(s0) + s1.c_str();
}
inline CSString operator+(const char* s0,const CSString& s1)
{
return CSString(s0)+s1;
return CSString(s0) + s1.c_str();
}
#ifndef NL_COMP_VC10
#if !defined(NL_COMP_VC) || (NL_COMP_VC_VERSION <= 100)
// TODO: check if it can be disabled for other compilers too
inline CSString operator+(const std::string& s0,const CSString& s1)
{
return s0+static_cast<const std::string&>(s1);
}
#endif // NL_COMP_VC10
#endif
} // NLMISC

@ -264,6 +264,40 @@ inline bool fromString(const std::string &str, bool &val)
return true;
}
inline bool fromString(const char *str, uint32 &val) { if (strstr(str, "-") != NULL) { val = 0; return false; } char *end; unsigned long v; errno = 0; v = strtoul(str, &end, 10); if (errno || v > UINT_MAX || end == str) { val = 0; return false; } else { val = (uint32)v; return true; } }
inline bool fromString(const char *str, sint32 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > INT_MAX || v < INT_MIN || end == str) { val = 0; return false; } else { val = (sint32)v; return true; } }
inline bool fromString(const char *str, uint8 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > UCHAR_MAX || v < 0 || end == str) { val = 0; return false; } else { val = (uint8)v; return true; } }
inline bool fromString(const char *str, sint8 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > SCHAR_MAX || v < SCHAR_MIN || end == str) { val = 0; return false; } else { val = (sint8)v; return true; } }
inline bool fromString(const char *str, uint16 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > USHRT_MAX || v < 0 || end == str) { val = 0; return false; } else { val = (uint16)v; return true; } }
inline bool fromString(const char *str, sint16 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > SHRT_MAX || v < SHRT_MIN || end == str) { val = 0; return false; } else { val = (sint16)v; return true; } }
inline bool fromString(const char *str, uint64 &val) { bool ret = sscanf(str, "%"NL_I64"u", &val) == 1; if (!ret) val = 0; return ret; }
inline bool fromString(const char *str, sint64 &val) { bool ret = sscanf(str, "%"NL_I64"d", &val) == 1; if (!ret) val = 0; return ret; }
inline bool fromString(const char *str, float &val) { bool ret = sscanf(str, "%f", &val) == 1; if (!ret) val = 0.0f; return ret; }
inline bool fromString(const char *str, double &val) { bool ret = sscanf(str, "%lf", &val) == 1; if (!ret) val = 0.0; return ret; }
inline bool fromString(const char *str, bool &val)
{
switch (str[0])
{
case '1':
case 't':
case 'y':
case 'T':
case 'Y':
val = true;
return true;
case '0':
case 'f':
case 'n':
case 'F':
case 'N':
val = false;
return true;
}
return false;
}
inline bool fromString(const std::string &str, std::string &val) { val = str; return true; }
// stl vectors of bool use bit reference and not real bools, so define the operator for bit reference

@ -39,8 +39,7 @@ typedef const std::string *TStringId;
// Traits for hash_map using CStringId
struct CStringIdHashMapTraits
{
static const size_t bucket_size = 4;
static const size_t min_buckets = 8;
enum { bucket_size = 4, min_buckets = 8, };
CStringIdHashMapTraits() { }
size_t operator() (const NLMISC::TStringId &stringId) const
{

@ -77,6 +77,10 @@ public:
/// Get desktop current color depth without using UDriver.
static uint getCurrentColorDepth();
/// Detect whether the current process is a windowed application. Return true if definitely yes, false if unknown
static bool detectWindowedApplication();
};
} // NLMISC

@ -53,7 +53,10 @@
# endif
# ifdef _MSC_VER
# define NL_COMP_VC
# if _MSC_VER >= 1700
# if _MSC_VER >= 1800
# define NL_COMP_VC12
# define NL_COMP_VC_VERSION 120
# elif _MSC_VER >= 1700
# define NL_COMP_VC11
# define NL_COMP_VC_VERSION 110
# elif _MSC_VER >= 1600
@ -414,6 +417,12 @@ extern void operator delete[](void *p) throw();
# define CHashMap stdext::hash_map
# define CHashSet stdext::hash_set
# define CHashMultiMap stdext::hash_multimap
#elif defined(NL_COMP_VC) && (NL_COMP_VC_VERSION >= 120)
# include <hash_map>
# include <hash_set>
# define CHashMap ::std::hash_map
# define CHashSet ::std::hash_set
# define CHashMultiMap ::std::hash_multimap
#elif defined(NL_COMP_GCC) // GCC4
# include <ext/hash_map>
# include <ext/hash_set>
@ -454,7 +463,11 @@ typedef uint16 ucchar;
// To define a 64bits constant; ie: UINT64_CONSTANT(0x123456781234)
#ifdef NL_COMP_VC
# if (NL_COMP_VC_VERSION >= 80)
# if (NL_COMP_VC_VERSION >= 120)
# define INT64_CONSTANT(c) (c##LL)
# define SINT64_CONSTANT(c) (c##LL)
# define UINT64_CONSTANT(c) (c##ULL)
# elif (NL_COMP_VC_VERSION >= 80)
# define INT64_CONSTANT(c) (c##LL)
# define SINT64_CONSTANT(c) (c##LL)
# define UINT64_CONSTANT(c) (c##LL)

@ -355,8 +355,7 @@ namespace NLMISC
// Traits for hash_map using CEntityId
struct CUCStringHashMapTraits
{
static const size_t bucket_size = 4;
static const size_t min_buckets = 8;
enum { bucket_size = 4, min_buckets = 8, };
CUCStringHashMapTraits() { }
size_t operator() (const ucstring &id ) const
{

@ -21,8 +21,19 @@
#ifdef NL_OS_WINDOWS
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#ifndef NL_COMP_MINGW
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#ifndef _WIN32_WINDOWS
# define _WIN32_WINDOWS 0x0410
#endif
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0400
#endif
#ifndef WINVER
# define WINVER 0x0400
#endif
#ifndef NOMINMAX
# define NOMINMAX
#endif
#include <windows.h>
@ -46,11 +57,7 @@ class CWinDisplayer : public NLMISC::CWindowDisplayer
{
public:
CWinDisplayer (const char *displayerName = "") : CWindowDisplayer(displayerName), Exit(false)
{
needSlashR = true;
createLabel ("@Clear|CLEAR");
}
CWinDisplayer(const char *displayerName = "");
virtual ~CWinDisplayer ();

@ -31,7 +31,7 @@ public:
~CXMLAutoPtr() { destroy(); }
operator const char *() const { return _Value; }
operator bool() const { return _Value != NULL; }
operator std::string() const { return std::string(_Value); }
inline std::string str() const { return _Value; }
bool operator ! () const { return _Value == NULL; }
operator const unsigned char *() const { return (const unsigned char *) _Value; }
char operator * () const { nlassert(_Value); return *_Value; }

@ -42,8 +42,7 @@ namespace NLSOUND {
template <class Pointer>
struct THashPtr : public std::unary_function<const Pointer &, size_t>
{
static const size_t bucket_size = 4;
static const size_t min_buckets = 8;
enum { bucket_size = 4, min_buckets = 8, };
size_t operator () (const Pointer &ptr) const
{
//CHashSet<uint>::hasher h;

@ -82,8 +82,7 @@ struct CContextMatcher
struct CHash : public std::unary_function<CContextMatcher, size_t>
{
static const size_t bucket_size = 4;
static const size_t min_buckets = 8;
enum { bucket_size = 4, min_buckets = 8, };
size_t operator () (const CContextMatcher &patternMatcher) const
{
return patternMatcher.getHashValue();

@ -18,11 +18,16 @@
#include <stdlib.h>
// contains all debug features
#include "nel/misc/debug.h"
#include <nel/misc/debug.h>
#include <nel/misc/report.h>
using namespace NLMISC;
void repeatederror()
{
// hit always ignore to surpress this error for the duration of the program
nlassert(false && "hit always ignore");
}
int main (int /* argc */, char ** /* argv */)
int main(int /* argc */, char ** /* argv */)
{
// all debug functions have different behaviors in debug and in release mode.
// in general, in debug mode, all debug functions are active, they display
@ -36,20 +41,24 @@ int main (int /* argc */, char ** /* argv */)
// in release mode, this function does nothing by default. you have to add a displayer
// manually, or put true in the parameter to say to the function that you want it to
// add the default displayers
createDebug ();
NLMISC::createDebug();
// enable the crash report tool
NLMISC::INelContext::getInstance().setWindowedApplication(true);
NLMISC::setReportPostUrl("http://ryzomcore.org/crash_report/");
// display debug information, that will be skipped in release mode.
nldebug ("nldebug() %d", 1);
nldebug("nldebug() %d", 1);
// display the string
nlinfo ("nlinfo() %d", 2);
nlinfo("nlinfo() %d", 2);
// when something not normal, but that the program can manage, occurs, call nlwarning()
nlwarning ("nlwarning() %d", 3);
nlwarning("nlwarning() %d", 3);
// nlassert() is like assert but do more powerful things. in release mode, the test is
// not executed and nothing will happen. (Press F5 in Visual C++ to continue the execution)
nlassert (true == false);
nlassert(true == false);
// in a switch case or when you want that the program never executes a part of code, use stop.
// in release, nlstop does nothing. in debug mode,
@ -61,16 +70,20 @@ int main (int /* argc */, char ** /* argv */)
// occurs. (In Visual C++ press F5 to continue)
try
{
nlerror ("nlerror() %d", 4);
nlerror("nlerror() %d", 4);
}
catch(const EFatalError &)
catch (const NLMISC::EFatalError &)
{
// just continue...
nlinfo ("nlerror() generated an EFatalError exception, just ignore it");
nlinfo("nlerror() generated an EFatalError exception, just ignore it");
}
// keep repeating the same error
for (int i = 0; i < 32; ++i)
repeatederror();
printf("\nPress <return> to exit\n");
getchar ();
getchar();
return EXIT_SUCCESS;
}

@ -98,8 +98,7 @@ struct CClient
struct TInetAddressHash
{
static const size_t bucket_size = 4;
static const size_t min_buckets = 8;
enum { bucket_size = 4, min_buckets = 8, };
inline bool operator() (const NLNET::CInetAddress &x1, const NLNET::CInetAddress &x2) const
{

@ -1327,6 +1327,10 @@ const D3DFORMAT FinalPixelFormat[ITexture::UploadFormatCount][CDriverD3D::FinalP
bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay)
{
H_AUTO_D3D(CDriver3D_setDisplay);
if (!mode.OffScreen)
NLMISC::INelContext::getInstance().setWindowedApplication(true);
if (!_D3D)
return false;
#ifndef NL_NO_ASM

@ -67,6 +67,16 @@ IF(UNIX AND NOT APPLE)
ADD_DEFINITIONS(-DHAVE_XCURSOR)
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_Xcursor_LIB})
ENDIF(X11_Xcursor_FOUND)
IF(X11_Xext_FOUND)
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_Xext_LIB})
ENDIF(X11_Xext_FOUND)
# libraries needed to be linked while linking to static X11 libraries
FIND_LIBRARY(XCB_LIBRARY
NAMES xcb
HINTS ${X11_LIB_SEARCH_PATH})
IF(XCB_LIBRARY)
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${XCB_LIBRARY})
ENDIF(XCB_LIBRARY)
ENDIF(UNIX AND NOT APPLE)
IF(WITH_PCH)

@ -603,6 +603,9 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
{
H_AUTO_OGL(CDriverGL_setDisplay)
if (!mode.OffScreen)
NLMISC::INelContext::getInstance().setWindowedApplication(true);
_win = EmptyWindow;
_CurrentMode = mode;

@ -73,7 +73,7 @@ pair<string, uint32> CZoneSearch::getZoneName(uint x, uint y, uint cx, uint cy)
sprintf(name, "%d_%c%c.zonel", zoneY, firstLetter, secondLetter);
return make_pair<string, uint32>(string(name), distance);
return std::pair<string, uint32>(string(name), distance);
}

@ -6,7 +6,7 @@ SOURCE_GROUP("src" FILES ${SRC})
NL_TARGET_LIB(nelgui ${SRC} ${HEADERS})
INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR} ${LUABIND_INCLUDE_DIR} ${LIBWWW_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR} ${LUABIND_INCLUDE_DIR} ${LIBWWW_INCLUDE_DIR} ${CURL_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(nelgui nelmisc nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${LIBXML2_LIBRARIES} ${LIBWWW_LIBRARIES} ${CURL_LIBRARIES})
SET_TARGET_PROPERTIES(nelgui PROPERTIES LINK_INTERFACE_LIBRARIES "")

@ -519,17 +519,17 @@ namespace NLGUI
// Read Action handlers
prop = (char*) xmlGetProp( node, (xmlChar*)"onscroll" );
if (prop) _AHOnScroll = NLMISC::strlwr(prop);
if (prop) _AHOnScroll = NLMISC::strlwr(prop.str());
prop = (char*) xmlGetProp( node, (xmlChar*)"params" );
if (prop) _AHOnScrollParams = string((const char*)prop);
//
prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollend" );
if (prop) _AHOnScrollEnd = NLMISC::strlwr(prop);
if (prop) _AHOnScrollEnd = NLMISC::strlwr(prop.str());
prop = (char*) xmlGetProp( node, (xmlChar*)"end_params" );
if (prop) _AHOnScrollEndParams = string((const char*)prop);
//
prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollcancel" );
if (prop) _AHOnScrollCancel = NLMISC::strlwr(prop);
if (prop) _AHOnScrollCancel = NLMISC::strlwr(prop.str());
prop = (char*) xmlGetProp( node, (xmlChar*)"cancel_params" );
if (prop) _AHOnScrollCancelParams = string((const char*)prop);
@ -538,9 +538,9 @@ namespace NLGUI
prop = (char*) xmlGetProp( node, (xmlChar*)"target" );
if (prop)
{
CInterfaceGroup *group = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(prop));
CInterfaceGroup *group = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(prop.str()));
if(group == NULL)
group = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(this->getId(), prop));
group = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(this->getId(), prop.str()));
if(group != NULL)
setTarget (group);

@ -268,7 +268,7 @@ namespace NLGUI
void CDBGroupComboBox::addText(const ucstring &text)
{
dirt();
_Texts.push_back(make_pair(_Texts.size(), text));
_Texts.push_back(make_pair((uint)_Texts.size(), text));
_Textures.push_back(std::string());
}
@ -330,7 +330,7 @@ namespace NLGUI
}
// ***************************************************************************
const uint &CDBGroupComboBox::getTextId(uint i) const
uint CDBGroupComboBox::getTextId(uint i) const
{
static uint null = 0;
if(i<_Texts.size())

@ -2200,7 +2200,7 @@ namespace NLGUI
if( editorMode )
_Extends = std::string( (const char*)prop );
CGroupMenu *gm = dynamic_cast<CGroupMenu *>(CWidgetManager::getInstance()->getElementFromId(prop));
CGroupMenu *gm = dynamic_cast<CGroupMenu *>(CWidgetManager::getInstance()->getElementFromId(prop.str()));
if (!gm)
{
gm = dynamic_cast<CGroupMenu *>(CWidgetManager::getInstance()->getElementFromId("ui:interface:" + std::string((const char*)prop)));

@ -55,7 +55,7 @@ namespace NLGUI
if (ptr) _Dynamic = CInterfaceElement::convertBool (ptr);
ptr = xmlGetProp (cur, (xmlChar*)"type");
string sTmp = ptr;
string sTmp = ptr.str();
sTmp = strlwr(sTmp);
if (sTmp == "linear")
_Type = Track_Linear;
@ -74,7 +74,7 @@ namespace NLGUI
}
//
if (!CInterfaceLink::splitLinkTargets (ptr, parentGroup, _Targets))
if (!CInterfaceLink::splitLinkTargets (ptr.str(), parentGroup, _Targets))
{
nlwarning ("no target for track");
return false;
@ -194,7 +194,7 @@ namespace NLGUI
fromString((const char*)time, fAnimTime);
TAnimationTime animTime = fAnimTime * CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionMulCoefAnim).getValFloat();
double animValue;
fromString(value, animValue);
fromString(value.str(), animValue);
// Depending on the type of the track add the key
switch(_Type)

@ -312,7 +312,7 @@ namespace NLGUI
ptr = (char*) xmlGetProp( cur, (xmlChar*)"max_sizeparent" );
if (ptr)
{
string idparent = ptr;
string idparent = ptr.str();
idparent = NLMISC::strlwr(idparent);
if (idparent != "parent")
{

@ -664,7 +664,7 @@ namespace NLGUI
//if it begins with a #, it is a reference in the instance attribute
if (strchr(ptr, '#') != NULL)
{
string LastProp = ptr;
string LastProp = ptr.str();
string NewProp ="";
string RepProp;
@ -796,7 +796,7 @@ namespace NLGUI
return false;
}
sint32 size;
fromString(cSize, size);
fromString(cSize.str(), size);
if (size <= 0)
{
// todo hulud interface syntax error
@ -929,7 +929,7 @@ namespace NLGUI
nlwarning("<CInterfaceParser::parseLink> Can't read the expression for a link node");
return false;
}
std::string expr = ptr;
std::string expr = ptr.str();
std::vector<CInterfaceLink::CTargetInfo> targets;
@ -1119,13 +1119,13 @@ namespace NLGUI
nlinfo ("options has no name");
return false;
}
string optionsName = ptr;
string optionsName = ptr.str();
// herit if possible
ptr = (char*) xmlGetProp( cur, (xmlChar*)"herit" );
if (ptr)
{
string optionsParentName = ptr;
string optionsParentName = ptr.str();
CInterfaceOptions *io = wm->getOptions( optionsParentName );
if( io != NULL )
options->copyBasicMap( *io );
@ -1771,7 +1771,7 @@ namespace NLGUI
{
CInterfaceExprValue res;
if (CInterfaceExpr::eval(ptrVal2, res))
if (CInterfaceExpr::eval(ptrVal2.str(), res))
{
if (!res.toString())
{
@ -1807,7 +1807,7 @@ namespace NLGUI
nlwarning ("no id in a procedure");
return false;
}
string procId= ptr;
string procId= ptr.str();
if (_ProcedureMap.find(procId) != _ProcedureMap.end())
{
@ -2171,7 +2171,7 @@ namespace NLGUI
//get the property value
ptr = (char*)xmlGetProp( cur, props->name);
nlassert(ptr);
string propVal= ptr;
string propVal= ptr.str();
string newPropVal;
// solve define of this prop
@ -2328,7 +2328,7 @@ namespace NLGUI
nlinfo ("anim has no id");
return false;
}
string animId = ptr;
string animId = ptr.str();
pAnim = new CInterfaceAnim;
if (pAnim->parse (cur, parentGroup))

@ -1,6 +1,176 @@
FILE(GLOB SRC *.cpp *.h config_file/*.cpp config_file/*.h)
FILE(GLOB HEADERS ../../include/nel/misc/*.h)
FILE(GLOB NLMISC_CDB
cdb.cpp ../../include/nel/misc/cdb.h
cdb_*.cpp ../../include/nel/misc/cdb_*.h
)
FILE(GLOB NLMISC_EVENT
events.cpp ../../include/nel/misc/events.h
event_*.cpp ../../include/nel/misc/event_*.h
*_event_*.cpp ../../include/nel/misc/*_event_*.h
)
FILE(GLOB NLMISC_DEBUG
debug.cpp ../../include/nel/misc/debug.h
report.cpp ../../include/nel/misc/report.h
log.cpp ../../include/nel/misc/log.h
)
FILE(GLOB NLMISC_FILESYSTEM
async_file_manager.cpp ../../include/nel/misc/async_file_manager.h
file.cpp ../../include/nel/misc/file.h
path.cpp ../../include/nel/misc/path.h
big_file.cpp ../../include/nel/misc/big_file.h
*_xml.cpp ../../include/nel/misc/*_xml.h
xml_*.cpp ../../include/nel/misc/xml_*.h
)
FILE(GLOB NLMISC_STREAM
*_stream.cpp ../../include/nel/misc/*_stream.h
stream.cpp ../../include/nel/misc/stream.h
stream_*.cpp ../../include/nel/misc/stream_*.h
)
FILE(GLOB NLMISC_DISPLAYER
displayer.cpp ../../include/nel/misc/displayer.h
*_displayer.cpp ../../include/nel/misc/*_displayer.h
)
FILE(GLOB NLMISC_MATH
plane.cpp ../../include/nel/misc/plane.h
../../include/nel/misc/plane_inline.h
polygon.cpp ../../include/nel/misc/polygon.h
quad.cpp ../../include/nel/misc/quad.h
quat.cpp ../../include/nel/misc/quat.h
rect.cpp ../../include/nel/misc/rect.h
rgba.cpp ../../include/nel/misc/rgba.h
triangle.cpp ../../include/nel/misc/triangle.h
uv.cpp ../../include/nel/misc/uv.h
vector*.cpp ../../include/nel/misc/vector*.h
aabbox.cpp ../../include/nel/misc/aabbox.h
algo.cpp ../../include/nel/misc/algo.h
bsphere.cpp ../../include/nel/misc/bsphere.h
fast_floor.cpp ../../include/nel/misc/fast_floor.h
geom_ext.cpp ../../include/nel/misc/geom_ext.h
line.cpp ../../include/nel/misc/line.h
matrix.cpp ../../include/nel/misc/matrix.h
)
FILE(GLOB NLMISC_PLATFORM
*_nl.cpp ../../include/nel/misc/*_nl.h
common.cpp ../../include/nel/misc/common.h
app_context.cpp ../../include/nel/misc/app_context.h
check_fpu.cpp ../../include/nel/misc/check_fpu.h
cpu_time_stat.cpp ../../include/nel/misc/cpu_time_stat.h
dummy_window.cpp ../../include/nel/misc/dummy_window.h
dynloadlib.cpp ../../include/nel/misc/dynloadlib.h
fast_mem.cpp ../../include/nel/misc/fast_mem.h
inter_window_msg_queue.cpp ../../include/nel/misc/inter_window_msg_queue.h
system_*.cpp ../../include/nel/misc/system_*.h
win32_util.cpp ../../include/nel/misc/win32_util.h
win_tray.cpp ../../include/nel/misc/win_tray.h
)
FILE(GLOB NLMISC_GENERIC
../../include/nel/misc/array_2d.h
*_memory.cpp ../../include/nel/misc/*_memory.h
buf_fifo.cpp ../../include/nel/misc/buf_fifo.h
../../include/nel/misc/callback.h
*_allocator.cpp ../../include/nel/misc/*_allocator.h
../../include/nel/misc/enum_bitset.h
fast_id_map.cpp ../../include/nel/misc/fast_id_map.h
hierarchical_timer.cpp ../../include/nel/misc/hierarchical_timer.h
../../include/nel/misc/historic.h
../../include/nel/misc/mutable_container.h
../../include/nel/misc/random.h
smart_ptr.cpp ../../include/nel/misc/smart_ptr.h
../../include/nel/misc/smart_ptr_inline.h
../../include/nel/misc/resource_ptr.h
../../include/nel/misc/resource_ptr_inline.h
bit_set.cpp ../../include/nel/misc/bit_set.h
stop_watch.cpp ../../include/nel/misc/stop_watch.h
../../include/nel/misc/twin_map.h
object_vector.cpp ../../include/nel/misc/object_vector.h
../../include/nel/misc/singleton.h
speaker_listener.cpp ../../include/nel/misc/speaker_listener.h
../../include/nel/misc/static_map.h
stl_block_list.cpp ../../include/nel/misc/stl_block_list.h
)
FILE(GLOB NLMISC_UTILITY
config_file.cpp ../../include/nel/misc/config_file.h
cf_*.cpp ../../include/nel/misc/cf_*.h
config_file/config_file.cpp config_file/config_file.h
config_file/cf_*.cpp config_file/cf_*.h
class_id.cpp ../../include/nel/misc/class_id.h
class_registry.cpp ../../include/nel/misc/class_registry.h
cmd_args.cpp ../../include/nel/misc/cmd_args.h
command.cpp ../../include/nel/misc/command.h
eid_translator.cpp ../../include/nel/misc/eid_translator.h
entity_id.cpp ../../include/nel/misc/entity_id.h
eval_num_expr.cpp ../../include/nel/misc/eval_num_expr.h
factory.cpp ../../include/nel/misc/factory.h
grid_traversal.cpp ../../include/nel/misc/grid_traversal.h
mouse_smoother.cpp ../../include/nel/misc/mouse_smoother.h
noise_value.cpp ../../include/nel/misc/noise_value.h
progress_callback.cpp ../../include/nel/misc/progress_callback.h
sheet_id.cpp ../../include/nel/misc/sheet_id.h
variable.cpp ../../include/nel/misc/variable.h
value_smoother.cpp ../../include/nel/misc/value_smoother.h
)
FILE(GLOB NLMISC_STRING
string_*.cpp ../../include/nel/misc/string_*.h
../../include/nel/misc/ucstring.h
unicode.cpp
sstring.cpp ../../include/nel/misc/sstring.h
)
FILE(GLOB NLMISC_I18N
diff_tool.cpp ../../include/nel/misc/diff_tool.h
i18n.cpp ../../include/nel/misc/i18n.h
words_dictionary.cpp ../../include/nel/misc/words_dictionary.h
)
FILE(GLOB NLMISC_THREAD
co_task.cpp ../../include/nel/misc/co_task.h
mutex.cpp ../../include/nel/misc/mutex.h
*_thread.cpp ../../include/nel/misc/*_thread.h
task_*.cpp ../../include/nel/misc/task_*.h
reader_writer.cpp ../../include/nel/misc/reader_writer.h
tds.cpp ../../include/nel/misc/tds.h
thread.cpp ../../include/nel/misc/thread.h
)
FILE(GLOB NLMISC_BITMAP
bitmap.cpp ../../include/nel/misc/bitmap.h
bitmap_*.cpp
)
FILE(GLOB NLMISC_CRYPT
md5.cpp ../../include/nel/misc/md5.h
sha1.cpp ../../include/nel/misc/sha1.h
)
SOURCE_GROUP("" FILES ${SRC} ${HEADERS})
SOURCE_GROUP("cdb" FILES ${NLMISC_CDB})
SOURCE_GROUP("event" FILES ${NLMISC_EVENT})
SOURCE_GROUP("debug" FILES ${NLMISC_DEBUG})
SOURCE_GROUP("platform" FILES ${NLMISC_PLATFORM})
SOURCE_GROUP("filesystem" FILES ${NLMISC_FILESYSTEM})
SOURCE_GROUP("stream" FILES ${NLMISC_STREAM})
SOURCE_GROUP("displayer" FILES ${NLMISC_DISPLAYER})
SOURCE_GROUP("math" FILES ${NLMISC_MATH})
SOURCE_GROUP("generic" FILES ${NLMISC_GENERIC})
SOURCE_GROUP("utility" FILES ${NLMISC_UTILITY})
SOURCE_GROUP("bitmap" FILES ${NLMISC_BITMAP})
SOURCE_GROUP("thread" FILES ${NLMISC_THREAD})
SOURCE_GROUP("i18n" FILES ${NLMISC_I18N})
SOURCE_GROUP("crypt" FILES ${NLMISC_CRYPT})
SOURCE_GROUP("string" FILES ${NLMISC_STRING})
NL_TARGET_LIB(nelmisc ${HEADERS} ${SRC})
IF(WITH_GTK)

@ -114,6 +114,7 @@ CApplicationContext::CApplicationContext()
DebugNeedAssert = false;
NoAssert = false;
AlreadyCreateSharedAmongThreads = false;
WindowedApplication = false;
contextReady();
}
@ -242,6 +243,16 @@ void CApplicationContext::setAlreadyCreateSharedAmongThreads(bool b)
AlreadyCreateSharedAmongThreads = b;
}
bool CApplicationContext::isWindowedApplication()
{
return WindowedApplication;
}
void CApplicationContext::setWindowedApplication(bool b)
{
WindowedApplication = b;
}
CLibraryContext::CLibraryContext(INelContext &applicationContext)
: _ApplicationContext(&applicationContext)
{
@ -430,6 +441,16 @@ void CLibraryContext::setAlreadyCreateSharedAmongThreads(bool b)
_ApplicationContext->setAlreadyCreateSharedAmongThreads(b);
}
bool CLibraryContext::isWindowedApplication()
{
return _ApplicationContext->isWindowedApplication();
}
void CLibraryContext::setWindowedApplication(bool b)
{
_ApplicationContext->setWindowedApplication(b);
}
void initNelLibrary(NLMISC::CLibrary &lib)
{
nlassert(lib.isLibraryLoaded());

@ -43,20 +43,7 @@
#else //NL_USE_THREAD_COTASK
// some platform specifics
#if defined (NL_OS_WINDOWS)
//# define _WIN32_WINNT 0x0500
# define NL_WIN_CALLBACK CALLBACK
// Visual .NET won't allow Fibers for a Windows version older than 2000. However the basic features are sufficient for us, we want to compile them for all Windows >= 95
# if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0400)
# ifdef _WIN32_WINNT
# undef _WIN32_WINNT
# endif
# define _WIN32_WINNT 0x0400
# endif
# ifndef NL_COMP_MINGW
# define NOMINMAX
# endif
# include <windows.h>
# define NL_WIN_CALLBACK CALLBACK
#elif defined (NL_OS_UNIX)
# define NL_WIN_CALLBACK
# include <ucontext.h>

@ -20,10 +20,7 @@
#include "nel/misc/common.h"
#ifdef NL_OS_WINDOWS
# ifndef NL_COMP_MINGW
# define NOMINMAX
# endif
# include <windows.h>
# include <ShellAPI.h>
# include <io.h>
# include <tchar.h>
#elif defined NL_OS_UNIX
@ -670,7 +667,7 @@ bool abortProgram(uint32 pid)
#endif
}
bool launchProgram (const std::string &programName, const std::string &arguments)
bool launchProgram(const std::string &programName, const std::string &arguments, bool log)
{
#ifdef NL_OS_WINDOWS
@ -722,7 +719,8 @@ bool launchProgram (const std::string &programName, const std::string &arguments
{
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);
nlwarning("LAUNCH: Failed launched '%s' with arg '%s' err %d: '%s'", programName.c_str(), arguments.c_str(), GetLastError (), lpMsgBuf);
if (log)
nlwarning("LAUNCH: Failed launched '%s' with arg '%s' err %d: '%s'", programName.c_str(), arguments.c_str(), GetLastError(), lpMsgBuf);
LocalFree(lpMsgBuf);
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
@ -779,7 +777,8 @@ bool launchProgram (const std::string &programName, const std::string &arguments
if (status == -1)
{
char *err = strerror (errno);
nlwarning("LAUNCH: Failed launched '%s' with arg '%s' err %d: '%s'", programName.c_str(), arguments.c_str(), errno, err);
if (log)
nlwarning("LAUNCH: Failed launched '%s' with arg '%s' err %d: '%s'", programName.c_str(), arguments.c_str(), errno, err);
}
else if (status == 0)
{
@ -799,7 +798,8 @@ bool launchProgram (const std::string &programName, const std::string &arguments
return true;
}
#else
nlwarning ("LAUNCH: launchProgram() not implemented");
if (log)
nlwarning ("LAUNCH: launchProgram() not implemented");
#endif
return false;

@ -17,28 +17,8 @@
#include "stdmisc.h"
#include "nel/misc/types_nl.h"
#include "nel/misc/debug.h"
#ifdef HAVE_NELCONFIG_H
# include "nelconfig.h"
#endif // HAVE_NELCONFIG_H
#include "nel/misc/log.h"
#include "nel/misc/displayer.h"
#include "nel/misc/mem_displayer.h"
#include "nel/misc/command.h"
#include "nel/misc/report.h"
#include "nel/misc/path.h"
#include "nel/misc/variable.h"
#include "nel/misc/system_info.h"
#ifdef NL_OS_WINDOWS
# define _WIN32_WINDOWS 0x0410
# ifndef NL_COMP_MINGW
# define WINVER 0x0400
# define NOMINMAX
# endif
# include <windows.h>
# include <direct.h>
# include <tchar.h>
# include <imagehlp.h>
@ -59,6 +39,22 @@
# include <errno.h>
#endif
#include "nel/misc/debug.h"
#ifdef HAVE_NELCONFIG_H
# include "nelconfig.h"
#endif // HAVE_NELCONFIG_H
#include "nel/misc/log.h"
#include "nel/misc/displayer.h"
#include "nel/misc/mem_displayer.h"
#include "nel/misc/command.h"
#include "nel/misc/report.h"
#include "nel/misc/path.h"
#include "nel/misc/variable.h"
#include "nel/misc/system_info.h"
#include "nel/misc/system_utils.h"
#define NL_NO_DEBUG_FILES 1
using namespace std;
@ -83,7 +79,8 @@ using namespace std;
#define LOG_IN_FILE NEL_LOG_IN_FILE
// If true, debug system will trap crash even if the application is in debugger
static const bool TrapCrashInDebugger = false;
//static const bool TrapCrashInDebugger = false;
static const bool TrapCrashInDebugger = true;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
@ -552,8 +549,8 @@ public:
{
// yoyo: allow only to send the crash report once. Because users usually click ignore,
// which create noise into list of bugs (once a player crash, it will surely continues to do it).
bool i = false;
report (progname+shortExc, "", subject, _Reason, true, 1, true, 1, !isCrashAlreadyReported(), i, NL_CRASH_DUMP_FILE);
report(progname + shortExc, subject, _Reason, NL_CRASH_DUMP_FILE, true, !isCrashAlreadyReported(), ReportAbort);
// TODO: Does this need to be synchronous? Why does this not handle the report result?
// no more sent mail for crash
setCrashAlreadyReported(true);
@ -1196,10 +1193,10 @@ void createDebug (const char *logPath, bool logInFile, bool eraseLastLog)
#ifdef NL_OS_WINDOWS
if (TrapCrashInDebugger || !IsDebuggerPresent ())
#endif
{
DefaultMsgBoxDisplayer = new CMsgBoxDisplayer ("DEFAULT_MBD");
}
#endif
#if LOG_IN_FILE
if (logInFile)
@ -1227,6 +1224,9 @@ void createDebug (const char *logPath, bool logInFile, bool eraseLastLog)
#endif // LOG_IN_FILE
DefaultMemDisplayer = new CMemDisplayer ("DEFAULT_MD");
if (NLMISC::CSystemUtils::detectWindowedApplication())
INelContext::getInstance().setWindowedApplication(true);
initDebug2(logInFile);
INelContext::getInstance().setAlreadyCreateSharedAmongThreads(true);

@ -18,6 +18,10 @@
#include "nel/misc/types_nl.h"
#ifndef NL_OS_WINDOWS
# define IsDebuggerPresent() false
#endif
#ifdef NL_OS_WINDOWS
# include <io.h>
# include <fcntl.h>
@ -35,19 +39,6 @@
#include "nel/misc/debug.h"
#ifdef NL_OS_WINDOWS
// these defines is for IsDebuggerPresent(). it'll not compile on windows 95
// just comment this and the IsDebuggerPresent to compile on windows 95
# define _WIN32_WINDOWS 0x0410
# ifndef NL_COMP_MINGW
# define WINVER 0x0400
# define NOMINMAX
# endif
# include <windows.h>
#else
# define IsDebuggerPresent() false
#endif
#include "nel/misc/displayer.h"
using namespace std;
@ -529,7 +520,7 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes
// in release "<Msg>"
void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *message)
{
#ifdef NL_OS_WINDOWS
//#ifdef NL_OS_WINDOWS
bool needSpace = false;
// stringstream ss;
@ -688,39 +679,35 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m
// yoyo: allow only to send the crash report once. Because users usually click ignore,
// which create noise into list of bugs (once a player crash, it will surely continues to do it).
std::string filename = getLogDirectory() + NL_CRASH_DUMP_FILE;
TReportResult reportResult = report(args.ProcessName + " NeL " + toString(logTypeToString(args.LogType, true)),
subject, body, filename, NL_REPORT_SYNCHRONOUS, !isCrashAlreadyReported(), NL_REPORT_DEFAULT);
if (ReportDebug == report (args.ProcessName + " NeL " + toString(logTypeToString(args.LogType, true)), "", subject, body, true, 2, true, 1, !isCrashAlreadyReported(), IgnoreNextTime, filename.c_str()))
switch (reportResult)
{
case ReportAlwaysIgnore:
IgnoreNextTime = true;
break;
case ReportBreak:
INelContext::getInstance().setDebugNeedAssert(true);
break;
case ReportAbort:
# ifdef NL_OS_WINDOWS
# ifndef NL_COMP_MINGW
// disable the Windows popup telling that the application aborted and disable the dr watson report.
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
# endif
# endif
abort();
break;
}
// no more sent mail for crash
setCrashAlreadyReported(true);
}
}
/* // Check the envvar NEL_IGNORE_ASSERT
if (getenv ("NEL_IGNORE_ASSERT") == NULL)
{
// Ask the user to continue, debug or ignore
int result = MessageBox (NULL, ss2.str().c_str (), logTypeToString(args.LogType, true), MB_ABORTRETRYIGNORE | MB_ICONSTOP);
if (result == IDABORT)
{
// Exit the program now
exit (EXIT_FAILURE);
}
else if (result == IDRETRY)
{
// Give the debugger a try
DebugNeedAssert = true;
}
else if (result == IDIGNORE)
{
// Continue, do nothing
}
}
*/ }
#endif
//#endif
}

@ -32,6 +32,7 @@
#pragma comment(lib, "gthread-1.3.lib")
#endif
#include "nel/misc/app_context.h"
#include "nel/misc/path.h"
#include "nel/misc/command.h"
#include "nel/misc/thread.h"
@ -59,6 +60,14 @@ static GtkWidget *hrootbox = NULL, *scrolled_win2 = NULL;
// Functions
//
CGtkDisplayer (const char *displayerName) : CWindowDisplayer(displayerName)
{
needSlashR = false;
createLabel ("@Clear|CLEAR");
INelContext::getInstance().setWindowedApplication(true);
}
CGtkDisplayer::~CGtkDisplayer ()
{
if (_Init)

@ -19,11 +19,7 @@
#include "nel/misc/log.h"
#ifdef NL_OS_WINDOWS
# ifndef NL_COMP_MINGW
# define NOMINMAX
# endif
# include <process.h>
# include <windows.h>
#else
# include <unistd.h>
#endif

@ -24,10 +24,6 @@
#include "nel/misc/debug.h"
#ifdef NL_OS_WINDOWS
# ifndef NL_COMP_MINGW
# define NOMINMAX
# endif
# include <windows.h>
# include <imagehlp.h>
# pragma comment(lib, "imagehlp.lib")
# ifdef NL_OS_WIN64
@ -103,7 +99,7 @@ static string getFuncInfo (DWORD_TYPE funcAddr, DWORD_TYPE stackAddr)
if (stop==0 && (parse[i] == ',' || parse[i] == ')'))
{
char tmp[32];
sprintf (tmp, "=0x%p", *((ULONG*)(stackAddr) + 2 + pos++));
sprintf(tmp, "=0x%p", *((DWORD_TYPE*)(stackAddr) + 2 + pos++));
str += tmp;
}
str += parse[i];

@ -41,15 +41,6 @@ using namespace std;
#ifdef NL_OS_WINDOWS
// these defines are for IsDebuggerPresent(). It'll not compile on windows 95
// just comment this and the IsDebuggerPresent to compile on windows 95
#define _WIN32_WINDOWS 0x0410
#ifndef NL_COMP_MINGW
# define WINVER 0x0400
# define NOMINMAX
#endif
#include <windows.h>
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif

@ -25,10 +25,6 @@
#include "nel/misc/xml_pack.h"
#ifdef NL_OS_WINDOWS
# ifndef NL_COMP_MINGW
# define NOMINMAX
# endif
# include <windows.h>
# include <sys/types.h>
# include <sys/stat.h>
# include <direct.h>
@ -902,10 +898,10 @@ void CFileContainer::getPathContent (const string &path, bool recurse, bool want
if (isdirectory(de))
{
// skip CVS and .svn directory
if ((!showEverything) && (fn == "CVS" || fn == ".svn"))
// skip CVS, .svn and .hg directory
if ((!showEverything) && (fn == "CVS" || fn == ".svn" || fn == ".hg"))
{
NL_DISPLAY_PATH("PATH: CPath::getPathContent(%s, %d, %d, %d): skip CVS and .svn directory", path.c_str(), recurse, wantDir, wantFile);
NL_DISPLAY_PATH("PATH: CPath::getPathContent(%s, %d, %d, %d): skip CVS, .svn and .hg directory", path.c_str(), recurse, wantDir, wantFile);
continue;
}
@ -941,10 +937,10 @@ void CFileContainer::getPathContent (const string &path, bool recurse, bool want
closedir (dir);
#ifndef NL_OS_WINDOWS
BasePathgetPathContent = "";
BasePathgetPathContent.clear();
#endif
// let s recurse
// let's recurse
for (uint i = 0; i < recursPath.size (); i++)
{
// Progress bar
@ -1037,6 +1033,9 @@ void CFileContainer::addSearchPath (const string &path, bool recurse, bool alter
{
// find all path and subpath
getPathContent (newPath, recurse, true, false, pathsToProcess, progressCallBack);
// sort files
sort(pathsToProcess.begin(), pathsToProcess.end());
}
for (uint p = 0; p < pathsToProcess.size(); p++)
@ -1082,7 +1081,10 @@ void CFileContainer::addSearchPath (const string &path, bool recurse, bool alter
// find all files in the path and subpaths
getPathContent (newPath, recurse, false, true, filesToProcess, progressCallBack);
// Progree bar
// sort files
sort(filesToProcess.begin(), filesToProcess.end());
// Progress bar
if (progressCallBack)
{
progressCallBack->popCropedValues ();

@ -16,346 +16,209 @@
#include "stdmisc.h"
#include <stdlib.h>
#include <sstream>
#include "nel/misc/common.h"
#include "nel/misc/ucstring.h"
#include "nel/misc/report.h"
#include "nel/misc/path.h"
#ifdef NL_OS_WINDOWS
# ifndef NL_COMP_MINGW
# define NOMINMAX
# endif
# include <windows.h>
# include <windowsx.h>
# include <winuser.h>
#endif // NL_OS_WINDOWS
#define NL_NO_DEBUG_FILES 1
using namespace std;
#include "nel/misc/file.h"
#include "nel/misc/system_utils.h"
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
#define NL_REPORT_POST_URL_ENVVAR "NL_REPORT_POST_URL"
#ifdef NL_OS_WINDOWS
#define NL_CRASH_REPORT_TOOL "crash_report.exe"
#else
#define NL_CRASH_REPORT_TOOL "crash_report"
#endif
#define NL_DEBUG_REPORT 0
// Set to 1 if you want command line report tool
#define NL_REPORT_CONSOLE 0
// Set to 1 if you want command line report tool even when the debugger is present
#define NL_REPORT_CONSOLE_DEBUGGER 1
namespace NLMISC
{
void setReportPostUrl(const char *postUrl)
{
#if NL_DEBUG_REPORT
if (INelContext::isContextInitialised())
nldebug("Set report post url to '%s'", postUrl);
#endif
#ifdef NL_OS_WINDOWS
static HWND sendReport=NULL;
SetEnvironmentVariableA(NL_REPORT_POST_URL_ENVVAR, postUrl);
#else
setenv(NL_REPORT_POST_URL_ENVVAR, postUrl, 1);
#endif
}
//old doesn't work on visual c++ 7.1 due to default parameter typedef bool (*TEmailFunction) (const std::string &smtpServer, const std::string &from, const std::string &to, const std::string &subject, const std::string &body, const std::string &attachedFile = "", bool onlyCheck = false);
typedef bool (*TEmailFunction) (const std::string &smtpServer, const std::string &from, const std::string &to, const std::string &subject, const std::string &body, const std::string &attachedFile, bool onlyCheck);
#define DELETE_OBJECT(a) if((a)!=NULL) { DeleteObject (a); a = NULL; }
static TEmailFunction EmailFunction = NULL;
void setReportEmailFunction (void *emailFunction)
inline const char *getReportPostURL()
{
EmailFunction = (TEmailFunction)emailFunction;
#ifdef NL_OS_WINDOWS
if (sendReport)
EnableWindow(sendReport, FALSE);
static char buf[512];
buf[0] = '\0';
int res = GetEnvironmentVariableA(NL_REPORT_POST_URL_ENVVAR, buf, sizeof(buf));
if (res <= 0 || res > 511) return NULL;
if (buf[0] == '\0') return NULL;
return buf;
#else
char *res = getenv(NL_REPORT_POST_URL_ENVVAR);
if (res == NULL || res[0] == '\0') return NULL;
return res;
#endif
}
#ifndef NL_OS_WINDOWS
TReportResult report(const std::string &title, const std::string &subject, const std::string &body, const std::string &attachment, bool synchronous, bool sendReport, TReportResult defaultResult)
{
std::string reportPath;
if (!body.empty())
{
std::stringstream reportFile;
reportFile << getLogDirectory();
reportFile << "nel_report_";
reportFile << (int)time(NULL);
reportFile << ".log";
reportPath = CFile::findNewFile(reportFile.str());
std::ofstream f;
f.open(reportPath.c_str());
if (!f.good())
{
#if NL_DEBUG_REPORT
if (INelContext::isContextInitialised())
nldebug("Failed to write report log to '%s'", reportPath.c_str());
#endif
reportPath.clear();
}
else
{
f << body;
f.close();
}
}
// GNU/Linux, do nothing
if (((INelContext::isContextInitialised()
&& INelContext::getInstance().isWindowedApplication())
|| CSystemUtils::detectWindowedApplication())
&& CFile::isExists(NL_CRASH_REPORT_TOOL))
{
std::stringstream params;
params << NL_CRASH_REPORT_TOOL;
void report ()
{
}
if (!reportPath.empty())
params << " -log \"" << reportPath << "\"";
#else
if (!subject.empty())
params << " -attachment \"" << attachment << "\"";
// Windows specific version
if (!title.empty())
params << " -title \"" << title << "\"";
static string Body;
static string Subject;
static string AttachedFile;
if (!subject.empty())
params << " -subject \"" << subject << "\"";
static HWND checkIgnore=NULL;
static HWND debug=NULL;
static HWND ignore=NULL;
static HWND quit=NULL;
static HWND dialog=NULL;
const char *reportPostUrl = getReportPostURL();
if (reportPostUrl)
params << " -host \"" << reportPostUrl << "\"";
static bool NeedExit;
static TReportResult Result;
static bool IgnoreNextTime;
static bool CanSendMailReport= false;
if (synchronous)
params << " -dev";
static bool DebugDefaultBehavior, QuitDefaultBehavior;
if (sendReport)
params << " -sendreport";
static void sendEmail()
{
if (CanSendMailReport && SendMessage(sendReport, BM_GETCHECK, 0, 0) != BST_CHECKED)
{
bool res = EmailFunction ("", "", "", Subject, Body, AttachedFile, false);
if (res)
std::string paramsStr = params.str();
if (synchronous)
{
// EnableWindow(sendReport, FALSE);
// MessageBox (dialog, "The email was successfully sent", "email", MB_OK);
#ifndef NL_NO_DEBUG_FILES
CFile::createEmptyFile(getLogDirectory() + "report_sent");
TReportResult result = (TReportResult)::system(paramsStr.c_str());
if (result != ReportAlwaysIgnore
&& result != ReportIgnore
&& result != ReportAbort
&& result != ReportBreak)
{
#if NL_DEBUG_REPORT
if (INelContext::isContextInitialised())
nldebug("Return default result, invalid return code %i", (int)result);
#endif
return defaultResult;
}
return result;
}
else
{
#ifndef NL_NO_DEBUG_FILES
CFile::createEmptyFile(getLogDirectory() + "report_failed");
#endif
// MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR);
NLMISC::launchProgram(NL_CRASH_REPORT_TOOL, paramsStr,
NL_DEBUG_REPORT ? INelContext::isContextInitialised() : false); // Only log if required, avoid infinite loop
return defaultResult;
}
}
else
{
#ifndef NL_NO_DEBUG_FILES
CFile::createEmptyFile(getLogDirectory() + "report_refused");
#if NL_DEBUG_REPORT
if (INelContext::isContextInitialised() && !CFile::isExists(NL_CRASH_REPORT_TOOL))
nldebug("Crash report tool '%s' does not exist", NL_CRASH_REPORT_TOOL);
#endif
}
}
static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
//MSGFILTER *pmf;
if (message == WM_COMMAND && HIWORD(wParam) == BN_CLICKED)
{
if ((HWND) lParam == checkIgnore)
#if defined(NL_OS_WINDOWS) && !FINAL_VERSION && !NL_REPORT_CONSOLE_DEBUGGER
if (IsDebuggerPresent())
{
IgnoreNextTime = !IgnoreNextTime;
}
else if ((HWND) lParam == debug)
{
sendEmail();
NeedExit = true;
Result = ReportDebug;
if (DebugDefaultBehavior)
{
NLMISC_BREAKPOINT;
}
return defaultResult;
}
else if ((HWND) lParam == ignore)
{
sendEmail();
NeedExit = true;
Result = ReportIgnore;
}
else if ((HWND) lParam == quit)
{
sendEmail();
NeedExit = true;
Result = ReportQuit;
if (QuitDefaultBehavior)
{
// ace: we cannot call exit() because it's call the static object dtor and can crash the application
// if the dtor call order is not good.
//exit(EXIT_SUCCESS);
#ifdef NL_OS_WINDOWS
#ifndef NL_COMP_MINGW
// disable the Windows popup telling that the application aborted and disable the dr watson report.
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
#endif
else
#endif
// quit without calling atexit or static object dtors.
abort();
}
}
/*else if ((HWND) lParam == sendReport)
if (synchronous)
{
if (EmailFunction != NULL)
#if NL_REPORT_CONSOLE
// An interactive console based report
printf("\n");
if (!title.empty())
printf("%s\n", title.c_str());
else
printf("NeL report\n");
printf("\n");
if (!subject.empty())
printf("\tsubject: '%s'\n", subject.c_str());
if (!body.empty())
printf("\tbody: '%s'\n", reportPath.c_str());
if (!attachment.empty())
printf("\tattachment: '%s'\n", attachment.c_str());
for (;;)
{
bool res = EmailFunction ("", "", "", Subject, Body, AttachedFile, false);
if (res)
{
EnableWindow(sendReport, FALSE);
MessageBox (dialog, "The email was successfully sent", "email", MB_OK);
CFile::createEmptyFile(getLogDirectory() + "report_sent");
}
else
printf("\n");
printf("Always Ignore (S), Ignore (I), Abort (A), Break (B)?\n"); // S for Surpress
printf("> ");
int c = getchar();
getchar();
switch (c)
{
MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR);
case 'S':
case 's':
return ReportAlwaysIgnore;
case 'I':
case 'i':
return ReportIgnore;
case 'A':
case 'a':
return ReportAbort;
case 'B':
case 'b':
return ReportBreak;
}
}
}*/
}
else if (message == WM_CHAR)
{
if (wParam == 27)
{
// ESC -> ignore
sendEmail();
NeedExit = true;
Result = ReportIgnore;
}
}
return DefWindowProc (hWnd, message, wParam, lParam);
}
TReportResult report (const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const string &attachedFile)
{
// register the window
static bool AlreadyRegister = false;
if(!AlreadyRegister)
{
WNDCLASSW wc;
memset (&wc,0,sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = GetModuleHandle(NULL);
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpszClassName = L"NLReportWindow";
wc.lpszMenuName = NULL;
if (!RegisterClassW(&wc)) return ReportError;
AlreadyRegister = true;
}
ucstring formatedTitle = title.empty() ? ucstring("NeL report") : ucstring(title);
// create the window
dialog = CreateWindowW (L"NLReportWindow", (LPCWSTR)formatedTitle.c_str(), WS_DLGFRAME | WS_CAPTION /*| WS_THICKFRAME*/, CW_USEDEFAULT, CW_USEDEFAULT, 456, 400, NULL, NULL, GetModuleHandle(NULL), NULL);
// create the font
HFONT font = CreateFont (-12, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
Subject = subject;
AttachedFile = attachedFile;
// create the edit control
HWND edit = CreateWindowW (L"EDIT", NULL, WS_BORDER | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_READONLY | ES_LEFT | ES_MULTILINE, 7, 70, 429, 212, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
SendMessage (edit, WM_SETFONT, (WPARAM) font, TRUE);
// set the edit text limit to lot of :)
SendMessage (edit, EM_LIMITTEXT, ~0U, 0);
Body = addSlashR (body);
// set the message in the edit text
SendMessage (edit, WM_SETTEXT, (WPARAM)0, (LPARAM)Body.c_str());
if (enableCheckIgnore)
{
// create the combo box control
checkIgnore = CreateWindowW (L"BUTTON", L"Don't display this report again", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_CHECKBOX, 7, 290, 429, 18, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
SendMessage (checkIgnore, WM_SETFONT, (WPARAM) font, TRUE);
if(ignoreNextTime)
{
SendMessage (checkIgnore, BM_SETCHECK, BST_CHECKED, 0);
#else
return defaultResult;
#endif
}
}
// create the debug button control
debug = CreateWindowW (L"BUTTON", L"Debug", WS_CHILD | WS_VISIBLE, 7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
SendMessage (debug, WM_SETFONT, (WPARAM) font, TRUE);
if (debugButton == 0)
EnableWindow(debug, FALSE);
// create the ignore button control
ignore = CreateWindowW (L"BUTTON", L"Ignore", WS_CHILD | WS_VISIBLE, 75+7+7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
SendMessage (ignore, WM_SETFONT, (WPARAM) font, TRUE);
if (ignoreButton == 0)
EnableWindow(ignore, FALSE);
// create the quit button control
quit = CreateWindowW (L"BUTTON", L"Quit", WS_CHILD | WS_VISIBLE, 75+75+7+7+7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
SendMessage (quit, WM_SETFONT, (WPARAM) font, TRUE);
if (quitButton == 0)
EnableWindow(quit, FALSE);
// create the debug button control
sendReport = CreateWindowW (L"BUTTON", L"Don't send the report", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 7, 315+32, 429, 18, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
SendMessage (sendReport, WM_SETFONT, (WPARAM) font, TRUE);
string formatedHeader;
if (header.empty())
{
formatedHeader = "This application stopped to display this report.";
}
else
{
formatedHeader = header;
}
// ace don't do that because it s slow to try to send a mail
//CanSendMailReport = sendReportButton && EmailFunction != NULL && EmailFunction("", "", "", "", "", true);
CanSendMailReport = sendReportButton && EmailFunction != NULL;
if (CanSendMailReport)
formatedHeader += " Send report will only email the contents of the box below. Please, send it to help us (it could take few minutes to send the email, be patient).";
else
EnableWindow(sendReport, FALSE);
ucstring uc = ucstring::makeFromUtf8(formatedHeader);
// create the label control
HWND label = CreateWindowW (L"STATIC", (LPCWSTR)uc.c_str(), WS_CHILD | WS_VISIBLE /*| SS_WHITERECT*/, 7, 7, 429, 51, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
SendMessage (label, WM_SETFONT, (WPARAM) font, TRUE);
DebugDefaultBehavior = debugButton==1;
QuitDefaultBehavior = quitButton==1;
IgnoreNextTime = ignoreNextTime;
// show until the cursor really show :)
while (ShowCursor(TRUE) < 0)
;
SetWindowPos (dialog, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
SetFocus(dialog);
SetForegroundWindow(dialog);
NeedExit = false;
while(!NeedExit)
{
MSG msg;
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
else
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
return defaultResult;
}
nlSleep (1);
}
// set the user result
ignoreNextTime = IgnoreNextTime;
ShowWindow(dialog, SW_HIDE);
DELETE_OBJECT(sendReport)
DELETE_OBJECT(quit)
DELETE_OBJECT(ignore)
DELETE_OBJECT(debug)
DELETE_OBJECT(checkIgnore)
DELETE_OBJECT(edit)
DELETE_OBJECT(label)
DELETE_OBJECT(dialog)
return Result;
}
#endif
} // NLMISC

@ -19,12 +19,7 @@
#include "nel/misc/shared_memory.h"
#include "nel/misc/debug.h"
#ifdef NL_OS_WINDOWS
# ifndef NL_COMP_MINGW
# define NOMINMAX
# endif
# include <windows.h>
#else
#ifndef NL_OS_WINDOWS
# include <sys/types.h>
# include <sys/ipc.h>
# include <sys/shm.h>

@ -42,12 +42,20 @@
#include <utility>
#include <vector>
#ifdef _WIN32
# ifndef __MINGW32__
#define NOMINMAX
#include <nel/misc/types_nl.h>
#ifdef NL_OS_WINDOWS
# define WIN32_LEAN_AND_MEAN
# define _WIN32_WINDOWS 0x0410
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0400
# endif
# ifndef NL_COMP_MINGW
# define WINVER 0x0400
# define NOMINMAX
# endif
# include <WinSock2.h>
# include <windows.h>
# include <Windows.h>
#endif
#endif // NL_STDMISC_H

@ -19,10 +19,6 @@
#include "nel/misc/system_info.h"
#ifdef NL_OS_WINDOWS
# ifndef NL_COMP_MINGW
# define NOMINMAX
# endif
# include <windows.h>
# include <WinNT.h>
# include <tchar.h>
# include <intrin.h>

@ -18,16 +18,12 @@
#include "nel/misc/system_utils.h"
#ifdef NL_OS_WINDOWS
#ifndef NL_COMP_MINGW
#define NOMINMAX
#endif
#include <windows.h>
#ifdef _WIN32_WINNT_WIN7
# include <ObjBase.h>
# ifdef _WIN32_WINNT_WIN7
// only supported by Windows 7 Platform SDK
#include <ShObjIdl.h>
#define TASKBAR_PROGRESS 1
#endif
# include <ShObjIdl.h>
# define TASKBAR_PROGRESS 1
# endif
#endif
#ifdef DEBUG_NEW
@ -359,4 +355,14 @@ uint CSystemUtils::getCurrentColorDepth()
return depth;
}
/// Detect whether the current process is a windowed application. Return true if definitely yes, false if unknown
bool CSystemUtils::detectWindowedApplication()
{
#ifdef NL_OS_WINDOWS
if (GetConsoleWindow() == NULL)
return true;
#endif
return false;
}
} // NLMISC

@ -21,10 +21,7 @@
#include "nel/misc/thread.h"
#ifdef NL_OS_WINDOWS
# ifndef NL_COMP_MINGW
# define NOMINMAX
# endif
# include <windows.h>
# include <MMSystem.h>
#elif defined (NL_OS_UNIX)
# include <sys/time.h>
# include <unistd.h>

@ -20,8 +20,6 @@
#ifdef NL_OS_WINDOWS
#include <windows.h>
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif

@ -18,10 +18,6 @@
#include "nel/misc/win_displayer.h"
#ifdef NL_OS_WINDOWS
#ifndef NL_COMP_MINGW
# define NOMINMAX
#endif
#include <windows.h>
#include <windowsx.h>
#include <winuser.h>
#include <cstring>
@ -30,6 +26,7 @@
#include <commctrl.h>
#include <ctime>
#include "nel/misc/app_context.h"
#include "nel/misc/path.h"
#include "nel/misc/command.h"
#include "nel/misc/thread.h"
@ -45,6 +42,13 @@ namespace NLMISC {
static CHARFORMAT2 CharFormat;
CWinDisplayer::CWinDisplayer(const char *displayerName) : CWindowDisplayer(displayerName), Exit(false)
{
needSlashR = true;
createLabel("@Clear|CLEAR");
INelContext::getInstance().setWindowedApplication(true);
}
CWinDisplayer::~CWinDisplayer ()
{

@ -22,10 +22,6 @@
#include "nel/misc/event_server.h"
#ifdef NL_OS_WINDOWS
#ifndef NL_COMP_MINGW
#define NOMINMAX
#endif
#include <windows.h>
#include <windowsx.h>
/**

@ -251,7 +251,7 @@ void CWordsDictionary::exactLookupByKey( const CSString& key, CVectorSString& re
*/
inline CSString CWordsDictionary::makeResult( const CSString &key, const CSString &word )
{
return key + CSString(": ") + word;
return key + ": " + word.c_str();
}

@ -23,12 +23,6 @@
#ifdef NL_OS_WINDOWS
// these defines is for IsDebuggerPresent(). it'll not compile on windows 95
// just comment this and the IsDebuggerPresent to compile on windows 95
# define _WIN32_WINDOWS 0x0410
# ifndef NL_COMP_MINGW
# define WINVER 0x0400
# define NOMINMAX
# endif
# include <windows.h>
# include <direct.h>
#elif defined NL_OS_UNIX
# include <unistd.h>
@ -606,7 +600,7 @@ sint IService::main (const char *serviceShortName, const char *serviceLongName,
ListeningPort = servicePort;
setReportEmailFunction ((void*)sendEmail);
// setReportEmailFunction ((void*)sendEmail);
// setDefaultEmailParams ("gw.nevrax.com", "", "cado@nevrax.com");

@ -17,7 +17,9 @@
#include "nel/misc/types_nl.h"
#ifdef NL_OS_WINDOWS
# define _WIN32_WINDOWS 0x0410
# ifndef NL_COMP_MINGW
# define WINVER 0x0400
# define NOMINMAX
# endif
# include <winsock2.h>

@ -2253,7 +2253,7 @@ bool NLPACS::CLocalRetriever::checkSurfaceIntegrity(uint surf, NLMISC::CVector t
for (k=0; k+1<ochain.getVertices().size(); ++k)
{
edges.push_back(make_pair<CVector2s, CVector2s>(ochain[k], ochain[k+1]));
edges.push_back(std::pair<CVector2s, CVector2s>(ochain[k], ochain[k+1]));
}
}
}

@ -86,6 +86,7 @@ NL_TARGET_LIB(nelsound ${HEADERS} ${SRC})
INCLUDE_DIRECTORIES(${VORBIS_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${OGG_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(nelsound ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY})

@ -68,6 +68,7 @@ NEL_3DSMAX_SHARED_API NLMISC::INelContext &GetSharedNelContext()
{
new NLMISC::CApplicationContext();
NLMISC::createDebug();
NLMISC::INelContext::getInstance().setWindowedApplication(true);
}
return NLMISC::INelContext::getInstance();
}

@ -957,6 +957,7 @@ protected:
Value* force_quit_on_msg_displayer_cf(Value** arg_list, int count)
{
nlwarning("Enable force quit on NeL report msg displayer");
NLMISC::INelContext::getInstance().setWindowedApplication(false);
// disable the Windows popup telling that the application aborted and disable the dr watson report.
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
putenv("NEL_IGNORE_ASSERT=1");

@ -3,6 +3,7 @@ SUBDIRS(bnp_make disp_sheet_id extract_filename lock make_sheet_id xml_packer)
IF(WITH_QT)
ADD_SUBDIRECTORY(words_dic_qt)
ADD_SUBDIRECTORY(message_box_qt)
ADD_SUBDIRECTORY(crash_report)
ENDIF(WITH_QT)
IF(WIN32)

@ -0,0 +1,39 @@
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SRC_DIR} ${QT_INCLUDES})
FILE(GLOB CRASHREPORT_SRC *.cpp)
FILE(GLOB CRASHREPORT_HDR *h)
SET(CRASHREPORT_MOC_HDR
crash_report_socket.h
crash_report_widget.h
)
SET(CRASHREPORT_UI
crash_report_widget.ui
)
SET(QT_USE_QTGUI TRUE)
SET(QT_USE_QTNETWORK TRUE)
SET(QT_USE_QTMAIN TRUE)
SET(QT_USE_QTOPENGL FALSE)
SET(QT_USE_QTXML FALSE)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
QT4_WRAP_CPP(CRASHREPORT_MOC_SRC ${CRASHREPORT_MOC_HDR})
QT4_WRAP_UI(CRASHREPORT_UI_HDR ${CRASHREPORT_UI})
SOURCE_GROUP(QtResources FILES ${CRASHREPORT_UI})
SOURCE_GROUP(QtGeneratedUiHdr FILES ${CRASHREPORT_UI_HDR})
SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${CRASHREPORT_MOC_SRC})
SOURCE_GROUP("source files" FILES ${CRASHREPORT_SRC})
SOURCE_GROUP("header files" FILES ${CRASHREPORT_HDR})
ADD_EXECUTABLE(crash_report WIN32 MACOSX_BUNDLE ${CRASHREPORT_SRC} ${CRASHREPORT_MOC_HDR} ${CRASHREPORT_MOC_SRC} ${CRASHREPORT_UI_HDR})
TARGET_LINK_LIBRARIES(crash_report ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
NL_DEFAULT_PROPS(crash_report "NeL, Tools, Misc: Crash Report")
NL_ADD_RUNTIME_FLAGS(crash_report)
INSTALL(TARGETS crash_report RUNTIME DESTINATION ${NL_BIN_PREFIX})

@ -0,0 +1,111 @@
// Nel MMORPG framework - Error Reporter
//
// Copyright (C) 2015 Laszlo Kis-Adam
// Copyright (C) 2010 Ryzom Core <http://ryzomcore.org/>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "crash_report_widget.h"
#include <QApplication>
#include <QMessageBox>
#include <stack>
#include <vector>
#include <string>
class CCmdLineParser
{
public:
static void parse( int argc, char **argv, std::vector< std::pair< std::string, std::string > > &v )
{
std::stack< std::string > stack;
std::string key;
std::string value;
for( int i = argc - 1 ; i >= 0; i-- )
{
stack.push( std::string( argv[ i ] ) );
}
while( !stack.empty() )
{
key = stack.top();
stack.pop();
// If not a real parameter ( they start with '-' ), discard.
if( key[ 0 ] != '-' )
continue;
// Remove the '-'
key = key.substr( 1 );
// No more parameters
if( stack.empty() )
{
v.push_back( std::make_pair( key, "" ) );
break;
}
value = stack.top();
// If next parameter is a key, process it in the next iteration
if( value[ 0 ] == '-' )
{
v.push_back( std::make_pair( key, "" ) );
continue;
}
// Otherwise store the pair
else
{
v.push_back( std::make_pair( key, value ) );
stack.pop();
}
}
}
};
int main( int argc, char **argv )
{
#ifndef WIN32
// Workaround to default -style=gtk+ on recent Cinnamon versions
char *currentDesktop = getenv("XDG_CURRENT_DESKTOP");
if (currentDesktop)
{
printf("XDG_CURRENT_DESKTOP: %s\n", currentDesktop);
if (!strcmp(currentDesktop, "X-Cinnamon"))
{
setenv("XDG_CURRENT_DESKTOP", "gnome", 1);
}
}
#endif
QApplication app( argc, argv );
std::vector< std::pair< std::string, std::string > > params;
CCmdLineParser::parse( argc, argv, params );
CCrashReportWidget w;
w.setup( params );
w.show();
int ret = app.exec();
if( ret != EXIT_SUCCESS )
return ret;
else
return w.getReturnValue();
}

@ -0,0 +1,33 @@
// Ryzom Core MMORPG framework - Error Reporter
//
// Copyright (C) 2015 Laszlo Kis-Adam
// Copyright (C) 2010 Ryzom Core <http://ryzomcore.org/>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RCERROR_DATA
#define RCERROR_DATA
#include <QString>
struct SCrashReportData
{
QString description;
QString report;
QString email;
};
#endif

@ -0,0 +1,78 @@
// Nel MMORPG framework - Error Reporter
//
// Copyright (C) 2015 Laszlo Kis-Adam
// Copyright (C) 2010 Ryzom Core <http://ryzomcore.org/>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "crash_report_socket.h"
#include <QNetworkAccessManager>
#include <QUrl>
#include <QNetworkRequest>
#include <QNetworkReply>
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
# include <QUrlQuery>
#endif
class CCrashReportSocketPvt
{
public:
QNetworkAccessManager mgr;
};
CCrashReportSocket::CCrashReportSocket( QObject *parent ) :
QObject( parent )
{
m_pvt = new CCrashReportSocketPvt();
connect( &m_pvt->mgr, SIGNAL( finished( QNetworkReply* ) ), this, SLOT( onFinished( QNetworkReply* ) ) );
}
CCrashReportSocket::~CCrashReportSocket()
{
delete m_pvt;
}
void CCrashReportSocket::sendReport( const SCrashReportData &data )
{
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
QUrlQuery params;
#else
QUrl params;
#endif
params.addQueryItem( "report", data.report );
params.addQueryItem( "descr", data.description );
params.addQueryItem("email", data.email);
QUrl url( m_url );
QNetworkRequest request( url );
request.setRawHeader( "Connection", "close" );
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
QByteArray postData = params.query(QUrl::FullyEncoded).toUtf8();
#else
QByteArray postData = params.encodedQuery();
#endif
m_pvt->mgr.post(request, postData);
}
void CCrashReportSocket::onFinished( QNetworkReply *reply )
{
if( reply->error() != QNetworkReply::NoError )
Q_EMIT reportFailed();
else
Q_EMIT reportSent();
}

@ -0,0 +1,55 @@
// Nel MMORPG framework - Error Reporter
//
// Copyright (C) 2015 Laszlo Kis-Adam
// Copyright (C) 2010 Ryzom Core <http://ryzomcore.org/>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RCERROR_SOCKET
#define RCERROR_SOCKET
#include <QObject>
#include "crash_report_data.h"
class CCrashReportSocketPvt;
class QNetworkReply;
class CCrashReportSocket : public QObject
{
Q_OBJECT
public:
CCrashReportSocket( QObject *parent );
~CCrashReportSocket();
void setURL( const char *URL ){ m_url = URL; }
QString url() const{ return m_url; }
void sendReport( const SCrashReportData &data );
Q_SIGNALS:
void reportSent();
void reportFailed();
private Q_SLOTS:
void onFinished( QNetworkReply *reply );
private:
CCrashReportSocketPvt *m_pvt;
QString m_url;
};
#endif

@ -0,0 +1,301 @@
// Nel MMORPG framework - Error Reporter
//
// Copyright (C) 2015 Laszlo Kis-Adam
// Copyright (C) 2010 Ryzom Core <http://ryzomcore.org/>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "crash_report_widget.h"
#include "crash_report_socket.h"
#include "crash_report_data.h"
#include <QTimer>
#include <QTextStream>
#include <QFile>
#include <QMessageBox>
#include <QFile>
#include <QPushButton>
#include <QHBoxLayout>
#include <QCheckBox>
CCrashReportWidget::CCrashReportWidget( QWidget *parent ) :
QWidget( parent )
{
m_developerMode = false;
m_forceSend = false;
m_devSendReport = false;
m_returnValue = ERET_NULL;
m_ui.setupUi( this );
m_socket = new CCrashReportSocket( this );
QTimer::singleShot( 1, this, SLOT( onLoad() ) );
connect( m_ui.emailCB, SIGNAL( stateChanged( int ) ), this, SLOT( onCBClicked() ) );
connect( m_socket, SIGNAL( reportSent() ), this, SLOT( onReportSent() ) );
connect( m_socket, SIGNAL( reportFailed() ), this, SLOT( onReportFailed() ) );
}
CCrashReportWidget::~CCrashReportWidget()
{
m_socket = NULL;
}
void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std::string > > &params )
{
for( int i = 0; i < params.size(); i++ )
{
const std::pair< std::string, std::string > &p = params[ i ];
const std::string &k = p.first;
const std::string &v = p.second;
if( k == "log" )
{
m_fileName = v.c_str();
if( !QFile::exists( m_fileName ) )
m_fileName.clear();
}
else
if( k == "host" )
{
m_socket->setURL( v.c_str() );
}
else
if( k == "title" )
{
setWindowTitle( v.c_str() );
}
else
if( k == "dev" )
{
m_developerMode = true;
}
else
if( k == "sendreport" )
{
m_forceSend = true;
}
}
if( m_fileName.isEmpty() )
{
m_ui.reportLabel->hide();
m_ui.reportEdit->hide();
}
if( m_socket->url().isEmpty() || m_fileName.isEmpty() )
{
m_ui.descriptionEdit->hide();
m_ui.emailCB->hide();
m_ui.emailEdit->hide();
m_ui.descrLabel->hide();
}
QHBoxLayout *hbl = new QHBoxLayout( this );
if( m_developerMode )
{
if( !m_socket->url().isEmpty() && !m_fileName.isEmpty() )
{
m_ui.emailCB->setEnabled( false );
QCheckBox *cb = new QCheckBox( tr( "Send report" ), this );
m_ui.gridLayout->addWidget( cb, 4, 0, 1, 1 );
m_ui.gridLayout->addWidget( m_ui.emailCB, 5, 0, 1, 1 );
m_ui.gridLayout->addWidget( m_ui.emailEdit, 6, 0, 1, 1 );
connect(cb, SIGNAL(stateChanged(int)), this, SLOT(onSendCBClicked()));
if (m_forceSend)
cb->setChecked(true);
}
hbl->addStretch();
QPushButton *alwaysIgnoreButton = new QPushButton( tr( "Always Ignore" ), this );
QPushButton *ignoreButton = new QPushButton( tr( "Ignore" ), this );
QPushButton *abortButton = new QPushButton( tr( "Abort" ), this );
QPushButton *breakButton = new QPushButton(tr("Break"), this);
breakButton->setAutoDefault(true);
hbl->addWidget( alwaysIgnoreButton );
hbl->addWidget( ignoreButton );
hbl->addWidget( abortButton );
hbl->addWidget( breakButton );
m_ui.gridLayout->addLayout( hbl, 7, 0, 1, 3 );
connect( alwaysIgnoreButton, SIGNAL( clicked( bool ) ), this, SLOT( onAlwaysIgnoreClicked() ) );
connect( ignoreButton, SIGNAL( clicked( bool ) ), this, SLOT( onIgnoreClicked() ) );
connect( abortButton, SIGNAL( clicked( bool ) ), this, SLOT( onAbortClicked() ) );
connect( breakButton, SIGNAL( clicked( bool ) ), this, SLOT( onBreakClicked() ) );
}
else
{
hbl->addStretch();
// If -host is specified, offer the send function
if( !m_socket->url().isEmpty() && !m_fileName.isEmpty() )
{
if (!m_forceSend)
{
QPushButton *cancelButton = new QPushButton(tr("Don't send report"), this);
connect(cancelButton, SIGNAL(clicked(bool)), this, SLOT(onCancelClicked()));
hbl->addWidget(cancelButton);
}
QPushButton *sendButton = new QPushButton( tr( "Send report" ), this );
sendButton->setAutoDefault(true);
connect( sendButton, SIGNAL( clicked( bool ) ), this, SLOT( onSendClicked() ) );
hbl->addWidget( sendButton );
}
// Otherwise only offer exit
else
{
QPushButton *exitButton = new QPushButton( tr( "Exit" ), this );
connect( exitButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) );
hbl->addWidget(exitButton);
exitButton->setAutoDefault(true);
}
m_ui.gridLayout->addLayout( hbl, 6, 0, 1, 3 );
}
}
void CCrashReportWidget::onLoad()
{
if( m_fileName.isEmpty() )
return;
QFile f( m_fileName );
bool b = f.open( QFile::ReadOnly | QFile::Text );
if( !b )
{
m_fileName.clear();
return;
}
QTextStream ss( &f );
m_ui.reportEdit->setPlainText( ss.readAll() );
f.close();
}
void CCrashReportWidget::onSendClicked()
{
if( m_developerMode && !m_devSendReport )
{
close();
return;
}
if( m_socket->url().isEmpty() || m_fileName.isEmpty() )
{
close();
return;
}
QApplication::setOverrideCursor( Qt::WaitCursor );
SCrashReportData data;
data.description = m_ui.descriptionEdit->toPlainText();
data.report = m_ui.reportEdit->toPlainText();
if( m_ui.emailCB->isChecked() )
data.email = m_ui.emailEdit->text();
m_socket->sendReport( data );
}
void CCrashReportWidget::onCancelClicked()
{
removeAndQuit();
}
void CCrashReportWidget::onCBClicked()
{
m_ui.emailEdit->setEnabled( m_ui.emailCB->isChecked() );
}
void CCrashReportWidget::onSendCBClicked()
{
bool b = m_ui.emailCB->isEnabled();
if( b )
{
m_ui.emailCB->setChecked( false );
}
m_ui.emailCB->setEnabled( !b );
m_devSendReport = !m_devSendReport;
}
void CCrashReportWidget::onAlwaysIgnoreClicked()
{
m_returnValue = ERET_ALWAYS_IGNORE;
onSendClicked();
}
void CCrashReportWidget::onIgnoreClicked()
{
m_returnValue = ERET_IGNORE;
onSendClicked();
}
void CCrashReportWidget::onAbortClicked()
{
m_returnValue = ERET_ABORT;
onSendClicked();
}
void CCrashReportWidget::onBreakClicked()
{
m_returnValue = ERET_BREAK;
onSendClicked();
}
void CCrashReportWidget::onReportSent()
{
QApplication::setOverrideCursor( Qt::ArrowCursor );
QMessageBox::information( this,
tr( "Report sent" ),
tr( "The report has been sent." ) );
removeAndQuit();
}
void CCrashReportWidget::onReportFailed()
{
QApplication::setOverrideCursor( Qt::ArrowCursor );
QMessageBox::information( this,
tr( "Report failed" ),
tr( "Failed to send the report..." ) );
removeAndQuit();
}
void CCrashReportWidget::removeAndQuit()
{
if( !m_fileName.isEmpty() )
QFile::remove( m_fileName );
close();
}

@ -0,0 +1,82 @@
// Nel MMORPG framework - Error Reporter
//
// Copyright (C) 2015 Laszlo Kis-Adam
// Copyright (C) 2010 Ryzom Core <http://ryzomcore.org/>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RCERROR_WIDGET
#define RCERROR_WIDGET
#include "ui_crash_report_widget.h"
#include <vector>
#include <string>
class CCrashReportSocket;
class CCrashReportWidget : public QWidget
{
Q_OBJECT
public:
enum EReturnValue
{
ERET_NULL = 0,
ERET_ALWAYS_IGNORE = 21,
ERET_IGNORE = 22,
ERET_ABORT = 23,
ERET_BREAK = 24
};
CCrashReportWidget( QWidget *parent = NULL );
~CCrashReportWidget();
void setFileName( const char *fn ){ m_fileName = fn; }
void setup( const std::vector< std::pair< std::string, std::string > > &params );
EReturnValue getReturnValue() const{ return m_returnValue; }
private Q_SLOTS:
void onLoad();
void onSendClicked();
void onCancelClicked();
void onCBClicked();
void onSendCBClicked();
void onAlwaysIgnoreClicked();
void onIgnoreClicked();
void onAbortClicked();
void onBreakClicked();
void onReportSent();
void onReportFailed();
private:
void removeAndQuit();
Ui::CrashReportWidget m_ui;
QString m_fileName;
CCrashReportSocket *m_socket;
bool m_developerMode;
bool m_forceSend;
bool m_devSendReport;
EReturnValue m_returnValue;
};
#endif

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CrashReportWidget</class>
<widget class="QWidget" name="CrashReportWidget">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>406</width>
<height>430</height>
</rect>
</property>
<property name="windowTitle">
<string>NeL report</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="descrLabel">
<property name="text">
<string>What were you doing when the crash occured?</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="reportLabel">
<property name="text">
<string>Contents of the report ( automatically generated )</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QPlainTextEdit" name="descriptionEdit"/>
</item>
<item row="4" column="0" colspan="3">
<widget class="QCheckBox" name="emailCB">
<property name="text">
<string>Email me if you have further questions, or updates on this issue</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QLineEdit" name="emailEdit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Enter your email address here</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QPlainTextEdit" name="reportEdit">
<property name="enabled">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

@ -163,7 +163,7 @@ void readFormId( string& outputFileName )
map<string,uint8>::iterator itFT = FileTypeToId.find(fileType);
if( itFT == FileTypeToId.end() )
{
FileTypeToId.insert( make_pair(fileType,fid.FormIDInfos.Type) );
FileTypeToId.insert( std::pair<std::string, uint8>(fileType,fid.FormIDInfos.Type) );
}
}
else

@ -379,7 +379,7 @@ int main(int argc, char *argv[])
CSString subFileName = parser.leftCrop(sizeof(" <nel:xml_file name=")-1);
subFileName = subFileName.matchDelimiters(false, false, true, false);
subFileName = subFileName.unquoteIfQuoted();
subFileName = dirName+"/"+subFileName;
subFileName = dirName + "/" + subFileName.c_str();
printf("Extracting file '%s'...\n", CFile::getFilename(subFileName).c_str());
// open the output file

@ -990,7 +990,7 @@ void processGlobalRetriever()
{
if (Verbose)
nlinfo("unlink: %s", unlinkstr.c_str());
faultyInstances.insert(make_pair<uint, CFaultyInstance>(i, fi));
faultyInstances.insert(std::pair<uint, CFaultyInstance>(i, fi));
}
}
@ -1046,7 +1046,7 @@ void processGlobalRetriever()
{
if (Verbose)
nlinfo("after fix: unlink: %s", unlinkstr.c_str());
faultyInstances.insert(make_pair<uint, CFaultyInstance>(i, fi));
faultyInstances.insert(std::pair<uint, CFaultyInstance>(i, fi));
}
}
}

@ -201,8 +201,7 @@ template<class A>
class CHashPtr
{
public:
static const size_t bucket_size = 4;
static const size_t min_buckets = 8;
enum { bucket_size = 4, min_buckets = 8, };
typedef A *ptrA;
size_t operator() (const ptrA &a) const

@ -90,6 +90,7 @@ INCLUDE_DIRECTORIES(
${LUABIND_INCLUDE_DIR}
${LIBWWW_INCLUDE_DIR}
${CURL_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR}
)
TARGET_LINK_LIBRARIES(ryzom_client

@ -281,8 +281,7 @@ public:
// HashMapTraits for NLMISC::TKey
struct CTKeyHashMapTraits
{
static const size_t bucket_size = 4;
static const size_t min_buckets = 8;
enum { bucket_size = 4, min_buckets = 8, };
CTKeyHashMapTraits() { }
size_t operator() (NLMISC::TKey key) const
{

@ -365,6 +365,8 @@ int main(int argc, char **argv)
createDebug();
INelContext::getInstance().setWindowedApplication(true);
#ifndef NL_DEBUG
INelContext::getInstance().getDebugLog()->removeDisplayer("DEFAULT_SD");
INelContext::getInstance().getInfoLog()->removeDisplayer("DEFAULT_SD");

@ -1204,7 +1204,7 @@ class CHandlerTell : public IActionHandler
ucstring s = CI18N::get("youTellPlayer");
strFindReplace(s, "%name", receiver);
strFindReplace(finalMsg, CI18N::get("youTell"), s);
CInterfaceManager::getInstance()->log(finalMsg);
CInterfaceManager::getInstance()->log(finalMsg, CChatGroup::groupTypeToString(CChatGroup::tell));
}
};
REGISTER_ACTION_HANDLER( CHandlerTell, "tell");

@ -103,7 +103,6 @@ extern uint32 Version; // Client Version.
extern UDriver *Driver;
extern UTextContext *TextContext;
extern bool game_exit;
extern CMsgBoxDisplayer MsgBoxError;
extern CSoundManager *SoundMngr;

@ -15,7 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#define CURL_STATICLIB 1
#include <curl/curl.h>
#include "http_client_curl.h"

@ -142,7 +142,6 @@ using namespace std;
// Ligo primitive class
CLigoConfig LigoConfig;
CMsgBoxDisplayer MsgBoxError;
CClientChatManager ChatMngr;
bool LastScreenSaverEnabled = false;
@ -568,7 +567,7 @@ void listStereoDisplayDevices(std::vector<NL3D::CStereoDeviceInfo> &devices)
std::stringstream name;
name << IStereoDisplay::getLibraryName(it->Library) << " - " << it->Manufacturer << " - " << it->ProductName;
std::stringstream fullname;
fullname << std::string("[") << name << "] [" << it->Serial << "]";
fullname << std::string("[") << name.str() << "] [" << it->Serial << "]";
nlinfo("VR [C]: Stereo Display: %s", name.str().c_str());
if (cache)
{

@ -483,7 +483,7 @@ void CChatWindow::displayLocalPlayerTell(const ucstring &receiver, const ucstrin
strFindReplace(s, "%name", receiver);
strFindReplace(finalMsg, CI18N::get("youTell"), s);
displayMessage(finalMsg, prop.getRGBA(), CChatGroup::tell, 0, numBlinks);
CInterfaceManager::getInstance()->log(finalMsg);
CInterfaceManager::getInstance()->log(finalMsg, CChatGroup::groupTypeToString(CChatGroup::tell));
}
void CChatWindow::encodeColorTag(const NLMISC::CRGBA &color, ucstring &text, bool append)

@ -333,29 +333,29 @@ bool CCtrlSheetInfo::parseCtrlInfo(xmlNodePtr cur, CInterfaceGroup * /* parentGr
prop = (char*) xmlGetProp( cur, (xmlChar*)"nature" );
if (prop)
{
if (NLMISC::strlwr(prop) == "item")
if (NLMISC::strlwr(prop.str()) == "item")
_Type = CCtrlSheetInfo::SheetType_Item;
else if (NLMISC::strlwr(prop) == "pact")
else if (NLMISC::strlwr(prop.str()) == "pact")
_Type = CCtrlSheetInfo::SheetType_Pact;
else if (NLMISC::strlwr(prop) == "skill")
else if (NLMISC::strlwr(prop.str()) == "skill")
_Type = CCtrlSheetInfo::SheetType_Skill;
else if (NLMISC::strlwr(prop) == "auto")
else if (NLMISC::strlwr(prop.str()) == "auto")
_Type = CCtrlSheetInfo::SheetType_Auto;
else if (NLMISC::strlwr(prop) == "macro")
else if (NLMISC::strlwr(prop.str()) == "macro")
_Type = CCtrlSheetInfo::SheetType_Macro;
else if (NLMISC::strlwr(prop) == "guild_flag")
else if (NLMISC::strlwr(prop.str()) == "guild_flag")
_Type = CCtrlSheetInfo::SheetType_GuildFlag;
else if (NLMISC::strlwr(prop) == "mission")
else if (NLMISC::strlwr(prop.str()) == "mission")
_Type = CCtrlSheetInfo::SheetType_Mission;
else if (NLMISC::strlwr(prop) == "sbrick")
else if (NLMISC::strlwr(prop.str()) == "sbrick")
_Type = CCtrlSheetInfo::SheetType_SBrick;
else if (NLMISC::strlwr(prop) == "sphraseid")
else if (NLMISC::strlwr(prop.str()) == "sphraseid")
_Type = CCtrlSheetInfo::SheetType_SPhraseId;
else if (NLMISC::strlwr(prop) == "sphrase")
else if (NLMISC::strlwr(prop.str()) == "sphrase")
_Type = CCtrlSheetInfo::SheetType_SPhrase;
else if (NLMISC::strlwr(prop) == "elevator_destination")
else if (NLMISC::strlwr(prop.str()) == "elevator_destination")
_Type = CCtrlSheetInfo::SheetType_ElevatorDestination;
else if (NLMISC::strlwr(prop) == "outpost_building")
else if (NLMISC::strlwr(prop.str()) == "outpost_building")
_Type = CCtrlSheetInfo::SheetType_OutpostBuilding;
}
@ -468,7 +468,7 @@ bool CCtrlSheetInfo::parseCtrlInfo(xmlNodePtr cur, CInterfaceGroup * /* parentGr
prop = (char*) xmlGetProp( cur, (xmlChar*)"item_slot" );
if(prop)
{
string str= prop;
string str= prop.str();
_ItemSlot= SLOTTYPE::stringToSlotType(NLMISC::toUpper(str));
}

@ -115,7 +115,7 @@ bool CDBGroupListSheet::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
if (prop)
{
// get a branch in the database.
CCDBNodeBranch *branch= NLGUI::CDBManager::getInstance()->getDbBranch(prop);
CCDBNodeBranch *branch = NLGUI::CDBManager::getInstance()->getDbBranch(prop.str());
if(!branch)
{
nlinfo ("Branch not found in the database %s", (const char*)prop);

@ -98,7 +98,7 @@ bool CDBGroupListSheetText::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
if (prop)
{
// get a branch in the database.
CCDBNodeBranch *branch= NLGUI::CDBManager::getInstance()->getDbBranch(prop);
CCDBNodeBranch *branch = NLGUI::CDBManager::getInstance()->getDbBranch(prop.str());
if(!branch)
{
nlinfo ("Branch not found in the database %s", (const char*)prop);

@ -556,7 +556,7 @@ bool CGroupMap::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
ptr = (char*) xmlGetProp( cur, (xmlChar*)"map_mode" );
if (ptr)
{
string sTmp = ptr;
string sTmp = ptr.str();
if (sTmp == "normal")
_MapMode = MapMode_Normal;
else if (sTmp == "death")

@ -162,13 +162,13 @@ bool CInterface3DScene::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
_Ref3DScene = NULL;
if (ptr)
{
CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(this->getId(), ptr);
CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(this->getId(), ptr.str());
_Ref3DScene = dynamic_cast<CInterface3DScene*>(pIE);
}
if (_Ref3DScene != NULL)
{
ptr = (char*) xmlGetProp( cur, (xmlChar*)"curcam" );
if (ptr) setCurrentCamera (ptr);
if (ptr) setCurrentCamera (ptr.str());
return true;
}
@ -294,7 +294,7 @@ bool CInterface3DScene::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
CXMLAutoPtr ptr((const char*)xmlGetProp (cur, (xmlChar*)"name"));
string animName;
if (ptr)
animName = strlwr (CFile::getFilenameWithoutExtension(ptr));
animName = strlwr (CFile::getFilenameWithoutExtension(ptr.str()));
if (!animName.empty())
{
@ -340,7 +340,7 @@ bool CInterface3DScene::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
// Get the current camera
ptr = (char*) xmlGetProp( cur, (xmlChar*)"curcam" );
if (ptr) setCurrentCamera (ptr);
if (ptr) setCurrentCamera(ptr.str());
return true;
}

@ -2684,7 +2684,7 @@ bool CInterfaceManager::deletePlayerKeys (const std::string &playerFileIdent)
}
// ***************************************************************************
void CInterfaceManager::log(const ucstring &str)
void CInterfaceManager::log(const ucstring &str, const std::string &cat)
{
if (_LogState)
{
@ -2693,7 +2693,7 @@ void CInterfaceManager::log(const ucstring &str)
FILE *f = fopen(fileName.c_str(), "at");
if (f != NULL)
{
const string finalString = string(NLMISC::IDisplayer::dateToHumanString()) + " * " + str.toUtf8();
const string finalString = string(NLMISC::IDisplayer::dateToHumanString()) + " (" + NLMISC::toUpper(cat) + ") * " + str.toUtf8();
fprintf(f, "%s\n", finalString.c_str());
}
fclose(f);

@ -218,7 +218,7 @@ public:
// Log system (all chat/tell
void setLogState(bool state) { _LogState = state; }
bool getLogState() const { return _LogState; }
void log(const ucstring &str);
void log(const ucstring &str, const std::string &cat = "");
/// Text from here and from server

@ -1981,7 +1981,7 @@ bool SBagOptions::parse(xmlNodePtr cur, CInterfaceGroup * /* parentGroup */)
prop = xmlGetProp (cur, (xmlChar*)"inv_type");
if (prop)
{
InvType = CInventoryManager::invTypeFromString(prop);
InvType = CInventoryManager::invTypeFromString(prop.str());
}
else
{
@ -1990,22 +1990,22 @@ bool SBagOptions::parse(xmlNodePtr cur, CInterfaceGroup * /* parentGroup */)
}
prop = xmlGetProp (cur, (xmlChar*)"filter_armor");
if (prop) DbFilterArmor = NLGUI::CDBManager::getInstance()->getDbProp(prop);
if (prop) DbFilterArmor = NLGUI::CDBManager::getInstance()->getDbProp(prop.str());
prop = xmlGetProp (cur, (xmlChar*)"filter_weapon");
if (prop) DbFilterWeapon = NLGUI::CDBManager::getInstance()->getDbProp(prop);
if (prop) DbFilterWeapon = NLGUI::CDBManager::getInstance()->getDbProp(prop.str());
prop = xmlGetProp (cur, (xmlChar*)"filter_tool");
if (prop) DbFilterTool = NLGUI::CDBManager::getInstance()->getDbProp(prop);
if (prop) DbFilterTool = NLGUI::CDBManager::getInstance()->getDbProp(prop.str());
prop = xmlGetProp (cur, (xmlChar*)"filter_mp");
if (prop) DbFilterMP = NLGUI::CDBManager::getInstance()->getDbProp(prop);
if (prop) DbFilterMP = NLGUI::CDBManager::getInstance()->getDbProp(prop.str());
prop = xmlGetProp (cur, (xmlChar*)"filter_missmp");
if (prop) DbFilterMissMP = NLGUI::CDBManager::getInstance()->getDbProp(prop);
if (prop) DbFilterMissMP = NLGUI::CDBManager::getInstance()->getDbProp(prop.str());
prop = xmlGetProp (cur, (xmlChar*)"filter_tp");
if (prop) DbFilterTP = NLGUI::CDBManager::getInstance()->getDbProp(prop);
if (prop) DbFilterTP = NLGUI::CDBManager::getInstance()->getDbProp(prop.str());
return true;
}

@ -353,7 +353,7 @@ bool CCommandParser::parse( xmlNodePtr cur, NLGUI::CInterfaceGroup *parentGroup
if (ptrName)
{
// Does the action exist ?
std::string name = ptrName;
std::string name = ptrName.str();
if (!ICommand::exists (name) || (CUserCommand::CommandMap.find(name) != CUserCommand::CommandMap.end()))
{
// Get the action
@ -369,7 +369,7 @@ bool CCommandParser::parse( xmlNodePtr cur, NLGUI::CInterfaceGroup *parentGroup
// if prop "ctrlchar" is declared with false, then disable ctrlchar for this command
CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"ctrlchar" ));
if( (const char*)prop && (CInterfaceElement::convertBool((const char*)prop)==false) )
ICommand::enableControlCharForCommand(ptrName, false);
ICommand::enableControlCharForCommand(ptrName.str(), false);
// Done
ret = true;

@ -478,7 +478,7 @@ void CPeopleList::displayLocalPlayerTell(const ucstring &receiver, uint index, c
strFindReplace(s, "%name", receiver);
strFindReplace(finalMsg, CI18N::get("youTell"), s);
gl->addChild(getChatTextMngr().createMsgText(finalMsg, prop.getRGBA()));
CInterfaceManager::getInstance()->log(finalMsg);
CInterfaceManager::getInstance()->log(finalMsg, CChatGroup::groupTypeToString(CChatGroup::tell));
// if the group is closed, make it blink
if (!gc->isOpen())
@ -946,7 +946,7 @@ class CHandlerContactEntry : public IActionHandler
ucstring s = CI18N::get("youTellPlayer");
strFindReplace(s, "%name", pWin->getFreeTellerName(str));
strFindReplace(final, CI18N::get("youTell"), s);
CInterfaceManager::getInstance()->log(final);
CInterfaceManager::getInstance()->log(final, CChatGroup::groupTypeToString(CChatGroup::tell));
}
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save