diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 98c814599..66547c701 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -328,13 +328,19 @@ IF(WITH_QT5) ENDIF() # freetype is needed since Qt 5.5 - IF(UNIX) - SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/libqtfreetype.a") - ELSEIF(WIN32) - SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/qtfreetype.lib") - ENDIF() - IF(EXISTS ${FREETYPE_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIB}) + FIND_PACKAGE(FreeType) + + IF(FREETYPE_FOUND) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIBRARIES}) + ELSE() + IF(UNIX) + SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/libqtfreetype.a") + ELSEIF(WIN32) + SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/qtfreetype.lib") + ENDIF() + IF(EXISTS ${FREETYPE_LIB}) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIB}) + ENDIF() ENDIF() ADD_QT_PLUGIN(accessible qtaccessiblewidgets) @@ -348,7 +354,8 @@ IF(WITH_QT5) IF(WIN32) SET(QT_LIBRARIES ${QT_LIBRARIES} ${WINSDK_LIBRARY_DIR}/Crypt32.lib - ${WINSDK_LIBRARY_DIR}/WS2_32.Lib) + ${WINSDK_LIBRARY_DIR}/WS2_32.Lib + ${WINSDK_LIBRARY_DIR}/IPHlpApi.Lib) ENDIF() # Core diff --git a/code/nel/include/nel/gui/ctrl_draggable.h b/code/nel/include/nel/gui/ctrl_draggable.h index 3f625db1d..22ace71e0 100644 --- a/code/nel/include/nel/gui/ctrl_draggable.h +++ b/code/nel/include/nel/gui/ctrl_draggable.h @@ -29,7 +29,7 @@ namespace NLGUI DECLARE_UI_CLASS( CCtrlDraggable ) CCtrlDraggable( const TCtorParam ¶m ); - virtual ~CCtrlDraggable(){}; + virtual ~CCtrlDraggable(){} static CCtrlDraggable *getDraggedSheet(){ return _LastDraggedSheet; } bool isDragged() const{ return dragged; } diff --git a/code/nel/include/nel/gui/interface_parser.h b/code/nel/include/nel/gui/interface_parser.h index 18ec9045a..0a2d107fb 100644 --- a/code/nel/include/nel/gui/interface_parser.h +++ b/code/nel/include/nel/gui/interface_parser.h @@ -72,10 +72,12 @@ namespace NLGUI GroupChildren = 4 /// module can parse when parsing the group children }; - IParserModule(){ + IParserModule() + { parser = NULL; parsingStage = None; } + virtual ~IParserModule(){} bool canParseInStage( ParsingStage stage ) diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 9d8ff060e..cfb51af8e 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -71,7 +71,7 @@ namespace NLGUI class IOnWidgetsDrawnHandler { public: - virtual ~IOnWidgetsDrawnHandler(){}; + virtual ~IOnWidgetsDrawnHandler(){} virtual void process() = 0; }; diff --git a/code/nel/include/nel/net/inet_address.h b/code/nel/include/nel/net/inet_address.h index dcf5b3708..b7dba0614 100644 --- a/code/nel/include/nel/net/inet_address.h +++ b/code/nel/include/nel/net/inet_address.h @@ -32,6 +32,12 @@ struct in6_addr; #ifdef NL_OS_WINDOWS // automatically add the win socket library if you use nel network part #pragma comment(lib, "ws2_32.lib") + +// it seems that the default loop back address is not defined for ipv6 +#ifndef IN6ADDR_LOOPBACK_INIT +#define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } +#endif + #endif namespace NLMISC @@ -137,6 +143,9 @@ public: /// Returns true if this CInetAddress is 127.0.0.1 bool is127001 () const; + /// Returns true if this CInetAddress is a loop back address + bool isLoopbackIPAddress () const; + /// Creates a CInetAddress object with local host address, port=0 static CInetAddress localHost(); diff --git a/code/nel/src/gui/ctrl_button.cpp b/code/nel/src/gui/ctrl_button.cpp index bc54003da..d689dd71c 100644 --- a/code/nel/src/gui/ctrl_button.cpp +++ b/code/nel/src/gui/ctrl_button.cpp @@ -40,7 +40,8 @@ namespace NLGUI { char c = toLower( s[ i ] ); - switch( c ){ + switch( c ) + { case 'l': _Align &= ~1; break; diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 1b5e36964..2c225b3ce 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -5882,9 +5882,11 @@ namespace NLGUI { const char* digits = (Type == "I" ? upper : lower); uint8 i, d=0; - do { + do + { uint32 num = number % 10; - if (num % 5 < 4){ + if (num % 5 < 4) + { for (i = num % 5; i > 0; i--) { ret.insert(ret.begin(), digits[d]); @@ -5904,7 +5906,9 @@ namespace NLGUI } number /= 10; d += 2; - } while (number > 0); + } + while (number > 0); + if (Type == "I") { ret = toUpper(ret); diff --git a/code/nel/src/gui/group_html_parser.cpp b/code/nel/src/gui/group_html_parser.cpp index 260e6a96f..de96a63ea 100644 --- a/code/nel/src/gui/group_html_parser.cpp +++ b/code/nel/src/gui/group_html_parser.cpp @@ -121,69 +121,112 @@ namespace NLGUI // *************************************************************************** // http://stackoverflow.com/a/18335183 - static std::string correct_non_utf_8(const std::string &str) + static std::string correctNonUtf8(const std::string &str) { - int i,f_size=str.size(); + int i, f_size=str.size(); unsigned char c,c2,c3,c4; std::string to; to.reserve(f_size); - for(i=0 ; i127 && c2<192){//valid 2byte UTF8 - if(c==194 && c2<160){//control char, skipping + } + else if (c < 224 && i + 1 < f_size) + { + //possibly 2byte UTF8 + c2 = (unsigned char)(str[i+1]); + + if (c2 > 127 && c2 < 192) + { + //valid 2byte UTF8 + if (c == 194 && c2 < 160) + { + //control char, skipping ; - }else{ + } + else + { to.append(1,c); to.append(1,c2); } i++; continue; } - }else if(c<240 && i+2127 && c2<192 && c3>127 && c3<192){//valid 3byte UTF8 + } + else if (c < 240 && i + 2 < f_size) + { + // possibly 3byte UTF8 + c2 = (unsigned char)(str[i+1]); + c3 = (unsigned char)(str[i+2]); + + if (c2 > 127 && c2 < 192 && c3 > 127 && c3 < 192) + { + // valid 3byte UTF8 to.append(1,c); to.append(1,c2); to.append(1,c3); i+=2; continue; } - }else if(c<245 && i+3127 && c2<192 && c3>127 && c3<192 && c4>127 && c4<192){//valid 4byte UTF8 + } + else if (c < 245 && i + 3 < f_size) + { + //possibly 4byte UTF8 + c2 = (unsigned char)(str[i+1]); + c3 = (unsigned char)(str[i+2]); + c4 = (unsigned char)(str[i+3]); + if (c2 > 127 && c2 < 192 && c3 > 127 && c3 < 192 && c4 > 127 && c4 < 192) + { + //valid 4byte UTF8 to.append(1,c); to.append(1,c2); to.append(1,c3); @@ -192,6 +235,7 @@ namespace NLGUI continue; } } + //invalid UTF8, converting ASCII (c>245 || string too short for multi-byte)) to.append(1,(unsigned char)195); to.append(1,c-64); @@ -250,7 +294,7 @@ namespace NLGUI } // if there is invalid utf-8 chars, then libxml will break everything after first it finds. - htmlString = correct_non_utf_8(htmlString); + htmlString = correctNonUtf8(htmlString); } // *************************************************************************** diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 37a115965..f866594c9 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -1258,7 +1258,7 @@ namespace NLGUI getWindowForActiveMasterGroup(newCtrl->getContextHelpWindowName()); uint32 _ScreenH, _ScreenW; - CViewRenderer::getInstance()->getScreenSize( _ScreenH, _ScreenW ); + CViewRenderer::getInstance()->getScreenSize( _ScreenW, _ScreenH ); if(ttPosRef==Hotspot_TTAuto || ttParentRef==Hotspot_TTAuto) { diff --git a/code/nel/src/misc/bitmap_gif.cpp b/code/nel/src/misc/bitmap_gif.cpp index 30e8b652c..4ae9dd0cf 100644 --- a/code/nel/src/misc/bitmap_gif.cpp +++ b/code/nel/src/misc/bitmap_gif.cpp @@ -49,7 +49,8 @@ static uint8 INTERLACED_OFFSET[] = { 0, 4, 2, 1 }; static uint8 INTERLACED_JUMP[] = { 8, 8, 4, 2 }; #endif -static int readGIFData(GifFileType *gif, GifByteType *data, int length){ +static int readGIFData(GifFileType *gif, GifByteType *data, int length) +{ NLMISC::IStream *f = static_cast(gif->UserData); if(!f->isReading()) return 0; diff --git a/code/nel/src/misc/cmd_args.cpp b/code/nel/src/misc/cmd_args.cpp index 65aae5769..d9370b831 100644 --- a/code/nel/src/misc/cmd_args.cpp +++ b/code/nel/src/misc/cmd_args.cpp @@ -220,6 +220,11 @@ bool CCmdArgs::parse(int argc, char **argv) for(sint i = 0; i < argc; ++i) { +#ifdef NL_OS_MAC + // get rid of -psn_* arguments under OS X + if (strncmp(argv[i], "-psn_", 5) == 0) continue; +#endif + args.push_back(argv[i]); } @@ -245,7 +250,7 @@ bool CCmdArgs::parse(const std::vector &argv) uint argc = argv.size(); // process each argument - for (sint i = 1; i < argc; i++) + for (uint i = 1; i < argc; i++) { std::string name = argv[i]; diff --git a/code/nel/src/net/inet_address.cpp b/code/nel/src/net/inet_address.cpp index 9dc7f5d00..093bf8dcb 100644 --- a/code/nel/src/net/inet_address.cpp +++ b/code/nel/src/net/inet_address.cpp @@ -92,18 +92,18 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t size) BOOLEAN IN6_IS_ADDR_UNSPECIFIED(CONST IN6_ADDR *a) { - // - // We can't use the in6addr_any variable, since that would - // require existing callers to link with a specific library. - // - return (BOOLEAN)((a->s6_words[0] == 0) && - (a->s6_words[1] == 0) && - (a->s6_words[2] == 0) && - (a->s6_words[3] == 0) && - (a->s6_words[4] == 0) && - (a->s6_words[5] == 0) && - (a->s6_words[6] == 0) && - (a->s6_words[7] == 0)); + // + // We can't use the in6addr_any variable, since that would + // require existing callers to link with a specific library. + // + return (BOOLEAN)((a->s6_words[0] == 0) && + (a->s6_words[1] == 0) && + (a->s6_words[2] == 0) && + (a->s6_words[3] == 0) && + (a->s6_words[4] == 0) && + (a->s6_words[5] == 0) && + (a->s6_words[6] == 0) && + (a->s6_words[7] == 0)); } #endif @@ -714,25 +714,51 @@ std::vector CInetAddress::localAddresses() if (status) { // will come here if the local hostname (/etc/hostname in Linux) is not the real name - throw ESocket( (string("Hostname resolution failed for ")+string(localhost)).c_str() ); + throw ESocket( toString("Hostname resolution failed for %s", localhost).c_str() ); } struct addrinfo *p = res; + // for loopback ipv4 + bool IPv4LoopbackAdded = false; + + // for loopback ipv6 + bool IPv6LoopbackAdded = false; + // process all addresses while (p != NULL) { // check address family if (p->ai_family == AF_INET) { - // ipv4 + // loopback ipv4 + if (!IPv4LoopbackAdded) + { + // add loopback address only once + struct in_addr psin_addrIPv4; + psin_addrIPv4.s_addr = htonl(INADDR_LOOPBACK); + vect.push_back(CInetAddress(&psin_addrIPv4, localhost)); + + IPv4LoopbackAdded = true; + } + struct sockaddr_in *ipv4 = (struct sockaddr_in *)p->ai_addr; vect.push_back( CInetAddress( &ipv4->sin_addr, localhost ) ); + } else if (p->ai_family == AF_INET6) { - // ipv6 + // loopback ipv6 + if (!IPv6LoopbackAdded) + { + // add loopback address only once + struct in6_addr psin_addrIPv6 = IN6ADDR_LOOPBACK_INIT; + vect.push_back(CInetAddress(&psin_addrIPv6, localhost)); + + IPv6LoopbackAdded = true; + } + struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)p->ai_addr; vect.push_back( CInetAddress( &ipv6->sin6_addr, localhost ) ); @@ -747,7 +773,7 @@ std::vector CInetAddress::localAddresses() if(vect.empty()) { - throw ESocket( (string("No network card detected for ")+string(localhost)).c_str() ); + throw ESocket(toString("No network card detected for %s", localhost).c_str() ); } return vect; @@ -758,6 +784,16 @@ bool CInetAddress::is127001 () const return (internalIPAddress () == htonl(0x7F000001)); } +bool CInetAddress::isLoopbackIPAddress () const +{ + std::string sIPAddress = ipAddress(); + + return (sIPAddress.compare("::") == 0) || + (sIPAddress.compare("::1") == 0) || + (sIPAddress.compare("127.0.0.1") == 0) || + (sIPAddress.compare("0:0:0:0:0:0:0:1") == 0); +} + std::string vectorCInetAddressToString(const std::vector &addrs) { diff --git a/code/nel/src/net/unified_network.cpp b/code/nel/src/net/unified_network.cpp index 0f4396ef5..ee882f547 100644 --- a/code/nel/src/net/unified_network.cpp +++ b/code/nel/src/net/unified_network.cpp @@ -828,17 +828,17 @@ void CUnifiedNetwork::addService(const string &name, const vector for (uint i = 0; i < addr.size(); i++) { // first we have to look if we have a network that can established the connection - + uint j = 0; - // it s 127.0.0.1, it s ok - if (!addr[i].is127001 ()) + + if (!addr[i].isLoopbackIPAddress()) { + // it's loopback ip address, it's ok for (j = 0; j < laddr.size (); j++) { if (laddr[j].internalNetAddress () == addr[i].internalNetAddress ()) { - // it's ok, we can try - break; + break; // it's ok, we can try } } @@ -1272,8 +1272,7 @@ uint8 CUnifiedNetwork::findConnectionId (TServiceId sid, uint8 nid) uint8 connectionId = _IdCnx[sid.get()].DefaultNetwork; if (nid == 0xFF) - { - // it s often happen because they didn't set a good network configuration, so it s in debug to disable it easily + { // default network //nldebug ("HNETL5: nid %hu, will use the default connection %hu", (uint16)nid, (uint16)connectionId); } else if (nid >= _IdCnx[sid.get()].NetworkConnectionAssociations.size()) @@ -1294,8 +1293,12 @@ uint8 CUnifiedNetwork::findConnectionId (TServiceId sid, uint8 nid) if (connectionId >= _IdCnx[sid.get()].Connections.size() || !_IdCnx[sid.get()].Connections[connectionId].valid() || !_IdCnx[sid.get()].Connections[connectionId].CbNetBase->connected()) { - // there's a problem with the selected connectionID, so try to find a valid one - nlwarning ("HNETL5: Can't find selected connection id %hu to send message to %s because connection is not valid or connected, find a valid connection id", (uint16)connectionId, _IdCnx[sid.get()].ServiceName.c_str ()); + + if (nid != 0xFF) + { + // not a default network. There's a problem with the selected connectionID, so try to find a valid one + nlwarning ("HNETL5: Can't find selected connection id %hu to send message to %s because connection is not valid or connected, find a valid connection id", (uint16)connectionId, _IdCnx[sid.get()].ServiceName.c_str ()); + } for (connectionId = 0; connectionId < _IdCnx[sid.get()].Connections.size(); connectionId++) { @@ -1303,6 +1306,19 @@ uint8 CUnifiedNetwork::findConnectionId (TServiceId sid, uint8 nid) { // we found one at last, use this one //nldebug ("HNETL5: Ok, we found a valid connectionid, use %hu", (uint16)connectionId); + if (nid < _IdCnx[sid.get()].NetworkConnectionAssociations.size()) + { + _IdCnx[sid.get()].NetworkConnectionAssociations[nid] = connectionId; // we set the preferred networkConnectionAssociation + } + else + { + if (nid == 0xFF) + { + _IdCnx[sid.get()].DefaultNetwork = connectionId; + } + } + + nlwarning ("HNETL5: selected connection id %hu from network %hu to send message to %s", (uint16)connectionId, (uint16)nid, _IdCnx[sid.get()].ServiceName.c_str ()); break; } } @@ -1782,7 +1798,7 @@ bool CUnifiedNetwork::isServiceLocal (TServiceId sid) { for (uint j = 0; j < _IdCnx[sid.get()].ExtAddress.size(); j++) { - if (_IdCnx[sid.get()].ExtAddress[j].is127001 ()) + if (_IdCnx[sid.get()].ExtAddress[j].isLoopbackIPAddress ()) return true; if (_IdCnx[sid.get()].ExtAddress[j].internalIPAddress () == laddr[i].internalIPAddress ()) diff --git a/code/nel/tools/3d/object_viewer_widget/src/stdpch.h b/code/nel/tools/3d/object_viewer_widget/src/stdpch.h index 2c5b38f92..588d8a898 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/stdpch.h +++ b/code/nel/tools/3d/object_viewer_widget/src/stdpch.h @@ -29,12 +29,6 @@ along with this program. If not, see . #undef free #endif -#include - -#ifdef Q_COMPILER_RVALUE_REFS -#undef Q_COMPILER_RVALUE_REFS -#endif - #include #include diff --git a/code/nel/tools/3d/panoply_preview/main_window.h b/code/nel/tools/3d/panoply_preview/main_window.h index 1d864249b..3e3d2f025 100644 --- a/code/nel/tools/3d/panoply_preview/main_window.h +++ b/code/nel/tools/3d/panoply_preview/main_window.h @@ -21,12 +21,6 @@ // STL includes // Qt includes -#include - -#ifdef Q_COMPILER_RVALUE_REFS -#undef Q_COMPILER_RVALUE_REFS -#endif - #include // NeL includes diff --git a/code/nel/tools/3d/panoply_preview/panoply_preview.h b/code/nel/tools/3d/panoply_preview/panoply_preview.h index 794a223f8..9fbe2bad3 100644 --- a/code/nel/tools/3d/panoply_preview/panoply_preview.h +++ b/code/nel/tools/3d/panoply_preview/panoply_preview.h @@ -21,12 +21,6 @@ // STL includes // Qt includes -#include - -#ifdef Q_COMPILER_RVALUE_REFS -#undef Q_COMPILER_RVALUE_REFS -#endif - #include #include #include diff --git a/code/nel/tools/3d/shared_widgets/command_log.h b/code/nel/tools/3d/shared_widgets/command_log.h index 16bc21c9d..ec6332601 100644 --- a/code/nel/tools/3d/shared_widgets/command_log.h +++ b/code/nel/tools/3d/shared_widgets/command_log.h @@ -34,12 +34,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // STL includes // Qt includes -#include - -#ifdef Q_COMPILER_RVALUE_REFS -#undef Q_COMPILER_RVALUE_REFS -#endif - #include #include #include diff --git a/code/nel/tools/3d/tile_edit_qt/common.h b/code/nel/tools/3d/tile_edit_qt/common.h index 685195251..6cafbbd8a 100644 --- a/code/nel/tools/3d/tile_edit_qt/common.h +++ b/code/nel/tools/3d/tile_edit_qt/common.h @@ -26,12 +26,6 @@ #undef free #endif -#include - -#ifdef Q_COMPILER_RVALUE_REFS -#undef Q_COMPILER_RVALUE_REFS -#endif - #include #include diff --git a/code/nel/tools/misc/crash_report/crash_report_data.h b/code/nel/tools/misc/crash_report/crash_report_data.h index 8a7f2ffcb..f2d222189 100644 --- a/code/nel/tools/misc/crash_report/crash_report_data.h +++ b/code/nel/tools/misc/crash_report/crash_report_data.h @@ -20,12 +20,6 @@ #ifndef RCERROR_DATA #define RCERROR_DATA -#include - -#ifdef Q_COMPILER_RVALUE_REFS -#undef Q_COMPILER_RVALUE_REFS -#endif - #include struct SCrashReportData diff --git a/code/nel/tools/misc/words_dic_qt/words_dicDlg.h b/code/nel/tools/misc/words_dic_qt/words_dicDlg.h index 707eaaa44..dcf27e838 100644 --- a/code/nel/tools/misc/words_dic_qt/words_dicDlg.h +++ b/code/nel/tools/misc/words_dic_qt/words_dicDlg.h @@ -1,12 +1,6 @@ #ifndef WORDS_DICDLG_H #define WORDS_DICDLG_H -#include - -#ifdef Q_COMPILER_RVALUE_REFS -#undef Q_COMPILER_RVALUE_REFS -#endif - #include #include "ui_words_dic_Qt.h" diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/info_player.lua b/code/ryzom/client/data/gamedev/interfaces_v3/info_player.lua index a4deeb05a..12210fadf 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/info_player.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/info_player.lua @@ -161,7 +161,7 @@ end ------------------------------------------------------------------------------------------------------------ -- Compute the current Max Resist function game:getMagicResistMaxLevel() - local mlvl= self:getMagicResistBaseLevel() + getDbProp(formatUI('%player_resist_maxratio')); + local mlvl= 25 + self:getMagicResistBaseLevel() + getDbProp(formatUI('%player_resist_maxratio')); return math.max(0,mlvl); end @@ -267,27 +267,27 @@ function game:onDrawNpcWebPage() local available if config.Local == 1 then available = (NicoMagicURL ~= "") - else - available = isDynStringAvailable(self.NpcWebPage.UrlTextId) + else + available = isDynStringAvailable(self.NpcWebPage.UrlTextId) end - if(available) then + if(available) then local ucUrl if config.Local == 1 then - ucUrl = ucstring(NicoMagicURL) -- for test in local mode + ucUrl = ucstring(NicoMagicURL) -- for test in local mode else ucUrl = getDynString(self.NpcWebPage.UrlTextId); end -- browse local uiStr= getUIId(getUICaller()); - -- if the url + -- if the url local utf8Url = ucUrl:toUtf8() - local isRing = string.find(utf8Url, "ring_access_point=1") ~= nil + local isRing = string.find(utf8Url, "ring_access_point=1") ~= nil if isRing then getUI("ui:interface:npc_web_browser").active = false runAH(nil, "context_ring_sessions", "") return else - local hideWindow = string.find(utf8Url, "_hideWindow=1") ~= nil + local hideWindow = string.find(utf8Url, "_hideWindow=1") ~= nil if hideWindow then getUI("ui:interface:npc_web_browser").active = false end @@ -336,14 +336,14 @@ function game:startNpcWebPage() end ------------------------------------------------------------------------------------------------------------ --- +-- function game:closeNpcWebBrowserHeader() local ui = getUI('ui:interface:npc_web_browser'); - + -- save size ui_npc_web_browser_h = ui.h; ui_npc_web_browser_w = ui.w; - + -- reduce window size ui.pop_min_h = 32; ui.h = 0; @@ -351,7 +351,7 @@ function game:closeNpcWebBrowserHeader() end ------------------------------------------------------------------------------------------------------------ --- +-- function game:openNpcWebBrowserHeader() local ui = getUI('ui:interface:npc_web_browser'); ui.pop_min_h = 96; @@ -360,7 +360,7 @@ function game:openNpcWebBrowserHeader() if (ui_npc_web_browser_h ~= nil) then ui.h = ui_npc_web_browser_h; end - + if (ui_npc_web_browser_w ~= nil) then ui.w = ui_npc_web_browser_w; end @@ -538,7 +538,7 @@ function game:updateFameBar(path) uiMaxLimit.x = barX + barW * (fameMax + 100) / 200; -- init bar3d - if (bar3dStart < bar3dLimit) then + if (bar3dStart < bar3dLimit) then uiBar3d.x= bar3dStart; uiBar3d.w= bar3dLimit-bar3dStart; else @@ -553,7 +553,7 @@ function game:updateFameBarTT(path) local fameMax = getDbProp(path .. ':THRESHOLD'); local text = i18n.get('uittFameMaxPossible'); - text = findReplaceAll(text, '%famemax', tostring(fameMax)); + text = findReplaceAll(text, '%famemax', tostring(fameMax)); setContextHelpText(text); end @@ -564,12 +564,12 @@ function game:getPvpEffects() local i; local hasBonus = false; local hasMalus = false; - + local text = '' local textBonus = ''; local textMalus = ''; local fmt; - + -- check every malus and bonus for i=0, n do local path = formatUI('SERVER:PVP_EFFECTS:#1', i); @@ -611,7 +611,7 @@ function game:getPvpEffects() end ------------------------------------------------------------------------------------------------------------ -function game:getFactionName(id) +function game:getFactionName(id) if (id == self.TPVPClan.Kami) then return i18n.get('uiFameKami'); elseif (id == self.TPVPClan.Karavan) then @@ -636,10 +636,10 @@ function game:getAllegiancePoints() local civPoints = getDbProp(path .. ':CIV_POINTS'); local cult = getDbProp(path .. ':CULT'); local cultPoints = getDbProp(path .. ':CULT_POINTS'); - + local text; local uiGroup= getUICaller(); - + -- civ allegiance if (civ == self.TPVPClan.None or civ == self.TPVPClan.Neutral) then text = i18n.get('uiPvpFameNoCivAllegiance'); @@ -647,9 +647,9 @@ function game:getAllegiancePoints() text = i18n.get('uiPvpFameAllegiancePoints'); text = findReplaceAll(text, '%faction', self:getFactionName(civ)); text = findReplaceAll(text, '%points', tostring(civPoints)); - end + end uiGroup.civ_allegiance_pts.uc_hardtext_format = text; - + -- cult allegiance if (cult == self.TPVPClan.None or cult == self.TPVPClan.Neutral) then text = i18n.get('uiPvpFameNoCultAllegiance'); @@ -698,11 +698,11 @@ function game:fameAllegianceTooltipCultGuild() end ------------------------------------------------------------------------------------------------------------ --- +-- function game:tooltipDeltaValue(base, max) -- Calculate delta local val = max - base; - + local text; if (val == 0) then text = concatUCString('@{FFFF}', tostring(max)); @@ -729,37 +729,37 @@ function game:tooltipDeltaValue(base, max) text = concatUCString(text, ')'); end end - + return text; end ------------------------------------------------------------------------------------------------------------ --- +-- function game:tooltipScore(dbBase, dbMax, ttFormat) -- Get DB values local base = getDbProp(dbBase); local max = getDbProp(dbMax); - + -- Tooltip text local fmt = i18n.get(ttFormat); local text = self:tooltipDeltaValue(base, max); fmt = findReplaceAll(fmt, "%n", text ); - + -- Set tooltip setContextHelpText(fmt); end ------------------------------------------------------------------------------------------------------------ --- +-- function game:tooltipScoreEP(dbBase, dbMax, ttFormat, dbLvl, dbMod) -- Defender level local defLvl= getDbProp(formatUI(dbLvl)); defLvl = math.max(0, defLvl); - + -- Attacker level local attLvl = getBaseSkillValueMaxChildren(getSkillIdFromName('SF')); - + -- Get DB values local base = getDbProp(dbBase); local max = getDbProp(dbMax); @@ -774,7 +774,7 @@ function game:tooltipScoreEP(dbBase, dbMax, ttFormat, dbLvl, dbMod) fmt = findReplaceAll(fmt, "%n", text ); fmt = findReplaceAll(fmt, "%l", tostring(attLvl)); fmt = findReplaceAll(fmt, "%p", textChance); - + -- Set tooltip setContextHelpText(fmt); end @@ -786,7 +786,7 @@ end ---------------------------------- RING STATS --------------------------------------------------- ------------------------------------------------------------------------------------------------------------- -RingPlayerInfo = +RingPlayerInfo = { WaitingInfo = false, LastRefreshTime = 0, @@ -810,7 +810,7 @@ end -- function RingPlayerInfo:initRingStatPlayer() - setOnDraw(self:getWindow(), "RingPlayerInfo:onRingRatingPlayerDraw()") + setOnDraw(self:getWindow(), "RingPlayerInfo:onRingRatingPlayerDraw()") end -------------------------------------------------------------------------------------------------------------- @@ -819,16 +819,16 @@ function RingPlayerInfo:onRingRatingPlayerDraw() local timeInSec = nltime.getLocalTime() / 1000 if self.WaitingInfo then - if timeInSec - self.LastRefreshTime > self.WaitingPeriod then + if timeInSec - self.LastRefreshTime > self.WaitingPeriod then self.WaitingInfo = false self.LastRefreshTime = nltime.getLocalTime() / 1000 - else + else if not self.InfoReceived then --debugInfo("No received info") end end else - if timeInSec - self.LastRefreshTime > self.RefreshPeriod then + if timeInSec - self.LastRefreshTime > self.RefreshPeriod then self:refresh() else --debugInfo("pas de refresh") @@ -844,7 +844,7 @@ function RingPlayerInfo:updatePendingRefresh() if self.PendingRefresh then local currTime = nltime.getLocalTime() / 1000 - if currTime - self.LastRefreshQuerryTime > self.MinRefreshPeriod and game.getRingStats then + if currTime - self.LastRefreshQuerryTime > self.MinRefreshPeriod and game.getRingStats then self.LastRefreshQuerryTime = currTime self.PendingRefresh = false game.getRingStats() @@ -924,10 +924,10 @@ end -- function RingPlayerInfo:refresh() - self.PendingRefresh = true + self.PendingRefresh = true self.LastRefreshTime = nltime.getLocalTime() / 1000 self.WaitingInfo = true -end +end -------------------------------------------------------------------------------------------------------------- -- @@ -937,7 +937,7 @@ function RingPlayerInfo:tooltipEcosystemPoints(rp, maxRp, ttFormat) local fmt = i18n.get(ttFormat); fmt = findReplaceAll(fmt, "%n", rp ); fmt = findReplaceAll(fmt, "%p", maxRp ); - + -- Set tooltip return fmt; end @@ -954,8 +954,8 @@ function RingPlayerInfo:updateRRPSLevel(dbVal, tooltip) local ui= getUICaller(); local uiText= ui.val; - -- set the text - uiText.uc_hardtext= tostring(val) + -- set the text + uiText.uc_hardtext= tostring(val) self:tooltipRRPs(dbVal, tooltip) end @@ -970,7 +970,7 @@ function RingPlayerInfo:tooltipRRPs(dbBase, ttFormat) local fmt = i18n.get(ttFormat); local text = tostring(val) fmt = findReplaceAll(fmt, "%n", text ); - + -- Set tooltip setContextHelpText(fmt); end @@ -1013,7 +1013,7 @@ end -------------------------------------------------------------------------------------------------------------- -- function game:updateOrganization(path, uiOrgText, uiStatusText, uiPointsText) - + local org = getDbProp(path.."1:VALUE") getUICaller()[uiOrgText].uc_hardtext = i18n.get('uiOrganization_' .. org) @@ -1022,7 +1022,7 @@ function game:updateOrganization(path, uiOrgText, uiStatusText, uiPointsText) local points = getDbProp(path.."3:VALUE") getUICaller()[uiPointsText].uc_hardtext= points - + end ------------------------------------------------------------------------------------------------------------ @@ -1033,10 +1033,10 @@ end -------------------------------------------------------------------------------------------------------------- -function game:popMissionList() - local menu = getUI("ui:interface:mission_cb_menu") +function game:popMissionList() + local menu = getUI("ui:interface:mission_cb_menu") enableModalWindow(getUICaller(), "ui:interface:mission_cb_menu") - self:updateMissionMenuSize() + self:updateMissionMenuSize() end @@ -1053,12 +1053,12 @@ function game:getMissionDbPath(missionIndex) return "SERVER:GROUP:MISSIONS:" .. tostring(missionIndex - numMissions) else return "SERVER:MISSIONS:" .. tostring(missionIndex) - end + end end -------------------------------------------------------------------------------------------------------------- -function game:getCurrMissionIndex() - local result = getDbProp("UI:SAVE:MISSION_SELECTED") +function game:getCurrMissionIndex() + local result = getDbProp("UI:SAVE:MISSION_SELECTED") return result end @@ -1071,10 +1071,10 @@ end function game:updateCurrMissionComboBox() local numMissions = tonumber(getDefine("ipj_nb_mission")) local missionFound = false - local cb = getUI("ui:interface:info_player_journal:content:mission_combo") - local missionList = getUI("ui:interface:info_player_journal:content:mission_list") + local cb = getUI("ui:interface:info_player_journal:content:mission_combo") + local missionList = getUI("ui:interface:info_player_journal:content:mission_list") for i = 0, numMissions - 1 do - if getDbProp("SERVER:MISSIONS:" .. i .. ":TITLE") ~= 0 + if getDbProp("SERVER:MISSIONS:" .. i .. ":TITLE") ~= 0 or getDbProp("SERVER:GROUP:MISSIONS:" .. i .. ":TITLE") ~= 0 then missionFound = true break @@ -1095,20 +1095,20 @@ function game:updateCurrMissionComboBox() missionList.no_available_mission.active = false cb.arrow.active = true cb.select.active = true - local currMission = self:getCurrMissionIndex() + local currMission = self:getCurrMissionIndex() - local dbPath = self:getMissionDbPath(currMission) - -- - local selected = (currMission ~= -1) + local dbPath = self:getMissionDbPath(currMission) + -- + local selected = (currMission ~= -1) if selected then cb.mission_title.textid_dblink = dbPath .. ":TITLE" selected = (tile ~= 0) - end + end cb.mission_ico.active = selected cb.mission_title.active = selected cb.no_selected_mission.active = not selected missionList.no_selected_mission.active = not selected - if selected then + if selected then if getDbProp(dbPath .. ":FINISHED") == 0 then cb.mission_ico.texture = runExpr("getMissionSmallIcon(" .. tostring(getDbProp(dbPath .. ":ICON") .. ")")) elseif getDbProp(dbPath .. ":FINISHED") == 1 then @@ -1116,17 +1116,17 @@ function game:updateCurrMissionComboBox() else cb.mission_ico.texture = "Small_Task_Failed.tga" end - end + end end -------------------------------------------------------------------------------------------------------------- -function game:onMissionSelected(index) +function game:onMissionSelected(index) disableModalWindow() self:updateCurrMissionComboBox() end -------------------------------------------------------------------------------------------------------------- -function game:onGroupMissionSelected(index) +function game:onGroupMissionSelected(index) disableModalWindow() self:updateCurrMissionComboBox() end @@ -1138,33 +1138,33 @@ function game:onMissionDBIndexChanged() -- if selection was made from the list, update the other list if missionIndex >= self:getGroupMissionFirstIndex() then local groupMissionIndex = missionIndex - self:getGroupMissionFirstIndex() - getUI("ui:interface:info_player_journal:content:mission_list:b_group_title" .. tostring(groupMissionIndex)).pushed = true + getUI("ui:interface:info_player_journal:content:mission_list:b_group_title" .. tostring(groupMissionIndex)).pushed = true getUI("ui:interface:mission_cb_menu:mission_list:b_group_title" .. tostring(groupMissionIndex)).pushed = true else - getUI("ui:interface:info_player_journal:content:mission_list:b_title" .. tostring(missionIndex)).pushed = true + getUI("ui:interface:info_player_journal:content:mission_list:b_title" .. tostring(missionIndex)).pushed = true getUI("ui:interface:mission_cb_menu:mission_list:b_title" .. tostring(missionIndex)).pushed = true end end -------------------------------------------------------------------------------------------------------------- -function game:onMissionTitleChanged(index) +function game:onMissionTitleChanged(index) -- if title is not nil then a new mission has been added -> if db initilization is over, then selected this new mission - if getDbProp(self:getMissionDbPath(index) .. ":TITLE") ~= 0 then - if game.InGameDbInitialized or config.Local then + if getDbProp(self:getMissionDbPath(index) .. ":TITLE") ~= 0 then + if game.InGameDbInitialized or config.Local then self:setCurrentMission(index) end - else + else self:updateCurrMissionComboBox() self:updateMissionMenuSize() end end -------------------------------------------------------------------------------------------------------------- -function game:onGroupMissionTitleChanged(index) - if getDbProp(self:getMissionDbPath(index + 15) .. ":TITLE") ~= 0 then - if game.InGameDbInitialized or config.Local then +function game:onGroupMissionTitleChanged(index) + if getDbProp(self:getMissionDbPath(index + 15) .. ":TITLE") ~= 0 then + if game.InGameDbInitialized or config.Local then self:setCurrentMission(index + 15) end - else + else self:updateCurrMissionComboBox() self:updateMissionMenuSize() end @@ -1174,21 +1174,21 @@ end function game:updateMissionMenuSize() local parentCB = getUI("ui:interface:info_player_journal:content:mission_combo") local menu = getUI("ui:interface:mission_cb_menu") - if not menu.active then return end + if not menu.active then return end local maxNumMissions = 2 * self:getGroupMissionFirstIndex() - local missionCount = 0 + local missionCount = 0 for k = 0, maxNumMissions - 1 do if getDbProp(self:getMissionDbPath(k) .. ":TITLE") ~= 0 then - missionCount = missionCount + 1 + missionCount = missionCount + 1 end - end + end menu.h = 8 + missionCount * 18 menu.y = 0 menu:updateCoords() local y = parentCB.y_real - menu.h_real - 1 if y < 0 then y = parentCB.y_real + parentCB.h_real + 1 - end + end local scrW local scrH scrW, scrH = getWindowSize() @@ -1197,7 +1197,7 @@ function game:updateMissionMenuSize() end menu.w = parentCB.w_real menu.y = y - menu.x = parentCB.x_real + menu.x = parentCB.x_real menu.h = 8 + missionCount * 18 menu:invalidateCoords() end @@ -1205,7 +1205,7 @@ end -------------------------------------------------------------------------------------------------------------- --function game:updateMissionDescCloseButton(index) -- local dbPath = self:getMissionDbPath(index) --- if index == self:getCurrMissionIndex() then +-- if index == self:getCurrMissionIndex() then -- local closeText = getUI("ui:interface:info_player_journal:content:desc:close") -- local button = getUI("ui:interface:info_player_journal:content:desc:uppart:over_icon") -- local finished = getDbProp(dbPath .. ":FINISHED") @@ -1224,29 +1224,29 @@ end --end -------------------------------------------------------------------------------------------------------------- -function game:onMissionFinished(index) - self:updateCurrMissionComboBox() +function game:onMissionFinished(index) + self:updateCurrMissionComboBox() --self:updateMissionDescCloseButton(index) end -------------------------------------------------------------------------------------------------------------- -function game:onGroupMissionFinished(index) +function game:onGroupMissionFinished(index) self:updateCurrMissionComboBox() --self:updateMissionDescCloseButton(index + game:getGroupMissionFirstIndex()) end -------------------------------------------------------------------------------------------------------------- -function game:expandMissionList() - local missionCB = getUI("ui:interface:info_player_journal:content:mission_combo") +function game:expandMissionList() + local missionCB = getUI("ui:interface:info_player_journal:content:mission_combo") missionCB.active = not missionCB.active self:updateMissionWindowLayout() end -------------------------------------------------------------------------------------------------------------- -function game:updateMissionWindowLayout() +function game:updateMissionWindowLayout() if not isInRingMode() then local missionCB = getUI("ui:interface:info_player_journal:content:mission_combo") - local missionList = getUI("ui:interface:info_player_journal:content:mission_list") + local missionList = getUI("ui:interface:info_player_journal:content:mission_list") local fake = getUI("ui:interface:info_player_journal:content:fake") local sepBis = getUI("ui:interface:info_player_journal:content:separator_bis") local desc = getUI("ui:interface:info_player_journal:content:desc") @@ -1254,18 +1254,18 @@ function game:updateMissionWindowLayout() local popMinH local win = getUI("ui:interface:info_player_journal") - if missionCB.active then - sepBis.active = false + if missionCB.active then + sepBis.active = false missionList.active = false fake.sizeref="" fake.y = -32 fake.h = 0 - expanded = 0 + expanded = 0 desc.max_sizeref ="wh" desc.max_h= -42 win.pop_min_h = 152 - win.content_y_offset - else - sepBis.active = true + else + sepBis.active = true missionList.active = true fake.sizeref="wh5" fake.y = -8 @@ -1274,23 +1274,23 @@ function game:updateMissionWindowLayout() desc.max_sizeref ="wh5" desc.max_h=16 win.pop_min_h = 152 - win.content_y_offset - end + end - local fixedEntry = getUI("ui:interface:info_player_journal:content:mission_fixed_entry") + local fixedEntry = getUI("ui:interface:info_player_journal:content:mission_fixed_entry") fixedEntry:updateCoords() desc.max_h = desc.max_h - fixedEntry.h setDbProp("UI:SAVE:EXPAND_MISSION_LIST", expanded) - getUI("ui:interface:info_player_journal"):invalidateCoords() + getUI("ui:interface:info_player_journal"):invalidateCoords() end end -------------------------------------------------------------------------------------------------------------- -function game:onMissionJournalOpened() +function game:onMissionJournalOpened() local missionDesc = getUI("ui:interface:info_player_journal:content:desc") - missionDesc.active = getDbProp("UI:SAVE:MISSION_SELECTED") ~= -1 + missionDesc.active = getDbProp("UI:SAVE:MISSION_SELECTED") ~= -1 - local expandList = getDbProp("UI:SAVE:EXPAND_MISSION_LIST") + local expandList = getDbProp("UI:SAVE:EXPAND_MISSION_LIST") self:updateMissionJournalMode() if not isInRingMode() then @@ -1304,9 +1304,9 @@ function game:onMissionJournalOpened() self:updateMissionJournalHeader() self:updateMissionWindowLayout() - self:updateMissionJournalFixedEntry() + self:updateMissionJournalFixedEntry() + - end @@ -1315,12 +1315,12 @@ function game:updateMissionJournalHeader() local win = getUI("ui:interface:info_player_journal") local headerActive = getDbProp("UI:SAVE:MISSION_JOURNAL_HEADER_ACTIVE") ~= 0 win.header_active = headerActive - win.right_button_enabled = headerActive + win.right_button_enabled = headerActive if headerActive then - win.uc_title_opened = i18n.get("uiJournalTitle") + win.uc_title_opened = i18n.get("uiJournalTitle") win.content_y_offset = 0 else - win.uc_title_opened = ucstring("") + win.uc_title_opened = ucstring("") win.content_y_offset = win.header_opened.h_real + 3 end end @@ -1329,13 +1329,13 @@ end -------------------------------------------------------------------------------------------------------------- function game:updateMissionJournalFixedEntry() -- update fixed entry text - - local fixedEntryRing = getUI("ui:interface:info_player_journal:no_available_missions:main:mission_fixed_entry") + + local fixedEntryRing = getUI("ui:interface:info_player_journal:no_available_missions:main:mission_fixed_entry") local fixedEntryMain = getUI("ui:interface:info_player_journal:content:mission_fixed_entry") - + fixedEntryRing.active = game.InGameDbInitialized and isInRingMode() - fixedEntryMain.active = game.InGameDbInitialized and not isInRingMode() - + fixedEntryMain.active = game.InGameDbInitialized and not isInRingMode() + local id = "uiFixedMissionEntry" @@ -1346,22 +1346,22 @@ function game:updateMissionJournalFixedEntry() end if isPlayerFreeTrial() then id = id .. "_Trial" - end + end else - if isInRingMode() then - id = id .. "_R2" - else + if isInRingMode() then + id = id .. "_R2" + else id = id .. "_Mainland_" .. getUserRace() end - end + end fixedEntryMain.uc_hardtext = i18n.get(id) fixedEntryRing.uc_hardtext = i18n.get(id) - + self:updateMissionWindowLayout() end -------------------------------------------------------------------------------------------------------------- -function game:setCurrentMission(index) +function game:setCurrentMission(index) mw = getMissionWindow() mw.active = game.InGameDbInitialized if index < self:getGroupMissionFirstIndex() then @@ -1372,7 +1372,7 @@ function game:setCurrentMission(index) end -------------------------------------------------------------------------------------------------------------- -function game:onMissionComboWheelUp() +function game:onMissionComboWheelUp() local currMissionIndex = self:getCurrMissionIndex() while currMissionIndex > 0 do currMissionIndex = currMissionIndex - 1 @@ -1384,7 +1384,7 @@ function game:onMissionComboWheelUp() end -------------------------------------------------------------------------------------------------------------- -function game:onMissionComboWheelDown() +function game:onMissionComboWheelDown() local currMissionIndex = self:getCurrMissionIndex() local maxNumMission = 2 * self:getGroupMissionFirstIndex() while currMissionIndex < (maxNumMission - 1) do @@ -1399,37 +1399,37 @@ end -------------------------------------------------------------------------------------------------------------- -function game:toggleMissionJournalCaption() - local dbPath = "UI:SAVE:MISSION_JOURNAL_HEADER_ACTIVE" +function game:toggleMissionJournalCaption() + local dbPath = "UI:SAVE:MISSION_JOURNAL_HEADER_ACTIVE" setDbProp(dbPath, 1 - getDbProp(dbPath)) - local win = getUI("ui:interface:info_player_journal") + local win = getUI("ui:interface:info_player_journal") self:updateMissionJournalHeader() self:updateMissionWindowLayout() end -------------------------------------------------------------------------------------------------------------- -- handler called by C++ to tell that the main loop is about to begin -function game:onMainLoopBegin() - game.InGameDbInitialized = false +function game:onMainLoopBegin() + game.InGameDbInitialized = false game.PrevSessionMission = getDbProp("UI:VARIABLES:MISSION_SELECTED_PREV_SESSION") - + debugInfo("onMainLoopBegin()") end -------------------------------------------------------------------------------------------------------------- -- handler called by C++ to tell that all initial value have been set in the db -function game:onInGameDbInitialized() +function game:onInGameDbInitialized() game.InGameDbInitialized = true - -- if the journal is opened, force an update for the fixed entry text + -- if the journal is opened, force an update for the fixed entry text -- (says if we're in start island, paying account ...) need DB flags like -- IS_NEWBIE & IS_TRIAL to be received - game:updateMissionJournalFixedEntry() - -- If a mission was previously selected, restore it + game:updateMissionJournalFixedEntry() + -- If a mission was previously selected, restore it if game.PrevSessionMission ~= -1 then - self:setCurrentMission(game.PrevSessionMission) + self:setCurrentMission(game.PrevSessionMission) end - + game:setInfoPlayerCharacterRace() end @@ -1437,7 +1437,7 @@ function game:onWebIgReady() -- Call init webig getUI("ui:interface:web_transactions:content:html"):browse("home") getUI("ui:interface:webig:content:html"):browse("home") - + end -------------------------------------------------------------------------------------------------------------- @@ -1464,7 +1464,7 @@ end -------------------------------------------------------------------------------------------------------------- -- ring journal on / off -function game:setMissionJournalRingMode(isRing) +function game:setMissionJournalRingMode(isRing) local journal = getUI("ui:interface:info_player_journal") if isRing then journal.content.expand_mission_list.active = false @@ -1480,7 +1480,7 @@ function game:setMissionJournalRingMode(isRing) journal.no_available_missions.active = true else journal.content.expand_mission_list.active = true - journal.no_available_missions.active = false; + journal.no_available_missions.active = false; journal.content.active = true; --journal.content.mission_list.active = true; journal.content.sv.active = true; @@ -1494,8 +1494,8 @@ end -------------------------------------------------------------------------------------------------------------- -- update mission journal depending on wether we're in the ring or not function game:updateMissionJournalMode() - --local isRing = r2~=nil and r2.Mode~=nil and r2.Mode=='r2ed_anim_test' - game:setMissionJournalRingMode(isInRingMode()) + --local isRing = r2~=nil and r2.Mode~=nil and r2.Mode=='r2ed_anim_test' + game:setMissionJournalRingMode(isInRingMode()) end @@ -1521,22 +1521,22 @@ function game:onNewMissionStepAdded(stepIndex) end -- debugInfo("New Step") - if missionIndex < 15 then + if missionIndex < 15 then dbPath = "SERVER:MISSIONS:" .. tostring(missionIndex) .. ":GOALS:" .. tostring(stepIndex) .. ":TEXT" - else + else dbPath = "SERVER:GROUP:MISSIONS:" .. tostring(missionIndex - 15) .. ":GOALS:" .. tostring(stepIndex) .. ":TEXT" - end + end local stringID = getDbProp(dbPath) if stringID ~= 0 then -- debugInfo(tostring(stringID)) table.insert(remainingMissionTextIDs, stringID) - setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility0()") - else + setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility0()") + else end end function game:ensureLastMissionStepVisibility0() - + local missing = false for k, v in pairs(remainingMissionTextIDs) do if not isDynStringAvailable(v) then @@ -1545,54 +1545,54 @@ function game:ensureLastMissionStepVisibility0() end end local missionWnd = getMissionWindow() - if not missing then + if not missing then remainingMissionTextIDs = {} - -- delay real update to newt frame - setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility1()") + -- delay real update to newt frame + setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility1()") else - -- for debug : dump the list of remaining "dyn string" + -- for debug : dump the list of remaining "dyn string" --local stringList = "{" --for k, v in remainingMissionTextIDs do - -- if not isDynStringAvailable(v) then + -- if not isDynStringAvailable(v) then -- stringList = stringList .. " " .. tostring(v) -- end --end - --stringList = stringList .. "}" + --stringList = stringList .. "}" end end -function game:ensureLastMissionStepVisibility1() +function game:ensureLastMissionStepVisibility1() local missionWnd = getMissionWindow() - local scrollBar = missionWnd:find("sv_desc") - --scrollBar.trackPos = 20000 -- move upward + local scrollBar = missionWnd:find("sv_desc") + --scrollBar.trackPos = 20000 -- move upward --scrollBar:updateCoords() - --setOnDraw(missionWnd, "") - local descWnd = missionWnd:find("desc") + --setOnDraw(missionWnd, "") + local descWnd = missionWnd:find("desc") local maxNumSteps = getDefine("ipj_nb_goal") local topStep - for stepIndex = 0, maxNumSteps -1 do + for stepIndex = 0, maxNumSteps -1 do local currStep = descWnd["step" .. tostring(stepIndex)] if currStep.active then topStep = currStep end end -- debugInfo("Found step : " .. topStep.hardtext) - if topStep == nil then + if topStep == nil then return - end + end scrollBar:ensureVisible(topStep, "M", "M") - + --local wantedY = topStep.h_real / 2 - (descWnd.y_real - topStep.y_real) - --local wantedY = descWnd.y_real + descWnd.h_real - topStep.y_real - --local offsetY = wantedY - descWnd.max_h_real / 2 - --if offsetY < 0 then offsetY = 0 end + --local wantedY = descWnd.y_real + descWnd.h_real - topStep.y_real + --local offsetY = wantedY - descWnd.max_h_real / 2 + --if offsetY < 0 then offsetY = 0 end --descWnd.ofsy = offsetY --descWnd:invalidateCoords() --descWnd:updateCoords() - setOnDraw(missionWnd, "") - + setOnDraw(missionWnd, "") + end -------------------------------------------------------------------------------------------------------------- @@ -1606,9 +1606,9 @@ end function game:addRpJob(jobtype, id, value, rpjobs) local base_path = "ui:interface:info_player_skills:content:rpjobs:rpjob_"..jobtype.."_"..id..":rpjob_"..jobtype.."_infos_"..id - + local group = getUI("ui:interface:info_player_skills:content:rpjobs:rpjob_"..jobtype.."_"..id) - + if (value == nil) then group.active = false else @@ -1618,16 +1618,16 @@ function game:addRpJob(jobtype, id, value, rpjobs) group.active = false else group.active = true - + local echelon_value = rpjobs[sitem][1] local quantity = rpjobs[sitem][2] - + local maxlevel = (echelon_value*6)-30 - + if (quantity > maxlevel) then quantity = maxlevel end - + local base = getUI(base_path..":t") base.hardtext = i18n.get(name):toUtf8() local ui = getUI(base_path..":icon") @@ -1657,7 +1657,7 @@ function game:getRPJobs() rpjobs_elementary = {} rpjobs_roleplay = {} rpjobs = {} - + for i = 0, 499, 1 do local sheet = getDbProp("SERVER:INVENTORY:BAG:"..tostring(i)..":SHEET") if (sheet ~= 0) then @@ -1665,7 +1665,7 @@ function game:getRPJobs() if (string.sub(name, 0, 6) == "rpjob_") then local quality = getDbProp("SERVER:INVENTORY:BAG:"..tostring(i)..":QUALITY") local quantity = getDbProp("SERVER:INVENTORY:BAG:"..tostring(i)..":QUANTITY") - + if (name == "rpjob_advanced.sitem") then table.insert(rpjobs_advanced, quality) else @@ -1688,7 +1688,7 @@ function game:getRPJobs() end end end - + for id=1,2,1 do game:addRpJob("advanced", id, rpjobs_advanced[id], rpjobs) end diff --git a/code/ryzom/client/src/far_tp.cpp b/code/ryzom/client/src/far_tp.cpp index 765b1c421..8bc997599 100644 --- a/code/ryzom/client/src/far_tp.cpp +++ b/code/ryzom/client/src/far_tp.cpp @@ -602,7 +602,7 @@ void CLoginStateMachine::run() break; case st_disconnect: // Far TP part 2: disconnect from the FS and unload shard-specific data (called from farTPmainLoop()) - // FarTP.disconnectFromPreviousShard(); + FarTP.disconnectFromPreviousShard(); SM_BEGIN_EVENT_TABLE SM_EVENT(ev_connect, st_reconnect_fs); @@ -1439,9 +1439,6 @@ void CFarTP::farTPmainLoop() { ConnectionReadySent = false; LoginSM.pushEvent(CLoginStateMachine::ev_far_tp_main_loop_entered); - - disconnectFromPreviousShard(); - uint nbRecoSelectCharReceived = 0; bool welcomeWindow = true; diff --git a/code/ryzom/client/src/http_client_curl.cpp b/code/ryzom/client/src/http_client_curl.cpp index 4190de8e8..92bf3e957 100644 --- a/code/ryzom/client/src/http_client_curl.cpp +++ b/code/ryzom/client/src/http_client_curl.cpp @@ -20,6 +20,7 @@ #include #include +#include using namespace NLMISC; using namespace NLNET; @@ -62,11 +63,11 @@ bool CCurlHttpClient::authenticate(const std::string &user, const std::string &p const char *CAFilename = "ssl_ca_cert.pem"; // this is the certificate "Thawte Server CA" // *************************************************************************** -static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm) +static CURLcode sslctx_function(CURL * /* curl */, void *sslctx, void * /* parm */) { // look for certificate in search paths string path = CPath::lookup(CAFilename); - nldebug("Cert path '%s'", path.c_str()); + nlinfo("Cert path '%s'", path.c_str()); if (path.empty()) { @@ -91,6 +92,8 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm) // get a BIO BIO *bio = BIO_new_mem_buf(&buffer[0], file.getFileSize()); + + char errorBuffer[1024]; if (bio) { @@ -113,8 +116,19 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm) // add our certificate to this store if (X509_STORE_add_cert(store, itmp->x509) == 0) { - nlwarning("Error adding certificate"); - res = CURLE_SSL_CACERT; + uint errCode = ERR_get_error(); + + // ignore already in hash table errors + if (ERR_GET_LIB(errCode) != ERR_LIB_X509 || ERR_GET_REASON(errCode) != X509_R_CERT_ALREADY_IN_HASH_TABLE) + { + ERR_error_string_n(errCode, errorBuffer, 1024); + nlwarning("Error adding certificate %s: %s", itmp->x509->name, errorBuffer); + res = CURLE_SSL_CACERT; + } + } + else + { + nlinfo("Added certificate %s", itmp->x509->name); } } } @@ -148,7 +162,7 @@ bool CCurlHttpClient::verifyServer(bool verify) curl_easy_setopt(_Curl, CURLOPT_SSL_VERIFYPEER, verify ? 1 : 0); curl_easy_setopt(_Curl, CURLOPT_SSLCERTTYPE, "PEM"); // would allow to provide the CA in memory instead of using CURLOPT_CAINFO, but needs to include and link OpenSSL - if (curl_easy_setopt(_Curl, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function) == CURLE_NOT_BUILT_IN) + if (curl_easy_setopt(_Curl, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function) != CURLE_OK) { nlwarning("Unable to support CURLOPT_SSL_CTX_FUNCTION, curl not compiled with OpenSSL ?"); } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index c16807311..de06251f7 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -1833,7 +1833,8 @@ bool CInterfaceManager::saveConfig (const string &filename) COFile f; - if (!f.open(filename)) return false; + // using temporary file, so no f.close() unless its a success + if (!f.open(filename, false, false, true)) return false; CInterfaceConfig ic; @@ -1880,7 +1881,6 @@ bool CInterfaceManager::saveConfig (const string &filename) { nlwarning("Config saving failed"); // couldn't save result so do not continue - f.close(); return false; } @@ -1936,14 +1936,14 @@ bool CInterfaceManager::saveConfig (const string &filename) nlwarning("Bad user dyn chat saving"); return false; } + + f.close(); } catch(const NLMISC::EStream &) { - f.close(); nlwarning("Config saving failed."); return false; } - f.close(); ContinentMngr.serialFOWMaps(); @@ -2652,7 +2652,8 @@ bool CInterfaceManager::saveKeys(const std::string &filename) try { COFile file; - if (file.open (filename)) + // using temporary file, so no file.close() unless its a success + if (file.open (filename, false, false, true)) { COXml xmlStream; xmlStream.init (&file); @@ -2682,8 +2683,7 @@ bool CInterfaceManager::saveKeys(const std::string &filename) } catch (const Exception &e) { - nlwarning ("Error while writing the file %s : %s. Remove it.", filename.c_str(), e.what ()); - CFile::deleteFile(filename); + nlwarning ("Error while writing the file %s : %s.", filename.c_str(), e.what ()); } return ret; } diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index 109f9417e..954e022e5 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -779,7 +779,8 @@ void initLoginScreen() ClientApp = ClientCfg.ConfigFile.getVar("Application").asString(0); - string l = ClientCfg.LastLogin; + // give priority to login specified as argument + string l = !LoginLogin.empty() ? LoginLogin:ClientCfg.LastLogin; if(!l.empty()) { diff --git a/code/ryzom/client/src/login_patch.cpp b/code/ryzom/client/src/login_patch.cpp index bbd896ec9..019baaab5 100644 --- a/code/ryzom/client/src/login_patch.cpp +++ b/code/ryzom/client/src/login_patch.cpp @@ -1040,6 +1040,13 @@ void CPatchManager::executeBatchFile() arguments.push_back(startupPath); #endif + // log parameters passed to Ryzom client + nlinfo("Restarting Ryzom..."); + nlinfo("RyzomFilename = %s", RyzomFilename.c_str()); + nlinfo("ClientPatchPath = %s", ClientPatchPath.c_str()); + nlinfo("ClientRootPath = %s", ClientRootPath.c_str()); + nlinfo("StartupPath = %s", startupPath.c_str()); + batchFilename += UpdateBatchFilename; // make script executable diff --git a/code/ryzom/common/src/game_share/task_list.h b/code/ryzom/common/src/game_share/task_list.h index 3ac764ad8..b939d8bfa 100644 --- a/code/ryzom/common/src/game_share/task_list.h +++ b/code/ryzom/common/src/game_share/task_list.h @@ -99,7 +99,7 @@ public: void addTaskAt(T t, CTask* task) { task->setTime(t); _Tasks.push_back(task);_Clean = false; } uint32 getSize() const { return (uint32)_Tasks.size(); } CTask* getTaskAt(uint32 index) const { nlassert( index < _Tasks.size()); return _Tasks[index].getTask();} - void removeTaskAt(uint32 index){ nlassert( index < _Tasks.size()); _Tasks.erase(_Tasks.begin() + index); }; + void removeTaskAt(uint32 index){ nlassert( index < _Tasks.size()); _Tasks.erase(_Tasks.begin() + index); } // Waiting task are discared diff --git a/code/ryzom/server/src/input_output_service/chat_manager.cpp b/code/ryzom/server/src/input_output_service/chat_manager.cpp index e6dc5c254..872aa4501 100644 --- a/code/ryzom/server/src/input_output_service/chat_manager.cpp +++ b/code/ryzom/server/src/input_output_service/chat_manager.cpp @@ -488,7 +488,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr ) { // if( itCl->second->isMuted() ) CEntityId eid = TheDataset.getEntityId(sender); - if(_MutedUniverseUsers.find( eid ) != _MutedUniverseUsers.end()) + if(_MutedUsers.find( eid ) != _MutedUsers.end()) { nldebug("IOSCM: chat The player %s:%x is universe muted", TheDataset.getEntityId(sender).toString().c_str(), @@ -650,7 +650,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr ) // If universal channel check if player muted if (session->getChan()->UniversalChannel) { - if(_MutedUsers.find( eid ) != _MutedUsers.end()) + if(_MutedUniverseUsers.find( eid ) != _MutedUniverseUsers.end()) { nldebug("IOSCM: chat The player %s:%x is muted", TheDataset.getEntityId(sender).toString().c_str(), diff --git a/code/ryzom/tools/client/client_config_qt/stdpch.h b/code/ryzom/tools/client/client_config_qt/stdpch.h index 744899ecd..112cd5c45 100644 --- a/code/ryzom/tools/client/client_config_qt/stdpch.h +++ b/code/ryzom/tools/client/client_config_qt/stdpch.h @@ -17,14 +17,6 @@ #ifndef STDPCH_H #define STDPCH_H -#include - -#ifdef Q_COMPILER_RVALUE_REFS -#undef Q_COMPILER_RVALUE_REFS -#endif - -#include - #include #include