From 6abf73a61d67d8eaaa7b6e6b0d990cc57063a187 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 15 Jan 2016 11:34:23 +0100 Subject: [PATCH 01/12] VS2015 compilation fixes --- code/CMakeModules/nel.cmake | 10 +++++++-- code/nel/include/nel/misc/entity_id.h | 4 ++-- code/nel/include/nel/misc/mem_stream.h | 4 ++-- code/nel/include/nel/misc/string_common.h | 14 ++++++------ code/nel/include/nel/misc/types_nl.h | 7 ++++-- code/nel/src/gui/lua_object.cpp | 2 +- code/nel/src/misc/bit_mem_stream.cpp | 2 +- code/nel/src/misc/buf_fifo.cpp | 6 +++--- code/nel/src/misc/cdb_leaf.cpp | 4 ++-- code/nel/src/misc/common.cpp | 2 +- code/nel/src/misc/cpu_time_stat.cpp | 4 ++-- code/nel/src/misc/file.cpp | 2 +- code/nel/src/misc/o_xml.cpp | 4 ++-- code/nel/src/misc/system_utils.cpp | 26 +++++++++++++++++++++++ code/nel/src/net/buf_server.cpp | 4 ++-- code/nel/src/net/callback_client.cpp | 4 ++-- code/nel/src/net/message_recorder.cpp | 8 +++---- code/nel/src/net/net_log.cpp | 8 +++---- code/nel/src/net/unified_network.cpp | 8 +++---- code/nel/src/net/unitime.cpp | 18 ++++++++-------- code/nel/src/pacs/edge_collide.cpp | 4 ++-- 21 files changed, 90 insertions(+), 55 deletions(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index d54325fcb..59fbb3916 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -525,7 +525,13 @@ MACRO(NL_SETUP_BUILD) # Ignore default include paths ADD_PLATFORM_FLAGS("/X") - IF(MSVC12) + IF(MSVC14) + ADD_PLATFORM_FLAGS("/Gy- /MP") + # /Ox is working with VC++ 2015, 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(MSVC12) ADD_PLATFORM_FLAGS("/Gy- /MP") # /Ox is working with VC++ 2013, but custom optimizations don't exist SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") @@ -557,7 +563,7 @@ MACRO(NL_SETUP_BUILD) SET(DEBUG_CFLAGS "/Od /Ob1 ${DEBUG_CFLAGS}") ELSE(MSVC12) MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}") - ENDIF(MSVC12) + ENDIF(MSVC14) ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /Zm1000 /wd4250") diff --git a/code/nel/include/nel/misc/entity_id.h b/code/nel/include/nel/misc/entity_id.h index 0a3d51208..46561a512 100644 --- a/code/nel/include/nel/misc/entity_id.h +++ b/code/nel/include/nel/misc/entity_id.h @@ -354,7 +354,7 @@ public: } else { - nlerror ("CEntityId looped (max was %"NL_I64"d", MaxEntityId); + nlerror ("CEntityId looped (max was %" NL_I64 "d", MaxEntityId); } return *this; } @@ -487,7 +487,7 @@ public: uint creatorId; uint dynamicId; - if (sscanf(str, "(%"NL_I64"x:%x:%x:%x)", &id, &type, &creatorId, &dynamicId) != 4) + if (sscanf(str, "(%" NL_I64 "x:%x:%x:%x)", &id, &type, &creatorId, &dynamicId) != 4) { *this = Unknown; return; diff --git a/code/nel/include/nel/misc/mem_stream.h b/code/nel/include/nel/misc/mem_stream.h index 507ff6714..f614cc040 100644 --- a/code/nel/include/nel/misc/mem_stream.h +++ b/code/nel/include/nel/misc/mem_stream.h @@ -728,7 +728,7 @@ inline void CMemStream::serial(uint64 &b) } else { - writenumber( b, "%"NL_I64"u", 20 ); + writenumber( b, "%" NL_I64 "u", 20 ); } } else @@ -748,7 +748,7 @@ inline void CMemStream::serial(sint64 &b) } else { - writenumber( b, "%"NL_I64"d", 20 ); + writenumber( b, "%" NL_I64 "d", 20 ); } } else diff --git a/code/nel/include/nel/misc/string_common.h b/code/nel/include/nel/misc/string_common.h index f71759eae..d0a667563 100644 --- a/code/nel/include/nel/misc/string_common.h +++ b/code/nel/include/nel/misc/string_common.h @@ -186,8 +186,8 @@ inline std::string toString(const uint16 &val) { return toString("%hu", val); } inline std::string toString(const sint16 &val) { return toString("%hd", val); } inline std::string toString(const uint32 &val) { return toString("%u", val); } inline std::string toString(const sint32 &val) { return toString("%d", val); } -inline std::string toString(const uint64 &val) { return toString("%"NL_I64"u", val); } -inline std::string toString(const sint64 &val) { return toString("%"NL_I64"d", val); } +inline std::string toString(const uint64 &val) { return toString("%" NL_I64 "u", val); } +inline std::string toString(const sint64 &val) { return toString("%" NL_I64 "d", val); } #ifdef NL_COMP_GCC # if GCC_VERSION == 40102 @@ -206,7 +206,7 @@ inline std::string toString(const long unsigned int &val) #endif #if (SIZEOF_SIZE_T) == 8 -inline std::string toString(const size_t &val) { return toString("%"NL_I64"u", val); } +inline std::string toString(const size_t &val) { return toString("%" NL_I64 "u", val); } #else #ifdef NL_OS_MAC inline std::string toString(const size_t &val) { return toString("%u", val); } @@ -237,8 +237,8 @@ inline bool fromString(const std::string &str, uint8 &val) { char *end; long v; inline bool fromString(const std::string &str, sint8 &val) { char *end; long v; errno = 0; v = strtol(str.c_str(), &end, 10); if (errno || v > SCHAR_MAX || v < SCHAR_MIN || end == str.c_str()) { val = 0; return false; } else { val = (sint8)v; return true; } } inline bool fromString(const std::string &str, uint16 &val) { char *end; long v; errno = 0; v = strtol(str.c_str(), &end, 10); if (errno || v > USHRT_MAX || v < 0 || end == str.c_str()) { val = 0; return false; } else { val = (uint16)v; return true; } } inline bool fromString(const std::string &str, sint16 &val) { char *end; long v; errno = 0; v = strtol(str.c_str(), &end, 10); if (errno || v > SHRT_MAX || v < SHRT_MIN || end == str.c_str()) { val = 0; return false; } else { val = (sint16)v; return true; } } -inline bool fromString(const std::string &str, uint64 &val) { bool ret = sscanf(str.c_str(), "%"NL_I64"u", &val) == 1; if (!ret) val = 0; return ret; } -inline bool fromString(const std::string &str, sint64 &val) { bool ret = sscanf(str.c_str(), "%"NL_I64"d", &val) == 1; if (!ret) val = 0; return ret; } +inline bool fromString(const std::string &str, uint64 &val) { bool ret = sscanf(str.c_str(), "%" NL_I64 "u", &val) == 1; if (!ret) val = 0; return ret; } +inline bool fromString(const std::string &str, sint64 &val) { bool ret = sscanf(str.c_str(), "%" NL_I64 "d", &val) == 1; if (!ret) val = 0; return ret; } inline bool fromString(const std::string &str, float &val) { bool ret = sscanf(str.c_str(), "%f", &val) == 1; if (!ret) val = 0.0f; return ret; } inline bool fromString(const std::string &str, double &val) { bool ret = sscanf(str.c_str(), "%lf", &val) == 1; if (!ret) val = 0.0; return ret; } @@ -286,8 +286,8 @@ inline bool fromString(const char *str, uint8 &val) { char *end; long v; errno = 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, 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; } diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index 64d82d5bf..5f25387f5 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -67,7 +67,10 @@ # endif # ifdef _MSC_VER # define NL_COMP_VC -# if _MSC_VER >= 1800 +# if _MSC_VER >= 1900 +# define NL_COMP_VC14 +# define NL_COMP_VC_VERSION 140 +# elif _MSC_VER >= 1800 # define NL_COMP_VC12 # define NL_COMP_VC_VERSION 120 # elif _MSC_VER >= 1700 @@ -303,7 +306,7 @@ * Used to display a int64 in a platform independent way with printf like functions. \code sint64 myint64 = SINT64_CONSTANT(0x123456781234); - printf("This is a 64 bits int: %"NL_I64"u", myint64); + printf("This is a 64 bits int: %" NL_I64 "u", myint64); \endcode */ diff --git a/code/nel/src/gui/lua_object.cpp b/code/nel/src/gui/lua_object.cpp index 622157ed9..dc7abff52 100644 --- a/code/nel/src/gui/lua_object.cpp +++ b/code/nel/src/gui/lua_object.cpp @@ -422,7 +422,7 @@ namespace NLGUI { nlassert(key); nlassert(isValid()); - if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value '%d"NL_I64"' at key %s on object '%s' of type %s (not a table).", value, key, getId().c_str(), getTypename())); + if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value '%d" NL_I64 "' at key %s on object '%s' of type %s (not a table).", value, key, getId().c_str(), getTypename())); CLuaStackChecker lsc(_LuaState); push(); _LuaState->push(key); diff --git a/code/nel/src/misc/bit_mem_stream.cpp b/code/nel/src/misc/bit_mem_stream.cpp index ed282786e..4cd77e8ab 100644 --- a/code/nel/src/misc/bit_mem_stream.cpp +++ b/code/nel/src/misc/bit_mem_stream.cpp @@ -836,7 +836,7 @@ std::string CBitMemStream::getSerialItem( const TBMSSerialInfo& serialItem ) { uint64 u; serial( u, serialItem.BitSize ); - s = NLMISC::toString( "%"NL_I64"u", u ); + s = NLMISC::toString( "%" NL_I64 "u", u ); break; } case TBMSSerialInfo::F: // what about double? diff --git a/code/nel/src/misc/buf_fifo.cpp b/code/nel/src/misc/buf_fifo.cpp index 6c377f078..eee981644 100644 --- a/code/nel/src/misc/buf_fifo.cpp +++ b/code/nel/src/misc/buf_fifo.cpp @@ -538,9 +538,9 @@ void CBufFIFO::displayStats (CLog *log) log->displayNL ("%p BiggestBlock: %d, SmallestBlock: %d", this, _BiggestBlock, _SmallestBlock); log->displayNL ("%p BiggestBuffer: %d, SmallestBuffer: %d", this, _BiggestBuffer, _SmallestBuffer); - log->displayNL ("%p Pushed: %d, PushedTime: total %"NL_I64"d ticks, mean %f ticks", this, _Pushed, _PushedTime, (_Pushed>0?(double)(sint64)_PushedTime / (double)_Pushed:0.0)); - log->displayNL ("%p Fronted: %d, FrontedTime: total %"NL_I64"d ticks, mean %f ticks", this, _Fronted, _FrontedTime, (_Fronted>0?(double)(sint64)_FrontedTime / (double)_Fronted:0.0)); - log->displayNL ("%p Resized: %d, ResizedTime: total %"NL_I64"d ticks, mean %f ticks", this, _Resized, _ResizedTime, (_Resized>0?(double)(sint64)_ResizedTime / (double)_Resized:0.0)); + log->displayNL ("%p Pushed: %d, PushedTime: total %" NL_I64 "d ticks, mean %f ticks", this, _Pushed, _PushedTime, (_Pushed>0?(double)(sint64)_PushedTime / (double)_Pushed:0.0)); + log->displayNL ("%p Fronted: %d, FrontedTime: total %" NL_I64 "d ticks, mean %f ticks", this, _Fronted, _FrontedTime, (_Fronted>0?(double)(sint64)_FrontedTime / (double)_Fronted:0.0)); + log->displayNL ("%p Resized: %d, ResizedTime: total %" NL_I64 "d ticks, mean %f ticks", this, _Resized, _ResizedTime, (_Resized>0?(double)(sint64)_ResizedTime / (double)_Resized:0.0)); } void CBufFIFO::display () diff --git a/code/nel/src/misc/cdb_leaf.cpp b/code/nel/src/misc/cdb_leaf.cpp index 049791923..f74fb2d3d 100644 --- a/code/nel/src/misc/cdb_leaf.cpp +++ b/code/nel/src/misc/cdb_leaf.cpp @@ -120,7 +120,7 @@ ICDBNode * CCDBNodeLeaf::getNode (const CTextId& id, bool /* bCreate */) //----------------------------------------------- void CCDBNodeLeaf::write( CTextId& id, FILE * f) { - fprintf(f,"%"NL_I64"d\t%s\n",_Property,id.toString().c_str()); + fprintf(f,"%" NL_I64 "d\t%s\n",_Property,id.toString().c_str()); } // write // //----------------------------------------------- @@ -165,7 +165,7 @@ void CCDBNodeLeaf::readDelta(TGameCycle gc, CBitMemStream & f ) } if ( verboseDatabase ) { - nlinfo( "CDB: Read value (%u bits) %"NL_I64"d", bits, _Property ); + nlinfo( "CDB: Read value (%u bits) %" NL_I64 "d", bits, _Property ); } // bkup the date of change diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index e57ce635b..4c7d4fe02 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -380,7 +380,7 @@ string bytesToHumanReadable (uint64 bytes) div++; res = newres; } - return toString ("%"NL_I64"u%s", res, divTable[div]); + return toString ("%" NL_I64 "u%s", res, divTable[div]); } uint32 humanReadableToBytes (const string &str) diff --git a/code/nel/src/misc/cpu_time_stat.cpp b/code/nel/src/misc/cpu_time_stat.cpp index 861ab8e56..6441a8b45 100644 --- a/code/nel/src/misc/cpu_time_stat.cpp +++ b/code/nel/src/misc/cpu_time_stat.cpp @@ -49,7 +49,7 @@ bool CCPUTimeStat::getCPUTicks(uint64& user, uint64& nice, uint64& system, uint6 // /proc/stat // cpu [user] [nice] [system] [idle] [iowait] [irq] [softirq] - if (fscanf(f, "cpu %"NL_I64"u %"NL_I64"u %"NL_I64"u %"NL_I64"u %"NL_I64"u", &user, &nice, &system, &idle, &iowait) != 5) + if (fscanf(f, "cpu %" NL_I64 "u %" NL_I64 "u %" NL_I64 "u %" NL_I64 "u %" NL_I64 "u", &user, &nice, &system, &idle, &iowait) != 5) nlwarning("Failed to parse /proc/stat"); fclose(f); @@ -73,7 +73,7 @@ bool CCPUTimeStat::getPIDTicks(uint64& utime, uint64& stime, uint64& cutime, uin // /proc//stat // pid com sta ppi pgi ses tty tpg fla mif maf cmi cma [utime] [stime] [cutime] [cstime] ... - if (fscanf(f, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %"NL_I64"u %"NL_I64"u %"NL_I64"u %"NL_I64"u", &utime, &stime, &cutime, &cstime) != 4) + if (fscanf(f, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %" NL_I64 "u %" NL_I64 "u %" NL_I64 "u %" NL_I64 "u", &utime, &stime, &cutime, &cstime) != 4) nlwarning("Failed to parse /proc//stat"); fclose(f); diff --git a/code/nel/src/misc/file.cpp b/code/nel/src/misc/file.cpp index e5c0736f4..00a1823ef 100644 --- a/code/nel/src/misc/file.cpp +++ b/code/nel/src/misc/file.cpp @@ -791,7 +791,7 @@ NLMISC_CATEGORISED_COMMAND(nel, iFileAccessLogDisplay, "Display file access logs while (atIt!=atItEnd) { uint64 delta= (*atIt-IFileAccessLogStartTime); - log.display("%"NL_I64"u,",delta); + log.display("%" NL_I64 "u,",delta); ++atIt; } log.displayNL(""); diff --git a/code/nel/src/misc/o_xml.cpp b/code/nel/src/misc/o_xml.cpp index 0fbe3dade..d07362904 100644 --- a/code/nel/src/misc/o_xml.cpp +++ b/code/nel/src/misc/o_xml.cpp @@ -327,14 +327,14 @@ void COXml::serial(sint32 &b) void COXml::serial(uint64 &b) { - writenumber( b, "%"NL_I64"u", 20 ); + writenumber( b, "%" NL_I64 "u", 20 ); } // *************************************************************************** void COXml::serial(sint64 &b) { - writenumber( b, "%"NL_I64"d", 20 ); + writenumber( b, "%" NL_I64 "d", 20 ); } // *************************************************************************** diff --git a/code/nel/src/misc/system_utils.cpp b/code/nel/src/misc/system_utils.cpp index b70d3203e..2746c3f39 100644 --- a/code/nel/src/misc/system_utils.cpp +++ b/code/nel/src/misc/system_utils.cpp @@ -23,6 +23,32 @@ #include #include #include +#ifdef DXGI_STATUS_OCCLUDED +#undef DXGI_STATUS_OCCLUDED +#undef DXGI_STATUS_CLIPPED +#undef DXGI_STATUS_NO_REDIRECTION +#undef DXGI_STATUS_NO_DESKTOP_ACCESS +#undef DXGI_STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE +#undef DXGI_STATUS_MODE_CHANGED +#undef DXGI_STATUS_MODE_CHANGE_IN_PROGRESS +#endif +#ifdef DXGI_ERROR_INVALID_CALL +#undef DXGI_ERROR_INVALID_CALL +#undef DXGI_ERROR_NOT_FOUND +#undef DXGI_ERROR_MORE_DATA +#undef DXGI_ERROR_UNSUPPORTED +#undef DXGI_ERROR_DEVICE_REMOVED +#undef DXGI_ERROR_DEVICE_HUNG +#undef DXGI_ERROR_DEVICE_RESET +#undef DXGI_ERROR_WAS_STILL_DRAWING +#undef DXGI_ERROR_FRAME_STATISTICS_DISJOINT +#undef DXGI_ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE +#undef DXGI_ERROR_DRIVER_INTERNAL_ERROR +#undef DXGI_ERROR_NONEXCLUSIVE +#undef DXGI_ERROR_NOT_CURRENTLY_AVAILABLE +#undef DXGI_ERROR_REMOTE_CLIENT_DISCONNECTED +#undef DXGI_ERROR_REMOTE_OUTOFMEMORY +#endif #include #include #include diff --git a/code/nel/src/net/buf_server.cpp b/code/nel/src/net/buf_server.cpp index 09b061fd4..301972d68 100644 --- a/code/nel/src/net/buf_server.cpp +++ b/code/nel/src/net/buf_server.cpp @@ -716,7 +716,7 @@ uint64 CBufServer::newBytesReceived() { uint64 b = bytesReceived(); uint64 nbrecvd = b - _PrevBytesPoppedIn; - //nlinfo( "b: %"NL_I64"u new: %"NL_I64"u", b, nbrecvd ); + //nlinfo( "b: %" NL_I64 "u new: %" NL_I64 "u", b, nbrecvd ); _PrevBytesPoppedIn = b; return nbrecvd; } @@ -728,7 +728,7 @@ uint64 CBufServer::newBytesSent() { uint64 b = bytesSent(); uint64 nbsent = b - _PrevBytesPushedOut; - //nlinfo( "b: %"NL_I64"u new: %"NL_I64"u", b, nbsent ); + //nlinfo( "b: %" NL_I64 "u new: %" NL_I64 "u", b, nbsent ); _PrevBytesPushedOut = b; return nbsent; } diff --git a/code/nel/src/net/callback_client.cpp b/code/nel/src/net/callback_client.cpp index f05648016..2a5871c2f 100644 --- a/code/nel/src/net/callback_client.cpp +++ b/code/nel/src/net/callback_client.cpp @@ -311,7 +311,7 @@ void CCallbackClient::connect( const CInetAddress& addr ) throw ESocketConnectionFailed( addr ); //break; default : - nlwarning( "LNETL3C: No connection event in replay data, at update #%"NL_I64"u", _MR_UpdateCounter ); + nlwarning( "LNETL3C: No connection event in replay data, at update #%" NL_I64 "u", _MR_UpdateCounter ); } } #endif @@ -346,7 +346,7 @@ void CCallbackClient::disconnect( TSockId hostid ) // Read (skip) disconnection in the file if ( ! (_MR_Recorder.checkNextOne( _MR_UpdateCounter ) == Disconnecting) ) { - nlwarning( "LNETL3C: No disconnection event in the replay data, at update #%"NL_I64"u", _MR_UpdateCounter ); + nlwarning( "LNETL3C: No disconnection event in the replay data, at update #%" NL_I64 "u", _MR_UpdateCounter ); } } // Record or replay disconnection (because disconnect() in the client does not push a disc. event) diff --git a/code/nel/src/net/message_recorder.cpp b/code/nel/src/net/message_recorder.cpp index ec52ad1da..2f27be151 100644 --- a/code/nel/src/net/message_recorder.cpp +++ b/code/nel/src/net/message_recorder.cpp @@ -301,7 +301,7 @@ TNetworkEvent CMessageRecorder::checkNextOne( sint64 updatecounter ) TMessageRecord record; if ( getNext( record, updatecounter ) ) { - nldebug( "MR: Check next one: %s at update %"NL_I64"u", EventToString(record.Event).c_str(), updatecounter ); + nldebug( "MR: Check next one: %s at update %" NL_I64 "u", EventToString(record.Event).c_str(), updatecounter ); return record.Event; } else @@ -330,7 +330,7 @@ TNetworkEvent CMessageRecorder::replayConnectionAttempt( const CInetAddress& add { // Found event = (*ipr).Event; - nldebug( "MR: Connection attempt found at update %"NL_I64"u", (*ipr).UpdateCounter ); + nldebug( "MR: Connection attempt found at update %" NL_I64 "u", (*ipr).UpdateCounter ); _ConnectionAttempts.erase( ipr ); return event; } @@ -348,7 +348,7 @@ TNetworkEvent CMessageRecorder::replayConnectionAttempt( const CInetAddress& add if ( stored_addr == addr ) { // Found - nldebug( "MR: Connection attempt found at update %"NL_I64"u", (*ipr).UpdateCounter ); + nldebug( "MR: Connection attempt found at update %" NL_I64 "u", (*ipr).UpdateCounter ); _PreloadedRecords.erase( ipr ); return event; } @@ -367,7 +367,7 @@ TNetworkEvent CMessageRecorder::replayConnectionAttempt( const CInetAddress& add if ( stored_addr == addr ) { // Found - nldebug( "MR: Connection attempt found at update %"NL_I64"u", rec.UpdateCounter ); + nldebug( "MR: Connection attempt found at update %" NL_I64 "u", rec.UpdateCounter ); return rec.Event; } else diff --git a/code/nel/src/net/net_log.cpp b/code/nel/src/net/net_log.cpp index c6702be2f..9f563bf98 100644 --- a/code/nel/src/net/net_log.cpp +++ b/code/nel/src/net/net_log.cpp @@ -72,12 +72,12 @@ void CNetLog::output( const char *srchost, uint8 msgnum, const char *desthost, const char *msgname, uint32 msgsize ) { /*OLD char line [1024]; - smprintf( line, 1024, "@@%"NL_I64"d@%s@%hu@%s@%s@%s@%u@", (CUniTime::Sync?CUniTime::getUniTime():(TTime)0), + smprintf( line, 1024, "@@%" NL_I64 "d@%s@%hu@%s@%s@%s@%u@", (CUniTime::Sync?CUniTime::getUniTime():(TTime)0), srchost, (uint16)msgnum, _ProcessName.c_str(), desthost, msgname, msgsize ); displayRawNL( line ); */ -/* displayRawNL( "@@%"NL_I64"d@%s@%hu@%s@%s@%s@%u@", (CUniTime::Sync?CUniTime::getUniTime():(TTime)0), +/* displayRawNL( "@@%" NL_I64 "d@%s@%hu@%s@%s@%s@%u@", (CUniTime::Sync?CUniTime::getUniTime():(TTime)0), srchost, (uint16)msgnum, _ProcessName.c_str(), desthost, msgname, msgsize ); */ displayRawNL( "@@0@%s@%hu@%s@%s@%s@%u@", @@ -91,11 +91,11 @@ void CNetLog::output( const char *srchost, uint8 msgnum, void CNetLog::input( const char *srchost, uint8 msgnum, const char *desthost ) { /*OLD char line [1024]; - smprintf( line, 1024, "##%"NL_I64"d#%s#%hu#%s#%s#", (CUniTime::Sync?CUniTime::getUniTime():(TTime)0), + smprintf( line, 1024, "##%" NL_I64 "d#%s#%hu#%s#%s#", (CUniTime::Sync?CUniTime::getUniTime():(TTime)0), srchost, msgnum, _ProcessName.c_str(), desthost ); displayRawNL( line ); */ -/* displayRawNL( "##%"NL_I64"d#%s#%hu#%s#%s#", (CUniTime::Sync?CUniTime::getUniTime():(TTime)0), +/* displayRawNL( "##%" NL_I64 "d#%s#%hu#%s#%s#", (CUniTime::Sync?CUniTime::getUniTime():(TTime)0), srchost, msgnum, _ProcessName.c_str(), desthost ); */ displayRawNL( "##0#%s#%hu#%s#%s#", diff --git a/code/nel/src/net/unified_network.cpp b/code/nel/src/net/unified_network.cpp index 788dcdf12..0f4396ef5 100644 --- a/code/nel/src/net/unified_network.cpp +++ b/code/nel/src/net/unified_network.cpp @@ -251,7 +251,7 @@ void uncbServiceIdentification(CMessage &msgin, TSockId from, CCallbackNetBase & TServiceId inSid; if (from->appId () != AppIdDeadConnection) - AUTOCHECK_DISPLAY ("HNETL5: received a connect ident from an unknown connection 0x%"NL_I64"X", from->appId ()); + AUTOCHECK_DISPLAY ("HNETL5: received a connect ident from an unknown connection 0x%" NL_I64 "X", from->appId ()); // recover the service name and id msgin.serial(inSName); @@ -362,7 +362,7 @@ void uncbMsgProcessing(CMessage &msgin, TSockId from, CCallbackNetBase &/* netba if (uc == 0) { - nlwarning ("HNETL5: Received a message from a service %hu that is not ready (bad appid? 0x%"NL_I64"X)", sid.get(), from->appId ()); + nlwarning ("HNETL5: Received a message from a service %hu that is not ready (bad appid? 0x%" NL_I64 "X)", sid.get(), from->appId ()); return; } if((*itcb).second == 0) @@ -1139,7 +1139,7 @@ void CUnifiedNetwork::update(TTime timeout) if ( remainingTime > prevRemainingTime ) { // Restart at previousTime - nldebug( "Backward time sync detected (at least -%"NL_I64"d ms)", remainingTime - prevRemainingTime ); + nldebug( "Backward time sync detected (at least -%" NL_I64 "d ms)", remainingTime - prevRemainingTime ); remainingTime = prevRemainingTime; t0 = currentTime - (timeout - remainingTime); } @@ -1935,7 +1935,7 @@ void CUnifiedNetwork::autoCheck() for (j = 0; j < _IdCnx[i].Connections.size (); j++) { - if (_IdCnx[i].Connections[j].valid() && !_IdCnx[i].Connections[j].IsServerConnection && _IdCnx[i].Connections[j].CbNetBase->connected () && _IdCnx[i].Connections[j].getAppId() != i) AUTOCHECK_DISPLAY ("HLNET5: sid %d bad appid %"NL_I64"X", i, _IdCnx[i].Connections[j].getAppId()); + if (_IdCnx[i].Connections[j].valid() && !_IdCnx[i].Connections[j].IsServerConnection && _IdCnx[i].Connections[j].CbNetBase->connected () && _IdCnx[i].Connections[j].getAppId() != i) AUTOCHECK_DISPLAY ("HLNET5: sid %d bad appid %" NL_I64 "X", i, _IdCnx[i].Connections[j].getAppId()); } for (j = 0; j < _IdCnx[i].NetworkConnectionAssociations.size (); j++) diff --git a/code/nel/src/net/unitime.cpp b/code/nel/src/net/unitime.cpp index 057c29373..55e00a311 100644 --- a/code/nel/src/net/unitime.cpp +++ b/code/nel/src/net/unitime.cpp @@ -44,11 +44,11 @@ void _CUniTime::setUniTime (NLMISC::TTime /* uTime */, NLMISC::TTime /* lTime */ TTime lt = getLocalTime (); TTime delta = uTime - lTime + _SyncLocalTime - _SyncUniTime; - nlinfo ("_CUniTime::setUniTime(%"NL_I64"d, %"NL_I64"d): Resyncing delta %"NL_I64"dms",uTime,lTime,delta); + nlinfo ("_CUniTime::setUniTime(%" NL_I64 "d, %" NL_I64 "d): Resyncing delta %" NL_I64 "dms",uTime,lTime,delta); } else { - nlinfo ("_CUniTime::setUniTime(%"NL_I64"d, %"NL_I64"d)",uTime,lTime); + nlinfo ("_CUniTime::setUniTime(%" NL_I64 "d, %" NL_I64 "d)",uTime,lTime); Sync = true; } _SyncUniTime = uTime; @@ -191,7 +191,7 @@ void _CUniTime::syncUniTimeFromService (CCallbackNetBase::TRecordingState /* rec after = CTime::getLocalTime (); delta = after - before; - nlinfo ("_CUniTime::syncUniTimeFromService(): ping:%"NL_I64"dms, time:%ds, unitime:%"NL_I64"dms", delta, GetUniversalTimeSecondsSince1970, GetUniversalTimeUniTime); + nlinfo ("_CUniTime::syncUniTimeFromService(): ping:%" NL_I64 "dms, time:%ds, unitime:%" NL_I64 "dms", delta, GetUniversalTimeSecondsSince1970, GetUniversalTimeUniTime); // <-- from here to the "-->" comment, the block must be executed in less than one second or an infinite loop occurs @@ -222,11 +222,11 @@ void _CUniTime::syncUniTimeFromService (CCallbackNetBase::TRecordingState /* rec // adjust the unitime to the current localtime GetUniversalTimeUniTime += deltaAdjust; - nlinfo ("_CUniTime::syncUniTimeFromService(): rtime:%ds, runitime:%"NL_I64"ds, rlocaltime:%"NL_I64"d, deltaAjust:%"NL_I64"dms", nextsecond, GetUniversalTimeUniTime, lt, deltaAdjust); + nlinfo ("_CUniTime::syncUniTimeFromService(): rtime:%ds, runitime:%" NL_I64 "ds, rlocaltime:%" NL_I64 "d, deltaAjust:%" NL_I64 "dms", nextsecond, GetUniversalTimeUniTime, lt, deltaAdjust); } else { - nlinfo ("_CUniTime::syncUniTimeFromService(): runitime:%"NL_I64"ds, rlocaltime:%"NL_I64"d", GetUniversalTimeUniTime, lt); + nlinfo ("_CUniTime::syncUniTimeFromService(): runitime:%" NL_I64 "ds, rlocaltime:%" NL_I64 "d", GetUniversalTimeUniTime, lt); } _CUniTime::setUniTime (GetUniversalTimeUniTime, lt); @@ -256,7 +256,7 @@ static void cbServerAskUniversalTime (CMessage& /* msgin */, TSockId from, CCall TTime ut = _CUniTime::getUniTime (); // afficher l adresse de celui qui demande - nlinfo("UT: Send the universal time %"NL_I64"d to '%s'", ut, netbase.hostAddress(from).asString().c_str()); + nlinfo("UT: Send the universal time %" NL_I64 "d to '%s'", ut, netbase.hostAddress(from).asString().c_str()); CMessage msgout ("GUT"); msgout.serial (ut); @@ -359,7 +359,7 @@ void _CUniTime::syncUniTimeFromServer (CCallbackClient * /* client */) attempt++; } client->disconnect (); - nlinfo ("Universal time is %"NL_I64"dms with a mean error of %"NL_I64"dms", _CUniTime::getUniTime(), bestdelta/2); + nlinfo ("Universal time is %" NL_I64 "dms with a mean error of %" NL_I64 "dms", _CUniTime::getUniTime(), bestdelta/2); return; error: nlwarning ("there's no connection or lost or can't synchronize universal time"); @@ -377,12 +377,12 @@ NLMISC_CATEGORISED_COMMAND(nel, time, "displays the universal time", "") if ( _CUniTime::Sync ) { - log.displayNL ("CTime::getLocalTime(): %"NL_I64"dms, _CUniTime::getUniTime(): %"NL_I64"dms", CTime::getLocalTime (), _CUniTime::getUniTime ()); + log.displayNL ("CTime::getLocalTime(): %" NL_I64 "dms, _CUniTime::getUniTime(): %" NL_I64 "dms", CTime::getLocalTime (), _CUniTime::getUniTime ()); log.displayNL ("_CUniTime::getStringUniTime(): '%s'", _CUniTime::getStringUniTime()); } else { - log.displayNL ("CTime::getLocalTime(): %"NL_I64"dms ", CTime::getLocalTime ()); + log.displayNL ("CTime::getLocalTime(): %" NL_I64 "dms ", CTime::getLocalTime ()); } return true; diff --git a/code/nel/src/pacs/edge_collide.cpp b/code/nel/src/pacs/edge_collide.cpp index 700935947..c0766b691 100644 --- a/code/nel/src/pacs/edge_collide.cpp +++ b/code/nel/src/pacs/edge_collide.cpp @@ -174,9 +174,9 @@ CRational64 CEdgeCollide::testPointMove(const CVector2f &start, const CVector2f */ /* if (numerator != numeratorInt) - nlwarning("numerator(%f) != numeratorInt(%"NL_I64"d)", numerator, numeratorInt); + nlwarning("numerator(%f) != numeratorInt(%" NL_I64 "d)", numerator, numeratorInt); if (denominator != denominatorInt) - nlwarning("denominator(%f) != denominatorInt(%"NL_I64"d)", denominator, denominatorInt); + nlwarning("denominator(%f) != denominatorInt(%" NL_I64 "d)", denominator, denominatorInt); */ return CRational64(numeratorInt, denominatorInt); } From a6b1ac43316d65134783b70582f8427518f227b1 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 15 Jan 2016 11:52:09 +0100 Subject: [PATCH 02/12] Fix VS2015 warnings --- code/nel/src/misc/debug.cpp | 8 ++++---- code/nel/src/misc/eval_num_expr.cpp | 2 +- code/nel/src/misc/mem_displayer.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index 45a55188c..44cd6f706 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -864,18 +864,18 @@ public: else if(type == "int") { if (!IsBadReadPtr(addr,sizeof(int))) - sprintf (tmp, "%d", *addr); + sprintf (tmp, "%p", (void *)(*addr)); } else if (type == "char") { if (!IsBadReadPtr(addr,sizeof(char))) if (nlisprint(*addr)) { - sprintf (tmp, "'%c'", *addr); + sprintf (tmp, "'%c'", (char)((*addr) & 0xFF)); } else { - sprintf (tmp, "%d", *addr); + sprintf (tmp, "%p", (void *)(*addr)); } } else if (type == "char*") @@ -932,7 +932,7 @@ public: if(*addr == 0) sprintf (tmp, ""); else - sprintf (tmp, "0x%p", *addr); + sprintf (tmp, "0x%p", (void *)*addr); } } diff --git a/code/nel/src/misc/eval_num_expr.cpp b/code/nel/src/misc/eval_num_expr.cpp index c47309498..1bfad17eb 100644 --- a/code/nel/src/misc/eval_num_expr.cpp +++ b/code/nel/src/misc/eval_num_expr.cpp @@ -945,7 +945,7 @@ CEvalNumExpr::TReturnState CEvalNumExpr::evalExpression (double &finalResult, TT value = (double)(uint)((floor (value+0.5)==0.0)); break; case Tilde: - value = (double)~((uint)floor (value+0.5)); + value = (double)(~((uint)floor (value+0.5)) & std::numeric_limits::max()); break; case Minus: value = -value; diff --git a/code/nel/src/misc/mem_displayer.cpp b/code/nel/src/misc/mem_displayer.cpp index d92c4d432..40cc1bb6e 100644 --- a/code/nel/src/misc/mem_displayer.cpp +++ b/code/nel/src/misc/mem_displayer.cpp @@ -99,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", *((DWORD_TYPE*)(stackAddr) + 2 + pos++)); + sprintf(tmp, "=0x%p", (void *)(*((DWORD_TYPE*)(stackAddr) + 2 + pos++))); str += tmp; } str += parse[i]; From e9912417bf02ecd690db816e4d67071015c55bf9 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 15 Jan 2016 12:04:06 +0100 Subject: [PATCH 03/12] More VS2015 fixes --- code/nel/src/3d/dru.cpp | 6 +++--- code/nel/src/3d/texture_dlm.cpp | 2 +- code/nel/src/net/service.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/code/nel/src/3d/dru.cpp b/code/nel/src/3d/dru.cpp index 22d207682..bb86d8b84 100644 --- a/code/nel/src/3d/dru.cpp +++ b/code/nel/src/3d/dru.cpp @@ -99,7 +99,7 @@ IDriver *CDRU::createGlDriver() throw (EDru) throw EDruOpenglDriverNotFound(); } - nlinfo ("Using the library '"NL3D_GL_DLL_NAME"' that is in the directory: '%s'", driverLib.getLibFileName().c_str()); + nlinfo ("Using the library '" NL3D_GL_DLL_NAME "' that is in the directory: '%s'", driverLib.getLibFileName().c_str()); createDriver = (IDRV_CREATE_PROC) driverLib.getSymbolAddress(IDRV_CREATE_PROC_NAME); if (createDriver == NULL) @@ -153,7 +153,7 @@ IDriver *CDRU::createGlEsDriver() throw (EDru) throw EDruOpenglEsDriverNotFound(); } - nlinfo ("Using the library '"NL3D_GLES_DLL_NAME"' that is in the directory: '%s'", driverLib.getLibFileName().c_str()); + nlinfo ("Using the library '" NL3D_GLES_DLL_NAME "' that is in the directory: '%s'", driverLib.getLibFileName().c_str()); createDriver = (IDRV_CREATE_PROC) driverLib.getSymbolAddress(IDRV_CREATE_PROC_NAME); if (createDriver == NULL) @@ -206,7 +206,7 @@ IDriver *CDRU::createD3DDriver() throw (EDru) throw EDruDirect3dDriverNotFound(); } - nlinfo ("Using the library '"NL3D_D3D_DLL_NAME"' that is in the directory: '%s'", driverLib.getLibFileName().c_str()); + nlinfo ("Using the library '" NL3D_D3D_DLL_NAME "' that is in the directory: '%s'", driverLib.getLibFileName().c_str()); createDriver = (IDRV_CREATE_PROC) driverLib.getSymbolAddress(IDRV_CREATE_PROC_NAME); if (createDriver == NULL) diff --git a/code/nel/src/3d/texture_dlm.cpp b/code/nel/src/3d/texture_dlm.cpp index 40f87987c..2c8603859 100644 --- a/code/nel/src/3d/texture_dlm.cpp +++ b/code/nel/src/3d/texture_dlm.cpp @@ -385,7 +385,7 @@ void CTextureDLM::releaseLightMap(uint x, uint y) // Free this bit in the block. nlassert(block->FreeSpace & mask); - block->FreeSpace&= ~mask; + block->FreeSpace&= (~mask & std::numeric_limits::max()); // Free the block if necessary. diff --git a/code/nel/src/net/service.cpp b/code/nel/src/net/service.cpp index f7dc40da1..8f5a142cc 100644 --- a/code/nel/src/net/service.cpp +++ b/code/nel/src/net/service.cpp @@ -838,7 +838,7 @@ sint IService::main (const char *serviceShortName, const char *serviceLongName, } } - nlinfo ("SERVICE: Starting Service '%s' using NeL ("__DATE__" "__TIME__") compiled %s", _ShortName.c_str(), CompilationDate.c_str()); + nlinfo ("SERVICE: Starting Service '%s' using NeL (" __DATE__ " " __TIME__ ") compiled %s", _ShortName.c_str(), CompilationDate.c_str()); nlinfo ("SERVICE: On OS: %s", CSystemInfo::getOS().c_str()); setExitStatus (EXIT_SUCCESS); @@ -1802,7 +1802,7 @@ NLMISC_CATEGORISED_COMMAND(nel, serviceInfo, "display information about this ser if(args.size() != 0) return false; - log.displayNL ("Service %s '%s' using NeL ("__DATE__" "__TIME__")", IService::getInstance()->getServiceLongName().c_str(), IService::getInstance()->getServiceUnifiedName().c_str()); + log.displayNL ("Service %s '%s' using NeL (" __DATE__ " " __TIME__ ")", IService::getInstance()->getServiceLongName().c_str(), IService::getInstance()->getServiceUnifiedName().c_str()); log.displayNL ("Service listening port: %d", IService::getInstance()->ListeningPort.get()); log.displayNL ("Service running directory: '%s'", IService::getInstance()->RunningDirectory.c_str()); log.displayNL ("Service log directory: '%s'", IService::getInstance()->LogDirectory.c_str()); From b81ae23369103dca8829d6e99fa6303849a58aed Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 15 Jan 2016 12:07:33 +0100 Subject: [PATCH 04/12] Fix another VS2015 warning --- code/nel/include/nel/misc/smart_ptr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/include/nel/misc/smart_ptr.h b/code/nel/include/nel/misc/smart_ptr.h index 2bfb57cc3..016097a3c 100644 --- a/code/nel/include/nel/misc/smart_ptr.h +++ b/code/nel/include/nel/misc/smart_ptr.h @@ -352,7 +352,7 @@ public: } }; -#if defined(NL_COMP_VC) && NL_COMP_VC_VERSION >= 80 +#if defined(NL_COMP_VC) && NL_COMP_VC_VERSION >= 80 && NL_COMP_VC_VERSION < 140 // This operator only purpose is to compare with NULL value template From 8405248a32cc8dffac00b6b48016a9d8222cd969 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 15 Jan 2016 12:22:35 +0100 Subject: [PATCH 05/12] VS2015 fixes for NeL Samples --- code/nel/samples/net/udp/bench_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/samples/net/udp/bench_service.cpp b/code/nel/samples/net/udp/bench_service.cpp index 190347d4b..d36b8557a 100644 --- a/code/nel/samples/net/udp/bench_service.cpp +++ b/code/nel/samples/net/udp/bench_service.cpp @@ -299,7 +299,7 @@ void CClient::updatePong (sint64 pingTime, sint64 pongTime, uint32 pongNumber, u } else { - fprintf (fp, "%"NL_I64"d\t%"NL_I64"d\t%"NL_I64"d\t%d\n", pongTime, pingTime, (pongTime-pingTime), pongNumber); + fprintf (fp, "%" NL_I64 "d\t%" NL_I64 "d\t%" NL_I64 "d\t%d\n", pongTime, pingTime, (pongTime-pingTime), pongNumber); fclose (fp); } } From 9c1d333924b8ad5d701dcd51a0e6ec4f295a9cba Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 15 Jan 2016 12:29:05 +0100 Subject: [PATCH 06/12] More of the VS2015 stuff --- code/nel/samples/net/udp/bench_service.cpp | 2 +- code/nel/samples/net/udp/simlag.cpp | 2 +- code/ryzom/client/src/cdb_synchronised.cpp | 2 +- code/ryzom/client/src/character_cl.cpp | 12 ++++++------ code/ryzom/client/src/login_progress_post_thread.cpp | 2 +- code/ryzom/client/src/network_connection.cpp | 8 ++++---- code/ryzom/client/src/property_decoder.cpp | 2 +- code/ryzom/client/src/user_entity.cpp | 2 +- .../common/src/game_share/mirrored_data_set.cpp | 12 ++++++------ code/ryzom/common/src/game_share/simlag.cpp | 2 +- code/snowballs2/client/src/network.cpp | 2 +- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/code/nel/samples/net/udp/bench_service.cpp b/code/nel/samples/net/udp/bench_service.cpp index d36b8557a..4b75a6b93 100644 --- a/code/nel/samples/net/udp/bench_service.cpp +++ b/code/nel/samples/net/udp/bench_service.cpp @@ -578,7 +578,7 @@ void handleReceivedPong (CClient *client, sint64 pongTime) uint32 blockNumber = 0; msgin.serial(blockNumber); -// nlinfo ("receive a pong from %s pongnb %d %"NL_I64"d", CurrentInMsg->AddrFrom.asString().c_str(), pongNumber, pongTime - pingTime); +// nlinfo ("receive a pong from %s pongnb %d %" NL_I64 "d", CurrentInMsg->AddrFrom.asString().c_str(), pongNumber, pongTime - pingTime); client->updatePong (pingTime, pongTime, pongNumber, blockNumber); } diff --git a/code/nel/samples/net/udp/simlag.cpp b/code/nel/samples/net/udp/simlag.cpp index 9697413c0..c1839cfc9 100644 --- a/code/nel/samples/net/udp/simlag.cpp +++ b/code/nel/samples/net/udp/simlag.cpp @@ -142,7 +142,7 @@ void sendUDPNow (CUdpSock *client, const uint8 *packet, uint32 packetSize, const client->sendTo (packet, packetSize, *addr); uint32 packetNumber = *(uint32 *)packet; -// nlinfo ("time %"NL_I64"u sending now packet %5u", CTime::getLocalTime (), packetNumber); +// nlinfo ("time %" NL_I64 "u sending now packet %5u", CTime::getLocalTime (), packetNumber); } void sendUDP (CUdpSock *client, const uint8 *packet, uint32 packetSize, const CInetAddress *addr) diff --git a/code/ryzom/client/src/cdb_synchronised.cpp b/code/ryzom/client/src/cdb_synchronised.cpp index c8f3c4a44..1bc280fdf 100644 --- a/code/ryzom/client/src/cdb_synchronised.cpp +++ b/code/ryzom/client/src/cdb_synchronised.cpp @@ -255,7 +255,7 @@ bool CCDBSynchronised::setProp(const string &name, sint64 value) } #ifdef TRACE_SET_VALUE - nlinfo("Set value %"NL_I64"d for Prop %s", value,name.c_str() ); + nlinfo("Set value %" NL_I64 "d for Prop %s", value,name.c_str() ); #endif // Set the property. diff --git a/code/ryzom/client/src/character_cl.cpp b/code/ryzom/client/src/character_cl.cpp index 029fd9486..5d949b201 100644 --- a/code/ryzom/client/src/character_cl.cpp +++ b/code/ryzom/client/src/character_cl.cpp @@ -8399,7 +8399,7 @@ ADD_METHOD(void CCharacterCL::displayDebug(float x, float &y, float lineStep)) / if(isPlayer() || isUser()) { SPropVisualA visualA = *(SPropVisualA *)(&prop); - TextContext->printfAt(x, y, "VPA: %"NL_I64"X : Chest(%d,%d) Legs(%d,%d) Arms(%d,%d) Hat(%d,%d) RH(%d) LH(%d)", prop, + TextContext->printfAt(x, y, "VPA: %" NL_I64 "X : Chest(%d,%d) Legs(%d,%d) Arms(%d,%d) Hat(%d,%d) RH(%d) LH(%d)", prop, (uint)visualA.PropertySubData.JacketModel, (uint)visualA.PropertySubData.JacketColor, (uint)visualA.PropertySubData.TrouserModel, (uint)visualA.PropertySubData.TrouserColor, (uint)visualA.PropertySubData.ArmModel, (uint)visualA.PropertySubData.ArmColor, @@ -8408,29 +8408,29 @@ ADD_METHOD(void CCharacterCL::displayDebug(float x, float &y, float lineStep)) / (uint)visualA.PropertySubData.WeaponLeftHand); } else - TextContext->printfAt(x, y, "VPA: %"NL_I64"X", prop); + TextContext->printfAt(x, y, "VPA: %" NL_I64 "X", prop); y += lineStep; // VPB prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", _Slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); if(isPlayer() || isUser()) { SPropVisualB visualB = *(SPropVisualB *)(&prop); - TextContext->printfAt(x, y, "VPB: %"NL_I64"X : Hands(%d,%d) Feet(%d,%d).", prop, + TextContext->printfAt(x, y, "VPB: %" NL_I64 "X : Hands(%d,%d) Feet(%d,%d).", prop, (uint)visualB.PropertySubData.HandsModel, (uint)visualB.PropertySubData.HandsColor, (uint)visualB.PropertySubData.FeetModel, (uint)visualB.PropertySubData.FeetColor); } else - TextContext->printfAt(x, y, "VPB: %"NL_I64"X", prop); + TextContext->printfAt(x, y, "VPB: %" NL_I64 "X", prop); y += lineStep; // VPC prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", _Slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); if(isPlayer() || isUser()) { SPropVisualC visualC = *(SPropVisualC *)(&prop); - TextContext->printfAt(x, y, "VPC: %"NL_I64"X : EyesColor(%d) Tattoo(%d).", prop, visualC.PropertySubData.EyesColor, visualC.PropertySubData.Tattoo); + TextContext->printfAt(x, y, "VPC: %" NL_I64 "X : EyesColor(%d) Tattoo(%d).", prop, visualC.PropertySubData.EyesColor, visualC.PropertySubData.Tattoo); } else - TextContext->printfAt(x, y, "VPC: %"NL_I64"X", prop); + TextContext->printfAt(x, y, "VPC: %" NL_I64 "X", prop); y += lineStep; }// displayDebug // diff --git a/code/ryzom/client/src/login_progress_post_thread.cpp b/code/ryzom/client/src/login_progress_post_thread.cpp index 14d300bcb..788877980 100644 --- a/code/ryzom/client/src/login_progress_post_thread.cpp +++ b/code/ryzom/client/src/login_progress_post_thread.cpp @@ -34,7 +34,7 @@ using namespace NLMISC; static std::string uint64ToHex(uint64 size) { char data[256]; - sprintf(data, "%"NL_I64"X", size); + sprintf(data, "%" NL_I64 "X", size); return std::string(data); } diff --git a/code/ryzom/client/src/network_connection.cpp b/code/ryzom/client/src/network_connection.cpp index 47d573ca2..5a7e42179 100644 --- a/code/ryzom/client/src/network_connection.cpp +++ b/code/ryzom/client/src/network_connection.cpp @@ -189,7 +189,7 @@ void displayReceiveLog() TReceiveDateLog::iterator idl; for ( idl=ReceivePosDateLog[i].begin(); idl!=ReceivePosDateLog[i].end(); ++idl ) { - ReceiveLogger.displayRawNL( "%u\t%u\t%"NL_I64"u", (*idl).ServerCycle, (*idl).PredictedInterval, (*idl).LocalTime ); + ReceiveLogger.displayRawNL( "%u\t%u\t%" NL_I64 "u", (*idl).ServerCycle, (*idl).PredictedInterval, (*idl).LocalTime ); } } } @@ -1156,7 +1156,7 @@ void CNetworkConnection::receiveSystemSync(CBitMemStream &msgin) _CurrentClientTick = uint32(_CurrentServerTick - (_LCT+_MsPerTick)/_MsPerTick); _CurrentClientTime = _UpdateTime - (_LCT+_MsPerTick); - //nlinfo( "CNET[%p]: received SYNC %"NL_I64"u %"NL_I64"u - _CurrentReceivedNumber=%d _CurrentServerTick=%d", this, (uint64)_Synchronize, (uint64)stime, _CurrentReceivedNumber, _CurrentServerTick ); + //nlinfo( "CNET[%p]: received SYNC %" NL_I64 "u %" NL_I64 "u - _CurrentReceivedNumber=%d _CurrentServerTick=%d", this, (uint64)_Synchronize, (uint64)stime, _CurrentReceivedNumber, _CurrentServerTick ); sendSystemAckSync(); } @@ -1704,7 +1704,7 @@ void CNetworkConnection::decodeVisualProperties( CBitMemStream& msgin ) { nlinfo( "CLIENT: recvd property %hu (%s) for slot %hu, date %u", (uint16)PROPERTY_ORIENTATION, getPropText(PROPERTY_ORIENTATION), (uint16)slot, timestamp ); } - //nldebug("CLPROPNET[%p]: received property %d for entity %d: %"NL_I64"u", this, action->PropIndex, action->CLEntityId, action->getValue()); + //nldebug("CLPROPNET[%p]: received property %d for entity %d: %" NL_I64 "u", this, action->PropIndex, action->CLEntityId, action->getValue()); } } @@ -1964,7 +1964,7 @@ void CNetworkConnection::decodeDiscreetProperty( CBitMemStream& msgin, TPropInde { nlinfo( "CLIENT: recvd property %hu (%s) for slot %hu, date %u", (uint16)propIndex, getPropText(propIndex), (uint16)slot, TVPNodeClient::SlotContext.Timestamp ); } - //nldebug("CLPROPNET[%p]: received property %d for entity %d: %"NL_I64"u", this, action->PropIndex, action->CLEntityId, action->getValue()); + //nldebug("CLPROPNET[%p]: received property %d for entity %d: %" NL_I64 "u", this, action->PropIndex, action->CLEntityId, action->getValue()); } } } diff --git a/code/ryzom/client/src/property_decoder.cpp b/code/ryzom/client/src/property_decoder.cpp index bd839cec1..cb0bd5649 100644 --- a/code/ryzom/client/src/property_decoder.cpp +++ b/code/ryzom/client/src/property_decoder.cpp @@ -107,7 +107,7 @@ void CPropertyDecoder::receive(TPacketNumber /* packetNumber */, CAction *action property.LastReceived = act->getValue(); - nldebug("CLPROPD: Received (Id=%d,Act=%d)=(%"NL_I64"d)(Pck=%d)", act->Slot, act->Code, property.LastReceived, packetNumber); + nldebug("CLPROPD: Received (Id=%d,Act=%d)=(%" NL_I64 "d)(Pck=%d)", act->Slot, act->Code, property.LastReceived, packetNumber); } */ } diff --git a/code/ryzom/client/src/user_entity.cpp b/code/ryzom/client/src/user_entity.cpp index dcf0ccf41..1d0c27570 100644 --- a/code/ryzom/client/src/user_entity.cpp +++ b/code/ryzom/client/src/user_entity.cpp @@ -3552,7 +3552,7 @@ void CUserEntity::CSpeedFactor::update(ICDBNode *node) // virtual { CCDBNodeLeaf *leaf = safe_cast(node); _Value = ((float)leaf->getValue64())/100.0f; - //nlinfo("SpeedFactor changed to %f / %"NL_I64"u", _Value, leaf->getValue64()); + //nlinfo("SpeedFactor changed to %f / %" NL_I64 "u", _Value, leaf->getValue64()); // clamp the value (2.0 is the egg item or the level 6 speed up power up, nothing should be faster) // commented because ring editor speed is in fact faster diff --git a/code/ryzom/common/src/game_share/mirrored_data_set.cpp b/code/ryzom/common/src/game_share/mirrored_data_set.cpp index 3787c91f7..69884afee 100644 --- a/code/ryzom/common/src/game_share/mirrored_data_set.cpp +++ b/code/ryzom/common/src/game_share/mirrored_data_set.cpp @@ -1550,12 +1550,12 @@ void CMirroredDataSet::displayPropValue( const std::string& propName, const T } case TypeUint64: { - displayValueLine( propName, "%"NL_I64"u", "U64", (uint64*)NULL, this, entityIndex, propIndex, flagsStr, log ); + displayValueLine( propName, "%" NL_I64 "u", "U64", (uint64*)NULL, this, entityIndex, propIndex, flagsStr, log ); break; } case TypeSint64: { - displayValueLine( propName, "%"NL_I64"d", "S64", (sint64*)NULL, this, entityIndex, propIndex, flagsStr, log ); + displayValueLine( propName, "%" NL_I64 "d", "S64", (sint64*)NULL, this, entityIndex, propIndex, flagsStr, log ); break; } case TypeFloat: @@ -1635,12 +1635,12 @@ void CMirroredDataSet::setValueFromString( const TDataSetRow& entityIndex, TP } case TypeUint64: { - assignValue( this, entityIndex, propIndex, valueStr.c_str(), "%"NL_I64"u", (uint64*)NULL ); + assignValue( this, entityIndex, propIndex, valueStr.c_str(), "%" NL_I64 "u", (uint64*)NULL ); break; } case TypeSint64: { - assignValue( this, entityIndex, propIndex, valueStr.c_str(), "%"NL_I64"d", (sint64*)NULL ); + assignValue( this, entityIndex, propIndex, valueStr.c_str(), "%" NL_I64 "d", (sint64*)NULL ); break; } case TypeFloat: @@ -1726,12 +1726,12 @@ void CMirroredDataSet::getValueToString( const TDataSetRow& entityIndex, TPro } case TypeUint64: { - displayValue( this, entityIndex, propIndex, tmpStr, "%"NL_I64"u", (uint64*)NULL ); + displayValue( this, entityIndex, propIndex, tmpStr, "%" NL_I64 "u", (uint64*)NULL ); break; } case TypeSint64: { - displayValue( this, entityIndex, propIndex, tmpStr, "%"NL_I64"d", (sint64*)NULL ); + displayValue( this, entityIndex, propIndex, tmpStr, "%" NL_I64 "d", (sint64*)NULL ); break; } case TypeFloat: diff --git a/code/ryzom/common/src/game_share/simlag.cpp b/code/ryzom/common/src/game_share/simlag.cpp index 56acd59d1..ee637c95e 100644 --- a/code/ryzom/common/src/game_share/simlag.cpp +++ b/code/ryzom/common/src/game_share/simlag.cpp @@ -138,7 +138,7 @@ void sendUDPNow (CUdpSock *client, const uint8 *packet, uint32 packetSize, const client->sendTo (packet, packetSize, *addr); // uint32 packetNumber = *(uint32 *)packet; -// nlinfo ("time %"NL_I64"u sending now packet %5u", CTime::getLocalTime (), packetNumber); +// nlinfo ("time %" NL_I64 "u sending now packet %5u", CTime::getLocalTime (), packetNumber); } void sendUDP (CUdpSock *client, const uint8 *packet, uint32 packetSize, const CInetAddress *addr) diff --git a/code/snowballs2/client/src/network.cpp b/code/snowballs2/client/src/network.cpp index 819b89f29..544645243 100644 --- a/code/snowballs2/client/src/network.cpp +++ b/code/snowballs2/client/src/network.cpp @@ -379,7 +379,7 @@ void updateNetwork() TextContext->setHotSpot (UTextContext::MiddleTop); TextContext->setColor (CRGBA(255, 255, 255, 255)); TextContext->setFontSize (14); - TextContext->printfAt (0.5f, 0.99f, "d:%"NL_I64"u u:%"NL_I64"u / d:%"NL_I64"u u:%"NL_I64"u / d:%"NL_I64"u u:%"NL_I64"u", + TextContext->printfAt (0.5f, 0.99f, "d:%" NL_I64 "u u:%" NL_I64 "u / d:%" NL_I64 "u u:%" NL_I64 "u / d:%" NL_I64 "u u:%" NL_I64 "u", Connection->bytesDownloaded (), Connection->bytesUploaded (), Connection->getBytesReceived (),Connection->getBytesSent (), newBytesDownloaded, newBytesUploaded); From c4f5b5d5215ba63bd29b1086887ebdf5fd5bc42d Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 15 Jan 2016 12:33:27 +0100 Subject: [PATCH 07/12] And more VS2015 fixes --- code/ryzom/client/src/connection.cpp | 4 ++-- code/ryzom/common/src/game_share/object.cpp | 4 ++-- .../leveldesign/csv_transform/sadge_lib/include/text_output.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index a2d139294..69c05cc08 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -2122,7 +2122,7 @@ public: CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND)); if (pList == NULL) { - nlwarning("element "GROUP_LIST_MAINLAND" not found probably bad outgame.xml"); + nlwarning("element " GROUP_LIST_MAINLAND " not found probably bad outgame.xml"); return; } @@ -2315,7 +2315,7 @@ public: List = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET)); if (List == NULL) { - nlwarning("element "GROUP_LIST_KEYSET" not found probably bad outgame.xml"); + nlwarning("element " GROUP_LIST_KEYSET " not found probably bad outgame.xml"); return; } diff --git a/code/ryzom/common/src/game_share/object.cpp b/code/ryzom/common/src/game_share/object.cpp index f4426d067..d3f8856af 100644 --- a/code/ryzom/common/src/game_share/object.cpp +++ b/code/ryzom/common/src/game_share/object.cpp @@ -894,7 +894,7 @@ void CObjectInteger::inPlaceCopy(const CObjectInteger &src) } -std::string CObjectInteger::doToString() const { return NLMISC::toString("%d"NL_I64, _Value); } +std::string CObjectInteger::doToString() const { return NLMISC::toString("%" NL_I64 "d", _Value); } void CObjectInteger::doSerialize(std::string& out, CSerializeContext& /* context */) const { @@ -1977,7 +1977,7 @@ void CObjectInteger::dump(const std::string prefix, uint depth) const { //H_AUTO(R2_CObjectInteger_dump) std::string result(depth * 4, ' '); - result += NLMISC::toString("%sInteger, ptr = 0x%p, value = %d"NL_I64", ghost = %s", prefix.c_str(), this, _Value, _Ghost ? "true" : "false"); + result += NLMISC::toString("%sInteger, ptr = 0x%p, value = %" NL_I64 "d, ghost = %s", prefix.c_str(), this, _Value, _Ghost ? "true" : "false"); nlwarning(result.c_str()); } diff --git a/code/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_output.h b/code/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_output.h index 2eec9a4a0..1fd931f17 100644 --- a/code/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_output.h +++ b/code/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_output.h @@ -236,7 +236,7 @@ private: break; default: - fprintf(stderr,"\n"__FILE__":%d: BUG: invlid special code in CTextOutput object: %d\n",__LINE__,(int)code); + fprintf(stderr,"\n" __FILE__ ":%d: BUG: invlid special code in CTextOutput object: %d\n",__LINE__,(int)code); } } From 8b95360709b17abaae4fb61f0cf1b687047fa805 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 15 Jan 2016 16:17:23 +0100 Subject: [PATCH 08/12] More of that VS2015 magic --- code/ryzom/client/src/login.cpp | 8 ++++---- code/ryzom/client/src/r2/displayer_visual_entity.cpp | 2 +- code/ryzom/client/src/r2/editor.cpp | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index ae08874ba..35a811f9b 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -208,7 +208,7 @@ void createOptionalCatUI() CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_CAT)); if (pList == NULL) { - nlwarning("element "GROUP_LIST_CAT" not found probably bad login_main.xml"); + nlwarning("element " GROUP_LIST_CAT " not found probably bad login_main.xml"); return; } @@ -1085,7 +1085,7 @@ void initShardDisplay() CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_SHARD)); if (pList == NULL) { - nlwarning("element "GROUP_LIST_SHARD" not found probably bad login_main.xml"); + nlwarning("element " GROUP_LIST_SHARD " not found probably bad login_main.xml"); return; } /* // To test more servers @@ -1303,7 +1303,7 @@ class CAHOnLogin : public IActionHandler CGroupEditBox *pGEBPwd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_PASSWORD)); if ((pGEBLog == NULL) || (pGEBPwd == NULL)) { - nlwarning("element "CTRL_EDITBOX_LOGIN" or "CTRL_EDITBOX_PASSWORD" not found probably bad login_main.xml"); + nlwarning("element " CTRL_EDITBOX_LOGIN " or " CTRL_EDITBOX_PASSWORD " not found probably bad login_main.xml"); return; } @@ -1587,7 +1587,7 @@ void initPatch() CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_CAT)); if (pList == NULL) { - nlwarning("element "GROUP_LIST_CAT" not found probably bad login_main.xml"); + nlwarning("element " GROUP_LIST_CAT " not found probably bad login_main.xml"); return; } diff --git a/code/ryzom/client/src/r2/displayer_visual_entity.cpp b/code/ryzom/client/src/r2/displayer_visual_entity.cpp index 6b5e091e2..8f4fcf244 100644 --- a/code/ryzom/client/src/r2/displayer_visual_entity.cpp +++ b/code/ryzom/client/src/r2/displayer_visual_entity.cpp @@ -1108,7 +1108,7 @@ std::string CDisplayerVisualEntity::getVisualProperties() const uint64 uVPB = leafB->getValue64(); uint64 uVPC = leafC->getValue64(); - const std::string strVPABC = NLMISC::toString( "VPA:%016.16"NL_I64"x\nVPB:%016.16"NL_I64"x\nVPC:%016.16"NL_I64"x", uVPA, uVPB, uVPC ); + const std::string strVPABC = NLMISC::toString( "VPA:%016.16" NL_I64 "x\nVPB:%016.16" NL_I64 "x\nVPC:%016.16" NL_I64 "x", uVPA, uVPB, uVPC ); return strVPABC; } diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index 2cc6c1812..337e77828 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -806,7 +806,7 @@ int CEditor::luaGetVisualPropertiesFromInstanceId(CLuaState &ls) uint64 uVPB = vB.get(); uint64 uVPC = vC.get(); - std::string strVPABC = NLMISC::toString( "VPA:%016.16"NL_I64"x\nVPB:%016.16"NL_I64"x\nVPC:%016.16"NL_I64"x", uVPA, uVPB, uVPC ); + std::string strVPABC = NLMISC::toString( "VPA:%016.16" NL_I64 "x\nVPB:%016.16" NL_I64 "x\nVPC:%016.16" NL_I64 "x", uVPA, uVPB, uVPC ); ls.push(strVPABC); @@ -1957,12 +1957,12 @@ int CEditor::luaRemoveInstanceObserver(CLuaState &ls) IInstanceObserver *observer = getEditor().getInstanceObserver((TInstanceObserverHandle) ls.toInteger(2)); if (observer == NULL) { - CLuaIHM::fails(ls, "Instance observer not found for handle = %d"NL_I64, ls.toInteger(2)); + CLuaIHM::fails(ls, "Instance observer not found for handle = %" NL_I64 "d", ls.toInteger(2)); } CInstanceObserverLua *luaObserver = dynamic_cast(observer); if (luaObserver == NULL) { - CLuaIHM::fails(ls, "Instance observer found for handle %d"NL_I64", but has bad type, it wasn't registered from lua.", ls.toInteger(2)); + CLuaIHM::fails(ls, "Instance observer found for handle %" NL_I64 "d, but has bad type, it wasn't registered from lua.", ls.toInteger(2)); } getEditor().removeInstanceObserver((TInstanceObserverHandle) ls.toInteger(2)); CLuaObject receiver = luaObserver->getReceiver(); From fe6cc6656bbcb476a07b3137f577d89fa9589cbf Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 15 Jan 2016 16:42:21 +0100 Subject: [PATCH 09/12] Fix bad printf parameters --- code/ryzom/tools/leveldesign/export/export.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/code/ryzom/tools/leveldesign/export/export.cpp b/code/ryzom/tools/leveldesign/export/export.cpp index b15e48a59..e140bfc3b 100644 --- a/code/ryzom/tools/leveldesign/export/export.cpp +++ b/code/ryzom/tools/leveldesign/export/export.cpp @@ -561,13 +561,13 @@ bool SExportOptions::loadcf (CConfigFile &cf) bool SExportOptions::save (FILE *f) { fprintf (f,"\n// Export Options\n"); - fprintf (f, "EXP_OutIGDir = \"%s\";\n", OutIGDir); - fprintf (f, "EXP_ZoneWDir = \"%s\";\n", InLandscapeDir); - fprintf (f, "EXP_SmallBank = \"%s\";\n", LandBankFile); - fprintf (f, "EXP_FarBank = \"%s\";\n", LandFarBankFile); - fprintf (f, "EXP_DisplaceDir = \"%s\";\n", LandTileNoiseDir); + fprintf (f, "EXP_OutIGDir = \"%s\";\n", OutIGDir.c_str()); + fprintf (f, "EXP_ZoneWDir = \"%s\";\n", InLandscapeDir.c_str()); + fprintf (f, "EXP_SmallBank = \"%s\";\n", LandBankFile.c_str()); + fprintf (f, "EXP_FarBank = \"%s\";\n", LandFarBankFile.c_str()); + fprintf (f, "EXP_DisplaceDir = \"%s\";\n", LandTileNoiseDir.c_str()); fprintf (f, "EXP_CellSize = %f;\n", CellSize); - fprintf (f, "EXP_PrimFloraDir = \"%s\";\n", PrimFloraDir); + fprintf (f, "EXP_PrimFloraDir = \"%s\";\n", PrimFloraDir.c_str()); return true; } From 8f61c6dfa90b7b281bd01af8ff4208613c304db6 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 15 Jan 2016 17:10:39 +0100 Subject: [PATCH 10/12] Separate window displayer message stringify --- code/nel/include/nel/misc/window_displayer.h | 2 ++ code/nel/src/misc/window_displayer.cpp | 37 +++++++++++++------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/code/nel/include/nel/misc/window_displayer.h b/code/nel/include/nel/misc/window_displayer.h index de05b25d5..4fc86c2b0 100644 --- a/code/nel/include/nel/misc/window_displayer.h +++ b/code/nel/include/nel/misc/window_displayer.h @@ -64,6 +64,8 @@ public: virtual void getWindowPos (uint32 &x, uint32 &y, uint32 &w, uint32 &h) { x=y=w=h=0; } + static std::string stringifyMessage(const NLMISC::CLog::TDisplayInfo &args, const char *message, bool needSlashR = false); + protected: // display a string (MT) diff --git a/code/nel/src/misc/window_displayer.cpp b/code/nel/src/misc/window_displayer.cpp index 5c9227933..c36ff6f58 100644 --- a/code/nel/src/misc/window_displayer.cpp +++ b/code/nel/src/misc/window_displayer.cpp @@ -116,26 +116,20 @@ void CWindowDisplayer::create (string windowNameEx, bool iconified, sint x, sint _Thread->start (); } -void CWindowDisplayer::doDisplay (const NLMISC::CLog::TDisplayInfo &args, const char *message) +std::string CWindowDisplayer::stringifyMessage(const NLMISC::CLog::TDisplayInfo &args, const char *message, bool needSlashR) { bool needSpace = false; //stringstream ss; string str; - uint32 color = 0xFF000000; - if (args.LogType != CLog::LOG_NO) { - str += logTypeToString(args.LogType); - if (args.LogType == CLog::LOG_ERROR || args.LogType == CLog::LOG_ASSERT) color = 0x00FF0000; - else if (args.LogType == CLog::LOG_WARNING) color = 0x00800000; - else if (args.LogType == CLog::LOG_DEBUG) color = 0x00808080; - else color = 0; + str += CWindowDisplayer::logTypeToString(args.LogType); needSpace = true; } // Write thread identifier - if ( args.ThreadId != 0 ) + if (args.ThreadId != 0) { if (needSpace) { str += " "; needSpace = false; } #ifdef NL_OS_WINDOWS @@ -173,7 +167,7 @@ void CWindowDisplayer::doDisplay (const NLMISC::CLog::TDisplayInfo &args, const uint nbl = 1; char *npos, *pos = const_cast(message); - while ((npos = strchr (pos, '\n'))) + while ((npos = strchr(pos, '\n'))) { *npos = '\0'; str += pos; @@ -181,13 +175,13 @@ void CWindowDisplayer::doDisplay (const NLMISC::CLog::TDisplayInfo &args, const str += "\r"; str += "\n"; *npos = '\n'; - pos = npos+1; + pos = npos + 1; nbl++; } str += pos; pos = const_cast(args.CallstackAndLog.c_str()); - while ((npos = strchr (pos, '\n'))) + while ((npos = strchr(pos, '\n'))) { *npos = '\0'; str += pos; @@ -195,11 +189,28 @@ void CWindowDisplayer::doDisplay (const NLMISC::CLog::TDisplayInfo &args, const str += "\r"; str += "\n"; *npos = '\n'; - pos = npos+1; + pos = npos + 1; nbl++; } str += pos; + return str; +} + +void CWindowDisplayer::doDisplay (const NLMISC::CLog::TDisplayInfo &args, const char *message) +{ + uint32 color = 0xFF000000; + + if (args.LogType != CLog::LOG_NO) + { + if (args.LogType == CLog::LOG_ERROR || args.LogType == CLog::LOG_ASSERT) color = 0x00FF0000; + else if (args.LogType == CLog::LOG_WARNING) color = 0x00800000; + else if (args.LogType == CLog::LOG_DEBUG) color = 0x00808080; + else color = 0; + } + + std::string str = stringifyMessage(args, message, needSlashR); + { CSynchronized > >::CAccessor access (&_Buffer); if (_HistorySize > 0 && access.value().size() >= (uint)_HistorySize) From 20f93996ea446466450a4d752a4194cd2778ff4d Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 15 Jan 2016 17:11:10 +0100 Subject: [PATCH 11/12] Add panoply preview tool --- code/nel/tools/3d/CMakeLists.txt | 5 + .../tools/3d/panoply_preview/CMakeLists.txt | 36 ++ .../tools/3d/panoply_preview/greenpill.ico | Bin 0 -> 3638 bytes code/nel/tools/3d/panoply_preview/icon.rc | 1 + .../tools/3d/panoply_preview/main_window.cpp | 138 +++++ .../tools/3d/panoply_preview/main_window.h | 95 ++++ .../3d/panoply_preview/panoply_preview.cpp | 523 ++++++++++++++++++ .../3d/panoply_preview/panoply_preview.h | 125 +++++ .../tools/3d/panoply_preview/tool_config.h | 105 ++++ .../tools/3d/panoply_preview/tool_main.cpp | 176 ++++++ code/nel/tools/3d/panoply_preview/tool_main.h | 33 ++ .../tools/3d/shared_widgets/CMakeLists.txt | 23 + .../tools/3d/shared_widgets/command_log.cpp | 159 ++++++ .../nel/tools/3d/shared_widgets/command_log.h | 111 ++++ code/nel/tools/3d/shared_widgets/common.h | 87 +++ 15 files changed, 1617 insertions(+) create mode 100644 code/nel/tools/3d/panoply_preview/CMakeLists.txt create mode 100644 code/nel/tools/3d/panoply_preview/greenpill.ico create mode 100644 code/nel/tools/3d/panoply_preview/icon.rc create mode 100644 code/nel/tools/3d/panoply_preview/main_window.cpp create mode 100644 code/nel/tools/3d/panoply_preview/main_window.h create mode 100644 code/nel/tools/3d/panoply_preview/panoply_preview.cpp create mode 100644 code/nel/tools/3d/panoply_preview/panoply_preview.h create mode 100644 code/nel/tools/3d/panoply_preview/tool_config.h create mode 100644 code/nel/tools/3d/panoply_preview/tool_main.cpp create mode 100644 code/nel/tools/3d/panoply_preview/tool_main.h create mode 100644 code/nel/tools/3d/shared_widgets/CMakeLists.txt create mode 100644 code/nel/tools/3d/shared_widgets/command_log.cpp create mode 100644 code/nel/tools/3d/shared_widgets/command_log.h create mode 100644 code/nel/tools/3d/shared_widgets/common.h diff --git a/code/nel/tools/3d/CMakeLists.txt b/code/nel/tools/3d/CMakeLists.txt index bb35cbb5f..034fc5f55 100644 --- a/code/nel/tools/3d/CMakeLists.txt +++ b/code/nel/tools/3d/CMakeLists.txt @@ -67,6 +67,11 @@ IF(WITH_NEL_TOOLS AND WITH_3D) ADD_SUBDIRECTORY(object_viewer_widget) ENDIF() + IF(WITH_QT5) + ADD_SUBDIRECTORY(shared_widgets) + ADD_SUBDIRECTORY(panoply_preview) + ENDIF() + IF(WITH_NEL_TOOLS) FIND_PACKAGE(Squish) ENDIF() diff --git a/code/nel/tools/3d/panoply_preview/CMakeLists.txt b/code/nel/tools/3d/panoply_preview/CMakeLists.txt new file mode 100644 index 000000000..6d1cbd354 --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/CMakeLists.txt @@ -0,0 +1,36 @@ + +FILE(GLOB SRCS *.cpp) +FILE(GLOB HDRS *.h) +IF (WIN32) + FILE(GLOB RSRC *.rc) +ENDIF (WIN32) +FILE(GLOB RESOURCES *.qrc) + +FILE(GLOB PANOPLY_MAKER ../panoply_maker/color_modifier.cpp ../panoply_maker/color_modifier.h) + +SOURCE_GROUP("" FILES ${SRCS} ${HDRS} ${RSRC} ${RESOURCES}) +SOURCE_GROUP("panoply_maker" FILES ${PANOPLY_MAKER}) + +SET(CMAKE_AUTOMOC ON) + +QT5_ADD_RESOURCES(RESOURCE_ADDED ${RESOURCES}) + +CMAKE_POLICY(SET CMP0020 NEW) +ADD_EXECUTABLE(nl_panoply_preview WIN32 ${SRC} + ${SRCS} + ${HDRS} + ${RSRC} + ${RESOURCE_ADDED} + ${PANOPLY_MAKER} + ) + +TARGET_LINK_LIBRARIES(nl_panoply_preview + nelmisc + nel3d + shared_widgets + Qt5::Widgets) + +NL_DEFAULT_PROPS(nl_panoply_preview "NeL, Tools, 3D: panoply_preview") +NL_ADD_RUNTIME_FLAGS(nl_panoply_preview) + +INSTALL(TARGETS nl_panoply_preview RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT samples3d) diff --git a/code/nel/tools/3d/panoply_preview/greenpill.ico b/code/nel/tools/3d/panoply_preview/greenpill.ico new file mode 100644 index 0000000000000000000000000000000000000000..d2b9e8a20db5cd70480f795b9d76df93496b44dc GIT binary patch literal 3638 zcmeH}J&RL86o%j2@6ROa+^abWxP>hGFZKrrHiC^{VWF@P3xB|-3-)3euv-x9Qdk)l zOEC!BX|YwT1UoH+@tm8vH{+^g)n<$Pz;Kf}@5~v_P3F8n2M%_2z|RPW5wHuO-(P=! z=mYO~?mEx01baM0_b0U0(BHpcwOZkmKE`sn#7F%a@AV73(N8g-&oP_LFr7~EN>A`o z@8h|?jc0lfPxK8u*1)5$!2W08!3wzl0l0Sz+l>(P1&$ZR9Pegn7^Z2OWm(RU*ZeYB!0|i{T-OhRkYSk> zhr{s^g)Ta-FNlboW<8wh{8_bLmRIXf$48X?lz$Un*M~EZeg3Arvbn)}Jyg%N&ofnk z?|`j*!+|~lt}cLZ0=P0Dw!#|q{DL(ntd%uqL3|2Zm&&Vb^C^GpQN*8!H?cj*@BB#X zQ}_k6v=um~72taW<$t5r)ccsWs@C1NRHi?wSQ=Gas5I{iD(Wz9p}ZhTxJfFx`G7(> ua6HfVmE3}Gi&8m36*v2p<*9si-hX^@31E-K0Whg@Oa2WqCox+qpML=5Vmj9V literal 0 HcmV?d00001 diff --git a/code/nel/tools/3d/panoply_preview/icon.rc b/code/nel/tools/3d/panoply_preview/icon.rc new file mode 100644 index 000000000..64e741cac --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/icon.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "greenpill.ico" \ No newline at end of file diff --git a/code/nel/tools/3d/panoply_preview/main_window.cpp b/code/nel/tools/3d/panoply_preview/main_window.cpp new file mode 100644 index 000000000..4f7b7ddc2 --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/main_window.cpp @@ -0,0 +1,138 @@ +// NeL - MMORPG Framework +// Copyright (C) 2014 Jan BOON (jan.boon@kaetemi.be) +// +// 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 . + +#include +#include "main_window.h" + +// STL includes + +// Qt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// NeL includes +// #include +#include +#include + +// Project includes +#include "../shared_widgets/command_log.h" +#include "panoply_preview.h" + +using namespace std; +using namespace NLMISC; + +namespace NLTOOLS { + +namespace { + +QString nli18n(const char *label) +{ + return QString::fromUtf16(CI18N::get(label).c_str()); +} + +} /* anonymous namespace */ + +CMainWindow::CMainWindow(const QMap &customSizeHints, QWidget *parent, Qt::WindowFlags flags) + : QMainWindow(parent, flags), + m_PanoplyPreview(NULL), + m_CommandLog(NULL), m_CommandLogDock(NULL), + m_WidgetsMenu(NULL), m_HelpMenu(NULL), + m_AboutAct(NULL) +{ + setObjectName("CMainWindow"); + setWindowTitle(tr("NeL Panoply Preview")); + + createActions(); + createMenus(); + createToolBars(); + createStatusBar(); + + m_PanoplyPreview = new CPanoplyPreview(this); + setCentralWidget(m_PanoplyPreview); + + createDockWindows(); +} + +CMainWindow::~CMainWindow() +{ + +} + +void CMainWindow::createActions() +{ + m_AboutAct = new QAction(this); + connect(m_AboutAct, SIGNAL(triggered()), this, SLOT(about())); + + m_AboutAct->setText(tr("About")); + m_AboutAct->setStatusTip(tr("About")); +} + +void CMainWindow::createMenus() +{ + m_WidgetsMenu = menuBar()->addMenu(QString::null); + + m_HelpMenu = menuBar()->addMenu(QString::null); + m_HelpMenu->addAction(m_AboutAct); + + m_WidgetsMenu->setTitle(tr("Widgets")); + m_HelpMenu->setTitle(tr("Help")); +} + +void CMainWindow::createToolBars() +{ + +} + +void CMainWindow::createStatusBar() +{ + statusBar()->showMessage(tr("Ready")); +} + +void CMainWindow::createDockWindows() +{ + // CommandLog (Console) + { + m_CommandLogDock = new QDockWidget(this); + m_CommandLogDock->setWindowTitle(tr("Console")); + m_CommandLogDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); + m_CommandLog = new NLQT::CCommandLogDisplayer(m_CommandLogDock); + m_CommandLogDock->setWidget(m_CommandLog); + addDockWidget(Qt::BottomDockWidgetArea, m_CommandLogDock); + m_WidgetsMenu->addAction(m_CommandLogDock->toggleViewAction()); + } +} + +void CMainWindow::about() +{ + QMessageBox::about(this, tr("Panoply Preview"), tr("Copyright (C) 2014 Jan BOON (jan.boon@kaetemi.be)")); +} + +} /* namespace NLTOOLS */ + +/* end of file */ diff --git a/code/nel/tools/3d/panoply_preview/main_window.h b/code/nel/tools/3d/panoply_preview/main_window.h new file mode 100644 index 000000000..3e3d2f025 --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/main_window.h @@ -0,0 +1,95 @@ +// NeL - MMORPG Framework +// Copyright (C) 2014 Jan BOON (jan.boon@kaetemi.be) +// +// 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 . + +#ifndef NLTOOLS_MAIN_WINDOW_H +#define NLTOOLS_MAIN_WINDOW_H +#include + +// STL includes + +// Qt includes +#include + +// NeL includes +#include +#include +#include +#include +#include + +// Project includes +// ... + +class QTreeView; +class QDirModel; +class QUndoStack; +class QScrollArea; + +namespace NLQT { + class CCommandLogDisplayer; +} + +namespace NLTOOLS { + class CPanoplyPreview; + +/** + * CMainWindow + * \brief CMainWindow + * \date 2014-09-19 09:38GMT + * \author Jan BOON (jan.boon@kaetemi.be) + */ +class CMainWindow : public QMainWindow +{ + Q_OBJECT + +public: + CMainWindow(const QMap &customSizeHints, QWidget *parent = 0, Qt::WindowFlags flags = 0); + virtual ~CMainWindow(); + + inline QMenu *widgetsMenu() { return m_WidgetsMenu; } + +private slots: + void about(); + +private: + void createActions(); + void createMenus(); + void createToolBars(); + void createStatusBar(); + void createDockWindows(); + +private: + CMainWindow(const CMainWindow &); + CMainWindow &operator=(const CMainWindow &); + +private: + CPanoplyPreview *m_PanoplyPreview; + + NLQT::CCommandLogDisplayer *m_CommandLog; + QDockWidget *m_CommandLogDock; + + QMenu *m_WidgetsMenu; + QMenu *m_HelpMenu; + + QAction *m_AboutAct; + +}; /* class CMainWindow */ + +} /* namespace NLTOOLS */ + +#endif /* #ifndef NLTOOLS_MAIN_WINDOW_H */ + +/* end of file */ diff --git a/code/nel/tools/3d/panoply_preview/panoply_preview.cpp b/code/nel/tools/3d/panoply_preview/panoply_preview.cpp new file mode 100644 index 000000000..964711eea --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/panoply_preview.cpp @@ -0,0 +1,523 @@ +// NeL - MMORPG Framework +// Copyright (C) 2014 Jan BOON (jan.boon@kaetemi.be) +// +// 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 . + +#include +#include "panoply_preview.h" + +// STL includes + +// Qt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// NeL includes +#include +#include +#include +#include +#include +#include +#include + +// Project includes +#include "main_window.h" +#include "../panoply_maker/color_modifier.h" + +using namespace std; +using namespace NLMISC; + +namespace NLTOOLS { + +class CColorThread : public NLMISC::IRunnable +{ +public: + // Called when a thread is run. + virtual void run() + { + while (Running) + { + SettingsMutex.enter(); + if (!Running) + { + SettingsMutex.leave(); + return; + } + if (!Process) + { + SettingsMutex.leave(); + nlSleep(10); // TODO: Should wait on an event signal... + continue; + } + // nldebug("Update color modifier"); + m_ColorModifier.Hue = Hue; + m_ColorModifier.Lightness = Lightness; + m_ColorModifier.Saturation = Saturation; + m_ColorModifier.Luminosity = Luminosity; + m_ColorModifier.Contrast = Contrast; + Process = false; + SettingsMutex.leave(); + + BitmapMutex.enter(); + if (!Running) + { + BitmapMutex.leave(); + return; + } + if (!BitmapsOk) + { + nldebug("Bitmaps not ready"); + BitmapMutex.leave(); + nlSleep(500); + continue; + } + float retDeltaHue; + DestBitmap = ColorBitmap; + m_ColorModifier.convertBitmap(DestBitmap, ColorBitmap, MaskBitmap, retDeltaHue); + BitmapMutex.leave(); + + PanoplyPreview->displayBitmap(DestBitmap); + + nlSleep(10); // TODO: Should wait on an event signal... + } + } + + CColorThread() : PanoplyPreview(NULL), BitmapsOk(false), Hue(0), Lightness(0), Saturation(0), Luminosity(0), Contrast(0), Process(false), Running(true) { } + virtual ~CColorThread() { } + virtual void getName (std::string &result) const { result = "CColorThread"; } + +private: + CColorModifier m_ColorModifier; + +public: + CPanoplyPreview *PanoplyPreview; + + NLMISC::CMutex BitmapMutex; + NLMISC::CBitmap ColorBitmap; + NLMISC::CBitmap MaskBitmap; + bool BitmapsOk; + NLMISC::CBitmap DestBitmap; + + NLMISC::CMutex SettingsMutex; + float Hue; + float Lightness; + float Saturation; + float Luminosity; + float Contrast; + bool Process; + + bool Running; +}; + +// ***************************************************************** + +CPanoplyPreview::CPanoplyPreview(CMainWindow *parent) : QWidget(parent) +{ + connect(this, SIGNAL(tSigBitmap()), this, SLOT(tSlotBitmap())); + + createDockWindows(parent); + + m_Image = new QImage(512, 512, QImage::Format_RGB32); + m_Pixmap = new QPixmap(512, 512); + + setMinimumWidth(512); + setMinimumHeight(512); + + m_ColorThread = new CColorThread(); + m_ColorThread->PanoplyPreview = this; + m_Thread = IThread::create(m_ColorThread); + m_Thread->start(); +} + +CPanoplyPreview::~CPanoplyPreview() +{ + m_ColorThread->SettingsMutex.enter(); + m_ColorThread->BitmapMutex.enter(); + m_ColorThread->Running = false; + m_ColorThread->BitmapMutex.leave(); + m_ColorThread->SettingsMutex.leave(); + m_Thread->wait(); + delete m_Thread; + delete m_ColorThread; +} + +void CPanoplyPreview::paintEvent(QPaintEvent* e) +{ + QPainter painter(this); + painter.drawPixmap(0, 0, *m_Pixmap); +} + +void CPanoplyPreview::displayBitmap(const CBitmap &bitmap) // Called from thread! +{ + // nldebug("received bitmap"); + + m_ColorThread->BitmapMutex.enter(); + m_ImageMutex.enter(); + + const char *buffer = (const char *)&bitmap.getPixels()[0]; + + if (bitmap.getWidth() != m_Image->width() || bitmap.getHeight() != m_Image->height()) + { + QImage *image = m_Image; + m_Image = new QImage(bitmap.getWidth(), bitmap.getHeight(), QImage::Format_RGB32); + delete image; + } + + for (uint32 y = 0; y < bitmap.getHeight(); ++y) + { + uint8 *dst = (uint8 *)m_Image->scanLine(y); + const uint8 *src = (const uint8 *)&buffer[y * bitmap.getWidth() * sizeof(uint32)]; + for (uint32 x = 0; x < bitmap.getWidth(); ++x) + { + uint32 xb = x * 4; + dst[xb + 0] = src[xb + 2]; + dst[xb + 1] = src[xb + 1]; + dst[xb + 2] = src[xb + 0]; + dst[xb + 3] = src[xb + 3]; + } + + //memcpy(m_Image->scanLine(y), &buffer[y * bitmap.getWidth() * sizeof(uint32)], sizeof(uint32) * bitmap.getWidth()); + } + + m_ImageMutex.leave(); + m_ColorThread->BitmapMutex.leave(); + + tSigBitmap(); +} + +void CPanoplyPreview::tSlotBitmap() +{ + // nldebug("display bitmap"); + + m_ImageMutex.enter(); + + if (m_Image->width() != m_Pixmap->width() + || m_Image->height() != m_Pixmap->height()) + { + QPixmap *pixmap = m_Pixmap; + m_Pixmap = new QPixmap(m_Image->width(), m_Image->height()); + setMinimumWidth(m_Pixmap->width()); + setMinimumHeight(m_Pixmap->height()); + delete pixmap; + } + m_Pixmap->convertFromImage(*m_Image); + repaint(); + + m_ImageMutex.leave(); + +} + +void CPanoplyPreview::colorEdited(const QString &text) +{ + m_ColorFile = text; +} + +void CPanoplyPreview::maskEdited(const QString &text) +{ + m_MaskFile = text; +} + +void CPanoplyPreview::goPushed(bool) +{ + // nldebug("push bitmaps"); + m_ColorThread->SettingsMutex.enter(); + m_ColorThread->BitmapMutex.enter(); + m_ColorThread->BitmapsOk = false; + + try + { + { + NLMISC::CIFile is; + if (!is.open(m_ColorFile.toLocal8Bit().data())) + throw NLMISC::Exception("Cannot open file '%s'", m_ColorFile.toLocal8Bit().data()); + uint32 depth = m_ColorThread->ColorBitmap.load(is); + if (depth == 0 || m_ColorThread->ColorBitmap.getPixels().empty()) + throw NLMISC::Exception("Failed to load bitmap '%s'", m_ColorFile.toLocal8Bit().data()); + if (m_ColorThread->ColorBitmap.PixelFormat != NLMISC::CBitmap::RGBA) + m_ColorThread->ColorBitmap.convertToType(NLMISC::CBitmap::RGBA); + } + { + NLMISC::CIFile is; + if (!is.open(m_MaskFile.toLocal8Bit().data())) + throw NLMISC::Exception("Cannot open file '%s'", m_MaskFile.toLocal8Bit().data()); + uint32 depth = m_ColorThread->MaskBitmap.load(is); + if (depth == 0 || m_ColorThread->MaskBitmap.getPixels().empty()) + throw NLMISC::Exception("Failed to load bitmap '%s'", m_MaskFile.toLocal8Bit().data()); + if (m_ColorThread->MaskBitmap.PixelFormat != NLMISC::CBitmap::RGBA) + m_ColorThread->MaskBitmap.convertToType(NLMISC::CBitmap::RGBA); + } + { + m_ColorThread->BitmapsOk = true; + m_ColorThread->Process = true; + } + } + catch (const NLMISC::Exception &e) + { + nlwarning("Exception: '%s'", e.what()); + } + + m_ColorThread->BitmapMutex.leave(); + m_ColorThread->SettingsMutex.leave(); + // nldebug("done pushing butmaps"); +} + +void CPanoplyPreview::hueChanged(int value) +{ + float v = (float)value; + m_ColorThread->SettingsMutex.enter(); + m_ColorThread->Hue = v; + m_ColorThread->Process = true; + m_ColorThread->SettingsMutex.leave(); +} + +void CPanoplyPreview::lightnessChanged(int value) +{ + float v = (float)value * 0.01f; + m_ColorThread->SettingsMutex.enter(); + m_ColorThread->Lightness = v; + m_ColorThread->Process = true; + m_ColorThread->SettingsMutex.leave(); +} + +void CPanoplyPreview::saturationChanged(int value) +{ + float v = (float)value * 0.01f; + m_ColorThread->SettingsMutex.enter(); + m_ColorThread->Saturation = v; + m_ColorThread->Process = true; + m_ColorThread->SettingsMutex.leave(); +} + +void CPanoplyPreview::luminosityChanged(int value) +{ + float v = (float)value; + m_ColorThread->SettingsMutex.enter(); + m_ColorThread->Luminosity = v; + m_ColorThread->Process = true; + m_ColorThread->SettingsMutex.leave(); +} + +void CPanoplyPreview::contrastChanged(int value) +{ + float v = (float)value; + m_ColorThread->SettingsMutex.enter(); + m_ColorThread->Contrast = v; + m_ColorThread->Process = true; + m_ColorThread->SettingsMutex.leave(); +} + +// ***************************************************************** + +CSliderTextEdit::CSliderTextEdit(QWidget *parent, QLineEdit *lineEdit, float scale) : QSlider(Qt::Horizontal, parent), m_LineEdit(lineEdit), m_Updating(false), m_Scale(scale) +{ + connect(this, SIGNAL(valueChanged(int)), this, SLOT(sliderValueChanged(int))); + connect(lineEdit, SIGNAL(textEdited(const QString &)), this, SLOT(lineEditTextEdited(const QString &))); +} + +CSliderTextEdit::~CSliderTextEdit() +{ + +} + +void CSliderTextEdit::lineEditTextEdited(const QString &text) +{ + if (!m_Updating) + { + m_Updating = true; + setValue((int)(text.toFloat() * m_Scale)); + m_Updating = false; + } +} + +void CSliderTextEdit::sliderValueChanged(int value) +{ + if (!m_Updating) + { + m_Updating = true; + m_LineEdit->setText(QString::number((double)value / (double)m_Scale)); + m_Updating = false; + } +} + +// ***************************************************************** + +void CPanoplyPreview::createDockWindows(CMainWindow *mainWindow) +{ + nlassert(mainWindow); + + // Color Modifier + { + QDockWidget *dockWidget = new QDockWidget(mainWindow); + nlassert(dockWidget); + dockWidget->setWindowTitle(tr("Color Modifier")); + dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + QScrollArea *scrollArea = new QScrollArea(dockWidget); + scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + scrollArea->setWidgetResizable(true); + QWidget *widget = new QWidget(scrollArea); + QVBoxLayout *vboxLayout = new QVBoxLayout(widget); + + // Input File Paths + { + QGroupBox *groupBox = new QGroupBox(widget); + groupBox->setTitle(tr("Input File Paths")); + QGridLayout *groupLayout = new QGridLayout(groupBox); + + QLabel *colorLabel = new QLabel(groupBox); + colorLabel->setText(tr("Color: ")); + groupLayout->addWidget(colorLabel, 0, 0); + + QLineEdit *colorFile = new QLineEdit(groupBox); + colorFile->setText("W:\\database\\stuff\\fyros\\agents\\_textures\\actors\\fy_hof_armor00_arm01_c1.png"); + groupLayout->addWidget(colorFile, 0, 1); + + m_ColorFile = colorFile->text(); + connect(colorFile, SIGNAL(textEdited(const QString &)), this, SLOT(colorEdited(const QString &))); + + QLabel *maskLabel = new QLabel(groupBox); + maskLabel->setText(tr("Mask: ")); + groupLayout->addWidget(maskLabel, 1, 0); + + QLineEdit *maskFile = new QLineEdit(groupBox); + maskFile->setText("W:\\database\\stuff\\fyros\\agents\\_textures\\actors\\mask\\fy_hof_armor00_arm01_c1_skin.png"); + groupLayout->addWidget(maskFile, 1, 1); + + m_MaskFile = maskFile->text(); + connect(maskFile, SIGNAL(textEdited(const QString &)), this, SLOT(maskEdited(const QString &))); + + QPushButton *go = new QPushButton(groupBox); + go->setText(tr("Go")); + groupLayout->addWidget(go, 2, 0, 1, 2); + + connect(go, SIGNAL(clicked(bool)), this, SLOT(goPushed(bool))); + + groupBox->setLayout(groupLayout); + vboxLayout->addWidget(groupBox); + } + + // Color Modifier + { + QGroupBox *groupBox = new QGroupBox(widget); + groupBox->setTitle(tr("Color Modifier")); + QGridLayout *groupLayout = new QGridLayout(groupBox); + + QLabel *label; + QLineEdit *edit; + CSliderTextEdit *slider; + + label = new QLabel(groupBox); + label->setText(tr("Hue [0, 360]: ")); + groupLayout->addWidget(label, 0, 0); + + edit = new QLineEdit(groupBox); + edit->setText("0"); + groupLayout->addWidget(edit, 0, 1); + + slider = new CSliderTextEdit(groupBox, edit, 1.0f); + slider->setMinimum(0); + slider->setMaximum(360); + slider->setValue(0); + groupLayout->addWidget(slider, 1, 0, 1, 2); + + connect(slider, SIGNAL(valueChanged(int)), this, SLOT(hueChanged(int))); + + label = new QLabel(groupBox); + label->setText(tr("Lightness [-1, 1]: ")); + groupLayout->addWidget(label, 2, 0); + + edit = new QLineEdit(groupBox); + edit->setText("0"); + groupLayout->addWidget(edit, 2, 1); + + slider = new CSliderTextEdit(groupBox, edit, 100.0f); + slider->setMinimum(-100); + slider->setMaximum(100); + slider->setValue(0); + groupLayout->addWidget(slider, 3, 0, 1, 2); + + connect(slider, SIGNAL(valueChanged(int)), this, SLOT(lightnessChanged(int))); + + label = new QLabel(groupBox); + label->setText(tr("Saturation [-1, 1]: ")); + groupLayout->addWidget(label, 4, 0); + + edit = new QLineEdit(groupBox); + edit->setText("0"); + groupLayout->addWidget(edit, 4, 1); + + slider = new CSliderTextEdit(groupBox, edit, 100.0f); + slider->setMinimum(-100); + slider->setMaximum(100); + slider->setValue(0); + groupLayout->addWidget(slider, 5, 0, 1, 2); + + connect(slider, SIGNAL(valueChanged(int)), this, SLOT(saturationChanged(int))); + + label = new QLabel(groupBox); + label->setText(tr("Luminosity [-100, 100]: ")); + groupLayout->addWidget(label, 6, 0); + + edit = new QLineEdit(groupBox); + edit->setText("0"); + groupLayout->addWidget(edit, 6, 1); + + slider = new CSliderTextEdit(groupBox, edit, 1.0f); + slider->setMinimum(-100); + slider->setMaximum(100); + slider->setValue(0); + groupLayout->addWidget(slider, 7, 0, 1, 2); + + connect(slider, SIGNAL(valueChanged(int)), this, SLOT(luminosityChanged(int))); + + label = new QLabel(groupBox); + label->setText(tr("Contrast [-100, 100]: ")); + groupLayout->addWidget(label, 8, 0); + + edit = new QLineEdit(groupBox); + edit->setText("0"); + groupLayout->addWidget(edit, 8, 1); + + slider = new CSliderTextEdit(groupBox, edit, 1.0f); + slider->setMinimum(-100); + slider->setMaximum(100); + slider->setValue(0); + groupLayout->addWidget(slider, 9, 0, 1, 2); + + connect(slider, SIGNAL(valueChanged(int)), this, SLOT(contrastChanged(int))); + + groupBox->setLayout(groupLayout); + vboxLayout->addWidget(groupBox); + } + + vboxLayout->addStretch(); + widget->setLayout(vboxLayout); + scrollArea->setWidget(widget); + dockWidget->setWidget(scrollArea); + mainWindow->addDockWidget(Qt::LeftDockWidgetArea, dockWidget); + mainWindow->widgetsMenu()->addAction(dockWidget->toggleViewAction()); + } +} + +} /* namespace NLTOOLS */ + +/* end of file */ diff --git a/code/nel/tools/3d/panoply_preview/panoply_preview.h b/code/nel/tools/3d/panoply_preview/panoply_preview.h new file mode 100644 index 000000000..9fbe2bad3 --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/panoply_preview.h @@ -0,0 +1,125 @@ +// NeL - MMORPG Framework +// Copyright (C) 2014 Jan BOON (jan.boon@kaetemi.be) +// +// 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 . + +#ifndef NLTOOLS_PANOPLY_PREVIEW_H +#define NLTOOLS_PANOPLY_PREVIEW_H +#include + +// STL includes + +// Qt includes +#include +#include +#include +#include +#include +#include + +// NeL includes +#include +#include + +// Project includes + +namespace NLMISC { + class CBitmap; + class IThread; +} + +namespace NLTOOLS { + class CMainWindow; + class CColorThread; + +/** + * CPanoplyPreview + * \brief CPanoplyPreview + * \date 2014-09-19 09:38GMT + * \author Jan BOON (jan.boon@kaetemi.be) + */ +class CPanoplyPreview : public QWidget +{ + Q_OBJECT + +public: + CPanoplyPreview(CMainWindow *parent); + virtual ~CPanoplyPreview(); + + void displayBitmap(const NLMISC::CBitmap &bitmap); // Called from thread! + +protected: + virtual void paintEvent(QPaintEvent *e); + +signals: + void tSigBitmap(); + +private slots: + void tSlotBitmap(); + + void colorEdited(const QString &text); + void maskEdited(const QString &text); + void goPushed(bool); + + void hueChanged(int value); + void lightnessChanged(int value); + void saturationChanged(int value); + void luminosityChanged(int value); + void contrastChanged(int value); + +private: + void createDockWindows(CMainWindow *mainWindow); + +private: + NLMISC::IThread *m_Thread; + CColorThread *m_ColorThread; + + QString m_ColorFile; + QString m_MaskFile; + + QImage *m_Image; + QPixmap *m_Pixmap; + + NLMISC::CMutex m_ImageMutex; + +private: + CPanoplyPreview(const CPanoplyPreview &); + CPanoplyPreview &operator=(const CPanoplyPreview &); + +}; /* class CPanoplyPreview */ + +class CSliderTextEdit : public QSlider +{ + Q_OBJECT + +public: + CSliderTextEdit(QWidget *parent, QLineEdit *lineEdit, float scale); + virtual ~CSliderTextEdit(); + +private slots: + void lineEditTextEdited(const QString &text); + void sliderValueChanged(int value); + +private: + QLineEdit *m_LineEdit; + bool m_Updating; + float m_Scale; + +}; + +} /* namespace NLTOOLS */ + +#endif /* #ifndef NLTOOLS_PANOPLY_PREVIEW_H */ + +/* end of file */ diff --git a/code/nel/tools/3d/panoply_preview/tool_config.h b/code/nel/tools/3d/panoply_preview/tool_config.h new file mode 100644 index 000000000..94e53d2dc --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/tool_config.h @@ -0,0 +1,105 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// 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 . + +#ifndef NLTOOLS_CONFIG_H +#define NLTOOLS_CONFIG_H +#include + + + +// use the default log.log file (not erased on use) +// #define NLTOOLS_USE_LOG_LOG false + + + +// the config file name +// #define NLTOOLS_CONFIG_FILE "panoply_preview.cfg" +// #define NLTOOLS_CONFIG_FILE_DEFAULT "panoply_preview_default.cfg" + + + +// use panoply_preview log file +// #define NLTOOLS_USE_LOG 1 + +// panoply_preview log file name +#define NLTOOLS_LOG_FILE "panoply_preview.log" + +// clear panoply_preview log before use +#define NLTOOLS_ERASE_LOG true + +// version number +#define NLTOOLS_VERSION "0.10.0" + + + +// use the low fragmentation heap (windows feature) +// #define NLTOOLS_LOW_FRAGMENTATION_HEAP 1 + + + +// temporary dev tags +//#define NL_DEV_STEREO 0 +//#define NL_DEV_MEMLEAK 1 +//#define NL_DEV_NET 0 +//#define NL_DEV_NETNEW 1 +//#define NL_DEV_CG 0 +//#define NL_DEV_BULLET 0 + + + +// some default defines +#if FINAL_VERSION +# if !defined(NLTOOLS_USE_LOG_LOG) +# define NLTOOLS_USE_LOG_LOG false +# endif +# if !defined(NLTOOLS_USE_LOG) +# define NLTOOLS_USE_LOG 0 +# endif +#endif + +#if !defined (NLTOOLS_USE_LOG_LOG) +# define NLTOOLS_USE_LOG_LOG true +#endif +#if !defined (NLTOOLS_USE_LOG) +# define NLTOOLS_USE_LOG 1 +#endif + +#if !defined (NLTOOLS_LOW_FRAGMENTATION_HEAP) +# ifdef NL_OS_WINDOWS +# define NLTOOLS_LOW_FRAGMENTATION_HEAP 1 +# else +# define NLTOOLS_LOW_FRAGMENTATION_HEAP 0 +# endif +#endif + +// for compatibility with old configuration +#ifndef NLTOOLS_CONFIG_FILE +# ifndef NLTOOLS_CONFIG +# define NLTOOLS_CONFIG_FILE "panoply_preview.cfg" +# else +# define NLTOOLS_CONFIG_FILE NLTOOLS_CONFIG "panoply_preview.cfg" +# endif +#endif + +#ifndef NLTOOLS_CONFIG_FILE_DEFAULT +# define NLTOOLS_CONFIG_FILE_DEFAULT "panoply_preview_default.cfg" +#endif + + + +#endif /* #ifndef NLTOOLS_CONFIG_H */ + +/* end of file */ diff --git a/code/nel/tools/3d/panoply_preview/tool_main.cpp b/code/nel/tools/3d/panoply_preview/tool_main.cpp new file mode 100644 index 000000000..d1e08205f --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/tool_main.cpp @@ -0,0 +1,176 @@ +// NeL - MMORPG Framework +// Copyright (C) 2014 Jan BOON (jan.boon@kaetemi.be) +// +// 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 . + +#include +#include "tool_main.h" + +// STL includes +#include +#ifdef NL_OS_WINDOWS +# include +# include +# include +#endif + +// Qt includes +#include +#include +#include +#include + +// NeL includes +#include +#include +#include +#include +#include +#include + +// Project includes +#include "../shared_widgets/common.h" +#include "tool_config.h" +#include "main_window.h" + +using namespace std; +using namespace NLMISC; + +namespace NLTOOLS { + +namespace { + +CFileDisplayer *s_FileDisplayer = NULL; + +} /* anonymous namespace */ + +} /* namespace NLTOOLS */ + +void usage() +{ + /* from Qt sample */ + + qWarning() << "Usage: mainwindow [-SizeHint x] ..."; + exit(1); +} + +QMap parseCustomSizeHints(int argc, char **argv) +{ + /* from Qt sample */ + + QMap result; + + for (int i = 1; i < argc; ++i) { + QString arg = QString::fromLocal8Bit(argv[i]); + + if (arg.startsWith(QLatin1String("-SizeHint"))) { + QString name = arg.mid(9); + if (name.isEmpty()) + usage(); + if (++i == argc) + usage(); + QString sizeStr = QString::fromLocal8Bit(argv[i]); + int idx = sizeStr.indexOf(QLatin1Char('x')); + if (idx == -1) + usage(); + bool ok; + int w = sizeStr.left(idx).toInt(&ok); + if (!ok) + usage(); + int h = sizeStr.mid(idx + 1).toInt(&ok); + if (!ok) + usage(); + result[name] = QSize(w, h); + } + } + + return result; +} + +#ifdef NL_OS_WINDOWS +# ifdef _UNICODE +# define tstring wstring +# else +# define tstring string +# endif +#endif + +sint main(int argc, char **argv) +{ + // go nel! + { + // use log.log if NEL_LOG_IN_FILE and NLTOOLS_USE_LOG_LOG defined as 1 + createDebug(NULL, NLTOOLS_USE_LOG_LOG, false); + +#if NLTOOLS_USE_LOG + // create toverhex_client.log + // filedisplayer only deletes the 001 etc + if (NLTOOLS_ERASE_LOG && CFile::isExists(NLTOOLS_LOG_FILE)) + CFile::deleteFile(NLTOOLS_LOG_FILE); + // initialize the log file + NLTOOLS::s_FileDisplayer = new CFileDisplayer(); + NLTOOLS::s_FileDisplayer->setParam(NLTOOLS_LOG_FILE, NLTOOLS_ERASE_LOG); + DebugLog->addDisplayer(NLTOOLS::s_FileDisplayer); + InfoLog->addDisplayer(NLTOOLS::s_FileDisplayer); + WarningLog->addDisplayer(NLTOOLS::s_FileDisplayer); + AssertLog->addDisplayer(NLTOOLS::s_FileDisplayer); + ErrorLog->addDisplayer(NLTOOLS::s_FileDisplayer); +#endif + + nlinfo("Welcome to NeL!"); + } + + // low fragmentation heap (windows) +#if NLTOOLS_LOW_FRAGMENTATION_HEAP + ULONG heapFragValue = 2; // enable low fragmentation heap + if (HeapSetInformation(GetProcessHeap(), + HeapCompatibilityInformation, + &heapFragValue, sizeof(heapFragValue))) + { + nlinfo("HeapSetInformation OK!\n"); + } + else + { + nlwarning("HeapSetInformation FAIL! (%d)\n", GetLastError()); + } +#endif + +#ifdef NL_OS_WINDOWS + HRESULT hr; + hr = hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); + bool coInitOk = (hr == S_OK) || (hr == S_FALSE); +#endif + + CSheetId::initWithoutSheet(); + + NLQT::preApplication(); + QApplication app(argc, const_cast(argv)); + NLQT::postApplication(); + + QMap customSizeHints = parseCustomSizeHints(argc, argv); + + NLTOOLS::CMainWindow mainWin(customSizeHints); + mainWin.resize(800, 600); + mainWin.show(); // calls isVisible(true) + + int result = app.exec(); + +#ifdef NL_OS_WINDOWS + if (coInitOk) CoUninitialize(); +#endif + + return result; +} + +/* end of file */ diff --git a/code/nel/tools/3d/panoply_preview/tool_main.h b/code/nel/tools/3d/panoply_preview/tool_main.h new file mode 100644 index 000000000..75eae7204 --- /dev/null +++ b/code/nel/tools/3d/panoply_preview/tool_main.h @@ -0,0 +1,33 @@ +// NeL - MMORPG Framework +// Copyright (C) 2014 Jan BOON (jan.boon@kaetemi.be) +// +// 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 . + +#ifndef NLTOOLS_MAIN_H +#define NLTOOLS_MAIN_H +#include + +// STL includes + +// NeL includes + +// Project includes + +namespace NLTOOLS { + +} /* namespace NLTOOLS */ + +#endif /* #ifndef NLTOOLS_MAIN_H */ + +/* end of file */ diff --git a/code/nel/tools/3d/shared_widgets/CMakeLists.txt b/code/nel/tools/3d/shared_widgets/CMakeLists.txt new file mode 100644 index 000000000..153995dd2 --- /dev/null +++ b/code/nel/tools/3d/shared_widgets/CMakeLists.txt @@ -0,0 +1,23 @@ +FILE(GLOB SRCS *.cpp) +FILE(GLOB HDRS *.h) +IF (WIN32) + FILE(GLOB RSRC *.rc) +ENDIF (WIN32) +FILE(GLOB RESOURCES *.qrc) + +SOURCE_GROUP("" FILES ${SRCS} ${HDRS} ${RSRC} ${RESOURCES}) + +SET(CMAKE_AUTOMOC ON) + +QT5_ADD_RESOURCES(RESOURCE_ADDED ${RESOURCES}) + +CMAKE_POLICY(SET CMP0020 NEW) +NL_TARGET_LIB(shared_widgets ${SRCS} ${HDRS} ${RSRC} ${RESOURCE_ADDED}) + +TARGET_LINK_LIBRARIES(shared_widgets nelmisc nel3d Qt5::Widgets) +NL_DEFAULT_PROPS(shared_widgets "NeL, Tools, 3D: Shared Widgets") +NL_ADD_RUNTIME_FLAGS(shared_widgets) + +IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) + INSTALL(TARGETS shared_widgets LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} COMPONENT tools3d) +ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) diff --git a/code/nel/tools/3d/shared_widgets/command_log.cpp b/code/nel/tools/3d/shared_widgets/command_log.cpp new file mode 100644 index 000000000..d7b9ee735 --- /dev/null +++ b/code/nel/tools/3d/shared_widgets/command_log.cpp @@ -0,0 +1,159 @@ +/* + +Copyright (C) 2010-2015 by authors +Author: Jan Boon +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include +#include "command_log.h" + +// STL includes + +// Qt includes +#include + +// NeL includes +#include +#include +#include +#include + +// Project includes + +using namespace std; +using namespace NLMISC; + +namespace NLQT { + +CCommandLog::CCommandLog(QWidget *parent) : QWidget(parent) +{ + m_DisplayerOutput = new QTextEdit(); + m_DisplayerOutput->setReadOnly(true); + m_DisplayerOutput->setFocusPolicy(Qt::NoFocus); + m_CommandInput = new QLineEdit(); + + QVBoxLayout *layout = new QVBoxLayout(); + layout->addWidget(m_DisplayerOutput); + layout->addWidget(m_CommandInput); + setLayout(layout); + + connect(m_CommandInput, SIGNAL(returnPressed()), this, SLOT(returnPressed())); + connect(this, SIGNAL(tSigDisplay(const QColor &, const QString &)), this, SLOT(tSlotDisplay(const QColor &, const QString &))); + +} + +CCommandLog::~CCommandLog() +{ + +} + +void CCommandLog::doDisplay(const CLog::TDisplayInfo& args, const char *message) +{ + QColor color; + switch (args.LogType) + { + case CLog::LOG_DEBUG: + color = Qt::gray; + break; + case CLog::LOG_STAT: + color = Qt::green; + break; + case CLog::LOG_NO: + case CLog::LOG_UNKNOWN: + case CLog::LOG_INFO: + color = Qt::white; + break; + case CLog::LOG_WARNING: + color = Qt::yellow; + break; + case CLog::LOG_ERROR: + case CLog::LOG_ASSERT: + color = Qt::red; + break; + default: + color = Qt::black; + break; + } + + std::string str = NLMISC::CWindowDisplayer::stringifyMessage(args, message); + + tSigDisplay(color, str.substr(0, str.size() - 1).c_str()); +} + +void CCommandLog::tSlotDisplay(const QColor &c, const QString &text) +{ + m_DisplayerOutput->setTextColor(c); + m_DisplayerOutput->append(text); +} + +void CCommandLog::returnPressed() +{ + QString text = m_CommandInput->text(); + if (text.isEmpty()) + return; + + std::string cmd = text.toLocal8Bit().data(); + execCommand(cmd); + if (m_Func) m_Func(cmd); + + m_CommandInput->clear(); +} + +CCommandLogDisplayer::CCommandLogDisplayer(QWidget *parent) : CCommandLog(parent) +{ + connect(this, SIGNAL(execCommand(const std::string &)), this, SLOT(execCommandLog(const std::string &))); + DebugLog->addDisplayer(this); + InfoLog->addDisplayer(this); + WarningLog->addDisplayer(this); + AssertLog->addDisplayer(this); + ErrorLog->addDisplayer(this); + m_Log.addDisplayer(this); +} + +CCommandLogDisplayer::~CCommandLogDisplayer() +{ + DebugLog->removeDisplayer(this); + InfoLog->removeDisplayer(this); + WarningLog->removeDisplayer(this); + AssertLog->removeDisplayer(this); + ErrorLog->removeDisplayer(this); + m_Log.removeDisplayer(this); +} + +void CCommandLogDisplayer::doDisplay(const NLMISC::CLog::TDisplayInfo& args, const char *message) +{ + CCommandLog::doDisplay(args, message); +} + +void CCommandLogDisplayer::execCommandLog(const std::string &cmd) +{ + m_Log.displayRawNL("> %s", cmd.c_str()); + ICommand::execute(cmd, m_Log); +} + +} /* namespace NLQT */ + +/* end of file */ diff --git a/code/nel/tools/3d/shared_widgets/command_log.h b/code/nel/tools/3d/shared_widgets/command_log.h new file mode 100644 index 000000000..d92f84b72 --- /dev/null +++ b/code/nel/tools/3d/shared_widgets/command_log.h @@ -0,0 +1,111 @@ +/* + +Copyright (C) 2010-2015 by authors +Author: Jan Boon +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef NLQT_COMMAND_LOG_H +#define NLQT_COMMAND_LOG_H +#include + +// STL includes + +// Qt includes +#include +#include +#include + +// NeL includes +#include +#include +#include + +// Project includes + +namespace NLQT { + +typedef NLMISC::CCallback TCommandExecute; + +class CCommandLog : public QWidget +{ + Q_OBJECT + +public: + CCommandLog(QWidget *parent); + virtual ~CCommandLog(); + + void setExecCommand(const TCommandExecute &func) { m_Func = func; } + void doDisplay(const NLMISC::CLog::TDisplayInfo& args, const char *message); + + void clear() { m_DisplayerOutput->clear(); } + +signals: + void tSigDisplay(const QColor &c, const QString &text); + void execCommand(const std::string &cmd); + +private slots: + void returnPressed(); + void tSlotDisplay(const QColor &c, const QString &text); + +private: + QTextEdit *m_DisplayerOutput; + QLineEdit *m_CommandInput; + TCommandExecute m_Func; + +private: + CCommandLog(const CCommandLog &); + CCommandLog &operator=(const CCommandLog &); + +}; /* class CCommandLog */ + +class CCommandLogDisplayer : public CCommandLog, public NLMISC::IDisplayer +{ + Q_OBJECT + +public: + CCommandLogDisplayer(QWidget *parent); + virtual ~CCommandLogDisplayer(); + +protected: + virtual void doDisplay(const NLMISC::CLog::TDisplayInfo& args, const char *message); + +private slots: + void execCommandLog(const std::string &cmd); + +private: + NLMISC::CLog m_Log; + +private: + CCommandLogDisplayer(const CCommandLogDisplayer &); + CCommandLogDisplayer &operator=(const CCommandLogDisplayer &); + +}; /* class CCommandLogDisplayer */ + +} /* namespace NLQT */ + +#endif /* #ifndef NLQT_COMMAND_LOG_H */ + +/* end of file */ diff --git a/code/nel/tools/3d/shared_widgets/common.h b/code/nel/tools/3d/shared_widgets/common.h new file mode 100644 index 000000000..23cb2b86d --- /dev/null +++ b/code/nel/tools/3d/shared_widgets/common.h @@ -0,0 +1,87 @@ +/* + +Copyright (C) 2015 by authors +Author: Jan Boon +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef NLQT_COMMON_H +#define NLQT_COMMON_H +#include + +// STL includes + +// Qt includes +#include +#include +#include +#include + +// NeL includes + +// Project includes + +namespace NLQT { +namespace { + +void preApplication() +{ + QCoreApplication::libraryPaths(); + QString app_location = QCoreApplication::applicationFilePath(); + app_location.truncate(app_location.lastIndexOf(QLatin1Char('/'))); + app_location = QDir(app_location).canonicalPath(); + QCoreApplication::removeLibraryPath(app_location); + QCoreApplication::addLibraryPath("./platforms"); + QCoreApplication::addLibraryPath("./qtwebengine"); + QCoreApplication::addLibraryPath("./imageformats"); + QCoreApplication::addLibraryPath("./iconengines"); + QCoreApplication::addLibraryPath("./designer"); +} + +void postApplication() +{ + QApplication::setStyle(QStyleFactory::create("Fusion")); + QPalette palette = qApp->palette(); + palette.setColor(QPalette::Window, QColor(64, 64, 64)); + palette.setColor(QPalette::WindowText, Qt::white); + palette.setColor(QPalette::Base, QColor(48, 48, 48)); + palette.setColor(QPalette::AlternateBase, QColor(64, 64, 64)); + palette.setColor(QPalette::ToolTipBase, Qt::white); + palette.setColor(QPalette::ToolTipText, Qt::white); + palette.setColor(QPalette::Text, Qt::white); + palette.setColor(QPalette::Button, QColor(64, 64, 64)); + palette.setColor(QPalette::ButtonText, Qt::white); + palette.setColor(QPalette::BrightText, Qt::red); + palette.setColor(QPalette::Highlight, QColor(64, 128, 96)); + palette.setColor(QPalette::HighlightedText, Qt::white); + qApp->setPalette(palette); +} + +} +} /* namespace NLQT */ + +#endif /* #ifndef NLQT_SERVICE_WINDOW_H */ + +/* end of file */ From 7d11f82e588dc4e1be2200a4e219d03ea3121ac7 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 15 Jan 2016 17:22:27 +0100 Subject: [PATCH 12/12] Update mask pixel format in panoply preview tool --- code/nel/tools/3d/panoply_preview/panoply_preview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/nel/tools/3d/panoply_preview/panoply_preview.cpp b/code/nel/tools/3d/panoply_preview/panoply_preview.cpp index 964711eea..1eae30d9c 100644 --- a/code/nel/tools/3d/panoply_preview/panoply_preview.cpp +++ b/code/nel/tools/3d/panoply_preview/panoply_preview.cpp @@ -263,8 +263,8 @@ void CPanoplyPreview::goPushed(bool) uint32 depth = m_ColorThread->MaskBitmap.load(is); if (depth == 0 || m_ColorThread->MaskBitmap.getPixels().empty()) throw NLMISC::Exception("Failed to load bitmap '%s'", m_MaskFile.toLocal8Bit().data()); - if (m_ColorThread->MaskBitmap.PixelFormat != NLMISC::CBitmap::RGBA) - m_ColorThread->MaskBitmap.convertToType(NLMISC::CBitmap::RGBA); + if (m_ColorThread->MaskBitmap.PixelFormat != NLMISC::CBitmap::Luminance) + m_ColorThread->MaskBitmap.convertToType(NLMISC::CBitmap::Luminance); } { m_ColorThread->BitmapsOk = true;