diff --git a/code/nel/include/nel/misc/string_common.h b/code/nel/include/nel/misc/string_common.h
deleted file mode 100644
index 372ee4be5..000000000
--- a/code/nel/include/nel/misc/string_common.h
+++ /dev/null
@@ -1,396 +0,0 @@
-// NeL - MMORPG Framework
-// Copyright (C) 2010 Winch Gate Property Limited
-//
-// This source file has been modified by the following contributors:
-// Copyright (C) 2012 Laszlo KIS-ADAM (dfighter)
-// Copyright (C) 2016-2019 Jan BOON (Kaetemi)
-//
-// 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 NL_STRING_COMMON_H
-#define NL_STRING_COMMON_H
-
-#include "types_nl.h"
-
-#include
-#include
-#include
-#include
-
-namespace NLMISC
-{
-
-// get a string and add \r before \n if necessary
-std::string addSlashR (const std::string &str);
-std::string removeSlashR (const std::string &str);
-
-/**
- * \def MaxCStringSize
- *
- * The maximum size allowed for C string (zero terminated string) buffer.
- * This value is used when we have to create a standard C string buffer and we don't know exactly the final size of the string.
- */
-const int MaxCStringSize = 2048;
-
-
-/**
- * \def NLMISC_CONVERT_VARGS(dest,format)
- *
- * This macro converts variable arguments into C string (zero terminated string).
- * This function takes care to avoid buffer overflow.
- *
- * Example:
- *\code
- void MyFunction(const char *format, ...)
- {
- string str;
- NLMISC_CONVERT_VARGS (str, format, NLMISC::MaxCStringSize);
- // str contains the result of the conversion
- }
- *\endcode
- *
- * \param _dest \c string or \c char* that contains the result of the convertion
- * \param _format format of the string, it must be the last argument before the \c '...'
- * \param _size size of the buffer that will contain the C string
- */
-#define NLMISC_CONVERT_VARGS(_dest,_format,_size) \
-char _cstring[_size]; \
-va_list _args; \
-va_start (_args, _format); \
-int _res = vsnprintf (_cstring, _size-1, _format, _args); \
-if (_res == -1 || _res == _size-1) \
-{ \
- _cstring[_size-1] = '\0'; \
-} \
-va_end (_args); \
-_dest = _cstring
-
-
-
-/** sMart sprintf function. This function do a sprintf and add a zero at the end of the buffer
- * if there no enough room in the buffer.
- *
- * \param buffer a C string
- * \param count Size of the buffer
- * \param format of the string, it must be the last argument before the \c '...'
- */
-sint smprintf( char *buffer, size_t count, const char *format, ... );
-
-
-#ifdef NL_OS_WINDOWS
-
-//
-// These functions are needed by template system to failed the compilation if you pass bad type on nlinfo...
-//
-
-inline void _check(int /* a */) { }
-inline void _check(unsigned int /* a */) { }
-inline void _check(char /* a */) { }
-inline void _check(unsigned char /* a */) { }
-inline void _check(long /* a */) { }
-inline void _check(unsigned long /* a */) { }
-
-#ifdef NL_COMP_VC6
- inline void _check(uint8 /* a */) { }
-#endif // NL_COMP_VC6
-
-inline void _check(sint8 /* a */) { }
-inline void _check(uint16 /* a */) { }
-inline void _check(sint16 /* a */) { }
-
-#ifdef NL_COMP_VC6
- inline void _check(uint32 /* a */) { }
- inline void _check(sint32 /* a */) { }
-#endif // NL_COMP_VC6
-
-inline void _check(uint64 /* a */) { }
-inline void _check(sint64 /* a */) { }
-inline void _check(float /* a */) { }
-inline void _check(double /* a */) { }
-inline void _check(const char * /* a */) { }
-inline void _check(const void * /* a */) { }
-
-#define CHECK_TYPES(__a,__b) \
-inline __a(const char *fmt) { __b(fmt); } \
-template __a(const char *fmt, A a) { _check(a); __b(fmt, a); } \
-template __a(const char *fmt, A a, B b) { _check(a); _check(b); __b(fmt, a, b); } \
-template __a(const char *fmt, A a, B b, C c) { _check(a); _check(b); _check(c); __b(fmt, a, b, c); } \
-template __a(const char *fmt, A a, B b, C c, D d) { _check(a); _check(b); _check(c); _check(d); __b(fmt, a, b, c, d); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e) { _check(a); _check(b); _check(c); _check(d); _check(e); __b(fmt, a, b, c, d, e); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); __b(fmt, a, b, c, d, e, f); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); __b(fmt, a, b, c, d, e, f, g); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); __b(fmt, a, b, c, d, e, f, g, h); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); __b(fmt, a, b, c, d, e, f, g, h, i); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); __b(fmt, a, b, c, d, e, f, g, h, i, j); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); _check(k); __b(fmt, a, b, c, d, e, f, g, h, i, j, k); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); _check(k); _check(l); __b(fmt, a, b, c, d, e, f, g, h, i, j, k, l); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); _check(k); _check(l); _check(m); __b(fmt, a, b, c, d, e, f, g, h, i, j, k, l, m); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); _check(k); _check(l); _check(m); _check(n); __b(fmt, a, b, c, d, e, f, g, h, i, j, k, l, m, n); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); _check(k); _check(l); _check(m); _check(n); _check(o); __b(fmt, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); _check(k); _check(l); _check(m); _check(n); _check(o); _check(p); __b(fmt, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p, Q q) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); _check(k); _check(l); _check(m); _check(n); _check(o); _check(p); _check(q); __b(fmt, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p, Q q, R r) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); _check(k); _check(l); _check(m); _check(n); _check(o); _check(p); _check(q); _check(r); __b(fmt, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p, Q q, R r, S s) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); _check(k); _check(l); _check(m); _check(n); _check(o); _check(p); _check(q); _check(r); _check(s); __b(fmt, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p, Q q, R r, S s, T t) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); _check(k); _check(l); _check(m); _check(n); _check(o); _check(p); _check(q); _check(r); _check(s); _check(t); __b(fmt, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p, Q q, R r, S s, T t, U u) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); _check(k); _check(l); _check(m); _check(n); _check(o); _check(p); _check(q); _check(r); _check(s); _check(t); _check(u); __b(fmt, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p, Q q, R r, S s, T t, U u, V v) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); _check(k); _check(l); _check(m); _check(n); _check(o); _check(p); _check(q); _check(r); _check(s); _check(t); _check(u); _check(v); __b(fmt, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p, Q q, R r, S s, T t, U u, V v, W w) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); _check(k); _check(l); _check(m); _check(n); _check(o); _check(p); _check(q); _check(r); _check(s); _check(t); _check(u); _check(v); _check(w); __b(fmt, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p, Q q, R r, S s, T t, U u, V v, W w, X x) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); _check(k); _check(l); _check(m); _check(n); _check(o); _check(p); _check(q); _check(r); _check(s); _check(t); _check(u); _check(v); _check(w); _check(x); __b(fmt, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p, Q q, R r, S s, T t, U u, V v, W w, X x, Y y) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); _check(k); _check(l); _check(m); _check(n); _check(o); _check(p); _check(q); _check(r); _check(s); _check(t); _check(u); _check(v); _check(w); _check(x); _check(y); __b(fmt, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y); } \
-template __a(const char *fmt, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p, Q q, R r, S s, T t, U u, V v, W w, X x, Y y, Z z) { _check(a); _check(b); _check(c); _check(d); _check(e); _check(f); _check(g); _check(h); _check(i); _check(j); _check(k); _check(l); _check(m); _check(n); _check(o); _check(p); _check(q); _check(r); _check(s); _check(t); _check(u); _check(v); _check(w); _check(x); _check(y); _check(z); __b(fmt, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z); }
-
-#endif
-
-#ifdef NL_OS_WINDOWS
- inline std::string _toString(const char *format, ...)
-#else
- inline std::string toString(const char *format, ...)
-#endif
-{
- std::string Result;
- NLMISC_CONVERT_VARGS(Result, format, NLMISC::MaxCStringSize);
- return Result;
-}
-
-#ifdef NL_OS_WINDOWS
- CHECK_TYPES(std::string toString, return _toString)
-#endif // NL_OS_WINDOWS
-
-template std::string toStringPtr(const T *val) { return toString("%p", val); }
-
-template std::string toStringEnum(const T &val) { return toString("%u", (uint32)val); }
-
-/**
- * Template Object toString.
- * \param obj any object providing a "std::string toString()" method. The object doesn't have to derive from anything.
- *
- * the VC++ error "error C2228: left of '.toString' must have class/struct/union type" means you don't provide
- * a toString() method to your object.
- */
-template std::string toString(const T &obj)
-{
- return obj.toString();
-}
-
-//inline std::string toString(const char *val) { return toString("%s", val); }
-inline std::string toString(const uint8 &val) { return toString("%hu", (uint16)val); }
-inline std::string toString(const sint8 &val) { return toString("%hd", (sint16)val); }
-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); }
-
-#ifdef NL_COMP_GCC
-# if GCC_VERSION == 40102
-
-// error fix for size_t? gcc 4.1.2 requested this type instead of size_t ...
-inline std::string toString(const long unsigned int &val)
-{
-#ifdef _LP64
- return toString((uint64)val);
-#else
- return toString((uint32)val);
-#endif
-}
-
-# endif
-#endif
-
-#if (SIZEOF_SIZE_T) == 8
-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); }
-#endif
-#endif
-
-inline std::string toString(const float &val) { return toString("%f", val); }
-inline std::string toString(const double &val) { return toString("%lf", val); }
-inline std::string toString(const bool &val) { return val ? "1":"0"; }
-inline std::string toString(const std::string &val) { return val; }
-
-// stl vectors of bool use bit reference and not real bools, so define the operator for bit reference
-
-#ifdef NL_COMP_VC6
-inline std::string toString(const uint &val) { return toString("%u", val); }
-inline std::string toString(const sint &val) { return toString("%d", val); }
-#endif // NL_COMP_VC6
-
-template
-bool fromString(const std::string &str, T &obj)
-{
- return obj.fromString(str);
-}
-
-inline bool fromString(const std::string &str, uint32 &val) { if (str.find('-') != std::string::npos) { val = 0; return false; } char *end; unsigned long v; errno = 0; v = strtoul(str.c_str(), &end, 10); if (errno || v > UINT_MAX || end == str.c_str()) { val = 0; return false; } else { val = (uint32)v; return true; } }
-inline bool fromString(const std::string &str, sint32 &val) { char *end; long v; errno = 0; v = strtol(str.c_str(), &end, 10); if (errno || v > INT_MAX || v < INT_MIN || end == str.c_str()) { val = 0; return false; } else { val = (sint32)v; return true; } }
-inline bool fromString(const std::string &str, uint8 &val) { char *end; long v; errno = 0; v = strtol(str.c_str(), &end, 10); if (errno || v > UCHAR_MAX || v < 0 || end == str.c_str()) { val = 0; return false; } else { val = (uint8)v; return true; } }
-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, 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; }
-
-/// Fast string to bool, reliably defined for strings starting with 0, 1, t, T, f, F, y, Y, n, N, and empty strings, anything else is undefined.
-/// - Kaetemi
-inline bool toBool(const char *str) { return str[0] == '1' || (str[0] & 0xD2) == 0x50; }
-inline bool toBool(const std::string &str) { return toBool(str.c_str()); } // Safe because first byte may be null
-
-bool fromString(const std::string &str, bool &val);
-
-inline bool fromString(const std::string &str, std::string &val) { val = str; return true; }
-
-// stl vectors of bool use bit reference and not real bools, so define the operator for bit reference
-
-#ifdef NL_COMP_VC6
-inline bool fromString(const std::string &str, uint &val) { return sscanf(str.c_str(), "%u", &val) == 1; }
-inline bool fromString(const std::string &str, sint &val) { return sscanf(str.c_str(), "%d", &val) == 1; }
-#endif // NL_COMP_VC6
-
-inline bool startsWith(const char *str, const char *prefix)
-{
- for (int i = 0;; ++i)
- {
- if (str[i] != prefix[i] || str[i] == '\0')
- {
- return prefix[i] == '\0';
- }
- }
-}
-
-inline bool startsWith(const std::string &str, const char *prefix) { return startsWith(str.c_str(), prefix); }
-inline bool startsWith(const std::string &str, const std::string &prefix) { return startsWith(str.c_str(), prefix.c_str()); }
-
-inline bool endsWith(const char *str, size_t strLen, const char *suffix, size_t suffixLen)
-{
- if (strLen < suffixLen)
- return false;
- int minLen = strLen < suffixLen ? strLen : suffixLen;
- for (int i = 1; i <= minLen; ++i)
- if (str[strLen - i] != suffix[suffixLen - i])
- return false;
- return true;
-}
-
-inline bool endsWith(const char *str, const char *suffix) { return endsWith(str, strlen(str), suffix, strlen(suffix)); }
-inline bool endsWith(const std::string &str, const char *suffix) { return endsWith(str.c_str(), str.size(), suffix, strlen(suffix)); }
-inline bool endsWith(const std::string &str, const std::string &suffix) { return endsWith(str.c_str(), str.size(), suffix.c_str(), suffix.size()); }
-
-// Convert local codepage to UTF-8
-// On Windows, the local codepage is undetermined
-// On Linux, the local codepage is always UTF-8 (no-op)
-std::string mbcsToUtf8(const char *str, size_t len = 0);
-std::string mbcsToUtf8(const std::string &str);
-
-// Convert wide codepage to UTF-8
-// On Windows, the wide codepage is UTF-16
-// On Linux, the wide codepage is UTF-32
-std::string wideToUtf8(const wchar_t *str, size_t len = 0);
-std::string wideToUtf8(const std::wstring &str);
-
-// Convert UTF-8 to wide character set
-std::wstring utf8ToWide(const char *str, size_t len = 0);
-std::wstring utf8ToWide(const std::string &str);
-
-// Convert UTF-8 to local multibyte character set
-std::string utf8ToMbcs(const char *str, size_t len = 0);
-std::string utf8ToMbcs(const std::string &str);
-
-// Convert wide to local multibyte character set
-std::string wideToMbcs(const wchar_t *str, size_t len = 0);
-std::string wideToMbcs(const std::wstring &str);
-
-// Convert local multibyte to wide character set
-std::wstring mbcsToWide(const char *str, size_t len = 0);
-std::wstring mbcsToWide(const std::string &str);
-
-inline const char *asCStr(const char *str) { return str; }
-inline const char *asCStr(const std::string &str) { return str.c_str(); }
-inline const wchar_t *asCStr(const wchar_t *str) { return str; }
-inline const wchar_t *asCStr(const std::wstring &str) { return str.c_str(); }
-
-#if defined(NL_OS_WINDOWS)
-#define nlUtf8ToMbcs(str) (NLMISC::utf8ToMbcs(str).c_str())
-#define nlMbcsToUtf8(str) (NLMISC::mbcsToUtf8(str).c_str())
-#else
-#define nlUtf8ToMbcs(str) (NLMISC::asCStr(str))
-#define nlMbcsToUtf8(str) (NLMISC::asCStr(str))
-#endif
-#define nlWideToUtf8(str) (NLMISC::wideToUtf8(str).c_str())
-#define nlUtf8ToWide(str) (NLMISC::utf8ToWide(str).c_str())
-#define nlWideToMbcs(str) (NLMISC::wideToMbcs(str).c_str())
-#define nlMbcsToWide(str) (NLMISC::mbcsToWide(str).c_str())
-
-// On Windows, tstring is either local multibyte or utf-16 wide
-// On Linux, tstring is always utf-8
-
-#if defined(NL_OS_WINDOWS) && (defined(UNICODE) || defined(_UNICODE))
-typedef std::wstring tstring;
-typedef wchar_t tchar;
-inline std::string tStrToUtf8(const tchar *str) { return wideToUtf8((const wchar_t *)str); }
-inline std::string tStrToUtf8(const tstring &str) { return wideToUtf8((const std::wstring &)str); }
-inline std::wstring tStrToWide(const tchar *str) { return (const wchar_t *)str; }
-inline std::wstring tStrToWide(const tstring &str) { return (const std::wstring &)str; }
-inline std::string tStrToMbcs(const tchar *str) { return wideToMbcs((const wchar_t *)str); }
-inline std::string tStrToMbcs(const tstring &str) { return wideToMbcs((const std::wstring &)str); }
-#define nlTStrToUtf8(str) (NLMISC::tStrToUtf8(str).c_str())
-#define nlTStrToWide(str) ((const wchar_t *)NLMISC::asCStr(str))
-#define nlTStrToMbcs(str) (NLMISC::tStrToMbcs(str).c_str())
-inline tstring utf8ToTStr(const char *str) {return (const tstring &)utf8ToWide(str); }
-inline tstring utf8ToTStr(const std::string &str) { return (const tstring &)utf8ToWide(str); }
-inline tstring wideToTStr(const wchar_t *str) { return (const tchar *)str; }
-inline tstring wideToTStr(const std::wstring &str) { return (const tstring &)str; }
-inline tstring mbcsToTStr(const char *str) { return (const tstring &)mbcsToWide(str); }
-inline tstring mbcsToTStr(const std::string &str) { return (const tstring &)mbcsToWide(str); }
-#define nlUtf8ToTStr(str) (NLMISC::utf8ToTStr(str).c_str())
-#define nlWideToTStr(str) ((const tchar *)NLMISC::asCStr(str))
-#define nlMbcsToTStr(str) (NLMISC::mbcsToTStr(str).c_str())
-#else
-typedef std::string tstring;
-typedef char tchar;
-inline std::string tStrToUtf8(const tchar *str) { return mbcsToUtf8((const char *)str); }
-inline std::string tStrToUtf8(const tstring &str) { return mbcsToUtf8((const std::string &)str); }
-inline std::wstring tStrToWide(const tchar *str) { return mbcsToWide((const char *)str); }
-inline std::wstring tStrToWide(const tstring &str) { return mbcsToWide((const std::string &)str); }
-inline std::string tStrToMbcs(const tchar *str) { return (const char *)str; }
-inline std::string tStrToMbcs(const tstring &str) { return (const std::string &)str; }
-#if defined(NL_OS_WINDOWS)
-#define nlTStrToUtf8(str) (NLMISC::tStrToUtf8(str).c_str())
-#else
-#define nlTStrToUtf8(str) ((const char *)NLMISC::asCStr(str))
-#endif
-#define nlTStrToWide(str) (NLMISC::tStrToWide(str).c_str())
-#define nlTStrToMbcs(str) ((const char *)NLMISC::asCStr(str))
-inline tstring utf8ToTStr(const char *str) { return (const tstring &)utf8ToMbcs(str); }
-inline tstring utf8ToTStr(const std::string &str) { return (const tstring &)utf8ToMbcs(str); }
-inline tstring wideToTStr(const wchar_t *str) { return (const tstring &)wideToMbcs(str); }
-inline tstring wideToTStr(const std::wstring &str) { return (const tstring &)wideToMbcs(str); }
-inline tstring mbcsToTStr(const char *str) { return (const tchar *)str; }
-inline tstring mbcsToTStr(const std::string &str) { return (const tstring &)str; }
-#if defined(NL_OS_WINDOWS)
-#define nlUtf8ToTStr(str) (NLMISC::utf8ToTStr(str).c_str())
-#else
-#define nlUtf8ToTStr(str) ((const tchar *)NLMISC::asCStr(str))
-#endif
-#define nlWideToTStr(str) (NLMISC::wideToTStr(str).c_str())
-#define nlMbcsToTStr(str) ((const tchar *)NLMISC::asCStr(str))
-#endif
-
-} // NLMISC
-
-#endif // NL_STRING_COMMON_H
diff --git a/code/nel/tools/build_gamedata/0_setup.py b/code/nel/tools/build_gamedata/0_setup.py
deleted file mode 100644
index 12441fb05..000000000
--- a/code/nel/tools/build_gamedata/0_setup.py
+++ /dev/null
@@ -1,594 +0,0 @@
-#!/usr/bin/python
-#
-# \file 0_setup.py
-# \brief Run all setup processes
-# \date 2009-02-18 15:28GMT
-# \author Jan Boon (Kaetemi)
-# Python port of game data build pipeline.
-# Run all setup processes
-#
-# NeL - MMORPG Framework
-# Copyright (C) 2009-2014 by authors
-#
-# 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 .
-#
-
-import time, sys, os, shutil, subprocess, distutils.dir_util, argparse
-sys.path.append("configuration")
-
-parser = argparse.ArgumentParser(description='Ryzom Core - Build Gamedata - Setup')
-parser.add_argument('--noconf', '-nc', action='store_true')
-parser.add_argument('--noverify', '-nv', action='store_true')
-parser.add_argument('--preset', '-p', action='store_true')
-# parser.add_argument('--haltonerror', '-eh', action='store_true')
-parser.add_argument('--includeproject', '-ipj', nargs='+')
-parser.add_argument('--excludeproject', '-epj', nargs='+')
-parser.add_argument('--includeprocess', '-ipc', nargs='+')
-parser.add_argument('--excludeprocess', '-epc', nargs='+')
-args = parser.parse_args()
-
-if not args.includeproject == None and not args.excludeproject == None:
- print "ERROR --includeproject cannot be combined with --excludeproject, exit."
- exit()
-
-if not args.includeprocess == None and not args.excludeprocess == None:
- print "ERROR --includeprocess cannot be combined with --excludeprocess, exit."
- exit()
-
-if os.path.isfile("log.log"):
- os.remove("log.log")
-log = open("log.log", "w")
-from scripts import *
-try:
- from buildsite import *
-except ImportError:
- printLog(log, "*** FIRST RUN ***")
- if args.noconf:
- printLog(log, "ERROR --noconf is invalid on first run, exit.")
- exit()
-from tools import *
-
-if not args.noconf:
- try:
- BuildQuality
- except NameError:
- BuildQuality = 1
- try:
- if args.preset:
- DummyUnknownName
- RemapLocalFrom
- except NameError:
- RemapLocalFrom = 'R:'
- try:
- if args.preset:
- DummyUnknownName
- RemapLocalTo
- except NameError:
- RemapLocalTo = os.getenv('RC_ROOT').replace('\\', '/')
- if (not RemapLocalTo) or (not ':' in RemapLocalTo):
- RemapLocalTo = 'R:'
- try:
- if args.preset:
- DummyUnknownName
- ToolDirectories
- except NameError:
- ToolDirectories = [ 'R:/distribution/nel_tools_win_x64', 'R:/distribution/ryzom_tools_win_x64' ]
- try:
- ToolSuffix
- except NameError:
- ToolSuffix = ".exe"
- try:
- if args.preset:
- DummyUnknownName
- ScriptDirectory
- except NameError:
- ScriptDirectory = "R:/code/nel/tools/build_gamedata"
- try:
- if args.preset:
- DummyUnknownName
- WorkspaceDirectory
- except NameError:
- WorkspaceDirectory = "R:/leveldesign/workspace"
- try:
- if args.preset:
- DummyUnknownName
- DatabaseDirectory
- except NameError:
- DatabaseDirectory = "R:/graphics"
- try:
- if args.preset:
- DummyUnknownName
- SoundDirectory
- except NameError:
- SoundDirectory = "R:/sound"
- try:
- if args.preset:
- DummyUnknownName
- SoundDfnDirectory
- except NameError:
- SoundDfnDirectory = "R:/sound/DFN"
- try:
- if args.preset:
- DummyUnknownName
- ExportBuildDirectory
- except NameError:
- ExportBuildDirectory = "R:/pipeline/export"
- try:
- if args.preset:
- DummyUnknownName
- InstallDirectory
- except NameError:
- InstallDirectory = "R:/pipeline/install"
- try:
- if args.preset:
- DummyUnknownName
- ClientDevDirectory
- except NameError:
- ClientDevDirectory = "R:/pipeline/client_dev"
- try:
- if args.preset:
- DummyUnknownName
- ClientDevLiveDirectory
- except NameError:
- ClientDevLiveDirectory = "R:/pipeline/client_dev_live"
- try:
- if args.preset:
- DummyUnknownName
- ClientPatchDirectory
- except NameError:
- ClientPatchDirectory = "R:/pipeline/client_patch"
- try:
- if args.preset:
- DummyUnknownName
- ClientInstallDirectory
- except NameError:
- ClientInstallDirectory = "R:/pipeline/client_install"
- try:
- if args.preset:
- DummyUnknownName
- ShardInstallDirectory
- except NameError:
- ShardInstallDirectory = "R:/pipeline/shard"
- try:
- if args.preset:
- DummyUnknownName
- ShardDevDirectory
- except NameError:
- ShardDevDirectory = "R:/pipeline/shard_dev"
- try:
- if args.preset:
- DummyUnknownName
- WorldEditInstallDirectory
- except NameError:
- WorldEditInstallDirectory = "R:/pipeline/worldedit"
- try:
- if args.preset:
- DummyUnknownName
- WorldEditorFilesDirectory
- except NameError:
- WorldEditorFilesDirectory = "R:/code/ryzom/common/data_leveldesign/leveldesign/world_editor_files"
- try:
- if args.preset:
- DummyUnknownName
- LeveldesignDirectory
- except NameError:
- LeveldesignDirectory = "R:/leveldesign"
- try:
- if args.preset:
- DummyUnknownName
- LeveldesignDfnDirectory
- except NameError:
- LeveldesignDfnDirectory = "R:/leveldesign/DFN"
- try:
- if args.preset:
- DummyUnknownName
- LeveldesignWorldDirectory
- except NameError:
- LeveldesignWorldDirectory = "R:/leveldesign/world"
- try:
- if args.preset:
- DummyUnknownName
- PrimitivesDirectory
- except NameError:
- PrimitivesDirectory = "R:/leveldesign/primitives"
- try:
- if args.preset:
- DummyUnknownName
- LeveldesignDataCommonDirectory
- except NameError:
- LeveldesignDataCommonDirectory = "R:/leveldesign/common"
- try:
- if args.preset:
- DummyUnknownName
- LeveldesignDataShardDirectory
- except NameError:
- LeveldesignDataShardDirectory = "R:/leveldesign/shard"
- try:
- if args.preset:
- DummyUnknownName
- TranslationDirectory
- except NameError:
- TranslationDirectory = "R:/leveldesign/translation"
- try:
- if args.preset:
- DummyUnknownName
- GamedevDirectory
- except NameError:
- GamedevDirectory = "R:/code/ryzom/client/data/gamedev"
- try:
- if args.preset:
- DummyUnknownName
- DataCommonDirectory
- except NameError:
- DataCommonDirectory = "R:/code/ryzom/common/data_common"
- try:
- if args.preset:
- DummyUnknownName
- DataShardDirectory
- except NameError:
- DataShardDirectory = "R:/code/ryzom/server/data_shard"
- try:
- if args.preset:
- DummyUnknownName
- WindowsExeDllCfgDirectories
- except NameError:
- # TODO: Separate 64bit and 32bit
- WindowsExeDllCfgDirectories = [ '', 'R:/build/fv_x64/bin/Release', 'R:/distribution/external_x64', 'R:/code/ryzom/client', '', '', '' ]
- try:
- if args.preset:
- DummyUnknownName
- LinuxServiceExecutableDirectory
- except NameError:
- LinuxServiceExecutableDirectory = "R:/build/server_gcc/bin"
- try:
- if args.preset:
- DummyUnknownName
- LinuxClientExecutableDirectory
- except NameError:
- LinuxClientExecutableDirectory = "R:/build/client_gcc/bin"
- try:
- if args.preset:
- DummyUnknownName
- PatchmanDevDirectory
- except NameError:
- PatchmanDevDirectory = "R:/patchman/terminal_dev"
- try:
- if args.preset:
- DummyUnknownName
- PatchmanCfgAdminDirectory
- except NameError:
- PatchmanCfgAdminDirectory = "R:/patchman/admin_install"
- try:
- if args.preset:
- DummyUnknownName
- PatchmanCfgDefaultDirectory
- except NameError:
- PatchmanCfgDefaultDirectory = "R:/patchman/default"
- try:
- if args.preset:
- DummyUnknownName
- PatchmanBridgeServerDirectory
- except NameError:
- PatchmanBridgeServerDirectory = "R:/pipeline/bridge_server"
- try:
- SignToolExecutable
- except NameError:
- SignToolExecutable = "C:/Program Files/Microsoft SDKs/Windows/v6.0A/Bin/signtool.exe"
- try:
- SignToolSha1
- except NameError:
- SignToolSha1 = ""
- try:
- SignToolTimestamp
- except NameError:
- SignToolTimestamp = "http://timestamp.comodoca.com/authenticode"
- try:
- MaxAvailable
- except NameError:
- MaxAvailable = 1
- try:
- MaxDirectory
- except NameError:
- MaxDirectory = "C:/Program Files (x86)/Autodesk/3ds Max 2010"
- try:
- MaxUserDirectory
- except NameError:
- import os
- try:
- MaxUserDirectory = os.path.normpath(os.environ["LOCALAPPDATA"] + "/Autodesk/3dsMax/2010 - 32bit/enu")
- except KeyError:
- MaxAvailable = 0
- MaxUserDirectory = "C:/Users/Kaetemi/AppData/Local/Autodesk/3dsMax/2010 - 32bit/enu"
- try:
- MaxExecutable
- except NameError:
- MaxExecutable = "3dsmax.exe"
-
- printLog(log, "")
- printLog(log, "-------")
- printLog(log, "--- Setup build site")
- printLog(log, "-------")
- printLog(log, time.strftime("%Y-%m-%d %H:%MGMT", time.gmtime(time.time())))
- printLog(log, "")
- printLog(log, "This script will set up the buildsite configuration, and create needed directories.")
- printLog(log, "To use the defaults, simply hit ENTER, else type in the new value.")
- printLog(log, "Use -- if you need to insert an empty value.")
- printLog(log, "")
- BuildQuality = int(askVar(log, "Build Quality", str(BuildQuality)))
- if not args.preset:
- ToolDirectories[0] = askVar(log, "[IN] Primary Tool Directory", ToolDirectories[0]).replace("\\", "/")
- ToolDirectories[1] = askVar(log, "[IN] Secondary Tool Directory", ToolDirectories[1]).replace("\\", "/")
- ToolSuffix = askVar(log, "Tool Suffix", ToolSuffix)
- ScriptDirectory = askVar(log, "[IN] Script Directory", os.getcwd().replace("\\", "/")).replace("\\", "/")
- WorkspaceDirectory = askVar(log, "[IN] Workspace Directory", WorkspaceDirectory).replace("\\", "/")
- DatabaseDirectory = askVar(log, "[IN] Database Directory", DatabaseDirectory).replace("\\", "/")
- SoundDirectory = askVar(log, "[IN] Sound Directory", SoundDirectory).replace("\\", "/")
- SoundDfnDirectory = askVar(log, "[IN] Sound DFN Directory", SoundDfnDirectory).replace("\\", "/")
- ExportBuildDirectory = askVar(log, "[OUT] Export Build Directory", ExportBuildDirectory).replace("\\", "/")
- InstallDirectory = askVar(log, "[OUT] Install Directory", InstallDirectory).replace("\\", "/")
- ClientDevDirectory = askVar(log, "[OUT] Client Dev Directory", ClientDevDirectory).replace("\\", "/")
- ClientDevLiveDirectory = askVar(log, "[OUT] Client Dev Live Directory", ClientDevLiveDirectory).replace("\\", "/")
- ClientPatchDirectory = askVar(log, "[OUT] Client Patch Directory", ClientPatchDirectory).replace("\\", "/")
- ClientInstallDirectory = askVar(log, "[OUT] Client Install Directory", ClientInstallDirectory).replace("\\", "/")
- ShardInstallDirectory = askVar(log, "[OUT] Shard Data Install Directory", ShardInstallDirectory).replace("\\", "/")
- ShardDevDirectory = askVar(log, "[OUT] Shard Dev Directory", ShardDevDirectory).replace("\\", "/")
- WorldEditInstallDirectory = askVar(log, "[OUT] World Edit Data Install Directory", WorldEditInstallDirectory).replace("\\", "/")
- LeveldesignDirectory = askVar(log, "[IN] Leveldesign Directory", LeveldesignDirectory).replace("\\", "/")
- LeveldesignDfnDirectory = askVar(log, "[IN] Leveldesign DFN Directory", LeveldesignDfnDirectory).replace("\\", "/")
- LeveldesignWorldDirectory = askVar(log, "[IN] Leveldesign World Directory", LeveldesignWorldDirectory).replace("\\", "/")
- PrimitivesDirectory = askVar(log, "[IN] Primitives Directory", PrimitivesDirectory).replace("\\", "/")
- GamedevDirectory = askVar(log, "[IN] Gamedev Directory", GamedevDirectory).replace("\\", "/")
- DataShardDirectory = askVar(log, "[IN] Data Shard Directory", DataShardDirectory).replace("\\", "/")
- DataCommonDirectory = askVar(log, "[IN] Data Common Directory", DataCommonDirectory).replace("\\", "/")
- TranslationDirectory = askVar(log, "[IN] Translation Directory", TranslationDirectory).replace("\\", "/")
- LeveldesignDataShardDirectory = askVar(log, "[IN] Leveldesign Data Shard Directory", LeveldesignDataShardDirectory).replace("\\", "/")
- LeveldesignDataCommonDirectory = askVar(log, "[IN] Leveldesign Data Common Directory", LeveldesignDataCommonDirectory).replace("\\", "/")
- WorldEditorFilesDirectory = askVar(log, "[IN] World Editor Files Directory", WorldEditorFilesDirectory).replace("\\", "/")
- WindowsExeDllCfgDirectories[0] = askVar(log, "[IN] Primary Windows exe/dll/cfg Directory", WindowsExeDllCfgDirectories[0]).replace("\\", "/")
- WindowsExeDllCfgDirectories[1] = askVar(log, "[IN] Secondary Windows exe/dll/cfg Directory", WindowsExeDllCfgDirectories[1]).replace("\\", "/")
- WindowsExeDllCfgDirectories[2] = askVar(log, "[IN] Tertiary Windows exe/dll/cfg Directory", WindowsExeDllCfgDirectories[2]).replace("\\", "/")
- WindowsExeDllCfgDirectories[3] = askVar(log, "[IN] Quaternary Windows exe/dll/cfg Directory", WindowsExeDllCfgDirectories[3]).replace("\\", "/")
- WindowsExeDllCfgDirectories[4] = askVar(log, "[IN] Quinary Windows exe/dll/cfg Directory", WindowsExeDllCfgDirectories[4]).replace("\\", "/")
- WindowsExeDllCfgDirectories[5] = askVar(log, "[IN] Senary Windows exe/dll/cfg Directory", WindowsExeDllCfgDirectories[5]).replace("\\", "/")
- WindowsExeDllCfgDirectories[6] = askVar(log, "[IN] Septenary Windows exe/dll/cfg Directory", WindowsExeDllCfgDirectories[6]).replace("\\", "/")
- LinuxServiceExecutableDirectory = askVar(log, "[IN] Linux Service Executable Directory", LinuxServiceExecutableDirectory).replace("\\", "/")
- LinuxClientExecutableDirectory = askVar(log, "[IN] Linux Client Executable Directory", LinuxClientExecutableDirectory).replace("\\", "/")
- PatchmanDevDirectory = askVar(log, "[IN] Patchman Directory", PatchmanDevDirectory).replace("\\", "/")
- PatchmanCfgAdminDirectory = askVar(log, "[IN] Patchman Cfg Admin Directory", PatchmanCfgAdminDirectory).replace("\\", "/")
- PatchmanCfgDefaultDirectory = askVar(log, "[IN] Patchman Cfg Default Directory", PatchmanCfgDefaultDirectory).replace("\\", "/")
- PatchmanBridgeServerDirectory = askVar(log, "[OUT] Patchman Bridge Server Patch Directory", PatchmanBridgeServerDirectory).replace("\\", "/")
- SignToolExecutable = askVar(log, "Sign Tool Executable", SignToolExecutable).replace("\\", "/")
- SignToolSha1 = askVar(log, "Sign Tool Signature SHA1", SignToolSha1)
- SignToolTimestamp = askVar(log, "Sign Tool Timestamp Authority", SignToolTimestamp)
- MaxAvailable = int(askVar(log, "3dsMax Available", str(MaxAvailable)))
- if MaxAvailable:
- MaxDirectory = askVar(log, "3dsMax Directory", MaxDirectory).replace("\\", "/")
- MaxUserDirectory = askVar(log, "3dsMax User Directory", MaxUserDirectory).replace("\\", "/")
- MaxExecutable = askVar(log, "3dsMax Executable", MaxExecutable)
- if os.path.isfile("configuration/buildsite.py"):
- os.remove("configuration/buildsite.py")
- sf = open("configuration/buildsite.py", "w")
- sf.write("#!/usr/bin/python\n")
- sf.write("# \n")
- sf.write("# \\file site.py\n")
- sf.write("# \\brief Site configuration\n")
- sf.write("# \\date " + time.strftime("%Y-%m-%d-%H-%M-GMT", time.gmtime(time.time())) + "\n")
- sf.write("# \\author Jan Boon (Kaetemi)\n")
- sf.write("# Python port of game data build pipeline.\n")
- sf.write("# Site configuration.\n")
- sf.write("# \n")
- sf.write("# NeL - MMORPG Framework \n")
- sf.write("# Copyright (C) 2009-2014 by authors\n")
- sf.write("# \n")
- sf.write("# This program is free software: you can redistribute it and/or modify\n")
- sf.write("# it under the terms of the GNU Affero General Public License as\n")
- sf.write("# published by the Free Software Foundation, either version 3 of the\n")
- sf.write("# License, or (at your option) any later version.\n")
- sf.write("# \n")
- sf.write("# This program is distributed in the hope that it will be useful,\n")
- sf.write("# but WITHOUT ANY WARRANTY; without even the implied warranty of\n")
- sf.write("# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n")
- sf.write("# GNU Affero General Public License for more details.\n")
- sf.write("# \n")
- sf.write("# You should have received a copy of the GNU Affero General Public License\n")
- sf.write("# along with this program. If not, see .\n")
- sf.write("# \n")
- sf.write("\n")
- sf.write("\n")
- sf.write("# *** SITE INSTALLATION ***\n")
- sf.write("\n")
- sf.write("# Use '/' in path name, not '\'\n")
- sf.write("# Don't put '/' at the end of a directory name\n")
- sf.write("\n")
- sf.write("\n")
- sf.write("# Quality option for this site (1 for BEST, 0 for DRAFT)\n")
- sf.write("BuildQuality = " + str(BuildQuality) + "\n")
- sf.write("\n")
- sf.write("RemapLocalFrom = \"" + str(RemapLocalFrom) + "\"\n")
- sf.write("RemapLocalTo = \"" + str(RemapLocalTo) + "\"\n")
- sf.write("\n")
- sf.write("ToolDirectories = " + str(ToolDirectories) + "\n")
- sf.write("ToolSuffix = \"" + str(ToolSuffix) + "\"\n")
- sf.write("\n")
- sf.write("# Build script directory\n")
- sf.write("ScriptDirectory = \"" + str(ScriptDirectory) + "\"\n")
- sf.write("WorkspaceDirectory = \"" + str(WorkspaceDirectory) + "\"\n")
- sf.write("\n")
- sf.write("# Data build directories\n")
- sf.write("DatabaseDirectory = \"" + str(DatabaseDirectory) + "\"\n")
- sf.write("SoundDirectory = \"" + str(SoundDirectory) + "\"\n")
- sf.write("SoundDfnDirectory = \"" + str(SoundDfnDirectory) + "\"\n")
- sf.write("ExportBuildDirectory = \"" + str(ExportBuildDirectory) + "\"\n")
- sf.write("\n")
- sf.write("# Install directories\n")
- sf.write("InstallDirectory = \"" + str(InstallDirectory) + "\"\n")
- sf.write("ClientDevDirectory = \"" + str(ClientDevDirectory) + "\"\n")
- sf.write("ClientDevLiveDirectory = \"" + str(ClientDevLiveDirectory) + "\"\n")
- sf.write("ClientPatchDirectory = \"" + str(ClientPatchDirectory) + "\"\n")
- sf.write("ClientInstallDirectory = \"" + str(ClientInstallDirectory) + "\"\n")
- sf.write("ShardInstallDirectory = \"" + str(ShardInstallDirectory) + "\"\n")
- sf.write("ShardDevDirectory = \"" + str(ShardDevDirectory) + "\"\n")
- sf.write("WorldEditInstallDirectory = \"" + str(WorldEditInstallDirectory) + "\"\n")
- sf.write("\n")
- sf.write("# Utility directories\n")
- sf.write("WorldEditorFilesDirectory = \"" + str(WorldEditorFilesDirectory) + "\"\n")
- sf.write("\n")
- sf.write("# Leveldesign directories\n")
- sf.write("LeveldesignDirectory = \"" + str(LeveldesignDirectory) + "\"\n")
- sf.write("LeveldesignDfnDirectory = \"" + str(LeveldesignDfnDirectory) + "\"\n")
- sf.write("LeveldesignWorldDirectory = \"" + str(LeveldesignWorldDirectory) + "\"\n")
- sf.write("PrimitivesDirectory = \"" + str(PrimitivesDirectory) + "\"\n")
- sf.write("LeveldesignDataCommonDirectory = \"" + str(LeveldesignDataCommonDirectory) + "\"\n")
- sf.write("LeveldesignDataShardDirectory = \"" + str(LeveldesignDataShardDirectory) + "\"\n")
- sf.write("TranslationDirectory = \"" + str(TranslationDirectory) + "\"\n")
- sf.write("\n")
- sf.write("# Misc data directories\n")
- sf.write("GamedevDirectory = \"" + str(GamedevDirectory) + "\"\n")
- sf.write("DataCommonDirectory = \"" + str(DataCommonDirectory) + "\"\n")
- sf.write("DataShardDirectory = \"" + str(DataShardDirectory) + "\"\n")
- sf.write("WindowsExeDllCfgDirectories = " + str(WindowsExeDllCfgDirectories) + "\n")
- sf.write("LinuxServiceExecutableDirectory = \"" + str(LinuxServiceExecutableDirectory) + "\"\n")
- sf.write("LinuxClientExecutableDirectory = \"" + str(LinuxClientExecutableDirectory) + "\"\n")
- sf.write("PatchmanDevDirectory = \"" + str(PatchmanDevDirectory) + "\"\n")
- sf.write("PatchmanCfgAdminDirectory = \"" + str(PatchmanCfgAdminDirectory) + "\"\n")
- sf.write("PatchmanCfgDefaultDirectory = \"" + str(PatchmanCfgDefaultDirectory) + "\"\n")
- sf.write("PatchmanBridgeServerDirectory = \"" + str(PatchmanBridgeServerDirectory) + "\"\n")
- sf.write("\n")
- sf.write("# Sign tool\n")
- sf.write("SignToolExecutable = \"" + str(SignToolExecutable) + "\"\n")
- sf.write("SignToolSha1 = \"" + str(SignToolSha1) + "\"\n")
- sf.write("SignToolTimestamp = \"" + str(SignToolTimestamp) + "\"\n")
- sf.write("\n")
- sf.write("# 3dsMax directives\n")
- sf.write("MaxAvailable = " + str(MaxAvailable) + "\n")
- sf.write("MaxDirectory = \"" + str(MaxDirectory) + "\"\n")
- sf.write("MaxUserDirectory = \"" + str(MaxUserDirectory) + "\"\n")
- sf.write("MaxExecutable = \"" + str(MaxExecutable) + "\"\n")
- sf.write("\n")
- sf.write("\n")
- sf.write("# end of file\n")
- sf.flush()
- sf.close()
- sf = open("configuration/buildsite_local.py", "w")
- sfr = open("configuration/buildsite.py", "r")
- for l in sfr:
- sf.write(l.replace(RemapLocalFrom + '/', RemapLocalTo + '/'))
- sf.flush()
- sfr.close()
- sf.close()
-
-from buildsite_local import *
-
-sys.path.append(WorkspaceDirectory)
-from projects import *
-
-printLog(log, "")
-printLog(log, "-------")
-printLog(log, "--- Run the setup projects")
-printLog(log, "-------")
-printLog(log, time.strftime("%Y-%m-%d %H:%MGMT", time.gmtime(time.time())))
-printLog(log, "")
-# For each project
-for projectName in ProjectsToProcess:
- if ((args.includeproject == None or projectName in args.includeproject) and (args.excludeproject == None or not projectName in args.excludeproject)):
- printLog(log, "PROJECT " + projectName)
- os.putenv("NELBUILDACTIVEPROJECT", os.path.abspath(WorkspaceDirectory + "/" + projectName))
- os.chdir("processes")
- try:
- if not args.includeprocess == None:
- subprocess.call([ "python", "0_setup.py", "--includeprocess" ] + args.includeprocess)
- elif not args.excludeprocess == None:
- subprocess.call([ "python", "0_setup.py", "--excludeprocess" ] + args.excludeprocess)
- else:
- subprocess.call([ "python", "0_setup.py" ])
- except Exception, e:
- printLog(log, "<" + projectName + "> " + str(e))
- os.chdir("..")
- try:
- projectLog = open("processes/log.log", "r")
- projectLogData = projectLog.read()
- projectLog.close()
- log.write(projectLogData)
- except Exception, e:
- printLog(log, "<" + projectName + "> " + str(e))
- else:
- printLog(log, "IGNORE PROJECT " + projectName)
-printLog(log, "")
-
-# Additional directories
-printLog(log, ">>> Setup additional directories <<<")
-mkPath(log, ClientDevDirectory)
-mkPath(log, ClientDevLiveDirectory)
-mkPath(log, ClientPatchDirectory)
-mkPath(log, ClientInstallDirectory)
-
-if not args.noverify:
- printLog(log, "")
- printLog(log, "-------")
- printLog(log, "--- Verify tool paths")
- printLog(log, "-------")
- printLog(log, time.strftime("%Y-%m-%d %H:%MGMT", time.gmtime(time.time())))
- printLog(log, "")
- if MaxAvailable:
- findMax(log, MaxDirectory, MaxExecutable)
- findTool(log, ToolDirectories, TgaToDdsTool, ToolSuffix)
- findTool(log, ToolDirectories, BuildInterfaceTool, ToolSuffix)
- findTool(log, ToolDirectories, ExecTimeoutTool, ToolSuffix)
- findTool(log, ToolDirectories, BuildSmallbankTool, ToolSuffix)
- findTool(log, ToolDirectories, BuildFarbankTool, ToolSuffix)
- findTool(log, ToolDirectories, ZoneDependenciesTool, ToolSuffix)
- findTool(log, ToolDirectories, ZoneWelderTool, ToolSuffix)
- findTool(log, ToolDirectories, ZoneElevationTool, ToolSuffix)
- findTool(log, ToolDirectories, BuildRbankTool, ToolSuffix)
- findTool(log, ToolDirectories, BuildIndoorRbankTool, ToolSuffix)
- findTool(log, ToolDirectories, BuildIgBoxesTool, ToolSuffix)
- findTool(log, ToolDirectories, GetNeighborsTool, ToolSuffix)
- findTool(log, ToolDirectories, ZoneLighterTool, ToolSuffix)
- findTool(log, ToolDirectories, ZoneIgLighterTool, ToolSuffix)
- findTool(log, ToolDirectories, IgLighterTool, ToolSuffix)
- findTool(log, ToolDirectories, AnimBuilderTool, ToolSuffix)
- findTool(log, ToolDirectories, TileEditTool, ToolSuffix)
- # findTool(log, ToolDirectories, BuildImagesetTool, ToolSuffix) # kaetemi stuff, ignore this
- findTool(log, ToolDirectories, MakeSheetIdTool, ToolSuffix)
- # findTool(log, ToolDirectories, BuildSheetsTool, ToolSuffix) # kaetemi stuff, ignore this
- # findTool(log, ToolDirectories, BuildSoundTool, ToolSuffix) # kaetemi stuff, ignore this
- # findTool(log, ToolDirectories, BuildSoundTool, ToolSuffix)
- findTool(log, ToolDirectories, BuildSoundbankTool, ToolSuffix)
- findTool(log, ToolDirectories, BuildSamplebankTool, ToolSuffix)
- findTool(log, ToolDirectories, BuildCoarseMeshTool, ToolSuffix)
- findTool(log, ToolDirectories, LightmapOptimizerTool, ToolSuffix)
- findTool(log, ToolDirectories, BuildClodtexTool, ToolSuffix)
- findTool(log, ToolDirectories, BuildShadowSkinTool, ToolSuffix)
- findTool(log, ToolDirectories, PanoplyMakerTool, ToolSuffix)
- findTool(log, ToolDirectories, HlsBankMakerTool, ToolSuffix)
- findTool(log, ToolDirectories, LandExportTool, ToolSuffix)
- findTool(log, ToolDirectories, PrimExportTool, ToolSuffix)
- findTool(log, ToolDirectories, IgElevationTool, ToolSuffix)
- findTool(log, ToolDirectories, IgAddTool, ToolSuffix)
- findTool(log, ToolDirectories, BuildClodBankTool, ToolSuffix)
- findTool(log, ToolDirectories, SheetsPackerTool, ToolSuffix)
- findTool(log, ToolDirectories, BnpMakeTool, ToolSuffix)
- findTool(log, ToolDirectories, AiBuildWmapTool, ToolSuffix)
- findTool(log, ToolDirectories, TgaCutTool, ToolSuffix)
- findTool(log, ToolDirectories, PatchGenTool, ToolSuffix)
- findTool(log, ToolDirectories, TranslationToolsTool, ToolSuffix)
- findTool(log, ToolDirectories, BuildWorldPackedColTool, ToolSuffix)
- findTool(log, ToolDirectories, R2IslandsTexturesTool, ToolSuffix)
- findTool(log, ToolDirectories, PatchmanServiceTool, ToolSuffix)
-
-log.close()
-if os.path.isfile("0_setup.log"):
- os.remove("0_setup.log")
-shutil.copy("log.log", time.strftime("%Y-%m-%d-%H-%M-GMT", time.gmtime(time.time())) + "_setup.log")
-shutil.move("log.log", "0_setup.log")
diff --git a/code/nel/tools/build_gamedata/translation/make_merge_all.py b/code/nel/tools/build_gamedata/translation/make_merge_all.py
deleted file mode 100644
index 91fc4712b..000000000
--- a/code/nel/tools/build_gamedata/translation/make_merge_all.py
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/python
-#
-# \author Jan Boon (Kaetemi)
-#
-# NeL - MMORPG Framework
-# Copyright (C) 2014 by authors
-#
-# 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 .
-#
-
-import time, sys, os, shutil, subprocess, distutils.dir_util
-sys.path.append("../configuration")
-from scripts import *
-from buildsite import *
-from tools import *
-os.chdir(TranslationDirectory)
-if os.path.isfile("log.log"):
- os.remove("log.log")
-log = open("log.log", "w")
-
-printLog(log, "")
-printLog(log, "-------")
-printLog(log, "--- Make and merge all translations")
-printLog(log, "-------")
-printLog(log, time.strftime("%Y-%m-%d %H:%MGMT", time.gmtime(time.time())))
-printLog(log, "")
-
-
-TranslationTools = findTool(log, ToolDirectories, TranslationToolsTool, ToolSuffix)
-try:
- subprocess.call([ TranslationTools, "make_phrase_diff" ])
- subprocess.call([ TranslationTools, "merge_phrase_diff" ])
- subprocess.call([ TranslationTools, "make_clause_diff" ])
- subprocess.call([ TranslationTools, "merge_clause_diff" ])
- subprocess.call([ TranslationTools, "make_words_diff" ])
- subprocess.call([ TranslationTools, "merge_words_diff" ])
- subprocess.call([ TranslationTools, "make_string_diff" ])
- subprocess.call([ TranslationTools, "merge_string_diff" ])
- subprocess.call([ TranslationTools, "clean_string_diff" ])
- subprocess.call([ TranslationTools, "make_r2_string_diff" ])
- subprocess.call([ TranslationTools, "merge_r2_string_diff" ])
- subprocess.call([ TranslationTools, "clean_r2_string_diff" ])
- subprocess.call([ TranslationTools, "clean_words_diff" ])
- subprocess.call([ TranslationTools, "clean_clause_diff" ])
- subprocess.call([ TranslationTools, "clean_phrase_diff" ])
- subprocess.call([ TranslationTools, "make_worksheet_diff", "bot_names.txt" ])
- subprocess.call([ TranslationTools, "merge_worksheet_diff", "bot_names.txt" ])
-except Exception, e:
- printLog(log, "<" + processName + "> " + str(e))
-printLog(log, "")
-
-
-log.close()
-if os.path.isfile("make_merge_all.log"):
- os.remove("make_merge_all.log")
-shutil.copy("log.log", "make_merge_all_" + time.strftime("%Y-%m-%d-%H-%M-GMT", time.gmtime(time.time())) + ".log")
-shutil.move("log.log", "make_merge_all.log")
-
-raw_input("PRESS ANY KEY TO EXIT")
diff --git a/code/nel/tools/build_gamedata/translation/make_merge_wk.py b/code/nel/tools/build_gamedata/translation/make_merge_wk.py
deleted file mode 100644
index 43c1ac325..000000000
--- a/code/nel/tools/build_gamedata/translation/make_merge_wk.py
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/usr/bin/python
-#
-# \author Jan Boon (Kaetemi)
-#
-# NeL - MMORPG Framework
-# Copyright (C) 2014 by authors
-#
-# 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 .
-#
-
-import time, sys, os, shutil, subprocess, distutils.dir_util
-sys.path.append("../configuration")
-from scripts import *
-from buildsite import *
-from tools import *
-os.chdir(TranslationDirectory)
-if os.path.isfile("log.log"):
- os.remove("log.log")
-log = open("log.log", "w")
-
-printLog(log, "")
-printLog(log, "-------")
-printLog(log, "--- Make, merge and clean work")
-printLog(log, "-------")
-printLog(log, time.strftime("%Y-%m-%d %H:%MGMT", time.gmtime(time.time())))
-printLog(log, "")
-
-
-TranslationTools = findTool(log, ToolDirectories, TranslationToolsTool, ToolSuffix)
-printLog(log, ">>> Override languages.txt <<<")
-if not os.path.isfile("make_merge_wk_languages.txt"):
- shutil.move("languages.txt", "make_merge_wk_languages.txt")
-languagesTxt = open("languages.txt", "w")
-languagesTxt.write("wk\n")
-languagesTxt.close()
-
-
-printLog(log, ">>> Merge diff <<<") # This is necessary, because when we crop lines, we should only do this from untranslated files
-try:
- subprocess.call([ TranslationTools, "merge_phrase_diff" ])
- subprocess.call([ TranslationTools, "merge_clause_diff" ])
- subprocess.call([ TranslationTools, "merge_words_diff" ])
- subprocess.call([ TranslationTools, "merge_string_diff" ])
- subprocess.call([ TranslationTools, "merge_r2_string_diff" ])
- subprocess.call([ TranslationTools, "merge_worksheet_diff", "bot_names.txt" ])
-except Exception, e:
- printLog(log, "<" + processName + "> " + str(e))
-printLog(log, "")
-
-
-printLog(log, ">>> Make diff <<<")
-try:
- subprocess.call([ TranslationTools, "make_phrase_diff" ])
- subprocess.call([ TranslationTools, "make_clause_diff" ])
- subprocess.call([ TranslationTools, "make_words_diff" ])
- subprocess.call([ TranslationTools, "make_string_diff" ])
- subprocess.call([ TranslationTools, "make_r2_string_diff" ])
- subprocess.call([ TranslationTools, "make_worksheet_diff", "bot_names.txt" ])
-except Exception, e:
- printLog(log, "<" + processName + "> " + str(e))
-
-
-printLog(log, ">>> Mark diffs as translated <<<")
-diffFiles = os.listdir("diff")
-for diffFile in diffFiles:
- if "wk_diff_" in diffFile:
- printLog(log, "DIFF " + "diff/" + diffFile)
- subprocess.call([ TranslationTools, "crop_lines", "diff/" + diffFile, "3" ])
-
-#printLog(log, ">>> Clean diff <<<")
-#try:
-# subprocess.call([ TranslationTools, "clean_string_diff" ])
-# subprocess.call([ TranslationTools, "clean_phrase_diff" ])
-# subprocess.call([ TranslationTools, "clean_clause_diff" ])
-# subprocess.call([ TranslationTools, "clean_words_diff" ])
-#except Exception, e:
-# printLog(log, "<" + processName + "> " + str(e))
-#printLog(log, "")
-
-printLog(log, ">>> Merge diff <<<")
-try:
- subprocess.call([ TranslationTools, "merge_phrase_diff" ])
- subprocess.call([ TranslationTools, "merge_clause_diff" ])
- subprocess.call([ TranslationTools, "merge_words_diff" ])
- subprocess.call([ TranslationTools, "merge_string_diff" ])
- subprocess.call([ TranslationTools, "merge_r2_string_diff" ])
- subprocess.call([ TranslationTools, "merge_worksheet_diff", "bot_names.txt" ])
-except Exception, e:
- printLog(log, "<" + processName + "> " + str(e))
-printLog(log, "")
-
-
-printLog(log, ">>> Restore languages.txt <<<")
-os.remove("languages.txt")
-shutil.move("make_merge_wk_languages.txt", "languages.txt")
-
-
-log.close()
-if os.path.isfile("make_merge_wk.log"):
- os.remove("make_merge_wk.log")
-shutil.copy("log.log", "make_merge_wk_" + time.strftime("%Y-%m-%d-%H-%M-GMT", time.gmtime(time.time())) + ".log")
-shutil.move("log.log", "make_merge_wk.log")
-
-raw_input("PRESS ANY KEY TO EXIT")
diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp
deleted file mode 100644
index 055260673..000000000
--- a/code/ryzom/client/src/client_cfg.cpp
+++ /dev/null
@@ -1,2362 +0,0 @@
-// Ryzom - MMORPG Framework
-// Copyright (C) 2010-2019 Winch Gate Property Limited
-//
-// This source file has been modified by the following contributors:
-// Copyright (C) 2010 Robert TIMM (rti)
-// Copyright (C) 2010-2019 Jan BOON (Kaetemi)
-// Copyright (C) 2011-2012 Matt RAYKOWSKI (sfb)
-// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter)
-//
-// 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 "stdpch.h"
-// Misc.
-#include "nel/misc/config_file.h"
-#include "nel/misc/bit_mem_stream.h"
-#include "nel/misc/i18n.h"
-#include "nel/misc/cmd_args.h"
-// Client.
-#include "client_cfg.h"
-#include "entities.h"
-#include "cursor_functions.h"
-#include "debug_client.h"
-#include "view.h" // For the cameraDistance funtion
-#include "user_entity.h"
-#include "misc.h"
-#include "user_agent.h"
-
-// 3D Interface.
-#include "nel/3d/u_driver.h"
-#include "nel/3d/u_scene.h"
-// Game Share.
-#include "game_share/time_weather_season/time_and_season.h"
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef NL_OS_MAC
-#include "app_bundle_utils.h"
-#endif // NL_OS_MAC
-
-///////////
-// MACRO //
-///////////
-//-----------------------------------------------
-/// Macro to read a Bool from the CFG.
-/// variableName : Variable Name to Read and Set.
-//-----------------------------------------------
-#define _READ_BOOL(variableName) \
- /* Read the Variable Value From Script */ \
- varPtr = ClientCfg.ConfigFile.getVarPtr(#variableName); \
- /* Value found, set the Variable */ \
- if(varPtr) \
- ClientCfg.variableName = varPtr->asInt() ? true : false; \
- /* Use the Default Value */ \
- else \
- cfgWarning("CFG: Default value used for '"#variableName"' !!!"); \
-
-//-----------------------------------------------
-/// Macro to read an Int from the CFG.
-/// variableName : Variable Name to Read and Set.
-//-----------------------------------------------
-#define _READ_INT(variableName) \
- /* Read the Variable Value From Script */ \
- varPtr = ClientCfg.ConfigFile.getVarPtr(#variableName); \
- /* Value found, set the Variable */ \
- if(varPtr) \
- ClientCfg.variableName = varPtr->asInt(); \
- /* Use the Default Value */ \
- else \
- cfgWarning("CFG: Default value used for '"#variableName"' !!!"); \
-
-//-----------------------------------------------
-/// Macro to read a Float from the CFG.
-/// variableName : Variable Name to Read and Set.
-//-----------------------------------------------
-#define _READ_FLOAT(variableName) \
- /* Read the Variable Value From Script */ \
- varPtr = ClientCfg.ConfigFile.getVarPtr(#variableName); \
- /* Value found, set the Variable */ \
- if(varPtr) \
- ClientCfg.variableName = varPtr->asFloat(); \
- /* Use the Default Value */ \
- else \
- cfgWarning("CFG: Default value used for '"#variableName"' !!!"); \
-
-//-----------------------------------------------
-/// Macro to read a Float from the CFG.
-/// cfgVariableName : Variable Name to Read.
-/// variableName : Variable Name to Set.
-//-----------------------------------------------
-#define _READ_FLOAT2(cfgVariableName,variableName) \
- /* Read the Variable Value From Script */ \
- varPtr = ClientCfg.ConfigFile.getVarPtr(#cfgVariableName); \
- /* Value found, set the Variable */ \
- if(varPtr) \
- ClientCfg.variableName = varPtr->asFloat(); \
- /* Use the Default Value */ \
- else \
- cfgWarning("CFG: Default value used for '"#cfgVariableName"' !!!"); \
-
-//-----------------------------------------------
-/// Macro to read a Double from the CFG.
-/// variableName : Variable Name to Read and Set.
-//-----------------------------------------------
-#define _READ_DOUBLE(variableName) \
- /* Read the Variable Value From Script */ \
- varPtr = ClientCfg.ConfigFile.getVarPtr(#variableName); \
- /* Value found, set the Variable */ \
- if(varPtr) \
- ClientCfg.variableName = varPtr->asDouble(); \
- /* Use the Default Value */ \
- else \
- cfgWarning("CFG: Default value used for '"#variableName"' !!!"); \
-
-//-----------------------------------------------
-/// Macro to read a String from the CFG.
-/// variableName : Variable Name to Read and Set.
-//-----------------------------------------------
-#define _READ_STRING(variableName) \
- /* Read the Variable Value From Script */ \
- varPtr = ClientCfg.ConfigFile.getVarPtr(#variableName); \
- /* Value found, set the Variable */ \
- if(varPtr) \
- ClientCfg.variableName = varPtr->asString(); \
- /* Use the Default Value */ \
- else \
- cfgWarning("CFG: Default value used for '"#variableName"' !!!"); \
-
-//-----------------------------------------------
-/// Macro to read a CVector from the CFG.
-/// variableName : Variable Name to Read and Set.
-//-----------------------------------------------
-#define _READ_CVECTOR(variableName) \
- /* Read the Variable Value From Script */ \
- varPtr = ClientCfg.ConfigFile.getVarPtr(#variableName); \
- if(varPtr) \
- { \
- /* Check params */ \
- if(varPtr->size()==3) \
- { \
- ClientCfg.variableName.x = varPtr->asFloat(0); \
- ClientCfg.variableName.y = varPtr->asFloat(1); \
- ClientCfg.variableName.z = varPtr->asFloat(2); \
- } \
- else \
- cfgWarning("CFG: Bad params for '"#variableName"' !!!"); \
- } \
- else \
- cfgWarning("CFG: Default value used for '"#variableName"' !!!"); \
-
-
-//-----------------------------------------------
-/// Macro to read an Enum, as int from the CFG.
-/// variableName : Variable Name to Read and Set.
-//-----------------------------------------------
-#define _READ_ENUM_ASINT(type, variableName) \
- /* Read the Variable Value From Script */ \
- varPtr = ClientCfg.ConfigFile.getVarPtr(#variableName); \
- /* Value found, set the Variable */ \
- if(varPtr) \
- ClientCfg.variableName = (type)varPtr->asInt(); \
- /* Use the Default Value */ \
- else \
- cfgWarning("CFG: Default value used for '"#variableName"' !!!"); \
-
-//-----------------------------------------------
-/// Macro to read a String Vector from the CFG.
-/// variableName : Variable Name to Read and Set.
-//-----------------------------------------------
-#define _READ_STRINGVECTOR(variableName) \
- /* Read the Variable Value From Script */ \
- varPtr = ClientCfg.ConfigFile.getVarPtr(#variableName); \
- /* Value found, set the Variable */ \
- if(varPtr) \
- { \
- ClientCfg.variableName.clear (); \
- int iSz = varPtr->size(); \
- ClientCfg.variableName.reserve(iSz); \
- for (int i = 0; i < iSz; i++) \
- ClientCfg.variableName.push_back(varPtr->asString(i)); \
- } \
- /* Use the Default Value */ \
- else \
- cfgWarning("CFG: Default value used for '"#variableName"' !!!"); \
-
-//-----------------------------------------------
-// Macro for the dev version
-//-----------------------------------------------
-
-#if !FINAL_VERSION
-#define READ_BOOL_DEV(variableName) _READ_BOOL(variableName)
-#define READ_INT_DEV(variableName) _READ_INT(variableName)
-#define READ_FLOAT_DEV(variableName) _READ_FLOAT(variableName)
-#define READ_FLOAT2_DEV(cfgVariableName,variableName) _READ_FLOAT2(cfgVariableName,variableName)
-#define READ_DOUBLE_DEV(variableName) _READ_DOUBLE(variableName)
-#define READ_STRING_DEV(variableName) _READ_STRING(variableName)
-#define READ_CVECTOR_DEV(variableName) _READ_CVECTOR(variableName)
-#define READ_ENUM_ASINT_DEV(type, variableName) _READ_ENUM_ASINT(type, variableName)
-#define READ_STRINGVECTOR_DEV(variableName) _READ_STRINGVECTOR(variableName)
-#else // !FINAL_VERSION
-#define READ_BOOL_DEV(variableName)
-#define READ_INT_DEV(variableName)
-#define READ_FLOAT_DEV(variableName)
-#define READ_FLOAT2_DEV(cfgVariableName,variableName)
-#define READ_DOUBLE_DEV(variableName)
-#define READ_STRING_DEV(variableName)
-#define READ_CVECTOR_DEV(variableName)
-#define READ_ENUM_ASINT_DEV(type, variableName)
-#define READ_STRINGVECTOR_DEV(variableName)
-#endif // !FINAL_VERSION
-
-//-----------------------------------------------
-// Macro for the dev & final version
-//-----------------------------------------------
-
-#define READ_BOOL_FV(variableName) _READ_BOOL(variableName)
-#define READ_INT_FV(variableName) _READ_INT(variableName)
-#define READ_FLOAT_FV(variableName) _READ_FLOAT(variableName)
-#define READ_FLOAT2_FV(cfgVariableName,variableName) _READ_FLOAT2(cfgVariableName,variableName)
-#define READ_DOUBLE_FV(variableName) _READ_DOUBLE(variableName)
-#define READ_STRING_FV(variableName) _READ_STRING(variableName)
-#define READ_CVECTOR_FV(variableName) _READ_CVECTOR(variableName)
-#define READ_ENUM_ASINT_FV(type, variableName) _READ_ENUM_ASINT(type, variableName)
-#define READ_STRINGVECTOR_FV(variableName) _READ_STRINGVECTOR(variableName)
-
-///////////
-// USING //
-///////////
-using namespace NLMISC;
-using namespace NL3D;
-
-
-////////////
-// GLOBAL //
-////////////
-CClientConfig LastClientCfg;
-CClientConfig ClientCfg;
-const string ConfigFileName = "client.cfg";
-
-
-////////////
-// EXTERN //
-////////////
-#ifndef RZ_NO_CLIENT
-extern NL3D::UScene *Scene;
-extern NL3D::UDriver *Driver;
-extern CRyzomTime RT;
-extern string Cookie;
-extern string FSAddr;
-#endif
-
-extern NLMISC::CCmdArgs Args;
-
-/////////////
-// METHODS //
-/////////////
-
-// diplay only one time warning "Default values...."
-static bool DisplayCFGWarning= false;
-static void cfgWarning(const char *s)
-{
- if(DisplayCFGWarning)
- nlwarning(s);
-}
-
-//---------------------------------------------------
-// CClientConfig :
-// Constructor.
-//---------------------------------------------------
-CClientConfig::CClientConfig()
-{
- IsInvalidated = false;
-
- TestBrowser = false;
- Light = false; // Default is no client light version
- SaveConfig = false;
-
- PositionX = 0;
- PositionY = 0;
- Frequency = 60;
-
- SkipIntro = false;
- SelectCharacter = -1; // Default is no auto select
- SelectedSlot = 0; // Default is slot 0
-
- Windowed = false; // Default is windowed mode.
- Width = 0; // Default Width for the window (0 = current screen resolution).
- Height = 0; // Default Height for the window (0 = current screen resolution).
- Depth = 32; // Default Bit per Pixel.
- Driver3D = DrvAuto; // Select best driver depending on hardware.
- Contrast = 0.f; // Default Monitor Contrast.
- Luminosity = 0.f; // Default Monitor Luminosity.
- Gamma = 0.f; // Default Monitor Gamma.
-
- InterfaceScale = 1.0f; // Resize UI
- InterfaceScale_min = 0.8f;
- InterfaceScale_max = 2.0f;
- InterfaceScale_step = 0.05;
- BilinearUI = true;
-
- WindowSnapInvert = false;
- WindowSnapDistance = 10;
-
- VREnable = false;
- VRDisplayDevice = "Auto";
- VRDisplayDeviceId = "";
-
- Local = false; // Default is Net Mode.
- FSHost = ""; // Default Host.
-
- TexturesInterface.push_back("texture_interfaces_v3_2x");
- TexturesInterfaceDXTC.push_back("texture_interfaces_dxtc_2x");
-
- TexturesOutGameInterface.push_back("texture_interfaces_v3_outgame_ui");
-
- TexturesLoginInterface.push_back("texture_interfaces_v3_login");
-
- DisplayAccountButtons = true;
- CreateAccountURL = RYZOM_CLIENT_CREATE_ACCOUNT_URL; // "https://open.ryzom.dev/ams/";
- EditAccountURL = RYZOM_CLIENT_EDIT_ACCOUNT_URL; // "https://open.ryzom.dev/ams/";
- ForgetPwdURL = RYZOM_CLIENT_FORGET_PASSWORD_URL; // "https://open.ryzom.dev/ams/";
- Position = CVector(0.f, 0.f, 0.f); // Default Position.
- Heading = CVector(0.f, 1.f, 0.f); // Default Heading.
- EyesHeight = 1.5f; // Default User Eyes Height.
- Walk = 1.66f; // Default Velocity for the Walk.
- Run = 6.0f; // Default Velocity for the Run.
- Fly = 25.0f; // Default Velocity for the Fly.
- DmWalk = 6.0f; // Default Velocity for the Walk in Ring/DM or Ring/Editor.
- DmRun = 20.0f; // Default Velocity for the Run in Ring/DM or Ring/Editor.
-
- FlyAccel = 1000.f; // Default Acceleration for the fly, in m.s-2
-
- AllowDebugCommands = false; // Add debug commands at startup
-
- ForceDeltaTime = 0; // Default ForceDeltaTime, disabled by default
-
- HardwareCursor = true; // Default HardwareCursor
- HardwareCursorScale = 0.85f;
- CursorSpeed = 1.f; // Default CursorSpeed
- CursorAcceleration = 0; // Default CursorAcceleration
- FreeLookSpeed = 0.001f; // Default FreeLookSpeed
- FreeLookAcceleration = 0; // Default FreeLookAcceleration
- FreeLookSmoothingPeriod = 0.f; // when in absolute mode, free look factor is used instead of speed, the mouse gives the absolute angle
- FreeLookInverted = false;
- FreeLookTablet = false; // Mouse reports absolute coordinates, so avoid mouse recentering
- AutomaticCamera = true;
- DblClickMode = true; // when in dbl click mode, a double click is needed to execute default contextual action
- AutoEquipTool = true; // when true player will auto-equip last used weapon or forage tool when doing an action
-
- BGColor = CRGBA(100,100,255); // Default Background Color.
- LandscapeTileNear = 50.0f; // Default Landscape Tile Near.
- LandscapeThreshold = 1000.0f; // Default Landscape Threshold.
- Vision = 500.f; // Player vision.
- Vision_min = 200.f; // Player vision min.
- Vision_max = 800.f; // Player vision max.
- SkinNbMaxPoly = 40000;
- FxNbMaxPoly = 10000;
- Cloud = true;
- CloudQuality = 160.0f;
- CloudUpdate = 1;
- NbMaxSkeletonNotCLod= 20;
- CharacterFarClip = 200.f;
- ScreenAspectRatio = 0.f; // Default commmon Screen Aspect Ratio (no relation with the resolution) - 0.f = auto
- FoV = 75.f; // Default value for the FoV.
- ForceDXTC = false; // Default is no DXTC Compression.
- AnisotropicFilter = 0; // Default is disabled (-1 = maximum value, 0 = disabled, 1+ = enabled)
- DivideTextureSizeBy2= false; // Divide texture by 2
- DisableVtxProgram = false; // Disable Hardware Vertex Program.
- DisableVtxAGP = false; // Disable Hardware Vertex AGP.
- DisableTextureShdr = false; // Disable Hardware Texture Shader.
- MicroVeget = true; // Default is with MicroVeget.
- MicroVegetDensity = 100.0f;
- HDEntityTexture = false;
- HDTextureInstalled = false;
- Fog = true; // Fog is on by default
- WaitVBL = false;
- VideoMemory = 0;
-
- FXAA = true;
-
- Bloom = true;
- SquareBloom = true;
- DensityBloom = 255.f;
-
- GlobalWindPower = 0.10f; // Default is 0.25
- GlobalWindDirection = CVector(1,0,0); // Default direction is X>0
-
- MovieShooterMemory = 0; // MovieShooter disabled
- MovieShooterFramePeriod = 0.040f; // default is 25 fps
- MovieShooterBlend = false;
- MovieShooterFrameSkip = 0; // default not skip frame
- MovieShooterPrefix = "shot_";
-
- CameraRecorderPrefix = "cam_rec";
- CameraRecorderBlend = true;
-
- ScreenShotWidth = 0;
- ScreenShotHeight = 0;
- ScreenShotFullDetail = true;
- ScreenShotZBuffer = false;
-
- MaxNumberOfTimedFXInstances = 20;
- SelectionFX = "sfx_selection_mouseover.ps";
- MouseOverFX = "sfx_selection_mouseover.ps";
- SelectionFXSize = 0.8f;
-
-#if RZ_USE_PATCH
- PatchWanted = true;
-#else
- PatchWanted = false;
-#endif
-
- PatchUrl.clear();
- PatchletUrl.clear();
- PatchVersion.clear();
-
- WebIgMainDomain = RYZOM_WEBIG_MAIN_URL; // https://open.ryzom.dev/"
- WebIgTrustedDomains.push_back(RYZOM_WEBIG_TRUSTED_DOMAIN); // open.ryzom.dev
- WebIgNotifInterval = 10; // time in minutes
-
- CurlMaxConnections = 5;
- CurlCABundle.clear();
-
- RingReleaseNotePath = WebIgMainDomain + "/app_releasenotes/index.php";
- ReleaseNotePath = WebIgMainDomain + "/app_releasenotes/index.php";
-
-
- ///////////////
- // ANIMATION //
- // With a bigger angle, rotation is animated.
- AnimatedAngleThreshold = 25.0; //
- BlendFrameNumber = 5; //
- DestThreshold = 0.01; // Destination Threshold
- PositionLimiterRadius = 0.1;
- SignificantDist = 0.0001; // Significant Distance
- ///////////
- // SOUND //
- SoundOn = true; // Default is with sound.
- DriverSound = SoundDrvAuto;
- SoundForceSoftwareBuffer = true;
- SoundOutGameMusic = "main menu loop.ogg";
- SoundSFXVolume = 1.f;
- SoundGameMusicVolume = 1.f;
- SoundTPFade = 500;
- EnableBackgroundMusicTimeConstraint = true;
-
- SoundPackedSheetPath= "data/sound/"; // Default path for sound packed sheets
- SampleBankDir = "data/sound/samplebanks"; // Default path for samples
- UserEntitySoundLevel = 0.5f; // Default volume for sound in 1st person
- UseEax = true; // Default to use EAX;
- UseADPCM = false; // Defualt to PCM sample, NO ADPCM
- MaxTrack = 32; // DEfault to 32 track
-
- ColorShout = CRGBA(150,0,0,255); // Default Shout color.
- ColorTalk = CRGBA(255,255,255,255); // Default Talk color.
-
- StreamedPackagePath = "stream";
-
- // MP3 player
- MediaPlayerDirectory = "music";
- MediaPlayerAutoPlay = false;
-
-// PreDataPath.push_back("data/gamedev/language/"); // Default Path for the language data
-
-// DataPath.push_back("data/"); // Default Path for the Data.
-// DataPath.push_back("data_leveldesign/"); // Default Path for the Level Design Directory.
-// DataPath.push_back("data_common/"); // Default Path for the Level Design Directory.
-
- DataPathNoRecurse.push_back("data_leveldesign/leveldesign/Game_Elem");
-
- UpdatePackedSheetPath.push_back("data_leveldesign");
-
- UpdatePackedSheet = false; // Update packed sheet if needed
-
- EndScreenTimeOut = 0.f; // Default time out for the screen at the end of the application.
- Loading_BG = "loading_bg.tga"; // Default name for the loading background file.
- LoadingFreeTrial_BG = "loading_free_trial_bg.tga"; // Default name for the loading background file in FreeTrial mode.
- Launch_BG = "launcher_bg.tga"; // Default name for the launch background file.
- TeleportKami_BG = "teleport_kami_bg.tga";
- TeleportKaravan_BG = "teleport_caravan_bg.tga";
- Elevator_BG = "elevator_bg.tga"; // Default name for the loading background file.
- ResurectKami_BG = "resurect_kami_bg.tga";
- ResurectKaravan_BG = "resurect_caravane_bg.tga";
- End_BG = "end_bg.tga"; // Default name for the last background file.
- IntroNevrax_BG = "launcher_nevrax.tga";
- IntroNVidia_BG = "launcher_nvidia.tga";
-
- TipsY = 0.07f;
- TeleportInfoY = 0.23f;
-
- SceneName = "";
- IdFilePath = "sheet_id.bin";
- PacsPrimDir.push_back("data/3d/");
-
- Shadows = true; // Draw Shadows by default.
- ShadowsClipFar = 10.f; // Shadows are disabled after this distance.
- ShadowsLodDist = 3.f; // Shadows draw with just 1 part after this distance.
- ShadowZDirClampLandscape = -0.5f; // On landscape, allow a minimum Phi angle of -30 degrees
- ShadowZDirClampInterior = -0.86f; // On Interior, allow a minimum Phi angle of -60 degrees
- ShadowZDirClampSmoothSpeed = 0.5f;
- ShadowMaxDepthLandscape = 8.f;
- ShadowMaxDepthInterior = 2.f;
- ShadowMaxDepthSmoothSpeed = 6.f;
-
-
- Names = false; // Don't draw Names by default.
-
- Sleep = -1; // Default : client does not sleep.
- ProcessPriority = 0; // Default : NORMAL
- CPUMask = 0; // Default : auto detection
- ShowPath = false; // Default : do not display the path.
- DrawBoxes = false; // Default : Do not draw the selection.
-
- UserSheet = "fyros.race_stats"; // Default sheet used.
- Sex = GSGENDER::male; // Default : male.
-
- PrimitiveHeightAddition = 2.f; // Default : 2.f
-
- AttackDist = 0.5f;
- RyzomDay = 0;
- RyzomTime = 0.0f;
-
- ManualWeatherSetup = false;
-
- ChaseReactionTime = 0.4f; // Reaction time before chasing someone.
-
- TimeToAdjustCamera = 1000.0;
- ChangeDirAngle = 1.70f; // Default Angle.
-
- GuildSymbolSize = 0.3f; // Default Guild Symbol Size.
- SelectionDist = 150.f; // Default dist in meter.
- SelectionOutBBoxWeight = 16.f; // Default factor
- LootDist = 4.f; // Default loot/harvest distance (in meter).
- SpaceSelectionDist = 50.f;
- SpaceSelectionMaxCycle = 1;
-
- ForceLanguage = false;
- LanguageCode = "en"; // Default to english
- DebugStringManager = false; // Default to no debug
-
- // TUNING
- WaterOffset = -1.085f;
- FyrosWaterOffset = -1.0f;
- MatisWaterOffset = -1.08f;
- TrykerWaterOffset = -0.88f;
- ZoraiWaterOffset = -1.25f;
- WaterOffsetCreature = -1.6f;
- TimeToRemoveCol = 1000;
- MoveToTimeToStopStall = 500;
- TPVMinPitch = -1.5f;
- TPVMaxPitch = 1.5f;
- MaxHeadTargetDist = 30.0f;
- DeadFXName = "misc_dead.ps";
- ImpactFXName = "impact.ps";
- SkillUpFXName = "misc_levelup.ps";
- MinDistFactor = 0.5;
- NameScale = 1.0f; // Default Scale to display Names.
- NamePos = 0.02f;
- NameFontSize = 20;
- MaxNameDist = 50.0f;
- ConstNameSizeDist = 20.0f;
- StaticNameHeight = true;
- BarsHeight = 0.002f;
- BarsWidth = 0.05f;
- FightAreaSize = 1.5;
- BubbleZBias = -3.f;
- ForageInterfaceZBias= -10.f;
- FyrosScale = 1.0f;
- MatisScale = 1.08f;
- TrykerScale = 0.88f;
- ZoraiScale = 1.25f;
- EnableRacialAnimation = true;
-
- // OPTIONS
- RunAtTheBeginning = true;
- SelectWithRClick = false; // Default right click cannot select.
- RotKeySpeedMax = 3.0f;
- RotKeySpeedMin = 1.0f;
- RotAccel = 0.001f;
- PutBackItems = false;
- ShowNameUnderCursor = true;
- ShowNameSelected = true;
- ShowNameBelowDistanceSqr = 20.f * 20.f;
- ForceIndoorFPV = false;
- FollowOnAtk = true;
- AtkOnSelect = false;
- TransparentUnderCursor = false;
- ItemGroupAllowGuild = false;
- // PREFERENCES
- FPV = false;
- CameraHeight = 2.5f;
- CameraDistance = 3.0f;
- CameraDistStep = 1.0f;
- CameraDistMin = 1.0f;
- CameraDistMax = 100.0f;
- DmCameraDistMax = 25.0f;
- CameraAccel = 0.2f;
- CameraSpeedMin = 0.2f;
- CameraSpeedMax = 1.0f;
- CameraResetSpeed = 2.0f;
-
- MaxMapScale = 2.0f;
- R2EDMaxMapScale = 8.0f;
-
- TargetChangeCompass = true;
-
- // VERBOSES
- VerboseVP = false;
- VerboseAnimUser = false;
- VerboseAnimSelection = false;
- VerboseAllTraffic = false;
-
- // DEBUG
- DisplayMissingAnimFile = false;
- DefaultEntity = "ccafb1.creature";
- RestrainPI = true;
- DumpVSIndex = false;
- HelpFontSize = 12;
- HelpFontColor = CRGBA(255,255,255);
- HelpLineStep = 0.025f;
- DebugFontSize = 16;
- DebugFontColor = CRGBA(250, 250, 250);
- DebugLineStep = 0.02f;
- HeadOffset = CVector(0.f, 0.f, 0.f);
- Check = false;
- BlendForward = true;
- //
- FPExceptions = false; // Disable Floating Point Exceptions.
- DisplayWeapons = false; // Do not dusplay weapons in first person.
- NeedComputeVS = false; // Do not need to compute Visual Slots.
- //
- GroundFXMaxDist = 40.f;
- GroundFXMaxNB = 10;
- GroundFXCacheSize = 10;
- //
- AutoReloadFiles = false;
- BlendShapePatched = true;
- ExtendedCommands = false;
-
- WaterEnvMapUpdateTime = 1.f;
-
- NumFrameForProfile = 0;
- SimulateServerTick = false;
- TimerMode= 0;
-
- KlientChatPort= "";
-
- PreCacheShapes = true;
- ResetShapeBankOnRetCharSelect = false;
- LandscapeEnabled = true;
- VillagesEnabled = true;
- EAMEnabled = true;
- CacheUIParsing = false;
- MicroLifeEnabled = true;
-
- SkipEULA = false;
-
- StageLCTUsage= StageUsePosOnlyLCT;
-
- SimulatePacketLossRatio= 0;
-
- CheckMemoryEveryNFrame= -1;
- LogMemoryAllocation=false;
- LogMemoryAllocationSize=8;
-
- DamageShieldEnabled = false;
-
- LevelDesignEnabled = false;
-
- R2Mode = true;
- R2EDEnabled = false;
- R2EDExtendedDebug = false;
- R2EDVerboseParseTime = false;
- R2EDDontReparseUnchangedUIFiles = false;
- R2EDLightPalette = false;
- R2EDAutoSaveWait = 60*5;
- R2EDAutoSaveSlot = 9;
- R2EDMustVerifyRingAccessWhileLoadingAnimation = false;
- R2EDUseVerboseRingAccess = false;
- R2EDDssNetwork = 3;
-
- DamageShieldEnabled = false;
-
- AllowDebugLua = false;
- DisplayLuaDebugInfo = false;
- BeepWhenLaunched = false;
-
-
-
- LoadingStringCount = 0;
-
- LuaDebugInfoGotoButtonEnabled = false;
-
- FogDistAndDepthLookupBias = 0.f;
-
- R2EDLoadDynamicFeatures = 0;
-
- CheckR2ScenarioMD5 = true;
-
- DisplayTPReason = false;
-
- //TPCancelButtonX = 988;
- //TPCancelButtonY = 138;
- //TPQuitButtonX = 8;
- //TPQuitButtonY = 138;
- TPButtonW = 32;
- TPButtonH = 32;
-
- //SAVE
- ScenarioSavePath = "./my_scenarios/";
-
- R2EDClippedEntityBlendTime = 0.18f;
-
- BackgroundDownloader = false;
-
-}// CClientConfig //
-
-
-//---------------------------------------------------
-// load :
-// Load the client config file.
-//---------------------------------------------------
-void CClientConfig::setValuesOnFileChange()
-{
- // ClientCfg.ConfigFile.print (InfoLog);
-
- // display an info only when the file change
- nlinfo ("reloading the config file!");
-
- setValues();
-}
-
-//---------------------------------------------------
-// load :
-// Load the client config file.
-//---------------------------------------------------
-void CClientConfig::setValues()
-{
- CConfigFile::CVar *varPtr = 0;
- static bool firstTimeSetValues= true;
-
- //////////////////////
- // INTERFACE CONFIG //
- // input files
- READ_STRING_FV(XMLInputFile)
-
-
- READ_BOOL_FV(SkipIntro);
- READ_BOOL_DEV(SkipEULA);
- READ_INT_DEV(SelectCharacter);
-
- READ_INT_FV(SelectedSlot);
- if( ClientCfg.SelectedSlot>4 )
- {
- ClientCfg.SelectedSlot = 0;
- }
-
- // interface textures login menus
- READ_STRINGVECTOR_FV(TexturesLoginInterface);
- READ_STRINGVECTOR_FV(TexturesLoginInterfaceDXTC);
-
- // interface textures outgame menus
- READ_STRINGVECTOR_FV(TexturesOutGameInterface);
- READ_STRINGVECTOR_FV(TexturesOutGameInterfaceDXTC);
-
- // interface textures ingame and r2
- //READ_STRINGVECTOR_FV(TexturesInterface);
- //READ_STRINGVECTOR_FV(TexturesInterfaceDXTC);
-
- // interface files login menus
- READ_STRINGVECTOR_FV(XMLLoginInterfaceFiles);
-
- // interface files outgame menus
- READ_STRINGVECTOR_FV(XMLOutGameInterfaceFiles);
-
- // interface files
- READ_STRINGVECTOR_FV(XMLInterfaceFiles);
-
- // r2ed interfaces
- READ_STRINGVECTOR_FV(XMLR2EDInterfaceFiles);
-
- // logos
- READ_STRINGVECTOR_FV(Logos);
-
- // browser test mode
- READ_BOOL_DEV(TestBrowser);
- READ_STRING_DEV(TestBrowserUrl);
-
- // ClientLight
-#if !FINAL_VERSION
- varPtr = ClientCfg.ConfigFile.getVarPtr ("ClientLight");
- if (varPtr)
- ClientCfg.Light = varPtr->asInt() ? true : false;
-#endif // !FINAL_VERSION
-
-
- READ_BOOL_DEV(LandscapeEnabled)
- READ_BOOL_DEV(VillagesEnabled)
- READ_BOOL_DEV(EAMEnabled)
- READ_BOOL_DEV(CacheUIParsing)
- READ_BOOL_DEV(MicroLifeEnabled)
-
- READ_BOOL_DEV(LevelDesignEnabled)
-
- ///////////////////
- // WINDOW CONFIG //
- // Mode.
-
- // SaveConfig
- READ_BOOL_FV(SaveConfig)
-
- // Window Positon
- READ_INT_FV(PositionX)
- READ_INT_FV(PositionY)
-
- // Window frequency
- READ_INT_FV(Frequency)
-
- CConfigFile::CVar *pcvFullScreen = ClientCfg.ConfigFile.getVarPtr("FullScreen");
- if( pcvFullScreen )
- {
- ClientCfg.Windowed = pcvFullScreen->asInt() ? false : true;
- }
- else
- cfgWarning("Default value used for 'Fullscreen'");
- // Width
- READ_INT_FV(Width)
- // Height
- READ_INT_FV(Height)
- // Depth : Bit Per Pixel
- READ_INT_FV(Depth)
- // Contrast
- READ_FLOAT_FV(Contrast)
- // Luminosity
- READ_FLOAT_FV(Luminosity)
- // Gamma
- READ_FLOAT_FV(Gamma)
- // UI scaling
- READ_FLOAT_FV(InterfaceScale);
- READ_FLOAT_FV(InterfaceScale_min);
- READ_FLOAT_FV(InterfaceScale_max);
- READ_FLOAT_FV(InterfaceScale_step);
- clamp(ClientCfg.InterfaceScale, ClientCfg.InterfaceScale_min, ClientCfg.InterfaceScale_max);
- READ_BOOL_FV(BilinearUI);
- READ_BOOL_FV(WindowSnapInvert);
- READ_INT_FV(WindowSnapDistance);
- // 3D Driver
- varPtr = ClientCfg.ConfigFile.getVarPtr ("Driver3D");
- if (varPtr)
- {
- if (nlstricmp(varPtr->asString(), "Auto") == 0 || nlstricmp(varPtr->asString(), "0") == 0) ClientCfg.Driver3D = CClientConfig::DrvAuto;
- else if (nlstricmp(varPtr->asString(), "OpenGL") == 0 || nlstricmp(varPtr->asString(), "1") == 0) ClientCfg.Driver3D = CClientConfig::OpenGL;
- else if (nlstricmp(varPtr->asString(), "Direct3D") == 0 || nlstricmp(varPtr->asString(), "2") == 0) ClientCfg.Driver3D = CClientConfig::Direct3D;
- else if (nlstricmp(varPtr->asString(), "OpenGLES") == 0 || nlstricmp(varPtr->asString(), "3") == 0) ClientCfg.Driver3D = CClientConfig::OpenGLES;
- }
- else
- cfgWarning ("Default value used for 'Driver3D' !!!");
-
- READ_BOOL_FV(VREnable)
- READ_STRING_FV(VRDisplayDevice)
- READ_STRING_FV(VRDisplayDeviceId)
-
- ////////////
- // INPUTS //
- READ_BOOL_FV(HardwareCursor)
- READ_FLOAT_FV(HardwareCursorScale)
- READ_FLOAT_FV(CursorSpeed)
- READ_INT_FV(CursorAcceleration)
- READ_FLOAT_FV(FreeLookSpeed)
- READ_INT_FV(FreeLookAcceleration)
- READ_FLOAT_FV(FreeLookSmoothingPeriod)
- READ_BOOL_FV(FreeLookInverted)
- READ_BOOL_FV(FreeLookTablet)
- READ_BOOL_FV(AutomaticCamera)
- READ_BOOL_FV(DblClickMode)
- READ_BOOL_FV(AutoEquipTool)
-
- /////////
- // NET //
-#if !FINAL_VERSION
- // Local : local mode or network mode
- READ_BOOL_DEV(Local)
-#endif // FINAL_VERSION
- // FSHost
- READ_STRING_FV(FSHost)
-
- READ_BOOL_DEV(DisplayAccountButtons)
-
-
- READ_STRING_FV(CreateAccountURL)
- READ_STRING_FV(EditAccountURL)
- READ_STRING_FV(ForgetPwdURL)
-
- READ_STRING_DEV(BetaAccountURL)
- READ_STRING_DEV(FreeTrialURL)
-
- // defined in client_default.cfg
- READ_STRING_FV(LoginSupportURL)
-
- // read NamingPolicyURL from client_default.cfg
- //READ_STRING_FV(NamingPolicyURL)
-
- std::string languageCo = "wk";
- CConfigFile::CVar *languageCodeVarPtr = ClientCfg.ConfigFile.getVarPtr("LanguageCode");
-
- if (languageCodeVarPtr)
- {
- languageCo = languageCodeVarPtr->asString();
- }
-
- CConfigFile::CVar *policyurl = ClientCfg.ConfigFile.getVarPtr("NamingPolicyURL");
-
- if (policyurl)
- {
- for (uint i = 0; i < policyurl->size(); ++i)
- {
- std::string entry = policyurl->asString(i);
- if (entry.size() >= languageCo.size())
- {
- if (nlstricmp(entry.substr(0, languageCo.size()), languageCo) == 0)
- {
- std::string::size_type pos = entry.find("=");
-
- if (pos != std::string::npos)
- {
- ClientCfg.NamingPolicyURL = entry.substr(pos + 1);
- }
- }
- }
- }
- }
-
- // read NamingPolicyURL from client_default.cfg
- //READ_STRING_FV(ConditionsTermsURL)
- CConfigFile::CVar *coturl = ClientCfg.ConfigFile.getVarPtr("ConditionsTermsURL");
-
- if (coturl)
- {
- for (uint i = 0; i < coturl->size(); ++i)
- {
- std::string entry = coturl->asString(i);
-
- if (entry.size() >= languageCo.size())
- {
- if (nlstricmp(entry.substr(0, languageCo.size()), languageCo) == 0)
- {
- std::string::size_type pos = entry.find("=");
-
- if (pos != std::string::npos)
- {
- ClientCfg.ConditionsTermsURL = entry.substr(pos + 1);
- }
- }
- }
- }
- }
-
-
-#ifndef RZ_NO_CLIENT
- // if cookie is not empty, it means that the client was launch
- // by the nel_launcher, so it can't be local
- if(!Cookie.empty())
- {
- nlassert (!FSAddr.empty());
- ClientCfg.Local = false;
- }
- else
- {
- nlassert (FSAddr.empty());
- }
-#endif
-
- /////////////////
- // USER ENTITY //
- READ_CVECTOR_DEV(Position)
- READ_CVECTOR_DEV(Heading)
- // EyesHeight
- READ_FLOAT_DEV(EyesHeight)
-
- // Walk
- READ_FLOAT_DEV(Walk)
- // Run
- READ_FLOAT_DEV(Run)
-
- //When editing or Dm ing a session in ring mode the player move quicker
- // DM Walk
- READ_FLOAT_DEV(DmWalk)
- // DM Run
- READ_FLOAT_DEV(DmRun)
-
-
-
- // Fly
- READ_FLOAT_DEV(Fly)
- READ_FLOAT_DEV(FlyAccel)
-
- READ_BOOL_FV(AllowDebugCommands)
-
- // ForceDeltaTime
- READ_INT_DEV(ForceDeltaTime)
-
- ////////////
- // RENDER //
- // Background Color
-#if !FINAL_VERSION
- CConfigFile::CVar *pcvBackColor = ClientCfg.ConfigFile.getVarPtr("Background");
- if( pcvBackColor && (pcvBackColor->size()==3) )
- {
- ClientCfg.BGColor.R = pcvBackColor->asInt(0);
- ClientCfg.BGColor.G = pcvBackColor->asInt(1);
- ClientCfg.BGColor.B = pcvBackColor->asInt(2);
- ClientCfg.BGColor.A = 255;
- }
- else
- cfgWarning("Default value used for 'Background'");
-#endif // !FINAL_VERSION
- // LandscapeTileNear
- READ_FLOAT_FV(LandscapeTileNear)
- // LandscapeThreshold
- READ_FLOAT_FV(LandscapeThreshold)
- // to be backward compatible, suppose a value<1 is for the old System!!! => invert it!
- if( ClientCfg.LandscapeThreshold<1)
- {
- ClientCfg.LandscapeThreshold= 1.f/ ClientCfg.LandscapeThreshold;
- // must re-write in the CFG database, to be ok with the in-game configurator
- varPtr = ClientCfg.ConfigFile.getVarPtr("LandscapeThreshold");
- if(varPtr)
- varPtr->forceAsDouble(ClientCfg.LandscapeThreshold);
- }
- // Vision
- READ_FLOAT_FV(Vision)
- READ_FLOAT_FV(Vision_min)
- READ_FLOAT_FV(Vision_max)
- // SkinNbMaxPoly
- READ_INT_FV(SkinNbMaxPoly)
- // FxNbMaxPoly
- READ_INT_FV(FxNbMaxPoly)
- READ_BOOL_FV(Cloud)
- READ_FLOAT_FV(CloudQuality)
- READ_INT_FV(CloudUpdate)
- // NbMaxSkeletonNotCLod
- READ_INT_FV(NbMaxSkeletonNotCLod)
- // CharacterFarClip
- READ_FLOAT_FV(CharacterFarClip)
-
- // Bloom
- READ_BOOL_FV(Bloom)
- READ_BOOL_FV(SquareBloom)
- READ_FLOAT_FV(DensityBloom)
-
- // FXAA
- READ_BOOL_FV(FXAA)
-
- // ScreenAspectRatio.
- READ_FLOAT_FV(ScreenAspectRatio)
- // FoV.
- READ_FLOAT_FV(FoV)
- // ForceDXTC
- READ_BOOL_FV(ForceDXTC)
- // AnisotropicFilter
- READ_INT_FV(AnisotropicFilter)
- // DivideTextureSizeBy2
- READ_BOOL_FV(DivideTextureSizeBy2)
- // DisableVtxProgram
- READ_BOOL_FV(DisableVtxProgram)
- // DisableVtxAGP
- READ_BOOL_FV(DisableVtxAGP)
- // DisableTextureShdr
- READ_BOOL_FV(DisableTextureShdr)
- // MicroVeget
- READ_BOOL_FV(MicroVeget)
- // MicroVeget Density
- READ_FLOAT_FV(MicroVegetDensity)
- // GlobalWindPower: Global Wind Power
- READ_FLOAT_DEV(GlobalWindPower)
- // Global Wind Direction
- READ_CVECTOR_DEV(GlobalWindDirection)
- // HDEntityTexture
- READ_BOOL_FV(HDEntityTexture)
- // HDTextureInstalled
- READ_BOOL_FV(HDTextureInstalled)
-
- // Fog
- READ_BOOL_DEV(Fog)
-
- // WaitVBL
- READ_BOOL_FV(WaitVBL)
- // VideoMemory
- READ_INT_FV(VideoMemory);
-
- READ_INT_DEV(TimerMode)
-
- // MovieShooterMemory
- CConfigFile::CVar *pcv = ClientCfg.ConfigFile.getVarPtr("MovieShooterMemory");
- if( pcv )
- {
- ClientCfg.MovieShooterMemory = pcv->asInt();
- // Transform to octet
- ClientCfg.MovieShooterMemory *= 1024*1024;
- }
- else
- cfgWarning("'MovieShooterMemory' not found => MovieShooter Disabled");
- // MovieShooterPath
- READ_STRING_FV(MovieShooterPath)
- // MovieShooterFramePeriod
- READ_FLOAT_FV(MovieShooterFramePeriod)
- // MovieShooterBlend
- READ_BOOL_FV(MovieShooterBlend)
- // MovieShooterFrameSkip
- READ_INT_FV(MovieShooterFrameSkip)
-
- // Camera Recorder
- READ_STRING_FV(CameraRecorderPath)
- READ_STRING_FV(CameraRecorderPrefix)
- READ_BOOL_FV(CameraRecorderBlend)
-
- // Screenshot
- READ_INT_FV(ScreenShotWidth)
- READ_INT_FV(ScreenShotHeight)
- READ_BOOL_FV(ScreenShotFullDetail)
- READ_BOOL_FV(ScreenShotZBuffer)
-
- /////////////////////////
- // NEW PATCHING SYSTEM //
- READ_BOOL_FV(PatchWanted)
-
-#ifdef RZ_USE_CUSTOM_PATCH_SERVER
- READ_STRING_FV(PatchUrl)
- READ_STRING_FV(PatchVersion)
- READ_STRING_FV(RingReleaseNotePath)
- READ_STRING_FV(ReleaseNotePath)
-#else
- READ_STRING_DEV(PatchUrl)
- READ_STRING_DEV(PatchVersion)
- READ_STRING_DEV(RingReleaseNotePath)
- READ_STRING_DEV(ReleaseNotePath)
-#endif
-
- /////////////////////////
- // NEW PATCHLET SYSTEM //
- READ_STRING_FV(PatchletUrl)
-
- ///////////
- // WEBIG //
- READ_STRING_FV(WebIgMainDomain);
- if (ClientCfg.WebIgMainDomain.find("http://") == std::string::npos
- || ClientCfg.WebIgMainDomain.find("https://") == std::string::npos)
- ClientCfg.WebIgMainDomain = "http://" + ClientCfg.WebIgMainDomain;
- READ_STRINGVECTOR_FV(WebIgTrustedDomains);
- READ_INT_FV(WebIgNotifInterval);
- READ_INT_FV(CurlMaxConnections);
- if (ClientCfg.CurlMaxConnections < 0)
- ClientCfg.CurlMaxConnections = 2;
-
- READ_STRING_FV(CurlCABundle);
- if (!ClientCfg.CurlCABundle.empty() && ClientCfg.CurlCABundle[0] == '%') // Path is relative to client_default.cfg path (used by ryzom patch)
- {
- string defaultConfigFileName;
- if (ClientCfg.getDefaultConfigLocation(defaultConfigFileName))
- ClientCfg.CurlCABundle = CFile::getPath(defaultConfigFileName)+ClientCfg.CurlCABundle.substr(1);
- }
-
- ///////////////
- // ANIMATION //
- // AnimatedAngleThreshold
- READ_DOUBLE_DEV(AnimatedAngleThreshold)
- // BlendFrameNumber
- READ_INT_DEV(BlendFrameNumber)
- // DestThreshold
- READ_DOUBLE_DEV(DestThreshold)
- // PositionLimiterRadius
- READ_DOUBLE_DEV(PositionLimiterRadius)
- // SignificantDist
- READ_DOUBLE_DEV(SignificantDist)
- // Stage LCT usage
- READ_ENUM_ASINT_DEV(TStageLCTUsage, StageLCTUsage)
-
- ////////////
- // TUNING //
- // Water Offset
- READ_FLOAT_DEV(WaterOffset)
-
-#if !FINAL_VERSION
- READ_FLOAT_DEV(FyrosWaterOffset)
- READ_FLOAT_DEV(MatisWaterOffset)
- READ_FLOAT_DEV(TrykerWaterOffset)
- READ_FLOAT_DEV(ZoraiWaterOffset)
-#endif // FINAL_VERSION
-
- // Water Offset for creature
- READ_FLOAT_DEV(WaterOffsetCreature)
- // TimeToRemoveCol
- READ_INT_DEV(TimeToRemoveCol)
- // MoveToTimeToStopStall
- READ_INT_DEV(MoveToTimeToStopStall)
- // TimeToAdjustCamera
- READ_DOUBLE_DEV(TimeToAdjustCamera)
- // ChangeDirAngle
- READ_DOUBLE_DEV(ChangeDirAngle)
- // GuildSymbolSize
- READ_FLOAT_DEV(GuildSymbolSize)
- // SelectionDist
- READ_FLOAT_DEV(SelectionDist)
- // SelectionOutBBoxWeight
- READ_FLOAT_DEV(SelectionOutBBoxWeight)
- // LootDist
- READ_FLOAT_DEV(LootDist)
- // SpaceSelectionDist
- READ_FLOAT_DEV(SpaceSelectionDist)
- // SpaceSelectionMaxCycle
- READ_INT_DEV(SpaceSelectionMaxCycle)
- // Third Person View Min Pitch.
- READ_FLOAT_DEV(TPVMinPitch)
- // Third Person View Max Pitch.
- READ_FLOAT_DEV(TPVMaxPitch)
- // The character look at the target before this distance.
- READ_FLOAT_DEV(MaxHeadTargetDist)
- // FX played when dead
- READ_STRING_DEV(DeadFXName)
- // FX played for each impact
- READ_STRING_DEV(ImpactFXName)
- // FX Played at skill up
- READ_STRING_DEV(SkillUpFXName)
- // MinDistFactor
- READ_DOUBLE_DEV(MinDistFactor)
- // NameScale
- READ_FLOAT_DEV(NameScale)
- // NamePos
- READ_FLOAT_DEV(NamePos)
- // NameFontSize
- READ_INT_DEV(NameFontSize)
- // MaxNameDist
- READ_FLOAT_DEV(MaxNameDist)
- // ConstNameSizeDist
- READ_FLOAT_DEV(ConstNameSizeDist)
- // StaticNameHeight
- READ_BOOL_FV(StaticNameHeight)
- // BarsHeight
- READ_FLOAT_DEV(BarsHeight)
- // BarsWidth
- READ_FLOAT_DEV(BarsWidth)
- // DisplayWeapons
- READ_BOOL_FV(DisplayWeapons)
- // FightAreaSize
- READ_DOUBLE_DEV(FightAreaSize)
- // AttackDist
- READ_FLOAT_DEV(AttackDist)
- // BubbleZBias
- READ_FLOAT_DEV(BubbleZBias);
- // ForageInterfaceZBias
- READ_FLOAT_DEV(ForageInterfaceZBias);
-
- // EnableRacialAnimation
- READ_BOOL_FV(EnableRacialAnimation);
-
-#if !FINAL_VERSION
- READ_FLOAT_DEV(FyrosScale);
- READ_FLOAT_DEV(MatisScale);
- READ_FLOAT_DEV(TrykerScale);
- READ_FLOAT_DEV(ZoraiScale);
-
-#endif // FINAL_VERSION
-
- //////////////////
- // SOUND CONFIG //
- // SoundOn
- READ_BOOL_FV(SoundOn)
- // Sound Driver
- varPtr = ClientCfg.ConfigFile.getVarPtr ("DriverSound");
- if (varPtr)
- {
- if (nlstricmp(varPtr->asString(), "Auto") == 0) ClientCfg.DriverSound = CClientConfig::SoundDrvAuto;
- else if (nlstricmp(varPtr->asString(), "FMod") == 0) ClientCfg.DriverSound = CClientConfig::SoundDrvFMod;
- else if (nlstricmp(varPtr->asString(), "OpenAL") == 0) ClientCfg.DriverSound = CClientConfig::SoundDrvOpenAL;
- else if (nlstricmp(varPtr->asString(), "DirectSound") == 0) ClientCfg.DriverSound = CClientConfig::SoundDrvDirectSound;
- else if (nlstricmp(varPtr->asString(), "XAudio2") == 0) ClientCfg.DriverSound = CClientConfig::SoundDrvXAudio2;
- }
- else
- cfgWarning ("Default value used for 'DriverSound' !!!");
- // SoundForceSoftwareBuffer
- READ_BOOL_FV(SoundForceSoftwareBuffer);
- // SoundOutGameMusic
- READ_STRING_DEV(SoundOutGameMusic)
- // SoundSFXVolume
- READ_FLOAT_FV(SoundSFXVolume);
- // SoundGameMusicVolume
- READ_FLOAT_FV(SoundGameMusicVolume);
- // SoundTPFade
- READ_INT_DEV(SoundTPFade);
- // EnableBackgroundMusicTimeConstraint
- READ_BOOL_DEV(EnableBackgroundMusicTimeConstraint);
- // SoundPackedSheetPath
- READ_STRING_DEV(SoundPackedSheetPath)
- // SampleBankDir
- READ_STRING_DEV(SampleBankDir)
- // UserEntitySoundLevel : UserEntity sound level
- READ_FLOAT_FV(UserEntitySoundLevel)
- // Use EAX
- READ_BOOL_FV(UseEax)
- // UseADPCM
- READ_BOOL_DEV(UseADPCM)
- // Max track
- READ_INT_FV(MaxTrack)
-
- // MP3 Player
- READ_STRING_FV(MediaPlayerDirectory);
- READ_BOOL_FV(MediaPlayerAutoPlay);
-
- /////////////////
- // USER COLORS //
- // Shout Color
- CConfigFile::CVar *pcvColorShout = ClientCfg.ConfigFile.getVarPtr("ColorShout");
- if( pcvColorShout && (pcvColorShout->size() == 3) )
- {
- ClientCfg.ColorShout.R = pcvColorShout->asInt(0);
- ClientCfg.ColorShout.G = pcvColorShout->asInt(1);
- ClientCfg.ColorShout.B = pcvColorShout->asInt(2);
- ClientCfg.ColorShout.A = 255;
- }
- else
- cfgWarning("Default value used for 'ColorShout'");
-
- // Talk Color
- CConfigFile::CVar *pcvColorTalk = ClientCfg.ConfigFile.getVarPtr("ColorTalk");
- if( pcvColorTalk && (pcvColorTalk->size() == 3) )
- {
- ClientCfg.ColorTalk.R = pcvColorTalk->asInt(0);
- ClientCfg.ColorTalk.G = pcvColorTalk->asInt(1);
- ClientCfg.ColorTalk.B = pcvColorTalk->asInt(2);
- ClientCfg.ColorTalk.A = 255;
- }
- else
- cfgWarning("Default value used for 'ColorTalk'");
-
- //////////
- // MISC //
-
- // Pre Data Path.
- READ_STRINGVECTOR_FV(PreDataPath);
-
- // Data Path.
- READ_STRINGVECTOR_FV(DataPath);
-
- // Data Path no recurse.
- READ_STRINGVECTOR_FV(DataPathNoRecurse);
-
- // Streamed package path
- READ_STRING_FV(StreamedPackagePath);
-
- // Streamed package hosts
- READ_STRINGVECTOR_FV(StreamedPackageHosts);
-
- // List of files that trigger R2ED reload when touched
- READ_STRINGVECTOR_FV(R2EDReloadFiles);
-
- // Update packed sheet Path
- READ_STRINGVECTOR_FV(UpdatePackedSheetPath);
-
- // UpdatePackedSheet
- READ_BOOL_DEV(UpdatePackedSheet)
-
- // EndScreenTimeOut
- READ_FLOAT_DEV(EndScreenTimeOut)
- // Backgrounds
- READ_STRING_FV(Loading_BG)
- READ_STRING_FV(LoadingFreeTrial_BG)
- READ_STRING_FV(Launch_BG)
- READ_STRING_FV(TeleportKami_BG)
- READ_STRING_FV(TeleportKaravan_BG)
- READ_STRING_FV(Elevator_BG)
- READ_STRING_FV(ResurectKami_BG)
- READ_STRING_FV(ResurectKaravan_BG)
- READ_STRING_FV(End_BG)
- READ_STRING_FV(IntroNevrax_BG)
- READ_STRING_FV(IntroNVidia_BG)
-
- READ_FLOAT_DEV(TipsY)
- READ_FLOAT_DEV(TeleportInfoY)
- // SceneName
- READ_STRING_DEV(SceneName)
- // IdFile Path
- READ_STRING_DEV(IdFilePath)
-
- // PacsPrimDir
- READ_STRINGVECTOR_DEV(PacsPrimDir);
-
- /////////////
- // FILTERS //
- createDebug ();
- CConfigFile::CVar *pcvTmp = ClientCfg.ConfigFile.getVarPtr("NegFiltersDebug");
- if( pcvTmp )
- {
- int iSz = pcvTmp->size();
- for(int k = 0; k < iSz; ++k)
- {
- DebugLog->addNegativeFilter (pcvTmp->asString(k).c_str());
- }
- }
- else
- cfgWarning("Default value used for 'NegFiltersDebug'");
-
- pcvTmp = ClientCfg.ConfigFile.getVarPtr("NegFiltersInfo");
- if( pcvTmp )
- {
- int iSz = pcvTmp->size();
- for(int k = 0; k < iSz; ++k)
- {
- InfoLog->addNegativeFilter (pcvTmp->asString(k).c_str());
- }
- }
- else
- cfgWarning("Default value used for 'NegFiltersInfo'");
-
- pcvTmp = ClientCfg.ConfigFile.getVarPtr("NegFiltersWarning");
- if( pcvTmp )
- {
- int iSz = pcvTmp->size();
- for(int k = 0; k < iSz; ++k)
- {
- WarningLog->addNegativeFilter (pcvTmp->asString(k).c_str());
- }
- }
- else
- cfgWarning("Default value used for 'NegFiltersWarning'");
-
- // Script Files
- READ_STRINGVECTOR_FV(StartCommands);
-
- /////////////
- // OPTIONS //
- // Colors for system infos
- ClientCfg.SystemInfoParams.clear();
- CConfigFile::CVar *sic = ClientCfg.ConfigFile.getVarPtr("SystemInfoColors");
- if (!sic)
- {
- cfgWarning("Can't read SystemInfoColors, all colors defaulting to white");
- }
- else
- {
- if (sic->size() & 1)
- {
- cfgWarning("Expecting odd size for SystemInfoColors. Last entry ignored.");
- }
- uint numCol = sic->size() >> 1;
- for(uint k = 0; k < numCol; ++k)
- {
- uint r, g, b, a;
- char mode[64];
- char fx[64];
- fx[0]='\0';
- if (sscanf(sic->asString((2 * k) + 1).c_str(), "%d %d %d %d %s %s", &r, &g, &b, &a, mode, fx) < 5)
- {
- if(DisplayCFGWarning)
- nlwarning("Can't parse color for entry %s", sic->asString(2 * k).c_str());
- }
- else
- {
- SSysInfoParam p;
-
- p.Color = CRGBA(r, g, b, a);
- p.Mode = SSysInfoParam::Normal;
- p.SysInfoFxName = string(fx);
- if (stricmp(mode, "over") == 0) p.Mode = SSysInfoParam::Over;
- else if (stricmp(mode, "overonly") == 0) p.Mode = SSysInfoParam::OverOnly;
- else if (stricmp(mode, "center") == 0) p.Mode = SSysInfoParam::Center;
- else if (stricmp(mode, "centeraround") == 0) p.Mode = SSysInfoParam::CenterAround;
- else if (stricmp(mode, "around") == 0) p.Mode = SSysInfoParam::Around;
-
- ClientCfg.SystemInfoParams[toLower(sic->asString(2 * k))] = p;
- }
- }
- }
-
-#ifndef RZ_NO_CLIENT
- // printf commands in loading screens
- ClientCfg.loadingTexts.clear();
- CConfigFile::CVar *pc = ClientCfg.ConfigFile.getVarPtr("loadingTexts");
- if (pc)
- {
- if( pc->size()%5 == 0 && pc->size() >= 5)
- {
- for (uint i = 0; i < pc->size(); i+=5)
- {
- SPrintfCommand pcom;
- pcom.X = pc->asInt(i);
- pcom.Y = pc->asInt(i+1);
- pcom.Color = CRGBA::stringToRGBA( pc->asString(i+2).c_str() );
- pcom.FontSize = pc->asInt(i+3);
- pcom.Text = pc->asString(i+4);
-
- ClientCfg.loadingTexts.push_back( pcom );
- }
- }
- else
- {
- cfgWarning("Missing or too many parameters in loadingTexts");
- }
- }
-#endif
-
- READ_INT_FV(LoadingStringCount)
-
- // DEBUG MEMORY
- READ_INT_DEV(CheckMemoryEveryNFrame)
- READ_BOOL_DEV(LogMemoryAllocation)
- READ_INT_DEV(LogMemoryAllocationSize)
-
- // SelectWithRClick
- READ_BOOL_FV(SelectWithRClick)
- READ_BOOL_DEV(RunAtTheBeginning)
- READ_FLOAT_FV(RotKeySpeedMax)
- READ_FLOAT_FV(RotKeySpeedMin)
- READ_FLOAT_FV(RotAccel)
- READ_BOOL_DEV(PutBackItems)
- READ_BOOL_DEV(ShowNameUnderCursor)
- READ_BOOL_DEV(ShowNameSelected)
- READ_FLOAT_DEV(ShowNameBelowDistanceSqr)
- READ_BOOL_DEV(ForceIndoorFPV)
- READ_BOOL_FV(FollowOnAtk);
- READ_BOOL_FV(AtkOnSelect);
- READ_BOOL_DEV(TransparentUnderCursor);
- //
- READ_BOOL_FV(ItemGroupAllowGuild);
-
-
- /////////////////
- // PREFERENCES //
- // Read the view mode at load time only, cause prefer keep ingame player setup
- if(firstTimeSetValues)
- {
- READ_BOOL_FV(FPV)
- }
- READ_FLOAT_FV(CameraDistStep)
- READ_FLOAT_FV(CameraDistMin)
- READ_FLOAT_FV(CameraDistMax)
- READ_FLOAT_FV(DmCameraDistMax)
- READ_FLOAT_FV(CameraAccel)
- READ_FLOAT_FV(CameraSpeedMin)
- READ_FLOAT_FV(CameraSpeedMax)
- READ_FLOAT_FV(CameraResetSpeed)
- // Read the camera height and distance at load time only, cause prefer keep ingame player setup
- if(firstTimeSetValues)
- {
- READ_FLOAT_FV(CameraHeight)
- READ_FLOAT_FV(CameraDistance)
- }
-
- // Default values for CGroupMap
- READ_FLOAT_FV(MaxMapScale);
- READ_FLOAT_FV(R2EDMaxMapScale);
-
- // /tar to update compass or not
- READ_BOOL_FV(TargetChangeCompass);
-
- /////////////
- // SHADOWS //
- // Shadows : Get Shadows state
- READ_BOOL_FV(Shadows)
- // ShadowsClipFar : Get Shadows Clip Far.
- READ_FLOAT_DEV(ShadowsClipFar)
- // ShadowsLodDist : Get Shadows Lod Distance.
- READ_FLOAT_DEV(ShadowsLodDist)
- // ZClamp
- READ_FLOAT_DEV(ShadowZDirClampLandscape);
- READ_FLOAT_DEV(ShadowZDirClampInterior);
- READ_FLOAT_DEV(ShadowZDirClampSmoothSpeed);
- // MaxDepth
- READ_FLOAT_DEV(ShadowMaxDepthLandscape);
- READ_FLOAT_DEV(ShadowMaxDepthInterior);
- READ_FLOAT_DEV(ShadowMaxDepthSmoothSpeed);
-
-
- ////////////////
- // GROUND FXS //
- ////////////////
- READ_FLOAT_DEV(GroundFXMaxDist)
- READ_INT_DEV(GroundFXMaxNB)
- READ_INT_DEV(GroundFXCacheSize)
-
- // Names : Get Names state
- READ_BOOL_FV(Names)
- // Sleep
- READ_INT_FV(Sleep)
- // ProcessPriority
- READ_INT_FV(ProcessPriority)
- // CPUMask
- READ_INT_FV(CPUMask)
- // ShowPath : Get the ShowPath value.
- READ_BOOL_DEV(ShowPath)
- // UserSheet : Get the sheet to used for the use rin Local mode.
- READ_STRING_DEV(UserSheet)
-#if !FINAL_VERSION
- // Sex
- varPtr = ClientCfg.ConfigFile.getVarPtr("Sex");
- if(varPtr)
- ClientCfg.Sex = (GSGENDER::EGender)varPtr->asInt();
- else
- cfgWarning("Default value used for 'Sex' !!!");
-#endif // FINAL_VERSION
- // PrimitiveHeightAddition
- READ_BOOL_DEV(PrimitiveHeightAddition)
- // DrawBoxes
- READ_BOOL_DEV(DrawBoxes)
-
-
- // ChaseReactionTime
- READ_FLOAT_DEV(ChaseReactionTime)
- // RyzomTime
- READ_FLOAT_DEV(RyzomTime)
- // RyzomDay
- READ_INT_DEV(RyzomDay)
- // ManualWeatherSetup
- READ_BOOL_DEV(ManualWeatherSetup)
- // LanguageCode
- READ_BOOL_DEV(ForceLanguage)
- if (!ClientCfg.ForceLanguage)
- {
- READ_STRING_FV(LanguageCode)
- }
- // DebugStringManager
- READ_BOOL_DEV(DebugStringManager)
-
- // LastLogin
- READ_STRING_FV(LastLogin)
-
- //////////////
- // VERBOSES //
- READ_BOOL_DEV(VerboseVP)
- READ_BOOL_DEV(VerboseAnimUser)
- READ_BOOL_DEV(VerboseAnimSelection)
- READ_BOOL_DEV(VerboseAllTraffic)
-
- READ_STRING_DEV(LigoPrimitiveClass);
-
- ///////////
- // DEBUG //
- READ_INT_DEV(SimulatePacketLossRatio)
- READ_BOOL_DEV(PreCacheShapes)
- READ_BOOL_FV(ResetShapeBankOnRetCharSelect)
- READ_BOOL_DEV(DisplayMissingAnimFile)
- READ_STRING_DEV(DefaultEntity)
- READ_BOOL_DEV(RestrainPI)
- READ_BOOL_DEV(DumpVSIndex)
- READ_INT_DEV(HelpFontSize)
-#if !FINAL_VERSION
- // HelpFontColor
- {
- CConfigFile::CVar *cvHelpFontColor = ClientCfg.ConfigFile.getVarPtr("HelpFontColor");
- if(cvHelpFontColor && cvHelpFontColor->size() == 3)
- {
- ClientCfg.HelpFontColor.R = cvHelpFontColor->asInt(0);
- ClientCfg.HelpFontColor.G = cvHelpFontColor->asInt(1);
- ClientCfg.HelpFontColor.B = cvHelpFontColor->asInt(2);
- ClientCfg.HelpFontColor.A = 255;
- }
- else
- cfgWarning("Default value used for 'HelpFontColor' !!!");
- }
-#endif // !FINAL_VERSION
- // HelpLineStep
- READ_FLOAT_DEV(HelpLineStep)
-
- READ_INT_DEV(DebugFontSize)
-#if !FINAL_VERSION
- // DebugFontColor
- CConfigFile::CVar *pcvDebugFontColor = ClientCfg.ConfigFile.getVarPtr("DebugFontColor");
- if( pcvDebugFontColor && (pcvDebugFontColor->size() == 3) )
- {
- ClientCfg.DebugFontColor.R = pcvDebugFontColor->asInt(0);
- ClientCfg.DebugFontColor.G = pcvDebugFontColor->asInt(1);
- ClientCfg.DebugFontColor.B = pcvDebugFontColor->asInt(2);
- ClientCfg.DebugFontColor.A = 255;
- }
- else
- cfgWarning("Default value used for 'DebugFontColor'");
-#endif // !FINAL_VERSION
- READ_FLOAT_DEV(DebugLineStep)
-
- // HeadOffset
- READ_CVECTOR_DEV(HeadOffset)
- READ_BOOL_DEV(FPExceptions)
- READ_BOOL_DEV(NeedComputeVS)
- READ_BOOL_DEV(Check)
- READ_BOOL_DEV(UsePACSForAll)
- READ_FLOAT_DEV(WaterEnvMapUpdateTime)
- READ_BOOL_DEV(BlendForward)
-
- ClientCfg.ZCPacsPrim = "gen_bt_col_ext.pacs_prim";
- READ_STRING_DEV(ZCPacsPrim)
-
- READ_BOOL_FV(AutoReloadFiles)
- READ_BOOL_DEV(BlendShapePatched)
-
- READ_INT_DEV(MaxNumberOfTimedFXInstances);
-
- READ_STRING_DEV(SelectionFX);
- READ_STRING_DEV(MouseOverFX);
- READ_FLOAT_DEV(SelectionFXSize);
-
- if(ClientCfg.ConfigFile.exists("ExtendedCommands") && ClientCfg.ConfigFile.getVar("ExtendedCommands").asString() == "Enable")
- ClientCfg.ExtendedCommands = true;
-
-
- READ_BOOL_DEV(R2Mode);
- if (ClientCfg.Local) // R2EDEnabled is now set by the server
- {
- READ_BOOL_DEV(R2EDEnabled)
- }
- READ_INT_FV(R2EDDssNetwork)
-
-
- if (ClientCfg.Local)
- {
- ClientCfg.R2EDDssNetwork = 1;
- }
-
- READ_BOOL_DEV(R2EDExtendedDebug)
- #if FINAL_VERSION
- {
- CConfigFile::CVar *var = ClientCfg.ConfigFile.getVarPtr("R2EDExtendedDebug");
- if (var)
- {
- var->setAsInt(0);
- }
- // else no-op -> will resolve to 'nil' into lua
- }
- #endif
-
-
- READ_BOOL_DEV(R2EDVerboseParseTime)
- READ_BOOL_DEV(R2EDDontReparseUnchangedUIFiles)
- READ_BOOL_DEV(R2EDLightPalette)
- READ_INT_FV(R2EDAutoSaveWait)
- READ_INT_FV(R2EDAutoSaveSlot)
- READ_BOOL_DEV(R2EDMustVerifyRingAccessWhileLoadingAnimation)
- READ_BOOL_FV(R2EDUseVerboseRingAccess)
-
-
-
- //////////
- // TEMP //
- // Array with the name of all offensive impact FXs.
- READ_STRINGVECTOR_DEV(OffImpactFX);
-
-#ifndef RZ_NO_CLIENT
-
- //////////
- // INIT //
- // FPU
-#ifdef NL_OS_WINDOWS
- if(ClientCfg.FPExceptions)
- _control87(_EM_DENORMAL/*|_EM_INVALID|_EM_ZERODIVIDE|_EM_OVERFLOW*/|_EM_UNDERFLOW|_EM_INEXACT, _MCW_EM);
- else
- _control87(_EM_INVALID|_EM_DENORMAL|_EM_ZERODIVIDE|_EM_OVERFLOW|_EM_UNDERFLOW|_EM_INEXACT, _MCW_EM);
-
- // Set the process priority
- static DWORD priority[6]=
- {
- 0x40, // IDLE_PRIORITY_CLASS
- 0x4000, // BELOW_NORMAL_PRIORITY_CLASS
- 0x20, // NORMAL_PRIORITY_CLASS
- 0x8000, // ABOVE_NORMAL_PRIORITY_CLASS
- 0x80, // HIGH_PRIORITY_CLASS
- 0x100, // REALTIME_PRIORITY_CLASS
- };
-
- int index = ClientCfg.ProcessPriority+2;
- clamp(index, 0, 6);
- SetPriorityClass (GetCurrentProcess(), priority[index]);
-#endif // NL_OS_WINDOWS
-
- // Init Verbose Modes (at the beginning to be able to display them as soon as possible).
- ::VerboseVP = ClientCfg.VerboseVP;
- ::VerboseAnimUser = ClientCfg.VerboseAnimUser;
- ::VerboseAnimSelection = ClientCfg.VerboseAnimSelection;
-#ifdef LOG_ALL_TRAFFIC
- NLMISC::VerboseAllTraffic = ClientCfg.VerboseAllTraffic;
-#endif
-
- // (re-)Initialize contextual cursors.
- if (!ClientCfg.R2EDEnabled)
- {
- initContextualCursor();
- }
-
- // Prim files
- READ_STRINGVECTOR_DEV(PrimFiles);
-
- // Reset GlobalWind Setup
- if(Scene)
- {
- Scene->setGlobalWindPower(ClientCfg.GlobalWindPower);
- Scene->setGlobalWindDirection(ClientCfg.GlobalWindDirection);
- }
-
- if (Driver)
- {
- // Set the monitor color properties
- CMonitorColorProperties monitorColor;
- for(uint i=0; i<3; i++)
- {
- monitorColor.Contrast[i] = ClientCfg.Contrast;
- monitorColor.Luminosity[i] = ClientCfg.Luminosity;
- monitorColor.Gamma[i] = ClientCfg.Gamma;
- }
- if(!Driver->setMonitorColorProperties(monitorColor))
- cfgWarning("reloadCFG: setMonitorColorProperties fails");
- }
-
-
- // Show/hide all or parts of the user body.
- if (UserEntity)
- {
- UserEntity->eyesHeight(ClientCfg.EyesHeight);
- UserEntity->updateVisualDisplay();
-
- // Run speed and camera dist max are set according to R2 char mode
- UserEntity->flushR2CharMode();
- }
-
- // Initialize the camera distance (after camera dist max)
- View.setCameraDistanceMaxForPlayer();
-
- // draw in client light?
- if(ClientCfg.Light)
- {
- ClientCfg.DrawBoxes = true;
- ClientCfg.Names = true;
- }
-
- // Set Day / Time
- if (ClientCfg.Local)
- {
- uint32 tickOffset = (uint32)(ClientCfg.RyzomDay * RYZOM_HOURS_IN_TICKS * 24 + ClientCfg.RyzomTime * RYZOM_HOURS_IN_TICKS);
- RT.resetTickOffset();
- RT.increaseTickOffset( tickOffset );
- }
-#endif
-
- // for reset effect of variable in mainLoop(), set true
- ClientCfg.IsInvalidated= true;
-
- // Allow warning display only first time.
- DisplayCFGWarning= false;
-
- // If it is the load time, backup the ClientCfg into LastClientCfg
- if(firstTimeSetValues)
- LastClientCfg = ClientCfg;
-
- // no more true.
- firstTimeSetValues= false;
-
- READ_INT_DEV(NumFrameForProfile);
- READ_STRING_FV(KlientChatPort);
- READ_BOOL_DEV(SimulateServerTick);
-
- READ_BOOL_DEV(DamageShieldEnabled)
-
- READ_BOOL_FV(AllowDebugLua)
- READ_BOOL_FV(DisplayLuaDebugInfo)
-
- READ_BOOL_DEV(LuaDebugInfoGotoButtonEnabled)
- READ_STRING_DEV(LuaDebugInfoGotoButtonTemplate)
- READ_STRING_DEV(LuaDebugInfoGotoButtonCaption)
- READ_STRING_DEV(LuaDebugInfoGotoButtonFunction)
-
-
- READ_BOOL_DEV(BeepWhenLaunched)
-
- READ_STRING_DEV(R2ClientGw)
-
- READ_FLOAT_FV(FogDistAndDepthLookupBias)
-
- READ_INT_DEV(R2EDLoadDynamicFeatures)
-
- READ_BOOL_DEV(CheckR2ScenarioMD5);
-
- CConfigFile::CVar *pcvHardwareCursors = ClientCfg.ConfigFile.getVarPtr("HardwareCursors");
- if(pcvHardwareCursors)
- {
- ClientCfg.HardwareCursors.clear ();
- int iSz = pcvHardwareCursors->size();
- for (int i = 0; i < iSz; i++)
- ClientCfg.HardwareCursors.insert(toLower(pcvHardwareCursors->asString(i)));
- }
- else
- {
- cfgWarning("Default value used for 'HardwareCursors'");
- // default list of harware cursors
- ClientCfg.HardwareCursors.insert("curs_can_pan.tga");
- ClientCfg.HardwareCursors.insert("curs_can_pan_dup.tga");
- ClientCfg.HardwareCursors.insert("curs_create.tga");
- ClientCfg.HardwareCursors.insert("curs_create_multi.tga");
- ClientCfg.HardwareCursors.insert("curs_create_vertex_invalid.tga");
- ClientCfg.HardwareCursors.insert("curs_default.tga");
- ClientCfg.HardwareCursors.insert("curs_dup.tga");
- ClientCfg.HardwareCursors.insert("curs_L.tga");
- ClientCfg.HardwareCursors.insert("curs_M.tga");
- ClientCfg.HardwareCursors.insert("curs_pan.tga");
- ClientCfg.HardwareCursors.insert("curs_pan_dup.tga");
- ClientCfg.HardwareCursors.insert("curs_pick.tga");
- ClientCfg.HardwareCursors.insert("curs_pick_dup.tga");
- ClientCfg.HardwareCursors.insert("curs_R.tga");
- ClientCfg.HardwareCursors.insert("curs_resize_BL_TR.tga");
- ClientCfg.HardwareCursors.insert("curs_resize_BR_TL.tga");
- ClientCfg.HardwareCursors.insert("curs_resize_LR.tga");
- ClientCfg.HardwareCursors.insert("curs_resize_TB.tga");
- ClientCfg.HardwareCursors.insert("curs_rotate.tga");
- ClientCfg.HardwareCursors.insert("curs_scale.tga");
- ClientCfg.HardwareCursors.insert("curs_stop.tga");
- ClientCfg.HardwareCursors.insert("text_cursor.tga");
- ClientCfg.HardwareCursors.insert("r2_hand_can_pan.tga");
- ClientCfg.HardwareCursors.insert("r2_hand_pan.tga");
- ClientCfg.HardwareCursors.insert("r2ed_tool_can_pick.tga");
- ClientCfg.HardwareCursors.insert("r2ed_tool_can_rotate.tga");
- ClientCfg.HardwareCursors.insert("r2ed_tool_pick.tga");
- ClientCfg.HardwareCursors.insert("r2ed_tool_rotate.tga");
- ClientCfg.HardwareCursors.insert("r2ed_tool_rotating.tga");
- }
-
- // languages and types of Ring Scenarii
- READ_STRINGVECTOR_FV(ScenarioLanguages);
- READ_STRINGVECTOR_FV(ScenarioTypes);
-
- // build name
- READ_STRING_FV(BuildName)
-
- READ_BOOL_DEV(DisplayTPReason)
-
- //READ_INT_FV(TPQuitButtonX)
- //READ_INT_FV(TPQuitButtonY)
- //READ_INT_FV(TPCancelButtonX)
- //READ_INT_FV(TPCancelButtonY)
- READ_INT_FV(TPButtonW)
- READ_INT_FV(TPButtonH)
-
- READ_STRING_FV(ScenarioSavePath)
-
-
- ClientCfg.R2EDClippedEntityBlendTime = 0.18f;
- READ_FLOAT_FV(R2EDClippedEntityBlendTime)
-
- // vl: BackgroundDownloader is hardcoded to false and we don't want to run it, even if the cfg wants it
- //READ_BOOL_FV(BackgroundDownloader)
-
-}// load //
-
-
-//-----------------------------------------------
-// serial :
-// Serialize CFG.
-//-----------------------------------------------
-void CClientConfig::serial(NLMISC::IStream &f)
-{
- // Start the opening of a new node named ClientCFG.
- f.xmlPush("ClientCFG");
-
- f.xmlPushBegin("Light");
- f.xmlPushEnd();
- f.serial(Light);
- f.xmlPop();
-
- f.xmlPushBegin("Windowed");
- f.xmlPushEnd();
- f.serial(Windowed);
- f.xmlPop();
-
- f.xmlPushBegin("Width");
- f.xmlPushEnd();
- f.serial(Width);
- f.xmlPop();
-
- f.xmlPushBegin("Height");
- f.xmlPushEnd();
- f.serial(Height);
- f.xmlPop();
-
- f.xmlPushBegin("Depth");
- f.xmlPushEnd();
- f.serial(Depth);
- f.xmlPop();
-
- f.xmlPushBegin("Contrast");
- f.xmlPushEnd();
- f.serial(Contrast);
- f.xmlPop();
-
- f.xmlPushBegin("Luminosity");
- f.xmlPushEnd();
- f.serial(Luminosity);
- f.xmlPop();
-
- f.xmlPushBegin("Gamma");
- f.xmlPushEnd();
- f.serial(Gamma);
- f.xmlPop();
-
-
- f.xmlPushBegin("AttackDist");
- f.xmlPushEnd();
- f.serial(AttackDist);
- f.xmlPop();
-
- // SelectWithRClick
- f.xmlPushBegin("SelectWithRClick");
- f.xmlPushEnd();
- f.serial(SelectWithRClick);
- f.xmlPop();
-
- // Close the serial for the Client CFG.
- f.xmlPop();
-}// serial //
-
-
-//-----------------------------------------------
-// init :
-//-----------------------------------------------
-void CClientConfig::init(const string &configFileName)
-{
- // if the users client config does not exist
- if(!CFile::fileExists(configFileName))
- {
- // create the basic .cfg
- FILE *fp = nlfopen(configFileName, "w");
-
- if (fp == NULL)
- nlerror("CFG::init: Can't create config file '%s'", configFileName.c_str());
- else
- nlwarning("CFG::init: creating '%s' with default values", configFileName.c_str ());
-
- // get current locale
- std::string lang = CI18N::getSystemLanguageCode();
-
- const std::vector &languages = CI18N::getLanguageCodes();
-
- // search if current locale is defined in language codes
- for(uint i = 0; i < languages.size(); ++i)
- {
- if (lang == languages[i])
- {
- // store the language code in the config file
- fprintf(fp, "LanguageCode = \"%s\";\n", lang.c_str());
- break;
- }
- }
-
- fclose(fp);
- }
-
- // read the exising config file (don't parse it yet!)
- ucstring content;
- NLMISC::CI18N::readTextFile(configFileName, content);
- std::string contentUtf8 = content.toUtf8();
-
- // while there are "RootConfigFilename" values, remove them
- size_t pos = 0;
- while((pos = contentUtf8.find("RootConfigFilename")) != configFileName.npos)
- {
- size_t endOfLine = contentUtf8.find("\n", pos);
- contentUtf8.erase(pos, (endOfLine - pos) + 1);
- }
-
- // get current location of the root config file (client_default.cfg)
- std::string defaultConfigLocation;
- if(!getDefaultConfigLocation(defaultConfigLocation))
- nlerror("cannot find client_default.cfg");
-
- // and store it in the RootConfigFilename value in the very first line
- contentUtf8.insert(0, std::string("RootConfigFilename = \"") +
- defaultConfigLocation + "\";\n");
-
- // save the updated config file
- NLMISC::COFile configFile(configFileName, false, true, false);
- configFile.serialBuffer((uint8*)contentUtf8.c_str(), (uint)contentUtf8.size());
- configFile.close();
-
- // now we can continue loading and parsing the config file
-
- // if the config file will be modified, it calls automatically the function setValuesOnFileChange()
- ClientCfg.ConfigFile.setCallback (CClientConfig::setValuesOnFileChange);
-
- // load the config files
- ClientCfg.ConfigFile.load (configFileName);
-
- CConfigFile::CVar *pCV;
- // check language code is supported
- pCV = ClientCfg.ConfigFile.getVarPtr("LanguageCode");
- if (pCV)
- {
- std::string lang = pCV->asString();
- if (!CI18N::isLanguageCodeSupported(lang))
- {
- nlinfo("Unsupported language code \"%s\" fallback on default", lang.c_str());
- // fallback to default language
- ClientCfg.LanguageCode = CI18N::getSystemLanguageCode();
- // update ConfigFile variable
- pCV->setAsString(ClientCfg.LanguageCode);
- ClientCfg.ConfigFile.save();
- }
- }
-
- // update the ConfigFile variable in the config file
- pCV = ClientCfg.ConfigFile.getVarPtr("ClientVersion");
- if (pCV)
- {
- std::string str = pCV->asString ();
- if (str != getVersion() && ClientCfg.SaveConfig)
- {
- nlinfo ("Update and save the ClientVersion variable in config file %s -> %s", str.c_str(), getVersion().c_str());
- pCV->setAsString(getVersion());
- ClientCfg.ConfigFile.save();
- }
- }
- else
- nlwarning ("There's no ClientVersion variable in the config file!");
-
-}// init //
-
-
-//-----------------------------------------------
-// init :
-//-----------------------------------------------
-void CClientConfig::release ()
-{
-#ifndef RZ_NO_CLIENT
- // Do we have to save the cfg file ?
- if (ClientCfg.SaveConfig)
- {
- // Save values
- try
- {
- CConfigFile::CVar *varPtr = NULL;
-
- // Driver still alive ?
- if (Driver && Driver->isActive ())
- {
- sint32 x, y;
- uint32 width, height;
-
- Driver->getWindowPos(x, y);
- Driver->getWindowSize(width, height);
-
- // Are we in window mode ?
- if (ClientCfg.Windowed /* && !isWindowMaximized() */)
- {
- // Save windows position. width/height are saved when leaving ingame.
- writeInt("PositionX", x);
- writeInt("PositionY", y);
- }
- }
-
- // Save if in FPV or TPV.
- writeBool("FPV", ClientCfg.FPV);
-
- // Save the camera distance
- writeDouble("CameraDistance", ClientCfg.CameraDistance);
- }
- catch (const Exception &e)
- {
- nlwarning ("Error while set config file variables : %s", e.what ());
- }
-
- // Save it
- ClientCfg.ConfigFile.save ();
- }
-#endif
-}
-
-bool CClientConfig::readBool (const std::string &varName)
-{
- bool bVal = false;
- CConfigFile::CVar *varPtr = ConfigFile.getVarPtr(varName);
- if(varPtr)
- bVal = varPtr->asInt() ? true : false;
- else
- nlwarning("CFG: Default value used for '%s' !!!",varName.c_str());
- return bVal;
-}
-
-void CClientConfig::writeBool (const std::string &varName, bool bVal, bool bForce)
-{
- CConfigFile::CVar *varPtr = bForce ? ConfigFile.insertVar(varName, CConfigFile::CVar()):ConfigFile.getVarPtr(varName);
- if(varPtr)
- varPtr->forceAsInt(bVal ? 1:0);
- else
- nlwarning("CFG: Default value used for '%s' !!!",varName.c_str());
-}
-
-sint32 CClientConfig::readInt (const std::string &varName)
-{
- sint32 bVal = 0;
- CConfigFile::CVar *varPtr = ConfigFile.getVarPtr(varName);
- if(varPtr)
- bVal = varPtr->asInt();
- else
- nlwarning("CFG: Default value used for '%s' !!!",varName.c_str());
- return bVal;
-}
-
-void CClientConfig::writeInt (const std::string &varName, sint32 bVal, bool bForce)
-{
- CConfigFile::CVar *varPtr = bForce ? ConfigFile.insertVar(varName, CConfigFile::CVar()):ConfigFile.getVarPtr(varName);
- if(varPtr)
- varPtr->forceAsInt(bVal);
- else
- nlwarning("CFG: Default value used for '%s' !!!",varName.c_str());
-}
-
-double CClientConfig::readDouble (const std::string &varName)
-{
- double bVal = 0;
- CConfigFile::CVar *varPtr = ConfigFile.getVarPtr(varName);
- if(varPtr)
- bVal = varPtr->asDouble();
- else
- nlwarning("CFG: Default value used for '%s' !!!",varName.c_str());
- return bVal;
-}
-
-void CClientConfig::writeDouble (const std::string &varName, double dVal, bool bForce)
-{
- CConfigFile::CVar *varPtr = bForce ? ConfigFile.insertVar(varName, CConfigFile::CVar()):ConfigFile.getVarPtr(varName);
- if(varPtr)
- varPtr->forceAsDouble(dVal);
- else
- nlwarning("CFG: Default value used for '%s' !!!",varName.c_str());
-}
-
-string CClientConfig::readString (const std::string &varName)
-{
- string sVal;
- CConfigFile::CVar *varPtr = ConfigFile.getVarPtr(varName);
- if(varPtr)
- sVal = varPtr->asString();
- else
- nlwarning("CFG: Default value used for '%s' !!!",varName.c_str());
- return sVal;
-}
-
-void CClientConfig::writeString (const std::string &varName, const std::string &strVal, bool bForce)
-{
- CConfigFile::CVar *varPtr = bForce ? ConfigFile.insertVar(varName, CConfigFile::CVar()):ConfigFile.getVarPtr(varName);
- if(varPtr)
- varPtr->forceAsString(strVal);
- else
- nlwarning("CFG: Default value used for '%s' !!!",varName.c_str());
-}
-
-// ***************************************************************************
-bool CClientConfig::readBoolNoWarning(const std::string &varName)
-{
- bool bVal = false;
- CConfigFile::CVar *varPtr = ConfigFile.getVarPtr(varName);
- if(varPtr)
- bVal = varPtr->asInt() ? true : false;
- return bVal;
-}
-
-sint32 CClientConfig::readIntNoWarning(const std::string &varName)
-{
- sint32 bVal = 0;
- CConfigFile::CVar *varPtr = ConfigFile.getVarPtr(varName);
- if(varPtr)
- bVal = varPtr->asInt();
- return bVal;
-}
-
-double CClientConfig::readDoubleNoWarning(const std::string &varName)
-{
- double bVal = 0;
- CConfigFile::CVar *varPtr = ConfigFile.getVarPtr(varName);
- if(varPtr)
- bVal = varPtr->asDouble();
- return bVal;
-}
-
-// ***************************************************************************
-float CClientConfig::getActualLandscapeThreshold() const
-{
- // The threshold to set in landscape is the inverse of the CFG one
- return 1.0f/LandscapeThreshold;
-}
-
-// ***************************************************************************
-string CClientConfig::getHtmlLanguageCode() const
-{
- if(LanguageCode=="wk")
- return "en";
- else
- return LanguageCode;
-}
-
-// ***************************************************************************
-ucstring CClientConfig::buildLoadingString( const ucstring& ucstr ) const
-{
- if( LoadingStringCount > 0 )
- {
- uint index = rand()%LoadingStringCount;
- string tipId = "uiLoadingString"+toString(index);
- ucstring randomUCStr = CI18N::get(tipId);
- return randomUCStr;
- }
- else
- return ucstr;
-}
-
-// ***************************************************************************
-bool CClientConfig::getDefaultConfigLocation(std::string& p_name) const
-{
- std::string defaultConfigFileName = "client_default.cfg";
- std::string defaultConfigPath;
-
- p_name.clear();
-
-#ifdef NL_OS_MAC
- // on mac, client_default.cfg should be searched in .app/Contents/Resources/
- defaultConfigPath = getAppBundlePath() + "/Contents/Resources/";
-#else
- // unders Windows or Linux, search client_default.cfg is same directory as executable
- defaultConfigPath = Args.getProgramPath();
-#endif
-
- std::string currentPath = CPath::standardizePath(CPath::getCurrentPath());
- std::string etcPath = CPath::standardizePath(getRyzomEtcPrefix());
-
- // look in the current working directory first
- if (CFile::isExists(currentPath + defaultConfigFileName))
- p_name = currentPath + defaultConfigFileName;
-
- // look in startup directory
- else if (CFile::isExists(Args.getStartupPath() + defaultConfigFileName))
- p_name = Args.getStartupPath() + defaultConfigFileName;
-
- // look in application directory
- else if (CFile::isExists(defaultConfigPath + defaultConfigFileName))
- p_name = defaultConfigPath + defaultConfigFileName;
-
- // look in etc prefix path
- else if (!etcPath.empty() && CFile::isExists(etcPath + defaultConfigFileName))
- p_name = etcPath + defaultConfigFileName;
-
- // if some client_default.cfg was found return true
- return !p_name.empty();
-}
diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp
deleted file mode 100644
index f57238991..000000000
--- a/code/ryzom/client/src/connection.cpp
+++ /dev/null
@@ -1,3693 +0,0 @@
-// Ryzom - MMORPG Framework
-// Copyright (C) 2010-2019 Winch Gate Property Limited
-//
-// This source file has been modified by the following contributors:
-// Copyright (C) 2012 Matt RAYKOWSKI (sfb)
-// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter)
-// Copyright (C) 2014-2019 Jan BOON (Kaetemi)
-//
-// 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 .
-
-
-
-
-//////////////
-// Includes //
-//////////////
-#include "stdpch.h"
-
-// Misc.
-#include "nel/misc/i18n.h"
-#include "nel/misc/path.h"
-#include "nel/misc/time_nl.h"
-#include "nel/misc/algo.h"
-#include "nel/misc/system_utils.h"
-#include "nel/misc/stream.h"
-// 3D Interface.
-#include "nel/3d/u_driver.h"
-#include "nel/3d/u_text_context.h"
-#include "nel/3d/stereo_display.h"
-// Game Share
-//#include "game_share/gd_time.h" // \todo GUIGUI : TO DELETE/CHANGE
-#include "game_share/gender.h"
-#include "game_share/character_summary.h"
-#include "game_share/roles.h"
-#include "game_share/character_title.h"
-#include "game_share/shard_names.h"
-#include "game_share/utils.h"
-#include "game_share/bg_downloader_msg.h"
-
-// Std.
-#include
-// Client
-#include "connection.h"
-#include "nel/gui/action_handler.h"
-#include "sound_manager.h"
-#include "input.h"
-#include "login.h"
-#include "login_progress_post_thread.h"
-
-#include "client_cfg.h"
-#include "actions_client.h"
-#include "user_entity.h"
-#include "time_client.h"
-#include "net_manager.h"
-#include "string_manager_client.h"
-#include "far_tp.h"
-#include "movie_shooter.h"
-
-// Interface part
-#include "interface_v3/interface_manager.h"
-#include "interface_v3/character_3d.h"
-#include "nel/gui/ctrl_button.h"
-#include "interface_v3/input_handler_manager.h"
-#include "nel/gui/group_editbox.h"
-#include "nel/gui/interface_expr.h"
-#include "init_main_loop.h"
-#include "continent_manager.h"
-#include "interface_v3/group_quick_help.h"
-#include "nel/gui/dbgroup_combo_box.h"
-
-#include "r2/dmc/client_edition_module.h"
-#include "r2/editor.h"
-#include "game_share/scenario.h"
-#include "session_browser_impl.h"
-
-#include "bg_downloader_access.h"
-#include "main_loop.h"
-
-#include "misc.h"
-
-
-////////////////
-// Namespaces //
-////////////////
-using namespace NLMISC;
-using namespace NL3D;
-using namespace NLNET;
-using namespace std;
-using namespace RSMGR;
-using namespace R2;
-
-
-
-/////////////
-// Externs //
-/////////////
-extern uint32 Version; // Client Version.
-extern UDriver *Driver;
-extern UTextContext *TextContext;
-extern bool game_exit;
-
-extern CSoundManager *SoundMngr;
-
-extern bool serverReceivedReady;
-extern CContinentManager ContinentMngr;
-
-extern bool MovieShooterSaving;
-extern void endMovieShooting();
-extern void replayMovieShooting();
-extern void saveMovieShooting();
-extern void displaySpecialTextProgress(const char *text);
-extern bool InitMouseWithCursor(bool hardware);
-
-extern bool SetMousePosFirstTime;
-
-/////////////
-// Globals // initialization occurs in the function : connection
-/////////////
-bool userChar;
-bool noUserChar;
-bool ConnectInterf;
-bool CreateInterf;
-bool CharacterInterf;
-TTime UniversalTime;
-std::vector CharacterSummaries;
-std::string UsedFSAddr;
-std::string UserPrivileges;
-uint8 ServerPeopleActive = 255;
-uint8 ServerCareerActive = 255;
-
-bool WaitServerAnswer;
-bool CharNameValidArrived;
-bool CharNameValid;
-string CharNameValidDBLink;
-uint8 PlayerSelectedSlot = 0;
-string PlayerSelectedFileName;
-TSessionId PlayerSelectedMainland= (TSessionId)0; // This is the mainland selected at the SELECT perso!!
-ucstring PlayerSelectedHomeShardName;
-ucstring PlayerSelectedHomeShardNameWithParenthesis;
-extern std::string CurrentCookie;
-
-
-ucstring NewKeysCharNameWanted; // name of the character for which a new keyset must be created
-ucstring NewKeysCharNameValidated;
-std::string GameKeySet = "keys.xml";
-std::string RingEditorKeySet = "keys_r2ed.xml";
-
-string ScenarioFileName;
-sint LoginCharsel = -1;
-
-std::string ImportCharacter;
-
-static const char *KeySetVarName = "BuiltInKeySets";
-
-#define GROUP_LIST_CHARACTER "ui:outgame:charsel_import:import_list"
-#define GROUP_LIST_MAINLAND "ui:outgame:appear_mainland:mainland_list"
-#define GROUP_LIST_KEYSET "ui:outgame:appear_keyset:keyset_list"
-vector Mainlands;
-TSessionId MainlandSelected = (TSessionId)0; // This is the mainland selected at the CREATE perso!!
-
-// This is the home session (mainland) of the selected character
-TSessionId CharacterHomeSessionId = (TSessionId)0;
-
-
-bool PatchBegun = false;
-
-// \todo GUIGUI : USE TRANSPORT CLASS.
-// SVersionAnswer versionAnswer;
-
-
-// Finite State Machine : all the states before entering the game
-// ------------------------------------------------------------------------------------------------
-TInterfaceState globalMenu();
-
-
-bool hasPrivilegeDEV() { return (UserPrivileges.find(":DEV:") != std::string::npos); }
-bool hasPrivilegeSGM() { return (UserPrivileges.find(":SGM:") != std::string::npos); }
-bool hasPrivilegeGM() { return (UserPrivileges.find(":GM:") != std::string::npos); }
-bool hasPrivilegeVG() { return (UserPrivileges.find(":VG:") != std::string::npos); }
-bool hasPrivilegeSG() { return (UserPrivileges.find(":SG:") != std::string::npos); }
-bool hasPrivilegeG() { return (UserPrivileges.find(":G:") != std::string::npos); }
-bool hasPrivilegeEM() { return (UserPrivileges.find(":EM:") != std::string::npos); }
-bool hasPrivilegeEG() { return (UserPrivileges.find(":EG:") != std::string::npos); }
-bool hasPrivilegeOBSERVER() { return (UserPrivileges.find(":OBSERVER:") != std::string::npos); }
-bool hasPrivilegeTESTER() { return (UserPrivileges.find(":TESTER:") != std::string::npos); }
-
-
-// Restore the video mode (fullscreen for example) after the connection (done in a window)
-void connectionRestoreVideoMode ()
-{
- // Setup full screen if we have to
- UDriver::CMode mode;
- Driver->getCurrentScreenMode(mode);
-
- if (mode.Windowed)
- {
- uint32 width, height;
- Driver->getWindowSize(width, height);
- mode.Width = width;
- mode.Height = height;
- }
-
- // don't allow sizes smaller than 1024x768
- if (ClientCfg.Width < 1024) ClientCfg.Width = 1024;
- if (ClientCfg.Height < 768) ClientCfg.Height = 768;
-
- if (StereoDisplay)
- StereoDisplayAttached = StereoDisplay->attachToDisplay();
-
- if (!StereoDisplayAttached && (
- (ClientCfg.Windowed != mode.Windowed) ||
- (ClientCfg.Width != mode.Width) ||
- (ClientCfg.Height != mode.Height)))
- {
- mode.Windowed = ClientCfg.Windowed;
- mode.Depth = uint8(ClientCfg.Depth);
- mode.Width = ClientCfg.Width;
- mode.Height = ClientCfg.Height;
- mode.Frequency = ClientCfg.Frequency;
- setVideoMode(mode);
- }
-
- // And setup hardware mouse if we have to
- InitMouseWithCursor (ClientCfg.HardwareCursor && !StereoDisplayAttached);
- SetMouseFreeLook ();
- SetMouseCursor ();
- SetMouseSpeed (ClientCfg.CursorSpeed);
- SetMouseAcceleration (ClientCfg.CursorAcceleration);
-
- // Restore user UI scaling
- CViewRenderer::getInstance()->setInterfaceScale(ClientCfg.InterfaceScale);
-}
-
-
-#define UI_VARIABLES_SCREEN_WEBSTART 8
-
-
-// ***************************************************************************
-// Called to reload the start test page in test browser mode
-class CAHOnReloadTestPage: public IActionHandler
-{
- virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
- {
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- // need to reset password and current screen
- CGroupHTML *pGH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_BROWSER));
-
- pGH->browse(ClientCfg.TestBrowserUrl.c_str());
-
- }
-};
-REGISTER_ACTION_HANDLER (CAHOnReloadTestPage, "on_reload_test_page");
-
-
-// ------------------------------------------------------------------------------------------------
-void setOutGameFullScreen()
-{
- if (!ClientCfg.Local && ClientCfg.SelectCharacter == -1)
- {
- if (StereoDisplayAttached)
- StereoDisplay->detachFromDisplay();
- StereoDisplayAttached = false;
-
- InitMouseWithCursor(ClientCfg.HardwareCursor && !StereoDisplayAttached);
- }
-
- // Enable auto scaling in login window
- CViewRenderer::getInstance()->setInterfaceScale(1.0f, 1024, 768);
-}
-
-
-// New version of the menu after the server connection
-//
-// If you add something in this function, check CFarTP,
-// some kind of reinitialization might be useful over there.
-// ------------------------------------------------------------------------------------------------
-bool connection (const string &cookie, const string &fsaddr)
-{
-
- NLMISC::TTime connStart = ryzomGetLocalTime();
- NLMISC::TTime connLast = connStart;
- NLMISC::TTime connCurrent = connLast;
-
- game_exit = false;
-
- // set resolution from cfg after login
- connectionRestoreVideoMode ();
-
- // Preload continents
- {
- const ucstring nmsg("Loading continents...");
- ProgressBar.newMessage (ClientCfg.buildLoadingString(nmsg) );
- ContinentMngr.preloadSheets();
-
- connLast = connCurrent;
- connCurrent = ryzomGetLocalTime();
- nlinfo ("PROFILE: %d seconds (%d total) for Loading continents", (uint32)(connCurrent-connLast)/1000, (uint32)(connCurrent-connStart)/1000);
- }
-
- if (!fsaddr.empty () && !cookie.empty ())
- {
- // it means that we have a nel_launcher values, so we are online
- ClientCfg.Local = 0;
- nlinfo ("Using the nel launcher parameters '%s' '%s'", cookie.c_str (), fsaddr.c_str ());
- }
-
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
-
- // If the Client is in in Local Mode -> init the Time and return.
- if (ClientCfg.Local)
- {
-#ifdef ENABLE_INCOMING_MSG_RECORDER
- NetMngr.init("", "");
- // Set the impulse callback.
- NetMngr.setImpulseCallback (impulseCallBack);
- // Set the database.
- NetMngr.setDataBase (IngameDbMngr.getNodePtr());
- // init the string manager cache.
- STRING_MANAGER::CStringManagerClient::instance()->initCache("", ClientCfg.LanguageCode); // VOIR BORIS
-#endif
- return true;
- }
-
- ProgressBar.setFontFactor(1.0f);
-
- // Init out game
- setOutGameFullScreen();
-
- ucstring nmsg("Initializing outgame...");
- ProgressBar.newMessage (ClientCfg.buildLoadingString(nmsg) );
- pIM->initOutGame();
-
- connLast = connCurrent;
- connCurrent = ryzomGetLocalTime();
- nlinfo ("PROFILE: %d seconds (%d total) for Initializing outgame", (uint32)(connCurrent-connLast)/1000, (uint32)(connCurrent-connStart)/1000);
-
- // Init user interface
- nmsg = "Initializing user interface...";
- ProgressBar.newMessage (ClientCfg.buildLoadingString(nmsg) );
-
- // Hide cursor for interface
- //Driver->showCursor (false);
-
- // Init global variables
- userChar = false;
- noUserChar = false;
- ConnectInterf = true;
- CreateInterf = true;
- CharacterInterf = true;
- WaitServerAnswer= false;
-
- FarTP.setOutgame();
-
- // Start the finite state machine
- static bool firstConnection = true;
- TInterfaceState InterfaceState = AUTO_LOGIN;
- // TInterfaceState InterfaceState = firstConnection ? AUTO_LOGIN : GLOBAL_MENU;
- /*if (!firstConnection)
- {
- noUserChar = userChar = false;
- WaitServerAnswer = true;
- }*/
-
- NLGUI::CDBManager::getInstance()->getDbProp ("UI:CURRENT_SCREEN")->setValue32(ClientCfg.Local ? 6 : -1); // TMP TMP
- IngameDbMngr.flushObserverCalls();
- NLGUI::CDBManager::getInstance()->flushObserverCalls();
-
- // Active inputs
- Actions.enable(true);
- EditActions.enable(true);
-
- if (ClientCfg.SelectCharacter == -1)
- {
- // not initialized at login and remain hardware until here ...
-
- // Re-initialise the mouse (will be now in hardware mode, if required)
- //InitMouseWithCursor (ClientCfg.HardwareCursor && !StereoDisplayAttached); // the return value of enableLowLevelMouse() has already been tested at startup
-
- // no ui init if character selection is automatic
- //SetMouseFreeLook ();
- //SetMouseCursor ();
- SetMouseSpeed (ClientCfg.CursorSpeed);
- SetMouseAcceleration (ClientCfg.CursorAcceleration);
-
- NLGUI::CDBManager::getInstance()->getDbProp("UI:SELECTED_SLOT")->setValue32(ClientCfg.SelectedSlot);
- PlayerSelectedSlot = ClientCfg.SelectedSlot;
- }
-
- connLast = connCurrent;
- connCurrent = ryzomGetLocalTime();
- nlinfo ("PROFILE: %d seconds (%d total) for Initializing user interface", (uint32)(connCurrent-connLast)/1000, (uint32)(connCurrent-connStart)/1000);
-
- nlinfo ("PROFILE: %d seconds for connection", (uint32)(ryzomGetLocalTime ()-connStart)/1000);
-
- // Init web box
-
- // TMP TMP
- if (ClientCfg.Local)
- {
- InterfaceState = GLOBAL_MENU;
- }
-
- // Create the loading texture. We can't do that before because we need to add search path first.
- beginLoading (LoadBackground);
- UseEscapeDuringLoading = USE_ESCAPE_DURING_LOADING;
-
- while ((InterfaceState != GOGOGO_IN_THE_GAME) && (InterfaceState != QUIT_THE_GAME))
- {
- switch (InterfaceState)
- {
- case AUTO_LOGIN:
- InterfaceState = autoLogin (cookie, fsaddr, firstConnection);
- break;
-
- case GLOBAL_MENU:
- if (!ClientCfg.Local)
- {
- if (ClientCfg.SelectCharacter == -1)
- {
- NLGUI::CDBManager::getInstance()->getDbProp ("UI:CURRENT_SCREEN")->setValue32(0); // 0 == select
- }
- }
- InterfaceState = globalMenu();
- break;
- case GOGOGO_IN_THE_GAME:
- break;
- case QUIT_THE_GAME:
- break;
- }
- }
-
- firstConnection = false;
-
- // Restore user UI scaling
- CViewRenderer::getInstance()->setInterfaceScale(ClientCfg.InterfaceScale);
-
- // Disable inputs
- Actions.enable(false);
- EditActions.enable(false);
-
-// resetTextContext ("ingame.ttf", true);
- resetTextContext ("ryzom.ttf", true);
-
- if (InterfaceState == GOGOGO_IN_THE_GAME)
- {
- // set background downloader to 'paused' to ease loading of client
- pauseBGDownloader();
- return true;
- }
-
- if (InterfaceState == QUIT_THE_GAME)
- return false;
- nlassert ((InterfaceState == GOGOGO_IN_THE_GAME) || (InterfaceState == QUIT_THE_GAME));
- return true;
-}
-
-
-//
-
-// Allow user to reselect character after the server reconnection
-// ------------------------------------------------------------------------------------------------
-bool reconnection()
-{
-
- game_exit = false;
-
- setOutGameFullScreen();
-
- // Preload continents
- {
- const ucstring nmsg ("Loading continents...");
- ProgressBar.newMessage (ClientCfg.buildLoadingString(nmsg) );
- ContinentMngr.preloadSheets();
- }
-/*
- if (!fsaddr.empty () && !cookie.empty ())
- {
- // it means that we have a nel_launcher values, so we are online
- ClientCfg.Local = 0;
- nlinfo ("Using the nel launcher parameters '%s' '%s'", cookie.c_str (), fsaddr.c_str ());
- }
-
- // If the Client is in in Local Mode -> init the Time and return.
- if (ClientCfg.Local)
- {
-#ifdef ENABLE_INCOMING_MSG_RECORDER
- NetMngr.init("", "");
- // Set the impulse callback.
- NetMngr.setImpulseCallback (impulseCallBack);
- // Set the database.
- NetMngr.setDataBase (IngameDbMngr.getNodePtr());
- // init the string manager cache.
- STRING_MANAGER::CStringManagerClient::instance()->initCache("", ClientCfg.LanguageCode); // VOIR BORIS
-#endif
- connectionRestoreVideoMode ();
- return true;
- }
-*/
-
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
-
- ProgressBar.setFontFactor(1.0f);
-
- // Init out game
- pIM->initOutGame();
-
- // Hide cursor for interface
- Driver->showCursor (false);
-
- // Init global variables
- userChar = false;
- noUserChar = false;
- ConnectInterf = true;
- CreateInterf = true;
- CharacterInterf = true;
- WaitServerAnswer= false;
-
- FarTP.setOutgame();
-
- // these two globals sequence GlobalMenu to display the character select dialog
- WaitServerAnswer = true;
- userChar = true;
-
- // Start the finite state machine
- TInterfaceState InterfaceState = GLOBAL_MENU;
-
- NLGUI::CDBManager::getInstance()->getDbProp ("UI:CURRENT_SCREEN")->setValue32(-1);
- IngameDbMngr.flushObserverCalls();
- NLGUI::CDBManager::getInstance()->flushObserverCalls();
-
- // Active inputs
- Actions.enable(true);
- EditActions.enable(true);
-
- if (ClientCfg.SelectCharacter == -1)
- {
- // Re-initialise the mouse (will be now in hardware mode, if required)
- SetMousePosFirstTime = true;
- InitMouseWithCursor (ClientCfg.HardwareCursor && !StereoDisplayAttached); // the return value of enableLowLevelMouse() has already been tested at startup
-
- // no ui init if character selection is automatic
- SetMouseFreeLook ();
- SetMouseCursor ();
- SetMouseSpeed (ClientCfg.CursorSpeed);
- SetMouseAcceleration (ClientCfg.CursorAcceleration);
- NLGUI::CDBManager::getInstance()->getDbProp("UI:SELECTED_SLOT")->setValue32(ClientCfg.SelectedSlot);
- PlayerSelectedSlot = ClientCfg.SelectedSlot;
- }
-
- // we want the teleport graphics to display (not like in Server Hop mode)
- // this also kicks the state machine to sendReady() so we stop spinning in farTPmainLoop
- FarTP.setIngame();
-
- // Create the loading texture. We can't do that before because we need to add search path first.
- beginLoading (LoadBackground);
- UseEscapeDuringLoading = USE_ESCAPE_DURING_LOADING;
-
- // character selection menu
- while( InterfaceState == GLOBAL_MENU ) // != GOGOGO_IN_THE_GAME) && (InterfaceState != QUIT_THE_GAME))
- {
- if (ClientCfg.SelectCharacter == -1)
- {
- NLGUI::CDBManager::getInstance()->getDbProp ("UI:CURRENT_SCREEN")->setValue32(0); // 0 == select
- }
- InterfaceState = globalMenu();
- }
-
- // Restore user UI scaling
- CViewRenderer::getInstance()->setInterfaceScale(ClientCfg.InterfaceScale);
-
- // Disable inputs
- Actions.enable(false);
- EditActions.enable(false);
-
-// resetTextContext ("ingame.ttf", true);
- resetTextContext ("ryzom.ttf", true);
-
- if (InterfaceState == GOGOGO_IN_THE_GAME)
- {
- pauseBGDownloader();
- return true;
- }
- if (InterfaceState == QUIT_THE_GAME)
- return false;
- nlassert ((InterfaceState == GOGOGO_IN_THE_GAME) || (InterfaceState == QUIT_THE_GAME));
- return true;
-}
-
-// Automatic connection to the server, the user can't do anything
-// ------------------------------------------------------------------------------------------------
-TInterfaceState autoLogin (const string &cookie, const string &fsaddr, bool firstConnection)
-{
- noUserChar = userChar = false;
- string defaultPort = string(":47851");
- if(!fsaddr.empty())
- {
- // If we have a front end address from command line, use this one
- UsedFSAddr = fsaddr;
- if (UsedFSAddr.find(":") == string::npos)
- {
- UsedFSAddr += defaultPort;
- }
- }
- else
- {
- // Otherwise, use the front end address from configfile
- UsedFSAddr = ClientCfg.FSHost;
- FSAddr = UsedFSAddr; // to be able to do /reconnect
- LoginSM.pushEvent( CLoginStateMachine::ev_skip_all_login );
- if (UsedFSAddr.find(":") == string::npos)
- {
- UsedFSAddr += defaultPort;
- FSAddr += defaultPort; // to be able to do /reconnect
- }
- }
-
- if (firstConnection)
- NetMngr.init (cookie, UsedFSAddr);
-
- // Connection
- if (!ClientCfg.Local/*ace!ClientCfg.Light*/)
- {
- string result;
-
- if (firstConnection)
- {
- NetMngr.connect (result);
-
- if (!result.empty())
- {
- nlerror ("connection : %s.", result.c_str());
- return QUIT_THE_GAME;
- }
-
- // Ok the client is connected
-
- // Set the impulse callback.
- NetMngr.setImpulseCallback (impulseCallBack);
- // Set the database.
- NetMngr.setDataBase (IngameDbMngr.getNodePtr());
-
- // init the string manager cache.
- STRING_MANAGER::CStringManagerClient::instance()->initCache(UsedFSAddr, ClientCfg.LanguageCode);
- }
- }
- else
- {
- CCharacterSummary cs;
- cs.Name = "babar";
- //cs.Surname = "l'elephant";
- cs.People = EGSPD::CPeople::Zorai;
- cs.VisualPropA.PropertySubData.Sex = 0; // Male
-//Deprecated
-// cs.Role = ROLES::range_warrior;
-// cs.Job = JOBS::CasterBuffer;
-// cs.JobLevel = 16;
- CharacterSummaries.push_back(cs);
-
- cs.Name = "yeah";
- //cs.Surname = "zeelot";
- cs.People = EGSPD::CPeople::Matis;
- cs.VisualPropA.PropertySubData.Sex = 1; // Female
-//Deprecated
-// cs.Role = ROLES::buffer_magician;
-// cs.Job = JOBS::CasterHealer;
-// cs.JobLevel = 8;
- CharacterSummaries.push_back(cs);
-
- userChar = true;
- }
-
- WaitServerAnswer = true;
-
- return GLOBAL_MENU;
-}
-
-// ------------------------------------------------------------------------------------------------
-void globalMenuMovieShooter()
-{
-
- if(MovieShooterSaving)
- {
- // Add the buffer frame to the movie.
- if(!MovieShooter.addFrame(TimeInSec, Driver))
- {
- // Fail to add the frame => abort.
- endMovieShooting();
- }
- else
- {
- // Ok, just add a display.
- displaySpecialTextProgress("MovieShooting");
- }
- }
-
-}
-
-// ------------------------------------------------------------------------------------------------
-// Build a valid PlayerName for file Save selection.
-std::string buildPlayerNameForSaveFile(const ucstring &playerNameIn)
-{
- // remove any shard name appended
- ucstring playerName = playerNameIn;
- ucstring::size_type pos = playerNameIn.find('(');
- if(pos!=ucstring::npos && pos>0)
- {
- playerName.resize(pos);
- }
-
- // replace any special ucchar with '_'
- string ret;
- ret.resize(playerName.size());
- for(uint i=0;i='A' && c<='Z') ||
- (c>='a' && c<='z') ||
- (c>='0' && c<='9') ||
- (c=='_') )
- {
- ret[i]= tolower(c);
- }
- else
- ret[i]= '_';
- }
- return ret;
-}
-
-// ------------------------------------------------------------------------------------------------
-class CSoundGlobalMenu
-{
-public:
- CSoundGlobalMenu()
- {
- _MusicWantedAsync= false;
- _NbFrameBeforeChange= NbFrameBeforeChangeMax;
- }
- void setMusic(const string &music, bool async);
- void updateSound();
-private:
- string _MusicPlayed;
- string _MusicWanted;
- bool _MusicWantedAsync;
- sint _NbFrameBeforeChange;
- enum {NbFrameBeforeChangeMax= 10};
-};
-
-void CSoundGlobalMenu::updateSound()
-{
- // **** update the music played
- // The first music played is the music played at loading, before select char
- if(_MusicPlayed.empty())
- _MusicPlayed= toLower(ClientCfg.SoundOutGameMusic);
- if(_MusicWanted.empty())
- _MusicWanted= toLower(ClientCfg.SoundOutGameMusic);
-
- // because music is changed when the player select other race for instance,
- // wait the 3D to load (stall some secs)
-
- // if the wanted music is the same as the one currently playing, just continue playing
- if(_MusicPlayed!=_MusicWanted)
- {
- // wait nbFrameBeforeChangeMax before actually changing the music
- _NbFrameBeforeChange--;
- if(_NbFrameBeforeChange<=0)
- {
- _MusicPlayed= _MusicWanted;
- // play the music
- if (SoundMngr != NULL)
- SoundMngr->playMusic(_MusicPlayed, 500, _MusicWantedAsync, true, true);
- }
- }
-
-
- // **** update mngr
- if (SoundMngr != NULL)
- SoundMngr->update();
-}
-
-void CSoundGlobalMenu::setMusic(const string &music, bool async)
-{
- _MusicWanted= toLower(music);
- _MusicWantedAsync= async;
- // reset the counter
- _NbFrameBeforeChange= NbFrameBeforeChangeMax;
-}
-static CSoundGlobalMenu SoundGlobalMenu;
-
-
-static bool LuaBGDSuccessFlag = true; // tmp, for debug
-
-
-void updateBGDownloaderUI()
-{
- CInterfaceManager *im = CInterfaceManager::getInstance();
- CBGDownloaderAccess &bgDownloader = CBGDownloaderAccess::getInstance();
- bool bgWindowVisible = true;
- if (im->isInGame())
- {
- static NLMISC::CRefPtr bgDownloaderWindow;
- if (!bgDownloaderWindow)
- {
- bgDownloaderWindow = CWidgetManager::getInstance()->getElementFromId("ui:interface:bg_downloader");
- }
- bgWindowVisible = bgDownloaderWindow && bgDownloaderWindow->getActive();
- }
- bool prevSuccess = LuaBGDSuccessFlag;
- if (isBGDownloadEnabled() && PatchBegun)
- {
- if (AvailablePatchs == 0)
- {
- if (LuaBGDSuccessFlag)
- {
- LuaBGDSuccessFlag = CLuaManager::getInstance().executeLuaScript("bgdownloader:setPatchSuccess()");
- }
- }
- else
- {
- switch(bgDownloader.getLastTaskResult())
- {
- case BGDownloader::TaskResult_Unknown:
- {
- float progress = 0.f;
- /*if (bgDownloader.getTotalSize() != 0)
- {
- progress = (float) bgDownloader.getPatchingSize() / bgDownloader.getTotalSize();
- }*/
- if (bgDownloader.getTotalFilesToGet() != 0)
- {
- progress = (bgDownloader.getCurrentFilesToGet() + bgDownloader.getCurrentFileProgress()) / bgDownloader.getTotalFilesToGet();
- }
- if (LuaBGDSuccessFlag && bgWindowVisible)
- {
- LuaBGDSuccessFlag = CLuaManager::getInstance().executeLuaScript(toString("bgdownloader:setPatchProgress(%f)", progress));
- }
- // display current priority of the downloader
- if (LuaBGDSuccessFlag && bgWindowVisible)
- {
- LuaBGDSuccessFlag = CLuaManager::getInstance().executeLuaScript("bgdownloader:displayPriority()");
- }
- }
- break;
- case BGDownloader::TaskResult_Success:
- if (LuaBGDSuccessFlag && bgWindowVisible)
- {
- LuaBGDSuccessFlag = CLuaManager::getInstance().executeLuaScript("bgdownloader:setPatchSuccess()");
- }
- // task finished
- AvailablePatchs = 0;
- if (bgDownloader.getPatchCompletionFlag(true /* clear flag */))
- {
- // when in-game, display a message to signal the end of the patch
- if (im->isInGame())
- {
- im->displaySystemInfo(CI18N::get("uiBGD_InGamePatchCompletion"), "BC");
- }
- }
- break;
- default:
- // error case
- if (LuaBGDSuccessFlag && bgWindowVisible)
- {
- LuaBGDSuccessFlag = CLuaManager::getInstance().executeLuaScript("bgdownloader:setPatchError()");
- }
- break;
- }
- }
- }
- else
- {
- if (LuaBGDSuccessFlag && bgWindowVisible)
- {
- if (isBGDownloadEnabled())
- {
- // no necessary patch for now
- LuaBGDSuccessFlag = CLuaManager::getInstance().executeLuaScript("bgdownloader:setNoNecessaryPatch()");
- }
- else
- {
- // no download ui
- LuaBGDSuccessFlag = CLuaManager::getInstance().executeLuaScript("bgdownloader:setNoDownloader()");
- }
- }
- }
- if (prevSuccess != LuaBGDSuccessFlag)
- {
- nlwarning("Some scipt error occurred");
- }
-}
-
-
-// compute patcher priority, depending on the presence of one or more mainland characters : in this case, give the patch a boost
-void updatePatcherPriorityBasedOnCharacters()
-{
- if (isBGDownloadEnabled())
- {
- if (CBGDownloaderAccess::getInstance().getDownloadThreadPriority() != BGDownloader::ThreadPriority_Paused)
- {
- // choose priority based on available characters :
- bool hasMainlandChar = false;
- for(std::vector::iterator it = CharacterSummaries.begin(); it != CharacterSummaries.end(); ++it)
- {
- if (it->Name.empty()) continue;
- if (!it->InNewbieland)
- {
- hasMainlandChar = true;
- break;
- }
- }
- CBGDownloaderAccess::getInstance().requestDownloadThreadPriority(hasMainlandChar ? BGDownloader::ThreadPriority_Normal : BGDownloader::ThreadPriority_Low, false);
- }
- }
-}
-
-// Launch the interface to choose a character
-// ------------------------------------------------------------------------------------------------
-TInterfaceState globalMenu()
-{
- CLoginProgressPostThread::getInstance().step(CLoginStep(LoginStep_CharacterSelection, "login_step_character_selection"));
-
- CBGDownloaderAccess &bgDownloader = CBGDownloaderAccess::getInstance();
-
- if (isBGDownloadEnabled())
- {
- // If there's a need for mainland download, then proceed
- if (AvailablePatchs & (1 << BGDownloader::DownloadID_MainLand))
- {
- // if a task is already started, then this was a situation where player went back from game to the character selection,
- // so just unpause
- BGDownloader::TTaskResult dummyResult;
- ucstring dummyMessage;
- if (!bgDownloader.isTaskEnded(dummyResult, dummyMessage))
- {
- unpauseBGDownloader();
- }
- }
- }
-
-
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
-
- sint32 nScreenConnecting, nScreenIntro, nScreenServerCrashed;
- fromString(CWidgetManager::getInstance()->getParser()->getDefine("screen_connecting"), nScreenConnecting);
- fromString(CWidgetManager::getInstance()->getParser()->getDefine("screen_intro"), nScreenIntro);
- fromString(CWidgetManager::getInstance()->getParser()->getDefine("screen_crashing"), nScreenServerCrashed);
-
- // SKIP INTRO : Write to the database if we have to skip the intro and write we want to skip further intro to client cfg
- if (ClientCfg.SkipIntro)
- {
- CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:SKIP_INTRO", false);
- if (pNL != NULL)
- pNL->setValue64(1);
- }
-
- TGameCycle serverTick = NetMngr.getCurrentServerTick();
- bool PlayerWantToGoInGame = false;
- bool firewallTimeout = false;
-
- ProgressBar.finish(); // no progress while selecting character
-
- while (PlayerWantToGoInGame == false)
- {
-
- #if defined(NL_OS_WINDOWS) && defined(NL_DEBUG)
- // tmp for debug
- if (::GetAsyncKeyState(VK_SPACE))
- {
- pIM->uninitOutGame();
- pIM->initOutGame();
- CWidgetManager::getInstance()->activateMasterGroup ("ui:outgame", true);
- NLGUI::CDBManager::getInstance()->getDbProp ("UI:CURRENT_SCREEN")->setValue32(2); // TMP TMP
- IngameDbMngr.flushObserverCalls();
- NLGUI::CDBManager::getInstance()->flushObserverCalls();
- CWidgetManager::getInstance()->getElementFromId("ui:outgame:charsel")->setActive(false);
- CWidgetManager::getInstance()->getElementFromId("ui:outgame:charsel")->setActive(true);
- // Active inputs
- Actions.enable(true);
- EditActions.enable(true);
- LuaBGDSuccessFlag = true;
- CWidgetManager::getInstance()->getParser()->reloadAllLuaFileScripts();
- }
- #endif
-
- updateBGDownloaderUI();
-
-
- // Update network.
- try
- {
- if ( ! firewallTimeout )
- NetMngr.update();
- }
- catch (const EBlockedByFirewall&)
- {
- if ( NetMngr.getConnectionState() == CNetManager::Disconnect )
- {
- firewallTimeout = true;
- }
- else
- {
- // Display the firewall alert string
- CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:outgame:connecting:title"));
- if (pVT != NULL)
- pVT->setText(CI18N::get("uiFirewallAlert")+ucstring("..."));
-
- // The mouse and fullscreen mode should be unlocked for the user to set the firewall permission
- nlSleep( 30 ); // 'nice' the client, and prevent to make too many send attempts
- }
-
- }
- IngameDbMngr.flushObserverCalls();
- NLGUI::CDBManager::getInstance()->flushObserverCalls();
-
- // check if we can send another dated block
- if (NetMngr.getCurrentServerTick() != serverTick)
- {
- //
- serverTick = NetMngr.getCurrentServerTick();
- NetMngr.send(serverTick);
- }
- else
- {
- // Send dummy info
- NetMngr.send();
- }
- // Update the DT T0 and T1 global variables
- updateClientTime();
- CInputHandlerManager::getInstance()->pumpEvents();
- Driver->clearBuffers(CRGBA::Black);
- Driver->setMatrixMode2D11();
-
- // Update sound
- SoundGlobalMenu.updateSound();
-
- // Interface handling & displaying (processes clicks...)
- pIM->updateFrameEvents();
- pIM->updateFrameViews(NULL);
- IngameDbMngr.flushObserverCalls();
- NLGUI::CDBManager::getInstance()->flushObserverCalls();
-
- // Movie shooter
- globalMenuMovieShooter();
-
- // Force the client to sleep a bit.
- if(ClientCfg.Sleep >= 0)
- {
- nlSleep(ClientCfg.Sleep);
- }
-
- #if defined(NL_OS_WINDOWS) && defined(NL_DEBUG)
- if (::GetAsyncKeyState(VK_CONTROL))
- {
- pIM->displayUIViewBBoxs("");
- pIM->displayUICtrlBBoxs("");
- pIM->displayUIGroupBBoxs("");
- displayDebugUIUnderMouse();
- }
- #endif
-
- // Display
- Driver->swapBuffers();
-
- // SERVER INTERACTIONS WITH INTERFACE
- if (WaitServerAnswer)
- {
- if (noUserChar || userChar)
- {
-
- if (isBGDownloadEnabled())
- {
- // If there's a need for mainland download, then proceed
- if (AvailablePatchs & (1 << BGDownloader::DownloadID_MainLand))
- {
- // if a task is already started, then this was a situation where player went back from game to the character selection,
- // so just unpause
- BGDownloader::TTaskResult dummyResult;
- ucstring dummyMessage;
- if (bgDownloader.isTaskEnded(dummyResult, dummyMessage))
- {
- // launch mainland patch as a background task
- BGDownloader::CTaskDesc task(BGDownloader::DLState_GetAndApplyPatch,
- (1 << BGDownloader::DownloadID_MainLand));
- bgDownloader.startTask(task, getBGDownloaderCommandLine(), false /* showDownloader */);
-
- // choose priority based on available characters :
- updatePatcherPriorityBasedOnCharacters();
-
- PatchBegun = true;
- }
- }
- }
-
- //nlinfo("impulseCallBack : received userChars list");
- noUserChar = userChar = false;
- if( FarTP.isReselectingChar() || !FarTP.isServerHopInProgress() ) // if doing a Server Hop, expect serverReceivedReady without action from the user
- {
- sint charSelect = -1;
- if (ClientCfg.SelectCharacter != -1)
- charSelect = ClientCfg.SelectCharacter;
-
- if (LoginCharsel != -1)
- charSelect = LoginCharsel;
-
- WaitServerAnswer = false;
- if (charSelect == -1 || FarTP.isReselectingChar())
- {
- CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SERVER_RECEIVED_CHARS", false);
- if (pNL != NULL)
- {
- pNL->setValue64 (1); // Send impulse to interface observers
- IngameDbMngr.flushObserverCalls();
- NLGUI::CDBManager::getInstance()->flushObserverCalls();
- pNL->setValue64 (0);
- IngameDbMngr.flushObserverCalls();
- NLGUI::CDBManager::getInstance()->flushObserverCalls();
- }
- }
- else
- {
- // check that the pre selected character is available
- if (CharacterSummaries[charSelect].People == EGSPD::CPeople::Unknown || charSelect > 4)
- {
- // BAD ! preselected char does not exist, use the first available or fail
- uint i;
- for (i=0; isystemMessageBox("You have no character for the current user.\nClient will exit.", "Char loading error", UDriver::okType, UDriver::exclamationIcon);
- exit(-1);
- }
- else
- {
- UDriver::TMessageBoxId ret = Driver->systemMessageBox("The pre-selected character doesn't exist.\nDo you want to use the first available character instead ?", "Char loading error", UDriver::yesNoType, UDriver::warningIcon);
- if (ret == UDriver::noId)
- exit(-1);
- else
- charSelect = i;
- }
- }
- // Auto-selection for fast launching (dev only)
- CAHManager::getInstance()->runActionHandler("launch_game", NULL, toString("slot=%d|edit_mode=0", charSelect));
-
- if (LoginCharsel == -1)
- ClientCfg.SelectCharacter = charSelect;
- }
-
- }
-
- // Clear sending buffer that may contain prevous QUIT_GAME when getting back to the char selection screen
- NetMngr.flushSendBuffer();
- }
-
- if (CharNameValidArrived)
- {
- //nlinfo("impulseCallBack : received CharNameValidArrived");
- CharNameValidArrived = false;
- WaitServerAnswer = false;
- if (ClientCfg.SelectCharacter == -1)
- {
- CCDBNodeLeaf *pNL;
- pNL = NLGUI::CDBManager::getInstance()->getDbProp(CharNameValidDBLink,false);
- if (pNL != NULL)
- {
- if (CharNameValid)
- pNL->setValue64(1);
- else
- pNL->setValue64(0);
- }
-
- pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SERVER_RECEIVED_VALID", false);
- if (pNL != NULL)
- {
- pNL->setValue64 (1); // Send impulse to interface observers
- IngameDbMngr.flushObserverCalls();
- NLGUI::CDBManager::getInstance()->flushObserverCalls();
- pNL->setValue64 (0);
- IngameDbMngr.flushObserverCalls();
- NLGUI::CDBManager::getInstance()->flushObserverCalls();
- }
- }
- }
-
- if (serverReceivedReady)
- {
- //nlinfo("impulseCallBack : received serverReceivedReady");
- serverReceivedReady = false;
- WaitServerAnswer = false;
- PlayerWantToGoInGame = true;
- }
- }
- else
- {
- noUserChar = false;
- userChar = false;
- CharNameValidArrived = false;
- serverReceivedReady = false;
- }
-
- // Check if server disconnect the client
- if (!ClientCfg.Local)
- {
- if (NetMngr.getConnectionState() == CNetManager::Disconnect)
- {
- // Display the connection failure screen
- CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:CURRENT_SCREEN", false);
- if (pNL != NULL)
- pNL->setValue64 (nScreenServerCrashed);
-
- if ( firewallTimeout )
- {
- // Display the firewall error string instead of the normal failure string
- CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:outgame:crashing:title"));
- if (pVT != NULL)
- {
- pVT->setMultiLine( true );
- pVT->setText(CI18N::get("uiFirewallFail")+ucstring(".\n")+
- CI18N::get("uiFirewallAlert")+ucstring("."));
- }
- }
- }
- }
-
-
-
- // We want to quit the game without playing
- if (game_exit)
- return QUIT_THE_GAME;
- }
-
- if (ClientCfg.SelectCharacter != -1)
- PlayerSelectedSlot = ClientCfg.SelectCharacter;
-
- // Notify the state machine that we're exiting from global menu
- LoginSM.pushEvent(CLoginStateMachine::ev_global_menu_exited);
-
- // Init the current Player Name (for interface.cfg and sentence.name save). Make a good File Name.
- ucstring &playerName= CharacterSummaries[PlayerSelectedSlot].Name;
- PlayerSelectedFileName= buildPlayerNameForSaveFile(playerName);
-
- // Init the current Player Home shard Id and name
- CharacterHomeSessionId = CharacterSummaries[PlayerSelectedSlot].Mainland;
- PlayerSelectedMainland= CharacterSummaries[PlayerSelectedSlot].Mainland;
- PlayerSelectedHomeShardName.clear();
- PlayerSelectedHomeShardNameWithParenthesis.clear();
- for(uint i=0;igetWindowSize(width, height);
- ClientCfg.Width = width;
- ClientCfg.Height = height;
- }
-
- connectionRestoreVideoMode ();
- }
-
- // Skip intro next time
- ClientCfg.writeBool("SkipIntro", true);
-
- // return SELECT_CHARACTER;
- return GOGOGO_IN_THE_GAME;
-}
-
-
-// Init the character selection slot texts from the character summaries
-// ------------------------------------------------------------------------------------------------
-class CAHNetInitCharSel : public IActionHandler
-{
-public:
- virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
- {
- string sPath = getParam(Params, "slottexts");
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- uint i;
- for (i = 0; i < CharacterSummaries.size(); ++i)
- {
- CCharacterSummary &rCS = CharacterSummaries[i];
- CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(sPath+":text"+NLMISC::toString(i));
- CViewText *pVT = dynamic_cast(pIE);
- if (pVT == NULL) return;
-
- if (rCS.Name.empty())
- pVT->setText(CI18N::get("uiEmptySlot"));
- else
- pVT->setText(rCS.Name);
- }
- // 5 slots
- for (; i < 5; ++i)
- {
- CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sPath+":text"+NLMISC::toString(i)));
- if (pVT == NULL) return;
- pVT->setText(CI18N::get("uiEmptySlot"));
- }
- }
-};
-REGISTER_ACTION_HANDLER (CAHNetInitCharSel, "net_init_char_sel");
-
-// ------------------------------------------------------------------------------------------------
-void setTarget(CCtrlBase *ctrl, const string &targetName, ucstring &value)
-{
- std::vector targets;
- // find first enclosing group
- CCtrlBase *currCtrl = ctrl;
- CInterfaceGroup *ig = NULL;
- while (currCtrl)
- {
- ig = dynamic_cast(currCtrl);
- if (ig != NULL) break;
- currCtrl = currCtrl->getParent();
- }
- if (ig)
- {
- CInterfaceExprValue exprValue;
- exprValue.setUCString(value);
-
- CInterfaceLink::splitLinkTargets(targetName, ig, targets);
- for(uint k = 0; k < targets.size(); ++k)
- {
- if (targets[k].Elem) targets[k].affect(exprValue);
- }
- }
-}
-
-// ------------------------------------------------------------------------------------------------
-void setTarget(CCtrlBase *ctrl, const string &targetName, uint32 value)
-{
- std::vector targets;
- // find first enclosing group
- CCtrlBase *currCtrl = ctrl;
- CInterfaceGroup *ig = NULL;
- while (currCtrl)
- {
- ig = dynamic_cast(currCtrl);
- if (ig != NULL) break;
- currCtrl = currCtrl->getParent();
- }
- if (ig)
- {
- CInterfaceExprValue exprValue;
- exprValue.setInteger(value);
-
- CInterfaceLink::splitLinkTargets(targetName, ig, targets);
- for(uint k = 0; k < targets.size(); ++k)
- {
- if (targets[k].Elem) targets[k].affect(exprValue);
- }
- }
-}
-
-// ------------------------------------------------------------------------------------------------
-class CAHGetSlot: public IActionHandler
-{
-public:
- virtual void execute (CCtrlBase *pCaller, const string &Params)
- {
- string sProp = getParam(Params, "prop");
- string sTarget = getParam(Params, "target");
- string sSlot = getParam(Params, "slot");
-
- CInterfaceExprValue result;
- if (!CInterfaceExpr::eval(sSlot, result))
- return;
- uint8 selectedSlot = (uint8)result.getInteger();
- if (selectedSlot >= CharacterSummaries.size())
- return;
-
- PlayerSelectedSlot = selectedSlot;
-
- if (CharacterSummaries[PlayerSelectedSlot].Name.empty())
- return;
-
- ucstring sValue("");
- uint32 nValue = 0;
-
- if (sProp == "name")
- {
- sValue = CharacterSummaries[PlayerSelectedSlot].Name;
- setTarget (pCaller, sTarget, sValue);
- }
-/* else if (sProp == "surname")
-Deprecated {
- sValue = CharacterSummaries[PlayerSelectedSlot].Surname;
- setTarget (pCaller, sTarget, sValue);
- }
-*/ else if (sProp == "title")
- {
- bool womanTitle;
- if( CharacterSummaries[PlayerSelectedSlot].VisualPropA.PropertySubData.Sex == 1 )
- {
- UserEntity->setGender( GSGENDER::female );
- womanTitle = true;
- }
- else
- {
- UserEntity->setGender( GSGENDER::male );
- womanTitle = false;
- }
- string titleStr = CHARACTER_TITLE::toString(CharacterSummaries[PlayerSelectedSlot].Title);
- sValue = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(titleStr, womanTitle);
- {
- // Sometimes translation contains another title
- ucstring::size_type pos = sValue.find('$');
- if (pos != ucstring::npos)
- {
- sValue = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sValue), womanTitle);
- }
- }
- setTarget (pCaller, sTarget, sValue);
- }
-/* else if (sProp == "orient")
-Deprecated {
- sValue = ROLES::roleToUCString(CharacterSummaries[PlayerSelectedSlot].Role);
- setTarget (pCaller, sTarget, sValue);
- }
- else if (sProp == "job")
- {
-//Deprecated
-// sValue = JOBS::jobToUCString(CharacterSummaries[PlayerSelectedSlot].Job);
- sValue = JOBS::jobToUCString(JOBS::BladeBearer);
- setTarget (pCaller, sTarget, sValue);
- }
-*/ else if (sProp == "level")
- {
-//Deprecated
-// sValue = toString(CharacterSummaries[PlayerSelectedSlot].JobLevel);
- sValue = toString(1);
- setTarget (pCaller, sTarget, sValue);
- }
- else if (sProp == "pos")
- {
- nValue = CharacterSummaries[PlayerSelectedSlot].Location;
- setTarget (pCaller, sTarget, nValue);
- }
- }
-};
-REGISTER_ACTION_HANDLER (CAHGetSlot, "get_slot");
-
-
-// Setup the database from a database entry which represents a slot
-// ------------------------------------------------------------------------------------------------
-class CAHSetDBFromSlot : public IActionHandler
-{
-public:
- virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
- {
- string sDBLink = getParam(Params, "dblink");
- string sSlot = getParam(Params, "slot");
-
- CInterfaceExprValue result;
- if (!CInterfaceExpr::eval(sSlot, result))
- return;
-
- PlayerSelectedSlot = (uint8)result.getInteger();
-
- if (PlayerSelectedSlot >= CharacterSummaries.size())
- return;
-
- // Setup the database from the character summary
- CCharacterSummary &rCS = CharacterSummaries[PlayerSelectedSlot];
- if (rCS.Name.empty())
- return;
-
- SCharacter3DSetup::setupDBFromCharacterSummary(sDBLink, rCS);
- }
-};
-REGISTER_ACTION_HANDLER (CAHSetDBFromSlot, "set_db_from_slot");
-
-
-// Reset all the pushed radio button of a group
-// ------------------------------------------------------------------------------------------------
-class CAHResetPushed: public IActionHandler
-{
-public:
- virtual void execute (CCtrlBase *pCaller, const string &Params)
- {
- string sDBLink = getParam(Params, "dblink");
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(pCaller->getId(), sDBLink);
- CInterfaceGroup *pIG = dynamic_cast(pIE);
- if (pIG == NULL) return;
-
- const vector vCB = pIG->getControls();
- for (uint i = 0; i < vCB.size(); ++i)
- {
- CCtrlBaseButton *pBut = dynamic_cast(vCB[i]);
- if (pBut && pBut->getType() == CCtrlBaseButton::RadioButton)
- {
- pBut->setPushed (false);
- }
- }
- }
-};
-REGISTER_ACTION_HANDLER (CAHResetPushed, "reset_pushed");
-
-
-
-
-
-// Launch the game given a slot (slot is reference to the character summaries
-// ------------------------------------------------------------------------------------------------
-class CAHLaunchGame : public IActionHandler
-{
-public:
- virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
- {
- // Get the edit/play mode
- string sEditMode = getParam(Params, "edit_mode");
- bool wantsEditMode = false;
- CInterfaceExprValue result;
- bool wantsNewScenario = false;
-
- if (CInterfaceExpr::eval(sEditMode, result))
- {
- wantsEditMode = (result.getInteger() == 1) || (result.getInteger() == 2);
- wantsNewScenario = (result.getInteger() == 2);
- }
-
- CInterfaceManager *im = CInterfaceManager::getInstance();
- if (wantsEditMode)
- {
- // full patch needed for edition, warn the client
- if (AvailablePatchs != 0)
- {
- if (im->isInGame())
- {
- inGamePatchUncompleteWarning();
- }
- else
- {
- im->messageBoxWithHelp(CI18N::get("uiBGD_FullPatchNeeded"), "ui:outgame");
- }
- return;
- }
- }
-
- // Get the player selected slot
- string sSlot = getParam(Params, "slot");
- if (sSlot != "ingame_auto")
- {
- CInterfaceExprValue result;
- if (!CInterfaceExpr::eval(sSlot, result))
- return;
- PlayerSelectedSlot = (uint8)result.getInteger();
- if (PlayerSelectedSlot >= CharacterSummaries.size())
- return;
-
- ClientCfg.writeInt("SelectedSlot",PlayerSelectedSlot);
- if (ClientCfg.SaveConfig)
- ClientCfg.ConfigFile.save();
- }
-
-
- /*
- static volatile bool isMainlandCharacter = false; // TMP until we can get this info
- if (isMainlandCharacter)
- {
- nlassert(0); // use id="message_box" !!!
- if (AvailablePatchs != 0)
- {
- im->messageBoxWithHelp(CI18N::get("uiBGD_MainlandCharFullPatchNeeded"), "ui:outgame");
- }
- return;
- }
- */
-
-
- // Select the right sheet to create the user character.
- ClientCfg.UserSheet = CharacterSummaries[PlayerSelectedSlot].SheetId.toString();
-
- // If the user wants to enter its editing session, get the ring server to Far TP to.
- if (wantsEditMode)
- {
-
- if (wantsNewScenario)
- {
- CSessionBrowserImpl &sb = CSessionBrowserImpl::getInstance();
- sb.init(NULL);
- sb.closeEditSession(sb.getCharId());
- sb.waitOneMessage(CSessionBrowserImpl::getMessageName("on_invokeResult"));
- }
- if (FarTP.requestFarTPToSession( (TSessionId)0, PlayerSelectedSlot, CFarTP::LaunchEditor, false ))
- {
- WaitServerAnswer = true; // prepare to receive the character messages
- }
-
-// // If the player clicked 'Launch Editor', there was no CONNECTION:SELECT_CHAR sent yet,
-// // so don't wait for the EGS to acknowledge our quit message as he does not know our character
-// LoginSM.pushEvent(CLoginStateMachine::ev_ingame_return);
-
- return;
- }
-
- // Send CONNECTION:SELECT_CHAR
- CBitMemStream out;
- nlverify( GenericMsgHeaderMngr.pushNameToStream ("CONNECTION:SELECT_CHAR", out) );
- //nlinfo("impulseCallBack : CONNECTION:SELECT_CHAR '%d' sent.", PlayerSelectedSlot);
-
-
- CSelectCharMsg SelectCharMsg;
- SelectCharMsg.c = (uint8)PlayerSelectedSlot;
- out.serial (SelectCharMsg);
- if (!ClientCfg.Local/*ace!ClientCfg.Light*/)
- {
- NetMngr.push(out);
- NetMngr.send(NetMngr.getCurrentServerTick());
- }
-
- //PlayerWantToGoInGame = true;
-
-// CBitMemStream out2;
-// if(GenericMsgHeaderMngr.pushNameToStream("CONNECTION:ENTER", out2))
-// {
-// NetMngr.push(out2);
-// nlinfo("impulseCallBack : CONNECTION:ENTER sent");
-// }
-// else
-// nlwarning("unknown message name : 'CONNECTION:ENTER'.");
-
- WaitServerAnswer = true;
- if (ClientCfg.Local)
- serverReceivedReady = true;
- }
-};
-REGISTER_ACTION_HANDLER (CAHLaunchGame, "launch_game");
-
-
-// Ask the server to create a character
-// ------------------------------------------------------------------------------------------------
-class CAHAskCreateChar : public IActionHandler
-{
-public:
- virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
- {
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
-
- // Create the message for the server to create the character.
- CBitMemStream out;
- if (!GenericMsgHeaderMngr.pushNameToStream("CONNECTION:CREATE_CHAR", out))
- {
- nlwarning ("don't know message name CONNECTION:CREATE_CHAR");
- return;
- }
-
- // Setup the name
- string sEditBoxPath = getParam (Params, "name");
- ucstring sFirstName = ucstring("NotSet");
- ucstring sSurName = ucstring("NotSet");
- CGroupEditBox *pGEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sEditBoxPath));
- if (pGEB != NULL)
- sFirstName = pGEB->getInputString();
- else
- nlwarning ("can't get edit box name : %s",sEditBoxPath.c_str());
-
- // Build the character summary from the database branch ui:temp:char3d
- CCharacterSummary CS;
- string sCharSumPath = getParam(Params, "charsum");
- SCharacter3DSetup::setupCharacterSummaryFromDB(CS, sCharSumPath);
- CS.Mainland = MainlandSelected;
- CS.Name = sFirstName;
- //CS.Surname = sSurName;
-
- // Create the message to send to the server from the character summary
- CCreateCharMsg CreateCharMsg;
-
- CreateCharMsg.setupFromCharacterSummary(CS);
-
- // Slot
- {
- string sSlot = getParam(Params, "slot");
-
- CInterfaceExprValue result;
- if (!CInterfaceExpr::eval(sSlot, result))
- return;
-
- CreateCharMsg.Slot = (uint8)result.getInteger();
-
- NLGUI::CDBManager::getInstance()->getDbProp("UI:SELECTED_SLOT")->setValue32(PlayerSelectedSlot);
- }
-
- // Setup the new career
- string sCaracBasePath = getParam (Params, "caracs");
- CreateCharMsg.NbPointFighter = (uint8)NLGUI::CDBManager::getInstance()->getDbProp(sCaracBasePath+"FIGHT")->getValue32();
- CreateCharMsg.NbPointCaster = (uint8)NLGUI::CDBManager::getInstance()->getDbProp(sCaracBasePath+"MAGIC")->getValue32();
- CreateCharMsg.NbPointCrafter = (uint8)NLGUI::CDBManager::getInstance()->getDbProp(sCaracBasePath+"CRAFT")->getValue32();
- CreateCharMsg.NbPointHarvester = (uint8)NLGUI::CDBManager::getInstance()->getDbProp(sCaracBasePath+"FORAGE")->getValue32();
-
- // Setup starting point
- string sLocationPath = getParam(Params, "loc");
- {
- CreateCharMsg.StartPoint = RYZOM_STARTING_POINT::borea;
-
- CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp (sLocationPath, false);
- if (pNL != NULL)
- CreateCharMsg.StartPoint = (RYZOM_STARTING_POINT::TStartPoint)(pNL->getValue64());
- else
- nlwarning(("Can't read starting point from the database : " + sLocationPath).c_str());
-
- if (CS.People == EGSPD::CPeople::Fyros)
- CreateCharMsg.StartPoint= (RYZOM_STARTING_POINT::TStartPoint)(((uint8)CreateCharMsg.StartPoint) + ((uint8)RYZOM_STARTING_POINT::fyros_start));
- else if (CS.People == EGSPD::CPeople::Matis)
- CreateCharMsg.StartPoint= (RYZOM_STARTING_POINT::TStartPoint)(((uint8)CreateCharMsg.StartPoint) + ((uint8)RYZOM_STARTING_POINT::matis_start));
- else if (CS.People == EGSPD::CPeople::Tryker)
- CreateCharMsg.StartPoint= (RYZOM_STARTING_POINT::TStartPoint)(((uint8)CreateCharMsg.StartPoint) + ((uint8)RYZOM_STARTING_POINT::tryker_start));
- else // if (CS.People == EGSPD::CPeople::Zorai)
- CreateCharMsg.StartPoint= (RYZOM_STARTING_POINT::TStartPoint)(((uint8)CreateCharMsg.StartPoint) + ((uint8)RYZOM_STARTING_POINT::zorai_start));
-
- }
-
- // Send the message to the server
- CreateCharMsg.serialBitMemStream (out);
- if (!ClientCfg.Local/*!ClientCfg.Light*/)
- {
- noUserChar = userChar = false;
-
- NetMngr.push(out);
- NetMngr.send(NetMngr.getCurrentServerTick());
-
- //nlinfo("impulseCallBack : CONNECTION:CREATE_CHAR sent");
- CreateCharMsg.dump();
- }
- else
- {
- userChar = true;
- if (CharacterSummaries.size() < 5)
- CharacterSummaries.push_back(CS);
- }
- WaitServerAnswer = true;
- }
-};
-REGISTER_ACTION_HANDLER (CAHAskCreateChar, "ask_create_char");
-
-
-
-// Ask the server to delete a character
-// ------------------------------------------------------------------------------------------------
-class CAHAskDeleteChar : public IActionHandler
-{
-public:
- virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
- {
- // Create the message for the server to create the character.
- CBitMemStream out;
- if (!GenericMsgHeaderMngr.pushNameToStream("CONNECTION:DELETE_CHAR", out))
- {
- nlwarning ("don't know message name CONNECTION:DELETE_CHAR");
- return;
- }
-
- // Get the selected slot
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
-
- string sSlot = getParam(Params, "slot");
-
- CInterfaceExprValue result;
- if (!CInterfaceExpr::eval(sSlot, result))
- return;
-
- uint8 nSelectedSlot = (uint8)result.getInteger();
- if (nSelectedSlot >= CharacterSummaries.size())
- return;
-
- out.serial (nSelectedSlot);
-
- // Yoyo: delete the Local files. To avoid problem if recreate a character with same name.
- ucstring &playerName= CharacterSummaries[nSelectedSlot].Name;
- string playerDeletedFileName= buildPlayerNameForSaveFile(playerName);
- // Delete the 2 Local files
- pIM->deletePlayerConfig(playerDeletedFileName);
- pIM->deletePlayerKeys(playerDeletedFileName);
-
- // Send the message to the server
- if (!ClientCfg.Local/*ace!ClientCfg.Light*/)
- {
- noUserChar = userChar = false;
- NetMngr.push(out);
- NetMngr.send(NetMngr.getCurrentServerTick());
-
- //nlinfo("impulseCallBack : CONNECTION:DELETE_CHAR %d sent", nSelectedSlot);
- }
- else
- {
- if (nSelectedSlot < CharacterSummaries.size())
- CharacterSummaries.erase (CharacterSummaries.begin()+nSelectedSlot);
- if (CharacterSummaries.size() != 0)
- userChar = true;
- else
- noUserChar = true;
- }
- WaitServerAnswer = true;
- }
-};
-REGISTER_ACTION_HANDLER (CAHAskDeleteChar, "ask_delete_char");
-
-// ------------------------------------------------------------------------------------------------
-string getTarget(CCtrlBase * /* ctrl */, const string &targetName)
-{
- string sTmp = targetName;
- std::vector targetsVector;
- CInterfaceLink::splitLinkTargets(sTmp, NULL, targetsVector);
-
- CInterfaceLink::CTargetInfo &rTI = targetsVector[0];
-
- CInterfaceElement *elem = rTI.Elem;
- if (!elem)
- {
- nlwarning(" : Element is NULL");
- return "";
- }
- const CReflectedProperty *pRP = CReflectSystem ::getProperty(elem->getReflectedClassName(), rTI.PropertyName);
-
- if (pRP->Type == CReflectedProperty::String)
- return ((elem->*(pRP->GetMethod.GetString))());
- return "";
-}
-
-// ------------------------------------------------------------------------------------------------
-ucstring getUCTarget(CCtrlBase * /* ctrl */, const string &targetName)
-{
- string sTmp = targetName;
- std::vector targetsVector;
- CInterfaceLink::splitLinkTargets(sTmp, NULL, targetsVector);
-
- CInterfaceLink::CTargetInfo &rTI = targetsVector[0];
-
- CInterfaceElement *elem = rTI.Elem;
- if (!elem)
- {
- nlwarning(" : Element is NULL");
- return ucstring("");
- }
- const CReflectedProperty *pRP = elem->getReflectedProperty(rTI.PropertyName);
-
- if (pRP->Type == CReflectedProperty::UCString)
- return ((elem->*(pRP->GetMethod.GetUCString))());
- return ucstring("");
-}
-
-/*// Ask the server to rename a character
-// ------------------------------------------------------------------------------------------------
-class CAHAskRenameChar : public IActionHandler
-{
-public:
- virtual void execute (CCtrlBase *pCaller, const string &Params)
- {
- string sName = getTarget(NULL,getParam(Params, "name"));
- string sSurname = getTarget(NULL,getParam(Params, "surname"));
-
- string sDBSlot = getParam(Params, "dbslot");
-
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- uint8 nSelectedSlot = (uint8)NLGUI::CDBManager::getInstance()->getDbProp(sDBSlot,false)->getValue32();
-
- if (nSelectedSlot > CharacterSummaries.size())
- return;
-
- // Create the message for the server to create the character.
- CBitMemStream out;
- if (!GenericMsgHeaderMngr.pushNameToStream("CONNECTION:RENAME_CHAR", out))
- {
- nlwarning ("don't know message name CONNECTION:RENAME_CHAR");
- return;
- }
-
- // Get the selected slot
- out.serial (nSelectedSlot);
- out.serial (sName);
- out.serial (sSurname);
-
- // Send the message to the server
- if (!ClientCfg.Light)
- {
- noUserChar = userChar = false;
- NetMngr.push (out);
- NetMngr.send (NetMngr.getCurrentServerTick());
-
- nldebug("impulseCallBack : CONNECTION:RENAME_CHAR sent");
-
- // Wait for the character message which describe all the characters on a server
- while (!noUserChar && !userChar)
- {
- //NetMngr.waitForServer();
- NetMngr.update();
- NetMngr.send();
- nlSleep(100);
- }
- }
- else
- {
- CharacterSummaries[nSelectedSlot].FirstName = sName;
- CharacterSummaries[nSelectedSlot].Surname = sSurname;
- }
- }
-};
-REGISTER_ACTION_HANDLER (CAHAskRenameChar, "ask_rename_char");
-*/
-
-// Ask the server if the name is not already used
-// ------------------------------------------------------------------------------------------------
-class CAHAskValidName : public IActionHandler
-{
-public:
- virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
- {
- string sTarget = getParam(Params, "target");
- string sDBLink = getParam(Params, "dblink");
- CharNameValidDBLink = sDBLink;
-
- ucstring sName = getUCTarget(NULL,sTarget);
-
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- if (sName.empty())
- {
- NLGUI::CDBManager::getInstance()->getDbProp(sDBLink,false)->setValue32(0);
- return;
- }
-
- // Ask the server
- CharNameValid = true;
-
- // PATCH DU BUG DE L'ESPACE !!!
- if (sName.find(' ') != ucstring::npos)
- CharNameValid = false;
- // PATCH DU BUG DE L'ESPACE !!!
-
-
- if (CharNameValid)
- {
- if (!ClientCfg.Local/*ace!ClientCfg.Light*/)
- {
-
- CBitMemStream out;
- if (!GenericMsgHeaderMngr.pushNameToStream("CONNECTION:ASK_NAME", out))
- {
- nlwarning ("don't know message name CONNECTION:ASK_NAME");
- return;
- }
-
- CCheckNameMsg checkNameMsg;
- checkNameMsg.Name = sName;
- checkNameMsg.HomeSessionId = MainlandSelected;
- checkNameMsg.serialBitMemStream(out);
-
- NewKeysCharNameWanted = sName;
- // append shard name
- for(uint k = 0; k < Mainlands.size(); ++k)
- {
- if (Mainlands[k].Id == MainlandSelected)
- {
- // extract name from mainland
- /*ucstring::size_type first = Mainlands[k].Name.find('(');
- ucstring::size_type last = Mainlands[k].Name.find(')');
- if (first != ucstring::npos && last != ucstring::npos && first < last)
- {
- NewKeysCharNameWanted += Mainlands[k].Name.substr(first, last - first + 1);
- }*/
- NewKeysCharNameWanted += ('(' + Mainlands[k].Name + ')');
- break;
- }
- }
-
- NewKeysCharNameValidated.clear();
-
- NetMngr.push(out);
- NetMngr.send(NetMngr.getCurrentServerTick());
-
- //nlinfo("impulseCallBack : CONNECTION:ASK_NAME sent");
-
- // Wait for the valid character name message
- CharNameValidArrived = false;
- }
- else
- {
-
- CharNameValid = true;
- CharNameValidArrived = true;
-
- for (uint i = 0; i < CharacterSummaries.size(); ++i)
- {
- ucstring ls = CharacterSummaries[i].Name.toString();
- if (ls == sName)
- CharNameValid = false;
- }
- }
- }
- else
- {
- CharNameValidArrived = true;
- }
- WaitServerAnswer = true;
- }
-};
-REGISTER_ACTION_HANDLER (CAHAskValidName, "ask_valid_name");
-
-// ------------------------------------------------------------------------------------------------
-class CAHPlaySound : public IActionHandler
-{
-public:
- virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
- {
- string sName = getParam(Params, "name");
- TStringId id = CStringMapper::map(sName);
- if (SoundMngr != NULL)
- SoundMngr->spawnSource(id,CVector(0,0,0));
- }
-};
-REGISTER_ACTION_HANDLER (CAHPlaySound, "play_sound");
-
-// ------------------------------------------------------------------------------------------------
-class CAHPlayMusicOutgame : public IActionHandler
-{
-public:
- virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
- {
- // get the name of the wanted music
- string sName = getParam(Params, "name");
- bool async;
- fromString(getParam(Params, "async"), async);
-
- // if empty name, return to default mode
- if(sName.empty())
- sName= ClientCfg.SoundOutGameMusic;
-
- // change the music
- SoundGlobalMenu.setMusic(sName, async);
- }
-};
-REGISTER_ACTION_HANDLER (CAHPlayMusicOutgame, "play_music_outgame");
-
-// ------------------------------------------------------------------------------------------------
-class CAHRepeatUntil : public IActionHandler
-{
-public:
- virtual void execute (CCtrlBase *pCaller, const string &Params)
- {
- string sProc = getParam(Params, "proc");
- string sCond = getParam(Params, "cond");
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
-
- for(;;)
- {
- vector p;
- p.push_back(sProc);
- CWidgetManager::getInstance()->runProcedure(sProc, pCaller, p);
-
- CInterfaceExprValue result;
- if (CInterfaceExpr::eval(sCond, result))
- {
- if (result.getBool())
- break;
- }
- else
- {
- break;
- }
- }
-
- }
-};
-REGISTER_ACTION_HANDLER (CAHRepeatUntil, "repeatuntil");
-
-
-// ------------------------------------------------------------------------------------------------
-class CAHDispInfo : public IActionHandler
-{
-public:
- virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
- {
- string sStr = getParam(Params, "str");
- string sVal = getParam(Params, "val");
-
- string res;
-
- CInterfaceExprValue result;
- if (CInterfaceExpr::eval(sStr, result))
- {
- if (result.toString())
- {
- res += result.getString();
- }
- }
- if (CInterfaceExpr::eval(sVal, result))
- {
- if (result.toString())
- {
- res += result.getString();
- }
- }
-
- nlinfo(res.c_str());
- }
-};
-REGISTER_ACTION_HANDLER (CAHDispInfo, "disp_info");
-
-
-// ***************************************************************************
-class CAHInitMainlandList : public IActionHandler
-{
-public:
-
- virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
- {
- //CInterfaceManager *pIM = CInterfaceManager::getInstance();
-
- CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND));
- if (pList == NULL)
- {
- nlwarning("element " GROUP_LIST_MAINLAND " not found probably bad outgame.xml");
- return;
- }
-
- CInterfaceGroup *pPrevLine = NULL;
- for(uint i = 0; i < Mainlands.size(); i++)
- {
- vector< pair < string, string > > params;
- params.clear();
- params.push_back(pair("id", toString(Mainlands[i].Id)));
- if (i>0)
- params.push_back(pair("posref", "BL TL"));
-
- CInterfaceGroup *pNewLine = CWidgetManager::getInstance()->getParser()->createGroupInstance("t_mainland", GROUP_LIST_MAINLAND, params);
- if (pNewLine != NULL)
- {
- CViewBase *pVBon = pNewLine->getView("online");
- CViewBase *pVBoff = pNewLine->getView("offline");
- if ((pVBon != NULL) && (pVBoff != NULL))
- {
- pVBon->setActive(Mainlands[i].Online);
- pVBoff->setActive(!Mainlands[i].Online);
- }
-
- CViewText *pVT = dynamic_cast(pNewLine->getView("name"));
- if (pVT != NULL)
- {
- ucstring ucstr = Mainlands[i].Name + ucstring(" ") + Mainlands[i].Description;
- pVT->setText(ucstr);
- }
-
- // Add to the list
- pNewLine->setParent(pList);
- pNewLine->setParentSize(pList);
- pNewLine->setParentPos(pPrevLine);
- pList->addGroup(pNewLine);
-
- pPrevLine = pNewLine;
- }
- }
- // UI Patch
- if (!Mainlands.empty())
- {
- //choose default mainland from language code
- uint32 defaultMainland = 0;
- for(uint i = 0; i < Mainlands.size(); i++)
- {
- if( Mainlands[i].LanguageCode == ClientCfg.LanguageCode )
- {
- defaultMainland = i;
- break;
- }
- }
-
- CCtrlButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND ":"+toString(Mainlands[defaultMainland].Id)+":but"));
- if (pCB != NULL)
- {
- pCB->setPushed(true);
- CAHManager::getInstance()->runActionHandler (pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick());
- }
- }
- pList->invalidateCoords();
- }
-};
-REGISTER_ACTION_HANDLER (CAHInitMainlandList, "init_mainland_list");
-
-
-// ***************************************************************************
-class CAHResetMainlandList : public IActionHandler
-{
-public:
-
- virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
- {
- //CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND));
- pList->clearGroups();
- }
-};
-REGISTER_ACTION_HANDLER (CAHResetMainlandList, "reset_mainland_list");
-
-
-// ***************************************************************************
-class CAHMainlandSelect : public IActionHandler
-{
- virtual void execute (CCtrlBase *pCaller, const std::string &Params)
- {
- //nlinfo("CAHMainlandSelect called");
- struct CUnpush : public CInterfaceElementVisitor
- {
- CCtrlBase *Ref;
- virtual void visitCtrl(CCtrlBase *ctrl)
- {
- if (ctrl == Ref) return;
- CCtrlBaseButton *but = dynamic_cast(ctrl);
- if (but)
- {
- but->setPushed(false);
- }
- }
- };
- CInterfaceGroup *list = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND));
- if (!list)
- return;
-
- // unselect
- if (Params.empty())
- {
- CUnpush unpusher;
- unpusher.Ref = pCaller;
- list->visit(&unpusher);
- }
-
- // now select
- uint32 mainland;
- if (Params.empty())
- {
- CCtrlButton *pCB = dynamic_cast(pCaller);
- if (!pCB)
- return;
-
- std::string name = pCB->getId();
- name = name.substr(0, name.rfind(':'));
-
- if (!fromString(name.substr(name.rfind(':')+1, name.size()), mainland))
- return;
-
- pCB->setPushed(true);
- }
- else
- if (!fromString(Params, mainland))
- return;
-
- // and store
- MainlandSelected = (TSessionId)mainland;
- }
-};
-REGISTER_ACTION_HANDLER (CAHMainlandSelect, "mainland_select");
-
-
-// ***************************************************************************
-class CAHInitKeysetList : public IActionHandler
-{
-public:
-
-
-
- CInterfaceGroup *PrevLine;
- CInterfaceGroup *List;
- bool First;
-
- CInterfaceGroup *buildTemplate(const std::string &templateName, const std::string &id)
- {
- vector< pair < string, string > > params;
- params.clear();
- params.push_back(pair("id", id));
- if (!First)
- {
- params.push_back(pair("posref", "BL TL"));
- }
- First = false;
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- return CWidgetManager::getInstance()->getParser()->createGroupInstance(templateName, GROUP_LIST_KEYSET, params);
- }
-
- void addGroupInList(CInterfaceGroup *pNewLine)
- {
- if (!pNewLine) return;
- // Add to the list
- pNewLine->setParent(List);
- pNewLine->setParentSize(List);
- pNewLine->setParentPos(PrevLine);
- List->addGroup(pNewLine);
-
- PrevLine = pNewLine;
- }
-
- void addSeparator()
- {
- addGroupInList(buildTemplate("t_keyseparator", ""));
- }
-
- // add a new keyset in the list
- void addKeySet(const std::string &filename, const ucstring &name, const ucstring tooltip)
- {
- nlassert(List);
- CInterfaceGroup *pNewLine = buildTemplate("t_keyset", toString(filename));
- if (pNewLine != NULL)
- {
- CViewText *pVT = dynamic_cast(pNewLine->getView("name"));
- if (pVT != NULL)
- {
- pVT->setText(name);
- }
-
- CCtrlBase *pBut = pNewLine->getCtrl("but");
- if (pBut != NULL)
- {
- pBut->setDefaultContextHelp(tooltip);
- }
- addGroupInList(pNewLine);
- }
- }
-
- virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
- {
- NewKeysCharNameWanted.clear();
- NewKeysCharNameValidated.clear();
- GameKeySet = "keys.xml";
- RingEditorKeySet = "keys_r2ed.xml";
- First = true;
- PrevLine = NULL;
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
-
- List = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET));
- if (List == NULL)
- {
- nlwarning("element " GROUP_LIST_KEYSET " not found probably bad outgame.xml");
- return;
- }
-
- // built-in keysets
- CConfigFile::CVar *keySetVar = ClientCfg.ConfigFile.getVarPtr(KeySetVarName);
- sint wasdIndex = -1;
- sint zqsdIndex = -1;
- if (keySetVar && keySetVar->size() != 0)
- {
- for (uint k = 0; k < keySetVar->size(); ++k)
- {
- if (keySetVar->asString(k) == "zqsd") zqsdIndex = (sint) k;
- if (keySetVar->asString(k) == "wasd") wasdIndex = (sint) k;
-
- std::string strId = "uiCP_KeysetName_" + keySetVar->asString(k);
- strFindReplace(strId, ".", "_");
- ucstring keySetName = CI18N::get(strId);
- strId = "uiCP_KeysetTooltip_" + keySetVar->asString(k);
- strFindReplace(strId, ".", "_");
- if (CI18N::hasTranslation(strId))
- {
- ucstring keySetTooltip = CI18N::get(strId);
- addKeySet(keySetVar->asString(k), keySetName, keySetTooltip);
- }
- }
- }
- else
- {
- nlwarning("'%s' var not found in config file, or list is empty, proposing default keyset only", KeySetVarName);
- std::string defaultKeySet = "keys";
- ucstring keySetName = CI18N::get("uiCP_KeysetName_" + defaultKeySet);
- ucstring keySetTooltip = CI18N::get("uiCP_KeysetTooltip_" + defaultKeySet);
- addKeySet(defaultKeySet, keySetName, keySetTooltip);
- }
-
- // keyset from previous chars
- std::vector savedFiles;
- CPath::getPathContent("save/", false, false, true, savedFiles);
- enum { GameKeys = 0x1, EditorKeys = 0x2 };
- typedef std::map TKeySetFileMap;
- TKeySetFileMap keySetFiles; // combination of 'GameKeys' & 'EditorKeys' flag for each character
- for (uint k = 0; k < savedFiles.size(); ++k)
- {
- if (testWildCard(CFile::getFilename(savedFiles[k]), "keys_*.xml"))
- {
- bool editorKeys = testWildCard(CFile::getFilename(savedFiles[k]), "keys_r2ed_*.xml");
- std::string baseName = CFile::getFilenameWithoutExtension(savedFiles[k]).substr(strlen(editorKeys ? "keys_r2ed_" : "keys_"));
- if(!keySetFiles.count(baseName)) keySetFiles[baseName] = 0;
- keySetFiles[baseName] |= editorKeys ? EditorKeys : GameKeys;
- }
- }
- //
- bool separatorAdded = false;
- if (!keySetFiles.empty())
- {
- for(TKeySetFileMap::iterator it = keySetFiles.begin(); it != keySetFiles.end(); ++it)
- {
- ucstring name;
- if (ClientCfg.Local)
- {
- name = ucstring(it->first);
- }
- else
- {
- // search matching ucstring name from character summaries
- for (uint k = 0; k < CharacterSummaries.size(); ++k)
- {
- if (it->first == buildPlayerNameForSaveFile(CharacterSummaries[k].Name))
- {
- name = CharacterSummaries[k].Name;
- }
- }
- }
- if (!name.empty())
- {
- if (!separatorAdded)
- {
- addSeparator();
- separatorAdded = true;
- }
- addKeySet(it->first, ucstring(it->first), CI18N::get(std::string("uiCP_KeysetImport") + (it->second & GameKeys ? "_Game" : "")
- + (it->second & EditorKeys ? "_Editor" : "")));
- }
- }
- }
-
- // default to 'ZQSD' for French and Belgian keyboard, 'WASD' else
- bool wasd = !CSystemUtils::isAzertyKeyboard();
-
- /*sint startIndex = wasd ? wasdIndex : zqsdIndex;
- if (startIndex == -1) startIndex = 0;
- */
- // TMP TMP : no way to have 2 keys for the same action for now -> default to 'arrows' setting.
- sint startIndex = 0;
- nlassert(startIndex >= 0);
- if (startIndex < (sint) List->getNumGroup())
- {
- CInterfaceGroup *gr = dynamic_cast(List->getGroup(startIndex));
- if (gr)
- {
- CCtrlButton *pCB = dynamic_cast(gr->getCtrl("but"));
- if (pCB != NULL)
- {
- pCB->setPushed(true);
- CAHManager::getInstance()->runActionHandler (pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick());
- }
- }
- }
- List->invalidateCoords();
- }
-};
-REGISTER_ACTION_HANDLER (CAHInitKeysetList, "init_keyset_list");
-
-
-// ***************************************************************************
-class CAHResetKeysetList : public IActionHandler
-{
-public:
-
- virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
- {
- //CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET));
- pList->clearGroups();
- }
-};
-REGISTER_ACTION_HANDLER (CAHResetKeysetList, "reset_keyset_list");
-
-
-// ***************************************************************************
-class CAHResetKeysetSelect : public IActionHandler
-{
- std::string getIdPostFix(const std::string fullId)
- {
- std::string::size_type pos = fullId.find_last_of(":");
- if (pos != std::string::npos)
- return fullId.substr(pos + 1);
-
- return "";
- }
-
- virtual void execute(CCtrlBase *pCaller, const std::string &Params)
- {
- // 'unpush' all groups but the caller
- struct CUnpush : public CInterfaceElementVisitor
- {
- CCtrlBase *Ref;
- virtual void visitCtrl(CCtrlBase *ctrl)
- {
- if (ctrl == Ref) return;
- CCtrlBaseButton *but = dynamic_cast(ctrl);
- if (but)
- {
- but->setPushed(false);
- }
- }
- };
- CInterfaceGroup *list = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET));
- if (!list)
- return;
-
- // unselect
- CUnpush unpusher;
- unpusher.Ref = pCaller;
- list->visit(&unpusher);
-
- // now select
- CCtrlBaseButton *but = dynamic_cast(pCaller);
- if (but)
- but->setPushed(true);
-
- std::string id;
- if (Params.empty())
- {
- if (!pCaller) return;
- if (!pCaller->getParent()) return;
-
- id = getIdPostFix(pCaller->getParent()->getId());
- }
- else
- id = getIdPostFix(Params);
-
- GameKeySet = "keys.xml";
- RingEditorKeySet = "keys_r2ed.xml";
-
- // compute the two filenames from the id
- // if id is in the built-in keysets
- CConfigFile::CVar *keySetVar = ClientCfg.ConfigFile.getVarPtr(KeySetVarName);
- if (keySetVar && keySetVar->size() > 0)
- {
- for (uint k = 0; k < keySetVar->size(); ++k)
- {
- if (keySetVar->asString(k) == id)
- {
- GameKeySet = "keys" + string(id.empty() ? "" : "_") + id + ".xml";
- RingEditorKeySet = "keys_r2ed" + string(id.empty() ? "" : "_") + id + ".xml";
- return;
- }
- }
- }
-
- // else maybe from a previous character?
- if (CFile::isExists("save/keys_" + id + ".xml"))
- GameKeySet = "keys_" + id + ".xml";
-
- if (CFile::isExists("save/keys_r2ed_" + id + ".xml"))
- RingEditorKeySet = "keys_r2ed_" + id + ".xml";
-
- // NB: key file will be copied for real when the new character summary is
- }
-};
-REGISTER_ACTION_HANDLER (CAHResetKeysetSelect, "keyset_select");
-
-
-
-
-
-// *************************** SCENARIO CONTROL WINDOW ***********************
-// ***************************************************************************
-// helper function for "setScenarioInformation"
-static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName, const ucstring &text)
-{
- CInterfaceElement *result = scenarioWnd->findFromShortId(uiName);
- if(result)
- {
- CViewText* viewText = dynamic_cast(result);
- if(viewText)
- viewText->setText(text);
- CGroupEditBox* editBox = dynamic_cast(result);
- if(editBox)
- editBox->setInputString(text);
-
- }
-}
-// helper function for "setScenarioInformation"
-static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName, const std::string &utf8Text)
-{
- ucstring ucText;
- ucText.fromUtf8(utf8Text);
- setTextField(scenarioWnd, uiName, ucText);
-}
-// helper function for "setScenarioInformation"
-static std::string fieldLookup(const vector< pair< string, string > > &values, const std::string &id)
-{
- for(uint i=0; i > values;
- if(R2::getEditor().isInitialized())
- {
- values = R2::getEditor().getDMC().getEditionModule().getScenarioHeader();
- }
- else
- {
- R2::CScenarioValidator sv;
- std::string md5, signature;
- sv.setScenarioToLoad(scenarioName, values, md5, signature, false);
- }
- //
- setTextField(scenarioWnd, "rules_value_text", fieldLookup(values, "Rules"));
- uint levelRange = 0;
- uint32 nLevel;
- fromString(fieldLookup(values, "Level"), nLevel);
- switch(nLevel)
- {
- case 20: levelRange = 0; break;
- case 50: levelRange = 1; break;
- case 100: levelRange = 2; break;
- case 150: levelRange = 3; break;
- case 200: levelRange = 4; break;
- case 250: levelRange = 5; break;
- }
- setTextField(scenarioWnd, "level_value_text", CI18N::get("uiRAP_Level" + toString(levelRange)));
- setTextField(scenarioWnd, "language_value_text", CI18N::get("uiR2ED" + fieldLookup(values, "Language")));
- setTextField(scenarioWnd, "type_value_text", CI18N::get("uiR2ED" + fieldLookup(values, "Type")));
- setTextField(scenarioWnd, "edit_small_description", fieldLookup(values, "ShortDescription"));
- if(R2::getEditor().isInitialized())
- {
- setTextField(scenarioWnd, "scenario_value_text", "'" + fieldLookup(values, "Title") + "'");
- }
-}
-
-
-void getChildrenControls(CInterfaceGroup* group, std::vector & controls)
-{
- for(uint i=0; igetGroups().size(); i++)
- getChildrenControls(group->getGroups()[i], controls);
-
- for(uint i=0; igetControls().size(); i++)
- controls.push_back(group->getControls()[i]);
-}
-
-inline void setToggleButton(CInterfaceGroup* scenarioWnd, const string & buttonName, bool pushed)
-{
- CInterfaceElement * result = scenarioWnd->findFromShortId(buttonName);
- if(result)
- {
- CInterfaceGroup * group = dynamic_cast(result);
- if(group)
- {
- result = group->findFromShortId(string("toggle_butt"));
- if(result)
- {
- CCtrlBaseButton * baseButton = dynamic_cast(result);
- if(baseButton)
- baseButton->setPushed(!pushed);
- }
- }
- }
-}
-
-
-class CAHScenarioControl : public IActionHandler
-{
- virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
- {
- nlinfo("CAHScenarioControl called");
-
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CInterfaceGroup* scenarioWnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_scenario_control"));
- if(!scenarioWnd) return;
-
- // -------- active some groups in function of Ryzom mode or Edition/Animation mode ----
- // active team toggle button?
- CInterfaceElement *result = scenarioWnd->findFromShortId(string("invite_team"));
- if(result)
- {
- CInterfaceGroup* groupTeam = dynamic_cast(result);
- if(groupTeam)
- {
- bool team = !(R2::getEditor().isInitialized());
- if(team)
- team = (NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:TEAM_MEMBER")->getValue8())!=0;
- groupTeam->setActive(team);
- }
- }
-
- // set scenario name label
- result = scenarioWnd->findFromShortId(string("current_scenario_label_text"));
- if(result)
- {
- CViewText* viewText = dynamic_cast(result);
- if(viewText)
- {
- viewText->setText(R2::getEditor().isInitialized()?CI18N::get("uiR2EDScenarioName"):CI18N::get("uiR2EDScenarioFileName"));
- }
- }
-
- // ok button tranlation
- result = scenarioWnd->findFromShortId(string("ok_button"));
- if(result)
- {
- CCtrlTextButton* okButton = dynamic_cast(result);
- if(okButton)
- {
- if(R2::getEditor().getAccessMode()!=R2::CEditor::AccessDM)
- okButton->setHardText(CI18N::get("uiR2EDLaunchScenario").toString());
- else
- okButton->setHardText(CI18N::get("uiR2EDApplyScenarioFilters").toString());
- }
- }
-
- // init current scenario name and parameters
- if(!R2::getEditor().isInitialized())
- {
- ScenarioFileName.clear();
-
- // empty scenario
- CInterfaceElement *result = scenarioWnd->findFromShortId(string("scenario_value_text"));
- if(result)
- {
- CViewText* viewText= dynamic_cast(result);
-
- if(viewText)
- viewText->setText(ucstring(""));
- }
- }
- setScenarioInformation(scenarioWnd, "");
-
- // hide description and information?
- result = scenarioWnd->findFromShortId(string("scenario_info_prop"));
- if(result)
- result->setActive(R2::getEditor().isInitialized());
-
- result = scenarioWnd->findFromShortId(string("description_gr"));
- if(result)
- result->setActive(R2::getEditor().isInitialized());
-
- // mainlands list
- result = scenarioWnd->findFromShortId(string("shards"));
- if(result)
- {
- CGroupList * shardList = dynamic_cast(result);
- if(shardList)
- {
- shardList->deleteAllChildren();
-
- for(uint i = 0; i < Mainlands.size(); i++)
- {
- vector< pair < string, string > > params;
- params.clear();
- params.push_back(pair("id", toString(Mainlands[i].Id)));
- params.push_back(pair("w", "1024"));
- params.push_back(pair("tooltip", "uiRingFilterShard"));
- CInterfaceGroup *toggleGr = CWidgetManager::getInstance()->getParser()->createGroupInstance("label_toggle_button", shardList->getId(), params);
- shardList->addChild(toggleGr);
- // set unicode name
- CViewText *shardName = dynamic_cast(toggleGr->getView("button_text"));
- if (shardName)
- {
- shardName->setText(Mainlands[i].Name);
- }
- }
- }
- }
-
- // show/display "back" button
- result = scenarioWnd->findFromShortId(string("load_button"));
- if(result)
- {
- CCtrlBaseButton * loadB = dynamic_cast(result);
- if(loadB)
- {
- loadB->setActive(!R2::getEditor().isInitialized());
- }
- }
-
- // fill toggle buttons
- if(R2::getEditor().getAccessMode()==R2::CEditor::AccessDM)
- {
- CSessionBrowserImpl & sessionBrowser = CSessionBrowserImpl::getInstance();
- sessionBrowser.getSessionInfo(sessionBrowser.getCharId(), R2::getEditor().getDMC().getEditionModule().getCurrentAdventureId());
-
- if(sessionBrowser.waitOneMessage(sessionBrowser.getMessageName("on_sessionInfoResult")))
- {
- TRaceFilter & raceFilter = sessionBrowser._LastRaceFilter;
- setToggleButton(scenarioWnd, "fyros", raceFilter.checkEnumValue(TRaceFilterEnum::rf_fyros));
- setToggleButton(scenarioWnd, "matis", raceFilter.checkEnumValue(TRaceFilterEnum::rf_matis));
- setToggleButton(scenarioWnd, "tryker", raceFilter.checkEnumValue(TRaceFilterEnum::rf_tryker));
- setToggleButton(scenarioWnd, "zorai", raceFilter.checkEnumValue(TRaceFilterEnum::rf_zorai));
-
- TReligionFilter & religionFilter = sessionBrowser._LastReligionFilter;
- setToggleButton(scenarioWnd, "kami", religionFilter.checkEnumValue(TReligionFilterEnum::rf_kami));
- setToggleButton(scenarioWnd, "karavan", religionFilter.checkEnumValue(TReligionFilterEnum::rf_karavan));
- setToggleButton(scenarioWnd, "neutral", religionFilter.checkEnumValue(TReligionFilterEnum::rf_neutral));
-
- TGuildFilter & guildFilter = sessionBrowser._LastGuildFilter;
- setToggleButton(scenarioWnd, "guild_gr", (guildFilter==TGuildFilter::gf_any_player));
-
- TShardFilter & shardFilter = sessionBrowser._LastShardFilter;
- for(uint i=0; ifindFromShortId(string("global_access_toggle_butt"));
- if(result)
- {
- CCtrlBaseButton * baseButton = dynamic_cast(result);
- if(baseButton)
- baseButton->setPushed(subscriptionClosed);
- }
-
- bool autoInvite = sessionBrowser._LastAutoInvite;
- result = scenarioWnd->findFromShortId(string("auto_invite_toggle_butt"));
- if(result)
- {
- CCtrlBaseButton * baseButton = dynamic_cast(result);
- if(baseButton)
- baseButton->setPushed(!autoInvite);
- }
-
- // description
- string description = sessionBrowser._LastDescription;
- if(!description.empty())
- {
- result = scenarioWnd->findFromShortId(string("edit_small_description"));
- if(result)
- {
- CGroupEditBox* editBox = dynamic_cast(result);
- if(editBox)
- editBox->setInputString(description);
- }
- }
- }
- else
- {
- nlwarning("getSessionInfo callback return false");
- }
- }
- else
- {
- result = scenarioWnd->findFromShortId(string("access_players_filter"));
- if(result)
- {
- CInterfaceGroup* filtersGroup = dynamic_cast(result);
- if(filtersGroup)
- {
- std::vector controls;
- getChildrenControls(filtersGroup, controls);
- for(uint i=0; i(control);
- if(baseButton && (baseButton->getType()==CCtrlBaseButton::ToggleButton))
- baseButton->setPushed(false);
- }
- }
- }
- }
- }
-};
-REGISTER_ACTION_HANDLER (CAHScenarioControl, "init_scenario_control");
-
-
-// ***************************************************************************
-class CAHScenarioInformation : public IActionHandler
-{
- virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
- {
- nlinfo("CAHScenarioDescription called");
-
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CInterfaceGroup* scenarioWnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_scenario_control"));
- if(!scenarioWnd) return;
-
- CInterfaceElement *result = scenarioWnd->findFromShortId(string("scenario_value_text"));
- if(result)
- {
- CViewText* viewText= dynamic_cast(result);
-
- if(viewText)
- {
- ScenarioFileName = getParam(Params, "ScenarioName");
- setScenarioInformation(scenarioWnd, ScenarioFileName);
-
- string scenarioName = ScenarioFileName;
- string::size_type posScenarioName = 0;
- while(posScenarioName!=string::npos)
- {
- scenarioName = scenarioName.substr(posScenarioName==0?posScenarioName:posScenarioName+1);
- posScenarioName = scenarioName.find('/');
- }
- viewText->setText(scenarioName);
- }
- }
-
- // active description and information
- result = scenarioWnd->findFromShortId(string("scenario_info_prop"));
- if(result)
- result->setActive(true);
-
- result = scenarioWnd->findFromShortId(string("description_gr"));
- if(result)
- result->setActive(true);
- }
-};
-REGISTER_ACTION_HANDLER (CAHScenarioInformation, "scenario_information");
-
-// ***************************************************************************
-class CAHHideCharsFilters : public IActionHandler
-{
- virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
- {
- nlinfo("CAHHideCharsFilters called");
-
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CInterfaceGroup* scenarioWnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_scenario_control"));
- if(!scenarioWnd) return;
-
- bool lookingForPlayers = true;
- CInterfaceElement *result = scenarioWnd->findFromShortId(string("global_access_toggle_butt"));
- if(result)
- {
- CCtrlBaseButton * baseButton = dynamic_cast(result);
- if(baseButton)
- lookingForPlayers = !baseButton->getPushed(); // warning : on / off textures are inverted !!!
- }
-
- result = scenarioWnd->findFromShortId(string("access_body_gr"));
- if(result)
- result->setActive(lookingForPlayers);
-
- result = scenarioWnd->findFromShortId(string("sep_global_access"));
- if(result)
- result->setActive(lookingForPlayers);
-
- result = scenarioWnd->findFromShortId(string("auto_invite_label"));
- if(result)
- result->setActive(lookingForPlayers);
-
- result = scenarioWnd->findFromShortId(string("auto_invite_toggle_butt"));
- if(result)
- result->setActive(lookingForPlayers);
-
- result = scenarioWnd->findFromShortId(string("invite_team"));
- if(result)
- {
- bool team = (NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:TEAM_MEMBER")->getValue8())!=0;
- team = (team && !(R2::getEditor().isInitialized()) && lookingForPlayers);
- result->setActive(team);
- }
- }
-};
-REGISTER_ACTION_HANDLER (CAHHideCharsFilters, "hide_chars_filters");
-
-// ***************************************************************************
-class CAHLoadScenario : public IActionHandler
-{
- virtual void execute (CCtrlBase *pCaller, const string &/* Params */)
- {
- nlinfo("CAHLoadScenario called");
-
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CInterfaceGroup* scenarioWnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_scenario_control"));
- if(!scenarioWnd) return;
-
- CInterfaceElement *result = NULL;
-
- // load scenario
- if(!R2::getEditor().isInitialized())
- {
- R2::CEditor::setStartingAnimationFilename(ScenarioFileName);
- }
-
- // description
- string description;
- result = scenarioWnd->findFromShortId(string("edit_small_description"));
- if(result)
- {
- CGroupEditBox* editBox = dynamic_cast(result);
- if(editBox)
- description = editBox->getInputString().toString();
- }
-
- // races
- map races;
- races["fyros"] = false;
- races["matis"] = false;
- races["tryker"] = false;
- races["zorai"] = false;
- for(map::iterator itRace=races.begin(); itRace!=races.end(); itRace++)
- {
- result = scenarioWnd->findFromShortId(itRace->first);
- if(result)
- {
- CInterfaceGroup * group = dynamic_cast(result);
- if(group)
- {
- result = group->findFromShortId(string("toggle_butt"));
- if(result)
- {
- CCtrlBaseButton * baseButton = dynamic_cast(result);
- if(baseButton)
- itRace->second = !baseButton->getPushed();
- }
- }
- }
- }
-
- // religion
- map religions;
- religions["kami"] = false;
- religions["karavan"] = false;
- religions["neutral"] = false;
- for(map::iterator itReligion=religions.begin(); itReligion!=religions.end(); itReligion++)
- {
- result = scenarioWnd->findFromShortId(itReligion->first);
- if(result)
- {
- CInterfaceGroup * group = dynamic_cast(result);
- if(group)
- {
- result = group->findFromShortId(string("toggle_butt"));
- if(result)
- {
- CCtrlBaseButton * baseButton = dynamic_cast(result);
- if(baseButton)
- itReligion->second = !baseButton->getPushed();
- }
- }
- }
- }
-
- // guild
- bool anyPlayer = false;
- result = scenarioWnd->findFromShortId(string("guild_gr"));
- if(result)
- {
- CInterfaceGroup * group = dynamic_cast(result);
- if(group)
- {
- result = group->findFromShortId(string("toggle_butt"));
- if(result)
- {
- CCtrlBaseButton * baseButton = dynamic_cast(result);
- if(baseButton)
- anyPlayer = !baseButton->getPushed();
- }
- }
- }
-
- // shards
- std::vector shards(Mainlands.size(), false);
- for(uint i=0; ifindFromShortId(toString(Mainlands[i].Id));
- if(result)
- {
- CInterfaceGroup * group = dynamic_cast(result);
- if(group)
- {
- result = group->findFromShortId(string("toggle_butt"));
- if(result)
- {
- CCtrlBaseButton * baseButton = dynamic_cast(result);
- if(baseButton)
- shards[i] = !baseButton->getPushed();
- }
- }
- }
- }
-
- // levels
- map levels;
- levels["20"] = false;
- levels["50"] = false;
- levels["100"] = false;
- levels["150"] = false;
- levels["200"] = false;
- levels["250"] = false;
- for(map::iterator itLevel=levels.begin(); itLevel!=levels.end(); itLevel++)
- {
- result = scenarioWnd->findFromShortId(itLevel->first);
- if(result)
- {
- CInterfaceGroup * group = dynamic_cast(result);
- if(group)
- {
- result = group->findFromShortId(string("toggle_butt"));
- if(result)
- {
- CCtrlBaseButton * baseButton = dynamic_cast(result);
- if(baseButton)
- itLevel->second = !baseButton->getPushed();
- }
- }
- }
- }
-
- // global access
- bool globalAccess = false;
- result = scenarioWnd->findFromShortId(string("global_access_toggle_butt"));
- if(result)
- {
- CCtrlBaseButton * baseButton = dynamic_cast(result);
- if(baseButton)
- globalAccess = !baseButton->getPushed();
- }
-
- // auto invite
- bool autoInvite = false;
- result = scenarioWnd->findFromShortId(string("auto_invite_toggle_butt"));
- if(result)
- {
- CCtrlBaseButton * baseButton = dynamic_cast(result);
- if(baseButton)
- autoInvite = !baseButton->getPushed();
- }
-
- // invite your team
- bool inviteTeam = false;
- result = scenarioWnd->findFromShortId(string("team_toggle_butt"));
- if(result)
- {
- CCtrlBaseButton * baseButton = dynamic_cast(result);
- if(baseButton)
- inviteTeam = !baseButton->getPushed();
- }
-
- bool launchScenarioFromRingAccessPoint = false;
-
- vector< pair< string, string > > values;
- if(R2::getEditor().isInitialized())
- {
- values = R2::getEditor().getDMC().getEditionModule().getScenarioHeader();
- }
- else
- {
- R2::CScenarioValidator sv;
- std::string md5, signature;
- sv.setScenarioToLoad(ScenarioFileName, values, md5, signature, false);
- launchScenarioFromRingAccessPoint = true;
- }
-
- string rules, level, title;
- string initialIsland, initialEntryPoint, initialSeason;
- std::string lang, scenarioType;
- std::string otherCharAccess;
- std::string nevraxScenario = "0";
- std::string trialAllowed = "0";
- for(uint i=0; i pair = values[i];
-
- if(pair.first == "Rules") rules = pair.second;
- else if(pair.first == "Level") level = pair.second;
- else if(pair.first == "Title") title = pair.second;
- else if(pair.first == "InitialIsland") initialIsland = pair.second;
- else if(pair.first == "InitialEntryPoint") initialEntryPoint = pair.second;
- else if(pair.first == "InitialSeason") initialSeason = pair.second;
- else if(pair.first == "Language") lang = pair.second;
- else if(pair.first == "Type") scenarioType = pair.second;
- else if(pair.first == "OtherCharAccess") otherCharAccess = pair.second;
- else if(pair.first == "NevraxScenario") nevraxScenario = pair.second;
- else if(pair.first == "TrialAllowed") trialAllowed = pair.second;
- }
-
- uint nLevel;
- fromString(level, nLevel);
- R2::TSessionLevel sessionLevel = R2::TSessionLevel::TValues(nLevel/50 + 1);
-
- // ---- fix for old scenarii
- if (lang == "French")
- lang = "fr";
- else if (lang == "German" || lang == "Deutsch")
- lang = "de";
- else //if (lang == "English")
- lang = "en";
-
- if (nlstricmp(scenarioType, "Roleplay") == 0 || nlstricmp(scenarioType, "Role play") == 0)
- scenarioType = "so_story_telling";
- else if (nlstricmp(scenarioType, "Combat") == 0)
- scenarioType = "so_hack_slash";
- // --------------------------
-
- TRuleType ruleType(TRuleType::rt_strict);
- if(rules==CI18N::get("uiR2EDliberal").toString())
- ruleType = TRuleType(TRuleType::rt_liberal);
- else if(rules == CI18N::get("uiR2EDstrict").toString())
- ruleType = TRuleType(TRuleType::rt_strict);
- volatile static bool override = false;
- if (override)
- {
- if(rules== "Masterless")
- ruleType = TRuleType(TRuleType::rt_liberal);
- else if(rules == "Mastered")
- ruleType = TRuleType(TRuleType::rt_strict);
- }
-
- TRaceFilter raceFilter;
- if(races["fyros"])
- raceFilter.setEnumValue(TRaceFilterEnum::rf_fyros);
- if(races["matis"])
- raceFilter.setEnumValue(TRaceFilterEnum::rf_matis);
- if(races["tryker"])
- raceFilter.setEnumValue(TRaceFilterEnum::rf_tryker);
- if(races["zorai"])
- raceFilter.setEnumValue(TRaceFilterEnum::rf_zorai);
-
- TReligionFilter religionFilter;
- if(religions["kami"])
- religionFilter.setEnumValue(TReligionFilterEnum::rf_kami);
- if(religions["karavan"])
- religionFilter.setEnumValue(TReligionFilterEnum::rf_karavan);
- if(religions["neutral"])
- religionFilter.setEnumValue(TReligionFilterEnum::rf_neutral);
-
- TGuildFilter guildFilter(anyPlayer?TGuildFilter::gf_any_player:TGuildFilter::gf_only_my_guild);
-
- TShardFilter shardFilter;
- for (uint i = 0; i < shards.size(); ++i)
- {
- if (shards[i]) shardFilter.setEnumValue((RSMGR::TShardFilterEnum::TValues) (1<getDbProp("SERVER:USER:IS_NEWBIE")->getValueBool();
- if (FreeTrial && noob && (nevraxScenario != "1" || trialAllowed != "1"))
- {
- CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text"));
- if (pVT != NULL)
- pVT->setText(CI18N::get("uiRingWarningFreeTrial"));
- CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial");
-
- return;
- }
- }
-
-
- if(R2::getEditor().getAccessMode()!=R2::CEditor::AccessDM)
- {
- if (launchScenarioFromRingAccessPoint)
- {
- // hibernate Edit Session if active
- sessionBrowser.hibernateEditSession(charId);
- if(!sessionBrowser.waitOneMessage(sessionBrowser.getMessageName("on_invokeResult")))
- {
- nlwarning("hibernateEditSession callback return false");
- }
-
- }
-
- // schedule session
- bool launchSuccess = true;
- sessionBrowser.scheduleSession(charId, TSessionType::st_anim,
- title, description, sessionLevel,
- /*TAccessType::at_public,*/ ruleType, TEstimatedDuration::et_medium, 0, TAnimMode::am_dm,
- raceFilter, religionFilter, guildFilter, shardFilter, levelFilter, lang, RSMGR::TSessionOrientation(scenarioType),
- !globalAccess, autoInvite);
-
- if(sessionBrowser.waitOneMessage(sessionBrowser.getMessageName("on_scheduleSessionResult")))
- {
- if(sessionBrowser._LastScheduleSessionResult==0)
- {
- // start session
- sessionBrowser.startSession(sessionBrowser._LastScheduleSessionCharId,
- sessionBrowser._LastScheduleSessionId);
-
- if(sessionBrowser.waitOneMessage(sessionBrowser.getMessageName("on_invokeResult")))
- {
-
- if (launchScenarioFromRingAccessPoint)
- {
- if (!initialIsland.empty() && !initialEntryPoint.empty() && !initialSeason.empty())
- {
- sessionBrowser.setSessionStartParams(charId, sessionBrowser._LastScheduleSessionId, initialIsland, initialEntryPoint, initialSeason);
- }
- }
-
- TSessionPartStatus sessionStatus;
- if(ruleType==TRuleType::rt_liberal)
- sessionStatus = TSessionPartStatus(TSessionPartStatus::sps_play_invited);
- else
- sessionStatus = TSessionPartStatus(TSessionPartStatus::sps_anim_invited);
-
- // invite player
- sessionBrowser.inviteCharacter(
- sessionBrowser._LastScheduleSessionCharId,
- sessionBrowser._LastScheduleSessionId,
- sessionBrowser._LastScheduleSessionCharId,
- sessionStatus.toString());
-
- if(sessionBrowser.waitOneMessage(sessionBrowser.getMessageName("on_invokeResult")))
- {
- // request session
- FarTP.requestFarTPToSession(sessionBrowser._LastScheduleSessionId, PlayerSelectedSlot, CFarTP::JoinSession,
- !R2::getEditor().isInitialized());
- }
- else
- {
- nlwarning("inviteCharacter callback return false");
- }
-
- if (sessionBrowser._LastInvokeResult != 0)
- {
- nlwarning("inviteCharacter callback use error values %d", sessionBrowser._LastInvokeResult);
- }
-
- if(sessionBrowser._LastInvokeResult == 14)
- {
- CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text"));
- if (pVT != NULL)
- pVT->setText(CI18N::get("uiRingWarningFreeTrial"));
- CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial");
- }
-
-
- // invite team
- if(inviteTeam)
- {
- for (uint i = 0 ; i < 8 ; ++i)
- {
- uint32 val = NLGUI::CDBManager::getInstance()->getDbProp(NLMISC::toString("SERVER:GROUP:%d:NAME",i))->getValue32();
- if(val!=0)
- {
- STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
- ucstring res;
- if (pSMC->getString(val,res))
- {
- string charName = CEntityCL::removeTitleAndShardFromName(res).toString();
- sessionBrowser.inviteCharacterByName(sessionBrowser._LastScheduleSessionCharId, charName);
-
- if(!sessionBrowser.waitOneMessage(sessionBrowser.getMessageName("on_invokeResult")))
- {
- nlwarning("inviteCharacterByName callback return false");
- }
-
- if(sessionBrowser._LastInvokeResult == 14)
- {
- CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text"));
- if (pVT != NULL)
- pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial"));
- CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial");
- }
- }
- }
- }
- }
- }
- else
- {
- nlwarning("startSession callback return false");
- launchSuccess = false;
- }
- }
- else if(sessionBrowser._LastScheduleSessionResult==10)
- {
- pIM->messageBoxWithHelp(CI18N::get("uiRingWarningBanishedPlayer"));
- }
- else
- {
- launchSuccess=false;
- }
- }
- else
- {
- nlwarning("scheduleSession callback return false");
- launchSuccess = false;
- }
-
- if(!launchSuccess)
- {
- pIM->messageBoxWithHelp(CI18N::get("uiRingLaunchScenarioError"));
- }
- else
- {
- scenarioWnd->setActive(false);
- }
- }
- else
- {
- // update session
- sessionBrowser.updateSessionInfo(charId, sessionBrowser._LastScheduleSessionId, title, 0, description, sessionLevel,
- /*TAccessType::at_public, */TEstimatedDuration::et_medium, 0, raceFilter, religionFilter,
- guildFilter, shardFilter, levelFilter, !globalAccess, autoInvite, lang, RSMGR::TSessionOrientation(scenarioType));
-
- if(!sessionBrowser.waitOneMessage(sessionBrowser.getMessageName("on_invokeResult")))
- {
- nlwarning("updateSessionInfo callback return false");
- pIM->messageBoxWithHelp(CI18N::get("uiRingUpdateScenarioFiltersError"));
- }
- else
- {
- scenarioWnd->setActive(false);
- }
- }
- }
-};
-REGISTER_ACTION_HANDLER (CAHLoadScenario, "load_scenario");
-
-
-// ***************************************************************************
-class CAHOpenRingSessions : public IActionHandler
-{
- virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
- {
- if(!R2::getEditor().isInitialized())
- {
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CInterfaceGroup* ringSessionsWnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:ring_sessions"));
- if(!ringSessionsWnd) return;
- ringSessionsWnd->setActive(true);
- }
- }
-};
-REGISTER_ACTION_HANDLER (CAHOpenRingSessions, "open_ring_sessions");
-
-// ***************************************************************************
-class CAHInitImportCharacter : public IActionHandler
-{
- virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
- {
- CInterfaceGroup *list = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_CHARACTER));
- if (!list)
- {
- nlwarning("element " GROUP_LIST_CHARACTER " not found probably bad outgame.xml");
- return;
- }
-
- // retrieve saved files
- std::vector savedCharacters;
- CPath::getPathContent("save/", false, false, true, savedCharacters);
-
- CInterfaceGroup *newLine;
- CInterfaceGroup *prevLine;
-
- for (uint i = 0; i < savedCharacters.size(); ++i)
- {
- // search saved characters only
- if (testWildCard(CFile::getFilename(savedCharacters[i]), "character_*.save"))
- {
- const std::string id = CFile::getFilenameWithoutExtension(savedCharacters[i]).substr(strlen("character_"));
- if (id.empty())
- continue;
-
- std::vector> params;
- params.clear();
- params.push_back(std::pair("id", id));
- // adjust ref
- if (list->getNumGroup() > 0)
- params.push_back(std::pair("posref", "BL TL"));
-
- newLine = CWidgetManager::getInstance()->getParser()->createGroupInstance("t_import", GROUP_LIST_CHARACTER, params);
- if (newLine)
- {
- CViewText *text = dynamic_cast(newLine->getView("name"));
- if (text)
- text->setText(ucstring(savedCharacters[i]));
-
- // first button is pushed
- CCtrlButton *button = dynamic_cast(newLine->getCtrl("but"));
- if (button && list->getNumGroup() == 0)
- button->setPushed(true);
-
- // add to the list now
- newLine->setParent(list);
- newLine->setParentSize(list);
- newLine->setParentPos(prevLine);
-
- list->addGroup(newLine);
-
- prevLine = newLine;
- }
- }
- }
- // none case
- if (list->getNumGroup() == 0)
- CLuaManager::getInstance().executeLuaScript("outgame:procCharselNotifaction(3)");
-
- list->invalidateCoords();
- }
-};
-REGISTER_ACTION_HANDLER( CAHInitImportCharacter, "import_char_init" );
-
-// ***************************************************************************
-class CAHResetImportCharacter : public IActionHandler
-{
- virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
- {
- CInterfaceGroup *list = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_CHARACTER));
- if (list)
- list->clearGroups();
-
- if (!ImportCharacter.empty())
- ImportCharacter = "";
- }
-};
-REGISTER_ACTION_HANDLER( CAHResetImportCharacter, "import_char_reset" );
-
-// ***************************************************************************
-class CAHSelectImportCharacter : public IActionHandler
-{
- virtual void execute (CCtrlBase *pCaller, const std::string &Params)
- {
- struct CUnpush : public CInterfaceElementVisitor
- {
- CCtrlBase *Ref;
- virtual void visitCtrl(CCtrlBase *ctrl)
- {
- if (ctrl == Ref) return;
- CCtrlBaseButton *but = dynamic_cast(ctrl);
- if (but)
- {
- but->setPushed(false);
- }
- }
- };
- CInterfaceGroup *list = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_CHARACTER));
- if (!list)
- return;
-
- // unselect
- if (Params.empty())
- {
- CUnpush unpusher;
- unpusher.Ref = pCaller;
- list->visit(&unpusher);
- }
-
- // now select
- std::string name;
- if (Params.empty())
- {
- CCtrlButton *pCB = dynamic_cast(pCaller);
- if (!pCB)
- return;
-
- std::string id = pCB->getId();
- id = id.substr(0, id.rfind(':'));
-
- if (!fromString(id.substr(id.rfind(':')+1, id.size()), name))
- return;
-
- pCB->setPushed(true);
- }
- else
- if (!fromString(Params, name))
- return;
-
- ImportCharacter = "";
- // check filename and store
- if (CFile::fileExists(toString("save/character_%s.save", name.c_str())))
- ImportCharacter = name;
- }
-};
-REGISTER_ACTION_HANDLER( CAHSelectImportCharacter, "import_char_select" );
-
-// ***************************************************************************
-class CAHImportCharacter : public IActionHandler
-{
- virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
- {
- if (ImportCharacter.empty())
- return;
-
- if (!CFile::fileExists(toString("save/character_%s.save", ImportCharacter.c_str())))
- return;
-
- bool success = false;
-
- CIFile fd;
- CCharacterSummary CS;
- // use temporary file until close()
- if (fd.open(toString("save/character_%s.save", ImportCharacter.c_str())))
- {
- try
- {
- CS.serial(fd);
- SCharacter3DSetup::setupDBFromCharacterSummary("UI:TEMP:CHAR3D", CS);
-
- // validate import
- CDBManager::getInstance()->getDbProp("UI:TEMP:IMPORT")->setValue32(1);
- success = true;
- }
- catch (const EStream &e)
- {
- nlwarning(e.what());
- }
- fd.close();
- }
- else
- nlwarning("Failed to open file: save/character_%s.save", ImportCharacter.c_str());
-
- // user notification
- if (!success)
- CLuaManager::getInstance().executeLuaScript("outgame:procCharselNotifaction(2)");
- else
- CAHManager::getInstance()->runActionHandler("proc", NULL, "proc_charsel_create_new");
- }
-};
-REGISTER_ACTION_HANDLER( CAHImportCharacter, "import_char" );
-
-// ***************************************************************************
-class CAHExportCharacter : public IActionHandler
-{
- virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params)
- {
- if (Params.empty())
- return;
-
- sint32 slot = -1;
- if (!fromString(getParam(Params, "slot"), slot))
- return;
-
- if (slot >= CharacterSummaries.size() || slot < 0)
- return;
-
- // retrieve infos
- CCharacterSummary &CS = CharacterSummaries[slot];
- if (CS.Name.empty())
- return;
-
- // extract name
- const std::string name = buildPlayerNameForSaveFile(CS.Name.toString());
-
- COFile fd;
- bool success = false;
- // use temporary file until close()
- if (fd.open(toString("save/character_%s.save", name.c_str()), false, false, true))
- {
- try
- {
- fd.serial(CS);
- fd.flush();
- // validate
- success = true;
- }
- catch (const EStream &e)
- {
- nlwarning(e.what());
- }
- fd.close();
- }
- else
- nlwarning("Failed to open file: save/character_%s.save", name.c_str());
-
- const uint8 val = (success == true) ? 0 : 1;
- // user notification
- CLuaManager::getInstance().executeLuaScript(toString("outgame:procCharselNotifaction(%i)", val));
- }
-};
-REGISTER_ACTION_HANDLER( CAHExportCharacter, "export_char" );
diff --git a/code/ryzom/client/src/far_tp.cpp b/code/ryzom/client/src/far_tp.cpp
deleted file mode 100644
index 1c2a6e612..000000000
--- a/code/ryzom/client/src/far_tp.cpp
+++ /dev/null
@@ -1,1522 +0,0 @@
-// Ryzom - MMORPG Framework
-// Copyright (C) 2010-2011 Winch Gate Property Limited
-//
-// This source file has been modified by the following contributors:
-// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter)
-// Copyright (C) 2014-2016 Jan BOON (Kaetemi)
-//
-// 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 "stdpch.h"
-#include "nel/3d/u_driver.h"
-#include "far_tp.h"
-#include "net_manager.h"
-#include "connection.h"
-#include "interface_v3/interface_manager.h"
-#include "login_patch.h"
-#include "init_main_loop.h"
-#include "weather.h"
-#include "time_client.h"
-#include "timed_fx_manager.h"
-#include "world_database_manager.h"
-#include "continent_manager.h"
-#include "user_entity.h"
-#include "entities.h"
-#include "interface_v3/input_handler_manager.h"
-#include "interface_v3/bot_chat_page_all.h"
-#include "sound_manager.h"
-#include "actions_client.h"
-#include "r2/editor.h"
-#include "global.h"
-#include "release.h"
-#include "nel/misc/string_conversion.h"
-#include "debug_client.h"
-#include "session_browser_impl.h"
-#include "game_share/security_check.h"
-#include "client_chat_manager.h"
-#include "bg_downloader_access.h"
-#include "login_progress_post_thread.h"
-#include "interface_v3/action_handler_base.h"
-#include "item_group_manager.h"
-#include "nel/misc/cmd_args.h"
-
-#ifdef DEBUG_NEW
-#define new DEBUG_NEW
-#endif
-
-using namespace NLMISC;
-using namespace NLNET;
-using namespace NL3D;
-using namespace RSMGR;
-using namespace R2;
-
-extern CClientChatManager ChatMngr;
-extern CVariable SBSPortOffset;
-
-// ***************************************************************************
-// Login state machine
-// ***************************************************************************
-
-// Adapted from "nel/misc/string_conversion.h"
-#define NL_BEGIN_CLASS_STRING_CONVERSION_TABLE(__class, __type) \
-static const NLMISC::CStringConversion<__class::__type>::CPair __type##_nl_string_conversion_table[] = \
-{
-#define NL_END_CLASS_STRING_CONVERSION_TABLE(__class, __type, __tableName, __defaultValue) \
-}; \
-NLMISC::CStringConversion<__class::__type> \
-__tableName(__type##_nl_string_conversion_table, sizeof(__type##_nl_string_conversion_table) \
- / sizeof(__type##_nl_string_conversion_table[0]), __class::__defaultValue);
-#define NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(__class, val) { #val, __class::val},
-
-
-NL_BEGIN_CLASS_STRING_CONVERSION_TABLE (CLoginStateMachine, TState)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_start)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_login)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_auto_login)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_shard_list)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_start_config)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_scan_data)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_display_eula)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_check_patch)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_display_cat)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_patch)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_close_client)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_reboot_screen)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_restart_client)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_connect)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_browser_screen)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_ingame)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_leave_shard)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_enter_far_tp_main_loop)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_disconnect)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_reconnect_fs)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_reconnect_select_char)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_reconnect_ready)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_exit_global_menu)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_reconnect_error)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_create_account)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_end)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, st_unknown)
-NL_END_CLASS_STRING_CONVERSION_TABLE(CLoginStateMachine, TState, StateConversion, st_unknown)
-
-NL_BEGIN_CLASS_STRING_CONVERSION_TABLE (CLoginStateMachine, TEvent)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_quit)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_skip_all_login)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_init_done)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_game_conf)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_data_scan)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_close_data_scan)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_login_ok)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_bad_login)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_shard_selected)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_patch_needed)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_no_patch)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_run_patch)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_close_patch)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_accept_eula)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_decline_eula)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_reboot)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_ingame_return)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_far_tp_main_loop_entered)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_connect)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_conn_failed)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_conn_dropped)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_enter_game)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_self_reconnected)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_chars_received)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_no_user_char)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_ready_received)
-// NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_reselect_char)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_reconnect_ok_received)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_global_menu_exited)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_relog)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_create_account)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_close_create_account)
- NL_CLASS_STRING_CONVERSION_TABLE_ENTRY(CLoginStateMachine, ev_unknown)
-NL_END_CLASS_STRING_CONVERSION_TABLE(CLoginStateMachine, TEvent, EventConversion, ev_unknown)
-
-//-----------------------------------------------
-// toString :
-//-----------------------------------------------
-const std::string& CLoginStateMachine::toString(CLoginStateMachine::TState state)
-{
- return StateConversion.toString(state);
-}
-
-//-----------------------------------------------
-// toString :
-//-----------------------------------------------
-const std::string& CLoginStateMachine::toString(CLoginStateMachine::TEvent event)
-{
- return EventConversion.toString(event);
-}
-
-
-#define SM_BEGIN_EVENT_TABLE \
- for(;!isTerminationRequested();) \
- { \
- TEvent ev = waitEvent(); \
-
-#define SM_END_EVENT_TABLE \
- } \
-
-/*
-#define SM_EVENT(eventId, stateId) \
- if (ev == eventId) \
- { \
- try \
- { \
- COFile outputF; \
- string sLog = NLMISC::toString("[%s] %s -> %s\n", CLoginStateMachine::toString(ev).c_str(), CLoginStateMachine::toString(_CurrentState).c_str(), CLoginStateMachine::toString(stateId).c_str()); \
- if ( outputF.open( getLogDirectory() + "error_join.log", true, true ) ) \
- { \
- outputF.serialBuffer( (uint8*)(&sLog[0]), (uint)sLog.size() ); \
- outputF.close(); \
- } \
- } \
- catch (const Exception &) \
- {} \
- _CurrentState = stateId; \
- break; \
- } \
-*/
-
-#define SM_EVENT(eventId, stateId) \
- if (ev == eventId) \
- { \
- _CurrentState = stateId; \
- break; \
- } \
-
-extern std::string LoginLogin, LoginPassword, LoginCustomParameters;
-extern bool noUserChar;
-extern bool userChar;
-extern bool serverReceivedReady;
-extern bool CharNameValidArrived;
-extern bool FirstFrame;
-extern bool IsInRingSession;
-
-extern void selectTipsOfTheDay (uint tips);
-#define BAR_STEP_TP 2
-
-extern NLMISC::CCmdArgs Args;
-
-CLoginStateMachine::TEvent CLoginStateMachine::waitEvent()
-{
- nlassert(CCoTask::getCurrentTask() == this);
-
- while (_NextEvents.empty() && !isTerminationRequested())
- {
- // wait until someone push an event on the state machine
- yield();
-
- if (isTerminationRequested())
- return ev_quit;
- }
-
- TEvent ev = _NextEvents.front();
- _NextEvents.pop_front();
-
- return ev;
-}
-
-void CLoginStateMachine::pushEvent(TEvent eventId)
-{
- // set the next event
- _NextEvents.push_back(eventId);
-
- if (CCoTask::getCurrentTask() != this)
- {
- /// resume the state machine to advance state
- resume();
- }
-}
-
-
-void CLoginStateMachine::run()
-{
- // state machine coroutine
-
- while (_CurrentState != st_end && !isTerminationRequested())
- {
- switch(_CurrentState)
- {
- case st_start:
- /// initial state
-
- if (!ClientCfg.TestBrowser)
- {
- if (LoginPassword.empty())
- {
- if (!LoginCustomParameters.empty() && LoginLogin.empty())
- {
- // alternate login procedure
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_init_done, st_alt_login);
- SM_EVENT(ev_skip_all_login, st_ingame);
- SM_EVENT(ev_quit, st_end);
- SM_END_EVENT_TABLE
- }
- else
- {
- // standard procedure
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_init_done, st_login);
- SM_EVENT(ev_skip_all_login, st_ingame);
- SM_EVENT(ev_quit, st_end);
- SM_END_EVENT_TABLE
- }
- }
- else
- {
- // login 2, bypass the login screen
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_init_done, st_auto_login);
- SM_EVENT(ev_skip_all_login, st_ingame);
- SM_EVENT(ev_quit, st_end);
- SM_END_EVENT_TABLE
-
- }
- }
-// else
-// {
-// // browser test mode
-// SM_BEGIN_EVENT_TABLE
-// SM_EVENT(ev_init_done, st_browser_screen);
-// SM_EVENT(ev_quit, st_end);
-// SM_END_EVENT_TABLE
-// }
-
- break;
- case st_login:
- /// display login screen and options
- {
- initLoginScreen();
-
- if (ClientCfg.R2Mode)
- {
- // r2 mode
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_login_ok, st_check_patch);
- SM_EVENT(ev_game_conf, st_start_config);
- SM_EVENT(ev_data_scan, st_scan_data);
- SM_EVENT(ev_create_account, st_create_account);
- SM_EVENT(ev_bad_login, st_login);
- SM_EVENT(ev_quit, st_end);
- SM_END_EVENT_TABLE
- }
- else
- {
- // legacy mode
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_login_ok, st_shard_list);
- SM_EVENT(ev_game_conf, st_start_config);
- SM_EVENT(ev_data_scan, st_scan_data);
- SM_EVENT(ev_create_account, st_create_account);
- SM_EVENT(ev_bad_login, st_login);
- SM_EVENT(ev_quit, st_end);
- SM_END_EVENT_TABLE
- }
- }
- break;
- case st_auto_login:
- initAutoLogin();
-
-// if (ClientCfg.R2Mode)
- {
- // r2 mode
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_login_ok, st_check_patch);
- SM_EVENT(ev_quit, st_end);
- SM_END_EVENT_TABLE
- }
-// else
-// {
-// // legacy mode
-// SM_BEGIN_EVENT_TABLE
-// SM_EVENT(ev_login_ok, st_check_patch);
-// SM_EVENT(ev_quit, st_end);
-// SM_END_EVENT_TABLE
-// }
- break;
- case st_alt_login:
- initAltLogin();
-
-// if (ClientCfg.R2Mode)
- {
- // r2 mode
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_login_not_alt, st_login);
- SM_EVENT(ev_login_ok, st_check_patch);
- SM_EVENT(ev_quit, st_end);
- SM_END_EVENT_TABLE
- }
-// else
-// {
-// // legacy mode
-// SM_BEGIN_EVENT_TABLE
-// SM_EVENT(ev_login_ok, st_check_patch);
-// SM_EVENT(ev_quit, st_end);
-// SM_END_EVENT_TABLE
-// }
- break;
- case st_shard_list:
- /// display the shard list
- initShardDisplay();
-
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_shard_selected, st_check_patch);
- SM_EVENT(ev_quit, st_end);
- SM_END_EVENT_TABLE
-
- break;
- case st_start_config:
- /// launch the configurator and close ryzom
- break;
- case st_scan_data:
- /// run the check data thread
- initDataScan();
-
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_close_data_scan, st_login);
- SM_EVENT(ev_quit, st_end);
- SM_END_EVENT_TABLE
-
- break;
- case st_create_account:
-
- if (initCreateAccount())
- {
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_login_ok, st_check_patch);
- SM_EVENT(ev_close_create_account, st_login);
- SM_EVENT(ev_quit, st_end);
- SM_END_EVENT_TABLE
- }
- else
- {
- // return to login menu if an error occurred
- _CurrentState = st_login;
- }
-
- break;
- case st_display_eula:
- {
- /// display the eula and wait for validation
-
- if (ClientCfg.SkipEULA)
- {
- // we don't want to see eula, auto accept
- pushEvent(ev_accept_eula);
- }
-
- bool mustReboot = false;
-
- if (isBGDownloadEnabled())
- {
- mustReboot = CBGDownloaderAccess::getInstance().mustLaunchBatFile();
- }
- else
- {
- mustReboot = CPatchManager::getInstance()->mustLaunchBatFile();
- }
-
- if (mustReboot)
- {
- // skip eula and show reboot screen
- _CurrentState = st_reboot_screen;
- break;
- }
-
- initEula();
-
-// Login sequence was reordered
-// if (ClientCfg.R2Mode)
-// {
-// // ring mode
-// SM_BEGIN_EVENT_TABLE
-// SM_EVENT(ev_accept_eula, st_browser_screen);
-// SM_EVENT(ev_quit, st_end);
-// SM_END_EVENT_TABLE
-// }
-// else
-// {
-// // legacy mode
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_accept_eula, st_connect);
- SM_EVENT(ev_quit, st_end);
- SM_END_EVENT_TABLE
-// }
- }
- break;
- case st_check_patch:
- /// check the data to check if patch needed
- CLoginProgressPostThread::getInstance().step(CLoginStep(LoginStep_PostLogin, "login_step_post_login"));
-
- if (!ClientCfg.PatchWanted || (Args.haveArg("n") && Args.getLongArg("nopatch").front() == "1"))
- {
- // client don't want to be patched !
- _CurrentState = st_display_eula;
- break;
- }
-
- initPatchCheck();
- SM_BEGIN_EVENT_TABLE
- if (isBGDownloadEnabled())
- {
- SM_EVENT(ev_patch_needed, st_patch); // no choice for patch content when background downloader is used
- }
- else
- {
- SM_EVENT(ev_patch_needed, st_display_cat);
- }
- SM_EVENT(ev_no_patch, st_display_eula);
- SM_EVENT(ev_quit, st_end);
- SM_END_EVENT_TABLE
-
- break;
- case st_display_cat:
- initCatDisplay();
-
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_run_patch, st_patch);
- SM_EVENT(ev_quit, st_end);
- SM_END_EVENT_TABLE
-
- break;
- case st_patch:
- /// run the patch process and display progress
- initPatch();
-
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_close_patch, st_display_eula);
- SM_EVENT(ev_quit, st_end);
- SM_END_EVENT_TABLE
- break;
- case st_close_client:
- /// terminate the client and quit
- break;
- case st_reboot_screen:
- /// display the reboot screen and wait validation
- initReboot();
-
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_reboot, st_end);
- SM_EVENT(ev_quit, st_end);
- SM_END_EVENT_TABLE
-
- break;
- case st_restart_client:
- /// restart the client with login bypass params
- break;
- case st_connect:
- /// connect to the FS (start the 'in game' mode)
- ConnectToShard();
-
- if (ClientCfg.R2Mode)
- {
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_enter_game, st_ingame);
- SM_END_EVENT_TABLE
- }
- else
- {
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_enter_game, st_end);
- SM_EVENT(ev_conn_failed, st_shard_list);
- SM_END_EVENT_TABLE
- }
- break;
-// case st_browser_screen:
-// /// show the outgame browser
-//
-// if (!ClientCfg.TestBrowser)
-// {
-// // in test browser mode, the browser is already init
-// initWebBrowser();
-// }
-//
-// SM_BEGIN_EVENT_TABLE
-// SM_EVENT(ev_connect, st_connect);
-// SM_EVENT(ev_relog, st_login);
-// SM_EVENT(ev_quit, st_end);
-// SM_END_EVENT_TABLE
-//
-// break;
- case st_ingame:
- SM_BEGIN_EVENT_TABLE
- //SM_EVENT(ev_chars_received, st_ingame); // ignored for normal login procedure
- //SM_EVENT(ev_no_user_char, st_ingame); // "
- //SM_EVENT(ev_ready_received, st_ingame); // "
- //SM_EVENT(ev_global_menu_exited, st_ingame); "
- SM_EVENT(ev_connect, st_leave_shard); // connect to another shard
- SM_END_EVENT_TABLE
- break;
- case st_leave_shard:
- /*
- * Far TP / Server Hop / Reselect character entry point
- */
-
- // Server Hop part 1: We are not in main loop but still at character selection
- // => make a hop to the specified server without doing anything with interface
- // Far TP part 1.1: From the ingame main loop, the admin html box gives us an event ev_connect for the destination shard.
- // Note: the admin html box is run by CInputHandlerManager::getInstance()->pumpEvents() in the main loop.
- // Tip: to see where a co-task is resumed from, just add a breakpoint on the end of CCoTask::resume().
- CAHManager::getInstance()->runActionHandler("quit_ryzom", NULL, "");
-
- if (!FarTP.isIngame()) // assumes there is no Far TP starting between char selection and main loop, see below
- {
- crashLogAddServerHopEvent();
-
- FarTP.onServerQuitOk(); // don't wait for onServerQuitOK() because the EGS will no longer send it if it requests a Far TP during "select char" (not sending USER_CHAR)
-
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_ingame_return, st_disconnect);
- SM_END_EVENT_TABLE
- }
- else
- {
- if(FarTP.isReselectingChar())
- crashLogAddReselectPersoEvent();
- else
- crashLogAddFarTpEvent();
-
- if (NetMngr.getConnectionState() == CNetworkConnection::Disconnect)
- FarTP.onServerQuitOk(); // don't wait for onServerQuitOK() because the EGS is down
-
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_ingame_return, st_enter_far_tp_main_loop);
- SM_EVENT(ev_enter_game, st_ingame);
- SM_END_EVENT_TABLE
- }
- break;
- case st_enter_far_tp_main_loop:
- // if bgdownloader is used, then pause it
- pauseBGDownloader();
-
-
- // Far TP part 1.2: let the main loop finish the current frame.
- // This is called when CONNECTION:SERVER_QUIT_OK is received (from NetMngr.update() in main loop).
-
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_far_tp_main_loop_entered, st_disconnect);
- SM_END_EVENT_TABLE
- break;
- case st_disconnect:
- // Far TP part 2: disconnect from the FS and unload shard-specific data (called from farTPmainLoop())
- // FarTP.disconnectFromPreviousShard();
-
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_connect, st_reconnect_fs);
- SM_END_EVENT_TABLE
- break;
- case st_reconnect_fs:
- // Server Hop part 3.1: connect to the new shard (called from globalMenu())
- // Far TP part 3.1: connect to the new shard (called from farTPmainLoop())
- FarTP.connectToNewShard();
-
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_self_reconnected, st_ingame);
- SM_EVENT(ev_chars_received, st_reconnect_select_char);
- SM_EVENT(ev_no_user_char, st_reconnect_error);
- SM_EVENT(ev_conn_failed, st_reconnect_error);
- SM_EVENT(ev_conn_dropped, st_reconnect_error);
- SM_END_EVENT_TABLE
- break;
- case st_reconnect_select_char:
- // Server Hop part 3.2: bypass character selection ui & select the same character.
- // Far TP part 3.2: bypass character selection ui & select the same character.
- // This is called from farTPmainloop(), when CONNECTION:USER_CHARS is received.
- if( !FarTP.isReselectingChar() )
- {
- FarTP.selectCharAndEnter();
- }
- // Far TP part 3.2bis: see in farTPmainLoop()
-
- if (!FarTP.isIngame())
- {
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_ready_received, st_exit_global_menu);
- SM_EVENT(ev_conn_dropped, st_reconnect_error);
- SM_END_EVENT_TABLE
- }
- else
- {
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_ready_received, st_reconnect_ready);
- SM_EVENT(ev_conn_dropped, st_reconnect_error);
- if ( FarTP.isReselectingChar() && (ev == ev_connect) )
- {
- // Inside this Character Reselect we embed a new Server Hop
- FarTP.beginEmbeddedServerHop();
- _CurrentState = st_leave_shard;
- break;
- }
- SM_END_EVENT_TABLE
- }
- break;
- case st_exit_global_menu:
- // Server Hop part 3.3
- // Stay in Server Hop state until the global menu has been exited
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_global_menu_exited, FarTP.isServerHopEmbedded() ? st_reconnect_ready : st_ingame);
- SM_END_EVENT_TABLE
- break;
- case st_reconnect_ready:
- // Far TP part 3.3: send ready.
- // This is called from farTPmainloop(), when CONNECTION:READY is received.
-
- if ( FarTP.isServerHopEmbedded() )
- FarTP.endEmbeddedServerHop();
-
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_enter_game, st_ingame);
- SM_EVENT(ev_conn_dropped, st_reconnect_error);
- SM_END_EVENT_TABLE
- break;
- case st_reconnect_error:
- // Far TP failed
- FarTP.onFailure();
-
- SM_BEGIN_EVENT_TABLE
- SM_EVENT(ev_quit, st_end);
- SM_END_EVENT_TABLE
- break;
- default:
- nlwarning("Unhandeled state");
- break;
- }
- }
-}
-
-
-// ***************************************************************************
-// Far TP
-// ***************************************************************************
-
-CFarTP FarTP;
-
-extern std::string CurrentCookie;
-extern string ClientApp;
-
-
-namespace R2
-{
- extern bool ReloadUIFlag;
-}
-
-
-/*
- * requestFarTPToSession
- */
-bool CFarTP::requestFarTPToSession(TSessionId sessionId, uint8 charSlot, CFarTP::TJoinMode joinMode, bool bailOutIfSessionVanished)
-{
- if (_HookedForEditor)
- {
- // Redirect Far TP to editor instead of following instructions
- _HookedForEditor = false;
- return FarTP.requestFarTPToSession((TSessionId)0, charSlot, CFarTP::LaunchEditor, true); // allow bailing out in case of edition session not reachable
- }
-
- // call the join session using the session browser interface
- uint32 charId = (NetMngr.getLoginCookie().getUserId()<<4)+(0xf&charSlot);
-
- // Clean out for next Far TP
- _SessionIdToJoinFast = 0;
-
- CSessionBrowserImpl &sb = CSessionBrowserImpl::getInstance();
- sb.init(NULL);
-// sb.setAuthInfo(NetMngr.getLoginCookie());
-// sb.connectItf(CInetAddress("borisb", 80));
-
- sb.CurrentJoinMode = joinMode;
- // send the join session
-// _JoinSessionResultReceived = false;
- try
- {
- switch (joinMode)
- {
- case LaunchEditor:
- {
-retryJoinEdit:
- TSessionId sessionId(0);
- sb.joinEditSession(charId, ClientApp);
-
- bool ret = sb.waitOneMessage(CSessionBrowserImpl::getMessageName("on_joinSessionResult"));
-
- if (!ret)
- throw "Protocol error";
- if (sb._LastJoinSessionResult == 2)
- {
- // the edit session did not exist, create a new one
- sb.scheduleSession(charId, TSessionType::st_edit, "", "", TSessionLevel::sl_a, /*TAccessType::at_private, */TRuleType::rt_strict, TEstimatedDuration::et_long, 0, TAnimMode(), TRaceFilter(), TReligionFilter(), TGuildFilter(), TShardFilter(), TLevelFilter(), std::string(), TSessionOrientation(), true, true);
- ret = sb.waitOneMessage(CSessionBrowserImpl::getMessageName("on_scheduleSessionResult"));
- if (!ret || sb._LastScheduleSessionResult!= 0) throw "schedule error";
- sessionId = sb._LastScheduleSessionId;
-
- // invite the char in the session
- sb.inviteCharacter(charId, sessionId, charId, TSessionPartStatus::sps_edit_invited);
- ret = sb.waitOneMessage(CSessionBrowserImpl::getMessageName("on_invokeResult"));
- if (!ret || sb._LastInvokeResult != 0) throw "Invitation Error";
-
- // now, start the edit session
- sb.startSession(charId, sessionId);
- ret = sb.waitOneMessage(CSessionBrowserImpl::getMessageName("on_invokeResult"));
- if (!ret || sb._LastInvokeResult != 0) throw "start session error";
-
- // retry to join
- goto retryJoinEdit;
- }
- else if (sb._LastJoinSessionResult == 15)
- {
- sessionId = sb._LastJoinSessionId;
- // the session was closed, the SU has put it in planned state, start it
- sb.startSession(charId, sessionId);
- ret = sb.waitOneMessage(CSessionBrowserImpl::getMessageName("on_invokeResult"));
- if (!ret || sb._LastInvokeResult != 0) throw "start session error (2), no DSS available";
- // retry to join
- goto retryJoinEdit;
- }
- else if (sb._LastJoinSessionResult != 0)
- {
- // any other error are not recoverable from here
- throw "join session error";
- }
-
- // ok, the join is accepted !, the other far TP work is done in the callback
- }
- break;
- case JoinSession:
- {
- sb.joinSession(charId, sessionId, ClientApp);
-
- bool ret = sb.waitOneMessage(CSessionBrowserImpl::getMessageName("on_joinSessionResult"));
-
- if (!ret)
- throw "Protocol error";
- if (sb._LastJoinSessionResult == 16)
- {
-// #pragma message (NL_LOC_WRN "inform the player that he is banned from the ring")
- throw "User ban from the ring";
- }
- if (sb._LastJoinSessionResult != 0)
- {
- throw "Join session error";
- }
- // ok, the join is accepted !, the other far TP work is done in the callback
- }
- break;
- case JoinMainland:
-//retryJoinMainland:
- {
- TSessionId sessionId(0);
- sb.joinMainland(charId, ClientApp);
-
- bool ret = sb.waitOneMessage(CSessionBrowserImpl::getMessageName("on_joinSessionResult"));
-
- if (!ret)
- throw "Protocol error";
- if (sb._LastJoinSessionResult != 0)
- {
- // some error during the join
- throw "Error joining session";
- }
- // ok, the join is accepted !, the other far TP work is done in the callback
- }
- break;
- default:
- nlstop;
- }
-
- return true;
- }
-
-//
-// const string url = _URLBase + string(_URLTable[joinMode]);
-// string res;
-// try
-// {
-// // Get the address of a front-end service via http
-// if (!HttpClient.connect(url))
-// throw 1;
-// switch (joinMode)
-// {
-// case CFarTP::LaunchEditor:
-// if (!HttpClient.sendGetWithCookie(url, "ryzomId", CurrentCookie, toString("charSlot=%u", charSlot)))
-// throw 2;
-// break;
-// case CFarTP::JoinSession:
-// if (!HttpClient.sendPostWithCookie(url, "ryzomId", CurrentCookie, toString("sessionId=%u&charSlot=%u", sessionId, charSlot)))
-// throw 2;
-// break;
-// case CFarTP::JoinMainland:
-// if (!HttpClient.sendPostWithCookie(url, "ryzomId", CurrentCookie, "ml="))
-// throw 2;
-// break;
-// }
-// if (!HttpClient.receive(res))
-// throw 3;
-// HttpClient.disconnect();
-// string::size_type luaPos = res.find("");
-// if (luaPos == string::npos)
-// throw 4;
-// res = res.substr(luaPos + 5);
-// res = res.substr(0, res.find(""));
-// nlinfo("Found server for %ssession %u", joinMode==CFarTP::LaunchEditor ? "editing " : "", sessionId);
-//
-// // Begin Far TP
-// CInterfaceManager *pIM = CInterfaceManager::getInstance();
-// pIM->executeLuaScript(res, true);
-// return true;
-// }
- catch ( char *errorMsg )
- {
-// // Get more details on the error
-// string httpErrorStr;
-// if (errorNum < 4) // we didn't receive an answer
-// httpErrorStr = toString(" (HTTP error %u)", errorNum);
-// if ( errorNum == 4 )
-// {
-// string::size_type posEndOfFirstLine = res.find( "\n" );
-// if ( posEndOfFirstLine == string::npos )
-// {
-// // Invalid http answer
-// httpErrorStr = toString(" (HTTP invalid)");
-// }
-// else
-// {
-// // Http status not OK (e.g. "404 Not Found")
-// httpErrorStr = res.substr( 0, posEndOfFirstLine );
-// if ( httpErrorStr.find( "200 OK" ) == string::npos )
-// httpErrorStr = " (" + httpErrorStr + ")";
-// else
-// httpErrorStr.clear();
-// }
-// }
- bool requestRetToMainland = /*httpErrorStr.empty() &&*/ bailOutIfSessionVanished;
- bool isAttemptingEmbeddedServerHop = isReselectingChar() && (joinMode != CFarTP::JoinSession);
- bool letReturnToCharSelect = (!isIngame()) || isAttemptingEmbeddedServerHop;
-
- // User-friendly message
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- if ( letReturnToCharSelect )
- {
-// // Hide all buttons except Quit. If !requestRetToMainland, we will show them back at the end of connectToNewShard().
-// CAHManager::getInstance()->runActionHandler( "proc", NULL, "charsel_disable_buttons" );
-// CAHManager::getInstance()->runActionHandler( "set", NULL, "target_property=ui:outgame:charsel:quit_but:active|value=1" );
-
- CInterfaceElement *btnOk = CWidgetManager::getInstance()->getElementFromId("ui:outgame:charsel:message_box:ok");
- if (btnOk)
- btnOk->setActive( ! requestRetToMainland );
-
- // Hide the black screen i.e. force showing the interface
- CInterfaceElement *charSelBlackScreen = CWidgetManager::getInstance()->getElementFromId("ui:outgame:charsel:black_screen");
- if (charSelBlackScreen)
- {
- CViewBase *charSelBlackScreenBitmap = dynamic_cast(charSelBlackScreen);
- if (charSelBlackScreenBitmap)
- charSelBlackScreenBitmap->setAlpha(0);
- }
- }
- pIM->messageBoxWithHelp(
- CI18N::get(requestRetToMainland ? "uiSessionVanishedFarTP" : "uiSessionUnreachable") + ucstring(errorMsg),
- letReturnToCharSelect ? "ui:outgame:charsel" : "ui:interface");
-
- // Info in the log
- string outErrorMsg = toString("Could not join %ssession %u: '%s' error\n", joinMode==CFarTP::LaunchEditor ? "editing " : "", sessionId.asInt(), errorMsg );
- nlwarning( outErrorMsg.c_str() );
-// if ( httpErrorStr.empty() )
-// {
-// string delimiter = "Content-Type: text/html";
-// string::size_type delimPos = res.find( delimiter );
-// if ( delimPos != string::npos )
-// res = res.substr( delimPos + delimiter.size() );
-// }
-// uint pos = 0;
-// do
-// {
-// WarningLog->displayRaw( res.substr( pos, 200 ).c_str() ); // truncates long strings
-// pos += 200;
-// }
-// while ( pos < res.size() );
- WarningLog->displayRawNL( "" );
-
- // Save this error (regular log file is deleted at every startup)
-// res = res + "\n\n";
- /*try
- {
- COFile outputF;
- if ( outputF.open( getLogDirectory() + "error_join.log", true, true ) )
- {
- time_t currentTime;
- time( ¤tTime );
- string headerS = NLMISC::toString( "\n\n%s%s\n\n", asctime(localtime(¤tTime)), outErrorMsg.c_str() );
- outputF.serialBuffer( (uint8*)(&headerS[0]), (uint)headerS.size() );
-// outputF.serialBuffer( (uint8*)(&res[0]), res.size() );
- outputF.close();
- }
- }
- catch (const Exception &)
- {}
- */
-
- // If the session is not a permanent session and has vanished, pop the position
- if ( requestRetToMainland )
- {
- requestReturnToPreviousSession( sessionId );
- LastGameCycle = NetMngr.getCurrentServerTick();
- NetMngr.send(NetMngr.getCurrentServerTick());
- }
- else if ( letReturnToCharSelect )
- {
- // Show all buttons except 'New character' so that the character can retry entering game or choose another character.
- CAHManager::getInstance()->runActionHandler( "proc", NULL, "charsel_enable_buttons" );
- CAHManager::getInstance()->runActionHandler( "set", NULL, "target_property=ui:outgame:charsel:create_new_but:active|value=0" );
-
- CInterfaceGroup* charselGroup = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:outgame:charsel"));
- if(charselGroup)
- CAHManager::getInstance()->runActionHandler( "proc", charselGroup, "charsel_init_buttons" );
- }
-
- return false;
- }
-}
-
-
-/*
- * hookNextFarTPForEditor
- */
-void CFarTP::hookNextFarTPForEditor()
-{
- _HookedForEditor = true;
-}
-
-/*
- * requestReturnToPreviousSession
- */
-void CFarTP::requestReturnToPreviousSession(TSessionId rejectedSessionId)
-{
- const string msgName = "CONNECTION:RET_MAINLAND";
- CBitMemStream out;
- nlverify(GenericMsgHeaderMngr.pushNameToStream(msgName, out));
- out.serial(PlayerSelectedSlot);
- out.serial(rejectedSessionId);
- NetMngr.push(out);
- nlinfo("%s sent", msgName.c_str());
-}
-
-/*
- * requestReconnection
- */
-void CFarTP::requestReconnection()
-{
- _ReselectingChar = true;
- if (!requestFarTPToSession(TSessionId(std::numeric_limits::max()), std::numeric_limits::max(), CFarTP::JoinMainland, false))
- _ReselectingChar = false;
-}
-
-
-const char * CFarTP::_URLTable[CFarTP::NbJoinModes] =
-{
- "edit_session.php",
- "join_session.php",
- "join_shard.php"
-};
-
-
-/*
- * States
- */
-
-bool CFarTP::isFarTPInProgress() const
-{
- CLoginStateMachine::TState state = LoginSM.getCurrentState();
- return (state == CLoginStateMachine::st_leave_shard ||
- state == CLoginStateMachine::st_enter_far_tp_main_loop ||
- state == CLoginStateMachine::st_disconnect ||
- state == CLoginStateMachine::st_reconnect_fs ||
- state == CLoginStateMachine::st_reconnect_select_char ||
- state == CLoginStateMachine::st_reconnect_ready ||
- state == CLoginStateMachine::st_reconnect_error);
-}
-
-bool CFarTP::isServerHopInProgress() const
-{
- CLoginStateMachine::TState state = LoginSM.getCurrentState();
- return (state == CLoginStateMachine::st_leave_shard ||
- state == CLoginStateMachine::st_reconnect_fs ||
- state == CLoginStateMachine::st_reconnect_select_char ||
- state == CLoginStateMachine::st_exit_global_menu ||
- state == CLoginStateMachine::st_reconnect_error); // TODO: error handling
-}
-
-
-// from begin of Far TP to disconnection
-bool CFarTP::isLeavingShard() const
-{
- CLoginStateMachine::TState state = LoginSM.getCurrentState();
- return (state == CLoginStateMachine::st_leave_shard ||
- state == CLoginStateMachine::st_enter_far_tp_main_loop ||
- state == CLoginStateMachine::st_disconnect);
-}
-
-// from reconnection to game entering
-bool CFarTP::isJoiningShard() const
-{
- CLoginStateMachine::TState state = LoginSM.getCurrentState();
- return (state == CLoginStateMachine::st_reconnect_fs ||
- state == CLoginStateMachine::st_reconnect_select_char ||
- state == CLoginStateMachine::st_reconnect_ready ||
- state == CLoginStateMachine::st_reconnect_error);
-}
-
-
-/*
- * Events
- */
-
-void CFarTP::onServerQuitOk()
-{
- game_exit_request = false;
- ryzom_exit_request = false;
-
- if (LoginSM.getCurrentState() == CLoginStateMachine::st_leave_shard)
- LoginSM.pushEvent(CLoginStateMachine::ev_ingame_return);
-}
-
-void CFarTP::onServerQuitAbort()
-{
- game_exit_request = false;
- ryzom_exit_request = false;
-
- if (LoginSM.getCurrentState() == CLoginStateMachine::st_leave_shard)
- LoginSM.pushEvent(CLoginStateMachine::ev_enter_game);
- _ReselectingChar = false;
-}
-
-void CFarTP::disconnectFromPreviousShard()
-{
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
-
- if (isIngame())
- {
- // Display background (TODO: not Kami)
- beginLoading (StartBackground);
- UseEscapeDuringLoading = false;
-
- // Play music and fade out the Game Sound
- if (SoundMngr)
- {
- // Loading Music Loop.ogg
- LoadingMusic = ClientCfg.SoundOutGameMusic;
- SoundMngr->playEventMusic(LoadingMusic, CSoundManager::LoadingMusicXFade, true);
- SoundMngr->fadeOutGameSound(ClientCfg.SoundTPFade);
- }
-
- // Change the tips
- selectTipsOfTheDay (rand());
-
- // Start progress bar and display background
- ProgressBar.reset (BAR_STEP_TP);
- ucstring nmsg("Loading...");
- ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) );
- ProgressBar.progress(0);
- }
-
- // Disconnect from the FS
- NetMngr.disconnect();
-
- if (isIngame())
- {
- // Save the R2EDEnabled flag to know if we are switching it when we reconnect
- _PreviousR2EdEnabled = ClientCfg.R2EDEnabled;
-
- // Release R2 editor if applicable
- R2::getEditor().autoConfigRelease(IsInRingSession);
- }
-
- if( isReselectingChar() )
- {
- releaseMainLoopReselect();
- }
- else
- {
- // String manager: remove all waiting callbacks and removers
- // (if some interface stuff has not received its string yet, its remover will get useless)
- STRING_MANAGER::CStringManagerClient::release( false );
-
- // Ugly globals
- userChar = false;
- noUserChar = false;
- serverReceivedReady = false;
- CharNameValidArrived = false;
- UserCharPosReceived = false;
- SabrinaPhraseBookLoaded = false;
- }
-
- // Restart the network manager, the interface sync counter and the entities
- pIM->resetShardSpecificData();
-
- /*
- ServerToLocal autocopy stuff:
- When reinit will reset server counters to 0 in the server database, onServerChange()
- will be called and data will be copied since CInterfaceManager::_LocalSyncActionCounter==0
- (done in resetShardSpecificData() above)
- If we do the resetShardSpecificData() after, scenari could arise where Local database could not be reseted
- */
- NetMngr.reinit();
-
- if (isIngame() && !isReselectingChar())
- {
- nlinfo("FarTP: calling EntitiesMngr.reinit()");
- EntitiesMngr.reinit();
- }
- LoginSM.pushEvent(CLoginStateMachine::ev_connect);
-}
-
-void CFarTP::connectToNewShard()
-{
- // TODO: start commands?
-
- // Connect to the next FS
- NetMngr.initCookie(Cookie, FSAddr);
-
- // connect the session browser to the new shard
- NLNET::CInetAddress sbsAddress(CSessionBrowserImpl::getInstance().getFrontEndAddress());
- sbsAddress.setPort(sbsAddress.port()+SBSPortOffset);
- CSessionBrowserImpl::getInstance().connectItf(sbsAddress);
-
- string result;
- NetMngr.connect(result);
- if (!result.empty())
- {
- _Reason = new string(result);
- LoginSM.pushEvent(CLoginStateMachine::ev_conn_failed);
- return;
- }
-
- // Reinit the string manager cache.
- STRING_MANAGER::CStringManagerClient::instance()->initCache(FSAddr, ClientCfg.LanguageCode);
-
- // reset the chat mode
- ChatMngr.resetChatMode();
-
- // The next step will be triggered by the CONNECTION:USER_CHARS msg from the server
-}
-
-// return to character selection screen
-bool CFarTP::reselectCharacter()
-{
- if ( ! reconnection() )
- {
- // The user clicked the Quit button
- releaseOutGame();
- return false;
- }
- return true;
-}
-
-void CFarTP::selectCharAndEnter()
-{
- CBitMemStream out;
- nlverify (GenericMsgHeaderMngr.pushNameToStream("CONNECTION:SELECT_CHAR", out));
- CSelectCharMsg SelectCharMsg;
- SelectCharMsg.c = (uint8)PlayerSelectedSlot; // PlayerSelectedSlot has not been reset
- out.serial(SelectCharMsg);
- NetMngr.push(out);
- /*//Obsolete
- CBitMemStream out2;
- nlverify(GenericMsgHeaderMngr.pushNameToStream("CONNECTION:ENTER", out2));
- NetMngr.push(out2);
- */
- LastGameCycle = NetMngr.getCurrentServerTick();
- NetMngr.send(NetMngr.getCurrentServerTick());
-
- // if (!isIngame())
- // globalMenu will exit when WaitServerAnswer and serverReceivedReady (triggered by the CONNECTION:READY msg) are true
- // else
- // Next step will be triggered by the CONNECTION:READY msg from the server
-}
-
-void CFarTP::sendReady()
-{
- if ( isReselectingChar() )
- {
- initMainLoop();
- }
- else
- {
- // Set season
- RT.updateRyzomClock(NetMngr.getCurrentServerTick());
- DayNightCycleHour = (float)RT.getRyzomTime();
- CurrSeason = RT.getRyzomSeason();
- RT.updateRyzomClock(NetMngr.getCurrentServerTick());
- DayNightCycleHour = (float)RT.getRyzomTime();
- ManualSeasonValue = RT.getRyzomSeason();
-
- // Reset all fx (no need to CTimedFXManager::getInstance().reset() and EntitiesMngr.getGroundFXManager().reset() because the entities have been removed)
- CProjectileManager::getInstance().reset();
- FXMngr.reset(); // (must be done after EntitiesMngr.release())
- EntitiesMngr.getGroundFXManager().init(Scene, ClientCfg.GroundFXMaxDist, ClientCfg.GroundFXMaxNB, ClientCfg.GroundFXCacheSize);
-
- // Get the sheet for the user from the CFG.
- // Initialize the user and add him into the entity manager.
- // DO IT AFTER: Database, Collision Manager, PACS, scene, animations loaded.
- CSheetId userSheet(ClientCfg.UserSheet);
- nlinfo("FarTP: calling EntitiesMngr.create(0, userSheet.asInt())");
- TNewEntityInfo emptyEntityInfo;
- emptyEntityInfo.reset();
- EntitiesMngr.create(0, userSheet.asInt(), emptyEntityInfo);
-
- // Wait for the start position (USER_CHAR) and set the continent
- waitForUserCharReceived();
-
-
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- if ( ClientCfg.R2EDEnabled != _PreviousR2EdEnabled )
- {
- // Reload textures, keys and interface config if we are switch between playing and r2 mode
- // Must be done after receiving the current R2EDEnabled flag (USER_CHAR)
- pIM->loadIngameInterfaceTextures();
-
- // Unload (and save if leaving normal playing mode) keys and interface config
- // Instead of doing it in disconnectFromPreviousShard(), we do it here, only when it's needed
- ClientCfg.R2EDEnabled = ! ClientCfg.R2EDEnabled;
- pIM->uninitInGame0();
- CItemGroupManager::getInstance()->uninit();
-
- ClientCfg.R2EDEnabled = ! ClientCfg.R2EDEnabled;
- ActionsContext.removeAllCombos();
-
- if ( ! ClientCfg.R2EDEnabled )
- {
- // Remove all existing keys and load them back, and load new interface config
- pIM->loadKeys();
- CWidgetManager::getInstance()->hideAllWindows();
- pIM->loadInterfaceConfig();
- pIM->loadLandmarks();
- }
- else
- {
- R2::ReloadUIFlag = true; // in R2ED mode the CEditor class deals with it
- }
- }
- pIM->configureQuitDialogBox(); // must be called after waitForUserCharReceived() to know the ring config
-
- ContinentMngr.select(UserEntity->pos(), ProgressBar); // IMPORTANT : must select continent after ui init, because ui init also load landmarks (located in the icfg file)
- // landmarks would be invisible else (RT 12239)
-
-
-
- // Update Network until current tick increase.
- LastGameCycle = NetMngr.getCurrentServerTick();
- while (LastGameCycle == NetMngr.getCurrentServerTick())
- {
- // Event server get events
- CInputHandlerManager::getInstance()->pumpEventsNoIM();
- // Update Network.
- NetMngr.update();
- IngameDbMngr.flushObserverCalls();
- NLGUI::CDBManager::getInstance()->flushObserverCalls();
- // Be nice to the system
- nlSleep(100);
- }
- LastGameCycle = NetMngr.getCurrentServerTick();
- ProgressBar.progress(1);
-
- // Create the message for the server to create the character.
- CBitMemStream out;
- if(GenericMsgHeaderMngr.pushNameToStream("CONNECTION:READY", out))
- {
- out.serial(ClientCfg.LanguageCode);
- NetMngr.push(out);
- NetMngr.send(NetMngr.getCurrentServerTick());
- }
-
- // To be sure server crash is not fault of client
- ConnectionReadySent = true; // must be called before BotChatPageAll->initAfterConnectionReady()
-
- // To reset the inputs.
- CInputHandlerManager::getInstance()->pumpEventsNoIM();
-
- if(BotChatPageAll && (! ClientCfg.R2EDEnabled))
- BotChatPageAll->initAfterConnectionReady();
-
- // Transition from background to game
- FirstFrame = true;
- }
-
- ProgressBar.finish();
-
- LoginSM.pushEvent(CLoginStateMachine::ev_enter_game);
-
- if (_DSSDown)
- {
- _DSSDown = false;
- onDssDown(true);
- }
-}
-
-void CFarTP::onFailure()
-{
- // Display message
- string reason;
- if (_Reason)
- {
- reason += ": " + (*_Reason);
- delete _Reason;
- _Reason = NULL;
- }
- else if (noUserChar)
- {
- reason += ": no characters found!";
- }
- Driver->systemMessageBox(("Unable to join shard"+reason).c_str(), "Error", UDriver::okType, UDriver::exclamationIcon);
-
- // TODO: recover from error
-
- LoginSM.pushEvent(CLoginStateMachine::ev_quit);
-}
-
-void CFarTP::onDssDown(bool forceReturn)
-{
- if (!forceReturn)
- {
- // If leaving shard, don't bother with DSS "downitude"
- if (isLeavingShard())
- return;
- // If joining shard, store event and launch it at the end of reconnection
- if (isJoiningShard())
- {
- _DSSDown = true; // note: still, some cases will make the client hang or abort, e.g. DSS down before the client receives the start pos (in ring shard)
- return;
- }
- }
-
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
- pIM->messageBoxWithHelp(CI18N::get("uiDisconnected"));
- requestReturnToPreviousSession();
-}
-
-extern bool loginFinished;
-void setLoginFinished( bool f );
-extern bool loginOK;
-
-void CFarTP::joinSessionResult(uint32 /* userId */, TSessionId /* sessionId */, uint32 /* result */, const std::string &/* shardAddr */, const std::string &/* participantStatus */)
-{
-// _LastJoinSessionResultMsg = result;
-//
-// _JoinSessionResultReceived = true;
-//
-// if (result == 0)
-// {
-// // ok, the join is successful
-//
-// FSAddr = shardAddr;
-//
-// setLoginFinished( true );
-// loginOK = true;
-//
-// LoginSM.pushEvent(CLoginStateMachine::ev_connect);
-//
-// }
-// else
-// {
-// // TODO : display the error message on client screen and log
-// nlstop;
-// }
-}
-
-
-void CFarTP::setJoinSessionResult(TSessionId sessionId, const CSecurityCode& securityCode)
-{
- _SessionIdToJoinFast = sessionId;
- _SecurityCodeForDisconnection = securityCode;
-}
-
-void CFarTP::writeSecurityCodeForDisconnection(NLMISC::IStream& msgout)
-{
- CSecurityCheckForFastDisconnection::forwardSecurityCode(msgout, _SessionIdToJoinFast, _SecurityCodeForDisconnection);
-}
-
-// Not run by the cotask but within the main loop
-void CFarTP::farTPmainLoop()
-{
- ConnectionReadySent = false;
- LoginSM.pushEvent(CLoginStateMachine::ev_far_tp_main_loop_entered);
-
- disconnectFromPreviousShard();
-
- uint nbRecoSelectCharReceived = 0;
-
- bool welcomeWindow = true;
-
- // Update network until the end of the FarTP process, before resuming the main loop
- while (!ConnectionReadySent)
- {
- // Event server get events
- CInputHandlerManager::getInstance()->pumpEventsNoIM();
-
- // Update Network.
- NetMngr.update();
- IngameDbMngr.flushObserverCalls();
- NLGUI::CDBManager::getInstance()->flushObserverCalls();
-
- // TODO: resend in case the last datagram sent was lost?
-// // check if we can send another dated block
-// if (NetMngr.getCurrentServerTick() != serverTick)
-// {
-// //
-// serverTick = NetMngr.getCurrentServerTick();
-// NetMngr.send(serverTick);
-// }
-// else
-// {
-// // Send dummy info
-// NetMngr.send();
-// }
-
- if (LoginSM.getCurrentState() == CLoginStateMachine::st_reconnect_select_char)
- {
- // Far TP part 3.2bis: go to character selection dialog
- // This is done outside the co-routine because it may need to co-routine to do an embedded server hop
- if ( FarTP.isReselectingChar() )
- {
- ++nbRecoSelectCharReceived;
- if ( nbRecoSelectCharReceived <= 1 )
- {
- ClientCfg.SelectCharacter = -1; // turn off character autoselection
- if ( ! FarTP.reselectCharacter() ) // it should not return here in farTPmainLoop() in the same state otherwise this would be called twice
- return;
- }
- else
- nlwarning( "Received more than one st_reconnect_select_char event" );
- }
- }
- else if (LoginSM.getCurrentState() == CLoginStateMachine::st_reconnect_ready)
- {
- // Don't call sendReady() within the cotask but within the main loop, as it contains
- // event/network loops that could trigger a global exit().
- sendReady();
- welcomeWindow = !isReselectingChar();
- }
-
- // Be nice to the system
- nlSleep(100);
- }
-
- // active/desactive welcome window
- if(welcomeWindow)
- initWelcomeWindow();
-}
diff --git a/code/ryzom/client/src/interface_v3/inventory_manager.cpp b/code/ryzom/client/src/interface_v3/inventory_manager.cpp
deleted file mode 100644
index 20480dc38..000000000
--- a/code/ryzom/client/src/interface_v3/inventory_manager.cpp
+++ /dev/null
@@ -1,4049 +0,0 @@
-// Ryzom - MMORPG Framework
-// Copyright (C) 2010-2019 Winch Gate Property Limited
-//
-// This source file has been modified by the following contributors:
-// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter)
-// Copyright (C) 2015-2019 Jan BOON (Kaetemi)
-//
-// 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 "stdpch.h"
-#include "nel/misc/cdb_leaf.h"
-#include "nel/misc/cdb_branch.h"
-#include "inventory_manager.h"
-#include "interface_manager.h"
-#include "bot_chat_page_trade.h"
-#include "bot_chat_page_all.h"
-#include "nel/gui/group_container.h"
-#include "nel/gui/group_menu.h"
-#include "nel/misc/cdb_leaf.h"
-#include "nel/misc/cdb_branch.h"
-#include "list_sheet_base.h"
-#include "../net_manager.h"
-#include "../user_entity.h"
-#include "../global.h"
-
-#include "nel/misc/algo.h"
-
-// TODO: remove this ugly dependence
-#include "sphrase_manager.h"
-
-// For handlers
-#include "nel/gui/action_handler.h"
-#include "nel/gui/group_editbox.h"
-#include "dbctrl_sheet.h"
-
-#include "../sheet_manager.h"
-#include "game_share/slot_equipment.h"
-#include "game_share/animal_status.h"
-#include "game_share/bot_chat_types.h"
-
-#include "../client_cfg.h"
-
-#include "../misc.h"
-
-#ifdef DEBUG_NEW
-#define new DEBUG_NEW
-#endif
-
-using namespace std;
-using namespace NLMISC;
-
-extern TSessionId CharacterHomeSessionId;
-
-extern NLMISC::CLog g_log;
-// Context help
-extern void contextHelp (const std::string &help);
-
-CTempInvManager *CTempInvManager::_Instance = NULL;
-CInventoryManager *CInventoryManager::_Instance = NULL;
-
-NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupListSheetBag, std::string, "list_sheet_bag");
-NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupIconListBag, std::string, "list_icon_bag");
-NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupListSheetFilterCLMSlot, std::string, "list_sheet_filter_clm_slot");
-NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupListSheetFilterExchangeable, std::string, "list_sheet_filter_exchangeable");
-
-// ***************************************************************************
-// db path for all the inventories (without the SERVER: prefix)
-const std::string CInventoryManager::InventoryDBs[]=
-{
- "INVENTORY:BAG",
- // MAX_INVENTORY_ANIMAL
- "INVENTORY:PACK_ANIMAL0",
- "INVENTORY:PACK_ANIMAL1",
- "INVENTORY:PACK_ANIMAL2",
- "INVENTORY:PACK_ANIMAL3",
- "INVENTORY:PACK_ANIMAL4",
- "INVENTORY:PACK_ANIMAL5",
- "INVENTORY:PACK_ANIMAL6",
- "INVENTORY:TEMP",
- "EXCHANGE:GIVE",
- "EXCHANGE:RECEIVE",
- "TRADING",
- "INVENTORY:SHARE",
- "GUILD:INVENTORY",
- "INVENTORY:ROOM",
-};
-
-static void dummyCheck()
-{
- // if this raise, correct the 2 tables above and below
- nlctassert(MAX_INVENTORY_ANIMAL==7);
-}
-
-const uint CInventoryManager::InventoryIndexes[]=
-{
- INVENTORIES::bag,
- // MAX_INVENTORY_ANIMAL
- INVENTORIES::pet_animal1,
- INVENTORIES::pet_animal2,
- INVENTORIES::pet_animal3,
- INVENTORIES::pet_animal4,
- INVENTORIES::pet_animal5,
- INVENTORIES::pet_animal6,
- INVENTORIES::pet_animal7,
- INVENTORIES::temporary,
- INVENTORIES::exchange,
- INVENTORIES::exchange_proposition,
- INVENTORIES::trading,
- INVENTORIES::reward_sharing,
- INVENTORIES::guild,
- INVENTORIES::player_room,
-};
-
-const uint CInventoryManager::NumInventories= sizeof(CInventoryManager::InventoryDBs)/sizeof(CInventoryManager::InventoryDBs[0]);
-
-
-// *************************************************************************************************
-CItemImage::CItemImage()
-{
- Sheet = NULL;
- Quality = NULL;
- Quantity = NULL;
- CreateTime = NULL;
- Serial = NULL;
- UserColor = NULL;
- Price = NULL;
- Weight= NULL;
- NameId= NULL;
- InfoVersion= NULL;
-}
-
-// *************************************************************************************************
-void CItemImage::build(CCDBNodeBranch *branch)
-{
- if (!branch) return;
- Sheet = dynamic_cast(branch->getNode(ICDBNode::CTextId("SHEET"), false));
- Quality = dynamic_cast(branch->getNode(ICDBNode::CTextId("QUALITY"), false));
- Quantity = dynamic_cast(branch->getNode(ICDBNode::CTextId("QUANTITY"), false));
- CreateTime = dynamic_cast(branch->getNode(ICDBNode::CTextId("CREATE_TIME"), false));
- Serial = dynamic_cast(branch->getNode(ICDBNode::CTextId("SERIAL"), false));
- UserColor = dynamic_cast(branch->getNode(ICDBNode::CTextId("USER_COLOR"), false));
- Price = dynamic_cast(branch->getNode(ICDBNode::CTextId("PRICE"), false));
- Weight = dynamic_cast(branch->getNode(ICDBNode::CTextId("WEIGHT"), false));
- NameId = dynamic_cast(branch->getNode(ICDBNode::CTextId("NAMEID"), false));
- InfoVersion= dynamic_cast(branch->getNode(ICDBNode::CTextId("INFO_VERSION"), false));
- ResaleFlag = dynamic_cast(branch->getNode(ICDBNode::CTextId("RESALE_FLAG"), false));
-
- // Should always have at least those one:(ie all but Price)
- nlassert(Sheet && Quality && Quantity && CreateTime && Serial && UserColor && Weight && NameId && InfoVersion);
-}
-
-uint64 CItemImage::getItemId() const
-{
- return ((uint64)getSerial() << 32) | getCreateTime();
-}
-
-// *************************************************************************************************
-void CItemInfoCache::load(const std::string &filename)
-{
- try
- {
- CIFile f;
- if (f.open(filename))
- {
- serial(f);
- }
- } catch(...)
- { }
-}
-
-void CItemInfoCache::save(const std::string &filename)
-{
- try
- {
- COFile f;
- if (f.open(filename))
- {
- serial(f);
- }
- }catch(...)
- { }
-}
-
-void CItemInfoCache::serial(NLMISC::IStream &s)
-{
- s.serialCheck(NELID("METI"));
- uint ver = 1;
- s.serialVersion(ver);
-
- uint8 byte = 1;
- if (s.isReading())
- {
- _ItemInfoCacheMap.clear();
- while(true)
- {
- uint64 key;
-
- s.serial(byte);
- if (byte == 0)
- {
- break;
- }
- s.serial(key);
- s.serial(_ItemInfoCacheMap[key].CacheCycle);
- _ItemInfoCacheMap[key].serial(s);
-
- // these are not used in item info cache
- _ItemInfoCacheMap[key].InfoVersionFromMsg = 0;
- _ItemInfoCacheMap[key].InfoVersionFromSlot = 0;
- _ItemInfoCacheMap[key].InfoVersionSlotServerWaiting = 0;
- }
- }
- else
- {
- byte = 1;
- TItemInfoCacheMap::iterator it = _ItemInfoCacheMap.begin();
- while (it != _ItemInfoCacheMap.end())
- {
- // purge item from cache if not encountered in X save
- if (it->second.CacheCycle < 10000)
- {
- // 'record exists' byte
- s.serial(byte);
-
- // item id (serial << 32 | createTime)
- uint64 key = it->first;
- s.serial(key);
-
- uint32 cycle = it->second.CacheCycle+1;
- s.serial(cycle);
-
- // item info
- it->second.serial(s);
- }
-
- ++it;
- }
- // eof of records byte
- byte = 0;
- s.serial(byte);
- }
-}
-
-const CClientItemInfo *CItemInfoCache::getItemInfo(uint32 serial, uint32 createTime) const
-{
- if (serial > 0 && createTime > 0)
- {
- uint64 itemId = ((uint64)serial << 32) | createTime;
- return getItemInfo(itemId);
- }
-
- return NULL;
-}
-
-const CClientItemInfo *CItemInfoCache::getItemInfo(uint64 itemId) const
-{
- if (itemId > 0)
- {
- TItemInfoCacheMap::const_iterator it = _ItemInfoCacheMap.find(itemId);
- if (it != _ItemInfoCacheMap.end())
- return &(it->second);
- }
-
- return NULL;
-}
-
-void CItemInfoCache::readFromImpulse(uint64 itemId, CItemInfos itemInfo)
-{
- if (itemId > 0)
- {
- _ItemInfoCacheMap[itemId].readFromImpulse(itemInfo);
- _ItemInfoCacheMap[itemId].CacheCycle = 0;
- }
-}
-
-void CItemInfoCache::debugItemInfoCache() const
-{
- nlinfo("ItemInfoCache: %d entries", _ItemInfoCacheMap.size());
- uint count = 0;
- for (TItemInfoCacheMap::const_iterator it = _ItemInfoCacheMap.begin(); it != _ItemInfoCacheMap.end(); ++it)
- {
- uint32 serial = (it->first >> 32) & 0xFFFFFFFF;
- uint32 created = it->first & 0xFFFFFFFF;
- nlinfo("[%-4d] cacheCycle:%d, serial:%d, createTime:%d", count++, it->second.CacheCycle, serial, created);
- }
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
- pIM->displaySystemInfo(toString("ItemInfoCache: %d entries written to client.log", _ItemInfoCacheMap.size()));
-}
-
-// *************************************************************************************************
-// CInventoryManager
-// *************************************************************************************************
-
-// *************************************************************************************************
-CInventoryManager::CInventoryManager()
-{
- Money = NULL;
- ServerMoney = NULL;
- uint i;
- for (i = 0; i < MAX_HANDINV_ENTRIES; ++i)
- {
- Hands[i] = ServerHands[i] = 0;
- UIHands[i] = NULL;
- }
-
- for (i = 0; i < MAX_EQUIPINV_ENTRIES; ++i)
- {
- Equip[i] = ServerEquip[i] = 0;
- UIEquip[i] = NULL;
- UIEquip2[i] = NULL;
- }
-
- for (i = 0; i < MAX_BAGINV_ENTRIES; i++)
- {
- BagItemEquipped[i]= false;
- }
-
- _ItemInfoCacheFilename = toString("save/item_infos_%d.cache", CharacterHomeSessionId.asInt());
- _ItemInfoCache.load(_ItemInfoCacheFilename);
-
- nlctassert(NumInventories== sizeof(InventoryIndexes)/sizeof(InventoryIndexes[0]));
-}
-
-// ***************************************************************************
-CInventoryManager::~CInventoryManager()
-{
- _ItemInfoCache.save(_ItemInfoCacheFilename);
-}
-
-// *************************************************************************************************
-CInventoryManager *CInventoryManager::getInstance()
-{
- if( !_Instance )
- _Instance = new CInventoryManager();
- return _Instance;
-}
-
-// ***************************************************************************
-void CInventoryManager::releaseInstance()
-{
- if( _Instance )
- delete _Instance;
- _Instance = NULL;
-}
-
-// *************************************************************************************************
-CItemImage &CInventoryManager::getBagItem(uint index)
-{
- nlassert(index < MAX_BAGINV_ENTRIES);
- return Bag[index];
-}
-
-// *************************************************************************************************
-CItemImage &CInventoryManager::getTempItem(uint index)
-{
- nlassert(index < MAX_TEMPINV_ENTRIES);
- return TempInv[index];
-}
-
-// *************************************************************************************************
-CItemImage *CInventoryManager::getHandItem(uint index)
-{
- nlassert(index < MAX_HANDINV_ENTRIES);
- if (Hands[index] != 0)
- return &Bag[Hands[index]-1];
- else
- return NULL;
-}
-
-// *************************************************************************************************
-CItemImage *CInventoryManager::getEquipItem(uint index)
-{
- nlassert(index < MAX_EQUIPINV_ENTRIES);
- if (Equip[index] != 0)
- return &Bag[Equip[index]];
- else
- return NULL;
-}
-
-// *************************************************************************************************
-CDBCtrlSheet *CInventoryManager::getHandSheet(uint index)
-{
- return UIHands[index];
-}
-
-// *************************************************************************************************
-CDBCtrlSheet *CInventoryManager::getEquipSheet(uint index)
-{
- return UIEquip[index];
-}
-
-
-// *************************************************************************************************
-CItemImage &CInventoryManager::getServerBagItem(uint index)
-{
- nlassert(index < MAX_BAGINV_ENTRIES);
- return ServerBag[index];
-}
-const CItemImage &CInventoryManager::getServerBagItem(uint index) const
-{
- nlassert(index < MAX_BAGINV_ENTRIES);
- return ServerBag[index];
-}
-
-// *************************************************************************************************
-CItemImage &CInventoryManager::getServerTempItem(uint index)
-{
- nlassert(index < MAX_TEMPINV_ENTRIES);
- return ServerTempInv[index];
-}
-const CItemImage &CInventoryManager::getServerTempItem(uint index) const
-{
- nlassert(index < MAX_TEMPINV_ENTRIES);
- return ServerTempInv[index];
-}
-
-// *************************************************************************************************
-CItemImage *CInventoryManager::getServerHandItem(uint index)
-{
- nlassert(index < MAX_HANDINV_ENTRIES);
- if (ServerHands[index] != 0)
- return &ServerBag[ServerHands[index]];
- else
- return NULL;
-}
-
-// *************************************************************************************************
-CItemImage *CInventoryManager::getServerEquipItem(uint index)
-{
- nlassert(index < MAX_EQUIPINV_ENTRIES);
- if (ServerEquip[index] != 0)
- return &ServerBag[ServerEquip[index]];
- else
- return NULL;
-}
-
-// *************************************************************************************************
-uint64 CInventoryManager::getMoney() const
-{
- return Money ? Money->getValue64() : 0;
-}
-
-// *************************************************************************************************
-void CInventoryManager::setMoney(uint64 value)
-{
- if (Money) Money->setValue64(value);
-}
-
-// *************************************************************************************************
-uint64 CInventoryManager::getServerMoney() const
-{
- return ServerMoney ? ServerMoney->getValue64() : 0;
-}
-
-// *************************************************************************************************
-void CInventoryManager::setServerMoney(uint64 value)
-{
- if (ServerMoney) ServerMoney->setValue64(value);
-}
-// *************************************************************************************************
-void CInventoryManager::init()
-{
- CInterfaceManager *im = CInterfaceManager::getInstance();
- // LOCAL DB
- initItemArray(LOCAL_INVENTORY ":BAG", Bag, MAX_BAGINV_ENTRIES);
- initItemArray(LOCAL_INVENTORY ":TEMP", TempInv, MAX_TEMPINV_ENTRIES);
- Money = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":MONEY");
- initIndirection (LOCAL_INVENTORY ":HAND:", Hands, MAX_HANDINV_ENTRIES, true);
- initIndirection (LOCAL_INVENTORY ":EQUIP:", Equip, MAX_EQUIPINV_ENTRIES, true);
- // Init observers for auto equipment
- {
- for (uint i = 0; i < MAX_BAGINV_ENTRIES; ++i)
- {
- CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(i) + ":SHEET");
- ICDBNode::CTextId textId;
- pNL->addObserver(&_DBBagObs, textId);
- }
- }
- // Init Animals
- for(uint i=0;igetDbProp(SERVER_INVENTORY ":MONEY");
- // Init Animals
- for(uint i=0;i(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND_RIGHT));
- UIHands[1] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND_LEFT));
-
- UIEquip[SLOT_EQUIPMENT::HEADDRESS] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_HEADDRESS));
- UIEquip[SLOT_EQUIPMENT::EARL] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_EARING_LEFT));
- UIEquip[SLOT_EQUIPMENT::EARR] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_EARING_RIGHT));
- UIEquip[SLOT_EQUIPMENT::NECKLACE] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_NECK));
- UIEquip[SLOT_EQUIPMENT::WRISTL] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_BRACELET_LEFT));
- UIEquip[SLOT_EQUIPMENT::WRISTR] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_BRACELET_RIGHT));
- UIEquip[SLOT_EQUIPMENT::FINGERL] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_RING_LEFT));
- UIEquip[SLOT_EQUIPMENT::FINGERR] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_RING_RIGHT));
- UIEquip[SLOT_EQUIPMENT::ANKLEL] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_ANKLET_LEFT));
- UIEquip[SLOT_EQUIPMENT::ANKLER] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_ANKLET_RIGHT));
-
- UIEquip[SLOT_EQUIPMENT::HEAD] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMOR_HEAD));
- UIEquip[SLOT_EQUIPMENT::CHEST] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMOR_CHEST));
- UIEquip[SLOT_EQUIPMENT::ARMS] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMOR_ARMS));
- UIEquip[SLOT_EQUIPMENT::FEET] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMOR_FEET));
- UIEquip[SLOT_EQUIPMENT::LEGS] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMOR_LEGS));
- UIEquip[SLOT_EQUIPMENT::HANDS] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMOR_HANDS));
-
- UIEquip2[SLOT_EQUIPMENT::HEADDRESS] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_HEADDRESS));
- UIEquip2[SLOT_EQUIPMENT::EARL] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_EARING_LEFT));
- UIEquip2[SLOT_EQUIPMENT::EARR] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_EARING_RIGHT));
- UIEquip2[SLOT_EQUIPMENT::NECKLACE] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_NECK));
- UIEquip2[SLOT_EQUIPMENT::WRISTL] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_BRACELET_LEFT));
- UIEquip2[SLOT_EQUIPMENT::WRISTR] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_BRACELET_RIGHT));
- UIEquip2[SLOT_EQUIPMENT::FINGERL] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_RING_LEFT));
- UIEquip2[SLOT_EQUIPMENT::FINGERR] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_RING_RIGHT));
- UIEquip2[SLOT_EQUIPMENT::ANKLEL] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_ANKLET_LEFT));
- UIEquip2[SLOT_EQUIPMENT::ANKLER] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_ANKLET_RIGHT));
-
- UIEquip2[SLOT_EQUIPMENT::HEAD] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMR2_HEAD));
- UIEquip2[SLOT_EQUIPMENT::CHEST] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMR2_CHEST));
- UIEquip2[SLOT_EQUIPMENT::ARMS] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMR2_ARMS));
- UIEquip2[SLOT_EQUIPMENT::FEET] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMR2_FEET));
- UIEquip2[SLOT_EQUIPMENT::LEGS] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMR2_LEGS));
- UIEquip2[SLOT_EQUIPMENT::HANDS] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMR2_HANDS));
-
-
- // Init ItemInfoObservers
- {
- CCDBNodeLeaf *nodeTS;
-
- nodeTS= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:SESSION", false);
- if( nodeTS )
- {
- ICDBNode::CTextId textId;
- nodeTS->addObserver(&_DBTradeInfoObs, textId);
- }
-
- // Init All Version obs
- for(uint i=0;igetDbProp("SERVER:" + InventoryDBs[i] + ":" + toString(j) + ":INFO_VERSION", false);
- CCDBNodeLeaf *nodeSH= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:" + InventoryDBs[i] + ":" + toString(j) + ":SHEET", false);
- if( nodeIV && nodeSH )
- {
- ICDBNode::CTextId textIdIV, textIdSH;
- nodeIV->addObserver(&_DBInfoSlotVersionObs, textIdIV);
- nodeSH->addObserver(&_DBItemSheetObs, textIdSH);
- // if current value!=0, simulate a receive item info obs
- if(nodeIV->getValue32())
- {
- onReceiveItemInfoSlotVersion(nodeIV);
- }
- }
- else
- // stop here for this inventory
- break;
- }
- }
- }
- }
-}
-
-// *************************************************************************************************
-void CInventoryManager::initItemArray(const std::string &dbBranchName, CItemImage *dest, uint numItems)
-{
- nlassert(dest);
- CInterfaceManager *im = CInterfaceManager::getInstance();
- CCDBNodeBranch *branch = NLGUI::CDBManager::getInstance()->getDbBranch(dbBranchName);
- if (!branch)
- {
- nlwarning("Can't init inventory image from branch %s.", dbBranchName.c_str());
- return;
- }
- for(uint k = 0; k < numItems; ++k)
- {
- CCDBNodeBranch *itemBranch = dynamic_cast(branch->getNode((uint16) k));
- if (!itemBranch)
- {
- nlwarning("Can't retrieve item %d of branch %s", (int) k, dbBranchName.c_str());
- }
- else
- {
- dest[k].build(itemBranch);
- }
- }
-}
-
-// ***************************************************************************
-void CInventoryManager::initIndirection(const std::string &dbbranch, sint32 *indices, sint32 nbIndex, bool putObs)
-{
- CInterfaceManager *im = CInterfaceManager::getInstance();
- for (uint i = 0 ; i < (uint)nbIndex; ++i)
- {
- CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(dbbranch + toString(i) + ":INDEX_IN_BAG");
- if (putObs)
- {
- ICDBNode::CTextId textId;
- pNL->addObserver(&_DBEquipObs, textId);
- }
- if (pNL != NULL)
- indices[i] = pNL->getValue32();
- }
-}
-
-// ***************************************************************************
-void CInventoryManager::beginDrag(CDBCtrlSheet *pCS, TFrom From)
-{
- DNDCurrentItem = pCS;
- if (pCS)
- CDBCtrlSheet::setCurrSelSheet(pCS);
- DNDFrom = From;
-}
-
-// ***************************************************************************
-void CInventoryManager::endDrag()
-{
- DNDCurrentItem = NULL;
- DNDFrom = Nowhere;
-}
-
-// ***************************************************************************
-// Used for interface objects which are reference in bag (the getSheet() returns INDEX_IN_BAG)
-std::string CInventoryManager::getDBIndexPath(CDBCtrlSheet *pCS)
-{
- string sTmp;
- uint i;
- for (i = 0; i < MAX_HANDINV_ENTRIES; ++i)
- {
- if (UIHands[i] == pCS)
- {
- return string(LOCAL_INVENTORY) + ":HAND:" + toString(i);
- }
- }
-
- for (i = 0; i < MAX_EQUIPINV_ENTRIES; ++i)
- {
- if (UIEquip[i] == pCS)
- {
- return string(LOCAL_INVENTORY) + ":EQUIP:" + toString(i);
- }
- if (UIEquip2[i] == pCS)
- {
- return string(LOCAL_INVENTORY) + ":EQUIP:" + toString(i);
- }
- }
- return "";
-}
-
-// ***************************************************************************
-bool CInventoryManager::is2HandItem(uint32 sheetID)
-{
- bool result = false;
- CEntitySheet *sheet= SheetMngr.get(CSheetId(sheetID));
- if(sheet && sheet->type()== CEntitySheet::ITEM)
- {
- CItemSheet *item= (CItemSheet*)sheet;
- if( item->hasSlot(SLOTTYPE::TWO_HANDS) || item->hasSlot(SLOTTYPE::RIGHT_HAND_EXCLUSIVE) )
- result = true;
- }
- return result;
-}
-
-// ***************************************************************************
-bool CInventoryManager::isMeleeWeaponItem(uint32 sheetID)
-{
- bool result = false;
- CEntitySheet *sheet= SheetMngr.get(CSheetId(sheetID));
- if(sheet && sheet->type()== CEntitySheet::ITEM)
- {
- CItemSheet *item= (CItemSheet*)sheet;
- if( item->Family == ITEMFAMILY::MELEE_WEAPON )
- result = true;
- }
- return result;
-}
-
-// ***************************************************************************
-bool CInventoryManager::isRangeWeaponItem(uint32 sheetID)
-{
- bool result = false;
- CEntitySheet *sheet= SheetMngr.get(CSheetId(sheetID));
- if(sheet && sheet->type()== CEntitySheet::ITEM)
- {
- CItemSheet *item= (CItemSheet*)sheet;
- if( item->Family == ITEMFAMILY::RANGE_WEAPON )
- result = true;
- }
- return result;
-}
-
-// ***************************************************************************
-bool CInventoryManager::isDagger(uint32 sheetID)
-{
- bool result = false;
- CEntitySheet *sheet= SheetMngr.get(CSheetId(sheetID));
- if(sheet && sheet->type()== CEntitySheet::ITEM)
- {
- CItemSheet *item= (CItemSheet*)sheet;
- if( item->ItemType == ITEM_TYPE::DAGGER)
- result = true;
- }
- return result;
-}
-
-// ***************************************************************************
-bool CInventoryManager::isSword(uint32 sheetID)
-{
- bool result = false;
- CEntitySheet *sheet= SheetMngr.get(CSheetId(sheetID));
- if(sheet && sheet->type()== CEntitySheet::ITEM)
- {
- CItemSheet *item= (CItemSheet*)sheet;
- if( item->ItemType == ITEM_TYPE::SWORD)
- result = true;
- }
- return result;
-}
-
-// ***************************************************************************
-bool CInventoryManager::isForageToolItem(uint32 sheetID)
-{
- bool result = false;
- CEntitySheet *sheet= SheetMngr.get(CSheetId(sheetID));
- if(sheet && sheet->type()== CEntitySheet::ITEM)
- {
- CItemSheet *item= (CItemSheet*)sheet;
- if( item->Family == ITEMFAMILY::HARVEST_TOOL )
- result = true;
- }
- return result;
-}
-
-// ***************************************************************************
-uint32 CInventoryManager::getHandItemSheet( bool rightHand ) const
-{
- CSheetId item;
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
- string dbPropPath = toString("LOCAL:INVENTORY:HAND:%d:INDEX_IN_BAG",rightHand?0:1);
- // get the RightHand bag index
- sint32 itemSlot= NLGUI::CDBManager::getInstance()->getDbProp(dbPropPath)->getValue32();
- // if something in hand
- if(itemSlot>0)
- {
- CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:BAG:"+toString(itemSlot-1) +":SHEET", false);
- if(node)
- item= node->getValue32();
- }
- return item.asInt();
-}
-
-
-// ***************************************************************************
-bool CInventoryManager::isLeftHandItemCompatibleWithRightHandItem(uint32 leftHandSheet, uint32 rightHandSheet, uint32 lastRightHandSheet)
-{
- CEntitySheet *pLastRight = SheetMngr.get (CSheetId(lastRightHandSheet));
- if (pLastRight != NULL)
- {
- if (pLastRight->type() != CEntitySheet::ITEM) return false;
- CItemSheet *pIsLastRight = (CItemSheet *)pLastRight;
-
- // Last item in right hand is a 2 hand item and the new item is nothing (unequip)
- if (pIsLastRight->hasSlot(SLOTTYPE::TWO_HANDS) || pIsLastRight->hasSlot(SLOTTYPE::RIGHT_HAND_EXCLUSIVE))
- return false;
- }
-
- if (leftHandSheet == 0) return true;
-
- CEntitySheet *pLeft = SheetMngr.get (CSheetId(leftHandSheet));
- if (pLeft == NULL) return false;
- if (pLeft->type() != CEntitySheet::ITEM) return false;
- CItemSheet *pIsLeft = (CItemSheet *)pLeft;
-
- if ((pIsLeft->Family == ITEMFAMILY::AMMO) && (rightHandSheet == 0))
- return false;
-
- if ((pIsLeft->ItemType == ITEM_TYPE::DAGGER) && (rightHandSheet == 0))
- return false;
-
- CEntitySheet *pRight = SheetMngr.get (CSheetId(rightHandSheet));
- if (pRight == NULL) return true;
- if (pRight->type() != CEntitySheet::ITEM) return true;
- CItemSheet *pIsRight = (CItemSheet *)pRight;
-
- if (pIsRight->Family == ITEMFAMILY::RANGE_WEAPON)
- {
- if (pIsLeft->Family == ITEMFAMILY::AMMO)
- if (pIsRight->RangeWeapon.Skill == pIsLeft->Ammo.Skill)
- return true;
- }
-
- if (pIsLeft->ItemType == ITEM_TYPE::DAGGER)
- {
- if ((pIsRight->ItemType == ITEM_TYPE::SWORD) || (pIsRight->ItemType == ITEM_TYPE::DAGGER))
- return true;
- else
- return false;
- }
-
- if (!pIsRight->hasSlot(SLOTTYPE::TWO_HANDS) && !pIsRight->hasSlot(SLOTTYPE::RIGHT_HAND_EXCLUSIVE))
- {
- return true;
- }
-
- return false;
-}
-
-// ***************************************************************************
-static void grayItem (const std::string &listname, sint32 bagEntryIndex, bool gray)
-{
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
-
- IListSheetBase *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(listname));
-
- if (pList != NULL)
- {
- pList->invalidateCoords();
-
- for(uint i = 0; i < MAX_BAGINV_ENTRIES; ++i)
- {
- CDBCtrlSheet *pCS = pList->getSheet(i);
- string sTmp = pCS->getSheet();
- sTmp = sTmp.substr(sTmp.rfind(':')+1,sTmp.size());
- sint32 nTmp;
- fromString(sTmp, nTmp);
- if (nTmp == bagEntryIndex)
- pCS->setItemWeared(gray);
- }
- }
-}
-
-// ***************************************************************************
-void CInventoryManager::wearBagItem(sint32 bagEntryIndex)
-{
- if(bagEntryIndex>=0 && bagEntryIndex<(sint32)MAX_BAGINV_ENTRIES)
- {
- BagItemEquipped[bagEntryIndex]= true;
- grayItem (LIST_BAG_TEXT, bagEntryIndex, true);
- grayItem (LIST_BAG_ICONS, bagEntryIndex, true);
- sortBag();
- }
-}
-
-// ***************************************************************************
-void CInventoryManager::unwearBagItem(sint32 bagEntryIndex)
-{
- if(bagEntryIndex>=0 && bagEntryIndex<(sint32)MAX_BAGINV_ENTRIES)
- {
- BagItemEquipped[bagEntryIndex]= false;
- grayItem (LIST_BAG_TEXT, bagEntryIndex, false);
- grayItem (LIST_BAG_ICONS, bagEntryIndex, false);
- sortBag();
- }
-}
-
-// ***************************************************************************
-bool CInventoryManager::isBagItemWeared(sint32 bagEntryIndex)
-{
- if(bagEntryIndex>=0 && bagEntryIndex<(sint32)MAX_BAGINV_ENTRIES)
- {
- return BagItemEquipped[bagEntryIndex];
- }
-
- return false;
-}
-
-// ----------------------------------------------------------------------------
-static bool isSwimming()
-{
- if (UserEntity != NULL)
- return (UserEntity->mode() == MBEHAV::SWIM || UserEntity->mode() == MBEHAV::MOUNT_SWIM);
- else
- return false;
-}
-
-static bool isRiding()
-{
- if (UserEntity)
- return UserEntity->isRiding();
- else
- return false;
-}
-
-static bool isStunned()
-{
- if (UserEntity != NULL)
- return (UserEntity->behaviour() == MBEHAV::STUNNED);
- else
- return false;
-}
-
-static bool isDead()
-{
- if (UserEntity != NULL)
- return (UserEntity->mode() == MBEHAV::DEATH);
- else
- return false;
-}
-
-// ----------------------------------------------
-// equip
-//
-// ----------------------------------------------
-void CInventoryManager::equip(const std::string &bagPath, const std::string &invPath)
-{
- if (isSwimming() || isStunned() || isDead() || isRiding()) return;
-
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
-
- if (bagPath.empty() || invPath.empty())
- {
- return;
- }
-
- // Get inventory and slot
- string sIndexInBag = bagPath.substr(bagPath.rfind(':')+1,bagPath.size());
- uint16 indexInBag;
- fromString(sIndexInBag, indexInBag);
-
- uint16 inventory = INVENTORIES::UNDEFINED;
- uint16 invSlot = 0xffff;
-
- if (strnicmp(invPath.c_str(),"LOCAL:INVENTORY:HAND",20) == 0)
- {
- inventory = INVENTORIES::handling;
- fromString(invPath.substr(21,invPath.size()), invSlot);
- }
- else if (strnicmp(invPath.c_str(),"LOCAL:INVENTORY:EQUIP",21) == 0)
- {
- inventory = INVENTORIES::equipment;
- fromString(invPath.substr(22,invPath.size()), invSlot);
- }
-
- // Hands management : check if we have to unequip left hand because of incompatibility with right hand item
- sint16 oldRightIndexInBag = NLGUI::CDBManager::getInstance()->getDbProp(invPath + ":INDEX_IN_BAG")->getValue16();
- if (inventory == INVENTORIES::handling && invSlot == 0)
- {
- CDBCtrlSheet *pCSLeftHand = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND_LEFT));
- if (pCSLeftHand == NULL)
- {
- return;
- }
-
- // get sheet of left item
- uint32 leftSheet = 0;
- CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":HAND:1:INDEX_IN_BAG", false);
- if (pNL == NULL)
- {
- return;
- }
- if (pNL->getValue32() > 0)
- {
- CCDBNodeLeaf *pNL2 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(pNL->getValue32()-1) + ":SHEET", false);
- if (pNL2 == NULL)
- {
- return;
- }
- leftSheet = pNL2->getValue32();
- }
-
- // get sheet of previous right hand item
- uint32 lastRightSheet = 0;
- if (oldRightIndexInBag > 0)
- {
- pNL = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(oldRightIndexInBag-1) + ":SHEET", false);
- if (pNL == NULL)
- {
- return;
- }
- lastRightSheet = pNL->getValue32();
- }
-
- // get sheet of new right hand item
- uint32 rightSheet = 0;
- if (indexInBag+1 > 0)
- {
- pNL = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(indexInBag) + ":SHEET", false);
- if (pNL == NULL)
- {
- return;
- }
- rightSheet = pNL->getValue32();
- }
-
- // If incompatible -> remove
- if (!getInventory().isLeftHandItemCompatibleWithRightHandItem(leftSheet, rightSheet, lastRightSheet))
- {
- getInventory().unequip(LOCAL_INVENTORY ":HAND:1");
- }
- }
-
- // update the equip DB pointer
- NLGUI::CDBManager::getInstance()->getDbProp(invPath + ":INDEX_IN_BAG")->setValue16(indexInBag+1);
-
- // Yoyo add: when the user equip an item, the action are invalid during some time
- if(indexInBag < MAX_BAGINV_ENTRIES)
- {
- CItemSheet *pIS= dynamic_cast(SheetMngr.get(CSheetId(getBagItem(indexInBag).getSheetID())));
- if(pIS)
- {
- CSPhraseManager *pPM= CSPhraseManager::getInstance();
- pPM->setEquipInvalidation(NetMngr.getCurrentServerTick(), pIS->EquipTime);
- }
- }
-
- // Update trade window if any
- if ((BotChatPageAll != NULL) && (BotChatPageAll->Trade != NULL))
- BotChatPageAll->Trade->invalidateCoords();
-
- // Send message to the server
- if (inventory != INVENTORIES::UNDEFINED)
- {
- CBitMemStream out;
- const string sMsg = "ITEM:EQUIP";
- if (GenericMsgHeaderMngr.pushNameToStream(sMsg, out))
- {
- // Fill the message (equipped inventory, equipped inventory slot, bag slot)
- out.serial(inventory);
- out.serial(invSlot);
- out.serial(indexInBag);
- NetMngr.push (out);
-
- pIM->incLocalSyncActionCounter();
-
- //nlinfo("impulseCallBack : %s %d %d %d sent", sMsg.c_str(), inventory, invSlot, indexInBag);
- }
- else
- {
- nlwarning ("don't know message name %s", sMsg.c_str());
- }
- }
-}
-
-
-
-// ----------------------------------------------
-// unequip
-//
-// ----------------------------------------------
-void CInventoryManager::unequip(const std::string &invPath)
-{
- if (isSwimming() || isStunned() || isDead() ) return;
-
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
-
- sint16 oldIndexInBag = NLGUI::CDBManager::getInstance()->getDbProp(invPath + ":INDEX_IN_BAG")->getValue16();
- if( oldIndexInBag == 0 )
- {
- return;
- }
-
- // Get inventory and slot
- uint16 inventory = INVENTORIES::UNDEFINED;
- uint16 invSlot = 0xffff;
-
- if (strnicmp(invPath.c_str(),"LOCAL:INVENTORY:HAND",20) == 0)
- {
- inventory = INVENTORIES::handling;
- fromString(invPath.substr(21,invPath.size()), invSlot);
- }
- else if (strnicmp(invPath.c_str(),"LOCAL:INVENTORY:EQUIP",21) == 0)
- {
- inventory = INVENTORIES::equipment;
- fromString(invPath.substr(22,invPath.size()), invSlot);
- }
-
- // Hands management : check if we have to unequip left hand because of incompatibility with right hand item
- if (inventory == INVENTORIES::handling && invSlot == 0)
- {
- CDBCtrlSheet *pCSLeftHand = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND_LEFT));
- if (pCSLeftHand == NULL)
- {
- return;
- }
-
- // get sheet of left item
- uint32 leftSheet = 0;
- CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":HAND:1:INDEX_IN_BAG", false);
- if (pNL == NULL)
- {
- return;
- }
- if (pNL->getValue32() > 0)
- {
- CCDBNodeLeaf *pNL2 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(pNL->getValue32()-1) + ":SHEET", false);
- if (pNL2 == NULL)
- {
- return;
- }
- leftSheet = pNL2->getValue32();
- }
-
- // get sheet of previous right hand item
- uint32 lastRightSheet = 0;
- if (oldIndexInBag > 0)
- {
- pNL = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(oldIndexInBag-1) + ":SHEET", false);
- if (pNL == NULL)
- {
- return;
- }
- lastRightSheet = pNL->getValue32();
- }
-
- // sheet of new right hand item
- uint32 rightSheet = 0;
-
- // If incompatible -> remove
- if (!getInventory().isLeftHandItemCompatibleWithRightHandItem(leftSheet, rightSheet, lastRightSheet))
- {
- getInventory().unequip(LOCAL_INVENTORY ":HAND:1");
- }
- }
-
- NLGUI::CDBManager::getInstance()->getDbProp(invPath + ":INDEX_IN_BAG")->setValue16(0);
-
- // Update trade window if any
- if ((BotChatPageAll != NULL) && (BotChatPageAll->Trade != NULL))
- BotChatPageAll->Trade->invalidateCoords();
-
- // Send message to the server
- if (inventory != INVENTORIES::UNDEFINED)
- {
- CBitMemStream out;
- const string sMsg = "ITEM:UNEQUIP";
- if (GenericMsgHeaderMngr.pushNameToStream(sMsg, out))
- {
- // Fill the message (equipped inventory, equipped inventory slot)
- out.serial(inventory);
- out.serial(invSlot);
- NetMngr.push (out);
-
- pIM->incLocalSyncActionCounter();
-
- //nlinfo("impulseCallBack : %s %d %d sent", sMsg.c_str(), inventory, invSlot);
- }
- else
- {
- nlwarning ("don't know message name %s", sMsg.c_str());
- }
- }
-}
-
-
-// ***************************************************************************
-// Observer on DB equipment branch
-// ***************************************************************************
-void CInventoryManager::CDBEquipObs::update(ICDBNode* node)
-{
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- string sTmp = node->getFullName();
- string sIE, sIE2; // Interface Element
- CCDBNodeLeaf *pNL = dynamic_cast(node);
- if (pNL == NULL) return;
- if (strnicmp(sTmp.c_str(),"LOCAL:INVENTORY:HAND",20) == 0)
- {
- // Coming from hand
- sTmp = sTmp.substr(21,sTmp.size());
- sTmp = sTmp.substr(0,sTmp.rfind(':'));
- sint index;
- fromString(sTmp, index);
- if (index == 0)
- sIE = CTRL_HAND_RIGHT;
- else
- sIE = CTRL_HAND_LEFT;
- // update Hands.
- getInventory().Hands[index]= pNL->getValue16();
- }
- else if (strnicmp(sTmp.c_str(),"LOCAL:INVENTORY:EQUIP",21) == 0)
- {
- // Coming from equipement
- sTmp = sTmp.substr(22,sTmp.size());
- sTmp = sTmp.substr(0,sTmp.rfind(':'));
- sint32 nTmp;
- fromString(sTmp, nTmp);
- SLOT_EQUIPMENT::TSlotEquipment index = (SLOT_EQUIPMENT::TSlotEquipment)nTmp;
- switch(index)
- {
- case SLOT_EQUIPMENT::HEADDRESS: sIE = CTRL_JEWEL_HEADDRESS;
- sIE2= CTRL_JEWL2_HEADDRESS; break;
- case SLOT_EQUIPMENT::EARL: sIE = CTRL_JEWEL_EARING_LEFT;
- sIE2= CTRL_JEWL2_EARING_LEFT; break;
- case SLOT_EQUIPMENT::EARR: sIE = CTRL_JEWEL_EARING_RIGHT;
- sIE2= CTRL_JEWL2_EARING_RIGHT; break;
- case SLOT_EQUIPMENT::NECKLACE: sIE = CTRL_JEWEL_NECK;
- sIE2= CTRL_JEWL2_NECK; break;
- case SLOT_EQUIPMENT::WRISTL: sIE = CTRL_JEWEL_BRACELET_LEFT;
- sIE2= CTRL_JEWL2_BRACELET_LEFT; break;
- case SLOT_EQUIPMENT::WRISTR: sIE = CTRL_JEWEL_BRACELET_RIGHT;
- sIE2= CTRL_JEWL2_BRACELET_RIGHT; break;
- case SLOT_EQUIPMENT::FINGERL: sIE = CTRL_JEWEL_RING_LEFT;
- sIE2= CTRL_JEWL2_RING_LEFT; break;
- case SLOT_EQUIPMENT::FINGERR: sIE = CTRL_JEWEL_RING_RIGHT;
- sIE2= CTRL_JEWL2_RING_RIGHT; break;
- case SLOT_EQUIPMENT::ANKLEL: sIE = CTRL_JEWEL_ANKLET_LEFT;
- sIE2= CTRL_JEWL2_ANKLET_LEFT; break;
- case SLOT_EQUIPMENT::ANKLER: sIE = CTRL_JEWEL_ANKLET_RIGHT;
- sIE2= CTRL_JEWL2_ANKLET_RIGHT; break;
-
- case SLOT_EQUIPMENT::HEAD: sIE = CTRL_ARMOR_HEAD;
- sIE2= CTRL_ARMR2_HEAD; break;
- case SLOT_EQUIPMENT::CHEST: sIE = CTRL_ARMOR_CHEST;
- sIE2= CTRL_ARMR2_CHEST; break;
- case SLOT_EQUIPMENT::ARMS: sIE = CTRL_ARMOR_ARMS;
- sIE2= CTRL_ARMR2_ARMS; break;
- case SLOT_EQUIPMENT::FEET: sIE = CTRL_ARMOR_FEET;
- sIE2= CTRL_ARMR2_FEET; break;
- case SLOT_EQUIPMENT::LEGS: sIE = CTRL_ARMOR_LEGS;
- sIE2= CTRL_ARMR2_LEGS; break;
- case SLOT_EQUIPMENT::HANDS: sIE = CTRL_ARMOR_HANDS;
- sIE2= CTRL_ARMR2_HANDS; break;
-
- default:
- nlwarning("entry not handled");
- return;
- break;
- }
- // update Equips.
- getInventory().Equip[index]= pNL->getValue16();
- }
- else return;
-
- // Set database for wearing the right item
- CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sIE));
- CDBCtrlSheet *pCS2 = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sIE2));
-
- // Remove Last reference and update database
- sint16 oldVal = pNL->getOldValue16();
- sint16 newVal = pNL->getValue16();
- if (oldVal != 0)
- getInventory().unwearBagItem (oldVal-1);
-
- if (newVal != 0)
- getInventory().wearBagItem (newVal-1);
-
- // Update Display
- if (newVal == 0)
- {
- // in some case left sheet is same than right sheet so don't clear it now (ex: 2 hands item, right hand exclusive)
- if (sIE != CTRL_HAND_LEFT)
- {
- if (pCS != NULL) pCS->setSheet("");
- if (pCS2 != NULL) pCS2->setSheet("");
- }
- }
- else
- {
- if (pCS != NULL) pCS->setSheet(LOCAL_INVENTORY ":BAG:"+ toString(newVal-1));
- if (pCS2 != NULL) pCS2->setSheet(LOCAL_INVENTORY ":BAG:"+ toString(newVal-1));
- }
-
- // Hands management
- if (sIE == CTRL_HAND_RIGHT)
- {
- // if nothing in left hand -> return
- CDBCtrlSheet *pCSLeftHand = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND_LEFT));
- if (pCSLeftHand == NULL)
- {
- return;
- }
-
- // reset display of left hand
- CViewRenderer &rVR = *CViewRenderer::getInstance();
- pCSLeftHand->setTextureNoItem(rVR.getTextureIdFromName("hand_left.tga"));
- pCSLeftHand->setGrayed(false);
- pCSLeftHand->setItemSlot(SLOTTYPE::stringToSlotType("LEFT_HAND"));
- pCSLeftHand->setActionOnLeftClick("proc");
-
- // If something in left hand check if we have to remove
- {
- uint32 leftSheet = 0;
- CCDBNodeLeaf *pNL3 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":HAND:1:INDEX_IN_BAG", false);
- if (pNL3 == NULL) return;
- if (pNL3->getValue32() > 0)
- {
- CCDBNodeLeaf *pNL4 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(pNL3->getValue32()-1) + ":SHEET", false);
- if (pNL4 == NULL) return;
- leftSheet = pNL4->getValue32();
- }
-
- uint32 rightSheet = 0;
- if (newVal > 0)
- {
- pNL3 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(newVal-1) + ":SHEET", false);
- if (pNL3 == NULL) return;
- rightSheet = pNL3->getValue32();
- }
-
- uint32 lastRightSheet = 0;
- if (oldVal > 0)
- {
- pNL3 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(oldVal-1) + ":SHEET", false);
- if (pNL3 == NULL) return;
- lastRightSheet = pNL3->getValue32();
- }
-
- // If incompatible -> remove
- if (!getInventory().isLeftHandItemCompatibleWithRightHandItem(leftSheet, rightSheet, lastRightSheet))
- {
- pCSLeftHand->setSheet("");
- }
- // WORKAROUND: useful when an item is destroyed before it is unequipped (clean the left hand)
- if ((leftSheet == 0) && (rightSheet == 0))
- {
- pCSLeftHand->setSheet("");
- }
- }
-
- // update display of left hand according to new right hand item
- if (newVal > 0)
- {
- CCDBNodeLeaf *pNL2 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(newVal-1) + ":SHEET", false);
- if (pNL2 == NULL) return;
-
- if (getInventory().is2HandItem(pNL2->getValue32()))
- {
- if (getInventory().isRangeWeaponItem(pNL2->getValue32()))
- {
- pCSLeftHand->setItemSlot(SLOTTYPE::stringToSlotType("AMMO"));
- pCSLeftHand->setTextureNoItem(rVR.getTextureIdFromName("W_AM_logo.tga"));
- }
- else
- {
- pCSLeftHand->setSheet(LOCAL_INVENTORY ":BAG:"+ toString(newVal-1));
- pCSLeftHand->setGrayed(true);
- pCSLeftHand->setActionOnLeftClick("");
- }
- }
- }
- }
-
- // left hand item is changing
- if (sIE == CTRL_HAND_LEFT)
- {
- CDBCtrlSheet *pCSLeftHand = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND_LEFT));
- if ( pCSLeftHand )
- {
- CViewRenderer &rVR = *CViewRenderer::getInstance();
- pCSLeftHand->setActionOnLeftClick("proc");
- pCSLeftHand->setGrayed(false);
-
- // if now there is nothing in left hand
- if (newVal == 0)
- {
- // check if we clear display (have to manage 2 hands weapons for instance)
- bool clearLeftHandDisplay = true;
- CDBCtrlSheet * pCSRightHand = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND_RIGHT));
- if ( pCSRightHand && pCSRightHand->getSheetId() )
- {
- CCDBNodeLeaf *pNL3 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":HAND:0:INDEX_IN_BAG", false);
- if (pNL3)
- {
- if (pNL3->getValue32() > 0)
- {
- CCDBNodeLeaf *pNL4 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(pNL3->getValue32()-1) + ":SHEET", false);
- if (pNL4)
- {
- uint32 rightSheet = pNL4->getValue32();
- if (getInventory().is2HandItem(rightSheet))
- {
- if (getInventory().isRangeWeaponItem(rightSheet))
- {
- pCSLeftHand->setItemSlot(SLOTTYPE::stringToSlotType("AMMO"));
- pCSLeftHand->setTextureNoItem(rVR.getTextureIdFromName("W_AM_logo.tga"));
- }
- else
- {
- pCSLeftHand->setItemSlot(SLOTTYPE::stringToSlotType("LEFT_HAND"));
- pCSLeftHand->setTextureNoItem(rVR.getTextureIdFromName("hand_left.tga"));
- clearLeftHandDisplay = false;
- }
- }
- }
- }
- }
- }
- if(clearLeftHandDisplay)
- {
- if (pCS != NULL) pCS->setSheet("");
- if (pCS2 != NULL) pCS2->setSheet("");
- }
- }
- }
- }
-}
-
-// ***************************************************************************
-void CInventoryManager::CDBBagObs::update(ICDBNode* /* node */)
-{
- if (IngameDbMngr.initInProgress()) return;
-
- getInventory().checkIndexInBagIntegrity();
-
- // AUTO EQUIP the player with incoming item if we can put this item in an equipment slot
-
- // if we are not initializing the DB
-/*
- CCDBNodeLeaf *pNL = dynamic_cast(node);
- if (pNL != NULL)
- if (pNL->getValue32() == 0)
- return;
-
- if (IngameDbMngr.initInProgress()) return;
-
- sint bagEntryIndex;
-
- string path = node->getFullName();
- path = path.substr(0,path.rfind(':'));
- path = path.substr(path.rfind(':')+1,path.size());
-
- fromString(path, bagEntryIndex);
- // equip only if slot empty
- getInventory().autoEquip(bagEntryIndex, false);
-*/
-}
-
-// ***************************************************************************
-bool CInventoryManager::autoEquip(sint bagEntryIndex, bool allowReplace)
-{
- uint i;
-
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- IListSheetBase *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_BAG_TEXT));
- CDBCtrlSheet *pCSSrc = NULL;
-
- if (pList == NULL) return false;
-
- for (i = 0; i < MAX_BAGINV_ENTRIES; ++i)
- {
- pCSSrc = pList->getSheet(i);
- string sTmp = pCSSrc->getSheet();
- sTmp = sTmp.substr(sTmp.rfind(':')+1,sTmp.size());
- sint nTmp;
- fromString(sTmp, nTmp);
- if (nTmp == bagEntryIndex)
- break;
- }
-
- if (i == MAX_BAGINV_ENTRIES) return false;
- if (pCSSrc == NULL) return false;
-
- for (i = 0; i < MAX_HANDINV_ENTRIES; ++i)
- {
- CDBCtrlSheet *pCSDst = getInventory().getHandSheet(i);
- if (pCSDst == NULL) continue;
- string dstPath = getInventory().getDBIndexPath(pCSDst);
-
- sint32 indexDstPath = NLGUI::CDBManager::getInstance()->getDbProp(dstPath+":INDEX_IN_BAG")->getValue16();
-
- // Already something in that slot?
- if (!allowReplace && indexDstPath > 0)
- continue;
-
- // Does the source and destination are items ?
- if (pCSSrc->getType() == CCtrlSheetInfo::SheetType_Item)
- if (pCSDst->getType() == CCtrlSheetInfo::SheetType_Item)
- {
- // Right Slot ?
- if (pCSDst->canDropItem(pCSSrc))
- {
- // Ok let us equip with this item
- string srcPath = pCSSrc->getSheet();
- getInventory().equip (srcPath, dstPath);
- return true;
- }
- }
- }
-
- for (i = 0; i < MAX_EQUIPINV_ENTRIES; ++i)
- {
- CDBCtrlSheet *pCSDst = getInventory().getEquipSheet(i);
- if (pCSDst == NULL) continue;
- string dstPath = getInventory().getDBIndexPath(pCSDst);
- sint32 indexDstPath = NLGUI::CDBManager::getInstance()->getDbProp(dstPath+":INDEX_IN_BAG")->getValue16();
-
- // Already something in that slot?
- if (!allowReplace && indexDstPath > 0)
- continue;
-
- // Does the source and destination are items ?
- if (pCSSrc->getType() == CCtrlSheetInfo::SheetType_Item)
- if (pCSDst->getType() == CCtrlSheetInfo::SheetType_Item)
- {
- // Right Slot ?
- if (pCSDst->canDropItem(pCSSrc))
- {
- // Ok let us equip with this item
- string srcPath = pCSSrc->getSheet();
- getInventory().equip (srcPath, dstPath);
- return true;
- }
- }
- }
- return false;
-}
-
-// ***************************************************************************
-void CInventoryManager::dropOrDestroyItem(CDBCtrlSheet *item, CBitMemStream &out, uint16 quantity)
-{
- if (!item) return;
- uint16 inventory = (uint16) item->getInventoryIndex();
- // retrieve inventory & slot
- uint16 slot = (uint16) item->getIndexInDB();
- out.serial(inventory);
- out.serial(slot);
- out.serial(quantity);
- NetMngr.push(out);
-}
-
-// ***************************************************************************
-static void checkEquipmentIntegrity(const string &equipVal)
-{
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(equipVal+":INDEX_IN_BAG",false);
- if (pNL != NULL)
- {
- uint32 indexInBag = pNL->getValue16();
- if (indexInBag != 0)
- {
- string sTmp = string(LOCAL_INVENTORY) + ":BAG:" + toString(indexInBag-1) + ":SHEET";
- CCDBNodeLeaf *pNLBag = NLGUI::CDBManager::getInstance()->getDbProp(sTmp,false);
- if (pNLBag != NULL)
- {
- if (pNLBag->getValue32() == 0) // If no more item in this slot bag
- {
-// if (! IngameDbMngr.initInProgress()) // Commented because init is end when we received equipment
-// pNL->setValue16(0); // Reset INDEX_IN_BAG
- }
- else
- {
- // If the slot was previously empty check that there is no reference on it
- // else update the reference
- if (pNLBag->getOldValue32() == 0)
- {
- for (uint32 i = 0; i < MAX_EQUIPINV_ENTRIES; ++i)
- {
- CDBCtrlSheet *pCSDst = getInventory().getEquipSheet(i);
- if (pCSDst == NULL) continue;
- string dstPath = getInventory().getDBIndexPath(pCSDst);
- sint32 indexDstPath = NLGUI::CDBManager::getInstance()->getDbProp(dstPath+":INDEX_IN_BAG")->getValue16();
-
- // Update the sheet id of the control sheet
- if (indexDstPath == (sint32)indexInBag)
- {
- pCSDst->setSheetId(pNLBag->getValue32());
- }
- }
- }
- }
- }
- }
- }
-}
-
-// ***************************************************************************
-void CInventoryManager::checkIndexInBagIntegrity()
-{
- string sTmp;
- uint32 i;
-
- for (i = 0; i < MAX_HANDINV_ENTRIES; ++i)
- {
- sTmp = string(LOCAL_INVENTORY) + ":HAND:" + toString(i);
- checkEquipmentIntegrity(sTmp);
- }
-
- for (i = 0; i < MAX_EQUIPINV_ENTRIES; ++i)
- {
- sTmp = string(LOCAL_INVENTORY) + ":EQUIP:" + toString(i);
- checkEquipmentIntegrity(sTmp);
- }
-}
-
-// ***************************************************************************
-double CInventoryManager::getBranchBulk(const string &basePath, uint16 startItemIndex, uint16 numItems)
-{
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CCDBNodeBranch *branch = NLGUI::CDBManager::getInstance()->getDbBranch(basePath);
- if (!branch)
- {
- nlwarning(" Branch is NULL");
- return 0;
- }
-
- double totalBulk = 0;
- //
- uint16 lastIndexItem = std::min((uint16) (startItemIndex + numItems), (uint16) branch->getNbNodes());
- for (uint16 currItem = startItemIndex; currItem < lastIndexItem; ++ currItem)
- {
- ICDBNode *node = branch->getNode(currItem);
- if (node)
- {
- CCDBNodeLeaf *sheetNode = dynamic_cast(node->getNode(ICDBNode::CTextId("SHEET")));
- CCDBNodeLeaf *quantityNode = dynamic_cast(node->getNode(ICDBNode::CTextId("QUANTITY")));
- if (sheetNode && quantityNode)
- {
- // get the Sheet
- CSheetId sheetId = CSheetId(sheetNode->getValue32());
- if (sheetId != CSheetId::Unknown)
- {
- CItemSheet *itemSheet= dynamic_cast(SheetMngr.get(sheetId));
- if(itemSheet)
- {
- totalBulk += std::max((sint32)1, quantityNode->getValue32()) * itemSheet->Bulk;
- }
- }
- }
- }
- }
-
- return totalBulk;
-}
-
-/*
- *Get the number of used and max slots
- */
-void CInventoryManager::getBranchSlotCounts(const std::string &basePath, uint& nbUsedSlots, uint& nbMaxSlots )
-{
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CCDBNodeBranch *branch = NLGUI::CDBManager::getInstance()->getDbBranch(basePath);
- if (!branch)
- {
- nlwarning(" Branch is NULL");
- return;
- }
-
- nbMaxSlots = 0; // different from nbNodes, because there can be non-slots leaves (e.g. guild money...)
- nbUsedSlots = 0;
- uint nbNodes = branch->getNbNodes();
- for ( uint i=0; i!=nbNodes; ++i )
- {
- ICDBNode *node = branch->getNode(i);
- if (node)
- {
- CCDBNodeLeaf *sheetNode = dynamic_cast(node->getNode(ICDBNode::CTextId("SHEET")));
- if (sheetNode)
- {
- // Get the Sheet
- CSheetId sheetId = CSheetId(sheetNode->getValue32());
- if (sheetId != CSheetId::Unknown)
- {
- ++nbUsedSlots;
- }
-
- ++nbMaxSlots;
- }
- }
- }
-}
-
-
-// ***************************************************************************
-double CInventoryManager::getBagBulk(uint32 inventoryIndex)
-{
- nlctassert(MAX_INVENTORY_ANIMAL==7);
- if (inventoryIndex == 0)
- return getBranchBulk(LOCAL_INVENTORY ":BAG", 0, MAX_BAGINV_ENTRIES);
- else if (inventoryIndex == 1)
- return getBranchBulk(LOCAL_INVENTORY ":PACK_ANIMAL0", 0, MAX_ANIMALINV_ENTRIES);
- else if (inventoryIndex == 2)
- return getBranchBulk(LOCAL_INVENTORY ":PACK_ANIMAL1", 0, MAX_ANIMALINV_ENTRIES);
- else if (inventoryIndex == 3)
- return getBranchBulk(LOCAL_INVENTORY ":PACK_ANIMAL2", 0, MAX_ANIMALINV_ENTRIES);
- else if (inventoryIndex == 4)
- return getBranchBulk(LOCAL_INVENTORY ":PACK_ANIMAL3", 0, MAX_ANIMALINV_ENTRIES);
- else if (inventoryIndex == 5)
- return getBranchBulk(LOCAL_INVENTORY ":PACK_ANIMAL4", 0, MAX_ANIMALINV_ENTRIES);
- else if (inventoryIndex == 6)
- return getBranchBulk(LOCAL_INVENTORY ":PACK_ANIMAL5", 0, MAX_ANIMALINV_ENTRIES);
- else if (inventoryIndex == 7)
- return getBranchBulk(LOCAL_INVENTORY ":PACK_ANIMAL6", 0, MAX_ANIMALINV_ENTRIES);
- else if (inventoryIndex == 8)
- return 0;
- else if (inventoryIndex == 9)
- return 0;
- else if (inventoryIndex == 10)
- return getBranchBulk(LOCAL_INVENTORY ":TEMP", 0, MAX_TEMPINV_ENTRIES);
- return 0;
-}
-
-// ***************************************************************************
-double CInventoryManager::getItemBulk(uint32 sheetID)
-{
- CItemSheet *itemSheet= dynamic_cast(SheetMngr.get(CSheetId(sheetID)));
- if(itemSheet)
- return itemSheet->Bulk;
- return 0;
-}
-
-// ***************************************************************************
-double CInventoryManager::getMaxBagBulk(uint32 inventoryIndex)
-{
- nlctassert(MAX_INVENTORY_ANIMAL==7);
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CCDBNodeLeaf *pNL=NULL;
- if (inventoryIndex == 0)
- pNL = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:STATIC_DATA:BAG_BULK_MAX");
- else if (inventoryIndex == 1)
- pNL = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:PACK_ANIMAL:BEAST0:BULK_MAX");
- else if (inventoryIndex == 2)
- pNL = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:PACK_ANIMAL:BEAST1:BULK_MAX");
- else if (inventoryIndex == 3)
- pNL = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:PACK_ANIMAL:BEAST2:BULK_MAX");
- else if (inventoryIndex == 4)
- pNL = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:PACK_ANIMAL:BEAST3:BULK_MAX");
- else if (inventoryIndex == 5)
- pNL = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:PACK_ANIMAL:BEAST4:BULK_MAX");
- else if (inventoryIndex == 6)
- pNL = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:PACK_ANIMAL:BEAST5:BULK_MAX");
- else if (inventoryIndex == 7)
- pNL = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:PACK_ANIMAL:BEAST6:BULK_MAX");
- if (pNL != NULL)
- return pNL->getValue32();
- return 0;
-}
-
-// ***************************************************************************
-bool CInventoryManager::isSpaceInAllBagsForItem(CDBCtrlSheet *item)
-{
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CDBCtrlSheet *pCSDst = item;
- if (!pCSDst->isSheetValid()) return false;
- string sTmp = pCSDst->getSheet();
- CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp+":SHEET",false);
- CCDBNodeLeaf *pNLquantity = NLGUI::CDBManager::getInstance()->getDbProp(sTmp+":QUANTITY",false);
- if (pNL == NULL) return false;
- if (pNLquantity == NULL) return false;
-
- // Check if we can find empty space for this item (or stack of item)
- // in all of the bags that the player owe.
-
- CInventoryManager *pInv = CInventoryManager::getInstance();
- uint32 quantity = pNLquantity->getValue32();
- double totalBulk = quantity * pInv->getItemBulk(pNL->getValue32());
-// bool bPlaceFound = false;
- for (uint32 i = 0; i < 7; ++i)
- {
- if (pInv->isInventoryAvailable((INVENTORIES::TInventory)CInventoryManager::InventoryIndexes[i]))
- if ((pInv->getBagBulk(i) + totalBulk) <= pInv->getMaxBagBulk(i))
- return true;
- }
- return false;
-}
-
-// ***************************************************************************
-bool CInventoryManager::isSpaceInBagForItem(CDBCtrlSheet *item, uint32 quantity, uint32 bagId)
-{
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CDBCtrlSheet *pCSDst = item;
- if (!pCSDst->isSheetValid()) return false;
- string sTmp = pCSDst->getSheet();
- CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp+":SHEET",false);
- if (pNL == NULL) return false;
-
- // Check if we can find empty space for this item (or stack of item)
- // in a given bag that the player owe.
-
- CInventoryManager *pInv = CInventoryManager::getInstance();
- double totalBulk = quantity * pInv->getItemBulk(pNL->getValue32());
- if (pInv->isInventoryAvailable((INVENTORIES::TInventory)CInventoryManager::InventoryIndexes[bagId]))
- if ((pInv->getBagBulk(bagId) + totalBulk) <= pInv->getMaxBagBulk(bagId))
- return true;
- return false;
-}
-
-
-// ***************************************************************************
-// CTempInvManager
-// ***************************************************************************
-
-// Observers on DB
-// ***************************************************************************
-void CTempInvManager::CDBObs::update(ICDBNode* /* node */)
-{
- CTempInvManager::getInstance()->update();
-}
-
-void CTempInvManager::CDBObsType::update(ICDBNode* /* node */)
-{
- CTempInvManager::getInstance()->updateType();
-}
-
-void CTempInvManager::CDBForageQQObs::update(ICDBNode* /* node */)
-{
- CTempInvManager::getInstance()->updateForageQQ( WhichOne );
-}
-
-// ***************************************************************************
-CTempInvManager::CTempInvManager()
-{
- _Mode = TEMP_INV_MODE::Unknown;
-
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
-
- string sPath = string("LOCAL:INVENTORY:TEMP");
- for (uint i = 0; i < MAX_TEMPINV_ENTRIES; ++i)
- {
- CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sPath+":"+toString(i)+":SHEET", false);
- if (pNL != NULL)
- {
- ICDBNode::CTextId textId;
- pNL->addObserver(&_DBObs, textId);
- }
- }
- // Add Also the Mode to observe
- CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sPath+":TYPE", false);
- if(pNL)
- {
- ICDBNode::CTextId textId;
- pNL->addObserver(&_DBObsType, textId);
- }
-
- // Forage
- pNL = NLGUI::CDBManager::getInstance()->getDbProp(sPath+":ENABLE_TAKE");
- if (pNL != NULL)
- {
- ICDBNode::CTextId textId;
- pNL->addObserver(&_DBObs, textId);
- }
- pNL = NLGUI::CDBManager::getInstance()->getDbProp(sPath+":0:QUANTITY");
- _DBForageQQObs[0].WhichOne = 0;
- if (pNL != NULL)
- {
- ICDBNode::CTextId textId;
- pNL->addObserver(&_DBForageQQObs[0], textId);
- }
- pNL = NLGUI::CDBManager::getInstance()->getDbProp(sPath+":0:QUALITY");
- _DBForageQQObs[1].WhichOne = 1;
- if (pNL != NULL)
- {
- ICDBNode::CTextId textId;
- pNL->addObserver(&_DBForageQQObs[1], textId);
- }
-}
-
-// ***************************************************************************
-CTempInvManager::~CTempInvManager()
-{
-}
-
-// ***************************************************************************
-void CTempInvManager::releaseInstance()
-{
- if( _Instance )
- delete _Instance;
- _Instance = NULL;
-}
-
-// ***************************************************************************
-void CTempInvManager::update()
-{
- bool bAllEmpty = true;
- // Check the database state
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- string sPath = string("LOCAL:INVENTORY:TEMP");
- for (uint i = 0; i < MAX_TEMPINV_ENTRIES; i++)
- {
- string sTmp = sPath + ":" + toString(i) + ":SHEET";
- CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp);
-// uint32 nOldSheet = pNL->getOldValue32();
- uint32 nSheet = pNL->getValue32();
- if (nSheet != 0)
- bAllEmpty = false;
- }
-
- _Mode = (TEMP_INV_MODE::TInventoryMode)NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:TEMP:TYPE")->getValue8();
-
- CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_TEMPINV));
- if (pGC == NULL)
- return;
-
- // show/hide weight info depending on temp inventory mode
- bool displayWeight = (_Mode == TEMP_INV_MODE::Craft);
- CViewBase *weightText = dynamic_cast(pGC->getView("weight_txt"));
- if (weightText != NULL)
- weightText->setActive(displayWeight);
- CViewBase *weightImg = dynamic_cast(pGC->getView("weight"));
- if (weightImg != NULL)
- weightImg->setActive(displayWeight);
-
- if (_Mode == TEMP_INV_MODE::Forage)
- {
- // Disable/enable "Take all" button
- bool disableTake = (NLGUI::CDBManager::getInstance()->getDbProp(sPath+":ENABLE_TAKE")->getValue32() == 0);
- NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP_INV:ALL_EMPTY")->setValue32(disableTake);
- if ( disableTake )
- {
- // Display begin of forage
- pGC->setTitle( WIN_TEMPINV_TITLE_WAIT_FORAGING );
- _DBForageQQObs[0].FullValue = 0.0f;
- _DBForageQQObs[1].FullValue = 0.0f;
- }
- else
- {
- // Display forage result
- pGC->setTitle( WIN_TEMPINV_TITLE_FORAGE_RESULT );
- }
- }
- else
- {
- // Write to the UI db the empty state
- NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP_INV:ALL_EMPTY")->setValue32(bAllEmpty);
- }
-
- if (bAllEmpty)
- {
- // If all slots are empty, close the interface
- pGC->setActive(false);
- CAHManager::getInstance()->runActionHandler("phrase_update_all_memory_ctrl_regen_tick_range", NULL);
- }
- else
- {
- pGC->setActive(true);
- CAHManager::getInstance()->runActionHandler("phrase_update_all_memory_ctrl_regen_tick_range", NULL);
- // Something arrived, change text
- switch(_Mode)
- {
- case TEMP_INV_MODE::Loot: pGC->setTitle(WIN_TEMPINV_TITLE_LOOT); break;
- case TEMP_INV_MODE::Quarter: pGC->setTitle(WIN_TEMPINV_TITLE_QUARTERING); break;
- case TEMP_INV_MODE::Forage: /* see above */ break;
- case TEMP_INV_MODE::BagFull: pGC->setTitle(WIN_TEMPINV_TITLE_BAGFULL); break;
- case TEMP_INV_MODE::Craft: pGC->setTitle(WIN_TEMPINV_TITLE_CRAFT); break;
- case TEMP_INV_MODE::MissionReward: pGC->setTitle(WIN_TEMPINV_TITLE_MISSIONREWARD); break;
- case TEMP_INV_MODE::Crystallize: pGC->setTitle(WIN_TEMPINV_TITLE_CRYSTALLIZE); break;
-
- case TEMP_INV_MODE::Unknown:
- default: pGC->setTitle(WIN_TEMPINV_TITLE_ERROR); break;
- }
- }
-}
-
-// ***************************************************************************
-void CTempInvManager::updateType()
-{
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- _Mode = (TEMP_INV_MODE::TInventoryMode)NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:TEMP:TYPE")->getValue8();
- CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_TEMPINV));
- // Something arrived, change text
- switch(_Mode)
- {
- case TEMP_INV_MODE::Loot: pGC->setTitle(WIN_TEMPINV_TITLE_LOOT); break;
- case TEMP_INV_MODE::Quarter: pGC->setTitle(WIN_TEMPINV_TITLE_QUARTERING); break;
- case TEMP_INV_MODE::Forage: /* see above */ break;
- case TEMP_INV_MODE::BagFull: pGC->setTitle(WIN_TEMPINV_TITLE_BAGFULL); break;
- case TEMP_INV_MODE::Craft: pGC->setTitle(WIN_TEMPINV_TITLE_CRAFT); break;
- case TEMP_INV_MODE::MissionReward: pGC->setTitle(WIN_TEMPINV_TITLE_MISSIONREWARD); break;
- case TEMP_INV_MODE::Crystallize: pGC->setTitle(WIN_TEMPINV_TITLE_CRYSTALLIZE); break;
-
- case TEMP_INV_MODE::Unknown:
- default: /*pGC->setTitle(WIN_TEMPINV_TITLE_ERROR);*/ // do not overwrite a locally-set title with the default one when ServerAutoCopy syncs the local db during 'make item' (craft)
- break;
- }
-}
-
-// ***************************************************************************
-// Called when INVENTORY:TEMP:0:QUANTITY or INVENTORY:TEMP:0:QUALITY is modified
-// Reacts only if mode is Forage
-void CTempInvManager::updateForageQQ( uint whichOne )
-{
- if ( _Mode != TEMP_INV_MODE::Forage )
- return;
-
- // Avoid recursion, because we can't call CCDBNodeLeaf::setValue16() without calling observers!
- static bool isInUpdateForageQQ = false;
- if ( isInUpdateForageQQ )
- return;
- isInUpdateForageQQ = true;
-
- // Display forage progress with counters
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- bool disableTake = (NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:TEMP:ENABLE_TAKE")->getValue32() == 0);
- if ( disableTake )
- {
- float qt = 0.f, ql = 0.f;
- switch ( whichOne )
- {
- case 0:
- {
- CCDBNodeLeaf *leafQt = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:TEMP:0:QUANTITY");
- uint16 qtX10 = (uint16)(leafQt->getValue16());
- qt = _DBForageQQObs[whichOne].FullValue = (((float)(uint)qtX10) / 10.0f);
- leafQt->setValue16( (sint16)(sint)qt );
- ql = _DBForageQQObs[1-whichOne].FullValue;
- }
- break;
- case 1:
- {
- CCDBNodeLeaf *leafQl = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:TEMP:0:QUALITY");
- uint16 qlX10 = (uint16)(leafQl->getValue16());
- ql = _DBForageQQObs[whichOne].FullValue = (((float)(uint)qlX10) / 10.0f);
- leafQl->setValue16( (sint16)(sint)ql );
- qt = _DBForageQQObs[1-whichOne].FullValue;
- }
- break;
- default:;
- }
- ucstring title = CI18N::get( WIN_TEMPINV_TITLE_FORAGING );
- strFindReplace( title, "%qt", toString( "%.1f", qt ) );
- strFindReplace( title, "%ql", toString( "%.1f", ql ) );
- CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_TEMPINV));
- pGC->setUCTitle( title );
- }
-
- isInUpdateForageQQ = false;
-}
-
-// ***************************************************************************
-void CTempInvManager::open(TEMP_INV_MODE::TInventoryMode m)
-{
- _Mode = m;
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_TEMPINV));
-
- // In Foraging mode, we can call open() on the inventory with the same contents (e.g. when changing Forage action)
- if ( _Mode != TEMP_INV_MODE::Forage )
- {
- string sPath = string("LOCAL:INVENTORY:TEMP");
- for (uint i = 0; i < MAX_TEMPINV_ENTRIES; i++)
- {
- string sTmp = sPath + ":" + toString(i) + ":SHEET";
- CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp);
- pNL->setValue32(0);
- }
- }
- NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:TEMP:TYPE")->setValue8((uint8)_Mode);
-
- IngameDbMngr.flushObserverCalls();
- NLGUI::CDBManager::getInstance()->flushObserverCalls();
-
- if (pGC != NULL)
- {
- switch(_Mode)
- {
- case TEMP_INV_MODE::Loot: pGC->setTitle(WIN_TEMPINV_TITLE_WAIT_LOOT); break;
- case TEMP_INV_MODE::Quarter: pGC->setTitle(WIN_TEMPINV_TITLE_WAIT_QUARTERING); break;
- case TEMP_INV_MODE::Forage: pGC->setTitle(WIN_TEMPINV_TITLE_WAIT_FORAGING); break;
- case TEMP_INV_MODE::BagFull: pGC->setTitle(WIN_TEMPINV_TITLE_WAIT_BAGFULL); break;
- case TEMP_INV_MODE::Craft: pGC->setTitle(WIN_TEMPINV_TITLE_WAIT_CRAFT); break;
- case TEMP_INV_MODE::MissionReward: pGC->setTitle(WIN_TEMPINV_TITLE_WAIT_MISSIONREWARD); break;
- case TEMP_INV_MODE::Crystallize: pGC->setTitle(WIN_TEMPINV_TITLE_WAIT_CRYSTALLIZE); break;
-
- case TEMP_INV_MODE::Unknown:
- default: pGC->setTitle(WIN_TEMPINV_TITLE_WAIT_ERROR); break;
- };
-
- pGC->setActive(true);
- CAHManager::getInstance()->runActionHandler("phrase_update_all_memory_ctrl_regen_tick_range", NULL);
- }
-}
-
-// ***************************************************************************
-void CTempInvManager::close()
-{
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- string sPath = string("LOCAL:INVENTORY:TEMP");
-
- // Clear temp inventory if needed
- for (uint i = 0; i < MAX_TEMPINV_ENTRIES; i++)
- {
- string sTmp = sPath + ":" + toString(i) + ":SHEET";
- CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp);
- pNL->setValue32(0);
- }
-
- CInterfaceGroup *pIG = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_TEMPINV));
- if (pIG != NULL)
- {
- pIG->setActive(false);
- CAHManager::getInstance()->runActionHandler("phrase_update_all_memory_ctrl_regen_tick_range", NULL);
- }
-}
-
-// ***************************************************************************
-bool CTempInvManager::isOpened()
-{
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_TEMPINV));
- if (pGC != NULL)
- return pGC->getActive();
- return false;
-}
-
-// ***************************************************************************
-// BAG LISTS COMMON STUFF (sort, options ...)
-// ***************************************************************************
-
-// ***************************************************************************
-#define BAG_ITEM_NOT_SORTED 1000000
-// Used for sorting
-void initStructForItemSort(vector&vTemp, sint32 sheetId, sint32 quality, sint32 indexInList, sint32 indexInDB)
-{
- // Default value is the linear pos in the db (in case its not an item)
- vTemp[indexInList].Pos = toString("%08d", indexInDB);
-
- // if not empty
- if (sheetId != 0)
- {
- CEntitySheet *pItem = SheetMngr.get(CSheetId(sheetId));
- if ((pItem != NULL) && (pItem->Type == CEntitySheet::ITEM))
- {
- CItemSheet *pIS = safe_cast(pItem);
- vTemp[indexInList].Pos = toString("%02d", pIS->Family);
- vTemp[indexInList].Pos += toString("%03d", pIS->ItemType);
-
- // add some specific sort for raw material
- if (pIS->Family == ITEMFAMILY::RAW_MATERIAL)
- vTemp[indexInList].Pos += toString("%010d", pIS->Mp.ItemPartBF);
- else
- vTemp[indexInList].Pos += toString("%010d", 0);
-
- // add some specific sort for teleport
- if (pIS->Family == ITEMFAMILY::TELEPORT)
- vTemp[indexInList].Pos += toString("%02d%02d", pIS->ItemOrigin, pIS->Teleport.Type);
- else
- vTemp[indexInList].Pos += toString("%02d%02d", 0, 0);
-
-
- vTemp[indexInList].Pos += toString("%03d", quality);
-
- // add sort by name
- vTemp[indexInList].Pos += CSheetId(sheetId).toString();
-
-
- // add at last the index in DB. to avoid resort for items that are exaclty the same
- vTemp[indexInList].Pos += toString("%03d", indexInDB);
- }
- }
-}
-
-// ***************************************************************************
-// Used for common options
-bool SBagOptions::parse(xmlNodePtr cur, CInterfaceGroup * /* parentGroup */)
-{
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- // read params
- CXMLAutoPtr prop;
-
- // value
- prop = xmlGetProp (cur, (xmlChar*)"inv_type");
- if (prop)
- {
- InvType = CInventoryManager::invTypeFromString(prop.str());
- }
- else
- {
- InvType = CInventoryManager::InvUnknown;
- nlwarning("cannot find inventory type");
- }
-
- prop = xmlGetProp (cur, (xmlChar*)"filter_armor");
- if (prop) DbFilterArmor = NLGUI::CDBManager::getInstance()->getDbProp(prop.str());
-
- prop = xmlGetProp (cur, (xmlChar*)"filter_weapon");
- if (prop) DbFilterWeapon = NLGUI::CDBManager::getInstance()->getDbProp(prop.str());
-
- prop = xmlGetProp (cur, (xmlChar*)"filter_tool");
- if (prop) DbFilterTool = NLGUI::CDBManager::getInstance()->getDbProp(prop.str());
-
- prop = xmlGetProp (cur, (xmlChar*)"filter_pet");
- if (prop) DbFilterPet = NLGUI::CDBManager::getInstance()->getDbProp(prop.str());
-
- prop = xmlGetProp (cur, (xmlChar*)"filter_mp");
- if (prop) DbFilterMP = NLGUI::CDBManager::getInstance()->getDbProp(prop.str());
-
- prop = xmlGetProp (cur, (xmlChar*)"filter_missmp");
- if (prop) DbFilterMissMP = NLGUI::CDBManager::getInstance()->getDbProp(prop.str());
-
- prop = xmlGetProp (cur, (xmlChar*)"filter_tp");
- if (prop) DbFilterTP = NLGUI::CDBManager::getInstance()->getDbProp(prop.str());
-
- return true;
-}
-
-// ***************************************************************************
-void SBagOptions::setSearchFilter(const ucstring &s)
-{
- SearchQualityMin = 0;
- SearchQualityMax = 999;
- SearchFilter.clear();
- SearchFilterChanged = true;
-
- if (!s.empty())
- {
- std::vector words;
- splitUCString(toLower(s), ucstring(" "), words);
-
- size_t pos;
- for(int i = 0; igetValue8() != 0) != LastDbFilterArmor)
- {
- bRet = true;
- LastDbFilterArmor = (DbFilterArmor->getValue8() != 0);
- }
-
- if (DbFilterWeapon != NULL)
- if ((DbFilterWeapon->getValue8() != 0) != LastDbFilterWeapon)
- {
- bRet = true;
- LastDbFilterWeapon = (DbFilterWeapon->getValue8() != 0);
- }
-
- if (DbFilterTool != NULL)
- if ((DbFilterTool->getValue8() != 0) != LastDbFilterTool)
- {
- bRet = true;
- LastDbFilterTool = (DbFilterTool->getValue8() != 0);
- }
-
- if (DbFilterPet != NULL)
- if ((DbFilterPet->getValue8() != 0) != LastDbFilterPet)
- {
- bRet = true;
- LastDbFilterPet = (DbFilterPet->getValue8() != 0);
- }
-
- if (DbFilterMP != NULL)
- if ((DbFilterMP->getValue8() != 0) != LastDbFilterMP)
- {
- bRet = true;
- LastDbFilterMP = (DbFilterMP->getValue8() != 0);
- }
-
- if (DbFilterMissMP != NULL)
- if ((DbFilterMissMP->getValue8() != 0) != LastDbFilterMissMP)
- {
- bRet = true;
- LastDbFilterMissMP = (DbFilterMissMP->getValue8() != 0);
- }
-
- if (DbFilterTP != NULL)
- if ((DbFilterTP->getValue8() != 0) != LastDbFilterTP)
- {
- bRet = true;
- LastDbFilterTP = (DbFilterTP->getValue8() != 0);
- }
-
- if (SearchFilterChanged)
- {
- bRet = true;
- SearchFilterChanged = false;
- }
-
- return bRet;
-}
-
-// ***************************************************************************
-bool SBagOptions::canDisplay(CDBCtrlSheet *pCS) const
-{
- bool bDisplay = true;
-
- bool bFilterArmor = getFilterArmor();
- bool bFilterWeapon = getFilterWeapon();
- bool bFilterTool = getFilterTool();
- bool bFilterPet = getFilterPet();
- bool bFilterMP = getFilterMP();
- bool bFilterMissMP = getFilterMissMP();
- bool bFilterTP = getFilterTP();
-
- const CItemSheet *pIS = pCS->asItemSheet();
- if (pIS != NULL)
- {
- if (SearchFilter.size() > 0)
- {
- bool match = true;
- ucstring lcName = toLower(pCS->getItemActualName());
-
- // add item quality as a keyword to match
- if (pCS->getQuality() > 1)
- {
- lcName += ucstring(" " + toString(pCS->getQuality()));
- }
-
- for (uint i = 0; i< SearchFilter.size(); ++i)
- {
- if (lcName.find(SearchFilter[i]) == ucstring::npos)
- {
- return false;
- }
- }
- }
-
- // Quality range
- if (SearchQualityMin > pCS->getQuality() || SearchQualityMax < pCS->getQuality())
- return false;
-
- // Armor
- if ((pIS->Family == ITEMFAMILY::ARMOR) ||
- (pIS->Family == ITEMFAMILY::JEWELRY))
- if (!bFilterArmor) bDisplay = false;
-
- // Weapon
- if ((pIS->Family == ITEMFAMILY::SHIELD) ||
- (pIS->Family == ITEMFAMILY::MELEE_WEAPON) ||
- (pIS->Family == ITEMFAMILY::RANGE_WEAPON) ||
- (pIS->Family == ITEMFAMILY::AMMO) ||
- (pIS->Family == ITEMFAMILY::CRYSTALLIZED_SPELL) ||
- (pIS->Family == ITEMFAMILY::ITEM_SAP_RECHARGE) ||
- (pIS->Family == ITEMFAMILY::BRICK) )
- if (!bFilterWeapon) bDisplay = false;
-
- // Tool
- if ((pIS->Family == ITEMFAMILY::CRAFTING_TOOL) ||
- (pIS->Family == ITEMFAMILY::HARVEST_TOOL) ||
- (pIS->Family == ITEMFAMILY::TAMING_TOOL) ||
- (pIS->Family == ITEMFAMILY::TRAINING_TOOL) ||
- (pIS->Family == ITEMFAMILY::BAG))
- if (!bFilterTool) bDisplay = false;
-
- // Pet
- if (pIS->Family == ITEMFAMILY::PET_ANIMAL_TICKET)
- if (!bFilterPet) bDisplay = false;
-
- // MP
- if ((pIS->Family == ITEMFAMILY::RAW_MATERIAL) && pIS->canBuildSomeItemPart())
- if (!bFilterMP) bDisplay = false;
-
- // Mission MP
- if ((pIS->Family == ITEMFAMILY::MISSION_ITEM) ||
- (pIS->Family == ITEMFAMILY::XP_CATALYSER) ||
- (pIS->Family == ITEMFAMILY::CONSUMABLE) ||
- ((pIS->Family == ITEMFAMILY::RAW_MATERIAL) && !pIS->canBuildSomeItemPart()))
- if (!bFilterMissMP) bDisplay = false;
-
- // Teleporter Pacts
- if ((pIS->Family == ITEMFAMILY::TELEPORT))
- if (!bFilterTP) bDisplay = false;
-
- // Jobs Items
- if (pIS->Id.toString().substr(0, 6) == "rpjob_")
- bDisplay = false;
- }
-
- return bDisplay;
-}
-
-// ***************************************************************************
-// CDBGroupListSheetBag
-// ***************************************************************************
-
-
-// ***************************************************************************
-bool CDBGroupListSheetBag::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
-{
- if(!CDBGroupListSheetText::parse(cur, parentGroup))
- return false;
-
- // Parse options (type, filters ...)
- if (!_BO.parse(cur,parentGroup))
- return false;
-
- return true;
-}
-
-// ***************************************************************************
-void CDBGroupListSheetBag::checkCoords ()
-{
- CDBGroupListSheetText::checkCoords();
- if (_BO.isSomethingChanged())
- invalidateCoords();
-}
-
-// ***************************************************************************
-void CDBGroupListSheetBag::CSheetChildBag::updateViewText(CDBGroupListSheetText * /* pFather */)
-{
- // common method to update text as item
- updateViewTextAsItem();
-}
-
-// ***************************************************************************
-bool CDBGroupListSheetBag::CSheetChildBag::isSheetValid(CDBGroupListSheetText *pFather)
-{
- if (CSheetChild::isSheetValid(pFather))
- {
- // Check if the control match the filters !
- CDBGroupListSheetBag *pList = dynamic_cast(pFather);
- if (pList)
- return pList->canDisplay(Ctrl);
- }
- return false;
-}
-
-// ***************************************************************************
-void CDBGroupListSheetBag::CSheetChildBag::init(CDBGroupListSheetText *pFather, uint index)
-{
- // init my parent
- CSheetChild::init(pFather, index);
-
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
-
- // **** Bind the quality
- {
- // Basic quality
- string db= Ctrl->getSheet()+":QUALITY";
- if( NLGUI::CDBManager::getInstance()->getDbProp(db, false) )
- CurrentQuality.link ( db.c_str() );
- else
- {
- // dummy link to ui:.....
- CurrentQuality.link("UI:DUMMY:QUALITY");
- CurrentQuality.setSInt32(0);
- }
- }
-}
-
-// ***************************************************************************
-bool CDBGroupListSheetBag::CSheetChildBag::isInvalidated(CDBGroupListSheetText * /* pFather */)
-{
- // quality change
- if( CurrentQuality.getSInt32() != LastQuality )
- return true;
-
- return false;
-}
-
-// ***************************************************************************
-void CDBGroupListSheetBag::CSheetChildBag::update(CDBGroupListSheetText * /* pFather */)
-{
- LastQuality= CurrentQuality.getSInt32();
-}
-
-// ***************************************************************************
-void CDBGroupListSheetBag::onSwap (sint /* nDraggedSheet */, sint /* nDroppedSheet */)
-{
- // No more used because automatic sort
-}
-
-// ***************************************************************************
-void CDBGroupListSheetBag::sort()
-{
- vector vTemp;
-
- vTemp.resize (_MaxItems);
-
- uint i;
- for (i = 0; i < _MaxItems; ++i)
- {
- vTemp[i].SheetText = _SheetChildren[i];
-
- CDBCtrlSheet *ctrl= _SheetChildren[i]->Ctrl;
- initStructForItemSort (vTemp, ctrl->getSheetId(), ctrl->getQuality(), i, ctrl->getIndexInDB());
- }
-
- std::sort(vTemp.begin(), vTemp.end());
-
- for (i = 0; i < _MaxItems; ++i)
- {
- _SheetChildren[i] = vTemp[i].SheetText;
- }
-}
-
-// ***************************************************************************
-// CDBGroupIconListBag
-// ***************************************************************************
-
-// ***************************************************************************
-bool CDBGroupIconListBag::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
-{
- if(!CDBGroupListSheet::parse(cur, parentGroup))
- return false;
-
- // Parse options (type, filters ...)
- if (!_BO.parse(cur,parentGroup))
- return false;
-
- return true;
-}
-
-// ***************************************************************************
-void CDBGroupIconListBag::sort()
-{
- vector vTemp;
-
- vTemp.resize (_MaxItems);
-
- uint i;
- for (i = 0; i < _MaxItems; ++i)
- {
- vTemp[i].SheetIcon = _SheetChildren[i];
-
- CDBCtrlSheet *ctrl= _SheetChildren[i]->Ctrl;
- initStructForItemSort (vTemp, ctrl->getSheetId(), ctrl->getQuality(), i, ctrl->getIndexInDB());
- }
-
- std::sort(vTemp.begin(), vTemp.end());
-
- for (i = 0; i < _MaxItems; ++i)
- {
- _SheetChildren[i] = vTemp[i].SheetIcon;
- }
-}
-
-// ***************************************************************************
-void CDBGroupIconListBag::checkCoords ()
-{
- CDBGroupListSheet::checkCoords();
- if (_BO.isSomethingChanged())
- invalidateCoords();
-}
-
-// ***************************************************************************
-bool CDBGroupIconListBag::CSheetChildBag::isSheetValid(CDBGroupListSheet *pFather)
-{
- if (CSheetChild::isSheetValid(pFather))
- {
- // Check if the control match the filters !
- CDBGroupIconListBag *pList = dynamic_cast(pFather);
- if (pList)
- return pList->canDisplay(Ctrl);
- }
- return false;
-}
-
-
-
-// ***************************************************************************
-// CDBGroupListSheetFilterCLMSlot
-// ***************************************************************************
-
-// ***************************************************************************
-bool CDBGroupListSheetFilterCLMSlot::CSheetChildFilter::isSheetValid(CDBGroupListSheet *pFather)
-{
- if (CSheetChild::isSheetValid(pFather))
- {
- /* This filter look the ctrl who launch the modal where this list is displayed.
- If we can drop this ChildCtrl, on the CLM control, then ok, filtered
- Plus the ChildControl must not be locked
- */
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CDBCtrlSheet *clmCtrl = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal());
- if (!clmCtrl || !Ctrl) return false;
- if (clmCtrl->getInventoryIndex() == INVENTORIES::exchange &&
- Ctrl->getInventoryIndex() == INVENTORIES::exchange)
- {
- return false;
- }
- if ((clmCtrl->getType() == CCtrlSheetInfo::SheetType_Item) &&
- (Ctrl->getType() == CCtrlSheetInfo::SheetType_Item) )
- {
- // Ok if we can put in the slot Ctrl in clmCtrl
- if ( clmCtrl->canDropItem(Ctrl))
- {
- string sTmp = Ctrl->getSheet();
- // Look if the source is locked
- sTmp = sTmp.substr(sTmp.rfind(':')+1,sTmp.size());
- sint32 nTmp;
- fromString(sTmp, nTmp);
- if (!getInventory().isBagItemWeared(nTmp))
- return true;
- }
- }
- }
- return false;
-}
-
-// ***************************************************************************
-// CDBGroupListSheetFilterExchangeable
-// ***************************************************************************
-
-// ***************************************************************************
-bool CDBGroupListSheetFilterExchangeable::CSheetChildFilter::isSheetValid(CDBGroupListSheet *pFather)
-{
- if (CSheetChild::isSheetValid(pFather))
- {
- if(!Ctrl)
- return false;
- extern bool checkCanExchangeItem(CDBCtrlSheet *);
- return checkCanExchangeItem(Ctrl);
- }
- return false;
-}
-
-// ***************************************************************************
-void CDBGroupListSheetFilterExchangeable::sort()
-{
- vector