Add some missing tools
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* $Id:
|
||||
*/
|
||||
|
||||
// CloseWarning.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdpch.h"
|
||||
#include "client_background_downloader.h"
|
||||
#include "CloseWarning.h"
|
||||
|
||||
#include "nel/misc/i18n.h"
|
||||
|
||||
|
||||
using namespace NLMISC;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCloseWarning dialog
|
||||
|
||||
CCloseWarning::CCloseWarning(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CCloseWarning::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CCloseWarning)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CCloseWarning::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CCloseWarning)
|
||||
// NOTE: the ClassWizard will add DDX and DDV calls here
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCloseWarning, CDialog)
|
||||
//{{AFX_MSG_MAP(CCloseWarning)
|
||||
ON_WM_CLOSE()
|
||||
ON_COMMAND(IDOK, OnOK)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCloseWarning message handlers
|
||||
|
||||
BOOL CCloseWarning::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
SetIcon(AfxGetApp()->LoadIcon(IDI_MAIN_ICON), TRUE);
|
||||
GetDlgItem(IDC_CLOSE_WARNING)->SetWindowText(CI18N::get("uiBGD_CloseWarning").toString().c_str());
|
||||
GetDlgItem(IDC_DONT_SHOW_AGAIN)->SetWindowText(CI18N::get("uiBGD_DontShowAgain").toString().c_str());
|
||||
GetDlgItem(IDOK)->SetWindowText(CI18N::get("uiBGD_OK").toString().c_str());
|
||||
this->SetWindowText(CI18N::get("uiBGD_RBG").toString().c_str());
|
||||
((CButton *) GetDlgItem(IDC_DONT_SHOW_AGAIN))->SetCheck(theApp.getCloseWarningFlag() ? 0 : 1);
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CCloseWarning::OnOK()
|
||||
{
|
||||
theApp.setCloseWarningFlag(((CButton *) GetDlgItem(IDC_DONT_SHOW_AGAIN))->GetCheck() ? 0 : 1);
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
|
||||
void CCloseWarning::OnClose()
|
||||
{
|
||||
CDialog::OnClose();
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* $Id:
|
||||
*/
|
||||
|
||||
#if !defined(AFX_CLOSEWARNING_H__B55CE000_8E72_4AD1_8283_25D3A30336FD__INCLUDED_)
|
||||
#define AFX_CLOSEWARNING_H__B55CE000_8E72_4AD1_8283_25D3A30336FD__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// CloseWarning.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCloseWarning dialog
|
||||
|
||||
class CCloseWarning : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CCloseWarning(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CCloseWarning)
|
||||
enum { IDD = IDD_CLOSE_WARNING };
|
||||
// NOTE: the ClassWizard will add data members here
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CCloseWarning)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CCloseWarning)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnClose();
|
||||
afx_msg void OnOK();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_CLOSEWARNING_H__B55CE000_8E72_4AD1_8283_25D3A30336FD__INCLUDED_)
|
@ -0,0 +1,81 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by client_background_downloader.rc
|
||||
//
|
||||
#define IDD_CLIENT_BACKGROUND_DOWNLOADER_DIALOG 102
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDB_DOWNLOADER_BG 129
|
||||
#define IDI_RYZOM 130
|
||||
#define IDR_TRAY_MENU 131
|
||||
#define IDD_CLOSE_WARNING 132
|
||||
#define IDB_BG_TRAY 134
|
||||
#define IDB_DL_STOP 137
|
||||
#define IDB_PROGRESS_0 138
|
||||
#define IDB_PROGRESS_1 139
|
||||
#define IDB_PROGRESS_SUCCESS 140
|
||||
#define IDB_PROGRESS_PAUSED 145
|
||||
#define IDI_MAIN_ICON 146
|
||||
#define IDI_TRAY_ICON 147
|
||||
#define IDD_INSTALL_STEP 150
|
||||
#define IDB_INTRO 152
|
||||
#define IDD_INSTALL_TASK 153
|
||||
#define IDB_BACKGROUND0 155
|
||||
#define IDD_ERROR_BOX 156
|
||||
#define IDB_ERROR_LOGO 158
|
||||
#define IDD_CHOOSE_PACKAGE 159
|
||||
#define IDB_PACKAGE 160
|
||||
#define IDD_INSTALL_SUCCESS 161
|
||||
#define IDB_INSTALL_SUCCESS 164
|
||||
#define IDR_FR_UXT 166
|
||||
#define IDR_EN_UXT 168
|
||||
#define IDR_DE_UXT 169
|
||||
#define IDR_WK_UXT 170
|
||||
#define IDB_SHORTCUT 178
|
||||
#define IDB_APP_SHORTCUT 180
|
||||
#define IDB_PROGRESS_BG 183
|
||||
#define IDB_PROGRESS_FG 184
|
||||
#define IDB_TEST_ALPHA 185
|
||||
#define IDB_PROGRESS_ANIM 186
|
||||
#define IDB_PROGRESS_FAIL 187
|
||||
#define IDC_PROGRESS1 1000
|
||||
#define IDC_PROGRESS 1000
|
||||
#define IDC_CLOSE_WARNING 1001
|
||||
#define IDC_DONT_SHOW_AGAIN 1002
|
||||
#define IDC_STATUS_STRING 1003
|
||||
#define IDC_BYPASS 1004
|
||||
#define IDC_STATUS_BITMAP 1005
|
||||
#define IDC_THREAD_PRIORITY 1010
|
||||
#define IDC_NEWINSTALL 1013
|
||||
#define IDC_REPAIR 1014
|
||||
#define ID_CANCEL 1015
|
||||
#define IDEXIT 1016
|
||||
#define IDC_STATUS_TEXT 1017
|
||||
#define IDC_ERROR_MSG 1018
|
||||
#define IDC_MINIMAL_INSTALL 1019
|
||||
#define IDC_FULL_INSTALL 1020
|
||||
#define IDC_TORRENT 1021
|
||||
#define IDC_START_RYZOM_NOW 1022
|
||||
#define IDC_WEB_PAGE 1023
|
||||
#define IDC_BG_BITMAP 1027
|
||||
#define IDC_CURRENT_TASK 1028
|
||||
#define IDC_REMAINING_TIME 1029
|
||||
#define IDC_INTRO_TEXT 1032
|
||||
#define IDC_CONGRATS 1033
|
||||
#define IDC_FULL_PACKAGE 1034
|
||||
#define IDC_PACKAGE_TEXT 1035
|
||||
#define IDC_TASK_TYPE 1036
|
||||
#define IDC_PROGRESS_BITMAP 1037
|
||||
#define IDC_RESUME_MSG 1038
|
||||
#define IDM_SHOW_HIDE 32771
|
||||
#define IDM_DOWNLOADER_EXIT 32772
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 188
|
||||
#define _APS_NEXT_COMMAND_VALUE 32773
|
||||
#define _APS_NEXT_CONTROL_VALUE 1038
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
@ -0,0 +1,241 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// SimpleBrowser: Web browser control
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// Change History:
|
||||
//
|
||||
// April 6, 2003 - Original release, and article posted at
|
||||
// http://www.codeproject.com/useritems/SimpleBrowserForMFC.asp
|
||||
//
|
||||
// April 12, 2003 - Replaced NavigateString() with Write() and Clear().
|
||||
// - Added logic to Create() to wait for document ready.
|
||||
// - Added GetDocument() method.
|
||||
// - Added notification support.
|
||||
// - Added post data and headers to BeforeNavigate2 handling.
|
||||
//
|
||||
|
||||
#if !defined(SimpleBrowser_defined)
|
||||
#define SimpleBrowser_defined
|
||||
|
||||
#include "mshtml.h"
|
||||
|
||||
class SimpleBrowser : public CWnd {
|
||||
|
||||
public:
|
||||
|
||||
// construction and creation
|
||||
|
||||
SimpleBrowser();
|
||||
virtual ~SimpleBrowser();
|
||||
|
||||
BOOL Create(DWORD dwStyle,
|
||||
const RECT& rect,
|
||||
CWnd* pParentWnd,
|
||||
UINT nID);
|
||||
|
||||
// create browser directly
|
||||
|
||||
BOOL CreateFromControl(CWnd *pParentWnd,UINT nID);
|
||||
|
||||
// create browser in place of dialog control; the dialog control
|
||||
// identified by nID will be destroyed, and the browser will take
|
||||
// its place
|
||||
|
||||
// controls
|
||||
|
||||
void Navigate(LPCTSTR URL);
|
||||
|
||||
// navigate to URL
|
||||
|
||||
void Write(LPCTSTR string);
|
||||
|
||||
// append string to current document; note that the WebBrowser control tolerates
|
||||
// poorly formed documents, like:
|
||||
|
||||
// <html><body>....
|
||||
// --- no trailing body or html tags
|
||||
|
||||
// <html><body>...</body></html><html><body>...</body></html>...
|
||||
// --- multiple documents
|
||||
|
||||
void Clear();
|
||||
|
||||
// clear current document
|
||||
|
||||
void NavigateResource(int resource_ID);
|
||||
|
||||
// navigate to HTML document resource
|
||||
|
||||
void GoBack(); // navigate backward one item
|
||||
// in the history list
|
||||
|
||||
void GoForward(); // navigate forward one item
|
||||
// in the history list
|
||||
|
||||
void GoHome(); // navigate to current
|
||||
// home or start page
|
||||
|
||||
void Refresh(); // refresh contents
|
||||
|
||||
void Stop(); // stop current activity
|
||||
|
||||
void Print(LPCTSTR header = _T("&w&b&b&p"),
|
||||
LPCTSTR footer = _T("&d &t"));
|
||||
|
||||
// start printing contents; uses same 'metacharacters' for header and
|
||||
// footer as Internet Explorer; see IE Page Setup dialog
|
||||
|
||||
bool GetBusy(); // returns true if browser
|
||||
// busy downloading or other
|
||||
// activity
|
||||
|
||||
CString GetLocationName(); // get name of location currently
|
||||
// being browsed (title, if HTML
|
||||
// page; UNC path if file)
|
||||
|
||||
CString GetLocationURL(); // get URL of location currently
|
||||
// being browsed
|
||||
|
||||
READYSTATE GetReadyState(); // get browser ready state
|
||||
|
||||
bool GetSilent(); // get/set silent property
|
||||
void PutSilent(bool silent = false); // (if true, dialog and message
|
||||
// boxes may not be shown)
|
||||
|
||||
IHTMLDocument2 *GetDocument(); // get document interface; returns NULL
|
||||
// if interface is not available
|
||||
// (which is the case if you've navigated to
|
||||
// something that's NOT an HTML document,
|
||||
// like an Excel spreadsheet, which the
|
||||
// WebBrowser control is perfectly willing
|
||||
// to host)
|
||||
|
||||
// events (overridables)
|
||||
|
||||
virtual bool OnBeforeNavigate2(CString URL,
|
||||
CString frame,
|
||||
void *post_data,int post_data_size,
|
||||
CString headers);
|
||||
|
||||
// called before navigation begins; URL is destination, frame
|
||||
// is frame name ("" if none), post_data is HTTP POST data (NULL if none),
|
||||
// and headers are HTTP headers sent to server;
|
||||
// return true to cancel navigation, false to continue
|
||||
|
||||
virtual void OnDocumentComplete(CString URL);
|
||||
|
||||
// navigation to document complete; URL is location
|
||||
|
||||
virtual void OnDownloadBegin();
|
||||
|
||||
// navigation operation begins
|
||||
|
||||
virtual void OnProgressChange(int progress,int progress_max);
|
||||
|
||||
// navigation progress update
|
||||
|
||||
virtual void OnDownloadComplete();
|
||||
|
||||
// navigation operation completed
|
||||
|
||||
virtual void OnNavigateComplete2(CString URL);
|
||||
|
||||
// navigation to hyperlink complete; URL is location
|
||||
// (URL = string if NavigateString or NavigateResource are used)
|
||||
|
||||
virtual void OnStatusTextChange(CString text);
|
||||
|
||||
// status text has changed
|
||||
|
||||
virtual void OnTitleChange(CString text);
|
||||
|
||||
// title has changed
|
||||
|
||||
// notifications
|
||||
|
||||
enum NotificationType { // Note: SimpleBrowser does NOT support the
|
||||
// common notifications (NM_CLICK, etc.)
|
||||
|
||||
BeforeNavigate2, // set *LRESULT=TRUE to cancel navigation
|
||||
DocumentComplete,
|
||||
DownloadBegin,
|
||||
ProgressChange,
|
||||
DownloadComplete,
|
||||
NavigateComplete2,
|
||||
StatusTextChange,
|
||||
TitleChange
|
||||
|
||||
};
|
||||
|
||||
class Notification { // all notifications pass this structure
|
||||
|
||||
public:
|
||||
|
||||
Notification(HWND hwnd,UINT ID,NotificationType type);
|
||||
|
||||
NMHDR hdr; // hdr.hwndFrom = SimpleBrowser's HWND
|
||||
// hdr.idFrom = SimpleBrowser's control ID
|
||||
// hdr.code = <NavigationType>
|
||||
|
||||
CString URL; // BeforeNavigate2
|
||||
// DocumentComplete
|
||||
// NavigateComplete2
|
||||
|
||||
CString frame; // BeforeNavigate2
|
||||
void *post_data; // BeforeNavigate2
|
||||
int post_data_size;
|
||||
CString headers; // BeforeNavigate2
|
||||
|
||||
int progress; // ProgressChange
|
||||
int progress_max; // ProgressChange
|
||||
|
||||
CString text; // StatusTextChange
|
||||
// TitleChange
|
||||
|
||||
};
|
||||
|
||||
//{{AFX_VIRTUAL(SimpleBrowser)
|
||||
public:
|
||||
virtual void PostNcDestroy();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
protected:
|
||||
|
||||
//{{AFX_MSG(SimpleBrowser)
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
//}}AFX_MSG
|
||||
|
||||
void _OnBeforeNavigate2(LPDISPATCH lpDisp,
|
||||
VARIANT FAR *URL,
|
||||
VARIANT FAR *Flags,
|
||||
VARIANT FAR *TargetFrameName,
|
||||
VARIANT FAR *PostData,
|
||||
VARIANT FAR *Headers,
|
||||
VARIANT_BOOL *Cancel);
|
||||
void _OnDownloadBegin();
|
||||
void _OnProgressChange(long progress,long progress_max);
|
||||
void _OnDownloadComplete();
|
||||
void _OnDocumentComplete(LPDISPATCH lpDisp,VARIANT FAR* URL);
|
||||
void _OnNavigateComplete2(LPDISPATCH lpDisp,VARIANT FAR* URL);
|
||||
void _OnStatusTextChange(BSTR bstrText);
|
||||
void _OnTitleChange(BSTR bstrText);
|
||||
|
||||
//IHTMLDocument2 *getDocument();
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
DECLARE_EVENTSINK_MAP()
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//CWnd _BrowserWindow; // browser window
|
||||
IWebBrowser2 *_Browser; // browser control
|
||||
IDispatch *_BrowserDispatch; // browser control
|
||||
// dispatch interface
|
||||
struct IDocHostUIHandler *_DocHostUIHandler;
|
||||
struct IOleClientSite *_OleClientSite;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,10 @@
|
||||
About the project : client_background_downloader_extern_res :
|
||||
==============================================================
|
||||
|
||||
When including an external resource file in a .exe, VC++6 doesn't detect properly that the file
|
||||
has changed, and the resource file rebuild does not occur.
|
||||
To solve this problem, this utility project add a custom build step on the external files to "touch" the resource file,
|
||||
if these file are detected to be modified -> this force a recompilation of the resource file.
|
||||
The project is added as a dependency of client_background_downloader to ensure that this step will be taken first.
|
||||
For now, the final client_background_downaloder_rd.exe has the language files included has resources.
|
||||
|
After Width: | Height: | Size: 900 KiB |
@ -0,0 +1,150 @@
|
||||
// blended_bitmap.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdpch.h"
|
||||
#include "client_background_downloader.h"
|
||||
#include "blended_bitmap.h"
|
||||
#include "nel/misc/time_nl.h"
|
||||
|
||||
|
||||
/*#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif*/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CBlendedBitmap
|
||||
|
||||
CBlendedBitmap::CBlendedBitmap() : CWnd(), _BMRes(-1), _DIB(0)
|
||||
{
|
||||
_BGColor = ::GetSysColor(_BGSysColor);
|
||||
_BGSysColor = COLOR_3DFACE;
|
||||
resetDIBRect();
|
||||
}
|
||||
|
||||
CBlendedBitmap::~CBlendedBitmap()
|
||||
{
|
||||
releaseDIB();
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CBlendedBitmap, CWnd)
|
||||
//{{AFX_MSG_MAP(CBlendedBitmap)
|
||||
ON_WM_PAINT()
|
||||
ON_WM_ERASEBKGND()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
void CBlendedBitmap::releaseDIB()
|
||||
{
|
||||
if (_DIB)
|
||||
{
|
||||
DeleteObject(_DIB);
|
||||
_DIB = 0;
|
||||
resetDIBRect();
|
||||
}
|
||||
}
|
||||
|
||||
void CBlendedBitmap::resetDIBRect()
|
||||
{
|
||||
_DIBRect.left = 0;
|
||||
_DIBRect.right = 0;
|
||||
_DIBRect.top = 0;
|
||||
_DIBRect.bottom = 0;
|
||||
}
|
||||
|
||||
void CBlendedBitmap::setBitmap(int bitmapRes)
|
||||
{
|
||||
if (bitmapRes == _BMRes) return;
|
||||
releaseDIB();
|
||||
BITMAP dibInfo;
|
||||
_DIB = (HBITMAP) LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(bitmapRes), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
|
||||
if (_DIB)
|
||||
{
|
||||
if (!GetObject(_DIB, sizeof(BITMAP), (void *) &dibInfo))
|
||||
{
|
||||
releaseDIB();
|
||||
}
|
||||
_DIBRect.left = 0;
|
||||
_DIBRect.top = 0;
|
||||
_DIBRect.right = dibInfo.bmWidth;
|
||||
_DIBRect.bottom = dibInfo.bmHeight;
|
||||
_SrcRect = _DIBRect;
|
||||
}
|
||||
|
||||
_BMRes = bitmapRes;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void CBlendedBitmap::setSrcRect(const RECT &r)
|
||||
{
|
||||
_SrcRect = r;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
||||
void CBlendedBitmap::setBgColor(COLORREF color)
|
||||
{
|
||||
if (color == _BGColor) return;
|
||||
_BGColor = color;
|
||||
_BGSysColor = -1;
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void CBlendedBitmap::setSysBgColor(int sysColor)
|
||||
{
|
||||
if (sysColor == _BGSysColor) return;
|
||||
_BGSysColor = sysColor;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CBlendedImage message handlers
|
||||
|
||||
void CBlendedBitmap::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
::CRect r;
|
||||
GetClientRect(&r);
|
||||
COLORREF bgColor = (_BGSysColor != - 1) ? GetSysColor(_BGSysColor) : _BGColor;
|
||||
if (!_DIB)
|
||||
{
|
||||
dc.FillSolidRect(&r, bgColor);
|
||||
return;
|
||||
}
|
||||
CDC memoryDC;
|
||||
memoryDC.CreateCompatibleDC(&dc);
|
||||
CBitmap targetBitmap;
|
||||
targetBitmap.CreateCompatibleBitmap(&dc, r.right - r.left, r.bottom - r.top);
|
||||
/* CGdiObject *oldMemoryDCObj = (CGdiObject *) */ memoryDC.SelectObject(targetBitmap);
|
||||
CDC srcDC;
|
||||
srcDC.CreateCompatibleDC(&dc);
|
||||
// selecting a dib here garantee that no conversion occurs ; alpha is preserved
|
||||
/* CGdiObject *oldSRCDCObj = (CGdiObject *) */ srcDC.SelectObject(_DIB);
|
||||
BLENDFUNCTION bf;
|
||||
bf.BlendOp = AC_SRC_OVER;
|
||||
bf.BlendFlags = 0;
|
||||
bf.SourceConstantAlpha = 255;
|
||||
bf.AlphaFormat = 0x01; // AC_SRC_ALPHA
|
||||
memoryDC.FillSolidRect(&r, bgColor);
|
||||
BOOL res = ::AlphaBlend(memoryDC.m_hDC, r.left, r.top, r.right - r.left, r.bottom - r.top, srcDC.m_hDC, _SrcRect.left, _SrcRect.top, _SrcRect.right - _SrcRect.left, _SrcRect.bottom - _SrcRect.top, bf);
|
||||
nlassert(res != ERROR_INVALID_PARAMETER);
|
||||
// blit from memory dc into target area to have flicker free display
|
||||
dc.BitBlt(r.left, r.top, r.right - r.left, r.bottom - r.top, &memoryDC, 0, 0, SRCCOPY);
|
||||
|
||||
//srcDC.SelectObject(oldSRCDCObj);
|
||||
//memoryDC.SelectObject(oldMemoryDCObj);
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOL CBlendedBitmap::OnEraseBkgnd(CDC* pDC)
|
||||
{
|
||||
|
||||
return CWnd::OnEraseBkgnd(pDC);
|
||||
}
|
||||
|
@ -0,0 +1,68 @@
|
||||
#if !defined(AFX_BLENDED_BITMAP_H__32849754_C90E_430D_8213_CC87BA8725B8__INCLUDED_)
|
||||
#define AFX_BLENDED_BITMAP_H__32849754_C90E_430D_8213_CC87BA8725B8__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// blended_bitmap.h : header file
|
||||
//
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CBlendedBitmap window
|
||||
|
||||
class CBlendedBitmap : public CWnd
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CBlendedBitmap();
|
||||
|
||||
void setBitmap(int bitmapRes);
|
||||
void setBgColor(COLORREF color);
|
||||
void setSysBgColor(int sysColor = COLOR_3DFACE);
|
||||
|
||||
// Set the source rectangle to be blitted from the original bitmap
|
||||
void setSrcRect(const RECT &r);
|
||||
void getBitmapRect(RECT &dest) const { dest = _DIBRect; }
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CBlendedBitmap)
|
||||
protected:
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CBlendedBitmap();
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
RECT _SrcRect;
|
||||
RECT _DIBRect;
|
||||
HBITMAP _DIB;
|
||||
int _BMRes;
|
||||
COLORREF _BGColor;
|
||||
int _BGSysColor;
|
||||
//{{AFX_MSG(CBlendedBitmap)
|
||||
afx_msg void OnPaint();
|
||||
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
void resetDIBRect();
|
||||
void releaseDIB();
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_BLENDED_BITMAP_H__32849754_C90E_430D_8213_CC87BA8725B8__INCLUDED_)
|
@ -0,0 +1,117 @@
|
||||
// choose_package_dlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdpch.h"
|
||||
#include "client_background_downloader.h"
|
||||
#include "choose_package_dlg.h"
|
||||
#include "nel/misc/win32_util.h"
|
||||
#include "install_logic/game_downloader.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CChoosePackageDlg dialog
|
||||
|
||||
|
||||
CChoosePackageDlg::CChoosePackageDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CChoosePackageDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CChoosePackageDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CChoosePackageDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CChoosePackageDlg)
|
||||
DDX_Control(pDX, IDC_PACKAGE_TEXT, m_PackageText);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CChoosePackageDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CChoosePackageDlg)
|
||||
ON_BN_CLICKED(IDC_TORRENT, OnTorrent)
|
||||
ON_BN_CLICKED(IDC_FULL_PACKAGE, OnFullInstall)
|
||||
ON_BN_CLICKED(ID_CANCEL, OnCancel)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CChoosePackageDlg message handlers
|
||||
|
||||
BOOL CChoosePackageDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
SetIcon(AfxGetApp()->LoadIcon(IDI_MAIN_ICON), TRUE);
|
||||
NLMISC::CWin32Util::localizeWindow(this->m_hWnd);
|
||||
IGameDownloader* gd = IGameDownloader::getInstance();
|
||||
gd->registerChoosePackageDlg(this);
|
||||
//set Labels initial values
|
||||
gd->updateStartProcessText();
|
||||
// set Check box initial value
|
||||
((CButton *) GetDlgItem(IDC_FULL_PACKAGE))->SetCheck(gd->getUseFullVersion());
|
||||
// Do not display the Use torrent lable anymore
|
||||
((CButton *) GetDlgItem(IDC_TORRENT))->SetCheck(gd->getUseTorrent());
|
||||
((CButton *) GetDlgItem(IDC_TORRENT))->EnableWindow( gd->getTorrentExist() );
|
||||
((CButton *) GetDlgItem(IDC_TORRENT))->ShowWindow(SW_HIDE);
|
||||
|
||||
|
||||
NLMISC::CWin32Util::localizeWindow(this->m_hWnd);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CChoosePackageDlg::OnCancel()
|
||||
{
|
||||
// if on click on exit button or in the close button a widget is display. We check the current state in order to avoid cancel button -> onCancel->"do you want to quit Ryzom"->Yes->OnCancel ...
|
||||
IGameDownloader* gd = IGameDownloader::getInstance();
|
||||
if (gd->getState() != IGameDownloader::InstallFinished)
|
||||
{
|
||||
gd->doAction("download_cancel");
|
||||
if (gd->getState() == IGameDownloader::InstallFinished)
|
||||
{
|
||||
EndDialog(IDCANCEL);
|
||||
//CDialog::OnClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CChoosePackageDlg::OnTorrent()
|
||||
{
|
||||
//activate the torrent mode (only active if button is display on Torrent Mode is enabled)
|
||||
bool checked = static_cast<bool>(((CButton *) GetDlgItem(IDC_TORRENT))->GetCheck()==1);
|
||||
IGameDownloader* gd = IGameDownloader::getInstance();
|
||||
gd->doAction("download_use_torrent", checked);
|
||||
|
||||
}
|
||||
|
||||
void CChoosePackageDlg::OnFullInstall()
|
||||
{
|
||||
// activate the full install mode by clicking in the check box
|
||||
bool checked = static_cast<bool>(((CButton *) GetDlgItem(IDC_FULL_PACKAGE))->GetCheck()==1);
|
||||
IGameDownloader* gd = IGameDownloader::getInstance();
|
||||
gd->doAction("download_full_version", checked);
|
||||
}
|
||||
|
||||
void CChoosePackageDlg::OnMinimalInstall()
|
||||
{
|
||||
// obsolet code
|
||||
IGameDownloader* gd = IGameDownloader::getInstance();
|
||||
gd->doAction("download_full_version", false);
|
||||
}
|
||||
|
||||
void CChoosePackageDlg::setInstallText(const ucstring& title, const ucstring& content)
|
||||
{
|
||||
// update labels
|
||||
m_PackageText.Clear();
|
||||
m_PackageText.clear();
|
||||
m_PackageText.setFont(14, "Verdana", CFE_BOLD);
|
||||
m_PackageText.append(title);
|
||||
|
||||
ucstring content2 = "\n\n";
|
||||
content2 += content;
|
||||
m_PackageText.setFont(12, "Verdana", 0);
|
||||
m_PackageText.append(content2);
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
#if !defined(AFX_CHOOSE_PACKAGE_DLG_H__4C2CF3C5_2FAD_497D_BBB0_85475EDADBFA__INCLUDED_)
|
||||
#define AFX_CHOOSE_PACKAGE_DLG_H__4C2CF3C5_2FAD_497D_BBB0_85475EDADBFA__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// choose_package_dlg.h : header file
|
||||
//
|
||||
|
||||
|
||||
#include "rich_edit_ctrl_ex.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CChoosePackageDlg dialog
|
||||
|
||||
class CChoosePackageDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CChoosePackageDlg(CWnd* pParent = NULL); // standard constructor
|
||||
// change the content of the text displayed in the windows (change the title or the content)
|
||||
void setInstallText(const ucstring& title, const ucstring& content);
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CChoosePackageDlg)
|
||||
enum { IDD = IDD_CHOOSE_PACKAGE };
|
||||
CRichEditCtrlEx m_PackageText;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CChoosePackageDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CChoosePackageDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnCancel();
|
||||
afx_msg void OnTorrent();
|
||||
afx_msg void OnFullInstall();
|
||||
afx_msg void OnMinimalInstall();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_CHOOSE_PACKAGE_DLG_H__4C2CF3C5_2FAD_497D_BBB0_85475EDADBFA__INCLUDED_)
|
@ -0,0 +1,383 @@
|
||||
/*
|
||||
* $Id:
|
||||
*/
|
||||
|
||||
// client_background_downloader.cpp : Defines the class behaviors for the application.
|
||||
//
|
||||
|
||||
#include "stdpch.h"
|
||||
#include "client_background_downloader.h"
|
||||
#include "client_background_downloaderDlg.h"
|
||||
#include "intro_screen_dlg.h"
|
||||
#include "install_task_dlg.h"
|
||||
#include "choose_package_dlg.h"
|
||||
#include "install_success_dlg.h"
|
||||
#include "nel/misc/algo.h"
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/common.h"
|
||||
#include "../client/login_patch.h"
|
||||
#include "../client/login_progress_post_thread.h"
|
||||
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/debug.h"
|
||||
#include "nel/misc/displayer.h"
|
||||
#include "nel/misc/common.h"
|
||||
|
||||
#include "web_page_embedder.h"
|
||||
|
||||
#include "install_logic/game_downloader.h"
|
||||
|
||||
|
||||
const char *CClient_background_downloaderApp::AppRegEntry = "Software\\Nevrax\\ryzom\\background_downloader";
|
||||
const char *CClient_background_downloaderApp::RegKeyDisplayCloseWarning = "DisplayCloseWarning";
|
||||
|
||||
using NLMISC::CI18N;
|
||||
using NLMISC::CPath;
|
||||
|
||||
const char *ConfigFileName = "client.cfg";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClient_background_downloaderApp
|
||||
|
||||
BEGIN_MESSAGE_MAP(CClient_background_downloaderApp, CWinApp)
|
||||
//{{AFX_MSG_MAP(CClient_background_downloaderApp)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code!
|
||||
//}}AFX_MSG
|
||||
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClient_background_downloaderApp construction
|
||||
|
||||
CClient_background_downloaderApp::CClient_background_downloaderApp()
|
||||
{
|
||||
// TODO: add construction code here,
|
||||
// Place all significant initialization in InitInstance
|
||||
if (OleInitialize(NULL) != S_OK)
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CClient_background_downloaderApp::~CClient_background_downloaderApp()
|
||||
{
|
||||
OleUninitialize();
|
||||
CLoginProgressPostThread::getInstance().release();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// The one and only CClient_background_downloaderApp object
|
||||
|
||||
CClient_background_downloaderApp theApp;
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
bool CClient_background_downloaderApp::parseCommandLine(const std::string &commandLine)
|
||||
{
|
||||
// parse command line
|
||||
std::vector<std::string> args;
|
||||
NLMISC::splitString(commandLine, " ", args);
|
||||
|
||||
//if (args.size() < 4)
|
||||
if (args.size() < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (uint k = 0; k < args.size(); ++k)
|
||||
{
|
||||
while (NLMISC::strFindReplace(args[k], "\"", "")) {}
|
||||
}
|
||||
extern std::string R2ServerVersion;
|
||||
extern std::string VersionName;
|
||||
//R2ServerVersion = args[0];
|
||||
//VersionName = args[1];
|
||||
//ServerPath = args[2];
|
||||
//ServerVersion = args[3];
|
||||
ServerPath = args[0];
|
||||
ServerVersion = args[1];
|
||||
VersionName = ServerVersion;
|
||||
PatchURIs.clear();
|
||||
for (uint k = 4; k < args.size(); ++k)
|
||||
{
|
||||
PatchURIs.push_back(args[k]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CClient_background_downloaderApp::initLog(const char *appName)
|
||||
{
|
||||
NLMISC::createDebug();
|
||||
NLMISC::CFileDisplayer *RBGLogDisplayer = new NLMISC::CFileDisplayer(appName, true, "CLIENT.LOG");
|
||||
NLMISC::DebugLog->addDisplayer (RBGLogDisplayer);
|
||||
NLMISC::InfoLog->addDisplayer (RBGLogDisplayer);
|
||||
NLMISC::WarningLog->addDisplayer (RBGLogDisplayer);
|
||||
NLMISC::ErrorLog->addDisplayer (RBGLogDisplayer);
|
||||
NLMISC::AssertLog->addDisplayer (RBGLogDisplayer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct CResourceTranslationFileLoader : public CI18N::ILoadProxy
|
||||
{
|
||||
virtual void loadStringFile(const std::string &filename, ucstring &text)
|
||||
{
|
||||
bool ok = false;
|
||||
int resID = 0;
|
||||
if (NLMISC::nlstricmp(filename, "en.uxt") == 0)
|
||||
{
|
||||
resID = IDR_EN_UXT;
|
||||
}
|
||||
else
|
||||
if (NLMISC::nlstricmp(filename, "fr.uxt") == 0)
|
||||
{
|
||||
resID = IDR_FR_UXT;
|
||||
}
|
||||
else
|
||||
if (NLMISC::nlstricmp(filename, "de.uxt") == 0)
|
||||
{
|
||||
resID = IDR_DE_UXT;
|
||||
}
|
||||
else
|
||||
if (NLMISC::nlstricmp(filename, "wk.uxt") == 0)
|
||||
{
|
||||
resID = IDR_WK_UXT;
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("No resource file found for language %s ! Using wk.uxt as a default", filename.c_str());
|
||||
resID = IDR_WK_UXT;
|
||||
}
|
||||
HRSRC hrsrc = FindResource(theApp.m_hInstance, MAKEINTRESOURCE(resID), "UXT");
|
||||
if (hrsrc)
|
||||
{
|
||||
int resSize = SizeofResource(theApp.m_hInstance, hrsrc);
|
||||
if (resSize > 3)
|
||||
{
|
||||
HGLOBAL hglob = LoadResource(theApp.m_hInstance, hrsrc);
|
||||
if (hglob)
|
||||
{
|
||||
const char *datas = (const char *) LockResource(hglob);
|
||||
if (datas)
|
||||
{
|
||||
std::string rscStr;
|
||||
// skip first 3 characters (header of uxt file)
|
||||
rscStr.resize(resSize - 3);
|
||||
memcpy(&rscStr[0], datas + 3, resSize - 3);
|
||||
text.fromUtf8(rscStr);
|
||||
ok = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ok)
|
||||
{
|
||||
nlwarning("Failed to acquire resource for file %s", filename.c_str());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClient_background_downloaderApp initialization
|
||||
BOOL CClient_background_downloaderApp::InitInstance()
|
||||
{
|
||||
HANDLE mutex = CreateMutex (NULL, TRUE, BGDownloader::DownloaderMutexName);
|
||||
if (mutex && GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
exit (0);
|
||||
|
||||
AfxEnableControlContainer();
|
||||
AfxInitRichEdit();
|
||||
|
||||
CWebPageEmbedder::registerWebPageWindowClass(this->m_hInstance, "WebPage");
|
||||
|
||||
|
||||
// Standard initialization
|
||||
// If you are not using these features and wish to reduce the size
|
||||
// of your final executable, you should remove from the following
|
||||
// the specific initialization routines you do not need.
|
||||
|
||||
#ifdef _AFXDLL
|
||||
Enable3dControls(); // Call this when using MFC in a shared DLL
|
||||
#else
|
||||
Enable3dControlsStatic(); // Call this when linking to MFC statically
|
||||
#endif
|
||||
// Background patch is launch with argument but Installer/updater is launch without parameter
|
||||
bool installMode = parseCommandLine((LPCTSTR) m_lpCmdLine) == false;
|
||||
|
||||
std::string appName = NLMISC::strlwr(std::string(AfxGetAppName()));
|
||||
|
||||
if (installMode)
|
||||
{
|
||||
initLog("ryzom_installer.log");
|
||||
// if no command line is found, assume that the app is launched as an installer
|
||||
nldebug("Loading config file");
|
||||
|
||||
loadConfigFile(NULL, "Ryzom Installer");
|
||||
|
||||
|
||||
nldebug("Loading translation file for lang '%s'", getLanguage().c_str());
|
||||
CResourceTranslationFileLoader loadProxy;
|
||||
CI18N::setLoadProxy(&loadProxy);
|
||||
CI18N::load(getLanguage());
|
||||
|
||||
nldebug("Set translation file");
|
||||
|
||||
IGameDownloader* gd = IGameDownloader::getInstance();
|
||||
// if not first time then do not display first windows
|
||||
|
||||
|
||||
|
||||
int result;
|
||||
if (!gd->getFirstInstall())
|
||||
{
|
||||
|
||||
nldebug("Launching Intro Dlg");
|
||||
CIntroScreenDlg introScreen;
|
||||
result = introScreen.DoModal();
|
||||
if (result != IDOK)
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
nldebug("Mode '%s'", gd->getFirstInstall()?"Install":"Repair");
|
||||
if (!gd->getFirstInstall())
|
||||
{
|
||||
//reset cfg and string cache
|
||||
gd->resetCfgAndStringCache();
|
||||
loadConfigFile(NULL, "Ryzom Installer");
|
||||
}
|
||||
gd->doAction("welcome_continue", true);
|
||||
|
||||
|
||||
CInstallTaskDlg patchFiles;
|
||||
result = patchFiles.DoModal();
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
initLog("client_background_downloader.log");
|
||||
// If there's a command line, assume that the app is launched as a background downloader from the client
|
||||
CClient_background_downloaderDlg dlg;
|
||||
m_pMainWnd = &dlg;
|
||||
int nResponse = dlg.DoModal();
|
||||
if (nResponse == IDOK)
|
||||
{
|
||||
// TODO: Place code here to handle when the dialog is
|
||||
// dismissed with OK
|
||||
}
|
||||
else if (nResponse == IDCANCEL)
|
||||
{
|
||||
// TODO: Place code here to handle when the dialog is
|
||||
// dismissed with Cancel
|
||||
}
|
||||
}
|
||||
|
||||
// Since the dialog has been closed, return FALSE so that we exit the
|
||||
// application, rather than start the application's message pump.
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
void CClient_background_downloaderApp::loadConfigFile(HWND parent, const char *appTitle)
|
||||
{
|
||||
|
||||
// load language from config file
|
||||
try
|
||||
{
|
||||
theApp.ConfigFile.load(ConfigFileName);
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
::MessageBox(parent, e.what(), appTitle, MB_ICONEXCLAMATION);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
std::string CClient_background_downloaderApp::getLanguage()
|
||||
{
|
||||
std::string language = "en";
|
||||
NLMISC::CConfigFile::CVar *languageVarPtr = ConfigFile.getVarPtr("LanguageCode");
|
||||
if (languageVarPtr)
|
||||
{
|
||||
language = languageVarPtr->asString();
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Language not found in %s. Using english as a default.", ConfigFileName);
|
||||
}
|
||||
return language;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CClient_background_downloaderApp::setCloseWarningFlag(BOOL enabled)
|
||||
{
|
||||
HKEY hKey;
|
||||
if (RegCreateKey(HKEY_CURRENT_USER, AppRegEntry, &hKey)==ERROR_SUCCESS)
|
||||
{
|
||||
DWORD flag = (DWORD) enabled;
|
||||
RegSetValueEx(hKey, RegKeyDisplayCloseWarning, 0, REG_DWORD, (LPBYTE)&enabled, 4);
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
BOOL CClient_background_downloaderApp::getCloseWarningFlag() const
|
||||
{
|
||||
HKEY hKey;
|
||||
if (RegOpenKeyEx(HKEY_CURRENT_USER, AppRegEntry, 0, KEY_READ, &hKey)==ERROR_SUCCESS)
|
||||
{
|
||||
DWORD enabled = 0;
|
||||
DWORD type;
|
||||
ULONG len = 4;
|
||||
RegQueryValueEx(hKey, RegKeyDisplayCloseWarning, NULL, &type, (LPBYTE)&enabled, &len);
|
||||
return (BOOL) enabled;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
uint CClient_background_downloaderApp::computePatchSize(const CPatchManager::SPatchInfo &infoOnPatch, bool patchMainland)
|
||||
{
|
||||
uint32 nNonOptSize = 0;
|
||||
uint totalPatchSize = 0;
|
||||
std::vector<sint32> ReqCat;
|
||||
if (patchMainland) // 'optionnal category' will be the flag to indicate 'mainland'
|
||||
{
|
||||
for(uint i = 0; i < infoOnPatch.OptCat.size(); i++)
|
||||
{
|
||||
totalPatchSize += infoOnPatch.OptCat[i].Size;
|
||||
if (infoOnPatch.OptCat[i].Req != -1)
|
||||
{
|
||||
uint32 j;
|
||||
for (j = 0; j < ReqCat.size(); ++j)
|
||||
if (ReqCat[j] == infoOnPatch.OptCat[i].Req)
|
||||
break;
|
||||
// Add just once the req cat size to the non optional size
|
||||
if (j == ReqCat.size())
|
||||
{
|
||||
ReqCat.push_back(infoOnPatch.OptCat[i].Req);
|
||||
nNonOptSize += infoOnPatch.ReqCat[infoOnPatch.OptCat[i].Req].Size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add non optional cats
|
||||
for (uint32 i = 0; i < infoOnPatch.NonOptCat.size(); ++i)
|
||||
nNonOptSize += infoOnPatch.NonOptCat[i].Size;
|
||||
totalPatchSize += nNonOptSize;
|
||||
return totalPatchSize;
|
||||
}
|
||||
|
@ -0,0 +1,95 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// client_background_downloader.h : main header file for the CLIENT_BACKGROUND_DOWNLOADER application
|
||||
//
|
||||
|
||||
#if !defined(AFX_CLIENT_BACKGROUND_DOWNLOADER_H__C4688976_6D8B_4811_81AA_13C3C6CEC789__INCLUDED_)
|
||||
#define AFX_CLIENT_BACKGROUND_DOWNLOADER_H__C4688976_6D8B_4811_81AA_13C3C6CEC789__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#ifndef __AFXWIN_H__
|
||||
#error include 'stdafx.h' before including this file for PCH
|
||||
#endif
|
||||
|
||||
#include "resource.h" // main symbols
|
||||
#include "../client/login_patch.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClient_background_downloaderApp:
|
||||
// See client_background_downloader.cpp for the implementation of this class
|
||||
//
|
||||
|
||||
class CClient_background_downloaderApp : public CWinApp
|
||||
{
|
||||
public:
|
||||
CClient_background_downloaderApp();
|
||||
~CClient_background_downloaderApp();
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CClient_background_downloaderApp)
|
||||
public:
|
||||
virtual BOOL InitInstance();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
|
||||
//{{AFX_MSG(CClient_background_downloaderApp)
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code !
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
public:
|
||||
void setCloseWarningFlag(BOOL enabled);
|
||||
BOOL getCloseWarningFlag() const;
|
||||
|
||||
static uint computePatchSize(const CPatchManager::SPatchInfo &InfoOnPatch, bool patchMainland);
|
||||
|
||||
bool parseCommandLine(const std::string &commandLine);
|
||||
// get language chosen from the config file
|
||||
std::string getLanguage();
|
||||
// Load the config file. Title is needed at that point because no translation file could possibly be loaded
|
||||
void loadConfigFile(HWND parent, const char *appTitle);
|
||||
|
||||
|
||||
public:
|
||||
static const char *AppRegEntry;
|
||||
static const char *RegKeyDisplayCloseWarning;
|
||||
|
||||
std::vector<std::string> PatchURIs;
|
||||
std::string ServerPath;
|
||||
std::string ServerVersion;
|
||||
|
||||
NLMISC::CConfigFile ConfigFile;
|
||||
private:
|
||||
void initLog(const char *appName);
|
||||
};
|
||||
|
||||
|
||||
extern CClient_background_downloaderApp theApp;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_CLIENT_BACKGROUND_DOWNLOADER_H__C4688976_6D8B_4811_81AA_13C3C6CEC789__INCLUDED_)
|
@ -0,0 +1,394 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// French (France) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_OLE_RESOURCES\r\n"
|
||||
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
|
||||
"\r\n"
|
||||
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)\r\n"
|
||||
"#ifdef _WIN32\r\n"
|
||||
"LANGUAGE 12, 1\r\n"
|
||||
"#pragma code_page(1252)\r\n"
|
||||
"#endif //_WIN32\r\n"
|
||||
"#include ""res\\client_background_downloader.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
|
||||
"#include ""l.fra\\afxres.rc"" // Standard components\r\n"
|
||||
"#endif\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_MAIN_ICON ICON DISCARDABLE "icon1.ico"
|
||||
IDI_TRAY_ICON ICON DISCARDABLE "ico00001.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_CLIENT_BACKGROUND_DOWNLOADER_DIALOG DIALOGEX 0, 0, 344, 271
|
||||
STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION |
|
||||
WS_SYSMENU
|
||||
EXSTYLE WS_EX_APPWINDOW
|
||||
CAPTION "Ryzom background downloader"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
||||
BEGIN
|
||||
COMBOBOX IDC_THREAD_PRIORITY,264,255,75,88,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH,
|
||||
10,255,253,13
|
||||
CONTROL 138,IDC_STATUS_BITMAP,"Static",SS_BITMAP,7,240,20,20,
|
||||
WS_EX_TRANSPARENT
|
||||
CONTROL 129,IDC_STATIC,"Static",SS_BITMAP,6,8,333,231
|
||||
LTEXT "...",IDC_STATUS_STRING,26,242,311,9
|
||||
PUSHBUTTON "Bypass",IDC_BYPASS,282,240,56,13
|
||||
END
|
||||
|
||||
IDD_CLOSE_WARNING DIALOG DISCARDABLE 0, 0, 397, 77
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Ryzom background downloader"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,155,59,92,14
|
||||
LTEXT "Close warning",IDC_CLOSE_WARNING,96,17,279,23
|
||||
CONTROL "Check1",IDC_DONT_SHOW_AGAIN,"Button",BS_AUTOCHECKBOX |
|
||||
WS_TABSTOP,97,46,292,10
|
||||
CONTROL 134,IDC_STATIC,"Static",SS_BITMAP,1,17,85,39
|
||||
END
|
||||
|
||||
IDD_INSTALL_STEP DIALOG DISCARDABLE 0, 0, 488, 301
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "uiBGD_RyzomInstaller"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "uiBGD_NextStep",IDOK,413,270,66,24
|
||||
DEFPUSHBUTTON "uiBGD_Exit",ID_CANCEL,341,270,69,24
|
||||
CONTROL 152,IDC_STATIC,"Static",SS_BITMAP,7,7,233,289
|
||||
CONTROL "uiBGD_NewInstall",IDC_NEWINSTALL,"Button",
|
||||
BS_AUTORADIOBUTTON,251,226,227,11
|
||||
CONTROL "uiBGD_Repair",IDC_REPAIR,"Button",BS_AUTORADIOBUTTON |
|
||||
WS_DISABLED,251,241,228,11
|
||||
GROUPBOX "",IDC_STATIC,245,215,238,43
|
||||
GROUPBOX "",IDC_STATIC,245,261,237,36
|
||||
CONTROL "",IDC_INTRO_TEXT,"RICHEDIT",ES_MULTILINE | WS_DISABLED |
|
||||
WS_BORDER | WS_TABSTOP,245,6,240,207
|
||||
END
|
||||
|
||||
IDD_INSTALL_TASK DIALOGEX 0, 0, 441, 307
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "uiBGD_RyzomInstaller"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "uiBGD_Quit",IDEXIT,367,270,62,15
|
||||
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH,
|
||||
13,270,348,12
|
||||
LTEXT "",IDC_STATUS_TEXT,15,284,346,16
|
||||
CONTROL 155,IDC_BG_BITMAP,"Static",SS_BITMAP | SS_REALSIZEIMAGE,
|
||||
7,8,427,295
|
||||
LTEXT "",IDC_REMAINING_TIME,264,246,165,15,0,WS_EX_RIGHT
|
||||
CONTROL "Custom1",IDC_WEB_PAGE,"WebPage",WS_TABSTOP,7,8,427,295
|
||||
CONTROL "",IDC_TASK_TYPE,"RICHEDIT",ES_MULTILINE | WS_DISABLED |
|
||||
WS_TABSTOP,44,246,127,21
|
||||
CONTROL 185,IDC_PROGRESS_BITMAP,"Static",SS_BITMAP,9,241,32,30
|
||||
END
|
||||
|
||||
IDD_ERROR_BOX DIALOG DISCARDABLE 0, 0, 389, 150
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "uiBGD_RyzomInstaller"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "uiBGD_Exit",IDOK,133,116,62,21
|
||||
PUSHBUTTON "uiBGD_Help",IDHELP,196,116,57,20
|
||||
CONTROL 158,IDC_STATIC,"Static",SS_BITMAP,1,4,87,40
|
||||
LTEXT "Static",IDC_ERROR_MSG,136,5,246,68
|
||||
LTEXT "uiBGD_ResumeDownloadInfo",IDC_RESUME_MSG,7,85,351,31
|
||||
ICON IDI_MAIN_ICON,IDC_STATIC,361,85,20,20
|
||||
CONTROL 180,IDC_STATIC,"Static",SS_BITMAP,359,92,7,7
|
||||
END
|
||||
|
||||
IDD_CHOOSE_PACKAGE DIALOG DISCARDABLE 0, 0, 488, 301
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "uiBGD_RyzomInstaller"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "uiBGD_NextStep",IDOK,413,270,66,24
|
||||
DEFPUSHBUTTON "uiBGD_Exit",ID_CANCEL,341,270,69,24
|
||||
CONTROL 160,IDC_STATIC,"Static",SS_BITMAP,7,7,233,289
|
||||
GROUPBOX "",IDC_STATIC,245,213,237,48
|
||||
GROUPBOX "",IDC_STATIC,245,261,237,36
|
||||
CONTROL "uiBGD_FullInstall",IDC_FULL_PACKAGE,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,258,221,144,16
|
||||
CONTROL "uiBGD_Torrent",IDC_TORRENT,"Button",BS_AUTOCHECKBOX |
|
||||
WS_TABSTOP,258,239,144,16
|
||||
CONTROL "",IDC_PACKAGE_TEXT,"RICHEDIT",ES_MULTILINE |
|
||||
WS_DISABLED | WS_BORDER | WS_TABSTOP,245,7,238,205
|
||||
END
|
||||
|
||||
IDD_INSTALL_SUCCESS DIALOG DISCARDABLE 0, 0, 488, 301
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "uiBGD_RyzomInstaller"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "uiBGD_FinishInstall",IDOK,411,268,69,24
|
||||
CONTROL 164,IDC_STATIC,"Static",SS_BITMAP,7,7,233,289
|
||||
CONTROL "uiBGD_StartRyzomNow",IDC_START_RYZOM_NOW,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,254,241,226,22
|
||||
GROUPBOX "",IDC_STATIC,246,237,234,31
|
||||
CONTROL "",IDC_CONGRATS,"RICHEDIT",ES_MULTILINE | WS_DISABLED |
|
||||
WS_BORDER | WS_TABSTOP,246,13,234,224
|
||||
END
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0,0,1
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040c04b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "\0"
|
||||
VALUE "CompanyName", "GameForge France\0"
|
||||
VALUE "FileDescription", "Ryzom Background Downloader\0"
|
||||
VALUE "FileVersion", "1, 0, 0, 1\0"
|
||||
VALUE "InternalName", "client_background_downloader\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2007 GameForge France\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "client_background_downloader.EXE\0"
|
||||
VALUE "PrivateBuild", "\0"
|
||||
VALUE "ProductName", "Application client_background_downloader\0"
|
||||
VALUE "ProductVersion", "1, 0, 0, 1\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x40c, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_CLIENT_BACKGROUND_DOWNLOADER_DIALOG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 337
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 264
|
||||
END
|
||||
|
||||
IDD_CLOSE_WARNING, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 390
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 70
|
||||
END
|
||||
|
||||
IDD_INSTALL_STEP, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 481
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 294
|
||||
END
|
||||
|
||||
IDD_INSTALL_TASK, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 434
|
||||
TOPMARGIN, 9
|
||||
BOTTOMMARGIN, 301
|
||||
END
|
||||
|
||||
IDD_ERROR_BOX, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 382
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 143
|
||||
END
|
||||
|
||||
IDD_CHOOSE_PACKAGE, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 179
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 88
|
||||
END
|
||||
|
||||
IDD_INSTALL_SUCCESS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 480
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 275
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDB_DOWNLOADER_BG BITMAP DISCARDABLE "downloader_bg.bmp"
|
||||
IDB_BG_TRAY BITMAP DISCARDABLE "ry_bg_tray.bmp"
|
||||
IDB_DL_STOP BITMAP DISCARDABLE "dl_stop.bmp"
|
||||
IDB_PROGRESS_0 BITMAP DISCARDABLE "progress_icon_0.bmp"
|
||||
IDB_PROGRESS_1 BITMAP DISCARDABLE "progress_icon_1.bmp"
|
||||
IDB_PROGRESS_SUCCESS BITMAP DISCARDABLE "progress_success.bmp"
|
||||
IDB_PROGRESS_PAUSED BITMAP DISCARDABLE "progress_paused.bmp"
|
||||
IDB_INTRO BITMAP DISCARDABLE "intro.bmp"
|
||||
IDB_BACKGROUND0 BITMAP DISCARDABLE "background_0.bmp"
|
||||
IDB_ERROR_LOGO BITMAP DISCARDABLE "error_logo.bmp"
|
||||
IDB_PACKAGE BITMAP DISCARDABLE "package.bmp"
|
||||
IDB_INSTALL_SUCCESS BITMAP DISCARDABLE "install_success.bmp"
|
||||
IDB_APP_SHORTCUT BITMAP DISCARDABLE "shortcut_bmp.bmp"
|
||||
IDB_TEST_ALPHA BITMAP DISCARDABLE "test_alpha.bmp"
|
||||
IDB_PROGRESS_BG BITMAP DISCARDABLE "progress_bg.bmp"
|
||||
IDB_PROGRESS_FG BITMAP DISCARDABLE "progress_fg.bmp"
|
||||
IDB_PROGRESS_ANIM BITMAP DISCARDABLE "progress_anim_sh.bmp"
|
||||
IDB_PROGRESS_FAIL BITMAP DISCARDABLE "progress_failed.bmp"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_TRAY_MENU MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "tray"
|
||||
BEGIN
|
||||
MENUITEM "Show/Hide downloader", IDM_SHOW_HIDE
|
||||
MENUITEM "Exit", IDM_DOWNLOADER_EXIT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog Info
|
||||
//
|
||||
|
||||
IDD_CLIENT_BACKGROUND_DOWNLOADER_DIALOG DLGINIT
|
||||
BEGIN
|
||||
IDC_THREAD_PRIORITY, 0x403, 7, 0
|
||||
0x6150, 0x7375, 0x6465, "\000"
|
||||
IDC_THREAD_PRIORITY, 0x403, 13, 0
|
||||
0x6f4c, 0x2077, 0x7270, 0x6f69, 0x6972, 0x7974, "\000"
|
||||
IDC_THREAD_PRIORITY, 0x403, 16, 0
|
||||
0x6f4e, 0x6d72, 0x6c61, 0x7020, 0x6972, 0x726f, 0x7469, 0x0079,
|
||||
0
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// UXT
|
||||
//
|
||||
|
||||
IDR_FR_UXT UXT DISCARDABLE "..\\..\\translation\\translated\\fr.uxt"
|
||||
IDR_EN_UXT UXT DISCARDABLE "..\\..\\translation\\translated\\en.uxt"
|
||||
IDR_DE_UXT UXT DISCARDABLE "..\\..\\translation\\translated\\de.uxt"
|
||||
IDR_WK_UXT UXT DISCARDABLE "..\\..\\translation\\work\\wk.uxt"
|
||||
#endif // French (France) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
#define _AFX_NO_SPLITTER_RESOURCES
|
||||
#define _AFX_NO_OLE_RESOURCES
|
||||
#define _AFX_NO_TRACKER_RESOURCES
|
||||
#define _AFX_NO_PROPERTY_RESOURCES
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE 12, 1
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
#include "res\client_background_downloader.rc2" // non-Microsoft Visual C++ edited resources
|
||||
#include "l.fra\afxres.rc" // Standard components
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
@ -0,0 +1,190 @@
|
||||
/*
|
||||
* $Id:
|
||||
*/
|
||||
|
||||
// client_background_downloaderDlg.h : header file
|
||||
//
|
||||
|
||||
#if !defined(AFX_CLIENT_BACKGROUND_DOWNLOADERDLG_H__BAF8369B_BE81_4FE6_9A6B_72CAF4B26AEE__INCLUDED_)
|
||||
#define AFX_CLIENT_BACKGROUND_DOWNLOADERDLG_H__BAF8369B_BE81_4FE6_9A6B_72CAF4B26AEE__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
|
||||
#include "nel/misc/time_nl.h"
|
||||
#include "nel/misc/mem_stream.h"
|
||||
#include "nel/misc/inter_window_msg_queue.h"
|
||||
#include "game_share/bg_downloader_msg.h"
|
||||
#include "blended_bitmap.h"
|
||||
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
class IThread;
|
||||
}
|
||||
|
||||
|
||||
class CDownloadTask;
|
||||
|
||||
#ifndef NIF_INFO
|
||||
#define NIF_INFO 16
|
||||
#define NIIF_NONE 0
|
||||
#define NIIF_INFO 1
|
||||
#define NIIF_WARNING 2
|
||||
#define NIIF_ERROR 3
|
||||
#define NIM_SETVERSION 4
|
||||
#define NOTIFYICON_VERSION 3
|
||||
#endif
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClient_background_downloaderDlg dialog
|
||||
|
||||
/** Main dialog for the ryzom background downloader
|
||||
*
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2006
|
||||
*/
|
||||
class CClient_background_downloaderDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CClient_background_downloaderDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
~CClient_background_downloaderDlg();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CClient_background_downloaderDlg)
|
||||
enum { IDD = IDD_CLIENT_BACKGROUND_DOWNLOADER_DIALOG };
|
||||
CBlendedBitmap m_StatusBitmap;
|
||||
CComboBox m_ThreadPriorityCtrl;
|
||||
//}}AFX_DATA
|
||||
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CClient_background_downloaderDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
BGDownloader::TThreadPriority _ThreadPriority;
|
||||
BGDownloader::TThreadPriority _WantedThreadPriority;
|
||||
// current state
|
||||
BGDownloader::TDownloaderMode _Mode;
|
||||
BGDownloader::CTaskDesc _Task;
|
||||
BGDownloader::TTaskResult _LastTaskResult;
|
||||
uint32 _AvailablePatchs; // bitfield indexed by 'TDownloadID', filled after a task completion
|
||||
bool _Verbose; // true if during the update of the task progress, the client should also
|
||||
// display the progress
|
||||
bool _PriorityChangeAsked;
|
||||
|
||||
|
||||
enum { TIMER_CHECK_DBL_CLICK = 1, TIMER_MAIN_LOOP, TIMER_SEND_PRIORITY };
|
||||
|
||||
// client request
|
||||
bool _StopWanted;
|
||||
BGDownloader::CTaskDesc _WantedTask;
|
||||
//
|
||||
friend class CDownloadTask;
|
||||
CDownloadTask *_DownloadTask;
|
||||
|
||||
|
||||
|
||||
HICON m_hIcon;
|
||||
HICON m_hTrayIcon;
|
||||
BOOL _TrayIconAdded;
|
||||
|
||||
|
||||
|
||||
// we use VC6 SP5 and don't have the good headers, so redefine that struct here
|
||||
|
||||
struct NOTIFYICONDATAW_V2
|
||||
{
|
||||
DWORD cbSize;
|
||||
HWND hWnd;
|
||||
UINT uID;
|
||||
UINT uFlags;
|
||||
UINT uCallbackMessage;
|
||||
HICON hIcon;
|
||||
WCHAR szTip[128];
|
||||
DWORD dwState; //Version 5.0
|
||||
DWORD dwStateMask; //Version 5.0
|
||||
WCHAR szInfo[256]; //Version 5.0
|
||||
union {
|
||||
UINT uTimeout; //Version 5.0
|
||||
UINT uVersion; //Version 5.0
|
||||
} DUMMYUNIONNAME;
|
||||
WCHAR szInfoTitle[64]; //Version 5.0
|
||||
DWORD dwInfoFlags; //Version 5.0
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
NOTIFYICONDATAW _NID_V1;
|
||||
NOTIFYICONDATAW_V2 _NID;
|
||||
};
|
||||
|
||||
|
||||
bool _WaitSingleClick;
|
||||
sint64 _WaitSingleClickStartTime;
|
||||
bool _BypassWanted;
|
||||
bool _IsWin2KOrMore;
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CClient_background_downloaderDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnPaint();
|
||||
afx_msg HCURSOR OnQueryDragIcon();
|
||||
afx_msg void OnDestroy();
|
||||
afx_msg LRESULT OnTrayIconMsg(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg void OnMenuShowHide();
|
||||
afx_msg void OnMenuExit();
|
||||
afx_msg void OnClose();
|
||||
afx_msg void OnTimer(UINT nIDEvent);
|
||||
afx_msg void OnBypass();
|
||||
afx_msg void OnSelchangeThreadPriority();
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
void popTrayMenu();
|
||||
void setStatusString(const ucstring &str,
|
||||
uint32 currentFilesToGet,
|
||||
uint32 totalFilesToGet,
|
||||
uint32 patchingSize,
|
||||
uint32 totalSize,
|
||||
float currentFileProgress
|
||||
);
|
||||
void setLocalStatusString(const ucstring &str);
|
||||
void setProgress(BOOL enabled, float progress);
|
||||
void updateTaskProgressDisplay();
|
||||
void setFailBitmap();
|
||||
void setSuccessBitmap();
|
||||
void errorMessage(const ucstring &message);
|
||||
void protocolError();
|
||||
void askStop();
|
||||
bool checkValidEnum(int value, int maxValue);
|
||||
void handleClientMessage(NLMISC::CMemStream &inMsg);
|
||||
void initSearchPaths();
|
||||
void setDownloadThreadPriority(BGDownloader::TThreadPriority priority);
|
||||
void updateThreadPriority();
|
||||
bool isThreadPaused() const;
|
||||
void popBalloon(const ucstring &text, const ucstring &title, DWORD balloonIcon = NIIF_INFO);
|
||||
void removeTrayIcon();
|
||||
|
||||
|
||||
NLMISC::CInterWindowMsgQueue _ClientMsgQueue;
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_CLIENT_BACKGROUND_DOWNLOADERDLG_H__BAF8369B_BE81_4FE6_9A6B_72CAF4B26AEE__INCLUDED_)
|
@ -0,0 +1,80 @@
|
||||
// This file was created on March 28th 2001 by Robert Brault.
|
||||
// I created this Class to be able change the Color of your Static Text.
|
||||
// This is Derived from CStatic.
|
||||
//
|
||||
// There are three functions available Currently:
|
||||
// SetBkColor(COLORREF crColor)
|
||||
// SetTextColor(COLORREF crColor)
|
||||
//
|
||||
// How To Use:
|
||||
// Add three files to your project
|
||||
// ColorStatic.cpp, ColorStatic.h and Color.h
|
||||
// Color.h has (#define)'s for different colors (add any color you desire).
|
||||
//
|
||||
// Add #include "ColorStatic.h" to your Dialogs Header file.
|
||||
// Declare an instance of CColorStatic for each static text being modified.
|
||||
// Ex. CColorStatic m_stText;
|
||||
//
|
||||
// In your OnInitDialog() add a SubclassDlgItem for each CColorStatic member variable.
|
||||
// Ex. m_stText.SubclassDlgItem(IDC_ST_TEXT, this);
|
||||
// In this same function initialize your color for each piece of text unless you want the default.
|
||||
|
||||
|
||||
// ColorStatic.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdpch.h"
|
||||
#include "color_static.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CColorStatic
|
||||
|
||||
CColorStatic::CColorStatic()
|
||||
{
|
||||
m_crBkColor = ::GetSysColor(COLOR_3DFACE); // Initializing the Background Color to the system face color.
|
||||
m_crTextColor = 0; // Initializing the text to Black
|
||||
m_brBkgnd.CreateSolidBrush(m_crBkColor); // Create the Brush Color for the Background.
|
||||
}
|
||||
|
||||
CColorStatic::~CColorStatic()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CColorStatic, CStatic)
|
||||
//{{AFX_MSG_MAP(CColorStatic)
|
||||
ON_WM_CTLCOLOR_REFLECT()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CColorStatic message handlers
|
||||
|
||||
HBRUSH CColorStatic::CtlColor(CDC* pDC, UINT nCtlColor)
|
||||
{
|
||||
HBRUSH hbr;
|
||||
hbr = (HBRUSH)m_brBkgnd; // Passing a Handle to the Brush
|
||||
pDC->SetBkColor(m_crBkColor); // Setting the Color of the Text Background to the one passed by the Dialog
|
||||
pDC->SetTextColor(m_crTextColor); // Setting the Text Color to the one Passed by the Dialog
|
||||
|
||||
if (nCtlColor) // To get rid of compiler warning
|
||||
nCtlColor += 0;
|
||||
|
||||
return hbr;
|
||||
|
||||
}
|
||||
|
||||
void CColorStatic::SetBkColor(COLORREF crColor)
|
||||
{
|
||||
m_crBkColor = crColor; // Passing the value passed by the dialog to the member varaible for Backgound Color
|
||||
m_brBkgnd.DeleteObject(); // Deleting any Previous Brush Colors if any existed.
|
||||
m_brBkgnd.CreateSolidBrush(crColor); // Creating the Brush Color For the Static Text Background
|
||||
RedrawWindow();
|
||||
}
|
||||
|
||||
void CColorStatic::SetTextColor(COLORREF crColor)
|
||||
{
|
||||
m_crTextColor = crColor; // Passing the value passed by the dialog to the member varaible for Text Color
|
||||
RedrawWindow();
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
// This file was created on March 28th 2001. By Robert Brault
|
||||
//
|
||||
//
|
||||
|
||||
#if !defined(AFX_COLORSTATIC_H__614C19E7_EA25_42DF_928A_51AC901B813D__INCLUDED_)
|
||||
#define AFX_COLORSTATIC_H__614C19E7_EA25_42DF_928A_51AC901B813D__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// ColorStatic.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CColorStatic window
|
||||
|
||||
class CColorStatic : public CStatic
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
void SetTextColor(COLORREF crColor); // This Function is to set the Color for the Text.
|
||||
void SetBkColor(COLORREF crColor); // This Function is to set the BackGround Color for the Text.
|
||||
CColorStatic();
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CColorStatic)
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
virtual ~CColorStatic();
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CColorStatic)
|
||||
|
||||
CBrush m_brBkgnd; // Holds Brush Color for the Static Text
|
||||
COLORREF m_crBkColor; // Holds the Background Color for the Text
|
||||
COLORREF m_crTextColor; // Holds the Color for the Text
|
||||
|
||||
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_COLORSTATIC_H__614C19E7_EA25_42DF_928A_51AC901B813D__INCLUDED_)
|
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 184 KiB |
@ -0,0 +1,74 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// error_box_dlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdpch.h"
|
||||
#include "client_background_downloader.h"
|
||||
#include "error_box_dlg.h"
|
||||
#include "nel/misc/win32_util.h"
|
||||
#include "../client/browse_faq.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CErrorBoxDlg dialog
|
||||
|
||||
|
||||
CErrorBoxDlg::CErrorBoxDlg(const ucstring &errorMsg, const ucstring &resumeMessage, CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CErrorBoxDlg::IDD, pParent)
|
||||
{
|
||||
_ErrorMsg = errorMsg;
|
||||
_ResumeMsg = resumeMessage;
|
||||
//{{AFX_DATA_INIT(CErrorBoxDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CErrorBoxDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CErrorBoxDlg)
|
||||
// NOTE: the ClassWizard will add DDX and DDV calls here
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CErrorBoxDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CErrorBoxDlg)
|
||||
ON_BN_CLICKED(IDHELP, OnHelp)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CErrorBoxDlg message handlers
|
||||
|
||||
BOOL CErrorBoxDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
SetIcon(AfxGetApp()->LoadIcon(IDI_MAIN_ICON), TRUE);
|
||||
NLMISC::CWin32Util::localizeWindow(this->m_hWnd);
|
||||
SetWindowTextW(GetDlgItem(IDC_ERROR_MSG)->m_hWnd, (const WCHAR *) _ErrorMsg.c_str());
|
||||
SetWindowTextW(GetDlgItem(IDC_RESUME_MSG)->m_hWnd, (const WCHAR *) _ResumeMsg.c_str());
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CErrorBoxDlg::OnHelp()
|
||||
{
|
||||
browseFAQ(theApp.ConfigFile);
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
#if !defined(AFX_ERROR_BOX_DLG_H__B64622BC_239A_44D5_BD12_74E7BE6DE5B4__INCLUDED_)
|
||||
#define AFX_ERROR_BOX_DLG_H__B64622BC_239A_44D5_BD12_74E7BE6DE5B4__INCLUDED_
|
||||
|
||||
|
||||
|
||||
#include "nel/misc/ucstring.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CErrorBoxDlg dialog
|
||||
|
||||
class CErrorBoxDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CErrorBoxDlg(const ucstring &errorMsg,const ucstring &resumeMsg, CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CErrorBoxDlg)
|
||||
enum { IDD = IDD_ERROR_BOX };
|
||||
// NOTE: the ClassWizard will add data members here
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CErrorBoxDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
ucstring _ErrorMsg;
|
||||
ucstring _ResumeMsg; //Message displayed in the "Resume Label"
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CErrorBoxDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnHelp();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_ERROR_BOX_DLG_H__B64622BC_239A_44D5_BD12_74E7BE6DE5B4__INCLUDED_)
|
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 318 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 3.2 KiB |
@ -0,0 +1,180 @@
|
||||
#ifndef GameDownloader_H
|
||||
#define GameDownloader_H
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
|
||||
// Windows Gui specific
|
||||
class CInstallTaskDlg;
|
||||
class CChoosePackageDlg;
|
||||
|
||||
/*
|
||||
Core of the install program Exchanges messages with Ryzom Interface, Torrent Interface and Gui
|
||||
Use get getInstance to have a usefull instance
|
||||
*/
|
||||
class IGameDownloader
|
||||
{
|
||||
public:
|
||||
//! The differente state Software
|
||||
enum EState {Init, InitFinished, UpdateVersion, UpdateVersionFinished, UpdateLauncher, UpdateLauncherFinished, UpdateTorrent, UpdateTorrentFinished,
|
||||
UpdatePackage, UpdatePackageFinished,
|
||||
CheckFinished, RepositoryUpdated, Downloading, DownloadFinished, AskInstalling, InstallOk, Installing, AskInstallFinishing, InstallFinishing, InstallFinished};
|
||||
|
||||
public:
|
||||
|
||||
virtual ~IGameDownloader(){}
|
||||
|
||||
//Get the instance of the manager
|
||||
static IGameDownloader* getInstance();
|
||||
|
||||
/*** The the Gui Dialog*/
|
||||
virtual void setInstallTaskDlg(CInstallTaskDlg* dlg) = 0;
|
||||
virtual ucstring getStateLabelText() const = 0;
|
||||
virtual ucstring getContentLabelText() const = 0;
|
||||
virtual ucstring getTimeLeftLabelText() const = 0;
|
||||
virtual sint32 getProgressBarValue() const = 0;
|
||||
virtual void registerChoosePackageDlg(CChoosePackageDlg* dlg) = 0;
|
||||
virtual void updateStartProcessText() = 0;
|
||||
virtual bool getMustStartBrowser() const = 0;
|
||||
virtual bool getBrowserActive() const = 0;
|
||||
|
||||
|
||||
/*** Ask the Download to do an action
|
||||
*/
|
||||
virtual void doAction(const char* actionName, bool state = true) = 0;
|
||||
|
||||
// Ask the Ryzom Dll to look at wich package are available for download
|
||||
// if must Repare is true do a scan_data before a check
|
||||
//IRyzomUpdateListener::onCheckFinished indicates which package are available
|
||||
//IRyzomUpdateListener::onScanDataFinished indicates that the scan is finished
|
||||
virtual void getPackageSelection(bool mustRepair) = 0;
|
||||
|
||||
// Ask the Ryzom Dll the list of file that must be downloaded
|
||||
// selectPackage must be called before the answser is done via IRyzomUpdateListener::addToDownloadList and IRyzomUpdateListener::onDownloadListFinished
|
||||
virtual void getDownloadList() = 0;
|
||||
|
||||
//! must be called at each tick (update gui on exectue asynchronous message)
|
||||
virtual void update() = 0;
|
||||
|
||||
//! set the current Version option selected by the user (full Version or initial version)
|
||||
virtual void selectPackage(bool fullvesion) = 0;
|
||||
|
||||
// set Infos fore where to look for data (this infos are read from a version.xml file generate by php/db)
|
||||
// versionId is an optional value mean to download a specifc value
|
||||
virtual void setVersionInfo(const std::vector<std::string>& patchUris, const std::string& serverPath) = 0;
|
||||
|
||||
//! Used to update the launcher (depack the .bnp) *NIY*
|
||||
virtual bool updateLauncher() = 0;
|
||||
|
||||
//! load a .torrent from the server
|
||||
virtual bool updateTorrent() = 0;
|
||||
|
||||
//! set the name of the torrentFile to read, the tempory patch directory, the timestamp of the torrent file
|
||||
virtual void setTorrentInfo(const std::string & torrentPatchFilename,
|
||||
const std::string & torrentFilename,
|
||||
uint32 torrentPatchTimestamp) = 0;
|
||||
|
||||
//! set the name of the torrentFile to read, the tempory patch directory (usefull for the updating of the .torrent)
|
||||
virtual void setInstallInfo(const std::string & installPatchFilename,
|
||||
const std::string & installFilename, const std::string & installPatchExtract,
|
||||
uint32 torrentPatchTimestamp) = 0;
|
||||
|
||||
//! forward message to IRyzomControl for initializing the i18n of the ryzom dll
|
||||
virtual void initI18n(const char* lang, unsigned char *data, uint32 length) = 0;
|
||||
|
||||
//! Returns the current language from cfg file (forward to IRyzomControl)
|
||||
virtual std::string getLanguage() const = 0;
|
||||
|
||||
|
||||
virtual void resetCfgAndStringCache() = 0;
|
||||
//! Returns the patch Url from patch serveur (forward to IRyzomControl)
|
||||
virtual std::string getPatchUrl() const = 0;
|
||||
|
||||
//! see IRyzomControl::getLogUrl
|
||||
virtual std::string getLogUrl(const std::string& action) const = 0;
|
||||
|
||||
//! Set if it's the first install or not (by looking if the unpack/exedll.bnp file exist)
|
||||
virtual void setFirstInstall(bool firstInstall) = 0;
|
||||
//! Get the first install value (was set by setFirstInstall)
|
||||
virtual bool getFirstInstall() const = 0;
|
||||
|
||||
//! return the size of the Ros version patch
|
||||
virtual uint64 getRosPatchSize() const = 0;
|
||||
|
||||
//! return the size of the Full version patch
|
||||
virtual uint64 getRyzomPatchSize() const = 0;
|
||||
|
||||
//! return the size of the Ros version when depacked
|
||||
virtual uint64 getRosInstallSize() const = 0;
|
||||
|
||||
//! return the size of the full version when depacked
|
||||
virtual uint64 getRyzomInstallSize() const = 0;
|
||||
|
||||
//! \see IRzyomControl::getInstallHttpBackground
|
||||
virtual std::string getInstallHttpBackground() const = 0;
|
||||
|
||||
//! return the current state
|
||||
virtual EState getState() const = 0;
|
||||
//! update the current state(change are taken at the update function)
|
||||
virtual void setState(EState state) = 0;
|
||||
|
||||
|
||||
//! Set the session id (from stats.php)
|
||||
virtual void setSessionId(const std::string& sessionId) = 0;
|
||||
|
||||
//! Set the install id (from registree)
|
||||
virtual void setInstallId(const std::string& productId) = 0;
|
||||
|
||||
//! Set the user id (from stats.php)
|
||||
virtual void setUserId(const std::string& clientId) = 0;
|
||||
|
||||
//! obsolet
|
||||
virtual void setAutoInstall(bool autoInstall) = 0;
|
||||
//! obsolete
|
||||
virtual bool getAutoInstall() const = 0;
|
||||
|
||||
//! indicate if welcom message has been displayed
|
||||
//!{
|
||||
virtual bool getStarted() const = 0;
|
||||
virtual void setStarted(bool started) = 0;
|
||||
//!}
|
||||
|
||||
/* indicates if Ryzom must be start at end
|
||||
It store the gui state. And send the result to Ryzom module
|
||||
{
|
||||
*/
|
||||
virtual bool getStartRyzomAtEnd() const = 0;
|
||||
virtual void setStartRyzomAtEnd(bool ok) = 0;
|
||||
//!}
|
||||
|
||||
//! obsolete {
|
||||
virtual void setDownloadOnly(bool downloadOnly) = 0;
|
||||
virtual bool getDownloadOnly() const = 0;
|
||||
//!}
|
||||
|
||||
//! indicates if the full version is needed (store gui update, then send to ryzom/torrent module {
|
||||
virtual void setUseFullVersion(bool downloadOnly) = 0;
|
||||
virtual bool getUseFullVersion() const = 0;
|
||||
//! }
|
||||
|
||||
//! inidicates if a torrent exist on server. If it exist a combo box must be displayed. {
|
||||
virtual void setTorrentExist(bool exist) = 0;
|
||||
virtual bool getTorrentExist() const = 0;
|
||||
//! }
|
||||
|
||||
//! inidicates if a torrent is used (the torrent exist and the user has selected it) {
|
||||
virtual void setUseTorrent(bool useTorrent) = 0;
|
||||
virtual bool getUseTorrent() const = 0;
|
||||
//!}
|
||||
|
||||
//! return true if the turing arrow icone of the install_task dialog continue to turn
|
||||
virtual bool getUpdateDownloadIcon() const = 0;
|
||||
|
||||
private:
|
||||
static IGameDownloader* _Instance; //!instance of the Gui
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,943 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "stdpch.h"
|
||||
|
||||
#include "ryzom_control.h"
|
||||
|
||||
#include <string>
|
||||
#include "../client/login_patch.h"
|
||||
#include "nel/misc/i18n.h"
|
||||
|
||||
#include "nel/misc/app_context.h"
|
||||
#include "nel/misc/system_info.h"
|
||||
|
||||
std::string TheTmpInstallDirectory;
|
||||
|
||||
//std::string CfgApplication;
|
||||
std::string ClientLauncherUrl;
|
||||
extern std::string R2ServerVersion;
|
||||
|
||||
|
||||
|
||||
NLMISC::CApplicationContext* ApplicationContext = 0;
|
||||
|
||||
using namespace NLMISC;
|
||||
|
||||
//-------------------------------------------
|
||||
//! see ICkeckInfoViewer
|
||||
class CCheckInfoViewer : public ICkeckInfoViewer
|
||||
{
|
||||
public:
|
||||
CCheckInfoViewer(CPatchManager::SPatchInfo* patchInfo);
|
||||
|
||||
//! \see ICkeckInfoViewer::getCount
|
||||
virtual uint32 getCount(ECat cat) const;
|
||||
|
||||
//! \see ICkeckInfoViewer::getCount
|
||||
virtual const char * getName(ECat cat, uint32 index) const;
|
||||
|
||||
//! \see ICkeckInfoViewer::getCount
|
||||
virtual uint32 getSZipFileSize(ECat cat, uint32 index) const;
|
||||
|
||||
//! \see ICkeckInfoViewer::getCount
|
||||
virtual uint32 getFileSize(ECat cat, uint32 index) const;
|
||||
|
||||
private:
|
||||
CPatchManager::SPatchInfo *_PatchInfo;
|
||||
};
|
||||
|
||||
CCheckInfoViewer::CCheckInfoViewer(CPatchManager::SPatchInfo* patchInfo):_PatchInfo(patchInfo){}
|
||||
|
||||
uint32 CCheckInfoViewer::getCount(ECat cat) const
|
||||
{
|
||||
switch(cat)
|
||||
{
|
||||
case NonOptCat: return _PatchInfo->NonOptCat.size();
|
||||
case ReqCat: return _PatchInfo->ReqCat.size();
|
||||
case OptCat: return _PatchInfo->OptCat.size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * CCheckInfoViewer::getName(ECat cat, uint32 index) const
|
||||
{
|
||||
switch(cat)
|
||||
{
|
||||
case NonOptCat: return _PatchInfo->NonOptCat[index].Name.c_str();
|
||||
case ReqCat: return _PatchInfo->ReqCat[index].Name.c_str();
|
||||
case OptCat: return _PatchInfo->OptCat[index].Name.c_str();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 CCheckInfoViewer::getSZipFileSize(ECat cat, uint32 index) const
|
||||
{
|
||||
|
||||
switch(cat)
|
||||
{
|
||||
case NonOptCat: return _PatchInfo->NonOptCat[index].SZipSize;
|
||||
case ReqCat: return _PatchInfo->ReqCat[index].SZipSize;
|
||||
case OptCat: return _PatchInfo->OptCat[index].SZipSize;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 CCheckInfoViewer::getFileSize(ECat cat, uint32 index) const
|
||||
{
|
||||
switch(cat)
|
||||
{
|
||||
case NonOptCat: return _PatchInfo->NonOptCat[index].FinalFileSize;
|
||||
case ReqCat: return _PatchInfo->ReqCat[index].FinalFileSize;
|
||||
case OptCat: return _PatchInfo->OptCat[index].FinalFileSize;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//-------------------------------------------------
|
||||
//! Function that enble to "load" a i18n file from the Data member instread of harddisk
|
||||
class CInstallLoadProxy : public NLMISC::CI18N::ILoadProxy
|
||||
{
|
||||
public:
|
||||
//! \see NLMISC::CI18N::ILoadProxy::loadStringFile
|
||||
virtual void loadStringFile(const std::string &filename, ucstring &text);
|
||||
public:
|
||||
std::map<std::string, ucstring> Data;
|
||||
|
||||
};
|
||||
|
||||
void CInstallLoadProxy::loadStringFile(const std::string &filename, ucstring &text)
|
||||
{
|
||||
// if info exist reaturns data from memner Data
|
||||
std::map<std::string, ucstring>::const_iterator found ( Data.find(filename) );
|
||||
if ( found == Data.end())
|
||||
{
|
||||
text = ucstring("");
|
||||
return;
|
||||
}
|
||||
text = found->second;
|
||||
}
|
||||
|
||||
/// Used to forward log info From patchmanager to IRyzomControlListener (the gui)
|
||||
class CRyzomInstallStateListener : public IPatchManagerStateListener
|
||||
{
|
||||
public:
|
||||
CRyzomInstallStateListener(IRyzomControlListener* listener):_Listener(listener){}
|
||||
|
||||
void setState (bool bOutputToLog, const ucstring &ucsNewState);
|
||||
|
||||
private:
|
||||
IRyzomControlListener* _Listener;
|
||||
};
|
||||
|
||||
void CRyzomInstallStateListener::setState(bool bOutputToLog, const ucstring &ucsNewState)
|
||||
{
|
||||
std::string value = ucsNewState.toUtf8();
|
||||
|
||||
_Listener->setState(bOutputToLog, value.c_str());
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
|
||||
/// Implementation of the IRyzomControlImpl
|
||||
class CRyzomControlImpl : public IRyzomControl, public IAsyncDownloader
|
||||
{
|
||||
public:
|
||||
|
||||
CRyzomControlImpl(IRyzomControlListener* listener);
|
||||
~CRyzomControlImpl();
|
||||
//! load info from cfg file(call by ctor)
|
||||
void loadCfg();
|
||||
|
||||
//from IRyzomControl
|
||||
//! \see IRyzomControl::destroy
|
||||
virtual void destroy(){}
|
||||
//! \see IRyzomControl::check
|
||||
virtual void check();
|
||||
//! \see IRyzomControl::update
|
||||
virtual void update();
|
||||
// called by PatchManager
|
||||
virtual void getPackageSelection(bool mustRepairFirst);
|
||||
//! \see IRyzomControl::getDownloadList
|
||||
virtual void getDownloadList(IStringContainer* categoryList);
|
||||
//! \see IRyzomControl::install
|
||||
virtual void install(IInstallEntryViewer* installList, bool download);
|
||||
//! \see IRyzomControl::getServerVersion
|
||||
virtual const char* getServerVersion() const;
|
||||
//! \see IRyzomControl::getServerVersion
|
||||
virtual const char* getLanguage() const;
|
||||
//! \see IRyzomControl::getServerVersion
|
||||
virtual const char* getStartupHost() const;
|
||||
//! \see IRyzomControl::getServerVersion
|
||||
virtual const char* getApplication() const;
|
||||
//! \see IRyzomControl::getServerVersion
|
||||
virtual bool download(const char* patchPath, const char* sourcePath,
|
||||
const char* tmpDirectory, uint32 timestamp);
|
||||
//! \see IRyzomControl::requestStop
|
||||
virtual void requestStop();
|
||||
//! \see IRyzomControl::extract
|
||||
virtual bool extract(char* sourceFilename [],
|
||||
char* extractPath [],
|
||||
uint32 size);
|
||||
//! \see IRyzomControl::extract
|
||||
virtual void initPatchManager();
|
||||
//! \see IRyzomControl::extract
|
||||
virtual const char* getPatchUrl() const;
|
||||
//! \see IRyzomControl::extract
|
||||
virtual const char* getLogUrl(const char* action) const;
|
||||
//! \see IRyzomControl::getInstallHttpBackground
|
||||
virtual const char* getInstallHttpBackground() const;
|
||||
//! \see IRyzomControl::setStartRyzomAtEnd
|
||||
virtual void setStartRyzomAtEnd(bool ok) { _PatchManager->setStartRyzomAtEnd( ok); }
|
||||
|
||||
//from IAsyncDownloader
|
||||
//! \see IRyzomControlListener::addToDownloadList
|
||||
void addToDownloadList(const std::string &patchName, const std::string &sourceName, uint32 timestamp, const std::string& extractPath, uint32 sevenZipSize, uint32 size);
|
||||
//! \see IRyzomControlListener::onFileInstallFinished
|
||||
virtual void onFileInstallFinished();
|
||||
//! \see IRyzomControlListener::onFileDownloadFinished
|
||||
virtual void onFileDownloadFinished();
|
||||
//! \see IRyzomControlListener::onFileDownloading
|
||||
virtual void onFileDownloading(const std::string& sourceName, uint32 rate, uint32 fileIndex, uint32 fileCount, uint64 fileSize, uint64 fullSize);
|
||||
//! \see IRyzomControlListener::onFileInstalling
|
||||
virtual void onFileInstalling(const std::string& sourceName, uint32 rate, uint32 fileIndex, uint32 fileCount, uint64 fileSize, uint64 fullSize);
|
||||
//! \see IRyzomControlListener::initI18n
|
||||
void initI18n(const char* lang, unsigned char *data, uint32 length);
|
||||
//! \see IRyzomControlListener::fatalError
|
||||
virtual void fatalError(const std::string& errorId, const std::string& param1, const std::string& param2);
|
||||
//! \see IRyzomControlListener::resetCfgAndStringCache
|
||||
virtual void resetCfgAndStringCache();
|
||||
|
||||
private:
|
||||
enum EUpdaterState {idle, init, scanData, checkData, patch, finish}; //!< different state of the install process
|
||||
EUpdaterState _CurrentState; //!< The current state of the pach process
|
||||
CPatchManager* _PatchManager; //!< The Patch Manager that realy does the pach process
|
||||
IRyzomControlListener* _Listener; //!< The listener received controller feed back (the GUI must inherit from this class)
|
||||
CInstallLoadProxy* _InstallLoadProxy;//!< Contains i18n file (needed to "load the translation"
|
||||
CRyzomInstallStateListener* _StateListener; //!< The Stats listener receive the log ask from patch manager
|
||||
bool _InitPatchManager; //!< true if initPatchManager has been called
|
||||
std::string _Language; //!< The language of the install program (from cfg file)
|
||||
std::string _StartupHost;//!< The startup host used to have pacth url (from cfg file)
|
||||
std::string _StartupPage;//!< The startup host used to have pacth url (from cfg file)
|
||||
std::string _InstallStartupHost;//!< used for debug (if we want to use alternate host for client_install.php) (from cfg file)
|
||||
std::string _InstallStartupPage;//!< used for debug (if we want to use alternate host for client_install.php) (from cfg file)
|
||||
std::string _Application;//!< The Application name of Ryzom(from cfg file)
|
||||
std::string _InstallStatsUrl; // the URL of the stats tools eg http://r2linux03/stats/stats.php
|
||||
};
|
||||
|
||||
void CRyzomControlImpl::fatalError(const std::string& errorId, const std::string& param1, const std::string& param2)
|
||||
{
|
||||
//forward message to gui via IRyzomControlListener
|
||||
_Listener->fatalError(errorId.c_str(), param1.c_str(), param2.c_str());
|
||||
}
|
||||
|
||||
const char* CRyzomControlImpl::getServerVersion() const
|
||||
{
|
||||
//get infos on version from manager
|
||||
return _PatchManager->getServerVersion().c_str();
|
||||
}
|
||||
|
||||
CRyzomControlImpl::CRyzomControlImpl(IRyzomControlListener* listener)
|
||||
{
|
||||
_PatchManager = CPatchManager::getInstance();
|
||||
// the name of the file to launch at end of install
|
||||
_PatchManager->setRyzomFilename( ".\\client_ryzom_rd.exe" );
|
||||
_CurrentState = idle;
|
||||
_Listener = listener;
|
||||
_InstallLoadProxy = new CInstallLoadProxy();
|
||||
_StateListener = new CRyzomInstallStateListener(listener);
|
||||
_PatchManager->setStateListener(_StateListener);
|
||||
_InitPatchManager = false;
|
||||
TheTmpInstallDirectory = _Listener->getTmpInstallDirectory();
|
||||
loadCfg();
|
||||
|
||||
}
|
||||
|
||||
|
||||
CRyzomControlImpl::~CRyzomControlImpl()
|
||||
{
|
||||
delete _InstallLoadProxy;
|
||||
}
|
||||
|
||||
|
||||
void CRyzomControlImpl::check()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CRyzomControlImpl::getPackageSelection(bool mustRepairFirst)
|
||||
{
|
||||
if (_CurrentState == idle)
|
||||
{
|
||||
if (mustRepairFirst)
|
||||
{
|
||||
// launch MD5 integrity check
|
||||
_CurrentState = scanData;
|
||||
_PatchManager->startScanDataThread();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// launch size timestamp integrity check
|
||||
_CurrentState = checkData;
|
||||
_PatchManager->startCheckThread(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CRyzomControlImpl::getDownloadList(IStringContainer* categoryList)
|
||||
{
|
||||
if (_CurrentState == idle)
|
||||
{
|
||||
|
||||
_CurrentState = patch;
|
||||
std::vector<std::string> categories;
|
||||
uint32 first = 0, last = categoryList->getCount() ;
|
||||
for (; first != last; ++first)
|
||||
{
|
||||
categories.push_back(categoryList->getName(first));
|
||||
}
|
||||
// Ask the PatchManager to use inform use of progression
|
||||
_PatchManager->setAsyncDownloader( this );
|
||||
// we add all non optional categories to download
|
||||
_PatchManager->startPatchThread(categories, true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CRyzomControlImpl::update()
|
||||
{
|
||||
|
||||
if (_CurrentState == idle) { return; }
|
||||
|
||||
|
||||
if (_CurrentState == scanData)
|
||||
{
|
||||
bool ok, end;
|
||||
end = _PatchManager->isScanDataThreadEnded(ok);
|
||||
// update Gui
|
||||
_Listener->updateFuntion(IRyzomControlListener::ScanData, _PatchManager->getCurrentFilesToGet()+1, _PatchManager->getTotalFilesToGet());
|
||||
// if scan Data thread is finished launch Check Data Thread
|
||||
if (!end) { return; }
|
||||
_CurrentState = idle;
|
||||
_Listener->onScanDataFinished();
|
||||
_CurrentState = checkData;
|
||||
_PatchManager->startCheckThread(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (_CurrentState == checkData)
|
||||
{
|
||||
bool ok, end;
|
||||
end = _PatchManager->isCheckThreadEnded(ok);
|
||||
//update GUI
|
||||
_Listener->updateFuntion(IRyzomControlListener::CheckData, _PatchManager->getCurrentFilesToGet()+1, _PatchManager->getTotalFilesToGet());
|
||||
// if check Data thread is finished give package list to to Listener
|
||||
if (!end) { return; }
|
||||
CPatchManager::SPatchInfo InfoOnPatch;
|
||||
_PatchManager->getInfoToDisp(InfoOnPatch);
|
||||
CCheckInfoViewer viewer(&InfoOnPatch);
|
||||
_CurrentState = idle;
|
||||
_Listener->onCheckFinished(&viewer);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (_CurrentState == patch)
|
||||
{
|
||||
bool ok, end;
|
||||
end = _PatchManager->isPatchThreadEnded(ok);
|
||||
//update GUI
|
||||
_Listener->updateFuntion(IRyzomControlListener::Patch, _PatchManager->getCurrentFilesToGet()+1, _PatchManager->getTotalFilesToGet());
|
||||
// if download is finished infor listener
|
||||
if (!end) { return; }
|
||||
_CurrentState = idle;
|
||||
_Listener->onDownloadListFinished();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CRyzomControlImpl::addToDownloadList(const std::string &patchName, const std::string &sourceName, uint32 timestamp, const std::string& extratPath, uint32 sevenZipFile, uint32 size)
|
||||
{
|
||||
// forward to listener (gui)
|
||||
_Listener->addToDownloadList(patchName.c_str(), sourceName.c_str(), timestamp, extratPath.c_str(), sevenZipFile, size);
|
||||
}
|
||||
|
||||
|
||||
void CRyzomControlImpl::install(IInstallEntryViewer* installList, bool download)
|
||||
{
|
||||
// create list of fil to download / install
|
||||
std::vector<CInstallThreadEntry> entries;
|
||||
uint32 first =0, last = installList->getCount();
|
||||
for (; first != last; ++first)
|
||||
{
|
||||
|
||||
entries.push_back( CInstallThreadEntry(
|
||||
installList->getPatchName(first),
|
||||
installList->getSourceName(first),
|
||||
installList->getTimestamp(first),
|
||||
installList->getExtractPath(first),
|
||||
installList->getSize(first),
|
||||
installList->getSZipFileSize(first)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Use this list to feed Patch / Install Thread
|
||||
if (download)
|
||||
{
|
||||
_PatchManager->startDownloadThread(entries);
|
||||
}
|
||||
else
|
||||
{
|
||||
_PatchManager->startInstallThread(entries);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CRyzomControlImpl::onFileInstallFinished()
|
||||
{
|
||||
// forward from PatchManager to listener (gui)
|
||||
_Listener->onFileInstallFinished();
|
||||
}
|
||||
|
||||
void CRyzomControlImpl::onFileDownloading(const std::string& sourceName, uint32 rate, uint32 fileIndex, uint32 fileCount, uint64 fileSize, uint64 fullSize)
|
||||
{
|
||||
// forward from PatchManager to listener (gui)
|
||||
_Listener->onFileDownloading(sourceName.c_str(), rate, fileIndex, fileCount, fileSize, fullSize);
|
||||
}
|
||||
|
||||
void CRyzomControlImpl::onFileInstalling(const std::string& sourceName, uint32 rate, uint32 fileIndex, uint32 fileCount, uint64 fileSize, uint64 fullSize)
|
||||
{
|
||||
// forward from PatchManager to listener (gui)
|
||||
_Listener->onFileInstalling(sourceName.c_str(), rate, fileIndex, fileCount, fileSize, fullSize);
|
||||
}
|
||||
|
||||
|
||||
void CRyzomControlImpl::onFileDownloadFinished()
|
||||
{
|
||||
// forward from PatchManager to listener (gui)
|
||||
_Listener->onFileDownloadFinished();
|
||||
}
|
||||
|
||||
|
||||
// C Callback
|
||||
static void requestStopFun()
|
||||
{
|
||||
CRyzomControlImpl* impl = dynamic_cast<CRyzomControlImpl*>(IRyzomControl::getInstance());
|
||||
impl->requestStop();
|
||||
}
|
||||
|
||||
|
||||
void CRyzomControlImpl::initPatchManager()
|
||||
{
|
||||
if (_InitPatchManager) { return; }
|
||||
// Ask to listener the PatchURI
|
||||
std::vector<std::string> patchURIs;
|
||||
for ( uint32 first = 0, last = _Listener->getPatchUriCount(); first != last; ++first)
|
||||
{
|
||||
patchURIs.push_back(std::string( _Listener->getPatchUriValue(first) ) );
|
||||
}
|
||||
|
||||
// Init patch manager with url from login.php
|
||||
try
|
||||
{
|
||||
_PatchManager->init(patchURIs, _Listener->getServerPath(), _Listener->getVersion());
|
||||
} catch(...)
|
||||
{
|
||||
_Listener->fatalError("uiBGD_LoadVersionError" , "", "");
|
||||
return;
|
||||
}
|
||||
|
||||
if (R2ServerVersion == "")
|
||||
{
|
||||
_Listener->fatalError("uiBGD_LoadVersionError" , "", "");
|
||||
return;
|
||||
}
|
||||
|
||||
_InitPatchManager= true;
|
||||
}
|
||||
bool CRyzomControlImpl::download(const char* patchPath, const char* sourcePath,
|
||||
const char* tmpDirectory, uint32 timestamp)
|
||||
{
|
||||
// forward from listener (GUI) to Patchmanager
|
||||
if (!_InitPatchManager)
|
||||
{
|
||||
initPatchManager();
|
||||
}
|
||||
return _PatchManager->download(std::string(patchPath), std::string(sourcePath),
|
||||
std::string(tmpDirectory), timestamp);
|
||||
}
|
||||
|
||||
void CRyzomControlImpl::requestStop()
|
||||
{
|
||||
// forward from Patchmanage to (GUI)
|
||||
_Listener->requestStop();
|
||||
}
|
||||
|
||||
bool CRyzomControlImpl::extract(char* sourceFilename [],
|
||||
char* extractPath [],
|
||||
uint32 size)
|
||||
{
|
||||
// forward from listener (GUI) to patchmanager
|
||||
|
||||
std::vector<std::string> source;
|
||||
std::vector<std::string> extract;
|
||||
for ( uint32 first = 0 ; first != size; ++ first)
|
||||
{
|
||||
source.push_back(sourceFilename[first]);
|
||||
extract.push_back(extractPath[first]);
|
||||
}
|
||||
return _PatchManager->extract("tmp", source, extract, "updt_launcher.bat", _Listener->getLauncherName(), requestStopFun);
|
||||
}
|
||||
|
||||
|
||||
void CRyzomControlImpl::initI18n(const char* lang, unsigned char *data, uint32 length)
|
||||
{
|
||||
//Obsolete because the load is done in the main application
|
||||
/*
|
||||
using namespace NLMISC;
|
||||
ucstring result;
|
||||
CI18N::readTextBuffer(data, length, result, false);
|
||||
|
||||
_InstallLoadProxy->Data[ std::string(lang) + std::string(".uxt") ] = result;
|
||||
// load of a simulated "lang.uxt" trad file passd as argument
|
||||
CI18N::setLoadProxy(_InstallLoadProxy);
|
||||
CI18N::load(lang);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
const char * CRyzomControlImpl::getLogUrl(const char* action) const
|
||||
{
|
||||
// create url to stats.php with get argument
|
||||
static std::string buffer;
|
||||
buffer = _InstallStatsUrl+ std::string("?cmd=log&msg=") + action;
|
||||
return buffer.c_str();
|
||||
}
|
||||
|
||||
|
||||
const char *CRyzomControlImpl::getPatchUrl() const
|
||||
{
|
||||
// create patch url (login php)
|
||||
static std::string buffer;
|
||||
buffer = std::string("http://")+_InstallStartupHost + _InstallStartupPage + std::string("?cmd=get_patch_url&lang=") + _Language + std::string("&domain=") + _Application;
|
||||
return buffer.c_str();
|
||||
}
|
||||
|
||||
const char *CRyzomControlImpl::getInstallHttpBackground() const
|
||||
{
|
||||
// create smal background web site url
|
||||
static std::string buffer;
|
||||
buffer = ClientLauncherUrl + std::string("/client_install_")+ _Language + std::string(".htm");
|
||||
return buffer.c_str();
|
||||
}
|
||||
|
||||
void CRyzomControlImpl::resetCfgAndStringCache()
|
||||
{
|
||||
NLMISC::CConfigFile ConfigFile;
|
||||
bool ok = true;
|
||||
try
|
||||
{
|
||||
if (NLMISC::CFile::fileExists("./client.cfg"))
|
||||
{
|
||||
ConfigFile.load("./client.cfg");
|
||||
}
|
||||
else
|
||||
{
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (ok && ConfigFile.getVarPtr("LanguageCode") )
|
||||
{
|
||||
_Language = ConfigFile.getVar("LanguageCode").asString(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_Language = "en";
|
||||
}
|
||||
//Use .cfg value to write to the new clean client.cfg
|
||||
{
|
||||
std::string cfgContent = std::string("RootConfigFilename = \"client_default.cfg\";\r\n") +
|
||||
std::string("LanguageCode = \"")+_Language + std::string("\";\r\n");
|
||||
CConfigFile::CVar* startupHost = ConfigFile.getVarPtr("StartupHost");
|
||||
if (startupHost)
|
||||
{
|
||||
_StartupHost = startupHost->asString(0);
|
||||
cfgContent += NLMISC::toString("StartupHost = \"%s\";\r\n",startupHost->asString(0).c_str());
|
||||
}
|
||||
CConfigFile::CVar* application = ConfigFile.getVarPtr("Application");
|
||||
if (application)
|
||||
{
|
||||
cfgContent += NLMISC::toString("Application = {\"%s\", \"%s\", \"%s\"};\r\n", application->asString(0).c_str(), application->asString(1).c_str(), application->asString(2).c_str());
|
||||
}
|
||||
|
||||
COFile cfg("client.cfg");
|
||||
cfg.serialBuffer((uint8*)cfgContent.c_str(), cfgContent.size());
|
||||
|
||||
}
|
||||
// delete data/*.string_cache files
|
||||
{
|
||||
std::vector<std::string> vFiles;
|
||||
CPath::getPathContent("data", false, false, true, vFiles);
|
||||
for (uint32 i = 0; i < vFiles.size(); ++i)
|
||||
{
|
||||
if (NLMISC::CFile::getExtension(vFiles[i]) == "string_cache")
|
||||
{
|
||||
NLMISC::CFile::deleteFile(vFiles[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CRyzomControlImpl::loadCfg()
|
||||
{
|
||||
NLMISC::CConfigFile ConfigFile;
|
||||
bool ok = true;
|
||||
|
||||
// if already launch destroy cfg file (exedell has been unpack)
|
||||
// and create another cleaner
|
||||
|
||||
|
||||
// normal case load the client.cfg
|
||||
try
|
||||
{
|
||||
ConfigFile.load("./client.cfg");
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
resetCfgAndStringCache();
|
||||
|
||||
try
|
||||
{
|
||||
ConfigFile.load("./client.cfg");
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_Listener->fatalError("uiCfgError" , "", "");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// load calues from client.cfg
|
||||
if (!ConfigFile.getVarPtr("StartupHost")
|
||||
|| !ConfigFile.getVarPtr("Application")
|
||||
|| !ConfigFile.getVarPtr("LanguageCode")
|
||||
|| !ConfigFile.getVarPtr("StartupPage")
|
||||
)
|
||||
{
|
||||
_Listener->fatalError("uiCfgError" , "", "");
|
||||
return;
|
||||
}
|
||||
_Application = ConfigFile.getVar("Application").asString(0);
|
||||
//CfgApplication = _Application;
|
||||
_StartupHost = ConfigFile.getVar("StartupHost").asString(0);
|
||||
_Language = ConfigFile.getVar("LanguageCode").asString(0);
|
||||
_StartupPage = ConfigFile.getVar("StartupPage").asString(0);
|
||||
|
||||
if ( ConfigFile.getVarPtr("InstallStartupPage") )
|
||||
{
|
||||
//dev can use specific url for debug
|
||||
_InstallStartupPage = ConfigFile.getVarPtr("InstallStartupPage")->asString(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_InstallStartupPage = "/login2/client_install.php";
|
||||
std::string::size_type pos = _StartupPage.rfind("/");
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
_InstallStartupPage = _StartupPage.substr(0, pos);
|
||||
_InstallStartupPage += "/client_install.php";
|
||||
}
|
||||
}
|
||||
|
||||
//dev can use specific url for debug
|
||||
if ( ConfigFile.getVarPtr("InstallStartupHost") )
|
||||
{
|
||||
_InstallStartupHost = ConfigFile.getVarPtr("InstallStartupHost")->asString(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_InstallStartupHost = _StartupHost;
|
||||
}
|
||||
|
||||
// Url of the stas.php
|
||||
if ( ConfigFile.getVarPtr("InstallStatsUrl") )
|
||||
{
|
||||
_InstallStatsUrl = ConfigFile.getVarPtr("InstallStatsUrl")->asString(0);
|
||||
}
|
||||
|
||||
NLMISC::CConfigFile::CVar* installRate = ConfigFile.getVarPtr("InstallRate");
|
||||
if (installRate)
|
||||
{
|
||||
_Listener->setInstallRate( installRate->asDouble() );
|
||||
}
|
||||
|
||||
ClientLauncherUrl =std::string("http://")+ _InstallStartupHost; // if not def user same server
|
||||
}
|
||||
|
||||
|
||||
const char* CRyzomControlImpl::getApplication() const
|
||||
{
|
||||
return _Application.c_str();
|
||||
}
|
||||
|
||||
const char* CRyzomControlImpl::getLanguage() const
|
||||
{
|
||||
return _Language.c_str();
|
||||
}
|
||||
|
||||
const char* CRyzomControlImpl::getStartupHost() const
|
||||
{
|
||||
return _StartupHost.c_str();
|
||||
}
|
||||
//---------------------------------------------------------
|
||||
|
||||
//!see IRyzomVersionMaker
|
||||
class CRyzomVersionMaker : public IRyzomVersionMaker
|
||||
{
|
||||
private:
|
||||
//! Store pach element infos
|
||||
class CArchiveFile
|
||||
{
|
||||
public:
|
||||
CArchiveFile(const std::string& filename, uint32 version, bool optional, uint32 timestamp)
|
||||
:BaseName(filename), Version(version), Optional(optional), Timestamp(timestamp){}
|
||||
|
||||
std::string BaseName;
|
||||
uint32 Version;
|
||||
uint32 Timestamp;
|
||||
bool Optional;
|
||||
|
||||
};
|
||||
|
||||
//! Sort patch element by category (optional and by timestamp)
|
||||
class CArchiveFileSortFunc
|
||||
{
|
||||
public:
|
||||
bool operator ()(const CArchiveFile* lf, const CArchiveFile* rh) const
|
||||
{
|
||||
if ( lf->Optional != rh->Optional)
|
||||
{
|
||||
return lf->Optional;
|
||||
}
|
||||
return lf->Timestamp < rh->Timestamp;
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
static CRyzomVersionMaker* getInstance();
|
||||
|
||||
static void releaseInstance();
|
||||
|
||||
//! \see RyzomVersionMaker::setLog
|
||||
virtual void setLog( void (*log)(const char*))
|
||||
{
|
||||
_Log = log;
|
||||
}
|
||||
|
||||
//! \see RyzomVersionMaker::create
|
||||
virtual void create(const char* idxFilename, const char* archivefilename, IArchiveMakerListener* listener);
|
||||
|
||||
private:
|
||||
static CRyzomVersionMaker* _Instance;
|
||||
void (*_Log)(const char*);
|
||||
};
|
||||
|
||||
CRyzomVersionMaker* CRyzomVersionMaker::_Instance = 0;
|
||||
|
||||
void CRyzomVersionMaker::create(const char* idxFilename, const char* archivefilename, IArchiveMakerListener* listener)
|
||||
{
|
||||
|
||||
typedef std::vector<CArchiveFile*> TArchives;
|
||||
TArchives Archives;
|
||||
CProductDescriptionForClient client;
|
||||
//load version description file
|
||||
client.load(idxFilename);
|
||||
|
||||
{
|
||||
const CBNPFileSet &fileset = client.getFiles();
|
||||
//for each category
|
||||
const CBNPCategorySet & categorySet = client.getCategories();
|
||||
uint32 first = 0, last = categorySet.categoryCount();
|
||||
for (; first != last; ++first)
|
||||
{
|
||||
// for each file of a category
|
||||
const CBNPCategory& category = categorySet.getCategory(first);
|
||||
uint32 first2=0, last2=category.fileCount();
|
||||
for (;first2 != last2; ++first2)
|
||||
{
|
||||
// get the last VersionInfo of the file
|
||||
const std::string& filename = category.getFile(first2);
|
||||
const CBNPFile* filePtr = fileset.getFileByName(filename);
|
||||
if (filePtr)
|
||||
{
|
||||
uint32 versionCount = filePtr->versionCount();
|
||||
if ( versionCount != 0)
|
||||
{
|
||||
const CBNPFileVersion& version = filePtr->getVersion(versionCount - 1);
|
||||
// add file info to the Archive list
|
||||
Archives.push_back( new CRyzomVersionMaker::CArchiveFile(filename, version.getVersionNumber(), category.isOptional(), version.getTimeStamp()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_Log)
|
||||
{
|
||||
std::string msg = NLMISC::toString("\"%s\" has no version but is member of categories \"%s\"...", filename.c_str(), category.getName().c_str());
|
||||
_Log(msg.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_Log)
|
||||
{
|
||||
std::string msg = NLMISC::toString("\"%s\" is in category but not in fileset", filename.c_str() );
|
||||
_Log(msg.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// sort the Archive list by category and timestamp (Archive is download by chunk so we try that the player has linear need)
|
||||
std::stable_sort(Archives.begin(), Archives.end(), CRyzomVersionMaker::CArchiveFileSortFunc());
|
||||
listener->beginArchive(archivefilename);
|
||||
{
|
||||
|
||||
TArchives::const_iterator first=Archives.begin(), last = Archives.end();
|
||||
for (; first != last; ++first)
|
||||
{
|
||||
listener->addArchiveElement((*first)->BaseName.c_str(), (*first)->Version, (*first)->Optional, (*first)->Timestamp);
|
||||
}
|
||||
}
|
||||
{
|
||||
TArchives::iterator first=Archives.begin(), last = Archives.end();
|
||||
for (; first != last; ++first)
|
||||
{
|
||||
delete *first;
|
||||
}
|
||||
}
|
||||
listener->endArchive();
|
||||
|
||||
}
|
||||
|
||||
|
||||
CRyzomVersionMaker* CRyzomVersionMaker::getInstance()
|
||||
{ //singleton
|
||||
if (!_Instance){ _Instance = new CRyzomVersionMaker(); }
|
||||
return _Instance;
|
||||
}
|
||||
|
||||
void CRyzomVersionMaker::releaseInstance()
|
||||
{
|
||||
// release singleton
|
||||
if (_Instance)
|
||||
{
|
||||
delete _Instance;
|
||||
_Instance = 0;
|
||||
delete ApplicationContext;
|
||||
}
|
||||
}
|
||||
|
||||
IRyzomVersionMaker* IRyzomVersionMaker::getInstance()
|
||||
{
|
||||
return CRyzomVersionMaker::getInstance();
|
||||
}
|
||||
|
||||
void IRyzomVersionMaker::releaseInstance()
|
||||
{
|
||||
CRyzomVersionMaker::releaseInstance();
|
||||
}
|
||||
|
||||
IArchiveMakerListener::~IArchiveMakerListener(){}
|
||||
//-----------------------------------------------------------
|
||||
//!Forward CSystemInfo:: function
|
||||
//!{
|
||||
const char* INelControl::getOS ()
|
||||
{
|
||||
static std::string ret;
|
||||
ret = CSystemInfo::getOS();
|
||||
return ret.c_str();
|
||||
}
|
||||
|
||||
const char* INelControl::getProc ()
|
||||
{
|
||||
static std::string ret;
|
||||
ret = CSystemInfo::getProc();
|
||||
return ret.c_str();
|
||||
}
|
||||
|
||||
const char* INelControl::availableHDSpace ()
|
||||
{
|
||||
static std::string ret;
|
||||
ret = CSystemInfo::availableHDSpace(".");
|
||||
return ret.c_str();
|
||||
}
|
||||
|
||||
uint32 INelControl::availablePhysicalMemory ()
|
||||
{
|
||||
return CSystemInfo::availablePhysicalMemory();
|
||||
}
|
||||
|
||||
const char* INelControl::getVideoInfoDeviceName ()
|
||||
{
|
||||
static std::string ret;
|
||||
uint64 version;
|
||||
ret = "";
|
||||
bool ok = CSystemInfo::getVideoInfo(ret, version);
|
||||
if (ok)
|
||||
{
|
||||
return ret.c_str();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
uint64 INelControl::driverVersion()
|
||||
{
|
||||
static std::string ret;
|
||||
uint64 version=0;
|
||||
ret = "";
|
||||
bool ok = CSystemInfo::getVideoInfo(ret, version);
|
||||
if (ok)
|
||||
{
|
||||
return version;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//!}
|
||||
//-----------------------------------------------------------
|
||||
IRyzomControl* IRyzomControl::init(IRyzomControlListener* listener)
|
||||
{
|
||||
//ApplicationContext = new NLMISC::CApplicationContext();
|
||||
_Instance = new CRyzomControlImpl(listener);
|
||||
return _Instance;
|
||||
}
|
||||
|
||||
|
||||
IRyzomControl* IRyzomControl::_Instance = 0;
|
@ -0,0 +1,389 @@
|
||||
#ifndef __RYZOM_CONTROL_H__
|
||||
#define __RYZOM_CONTROL_H__
|
||||
|
||||
// Compile as static lib
|
||||
#if 0
|
||||
#ifdef RYZOM_CONTROL_BUILD
|
||||
#define RYZOM_CONTROL_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define RYZOM_CONTROL_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define RYZOM_CONTROL_EXPORT
|
||||
#endif
|
||||
/** This class must be use by module outside the dll to access Ryzom Specific info on patch.
|
||||
Class with stl object is not used. Becaus stl can have different definition between 2 dll
|
||||
*/
|
||||
class RYZOM_CONTROL_EXPORT ICkeckInfoViewer
|
||||
{
|
||||
public:
|
||||
virtual ~ICkeckInfoViewer(){}
|
||||
enum ECat { NonOptCat, ReqCat, OptCat };
|
||||
|
||||
public:
|
||||
/** Returns the number of item of a category
|
||||
eg getCount(ICkeckInfoViewer::ReqCat) return the number of element for the category required
|
||||
*/
|
||||
virtual uint32 getCount(ECat cat) const = 0;
|
||||
|
||||
/** Returns the name (by example exe_dll.bnp) of the patch element
|
||||
\param cat is the category (can be option, non optional or required)
|
||||
\index is the index of the element (starting at zero finishing at this->getCount(cat))
|
||||
*/
|
||||
virtual const char * getName(ECat cat, uint32 index) const = 0;
|
||||
|
||||
/** Returns the seven_zip size of the pach element (by example exe_dll.bnp.lzma)
|
||||
\param cat is the category (can be option, non optional or required)
|
||||
\index is the index of the element (starting at zero finishing at this->getCount(cat))
|
||||
*/
|
||||
virtual uint32 getSZipFileSize(ECat cat, uint32 index) const = 0;
|
||||
|
||||
/** Returns the size of the pach element after depack (size of exe_dll.bnp)
|
||||
\param cat is the category (can be option, non optional or required)
|
||||
\index is the index of the element (starting at zero finishing at this->getCount(cat))
|
||||
*/
|
||||
virtual uint32 getFileSize(ECat cat, uint32 index) const = 0;
|
||||
};
|
||||
|
||||
/** Module outside of the dll must inherit of this class in order to knwo the current state of the download.*/
|
||||
class RYZOM_CONTROL_EXPORT IRyzomControlListener
|
||||
{
|
||||
public:
|
||||
|
||||
/* Different stats of the download process (ScanData is the md5 integrity test,
|
||||
CheckData is the size + timestamp integrity testpach is downloading
|
||||
*/
|
||||
enum TUpdateType { ScanData, CheckData, Patch, Install };
|
||||
|
||||
public:
|
||||
virtual ~IRyzomControlListener(){}
|
||||
/** Called when the check thread finished the viewer param enable the inherited class to know the different package that need to be patch
|
||||
\param viewer The list of package that must be patched
|
||||
*/
|
||||
virtual void onCheckFinished(ICkeckInfoViewer* viewer){}
|
||||
|
||||
/** Called when scan data is finished (scan data is the md5 integrity test
|
||||
*/
|
||||
virtual void onScanDataFinished() {}
|
||||
|
||||
/** Called when all the file that need to be downloaded are finished
|
||||
*/
|
||||
virtual void onDownloadListFinished(){}
|
||||
|
||||
/** A file has been added to the download list (will be downlaod via patch system)
|
||||
\param patchName The name of the patch "/0012/exe_dll.bnp.lzma"
|
||||
\param sourceName The name of the sourceName "data/exe_dll.bnp"
|
||||
\param timestamp The timestamp to apply to the file after install
|
||||
\param extractPath if present the directory to extract data (eg "unpack/")
|
||||
\param sZipFileSize The size of the lzma file
|
||||
\param size The size of the bnp file
|
||||
*/
|
||||
virtual void addToDownloadList(const char* patchName, const char* sourceName, uint32 timestamp, const char* extractPath, uint32 sZipFileSize, uint32 size){}
|
||||
|
||||
/** Called when the all file have been installed
|
||||
*/
|
||||
virtual void onFileInstallFinished(){}
|
||||
|
||||
/** Called periodicaly (at each new download) to indicate the state of the downlaod progress
|
||||
\param sourceName the name of the file that is downloading
|
||||
\param rate The amount of byte by second of the process
|
||||
\param fileIndex The index of the file (0 to fileCount)
|
||||
\param fileCount The number of file to process
|
||||
\param fileSize The size of data processed
|
||||
\param fullSize The total amount of data to process
|
||||
*/
|
||||
virtual void onFileDownloading(const char* sourceName, uint32 rate, uint32 fileIndex, uint32 fileCount, uint64 fileSize, uint64 fullSize){}
|
||||
|
||||
/** Called periodicaly (at each new install) to indicate the state of the install progress
|
||||
\param sourceName the name of the file that is installing
|
||||
\param rate The amount of byte by second of the process
|
||||
\param fileIndex The index of the file (0 to fileCount)
|
||||
\param fileCount The number of file to process
|
||||
\param fileSize The size of data processed
|
||||
\param fullSize The total amount of data to process
|
||||
*/
|
||||
virtual void onFileInstalling(const char* sourceName, uint32 rate, uint32 fileIndex, uint32 fileCount, uint64 fileSize, uint64 fullSize){}
|
||||
|
||||
/** Called at the end of the downlaod process
|
||||
*/
|
||||
virtual void onFileDownloadFinished(){}
|
||||
|
||||
/** Returns the quantity of Uri given by the login process
|
||||
*/
|
||||
|
||||
virtual uint32 getPatchUriCount() const= 0;
|
||||
/** Must return the a patch Uri by its index.
|
||||
*/
|
||||
virtual const char * getPatchUriValue(uint32 index) const = 0;
|
||||
|
||||
/** Must return the pas path to the patch backup server
|
||||
*/
|
||||
virtual const char* getServerPath() const = 0;
|
||||
|
||||
/** Must return the version number as string (eg "187")
|
||||
*/
|
||||
virtual const char * getVersion() const = 0;
|
||||
|
||||
/** Must return the name of the laucher application "client_install.exe"
|
||||
*/
|
||||
virtual const char * getLauncherName() const = 0;
|
||||
|
||||
/** Must return the name of the laucher application "client_install.exe"
|
||||
*/
|
||||
virtual const char * getTmpInstallDirectory() const = 0;
|
||||
|
||||
/** The download/install process has been stoped
|
||||
*/
|
||||
virtual void requestStop() = 0;
|
||||
|
||||
/** Display a warning / info message (from the patch system)
|
||||
\param bOutputToLog True if the string must be display (warning), false if not (infod / debug)
|
||||
*/
|
||||
virtual void setState (bool bOutputToLog, const char* newState) = 0;
|
||||
|
||||
/** Called by the ScanData / CheckData process to indicate the state of progress
|
||||
\param updateType can be ScanData, CheckData
|
||||
\param index The index of the file processed
|
||||
\param max The number of file to process
|
||||
*/
|
||||
virtual void updateFuntion(TUpdateType updateType, uint32 index, uint32 max) = 0;
|
||||
|
||||
|
||||
/** Called to indicate an error
|
||||
\param msg is a i18n error msg
|
||||
\param param1 A error specific msg (empty or the argument to the format string given by the translation of msg)
|
||||
\param param1 same as param1
|
||||
*/
|
||||
virtual void fatalError(const char* msg, const char* param1, const char* param2) = 0;
|
||||
virtual void setInstallRate(double rate) = 0;
|
||||
|
||||
};
|
||||
|
||||
/** Interface to access to patch infos.
|
||||
A concret class with stl struct could create issues if used between dll compiled with different options
|
||||
*/
|
||||
class RYZOM_CONTROL_EXPORT IInstallEntryViewer
|
||||
{
|
||||
public:
|
||||
virtual ~IInstallEntryViewer(){}
|
||||
//! Returns the number of entry in the patch list
|
||||
virtual uint32 getCount() const = 0;
|
||||
//! Returns the name of a patch (.lzma)entry (from the patch list)
|
||||
virtual const char * getPatchName(uint32 index) const = 0;
|
||||
//! Returns the name of a source (.bnp) (from the patch list)
|
||||
virtual const char * getSourceName(uint32 index) const = 0;
|
||||
//! Returns the timestamp of the file
|
||||
virtual uint32 getTimestamp(uint32 index) const = 0;
|
||||
//! Returns the path where the file must be extract b.e. "data/" (or empty string)
|
||||
virtual const char * getExtractPath(uint32 index) const = 0;
|
||||
//! Returns the size of the bnp file
|
||||
virtual uint32 getSize(uint32 index) const = 0;
|
||||
//! Returns the size of the lzma file
|
||||
virtual uint32 getSZipFileSize(uint32 index) const = 0;
|
||||
|
||||
};
|
||||
/** Must be inherited to implement "string" container
|
||||
A concret class with stl struct could not be usedbecause it can create issues if used between dll compiled with different options
|
||||
*/
|
||||
|
||||
class RYZOM_CONTROL_EXPORT IStringContainer
|
||||
{
|
||||
public:
|
||||
virtual ~IStringContainer(){}
|
||||
//! Returns the size of the container
|
||||
virtual uint32 getCount() const = 0;
|
||||
|
||||
/** Return the value of the string conainer at specified index
|
||||
The function is called getName and not getValue because its only used is to hold a list of filename
|
||||
\param the index to get the file (between 0 and this->getCount())
|
||||
*/
|
||||
virtual const char * getName(uint32 index) const = 0;
|
||||
};
|
||||
|
||||
/** This class is the entry point to control the Ryzom Patching process
|
||||
At the init function a listener is passed to have feedback from the controller
|
||||
*/
|
||||
class RYZOM_CONTROL_EXPORT IRyzomControl
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
virtual ~IRyzomControl(){}
|
||||
/** Initialize the controller with a feedback class (listener) and return the instance
|
||||
*/
|
||||
static IRyzomControl* init(IRyzomControlListener* listener);
|
||||
|
||||
/** Return the instance of the singleton (must be initialized with init becfore)
|
||||
*/
|
||||
static IRyzomControl* getInstance() { return _Instance; }
|
||||
|
||||
//! obsolete?
|
||||
virtual void destroy() = 0;
|
||||
|
||||
//!obsolete?
|
||||
virtual void check() = 0;
|
||||
|
||||
//! Must be called at each tick (called back the listener to indicate the state of the progression)
|
||||
virtual void update() = 0;
|
||||
|
||||
/** Ask the instance to call the listener back with the package list in function of the data present on the disk ("matis_island",...)
|
||||
\param mustRepair True if a md5 check must be done on present file
|
||||
*/
|
||||
virtual void getPackageSelection(bool mustRepair) = 0;
|
||||
|
||||
/** Ask the instance to call the listener back with the list of file to download
|
||||
\pram categoryList The list of category we wants to download (given via getPackageSelection)
|
||||
*/
|
||||
virtual void getDownloadList(IStringContainer* categoryList) = 0;
|
||||
|
||||
/** Indicates if we want to start ryzom at the end of install.
|
||||
A .bat file is created to unpack data. The module want to know if he must add a start client_ryzom_rd.exe at the end of the .bat file
|
||||
\pram ok True if we want to start Ryzom client at the end of the install process.
|
||||
*/
|
||||
virtual void setStartRyzomAtEnd(bool ok) = 0;
|
||||
|
||||
/** Ask the instance to downlaod or start the installation of a patch file list
|
||||
\parm isntallList The list of file to install/download
|
||||
\pram download if false indicates that the download is also needed
|
||||
*/
|
||||
virtual void install(IInstallEntryViewer* installList, bool download = false) = 0;
|
||||
|
||||
|
||||
/** Called by patch Thread to indicate the state of the downlaod process
|
||||
It will call back the listener function.
|
||||
\see CRyzomListener::onDownloadProgress
|
||||
*/
|
||||
virtual bool download(const char* patchPath, const char* sourcePath,
|
||||
const char* tmpDirectory, uint32 timestamp) = 0;
|
||||
|
||||
/** Called by install Thread to apply the unpack of data
|
||||
\param sourceFilename The list of file name of file to unpaack
|
||||
\parma extractPath A list of extract path (or empty string)
|
||||
\pram siez the number of entry of *BOOTH* lists
|
||||
*/
|
||||
virtual bool extract(char* sourceFilename [], char* extractPath [], uint32 size) = 0;
|
||||
|
||||
/** Called by Install dll to indicates to the listener that the install lise finished
|
||||
*/
|
||||
virtual void requestStop() = 0;
|
||||
|
||||
/** Init the i18n subsystem using Ryzom .uxt file content
|
||||
\param language is the langage to read data eg "fr"
|
||||
\param data is the content of a .uxt i18n file
|
||||
\param length Is the size of data of the i18n file
|
||||
*/
|
||||
virtual void initI18n(const char* language, unsigned char *data, uint32 length) = 0;
|
||||
|
||||
/** When called ask the system to read i18n file and PatchUri path
|
||||
*/
|
||||
virtual void initPatchManager() = 0;
|
||||
|
||||
/** Returns the StartupHost (from the config file)
|
||||
*/
|
||||
virtual const char* getStartupHost() const = 0;
|
||||
|
||||
/** Returns the Application (from the config file)
|
||||
*/
|
||||
virtual const char* getApplication() const = 0;
|
||||
|
||||
/** Returns the language code (from the config file)
|
||||
*/
|
||||
virtual const char* getLanguage() const = 0;
|
||||
|
||||
/** Return the version of the server as string eg "188"
|
||||
*/
|
||||
virtual const char* getServerVersion() const = 0;
|
||||
|
||||
/** Return the backup patch url
|
||||
*/
|
||||
virtual const char* getPatchUrl() const = 0;
|
||||
|
||||
/** Return the url of the php stat website (eg http://r2linux03/stats/starts.php?action=log&...
|
||||
\param action is the action to execute on the website
|
||||
*/
|
||||
virtual const char* getLogUrl(const char* action) const = 0;
|
||||
|
||||
/** Gets the url of the small website display while the download process (eg http://dl1.gfsrv.net:40916/installer/client_install_fr.htm)
|
||||
*/
|
||||
virtual const char* getInstallHttpBackground() const = 0;
|
||||
|
||||
/** Reset the cfg file to clean default cfg. Clean the string cache.
|
||||
*/
|
||||
virtual void resetCfgAndStringCache() = 0;
|
||||
private:
|
||||
/** The instance of the module
|
||||
*/
|
||||
static IRyzomControl* _Instance;
|
||||
};
|
||||
|
||||
|
||||
/** Used by the archive creation process to control the creation of a new archive
|
||||
The only use of this class for the moment is CTorrentMakerListener that enable the creation of .torrent file
|
||||
*/
|
||||
class RYZOM_CONTROL_EXPORT IArchiveMakerListener
|
||||
{
|
||||
public:
|
||||
//! \see CTorrentMakerListener::beginArchive
|
||||
virtual void beginArchive( const char* outputfile) = 0;
|
||||
|
||||
//! \see CTorrentMakerListener::addArchiveElement
|
||||
virtual void addArchiveElement(const char* filename, uint32 version, bool optional, uint32 timestamp) = 0;
|
||||
|
||||
//! \see CTorrentMakerListener::endArchive
|
||||
virtual void endArchive() = 0;
|
||||
|
||||
//! \see CTorrentMakerListener::setLog
|
||||
virtual void setLog( void (*log)(const char*)) = 0;
|
||||
|
||||
virtual ~IArchiveMakerListener();
|
||||
};
|
||||
|
||||
|
||||
/** Used to create new archive with file sorted by category and timestamp to let the possibilit to be
|
||||
able to download only chunck of data need for a patch (in case of using the torrent protocol)
|
||||
*/
|
||||
class RYZOM_CONTROL_EXPORT IRyzomVersionMaker
|
||||
{
|
||||
public:
|
||||
virtual ~IRyzomVersionMaker(){}
|
||||
|
||||
//! Gets the instance of the archive creator
|
||||
static IRyzomVersionMaker* getInstance();
|
||||
//! Release the isntance of the archive creator
|
||||
|
||||
static void releaseInstance();
|
||||
|
||||
|
||||
/** creat a new archive (using idx file to knwo the list of file of the archive)
|
||||
\param idxFilename The name of the idx file used to have the list.
|
||||
\param archiveName The name of the archive to create
|
||||
\param listener The file that realy create the archive
|
||||
*/
|
||||
virtual void create(const char* idxFilename, const char* archivefilename, IArchiveMakerListener* listener) = 0;
|
||||
|
||||
//! set a log function
|
||||
virtual void setLog( void (*log)(const char*)) = 0;
|
||||
|
||||
};
|
||||
|
||||
/** Get the access to nel info on os, proc, memory and others
|
||||
Used for class that do not realy want to link with nel (eg the installer)
|
||||
*/
|
||||
class RYZOM_CONTROL_EXPORT INelControl
|
||||
{
|
||||
public:
|
||||
//! see INelControl::getOS
|
||||
static const char* getOS ();
|
||||
//! see INelControl::getProc
|
||||
static const char* getProc ();
|
||||
//! see INelControl::availableHDSpace
|
||||
static const char* availableHDSpace ();
|
||||
//! see INelControl::availablePhysicalMemory
|
||||
static uint32 availablePhysicalMemory ();
|
||||
//! see INelControl::getVideoInfoDeviceName
|
||||
static const char* getVideoInfoDeviceName ();
|
||||
//! see INelControl::driverVersion
|
||||
static uint64 driverVersion();
|
||||
|
||||
};
|
||||
#endif
|
@ -0,0 +1,117 @@
|
||||
#ifndef __TORRENT_CONTROL_H__
|
||||
#define __TORRENT_CONTROL_H__
|
||||
|
||||
//#include "libtorrent/config.hpp"
|
||||
#define TORRENT_EXPORT
|
||||
|
||||
//This DLL is use for bittorent protocl management (from install software)
|
||||
|
||||
/** This abstract class defines interface to access to a list of file to patch and to set the size of a file that must be patched
|
||||
A simple stl struct can not be used because it can have diferente implementation from two different dll
|
||||
- torrent_control.dll <=> is not using stl_port (because does not works with torrent header)
|
||||
- ryzom_control.dll <=> is using stl_port
|
||||
*/
|
||||
class TORRENT_EXPORT ITorrentStringContainer
|
||||
{
|
||||
public:
|
||||
virtual ~ITorrentStringContainer(){}
|
||||
// get the size of the container
|
||||
virtual uint32 getCount() const {return 0;};
|
||||
//get an element of the container (the function is named getName (because it store patch filename list
|
||||
virtual const char * getName(uint32 index) const {return 0;};
|
||||
//set The size of the file that is stored at position index
|
||||
virtual void setSize(uint32 index, uint32 size) {};
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
This class must be inherited by a GUI class to display the progress info of a torrent download
|
||||
This class must be inherited from a Controler class to change the default port and upload bittrate limit
|
||||
*/
|
||||
class TORRENT_EXPORT ITorrentListener
|
||||
{
|
||||
public:
|
||||
virtual ~ITorrentListener(){}
|
||||
/// defines the first port to listen (torrent specific protocol)
|
||||
virtual int getFirstPort() const {return 6881; }
|
||||
/// defines the last port to listen (torrent specific protocol)
|
||||
virtual int getLastPort() const { return 6889; }
|
||||
/// defines the upload rate limit (0 means no limit)
|
||||
virtual int getUploadRateLimit() const { return 20*1024; }
|
||||
/// periodicaly called to inform of download progress
|
||||
virtual void progressInfo(const char* msg){}
|
||||
/// called when download is finished (file is complete)
|
||||
virtual void torrentFinished() {}
|
||||
/// should be defined by inherited class to set the directory where torrent tmp file are save (eg patch/tmp)
|
||||
virtual const char * getTorrentTmpDir() const {return 0;};
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
This class is used to control torrent protocol.
|
||||
An implementation of this interface is given by getInstance method
|
||||
This singleton is used to control the bittorrent protoocol.
|
||||
|
||||
*/
|
||||
class TORRENT_EXPORT ITorrentControl
|
||||
{
|
||||
public:
|
||||
virtual ~ITorrentControl(){}
|
||||
|
||||
//! get the instance of the singleton
|
||||
static ITorrentControl* getInstance() { return 0; }
|
||||
/** start the download of a torrent file. Do not download from the torrent file that are not in allewedFile
|
||||
\param torrentFilename The name of the torrent file
|
||||
\param allowedFile The list of file from the torrent file that we want to download
|
||||
*/
|
||||
virtual void startDownloading(const char* torrentFilename, ITorrentStringContainer* allowedFiles) {};
|
||||
|
||||
/**
|
||||
Returns true if we are downloading a file
|
||||
*/
|
||||
virtual bool isCurrentDownloadValid() const {return 0;}
|
||||
|
||||
/**
|
||||
Returns the name of the file we are currently downloading (isCurrentDownloadValid must be true)
|
||||
*/
|
||||
virtual const char * getCurrentDownloadName() const {return 0;}
|
||||
|
||||
/**
|
||||
Returns the state of the current download.
|
||||
Values can be "uiQueued", "uiChecking", "uiConnecting", "uiDownloadingMetadata"
|
||||
, "uiDownload", "uiFinished", "uiSeeding", "uiAllocating".
|
||||
*/
|
||||
virtual const char* getCurrentDownloadStateLabel() const {return 0;}
|
||||
|
||||
/** Returns the progress percent of the current action (between 0 and 100)
|
||||
*/
|
||||
virtual unsigned __int64 getCurrentDownloadProgress() const{return 0;}
|
||||
|
||||
/** Returns the Download Rate of the current download (octet by second)
|
||||
File must be valid.
|
||||
*/
|
||||
virtual float getCurrentDownloadDownloadRate() const {return 0;}
|
||||
|
||||
/** Returns the quantity of data that is already downloaded
|
||||
*/
|
||||
virtual unsigned __int64 getCurrentDownloadTotalDone() const {return 0;}
|
||||
|
||||
/** Returns the quantity of data that is needed
|
||||
*/
|
||||
virtual unsigned __int64 getCurrentDownloadTotalWanted() const {return 0;}
|
||||
|
||||
/** Must be called at each tick (for udating gui)
|
||||
*/
|
||||
virtual void update() {}
|
||||
|
||||
/** Set the listener that is callback by this module to display the download progression
|
||||
*/
|
||||
virtual void setListener(ITorrentListener* listener) {}
|
||||
|
||||
/** obsolete
|
||||
*/
|
||||
virtual void updateEntriesSize(const char* torrentFilename, ITorrentStringContainer* allowedFiles){}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
After Width: | Height: | Size: 482 KiB |
@ -0,0 +1,79 @@
|
||||
// InstallSuccessDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdpch.h"
|
||||
#include "client_background_downloader.h"
|
||||
#include "install_success_dlg.h"
|
||||
#include "nel/misc/win32_util.h"
|
||||
#include "install_logic/game_downloader.h"
|
||||
#include "nel/misc/i18n.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CInstallSuccessDlg dialog
|
||||
|
||||
|
||||
CInstallSuccessDlg::CInstallSuccessDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CInstallSuccessDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CInstallSuccessDlg)
|
||||
m_StartRyzomNow = TRUE;
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CInstallSuccessDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CInstallSuccessDlg)
|
||||
DDX_Control(pDX, IDC_CONGRATS, m_CongratText);
|
||||
DDX_Check(pDX, IDC_START_RYZOM_NOW, m_StartRyzomNow);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CInstallSuccessDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CInstallSuccessDlg)
|
||||
ON_WM_CLOSE()
|
||||
ON_BN_CLICKED(IDC_START_RYZOM_NOW, OnStartRyzomNow)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CInstallSuccessDlg message handlers
|
||||
|
||||
BOOL CInstallSuccessDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
SetIcon(AfxGetApp()->LoadIcon(IDI_MAIN_ICON), TRUE);
|
||||
NLMISC::CWin32Util::localizeWindow(this->m_hWnd);
|
||||
((CButton *) GetDlgItem(IDC_START_RYZOM_NOW))->SetCheck(IGameDownloader::getInstance()->getStartRyzomAtEnd());
|
||||
// Set the title on the content of the window to its initial value
|
||||
m_CongratText.setFont(14, "Verdana", CFE_BOLD);
|
||||
m_CongratText.append(NLMISC::CI18N::get("uiBGD_TitleInstallSuccess"));
|
||||
m_CongratText.append(ucstring(std::string("\n\n")));
|
||||
m_CongratText.setFont(12, "Verdana", 0);
|
||||
m_CongratText.append(NLMISC::CI18N::get("uiBGD_ContentInstallSuccess"));
|
||||
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CInstallSuccessDlg::OnClose()
|
||||
{
|
||||
// when clicking on the cancel button or the close window button whe close the window
|
||||
IGameDownloader::getInstance()->doAction("download_cancel");
|
||||
if (IGameDownloader::getInstance()->getState() == IGameDownloader::InstallFinished)
|
||||
{
|
||||
CDialog::OnClose();
|
||||
}
|
||||
}
|
||||
|
||||
void CInstallSuccessDlg::OnStartRyzomNow()
|
||||
{
|
||||
// update the "Start Ryzom At End Of Install" state with the check button
|
||||
bool state = ((CButton *) GetDlgItem(IDC_START_RYZOM_NOW))->GetCheck();
|
||||
IGameDownloader::getInstance()->doAction("launch_start_at_end", state);
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
#if !defined(AFX_INSTALLSUCCESSDLG_H__99D7912B_475B_45E1_889F_87FFAF541DAA__INCLUDED_)
|
||||
#define AFX_INSTALLSUCCESSDLG_H__99D7912B_475B_45E1_889F_87FFAF541DAA__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// InstallSuccessDlg.h : header file
|
||||
//
|
||||
|
||||
|
||||
#include "rich_edit_ctrl_ex.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CInstallSuccessDlg dialog
|
||||
|
||||
class CInstallSuccessDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CInstallSuccessDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CInstallSuccessDlg)
|
||||
enum { IDD = IDD_INSTALL_SUCCESS };
|
||||
CRichEditCtrlEx m_CongratText;
|
||||
BOOL m_StartRyzomNow;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CInstallSuccessDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CInstallSuccessDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnClose();
|
||||
afx_msg void OnStartRyzomNow();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_INSTALLSUCCESSDLG_H__99D7912B_475B_45E1_889F_87FFAF541DAA__INCLUDED_)
|
@ -0,0 +1,580 @@
|
||||
// install_task_dlg.cpp : implementation file
|
||||
//
|
||||
#include "stdpch.h"
|
||||
#include "install_task_dlg.h"
|
||||
#include "client_background_downloader.h"
|
||||
#include "nel/misc/win32_util.h"
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/file.h"
|
||||
#include "game_share/bg_downloader_msg.h"
|
||||
#include "error_box_dlg.h"
|
||||
#include "blended_bitmap.h"
|
||||
//
|
||||
#include "web_page_embedder.h"
|
||||
|
||||
#include "install_logic/game_downloader.h"
|
||||
|
||||
|
||||
using NLMISC::CI18N;
|
||||
using NLMISC::CPath;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CInstallTaskDlg dialog
|
||||
|
||||
CInstallTaskDlg::CInstallTaskDlg(CWnd *pParent)
|
||||
: CDialog(CInstallTaskDlg::IDD, pParent)
|
||||
{
|
||||
_MustUpdateGui = true;
|
||||
_MustExit = false;
|
||||
_BrowserEventSink.Parent = this;
|
||||
}
|
||||
|
||||
|
||||
CInstallTaskDlg::CInstallTaskDlg(CPatchManager::SPatchInfo &infoOnPatch, CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CInstallTaskDlg::IDD, pParent)
|
||||
{
|
||||
_TaskType = TaskType_Unknwown;
|
||||
_BrowserEventSink.Parent = this;
|
||||
_Task = TaskCheck;
|
||||
_InfoOnPatch = &infoOnPatch;
|
||||
//{{AFX_DATA_INIT(CInstallTaskDlg)
|
||||
//}}AFX_DATA_INIT
|
||||
_TotalPatchSize = 0;
|
||||
_AnimStep = 0;
|
||||
//_Task = TestWebPage;
|
||||
}
|
||||
|
||||
CInstallTaskDlg::CInstallTaskDlg(const std::vector<std::string> &categories, uint totalPatchSize, CWnd *pParent /*=NULL*/)
|
||||
: CDialog(CInstallTaskDlg::IDD, pParent)
|
||||
{
|
||||
_TaskType = TaskType_Unknwown;
|
||||
_BrowserEventSink.Parent = this;
|
||||
_Task = TaskPatch;
|
||||
_InfoOnPatch = NULL;
|
||||
_TotalPatchSize = totalPatchSize;
|
||||
_Categories = categories;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CInstallTaskDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CInstallTaskDlg)
|
||||
DDX_Control(pDX, IDC_PROGRESS_BITMAP, m_ProgressBM);
|
||||
DDX_Control(pDX, IDC_TASK_TYPE, m_TaskTypeText);
|
||||
DDX_Control(pDX, IDC_STATUS_TEXT, m_StatusText);
|
||||
DDX_Control(pDX, IDC_REMAINING_TIME, m_RemainingTimeText);
|
||||
DDX_Control(pDX, IDC_PROGRESS, m_ProgressCtrl);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CInstallTaskDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CInstallTaskDlg)
|
||||
ON_WM_TIMER()
|
||||
ON_BN_CLICKED(IDEXIT, OnExit)
|
||||
ON_WM_SHOWWINDOW()
|
||||
ON_WM_CLOSE()
|
||||
ON_WM_PAINT()
|
||||
ON_WM_ERASEBKGND()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CInstallTaskDlg message handlers
|
||||
|
||||
BOOL CInstallTaskDlg::OnInitDialog()
|
||||
{
|
||||
|
||||
SetTimer(TIMER_MAIN_LOOP, 30, NULL);
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
|
||||
m_ProgressBM.setBitmap(IDB_PROGRESS_ANIM);
|
||||
m_ProgressBM.setBgColor(RGB(255, 255, 255));
|
||||
updateProgressIcon();
|
||||
|
||||
|
||||
::CBitmap progressBG;
|
||||
::CBitmap progressFG;
|
||||
progressBG.LoadBitmap(MAKEINTRESOURCE(IDB_PROGRESS_BG));
|
||||
progressFG.LoadBitmap(MAKEINTRESOURCE(IDB_PROGRESS_FG));
|
||||
m_ProgressCtrl.init(progressBG, progressFG);
|
||||
|
||||
m_StatusText.SetBkColor(RGB(255, 255, 255));
|
||||
m_RemainingTimeText.SetBkColor(RGB(255, 255, 255));
|
||||
|
||||
m_TaskTypeText.SetBackgroundColor(FALSE, RGB(255, 255, 255));
|
||||
|
||||
|
||||
GetDlgItem(IDC_WEB_PAGE)->ShowWindow(SW_HIDE);
|
||||
updateWebPageRegion();
|
||||
GetDlgItem(IDC_BG_BITMAP)->SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
|
||||
GetDlgItem(IDC_WEB_PAGE)->SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SetIcon(AfxGetApp()->LoadIcon(IDI_MAIN_ICON), TRUE);
|
||||
NLMISC::CWin32Util::localizeWindow(this->m_hWnd);
|
||||
CPatchManager *pPM = CPatchManager::getInstance();
|
||||
m_ProgressCtrl.SetRange(0, 1000);
|
||||
m_ProgressCtrl.SetPos(0);
|
||||
GetDlgItem(IDC_STATUS_TEXT)->SetWindowText("");
|
||||
|
||||
//GetDlgItem(IDC_WEB_PAGE)->ShowWindow(SW_HIDE);
|
||||
|
||||
// Get start URL
|
||||
NLMISC::CConfigFile::CVar *installWebPageVarPtr = theApp.ConfigFile.getVarPtr("InstallWebPage");
|
||||
if (installWebPageVarPtr)
|
||||
{
|
||||
StartURL = installWebPageVarPtr->asString();
|
||||
// add the language
|
||||
std::string languageCode = theApp.getLanguage();
|
||||
if (NLMISC::nlstricmp(languageCode, "wk") == 0)
|
||||
{
|
||||
languageCode = "en";
|
||||
}
|
||||
|
||||
StartURL += "client_install_" + languageCode + ".htm";
|
||||
}
|
||||
|
||||
IGameDownloader* gd = IGameDownloader::getInstance();
|
||||
gd->setInstallTaskDlg(this);
|
||||
|
||||
|
||||
// Deactivate nico code because Game download is different from classic patch because game_download can use Ryzom Patch or Torrent protocol
|
||||
#if 0
|
||||
switch(_Task)
|
||||
{
|
||||
case TaskCheck:
|
||||
pPM->startCheckThread(true);
|
||||
break;
|
||||
case TaskPatch:
|
||||
{
|
||||
beginBrowse();
|
||||
pPM->startPatchThread(_Categories, true);
|
||||
}
|
||||
break;
|
||||
case TestWebPage:
|
||||
{
|
||||
beginBrowse();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
nlassert(0);
|
||||
break;
|
||||
}
|
||||
updateTaskTypeText();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CInstallTaskDlg::updateWebPageRegion()
|
||||
{
|
||||
std::vector<HWND> childWindows;
|
||||
NLMISC::CWin32Util::appendChildWindows(this->m_hWnd, childWindows);
|
||||
CWnd *placeHolder = GetDlgItem(IDC_BG_BITMAP);
|
||||
CWnd *webPage = GetDlgItem(IDC_WEB_PAGE);
|
||||
CRect webPageRect;
|
||||
webPage->GetClientRect(&webPageRect);
|
||||
CRgn rgn;
|
||||
// trick here : hide right black border
|
||||
rgn.CreateRectRgn(webPageRect.left, webPageRect.top, webPageRect.right - 1, webPageRect.bottom);
|
||||
//nlwarning("%d, %d, %d, %d", webPageRect.top, webPageRect.right, webPageRect.bottom);
|
||||
for(uint k = 0; k < childWindows.size(); ++k)
|
||||
{
|
||||
if (webPage->m_hWnd == childWindows[k]) continue;
|
||||
if (placeHolder->m_hWnd == childWindows[k]) continue;
|
||||
CRect childRect;
|
||||
::GetWindowRect(childWindows[k], &childRect);
|
||||
webPage->ScreenToClient(childRect);
|
||||
if (childRect == webPageRect) continue;
|
||||
CRgn childRgn;
|
||||
int result = ::GetWindowRgn(childWindows[k], childRgn);
|
||||
if (result != ERROR)
|
||||
{
|
||||
childRgn.OffsetRgn(childRect.left, childRect.top);
|
||||
rgn.CombineRgn(&rgn, &childRgn, RGN_DIFF );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (childWindows[k] == m_ProgressCtrl.m_hWnd)
|
||||
{
|
||||
childRgn.CreateRectRgn(childRect.left + 1, childRect.top + 1, childRect.right - 1, childRect.bottom - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
childRgn.CreateRectRgn(childRect.left, childRect.top, childRect.right, childRect.bottom);
|
||||
}
|
||||
rgn.CombineRgn(&rgn, &childRgn, RGN_DIFF);
|
||||
}
|
||||
}
|
||||
webPage->SetWindowRgn((HRGN) rgn.Detach(), TRUE);
|
||||
|
||||
}
|
||||
|
||||
void CInstallTaskDlg::beginBrowse()
|
||||
{
|
||||
// Do not use Cfg Variable. Use the one given by GameDownloader that is configured on server.
|
||||
IGameDownloader* gd = IGameDownloader::getInstance();
|
||||
StartURL = gd->getInstallHttpBackground();
|
||||
|
||||
if (!StartURL.empty())
|
||||
{
|
||||
CWebPageEmbedder::setBrowserEventSink(GetDlgItem(IDC_WEB_PAGE)->m_hWnd, &_BrowserEventSink);
|
||||
CWebPageEmbedder::displayHTMLPage(GetDlgItem(IDC_WEB_PAGE)->m_hWnd, StartURL.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CInstallTaskDlg::handleTaskEnd(bool ok)
|
||||
{
|
||||
if (!ok)
|
||||
{
|
||||
CPatchManager *pPM = CPatchManager::getInstance();
|
||||
ucstring restart;
|
||||
CErrorBoxDlg msgBox(pPM->getLastErrorMessage(), restart, this);
|
||||
msgBox.DoModal();
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CInstallTaskDlg::updateProgressIcon()
|
||||
{
|
||||
RECT progressAnimRect;
|
||||
m_ProgressBM.getBitmapRect(progressAnimRect);
|
||||
if (progressAnimRect.right)
|
||||
{
|
||||
uint animCount = progressAnimRect.bottom / progressAnimRect.right;
|
||||
//uint animCount = 16;
|
||||
RECT srcRect;
|
||||
srcRect.left = 0;
|
||||
srcRect.right = progressAnimRect.right;
|
||||
srcRect.top = srcRect.right * (_AnimStep / 3);
|
||||
srcRect.bottom = srcRect.right * ((_AnimStep / 3) + 1);
|
||||
m_ProgressBM.setSrcRect(srcRect);
|
||||
++ _AnimStep;
|
||||
if (_AnimStep >= 3 * animCount) _AnimStep = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CInstallTaskDlg::OnTimer(UINT nIDEvent)
|
||||
|
||||
{
|
||||
static const char *markerFileName = "install_final_marker";
|
||||
if (nIDEvent == TIMER_MAIN_LOOP)
|
||||
{
|
||||
IGameDownloader* gd = IGameDownloader::getInstance();
|
||||
// update the progress icon animation
|
||||
if (gd->getUpdateDownloadIcon())
|
||||
{
|
||||
updateProgressIcon();
|
||||
}
|
||||
|
||||
// limit multi entry (a atomic swap would be best)
|
||||
static volatile bool ok = true;
|
||||
if (ok)
|
||||
{
|
||||
ok = false;
|
||||
// Exit if cancel or quit button was pressed
|
||||
if (_MustExit)
|
||||
{
|
||||
// display Warning message
|
||||
|
||||
gd->doAction("download_cancel", true);
|
||||
_MustExit = false;
|
||||
}
|
||||
|
||||
IGameDownloader* gd = IGameDownloader::getInstance();
|
||||
gd->update();
|
||||
// clossing process take 5 second so hide before closing
|
||||
if ( gd->getState() == IGameDownloader::InstallFinished && IsWindowVisible())
|
||||
{
|
||||
CWnd* win = AfxGetMainWnd();
|
||||
if (win) { win->ShowWindow(SW_HIDE); }
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
// If GameDownloader State has changed then look state on update components
|
||||
if (_MustUpdateGui)
|
||||
{
|
||||
// start browser (the browser is started before displaying the page content in ordre to no display and empty pages)
|
||||
static bool browserWasStarted = false;
|
||||
if (!browserWasStarted && gd->getMustStartBrowser() )
|
||||
{
|
||||
browserWasStarted = true;
|
||||
beginBrowse();
|
||||
}
|
||||
// must be updated if browser is active
|
||||
if (gd->getBrowserActive())
|
||||
{
|
||||
updateWebPage();
|
||||
}
|
||||
// update label
|
||||
ucstring str;
|
||||
str = gd->getContentLabelText();
|
||||
SetWindowTextW(GetDlgItem(IDC_STATUS_TEXT)->m_hWnd, (const WCHAR *) str.c_str());
|
||||
// update progress bar
|
||||
sint32 value = gd->getProgressBarValue();
|
||||
if (-1 < value && value <= 100)
|
||||
{
|
||||
m_ProgressCtrl.SetPos(10*value);
|
||||
}
|
||||
// update Title and text content
|
||||
updateTaskTypeText();
|
||||
if (gd->getBrowserActive())
|
||||
{
|
||||
updateWebPageRegion();
|
||||
}
|
||||
|
||||
_MustUpdateGui = false;
|
||||
}
|
||||
|
||||
ok = true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
{
|
||||
updateProgressIcon();
|
||||
updateTaskTypeText();
|
||||
CPatchManager *pPM = CPatchManager::getInstance();
|
||||
// update text & progress bar
|
||||
switch(_Task)
|
||||
{
|
||||
case TaskCheck:
|
||||
{
|
||||
bool ok;
|
||||
if (pPM->isCheckThreadEnded(ok))
|
||||
{
|
||||
KillTimer(TIMER_MAIN_LOOP);
|
||||
handleTaskEnd(ok);
|
||||
EndDialog(IDOK);
|
||||
}
|
||||
pPM->getInfoToDisp(*_InfoOnPatch);
|
||||
}
|
||||
break;
|
||||
case TaskPatch:
|
||||
{
|
||||
updateWebPage();
|
||||
bool ok;
|
||||
if (pPM->isPatchThreadEnded(ok))
|
||||
{
|
||||
handleTaskEnd(ok);
|
||||
if (pPM->mustLaunchBatFile())
|
||||
{
|
||||
try
|
||||
{
|
||||
NLMISC::COFile marker(markerFileName);
|
||||
pPM->createBatchFile(pPM->getDescFile(), false);
|
||||
pPM->executeBatchFile();
|
||||
_Task = WaitPatchTaskEnd;
|
||||
SetWindowTextW(GetDlgItem(IDC_STATUS_TEXT)->m_hWnd, (const WCHAR *) CI18N::get("uiBGD_FinalMove").c_str());
|
||||
m_ProgressCtrl.SetPos(1000);
|
||||
return;
|
||||
}
|
||||
catch(NLMISC::EDiskFullError &)
|
||||
{
|
||||
errorMsg(CI18N::get("uiPatchDiskFull"));
|
||||
}
|
||||
catch(NLMISC::EWriteError &)
|
||||
{
|
||||
errorMsg(CI18N::get("uiPatchWriteError"));
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
errorMsg(CI18N::get("uiBGD_InstallFailed") + ucstring(e.what()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
KillTimer(TIMER_MAIN_LOOP);
|
||||
EndDialog(IDOK);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WaitPatchTaskEnd:
|
||||
// wait until the batch file finish its execution
|
||||
if (!NLMISC::CPath::exists(markerFileName))
|
||||
{
|
||||
EndDialog(IDOK);
|
||||
}
|
||||
return;
|
||||
break;
|
||||
case TestWebPage:
|
||||
{
|
||||
updateWebPage();
|
||||
static uint counter = 0;
|
||||
GetDlgItem(IDC_STATUS_TEXT)->SetWindowText(NLMISC::toString("%d", counter ++).c_str());
|
||||
updateWebPageRegion();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
nlassert(0);
|
||||
break;
|
||||
}
|
||||
if (_Task != TestWebPage)
|
||||
{
|
||||
ucstring state = "???";
|
||||
std::vector<ucstring> log;
|
||||
if (pPM->getThreadState(state, log))
|
||||
{
|
||||
int currentFilesToGet = pPM->getCurrentFilesToGet();
|
||||
int totalFilesToGet = pPM->getTotalFilesToGet();
|
||||
setStatusString(state,
|
||||
currentFilesToGet,
|
||||
totalFilesToGet,
|
||||
pPM->getPatchingSize(),
|
||||
(uint32) _TotalPatchSize,
|
||||
pPM->getCurrentFileProgress()
|
||||
);
|
||||
|
||||
float progressValue = (currentFilesToGet + pPM->getCurrentFileProgress()) / totalFilesToGet;
|
||||
m_ProgressCtrl.SetPos((int) (1000 * progressValue));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
CDialog::OnTimer(nIDEvent);
|
||||
}
|
||||
|
||||
//**************************************************************************************************
|
||||
void CInstallTaskDlg::errorMsg(const ucstring &error)
|
||||
{
|
||||
m_ProgressBM.setBitmap(IDB_PROGRESS_FAIL);
|
||||
KillTimer(TIMER_MAIN_LOOP);
|
||||
/*
|
||||
CErrorBoxDlg msgBox(error, this);
|
||||
msgBox.DoModal();
|
||||
*/
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************************************
|
||||
void CInstallTaskDlg::updateWebPage()
|
||||
{
|
||||
if (!CWebPageEmbedder::isBusy(GetDlgItem(IDC_WEB_PAGE)->m_hWnd))
|
||||
{
|
||||
GetDlgItem(IDC_BG_BITMAP)->ShowWindow(SW_HIDE);
|
||||
GetDlgItem(IDC_WEB_PAGE)->ShowWindow(SW_SHOW);
|
||||
}
|
||||
}
|
||||
|
||||
//**************************************************************************************************
|
||||
void CInstallTaskDlg::setStatusString(const ucstring &str,
|
||||
uint32 currentFilesToGet,
|
||||
uint32 totalFilesToGet,
|
||||
uint32 patchingSize,
|
||||
uint32 totalSize,
|
||||
float currentFileProgress
|
||||
)
|
||||
{
|
||||
ucstring statusString = str + NLMISC::toString(" (%d / %d)", (int) currentFilesToGet, (int) totalFilesToGet);
|
||||
if (totalSize != 0)
|
||||
{
|
||||
statusString += " (" + BGDownloader::getWrittenSize(patchingSize) + " / " + BGDownloader::getWrittenSize(totalSize) + ")";
|
||||
}
|
||||
SetWindowTextW(GetDlgItem(IDC_STATUS_TEXT)->m_hWnd, (const WCHAR *) statusString.c_str());
|
||||
m_StatusText.SetBkColor(RGB(255, 255, 255));
|
||||
}
|
||||
// Windows exit
|
||||
void CInstallTaskDlg::OnExit()
|
||||
{
|
||||
_MustExit = true;
|
||||
|
||||
//PostQuitMessage(0);
|
||||
}
|
||||
|
||||
void CInstallTaskDlg::OnShowWindow(BOOL bShow, UINT nStatus)
|
||||
{
|
||||
CDialog::OnShowWindow(bShow, nStatus);
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************************************
|
||||
void CInstallTaskDlg::CBrowserEventSink::onInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pDispParams, VARIANT FAR *pVarResult, EXCEPINFO FAR *pExcepInfo, UINT FAR *puArgErr)
|
||||
{
|
||||
switch (dispIdMember)
|
||||
{
|
||||
case DISPID_BEFORENAVIGATE2:
|
||||
std::string url(ucstring((uint16 *) pDispParams[4].rgvarg->pcVal).toString());
|
||||
if (url != Parent->StartURL)
|
||||
{
|
||||
// any link will open a new window
|
||||
*pDispParams[0].rgvarg->pboolVal = TRUE; // cancel current navigation
|
||||
NLMISC::openURL(url.c_str()); // ... & launch a new browser for that url
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CInstallTaskDlg::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
|
||||
// TODO: Add your message handler code here
|
||||
|
||||
// Do not call CDialog::OnPaint() for painting messages
|
||||
}
|
||||
//MFC Button
|
||||
void CInstallTaskDlg::OnClose()
|
||||
{
|
||||
// TODO: Add your message handler code here and/or call default
|
||||
_MustExit = true;
|
||||
//CDialog::OnClose();
|
||||
}
|
||||
|
||||
//**************************************************************************************************
|
||||
void CInstallTaskDlg::updateTaskTypeText()
|
||||
{
|
||||
// Use GameDownloader state to display Progression Label ( 1/Install => 2/ Download)
|
||||
static IGameDownloader::EState previousState = IGameDownloader::Init;
|
||||
IGameDownloader* gd = IGameDownloader::getInstance();
|
||||
IGameDownloader::EState currentState = gd->getState();
|
||||
//UpdatePackage <=>
|
||||
if (currentState != previousState && (currentState == IGameDownloader::Downloading || currentState == IGameDownloader::Installing))
|
||||
{
|
||||
m_TaskTypeText.clear();
|
||||
if (currentState == IGameDownloader::Downloading)
|
||||
{
|
||||
m_TaskTypeText.setFont(10, "Verdana", CFE_BOLD);
|
||||
m_TaskTypeText.append(NLMISC::CI18N::get("uiBGD_TaskTypeDownload"));
|
||||
m_TaskTypeText.setFont(10, "Verdana", 0);
|
||||
m_TaskTypeText.append(ucstring("\n"));
|
||||
m_TaskTypeText.append(NLMISC::CI18N::get("uiBGD_TaskTypeInstall"));
|
||||
} else if (currentState == IGameDownloader::Installing)
|
||||
{
|
||||
m_TaskTypeText.setFont(10, "Verdana", 0);
|
||||
m_TaskTypeText.append(NLMISC::CI18N::get("uiBGD_TaskTypeDownload"));
|
||||
m_TaskTypeText.setFont(10, "Verdana", CFE_BOLD);
|
||||
m_TaskTypeText.append(ucstring("\n"));
|
||||
m_TaskTypeText.append(NLMISC::CI18N::get("uiBGD_TaskTypeInstall"));
|
||||
}
|
||||
// ?UpdatePackage
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL CInstallTaskDlg::OnEraseBkgnd(CDC* pDC)
|
||||
{
|
||||
return CDialog::OnEraseBkgnd(pDC);
|
||||
//return TRUE;
|
||||
}
|
||||
|
@ -0,0 +1,138 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#if !defined(AFX_INSTALL_TASK_DLG_H__34C5E208_AE87_4709_8508_E1F7FB694802__INCLUDED_)
|
||||
#define AFX_INSTALL_TASK_DLG_H__34C5E208_AE87_4709_8508_E1F7FB694802__INCLUDED_
|
||||
|
||||
|
||||
#include "resource.h"
|
||||
#include "../client/login_patch.h"
|
||||
#include "SimpleBrowser.h"
|
||||
#include "web_page_embedder.h"
|
||||
//#include "transparent_text.h"
|
||||
#include "color_static.h"
|
||||
#include "textured_progress_ctrl.h"
|
||||
#include "rich_edit_ctrl_ex.h"
|
||||
#include "blended_bitmap.h"
|
||||
|
||||
class CInstallTaskDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
// check task
|
||||
CInstallTaskDlg(CPatchManager::SPatchInfo &infoOnPatch, CWnd *pParent = NULL); // standard constructor
|
||||
// patch task
|
||||
CInstallTaskDlg(const std::vector<std::string> &categories, uint totalPatchSize, CWnd *pParent = NULL); // standard constructor
|
||||
CInstallTaskDlg(CWnd *pParent = NULL);
|
||||
// Ask the Form to update itself at the new update
|
||||
void askGuiUpdate(){_MustUpdateGui = true;}
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CInstallTaskDlg)
|
||||
enum { IDD = IDD_INSTALL_TASK };
|
||||
CBlendedBitmap m_ProgressBM;
|
||||
CRichEditCtrlEx m_TaskTypeText;
|
||||
CColorStatic m_StatusText;
|
||||
CColorStatic m_RemainingTimeText;
|
||||
CTexturedProgressCtrl m_ProgressCtrl;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CInstallTaskDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
|
||||
protected:
|
||||
|
||||
enum TTaskType
|
||||
{
|
||||
TaskType_Unknwown = 0,
|
||||
TaskType_Download,
|
||||
TaskType_Install
|
||||
};
|
||||
|
||||
enum TTask
|
||||
{
|
||||
TaskCheck = 0,
|
||||
TaskPatch,
|
||||
WaitPatchTaskEnd,
|
||||
TestWebPage = 666 // TMP TMP
|
||||
};
|
||||
std::vector<std::string> _Categories; // categories to patch
|
||||
CPatchManager::SPatchInfo *_InfoOnPatch;
|
||||
TTask _Task;
|
||||
TTaskType _TaskType;
|
||||
uint _TotalPatchSize;
|
||||
uint _AnimStep;
|
||||
//SimpleBrowser _Browser;
|
||||
enum { TIMER_MAIN_LOOP = 0 };
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CInstallTaskDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnTimer(UINT nIDEvent);
|
||||
afx_msg void OnExit();
|
||||
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
|
||||
afx_msg void OnClose();
|
||||
afx_msg void OnPaint();
|
||||
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
void setStatusString(const ucstring &str,
|
||||
uint32 currentFilesToGet,
|
||||
uint32 totalFilesToGet,
|
||||
uint32 patchingSize,
|
||||
uint32 totalSize,
|
||||
float currentFileProgress
|
||||
);
|
||||
|
||||
void handleTaskEnd(bool ok);
|
||||
|
||||
private:
|
||||
bool _MustUpdateGui; //Must update Lable at next update
|
||||
bool _MustExit; //Must exit at next update
|
||||
void beginBrowse();
|
||||
void updateWebPageRegion();
|
||||
void updateWebPage();
|
||||
void updateTaskTypeText();
|
||||
void updateProgressIcon();
|
||||
|
||||
|
||||
void errorMsg(const ucstring &error);
|
||||
|
||||
struct CBrowserEventSink : public CWebPageEmbedder::CBrowserEventSink
|
||||
{
|
||||
CInstallTaskDlg *Parent;
|
||||
virtual void onInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pDispParams, VARIANT FAR *pVarResult, EXCEPINFO FAR *pExcepInfo, UINT FAR *puArgErr);
|
||||
};
|
||||
|
||||
CBrowserEventSink _BrowserEventSink;
|
||||
friend struct CBrowserEventSink;
|
||||
std::string StartURL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_INSTALL_TASK_DLG_H__34C5E208_AE87_4709_8508_E1F7FB694802__INCLUDED_)
|
After Width: | Height: | Size: 482 KiB |
@ -0,0 +1,99 @@
|
||||
// intro_screen_dlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdpch.h"
|
||||
#include "client_background_downloader.h"
|
||||
#include "intro_screen_dlg.h"
|
||||
#include "nel/misc/win32_util.h"
|
||||
#include "install_logic/game_downloader.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CIntroScreenDlg dialog
|
||||
|
||||
|
||||
CIntroScreenDlg::CIntroScreenDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CIntroScreenDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CIntroScreenDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CIntroScreenDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CIntroScreenDlg)
|
||||
DDX_Control(pDX, IDC_INTRO_TEXT, m_IntroText);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CIntroScreenDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CIntroScreenDlg)
|
||||
ON_BN_CLICKED(IDC_NEWINSTALL, OnNewinstall)
|
||||
ON_BN_CLICKED(ID_CANCEL, OnCancel)
|
||||
ON_BN_CLICKED(IDC_REPAIR, OnRepair)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CIntroScreenDlg message handlers
|
||||
|
||||
BOOL CIntroScreenDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
SetIcon(AfxGetApp()->LoadIcon(IDI_MAIN_ICON), TRUE);
|
||||
NLMISC::CWin32Util::localizeWindow(this->m_hWnd);
|
||||
((CButton *) GetDlgItem(IDC_NEWINSTALL))->SetCheck(1);
|
||||
|
||||
// if first install do not check
|
||||
if (!IGameDownloader::getInstance()->getFirstInstall())
|
||||
{
|
||||
((CButton *) GetDlgItem(IDC_REPAIR))->SetCheck(1);
|
||||
((CButton *) GetDlgItem(IDC_NEWINSTALL))->SetCheck(0);
|
||||
((CButton *) GetDlgItem(IDC_REPAIR))->EnableWindow(TRUE);//enable repair button
|
||||
}
|
||||
|
||||
|
||||
|
||||
CHARFORMAT cf;
|
||||
ZeroMemory(&cf, sizeof(cf));
|
||||
cf.cbSize = sizeof(cf);
|
||||
|
||||
m_IntroText.setFont(14, "Verdana", CFE_BOLD);
|
||||
m_IntroText.append(NLMISC::CI18N::get("uiBGD_RyzomUpdateRepair"));
|
||||
m_IntroText.append(ucstring(std::string("\n\n")));
|
||||
|
||||
m_IntroText.setFont(12, "Verdana", 0);
|
||||
m_IntroText.append(NLMISC::CI18N::get("uiBGD_Welcome"));
|
||||
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CIntroScreenDlg::OnCancel()
|
||||
{
|
||||
// When the Cancel button is clicked we close the window
|
||||
IGameDownloader* gd = IGameDownloader::getInstance();
|
||||
gd->doAction("download_cancel");
|
||||
if (gd->getState() == IGameDownloader::InstallFinished)
|
||||
{
|
||||
EndDialog(IDCANCEL);
|
||||
}
|
||||
}
|
||||
|
||||
void CIntroScreenDlg::OnNewinstall()
|
||||
{
|
||||
// clicked on the Install buton
|
||||
IGameDownloader* gd = IGameDownloader::getInstance();
|
||||
gd->setFirstInstall(true);
|
||||
}
|
||||
|
||||
void CIntroScreenDlg::OnRepair()
|
||||
{
|
||||
//clicked on the Repair button
|
||||
IGameDownloader* gd = IGameDownloader::getInstance();
|
||||
gd->setFirstInstall(true);
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
#if !defined(AFX_INTRO_SCREEN_DLG_H__B8233ADB_85E0_4CF7_B6FA_678A609E6A00__INCLUDED_)
|
||||
#define AFX_INTRO_SCREEN_DLG_H__B8233ADB_85E0_4CF7_B6FA_678A609E6A00__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// intro_screen_dlg.h : header file
|
||||
//
|
||||
|
||||
|
||||
#include "rich_edit_ctrl_ex.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CIntroScreenDlg dialog
|
||||
|
||||
class CIntroScreenDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CIntroScreenDlg(CWnd* pParent = NULL); // standard constructor
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CIntroScreenDlg)
|
||||
enum { IDD = IDD_INSTALL_STEP };
|
||||
CRichEditCtrlEx m_IntroText;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CIntroScreenDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CIntroScreenDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnCancel();
|
||||
afx_msg void OnNewinstall();
|
||||
afx_msg void OnRepair();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_INTRO_SCREEN_DLG_H__B8233ADB_85E0_4CF7_B6FA_678A609E6A00__INCLUDED_)
|
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* $Id:
|
||||
*/
|
||||
|
||||
#include "stdpch.h"
|
||||
|
||||
uint32 LoginShardId = 0xFFFFFFFF;
|
||||
std::string LoginLogin, LoginPassword;
|
||||
std::string R2ServerVersion;
|
||||
std::string VersionName;
|
||||
|
||||
|
||||
|
||||
void quitCrashReport ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,197 @@
|
||||
/** \file login_xdelta.h
|
||||
*
|
||||
* Read and Apply a xdelta patch to a file
|
||||
* Some of the code is inspired by the code of xdelta
|
||||
*
|
||||
* $Id: login_xdelta.h,v 1.2 2007/05/09 15:33:05 boucher Exp $
|
||||
*/
|
||||
|
||||
/* Copyright, 2004 Nevrax Ltd.
|
||||
*
|
||||
* This file is part of NEVRAX NEL.
|
||||
* NEVRAX NEL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
|
||||
* NEVRAX NEL 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
|
||||
* General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with NEVRAX NEL; see the file COPYING. If not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
* MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef CL_LOGIN_XDELTA_H
|
||||
#define CL_LOGIN_XDELTA_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/md5.h"
|
||||
#include <string>
|
||||
#include <zlib.h>
|
||||
|
||||
#define XDELTA_PREFIX_LEN 8
|
||||
#define XDELTA_HEADER_WORDS 6
|
||||
#define XDELTA_HEADER_SPACE (XDELTA_HEADER_WORDS*4)
|
||||
#define XDELTA_110_PREFIX "%XDZ004%"
|
||||
#define XDELTA_FLAG_NO_VERIFY 1
|
||||
#define XDELTA_FLAG_FROM_COMPRESSED 2
|
||||
#define XDELTA_FLAG_TO_COMPRESSED 4
|
||||
#define XDELTA_FLAG_PATCH_COMPRESSED 8
|
||||
|
||||
#define XDELTA_TYPE_CHECKSUM ((1<<(1+8))+3)
|
||||
#define XDELTA_TYPE_INDEX ((1<<(2+8))+3)
|
||||
#define XDELTA_TYPE_SOURCEINFO ((1<<(3+8))+3)
|
||||
#define XDELTA_TYPE_CONTROL ((1<<(7+8))+3)
|
||||
#define XDELTA_TYPE_INSTRUCTION ((1<<(8+8))+3)
|
||||
|
||||
class CXDPFileReader;
|
||||
|
||||
/**
|
||||
* Class representing the xdelta control
|
||||
* it can be 2 sources max : the patch and the file to patch
|
||||
* Applying patch is copying from the source 'Index' at offset 'Offset' an amount of data
|
||||
* of length 'Length'.
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date July 2004
|
||||
*/
|
||||
struct SXDeltaCtrl
|
||||
{
|
||||
struct SSourceInfo
|
||||
{
|
||||
std::string Name;
|
||||
NLMISC::CHashKeyMD5 MD5;
|
||||
uint32 Len;
|
||||
bool IsData;
|
||||
bool Sequential;
|
||||
uint32 Position;
|
||||
uint32 Copies;
|
||||
uint32 CopyLength;
|
||||
|
||||
bool read(CXDPFileReader &fr);
|
||||
};
|
||||
|
||||
struct SInstruction
|
||||
{
|
||||
uint32 Index;
|
||||
uint32 Offset;
|
||||
uint32 Length;
|
||||
|
||||
bool read(CXDPFileReader &fr);
|
||||
};
|
||||
|
||||
NLMISC::CHashKeyMD5 ToMD5;
|
||||
uint32 ToLen;
|
||||
bool HasData;
|
||||
std::vector<SSourceInfo> SourceInfo;
|
||||
std::vector<SInstruction> Inst;
|
||||
|
||||
bool read(CXDPFileReader &fr);
|
||||
};
|
||||
|
||||
/**
|
||||
* Class representing a delta patch
|
||||
* We read only the 1.1 version. 'Compressed From' and 'Compressed To' are not supported.
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date July 2004
|
||||
*/
|
||||
class CXDeltaPatch
|
||||
{
|
||||
public:
|
||||
|
||||
enum TApplyResult
|
||||
{
|
||||
ApplyResult_Ok = 0,
|
||||
ApplyResult_DiskFull,
|
||||
ApplyResult_WriteError,
|
||||
ApplyResult_UnsupportedXDeltaFormat,
|
||||
ApplyResult_Error, // misc error
|
||||
};
|
||||
|
||||
// Callback progress for the file patching
|
||||
class ICallBack
|
||||
{
|
||||
public:
|
||||
// f is from 0 to 1 (0% to 100% (complete))
|
||||
virtual void progress(float f)=0;
|
||||
};
|
||||
|
||||
// Tools
|
||||
static TApplyResult apply( const std::string &sPatchFilename, const std::string &sFileToPatchFilename,
|
||||
const std::string &sOutputFilename, std::string &errorMsg, ICallBack *pCallBack = NULL);
|
||||
static bool info(const std::string &sPatchFilename);
|
||||
|
||||
|
||||
// Load a patch file
|
||||
bool load(const std::string &sFilename);
|
||||
|
||||
TApplyResult apply(const std::string &sFileToPatch, const std::string &sFileOutput, std::string &errorMsg);
|
||||
|
||||
bool isNoVerify() { return (_Flags&XDELTA_FLAG_NO_VERIFY)!=0; }
|
||||
bool isFromCompressed() { return (_Flags&XDELTA_FLAG_FROM_COMPRESSED)!=0; }
|
||||
bool isToCompressed() { return (_Flags&XDELTA_FLAG_TO_COMPRESSED)!=0; }
|
||||
bool isPatchCompressed() { return (_Flags&XDELTA_FLAG_PATCH_COMPRESSED)!=0; }
|
||||
|
||||
const std::string &getToName() const { return _ToName; }
|
||||
const std::string &getFromName() const { return _FromName; }
|
||||
const SXDeltaCtrl &getCtrl() const { return _Ctrl; }
|
||||
|
||||
bool checkIntegrity (CXDPFileReader &rFR, const NLMISC::CHashKeyMD5 &md5, uint32 nLength);
|
||||
|
||||
private:
|
||||
std::string _FileName;
|
||||
|
||||
uint32 _Flags;
|
||||
std::string _Version; // Look XDELTA_FLAG_*
|
||||
uint32 _HeaderOffset;
|
||||
uint32 _CtrlOffset;
|
||||
|
||||
std::string _FromName;
|
||||
std::string _ToName;
|
||||
|
||||
SXDeltaCtrl _Ctrl;
|
||||
|
||||
static ICallBack *_CallBack;
|
||||
};
|
||||
|
||||
/**
|
||||
* Class representing a stream
|
||||
* Help us to read from zipped or not file seemlessly
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date July 2004
|
||||
*/
|
||||
class CXDPFileReader
|
||||
{
|
||||
public:
|
||||
CXDPFileReader();
|
||||
~CXDPFileReader();
|
||||
bool init(const std::string &sFilename, sint32 nLowerBound, sint32 nUpperBound, bool bCompressed);
|
||||
bool read(uint8 *pBuf, sint32 nSize);
|
||||
bool readUInt32(uint32 &val);
|
||||
bool readUInt(uint32 &val);
|
||||
bool readBool(bool &val);
|
||||
bool readString(std::string &s);
|
||||
uint32 getFileSize();
|
||||
bool seek(uint32 pos);
|
||||
private:
|
||||
sint32 _LowerBound, _UpperBound;
|
||||
bool _Compressed;
|
||||
FILE *_File;
|
||||
gzFile _GzFile;
|
||||
|
||||
void freeZipMem();
|
||||
bool _Optimize;
|
||||
uint32 _OptimPage;
|
||||
std::vector<uint8*> _ZipMem;
|
||||
sint32 _Pos;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // CL_LOGIN_XDELTA_H
|
After Width: | Height: | Size: 482 KiB |
After Width: | Height: | Size: 216 KiB |
After Width: | Height: | Size: 144 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 9.1 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.3 KiB |
@ -0,0 +1,13 @@
|
||||
//
|
||||
// CLIENT_BACKGROUND_DOWNLOADER.RC2 - resources Microsoft Visual C++ does not edit directly
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#error this file is not editable by Microsoft Visual C++
|
||||
#endif //APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Add manually edited resources here...
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
@ -0,0 +1,82 @@
|
||||
// rich_edit_ctrl_ex.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdpch.h"
|
||||
#include "client_background_downloader.h"
|
||||
#include "rich_edit_ctrl_ex.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CRichEditCtrlEx
|
||||
|
||||
CRichEditCtrlEx::CRichEditCtrlEx()
|
||||
{
|
||||
setFont(12, "Verdana", 0);
|
||||
}
|
||||
|
||||
CRichEditCtrlEx::~CRichEditCtrlEx()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CRichEditCtrlEx, CRichEditCtrl)
|
||||
//{{AFX_MSG_MAP(CRichEditCtrlEx)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
|
||||
static HMODULE Shlwapi = 0;
|
||||
static bool LoadingFailed = false;
|
||||
typedef LRESULT (WINAPI * TSendMessageWrapW) (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
static TSendMessageWrapW SendMessageWrapW = NULL;
|
||||
|
||||
|
||||
void CRichEditCtrlEx::append(const ucstring &str)
|
||||
{
|
||||
if (!Shlwapi && !LoadingFailed)
|
||||
{
|
||||
Shlwapi = LoadLibrary("shlwapi.dll");
|
||||
if (!Shlwapi)
|
||||
{
|
||||
LoadingFailed = true;
|
||||
}
|
||||
SendMessageWrapW = (TSendMessageWrapW) GetProcAddress(Shlwapi, (const char *) 136 /*"SendMessageWrapW"*/);
|
||||
}
|
||||
SendMessage(EM_SETSEL, - 1, 0);
|
||||
SetSelectionCharFormat(_CharFormat);
|
||||
if (SendMessageWrapW)
|
||||
{
|
||||
::SendMessageWrapW(m_hWnd, EM_REPLACESEL, (WPARAM) FALSE, (LPARAM) str.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessage(EM_REPLACESEL, (WPARAM) FALSE, (LPARAM) str.toString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CRichEditCtrlEx::setFont(LONG size, const char *fontName, DWORD effects)
|
||||
{
|
||||
ZeroMemory(&_CharFormat, sizeof(_CharFormat));
|
||||
_CharFormat.cbSize = sizeof(_CharFormat);
|
||||
|
||||
_CharFormat.dwMask = CFM_BOLD|CFM_ITALIC|CFM_STRIKEOUT|CFM_UNDERLINE|CFM_COLOR|CFM_SIZE|CFE_AUTOCOLOR|CFM_FACE;
|
||||
_CharFormat.dwEffects = effects;
|
||||
_CharFormat.yHeight = size * (1440 / 72);
|
||||
_CharFormat.bCharSet = DEFAULT_CHARSET;
|
||||
_CharFormat.bPitchAndFamily = DEFAULT_PITCH;
|
||||
strncpy(_CharFormat.szFaceName, fontName, 32);
|
||||
}
|
||||
|
||||
void CRichEditCtrlEx::clear()
|
||||
{
|
||||
SendMessage(EM_SETSEL, 0, -1);
|
||||
SendMessage(EM_REPLACESEL, (WPARAM) FALSE, (LPARAM) "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CRichEditCtrlEx message handlers
|
@ -0,0 +1,60 @@
|
||||
#if !defined(AFX_RICH_EDIT_CTRL_EX_H__92FAEFC4_7921_42E9_89FC_BA9B1A5710F8__INCLUDED_)
|
||||
#define AFX_RICH_EDIT_CTRL_EX_H__92FAEFC4_7921_42E9_89FC_BA9B1A5710F8__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// rich_edit_ctrl_ex.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CRichEditCtrlEx window
|
||||
|
||||
class CRichEditCtrlEx : public CRichEditCtrl
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CRichEditCtrlEx();
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
|
||||
// set font to be applied to the next 'append' operation
|
||||
void setFont(LONG size, const char *fontName, DWORD effects);
|
||||
// Append a new ucstring to the rich edit ctrl, using the last settings of 'setfont'
|
||||
void append(const ucstring &str);
|
||||
void clear();
|
||||
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CRichEditCtrlEx)
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CRichEditCtrlEx();
|
||||
|
||||
CHARFORMAT _CharFormat;
|
||||
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CRichEditCtrlEx)
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_RICH_EDIT_CTRL_EX_H__92FAEFC4_7921_42E9_89FC_BA9B1A5710F8__INCLUDED_)
|
After Width: | Height: | Size: 9.1 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 452 B |
@ -0,0 +1,9 @@
|
||||
/*
|
||||
* $Id:
|
||||
*/
|
||||
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// client_config.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdpch.h"
|
@ -0,0 +1,55 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#if !defined(AFX_STDAFX_H__DD0A8599_6A9E_47AE_BE5E_50A017C1FA9C__INCLUDED_)
|
||||
#define AFX_STDAFX_H__DD0A8599_6A9E_47AE_BE5E_50A017C1FA9C__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
#include <afxwin.h> // MFC core and standard components
|
||||
#include <afxext.h> // MFC extensions
|
||||
#include <afxdisp.h> // MFC Automation classes
|
||||
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
|
||||
#ifndef _AFX_NO_AFXCMN_SUPPORT
|
||||
#include <afxcmn.h> // MFC support for Windows Common Controls
|
||||
#endif // _AFX_NO_AFXCMN_SUPPORT
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
|
||||
#include "nel/misc/config_file.h"
|
||||
#include "nel/misc/system_info.h"
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/i18n.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__DD0A8599_6A9E_47AE_BE5E_50A017C1FA9C__INCLUDED_)
|
After Width: | Height: | Size: 9.1 KiB |
@ -0,0 +1,76 @@
|
||||
// textured_progress_ctrl.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdpch.h"
|
||||
#include "client_background_downloader.h"
|
||||
#include "textured_progress_ctrl.h"
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CTexturedProgressCtrl
|
||||
|
||||
CTexturedProgressCtrl::CTexturedProgressCtrl() : _Initialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
CTexturedProgressCtrl::~CTexturedProgressCtrl()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CTexturedProgressCtrl::init(CBitmap &bg, CBitmap &fg)
|
||||
{
|
||||
_BG.Attach(bg.Detach());
|
||||
_FG.Attach(fg.Detach());
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CTexturedProgressCtrl, CProgressCtrl)
|
||||
//{{AFX_MSG_MAP(CTexturedProgressCtrl)
|
||||
ON_WM_PAINT()
|
||||
ON_WM_NCPAINT()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CTexturedProgressCtrl message handlers
|
||||
|
||||
void CTexturedProgressCtrl::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
|
||||
CRect r;
|
||||
GetClientRect(r);
|
||||
CDC srcDC;
|
||||
srcDC.CreateCompatibleDC(&dc);
|
||||
|
||||
int rangeLower, rangeUpper;
|
||||
GetRange(rangeLower, rangeUpper);
|
||||
float progress = (float) (GetPos() - rangeLower) / (rangeUpper - rangeLower);
|
||||
int size = (int) ((r.right - r.left) * progress);
|
||||
/* CGdiObject *srcDCOldObj =*/ srcDC.SelectObject(&_FG);
|
||||
dc.BitBlt(r.left, r.top, size, r.bottom - r.top, &srcDC, 0, 0, SRCCOPY);
|
||||
srcDC.SelectObject(&_BG);
|
||||
dc.BitBlt(r.left + size, r.top, (r.right - r.left) - size, r.bottom - r.top, &srcDC, size, 0, SRCCOPY);
|
||||
|
||||
std::string percentStr = NLMISC::toString("%d%%", (int) (100.f * progress));
|
||||
|
||||
|
||||
CSize sz = dc.GetTextExtent(percentStr.c_str(), percentStr.size());
|
||||
dc.SetBkMode(TRANSPARENT);
|
||||
dc.SetTextColor(RGB(0, 0, 0));
|
||||
dc.TextOut(1 + r.left + (r.Width() - sz.cx) / 2, 1 + r.top + (r.Height() - sz.cy) / 2, percentStr.c_str(), percentStr.size());
|
||||
dc.SetTextColor(RGB(255, 255, 255));
|
||||
dc.TextOut(r.left + (r.Width() - sz.cx) / 2, r.top + (r.Height() - sz.cy) / 2, percentStr.c_str(), percentStr.size());
|
||||
|
||||
//srcDC.SelectObject(srcDCOldObj);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CTexturedProgressCtrl::OnNcPaint()
|
||||
{
|
||||
// no-op (remove border)
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
#if !defined(AFX_TEXTURED_PROGRESS_CTRL_H__F8A8A5F1_C0E6_40B1_88FF_1CA46491C338__INCLUDED_)
|
||||
#define AFX_TEXTURED_PROGRESS_CTRL_H__F8A8A5F1_C0E6_40B1_88FF_1CA46491C338__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// textured_progress_ctrl.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CTexturedProgressCtrl window
|
||||
|
||||
class CTexturedProgressCtrl : public CProgressCtrl
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CTexturedProgressCtrl();
|
||||
/** Init progress ctrl background & foreground bitmaps
|
||||
* NB : The original bitmap handle are detached from 'bg' & 'fg'
|
||||
*/
|
||||
void init(CBitmap &bg, CBitmap &fg);
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CTexturedProgressCtrl)
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CTexturedProgressCtrl();
|
||||
|
||||
|
||||
CBitmap _BG, _FG;
|
||||
bool _Initialized;
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CTexturedProgressCtrl)
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnNcPaint();
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_TEXTURED_PROGRESS_CTRL_H__F8A8A5F1_C0E6_40B1_88FF_1CA46491C338__INCLUDED_)
|
@ -0,0 +1,51 @@
|
||||
#ifndef RY_WEB_PAGE_H
|
||||
#define RY_WEB_PAGE_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <oaidl.h>
|
||||
#include <exdispid.h>
|
||||
|
||||
|
||||
|
||||
/** Helper to embbed a Web page in a control, and receive events from it
|
||||
* Original C code by Chris Becke
|
||||
* Adapted to C++ by Nicolas Vizerie for GameForge's Ryzom installer
|
||||
*
|
||||
* NB : Ole needs to be initialized to use use this class
|
||||
*/
|
||||
struct CWebPageEmbedder
|
||||
{
|
||||
// callback to receive event from the web browser, as defined by the DWebBrowserEvents2 interface
|
||||
struct CBrowserEventSink
|
||||
{
|
||||
// Called when an event is fired (parameters are just forwarded from IDispatch::Invoke)
|
||||
virtual void onInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pDispParams, VARIANT FAR *pVarResult, EXCEPINFO FAR *pExcepInfo, UINT FAR *puArgErr) = 0;
|
||||
virtual void onDestroy() {}
|
||||
};
|
||||
|
||||
// Create a new class of window. Window with such a class will embed a browser in them
|
||||
static void registerWebPageWindowClass(HINSTANCE hInstance, const char *name);
|
||||
|
||||
// Set the event sink for a browser window
|
||||
static void setBrowserEventSink(HWND hwnd, CBrowserEventSink *eventSink);
|
||||
|
||||
/******************************* DisplayHTMLPage() ****************************
|
||||
* Displays a URL, or HTML file on disk.
|
||||
*
|
||||
* hwnd = Handle to the window hosting the browser object.
|
||||
* webPageName = Pointer to nul-terminated name of the URL/file.
|
||||
*
|
||||
* RETURNS: 0 if success, or non-zero if an error.
|
||||
*
|
||||
*/
|
||||
static long displayHTMLPage(HWND hwnd, const char *webPageName);
|
||||
|
||||
// Test if a web page is currently busing downloading
|
||||
static bool isBusy(HWND hwnd);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,49 @@
|
||||
//RootConfigFilename = "client_default.cfg";
|
||||
|
||||
WindowStyle = "WIN";
|
||||
|
||||
DontUseNS = 1;
|
||||
DontUseAES = 1;
|
||||
FSHost = "r2linux02:47851";
|
||||
UserId = 130009;
|
||||
NbConnections = 2;
|
||||
SelectCharacter = 0;
|
||||
CreateOnMainland = 245;
|
||||
VerboseScript = 0;
|
||||
AutoMove = 0;
|
||||
Sleep = 10;
|
||||
DataPath = {
|
||||
"data_common", "data_leveldesign/leveldesign/Game_elem"
|
||||
};
|
||||
NegFiltersWarning += { "CNET", "Can't execute msg", "config file" };
|
||||
NegFiltersInfo += { "CNET", "CLIMPD", "CF:", "PATH:", "config file" };
|
||||
NegFiltersDebug += { "LNET", "CNET", "CLIMPD", "CLMPNET" };
|
||||
|
||||
//PostCreateEnterCommands = { "Position 21224,-25497" };
|
||||
//PostEnterCommands = { "Position 21224,-25497" };
|
||||
|
||||
DataCasino =
|
||||
{
|
||||
"18677,-24487", // Fyros
|
||||
"4770,-3257", // Matis
|
||||
"17169,-32938", // Tryker
|
||||
"8761,-2880" // Zorai
|
||||
};
|
||||
|
||||
SimulatedClientScript =
|
||||
{
|
||||
"getRandomInt 1 5; this.sleep",
|
||||
"getRandomInt 0 3; getDataFromTable DataCasino; this.a_value Position", // TP to a random pos from the table
|
||||
"this.sleep 10",
|
||||
"this.a createItemInBag casino_token 10 100",
|
||||
"this.sleep 1",
|
||||
"this.getNearestEntity object_casino_machine.creature; this.target",
|
||||
"this.sleep 5",
|
||||
|
||||
"this.repeat 30",
|
||||
"this.continueMission 0",
|
||||
"this.sleep 4",
|
||||
"this.endrepeat",
|
||||
|
||||
"this.disconnect"
|
||||
};
|
@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// client_drone.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
@ -0,0 +1,23 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
|
||||
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
|
@ -0,0 +1,38 @@
|
||||
/** \file cdb.cpp
|
||||
*
|
||||
* $Id: cdb.cpp,v 1.1 2005/09/19 09:50:17 boucher Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//#include "stdpch.h"
|
||||
|
||||
//////////////
|
||||
// Includes //
|
||||
//////////////
|
||||
#include "cdb.h"
|
||||
#include "cdb_branch.h"
|
||||
#include <nel/misc/bit_mem_stream.h>
|
||||
|
||||
////////////////
|
||||
// Namespaces //
|
||||
////////////////
|
||||
using namespace NLMISC;
|
||||
using namespace std;
|
||||
|
||||
|
||||
CStringMapper *ICDBNode::_DBSM = NULL;
|
||||
|
||||
|
||||
std::string ICDBNode::getFullName()
|
||||
{
|
||||
std::string sTmp = _DBSM->localUnmap(_Name);
|
||||
CCDBNodeBranch *pParent = getParent();
|
||||
if (pParent == NULL) return sTmp;
|
||||
while (pParent->getParent() != NULL)
|
||||
{
|
||||
sTmp = *pParent->getName() + ":" + sTmp;
|
||||
pParent = pParent->getParent();
|
||||
}
|
||||
return sTmp;
|
||||
}
|
@ -0,0 +1,331 @@
|
||||
/** \file cdb.h
|
||||
*
|
||||
* $Id: cdb.h,v 1.2 2007/01/31 16:40:36 boucher Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef CDB_H
|
||||
#define CDB_H
|
||||
|
||||
// misc
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
#include "nel/misc/string_mapper.h"
|
||||
|
||||
#include <libxml/parser.h>
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
class IProgressCallback;
|
||||
class CBitMemStream;
|
||||
}
|
||||
|
||||
class CCDBNodeLeaf;
|
||||
class CCDBNodeBranch;
|
||||
|
||||
///global bool, must be set to true if we want to display database modification. See displayDBModifs in commands.cpp
|
||||
extern bool VerboseDatabase;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Interface to manage a database node, can contain a unique property or a set of property
|
||||
* \author Stephane Coutelas
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
|
||||
class ICDBNode : public NLMISC::CRefCount
|
||||
{
|
||||
//-----------------------------------------------------------------------
|
||||
// end of IDBNode interface
|
||||
// start of CDB sub-class definitions
|
||||
|
||||
public:
|
||||
enum EPropType
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
// Unsigned
|
||||
I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16,
|
||||
I17, I18, I19, I20, I21, I22, I23, I24, I25, I26, I27, I28, I29, I30, I31, I32,
|
||||
I33, I34, I35, I36, I37, I38, I39, I40, I41, I42, I43, I44, I45, I46, I47, I48,
|
||||
I49, I50, I51, I52, I53, I54, I55, I56, I57, I58, I59, I60, I61, I62, I63, I64,
|
||||
// Signed
|
||||
S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13, S14, S15, S16,
|
||||
S17, S18, S19, S20, S21, S22, S23, S24, S25, S26, S27, S28, S29, S30, S31, S32,
|
||||
S33, S34, S35, S36, S37, S38, S39, S40, S41, S42, S43, S44, S45, S46, S47, S48,
|
||||
S49, S50, S51, S52, S53, S54, S55, S56, S57, S58, S59, S60, S61, S62, S63, S64,
|
||||
TEXT, Nb_Prop_Type
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* observer interface to a database property
|
||||
* \author Nicolas Brigand
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class IPropertyObserver : public NLMISC::CRefCount
|
||||
{
|
||||
public :
|
||||
virtual void update(ICDBNode* node ) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Text id
|
||||
* \author Stephane Coutelas
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CTextId
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
CTextId(): _Idx(0) {}
|
||||
|
||||
/**
|
||||
* Init this text id from a string
|
||||
*/
|
||||
explicit CTextId( const std::string& str ): _Idx(0)
|
||||
{
|
||||
std::string s=str;
|
||||
uint32 i, j;
|
||||
for (i=0,j=0; i+j<s.size(); j++)
|
||||
if (s[i+j]==':')
|
||||
{
|
||||
_Ids.push_back(s.substr(i,j));
|
||||
i+=j+1; // +1 to skip the ':'
|
||||
j=0;
|
||||
}
|
||||
// deal with the last id in the string (terminated by a '\x0' and not a ':')
|
||||
_Ids.push_back(s.substr(i,j));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a string from this text id
|
||||
*/
|
||||
std::string toString() const
|
||||
{
|
||||
if (_Ids.size()==0) return std::string("");
|
||||
std::string str=_Ids[0];
|
||||
for (unsigned i=1; i<_Ids.size(); i++)
|
||||
str +=std::string(":")+ _Ids[i];
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push back a sub name id to this id
|
||||
*/
|
||||
void push( std::string str ) { _Ids.push_back( str ); }
|
||||
|
||||
/**
|
||||
* Remove the last sub name id to this id
|
||||
*/
|
||||
void pop() { _Ids.pop_back(); }
|
||||
|
||||
/**
|
||||
* Return the next sub id
|
||||
*/
|
||||
const std::string &readNext() const
|
||||
{
|
||||
nlassert( _Idx < _Ids.size() );
|
||||
return _Ids[_Idx++];
|
||||
}
|
||||
|
||||
/** return true if a call to readNext can be performed
|
||||
*/
|
||||
bool hasElements() const { return _Idx < _Ids.size(); }
|
||||
|
||||
/**
|
||||
* Get the current index in Id
|
||||
*/
|
||||
uint getCurrentIndex() const { return _Idx; }
|
||||
|
||||
/**
|
||||
* Return the count of strings composing this id
|
||||
*/
|
||||
uint size() const { return _Ids.size(); }
|
||||
|
||||
private:
|
||||
std::vector<std::string> _Ids;
|
||||
mutable uint _Idx;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// end of CDB sub-class definitions
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// IDBNode interface definition
|
||||
|
||||
public :
|
||||
|
||||
/**
|
||||
* destructor
|
||||
*/
|
||||
virtual ~ICDBNode() {}
|
||||
|
||||
/**
|
||||
* Build the structure of the database from a file
|
||||
* \param f is the stream
|
||||
*/
|
||||
virtual void init( xmlNodePtr node, NLMISC::IProgressCallback &progressCallBack, bool mapBanks=false ) = 0;
|
||||
|
||||
/**
|
||||
* Save a backup of the database
|
||||
* \param id is the text id of the property/grp
|
||||
* \param f is the stream
|
||||
*/
|
||||
//virtual void write( CTextId& id, FILE * f) = 0;
|
||||
|
||||
/**
|
||||
* Update the database from a stream coming from the FE
|
||||
* \param gc the server gameCycle of this update. Any outdated update are aborted
|
||||
* \param f : the stream.
|
||||
*/
|
||||
virtual void readDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream & f ) = 0;
|
||||
|
||||
/**
|
||||
* Get a node
|
||||
* \param ids is the list of property index
|
||||
* \param idx is the property index of the current node(updated by the method)
|
||||
*/
|
||||
virtual ICDBNode * getNode( std::vector<uint16>& ids, uint idx ) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Get a node . Create it if it does not exist yet
|
||||
* \param id : the CTextId identifying the node
|
||||
*/
|
||||
virtual ICDBNode * getNode( const CTextId& id, bool bCreate = true )=0 ;
|
||||
|
||||
/**
|
||||
* Get a node
|
||||
* \param idx is the node index
|
||||
*/
|
||||
virtual ICDBNode * getNode( uint16 idx ) = 0;
|
||||
|
||||
/**
|
||||
* Get a node index
|
||||
* \param node is a pointer to the node
|
||||
* \param index is a reference that receive the result
|
||||
* \return true if the node was found
|
||||
*/
|
||||
virtual bool getNodeIndex( ICDBNode* node , uint & index) = 0;
|
||||
|
||||
/**
|
||||
* Return the value of a property (the update flag is set to false)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \return the value of the property
|
||||
*/
|
||||
virtual sint64 getProp( CTextId& id ) = 0;
|
||||
|
||||
/**
|
||||
* Set the value of a property (the update flag is set to true)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \param value is the value of the property
|
||||
* \return bool : 'true' if property found.
|
||||
*/
|
||||
virtual bool setProp( CTextId& id, sint64 value ) = 0;
|
||||
|
||||
/// Reset all leaf data from this point
|
||||
virtual void resetData(NLMISC::TGameCycle gc) = 0;
|
||||
|
||||
/**
|
||||
* Clear the node and his children
|
||||
*/
|
||||
virtual void clear() = 0;
|
||||
|
||||
/**
|
||||
* add an observer to a property
|
||||
* \param observer : pointer to an observer
|
||||
* \param id text id identifying the property
|
||||
* \return false if the node doesn't exist
|
||||
*/
|
||||
//virtual bool addObserver(IPropertyObserver* observer, CTextId& id) = 0;
|
||||
|
||||
/** remove an obsever
|
||||
* \param observer : pointer to an observer
|
||||
* \param id text id identifying the property
|
||||
* \return false if the node or observer doesn t exist
|
||||
*/
|
||||
//virtual bool removeObserver(IPropertyObserver* observer, CTextId& id) = 0;
|
||||
|
||||
/**
|
||||
* Inform a node of its parenthood
|
||||
*/
|
||||
virtual void setParent(CCDBNodeBranch *parent) { nlassertex(0,("setParent() not overloaded for given node type!")); }
|
||||
|
||||
/**
|
||||
* get the parent of a node
|
||||
*/
|
||||
virtual CCDBNodeBranch* getParent() { nlassertex(0,("getParent() not overloaded for given node type!")); return NULL; }
|
||||
|
||||
/**
|
||||
* get the name of this node
|
||||
*/
|
||||
const std::string * getName() const { return &_DBSM->localUnmap(_Name); }
|
||||
|
||||
/**
|
||||
* get the full name of this node separator is ':' (ie UI:INTERFACE:REDSTUFF)
|
||||
* This will not return the fullname with the ROOT !
|
||||
*/
|
||||
std::string getFullName();
|
||||
|
||||
/// Count the leaves
|
||||
virtual uint countLeaves() const = 0;
|
||||
|
||||
/// Find the leaf which count is specified (if found, the returned value is non-null and count is 0)
|
||||
virtual CCDBNodeLeaf *findLeafAtCount( uint& count ) = 0;
|
||||
|
||||
/// Set the atomic branch flag (when all the modified nodes of a branch should be tranmitted at the same time)
|
||||
void setAtomic( bool atomicBranch ) { _Atomic = atomicBranch; }
|
||||
|
||||
/// Return true if the branch has the atomic flag
|
||||
bool isAtomic() const { return _Atomic; }
|
||||
|
||||
// test if the node is a leaf
|
||||
virtual bool isLeaf() const = 0;
|
||||
|
||||
/// Debug purpose
|
||||
virtual void display (const std::string &prefix){}
|
||||
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
ICDBNode() : _Atomic(false)
|
||||
{
|
||||
if (_DBSM == NULL) _DBSM = NLMISC::CStringMapper::createLocalMapper();
|
||||
_Name = NLMISC::CStringMapper::emptyId();
|
||||
}
|
||||
|
||||
/// Constructor
|
||||
ICDBNode (const std::string &name) : _Atomic(false)
|
||||
{
|
||||
if (_DBSM == NULL) _DBSM = NLMISC::CStringMapper::createLocalMapper();
|
||||
_Name = _DBSM->localMap(name);
|
||||
//_NameDbg = name;
|
||||
}
|
||||
|
||||
/// Atomic flag: is the branch an atomic group, or is the leaf a member of an atomic group
|
||||
bool _Atomic : 1;
|
||||
|
||||
/// Name of the node
|
||||
NLMISC::TStringId _Name;
|
||||
//std::string _NameDbg;
|
||||
|
||||
static NLMISC::CStringMapper *_DBSM;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // CDB_H
|
@ -0,0 +1,928 @@
|
||||
/** \file cdb_branch.cpp
|
||||
*
|
||||
* $Id: cdb_branch.cpp,v 1.3 2007/01/31 16:40:36 boucher Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//#include "stdpch.h"
|
||||
|
||||
//#define TRACE_READ_DELTA
|
||||
//#define TRACE_WRITE_DELTA
|
||||
//#define TRACE_SET_VALUE
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////
|
||||
// Includes //
|
||||
//////////////
|
||||
#include "cdb_branch.h"
|
||||
#include "cdb_leaf.h"
|
||||
#include "../client/dummy_progress.h"
|
||||
#include "game_share/xml_auto_ptr.h"
|
||||
#include <iostream.h>
|
||||
#include "nel/misc/bit_mem_stream.h"
|
||||
#include "nel/misc/bit_set.h"
|
||||
#include "nel/misc/hierarchical_timer.h"
|
||||
|
||||
////////////////
|
||||
// Namespaces //
|
||||
////////////////
|
||||
using namespace NLMISC;
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/debug.h"
|
||||
#include "nel/misc/file.h"
|
||||
#include "nel/misc/i_xml.h"
|
||||
|
||||
#include <libxml/parser.h>
|
||||
//#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
|
||||
/////////////
|
||||
// GLOBALS //
|
||||
/////////////
|
||||
|
||||
CCDBNodeBranch::CDBBranchObsInfo *CCDBNodeBranch::_FirstNotifiedObs[2] = { NULL, NULL };
|
||||
CCDBNodeBranch::CDBBranchObsInfo *CCDBNodeBranch::_LastNotifiedObs[2] = { NULL, NULL };
|
||||
CCDBNodeBranch::CDBBranchObsInfo *CCDBNodeBranch::_CurrNotifiedObs = NULL;
|
||||
CCDBNodeBranch::CDBBranchObsInfo *CCDBNodeBranch::_NextNotifiedObs = NULL;
|
||||
|
||||
//
|
||||
uint CCDBNodeBranch::_CurrNotifiedObsList = 0;
|
||||
|
||||
// Mapping from server database index to client database index (first-level nodes)
|
||||
vector<uint> CCDBNodeBranch::_CDBBankToUnifiedIndexMapping [NB_CDB_BANKS];
|
||||
|
||||
// Mapping from client database index to TCDBBank (first-level nodes)
|
||||
vector<TCDBBank> CCDBNodeBranch::_UnifiedIndexToBank;
|
||||
|
||||
// Last index mapped
|
||||
uint CCDBNodeBranch::_CDBLastUnifiedIndex = 0;
|
||||
|
||||
// Number of bits for first-level branches, by bank
|
||||
uint CCDBNodeBranch::_FirstLevelIdBitsByBank [NB_CDB_BANKS];
|
||||
|
||||
extern const char *CDBBankNames[INVALID_CDB_BANK+1];
|
||||
|
||||
// Internal use only. First-level bank-mapping.
|
||||
void CCDBNodeBranch::mapNodeByBank( ICDBNode *node, const string& bankStr, bool clientOnly, uint nodeIndex )
|
||||
{
|
||||
/*if ( clientOnly )
|
||||
{
|
||||
//nldebug( "CDB: Unified.%u is ClientOnly", _CDBLastUnifiedIndex );
|
||||
++_CDBLastUnifiedIndex;
|
||||
_UnifiedIndexToBank.push_back( CDBPlayer );
|
||||
}
|
||||
else*/ // now clientOnly indices are known by the server as well
|
||||
{
|
||||
for ( uint b=0; b!=INVALID_CDB_BANK; ++b )
|
||||
{
|
||||
if ( string(CDBBankNames[b]) == bankStr )
|
||||
{
|
||||
//nldebug( "CDB: Mapping %s.%u to Unified.%u", CDBBankNames[b], _CDBBankToUnifiedIndexMapping[b].size(), _CDBLastUnifiedIndex );
|
||||
_CDBBankToUnifiedIndexMapping[b].push_back( _CDBLastUnifiedIndex );
|
||||
++_CDBLastUnifiedIndex;
|
||||
_UnifiedIndexToBank.push_back( (TCDBBank)b );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// init
|
||||
//
|
||||
//-----------------------------------------------
|
||||
static /*inline*/ void addNode( ICDBNode *newNode, std::string newName, CCDBNodeBranch* parent,
|
||||
std::vector<ICDBNode *> &nodes, std::vector<ICDBNode *> &nodesSorted,
|
||||
xmlNodePtr &child, const string& bankName,
|
||||
bool atomBranch, bool clientOnly,
|
||||
NLMISC::IProgressCallback &progressCallBack,
|
||||
bool mapBanks )
|
||||
{
|
||||
nodesSorted.push_back(newNode);
|
||||
nodes.push_back(newNode);
|
||||
nodes.back()->setParent(parent);
|
||||
nodes.back()->setAtomic( parent->isAtomic() || atomBranch );
|
||||
nodes.back()->init(child, progressCallBack);
|
||||
|
||||
// Setup bank mapping for first-level node
|
||||
if ( mapBanks && (parent->getParent() == NULL) )
|
||||
{
|
||||
if ( ! bankName.empty() )
|
||||
{
|
||||
CCDBNodeBranch::mapNodeByBank( newNode, bankName, clientOnly, nodes.size()-1 );
|
||||
//nldebug( "CDB: Mapping %s for %s (node %u)", newName.c_str(), bankName.c_str(), nodes.size()-1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
nlerror( "Missing bank for first-level node %s", newName.c_str() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCDBNodeBranch::init( xmlNodePtr node, NLMISC::IProgressCallback &progressCallBack, bool mapBanks )
|
||||
{
|
||||
xmlNodePtr child;
|
||||
|
||||
_Sorted = false;
|
||||
// look for other branches within this branch
|
||||
uint countNode = CIXml::countChildren (node, "branch") + CIXml::countChildren (node, "leaf");
|
||||
uint nodeId = 0;
|
||||
for (child = CIXml::getFirstChildNode (node, "branch"); child; child = CIXml::getNextChildNode (child, "branch"))
|
||||
{
|
||||
// Progress bar
|
||||
progressCallBack.progress ((float)nodeId/(float)countNode);
|
||||
progressCallBack.pushCropedValues ((float)nodeId/(float)countNode, (float)(nodeId+1)/(float)countNode);
|
||||
|
||||
CXMLAutoPtr name((const char*)xmlGetProp (child, (xmlChar*)"name"));
|
||||
CXMLAutoPtr count((const char*)xmlGetProp (child, (xmlChar*)"count"));
|
||||
CXMLAutoPtr bank((const char*)xmlGetProp (child, (xmlChar*)"bank"));
|
||||
CXMLAutoPtr atom((const char*)xmlGetProp (child, (xmlChar*)"atom"));
|
||||
CXMLAutoPtr clientonly((const char*)xmlGetProp (child, (xmlChar*)"clientonly"));
|
||||
|
||||
string sBank, sAtom, sClientonly;
|
||||
if ( bank ) sBank = bank.getDatas();
|
||||
if ( atom ) sAtom = (const char *)atom;
|
||||
if ( clientonly ) sClientonly = clientonly.getDatas();
|
||||
nlassert((const char *) name != NULL);
|
||||
if ((const char *) count != NULL)
|
||||
{
|
||||
// dealing with an array of entries
|
||||
unsigned countAsInt=(unsigned)atoi(count);
|
||||
nlassert((const char *) count != NULL);
|
||||
|
||||
for (unsigned i=0;i<countAsInt;i++)
|
||||
{
|
||||
// Progress bar
|
||||
progressCallBack.progress ((float)i/(float)countAsInt);
|
||||
progressCallBack.pushCropedValues ((float)i/(float)countAsInt, (float)(i+1)/(float)countAsInt);
|
||||
|
||||
// nlinfo("+ %s%d",name,i);
|
||||
string newName = string(name.getDatas())+toString(i);
|
||||
addNode( new CCDBNodeBranch(newName), newName, this, _Nodes, _NodesByName, child, sBank, sAtom=="1", sClientonly=="1", progressCallBack, mapBanks );
|
||||
// nlinfo("-");
|
||||
|
||||
// Progress bar
|
||||
progressCallBack.popCropedValues ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// dealing with a single entry
|
||||
// nlinfo("+ %s",name);
|
||||
string newName = string(name.getDatas());
|
||||
addNode( new CCDBNodeBranch(newName), newName, this, _Nodes, _NodesByName, child, sBank, sAtom=="1", sClientonly=="1", progressCallBack, mapBanks );
|
||||
// nlinfo("-");
|
||||
}
|
||||
|
||||
// Progress bar
|
||||
progressCallBack.popCropedValues ();
|
||||
nodeId++;
|
||||
}
|
||||
|
||||
// look for leaves of this branch
|
||||
for (child = CIXml::getFirstChildNode (node, "leaf"); child; child = CIXml::getNextChildNode (child, "leaf"))
|
||||
{
|
||||
// Progress bar
|
||||
progressCallBack.progress ((float)nodeId/(float)countNode);
|
||||
progressCallBack.pushCropedValues ((float)nodeId/(float)countNode, (float)(nodeId+1)/(float)countNode);
|
||||
|
||||
CXMLAutoPtr name((const char*)xmlGetProp (child, (xmlChar*)"name"));
|
||||
CXMLAutoPtr count((const char*)xmlGetProp (child, (xmlChar*)"count"));
|
||||
CXMLAutoPtr bank((const char*)xmlGetProp (child, (xmlChar*)"bank"));
|
||||
|
||||
string sBank;
|
||||
if ( bank ) sBank = bank.getDatas();
|
||||
nlassert((const char *) name != NULL);
|
||||
if ((const char *) count != NULL)
|
||||
{
|
||||
// dealing with an array of entries
|
||||
unsigned countAsInt=(unsigned)atoi(count);
|
||||
nlassert((const char *) count != NULL);
|
||||
|
||||
for (unsigned i=0;i<countAsInt;i++)
|
||||
{
|
||||
// Progress bar
|
||||
progressCallBack.progress ((float)i/(float)countAsInt);
|
||||
progressCallBack.pushCropedValues ((float)i/(float)countAsInt, (float)(i+1)/(float)countAsInt);
|
||||
|
||||
// nlinfo(" %s%d",name,i);
|
||||
string newName = string(name.getDatas())+toString(i);
|
||||
addNode( new CCDBNodeLeaf(newName), newName, this, _Nodes, _NodesByName, child, sBank, false, false, progressCallBack, mapBanks );
|
||||
|
||||
// Progress bar
|
||||
progressCallBack.popCropedValues ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// nlinfo(" %s",name);
|
||||
string newName = string(name.getDatas());
|
||||
addNode( new CCDBNodeLeaf(newName), newName, this, _Nodes, _NodesByName, child, sBank, false, false, progressCallBack, mapBanks );
|
||||
}
|
||||
|
||||
// Progress bar
|
||||
progressCallBack.popCropedValues ();
|
||||
nodeId++;
|
||||
}
|
||||
|
||||
// count number of bits required to store the id
|
||||
if ( (mapBanks) && (getParent() == NULL) )
|
||||
{
|
||||
nlassertex( _UnifiedIndexToBank.size() == countNode, ("Mapped: %u Nodes: %u", _UnifiedIndexToBank.size(), countNode) );
|
||||
|
||||
_IdBits = 0;
|
||||
for ( uint b=0; b!=NB_CDB_BANKS; ++b )
|
||||
{
|
||||
uint nbNodesOfBank = _CDBBankToUnifiedIndexMapping[b].size();
|
||||
uint idb = 0;
|
||||
if ( nbNodesOfBank > 0 )
|
||||
for ( idb=1; nbNodesOfBank > unsigned(1<<idb) ; idb++ ) {}
|
||||
_FirstLevelIdBitsByBank[b] = idb;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( _Nodes.size() > 0 )
|
||||
for ( _IdBits=1; _Nodes.size() > unsigned(1<<_IdBits) ; _IdBits++ ) {}
|
||||
else
|
||||
_IdBits = 0;
|
||||
}
|
||||
|
||||
find(""); // Sort !
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// attachChild
|
||||
//
|
||||
//-----------------------------------------------
|
||||
void CCDBNodeBranch::attachChild( ICDBNode * node, string nodeName )
|
||||
{
|
||||
nlassert(_Parent==NULL);
|
||||
|
||||
if (node)
|
||||
{
|
||||
node->setParent(this);
|
||||
_Nodes.push_back( node );
|
||||
//nldebug ( "CDB: Attaching node" );
|
||||
_NodesByName.push_back( node );
|
||||
_Sorted = false;
|
||||
}
|
||||
|
||||
} // attachChild //
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// getNode
|
||||
//
|
||||
//-----------------------------------------------
|
||||
ICDBNode * CCDBNodeBranch::getNode( std::vector<uint16>& ids, uint idx )
|
||||
{
|
||||
if( idx == ids.size() )
|
||||
{
|
||||
return this;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _Nodes[ids[idx]]->getNode(ids,idx+1);
|
||||
}
|
||||
|
||||
} // getNode //
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// getNode
|
||||
//
|
||||
//-----------------------------------------------
|
||||
ICDBNode * CCDBNodeBranch::getNode (const CTextId& id, bool bCreate)
|
||||
{
|
||||
// lookup next element from textid in my index => idx
|
||||
string str = id.readNext();
|
||||
|
||||
ICDBNode *pNode = find(str);
|
||||
// If the node do not exists
|
||||
if ( pNode == NULL )
|
||||
{
|
||||
if (bCreate)
|
||||
{
|
||||
ICDBNode *newNode;
|
||||
if (id.getCurrentIndex() == id.size() )
|
||||
newNode= new CCDBNodeLeaf (str);
|
||||
else
|
||||
newNode= new CCDBNodeBranch (str);
|
||||
|
||||
_Nodes.push_back( newNode );
|
||||
_NodesByName.push_back( newNode );
|
||||
_Sorted = false;
|
||||
newNode->setParent(this);
|
||||
pNode = newNode;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// get property from child
|
||||
if (!id.hasElements())
|
||||
return pNode;
|
||||
|
||||
return pNode->getNode( id, bCreate );
|
||||
|
||||
} // getNode //
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// getNode
|
||||
//
|
||||
//-----------------------------------------------
|
||||
ICDBNode * CCDBNodeBranch::getNode( uint16 idx )
|
||||
{
|
||||
if ( idx < _Nodes.size() )
|
||||
return _Nodes[idx];
|
||||
else
|
||||
return NULL;
|
||||
|
||||
} // getNode //
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// write
|
||||
//
|
||||
//-----------------------------------------------
|
||||
/*void CCDBNodeBranch::write( CTextId& id, FILE * f)
|
||||
{
|
||||
uint i;
|
||||
for( i = 0; i < _Nodes.size(); i++ )
|
||||
{
|
||||
id.push (*_Nodes[i]->getName());
|
||||
_Nodes[i]->write(id,f);
|
||||
id.pop();
|
||||
}
|
||||
|
||||
} // write //
|
||||
*/
|
||||
|
||||
//-----------------------------------------------
|
||||
// getProp
|
||||
//
|
||||
//-----------------------------------------------
|
||||
sint64 CCDBNodeBranch::getProp( CTextId& id )
|
||||
{
|
||||
// lookup next element from textid in my index => idx
|
||||
string str = id.readNext();
|
||||
ICDBNode *pNode = find( str );
|
||||
nlassert( pNode != NULL );
|
||||
|
||||
// get property from child
|
||||
return pNode->getProp( id );
|
||||
|
||||
} // getProp //
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// setProp :
|
||||
// Set the value of a property (the update flag is set to true)
|
||||
// \param id is the text id of the property/grp
|
||||
// \param name is the name of the property
|
||||
// \param value is the value of the property
|
||||
// \return bool : 'true' if property found.
|
||||
//-----------------------------------------------
|
||||
bool CCDBNodeBranch::setProp( CTextId& id, sint64 value )
|
||||
{
|
||||
|
||||
// lookup next element from textid in my index => idx
|
||||
string str = id.readNext();
|
||||
ICDBNode *pNode = find( str );
|
||||
|
||||
// Property not found.
|
||||
if(pNode == NULL)
|
||||
{
|
||||
nlwarning("Property %s not found in %s", str.c_str(), id.toString().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// set property in child
|
||||
pNode->setProp(id,value);
|
||||
// Done
|
||||
return true;
|
||||
}// setProp //
|
||||
|
||||
|
||||
/*
|
||||
* Update the database from the delta, but map the first level with the bank mapping (see _CDBBankToUnifiedIndexMapping)
|
||||
*/
|
||||
void CCDBNodeBranch::readAndMapDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream& s, TCDBBank bank )
|
||||
{
|
||||
nlassert( ! isAtomic() ); // root node mustn't be atomic
|
||||
|
||||
// Read index
|
||||
uint32 idx;
|
||||
s.serial( idx, _FirstLevelIdBitsByBank[bank] );
|
||||
|
||||
// Translate bank index -> unified index
|
||||
idx = _CDBBankToUnifiedIndexMapping[bank][idx];
|
||||
if (idx >= _Nodes.size())
|
||||
{
|
||||
throw Exception ("idx %d > _Nodes.size() %d ", idx, _Nodes.size());
|
||||
}
|
||||
|
||||
// Display the Name if we are in verbose mode
|
||||
if ( VerboseDatabase )
|
||||
{
|
||||
string displayStr = string("Reading: ") + *(_Nodes[idx]->getName());
|
||||
//CInterfaceManager::getInstance()->getChatOutput()->addTextChild( ucstring( displayStr ),CRGBA(255,255,255,255));
|
||||
nlinfo( "CDB: %s%s %u/%d", (!getParent())?"[root] ":"-", displayStr.c_str(), idx, _IdBits );
|
||||
}
|
||||
|
||||
// Apply delta to children nodes
|
||||
_Nodes[idx]->readDelta( gc, s );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// readDelta
|
||||
//
|
||||
//-----------------------------------------------
|
||||
void CCDBNodeBranch::readDelta( NLMISC::TGameCycle gc, CBitMemStream & f )
|
||||
{
|
||||
if ( isAtomic() )
|
||||
{
|
||||
// Read the atom bitfield
|
||||
uint nbAtomElements = countLeaves();
|
||||
if(VerboseDatabase)
|
||||
nlinfo( "CDB/ATOM: %u leaves", nbAtomElements );
|
||||
CBitSet bitfield( nbAtomElements );
|
||||
f.readBits( bitfield );
|
||||
if ( ! bitfield.getVector().empty() )
|
||||
{
|
||||
if(VerboseDatabase)
|
||||
{
|
||||
nldebug( "CDB/ATOM: Bitfield: %s LastBits:", bitfield.toString().c_str() );
|
||||
f.displayLastBits( bitfield.size() );
|
||||
}
|
||||
}
|
||||
|
||||
// Set each modified property
|
||||
uint atomIndex;
|
||||
for ( uint i=0; i!=bitfield.size(); ++i )
|
||||
{
|
||||
if ( bitfield[i] )
|
||||
{
|
||||
if(VerboseDatabase)
|
||||
nldebug( "CDB/ATOM: Reading prop[%u] of atom", i );
|
||||
atomIndex = i;
|
||||
CCDBNodeLeaf *leaf = findLeafAtCount( atomIndex );
|
||||
if ( leaf )
|
||||
leaf->readDelta( gc, f );
|
||||
else
|
||||
nlwarning( "CDB: Can't find leaf with index %u in atom branch %s", i, getParent()?getName()->c_str():"(root)" );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 idx;
|
||||
|
||||
f.serial(idx,_IdBits);
|
||||
|
||||
if (idx >= _Nodes.size())
|
||||
{
|
||||
throw Exception ("idx %d > _Nodes.size() %d ", idx, _Nodes.size());
|
||||
}
|
||||
|
||||
// Display the Name if we are in verbose mode
|
||||
if ( VerboseDatabase )
|
||||
{
|
||||
string displayStr = string("Reading: ") + *(_Nodes[idx]->getName());
|
||||
//CInterfaceManager::getInstance()->getChatOutput()->addTextChild( ucstring( displayStr ),CRGBA(255,255,255,255));
|
||||
nlinfo( "CDB: %s%s %u/%d", (!getParent())?"[root] ":"-", displayStr.c_str(), idx, _IdBits );
|
||||
}
|
||||
|
||||
_Nodes[idx]->readDelta(gc, f);
|
||||
}
|
||||
}// readDelta //
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// clear
|
||||
//
|
||||
//-----------------------------------------------
|
||||
void CCDBNodeBranch::clear()
|
||||
{
|
||||
vector<ICDBNode *>::iterator itNode;
|
||||
for( itNode = _Nodes.begin(); itNode != _Nodes.end(); ++itNode )
|
||||
{
|
||||
(*itNode)->clear();
|
||||
delete (*itNode);
|
||||
}
|
||||
_Nodes.clear();
|
||||
_NodesByName.clear();
|
||||
// must remove all branch observers, to avoid any problem in subsequent flushObserversCalls()
|
||||
//removeAllBranchObserver();
|
||||
} // clear //
|
||||
|
||||
|
||||
/*
|
||||
* Find the leaf which count is specified (if found, the returned value is non-null and count is 0)
|
||||
*/
|
||||
CCDBNodeLeaf *CCDBNodeBranch::findLeafAtCount( uint& count )
|
||||
{
|
||||
vector<ICDBNode *>::const_iterator itNode;
|
||||
for ( itNode = _Nodes.begin(); itNode != _Nodes.end(); ++itNode )
|
||||
{
|
||||
CCDBNodeLeaf *leaf = (*itNode)->findLeafAtCount( count );
|
||||
if ( leaf )
|
||||
return leaf;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Count the leaves
|
||||
*/
|
||||
uint CCDBNodeBranch::countLeaves() const
|
||||
{
|
||||
uint n = 0;
|
||||
vector<ICDBNode *>::const_iterator itNode;
|
||||
for ( itNode = _Nodes.begin(); itNode != _Nodes.end(); ++itNode )
|
||||
{
|
||||
n += (*itNode)->countLeaves();
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
void CCDBNodeBranch::display (const std::string &prefix)
|
||||
{
|
||||
nlinfo("%sB %s", prefix.c_str(), _DBSM->localUnmap(_Name).c_str());
|
||||
string newPrefix = " " + prefix;
|
||||
vector<ICDBNode *>::const_iterator itNode;
|
||||
for ( itNode = _Nodes.begin(); itNode != _Nodes.end(); ++itNode )
|
||||
{
|
||||
(*itNode)->display(newPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
void CCDBNodeBranch::removeNode (CTextId& id)
|
||||
{
|
||||
// Look for the node
|
||||
CCDBNodeBranch *pNode = dynamic_cast<CCDBNodeBranch*>(getNode(id,false));
|
||||
if (pNode == NULL)
|
||||
{
|
||||
nlwarning("node %s not found", id.toString().c_str());
|
||||
return;
|
||||
}
|
||||
CCDBNodeBranch *pParent = pNode->_Parent;
|
||||
if (pParent== NULL)
|
||||
{
|
||||
nlwarning("parent node not found");
|
||||
return;
|
||||
}
|
||||
// search index node unsorted
|
||||
uint indexNode;
|
||||
for (indexNode = 0; indexNode < pParent->_Nodes.size(); ++indexNode)
|
||||
if (pParent->_Nodes[indexNode] == pNode)
|
||||
break;
|
||||
if (indexNode == pParent->_Nodes.size())
|
||||
{
|
||||
nlwarning("node not found");
|
||||
return;
|
||||
}
|
||||
// search index node sorted
|
||||
uint indexSorted;
|
||||
for (indexSorted = 0; indexSorted < pParent->_NodesByName.size(); ++indexSorted)
|
||||
if (pParent->_NodesByName[indexSorted] == pNode)
|
||||
break;
|
||||
if (indexSorted == pParent->_NodesByName.size())
|
||||
{
|
||||
nlwarning("node not found");
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove node from parent
|
||||
pParent->_Nodes.erase (pParent->_Nodes.begin()+indexNode);
|
||||
pParent->_NodesByName.erase (pParent->_NodesByName.begin()+indexSorted);
|
||||
pParent->_Sorted = false;
|
||||
|
||||
// Delete the node
|
||||
pNode->clear();
|
||||
delete pNode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
void CCDBNodeBranch::flushObserversCalls()
|
||||
{
|
||||
H_AUTO ( RZ_Interface_flushObserversCalls )
|
||||
|
||||
// nlassert(_CrtCheckMemory());
|
||||
_CurrNotifiedObs = _FirstNotifiedObs[_CurrNotifiedObsList];
|
||||
while (_CurrNotifiedObs)
|
||||
{
|
||||
// modified node should now store them in other list when they're modified
|
||||
_CurrNotifiedObsList = 1 - _CurrNotifiedObsList;
|
||||
// switch list so that modified node are stored in the other list
|
||||
while (_CurrNotifiedObs)
|
||||
{
|
||||
_NextNotifiedObs = _CurrNotifiedObs->NextNotifiedObserver[1 - _CurrNotifiedObsList];
|
||||
nlassert(_CurrNotifiedObs->Owner);
|
||||
if (_CurrNotifiedObs->Observer)
|
||||
_CurrNotifiedObs->Observer->update(_CurrNotifiedObs->Owner);
|
||||
if (_CurrNotifiedObs) // this may be modified by the call (if current observer is removed)
|
||||
{
|
||||
_CurrNotifiedObs->unlink(1 - _CurrNotifiedObsList);
|
||||
}
|
||||
_CurrNotifiedObs = _NextNotifiedObs;
|
||||
}
|
||||
nlassert(_FirstNotifiedObs[1 - _CurrNotifiedObsList] == NULL);
|
||||
nlassert(_LastNotifiedObs[1 - _CurrNotifiedObsList] == NULL);
|
||||
// examine other list to see if nodes have been registered
|
||||
_CurrNotifiedObs = _FirstNotifiedObs[_CurrNotifiedObsList];
|
||||
}
|
||||
// nlassert(_CrtCheckMemory());
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
void CCDBNodeBranch::CDBBranchObsInfo::link(uint list)
|
||||
{
|
||||
// nlassert(_CrtCheckMemory());
|
||||
nlassert(list < 2);
|
||||
if (Touched[list]) return; // already inserted in list
|
||||
Touched[list] = true;
|
||||
nlassert(!PrevNotifiedObserver[list]);
|
||||
nlassert(!NextNotifiedObserver[list]);
|
||||
if (!_FirstNotifiedObs[list])
|
||||
{
|
||||
_FirstNotifiedObs[list] = _LastNotifiedObs[list] = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
nlassert(!_LastNotifiedObs[list]->NextNotifiedObserver[list]);
|
||||
_LastNotifiedObs[list]->NextNotifiedObserver[list] = this;
|
||||
PrevNotifiedObserver[list] = _LastNotifiedObs[list];
|
||||
_LastNotifiedObs[list] = this;
|
||||
}
|
||||
// nlassert(_CrtCheckMemory());
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
void CCDBNodeBranch::CDBBranchObsInfo::unlink(uint list)
|
||||
{
|
||||
// nlassert(_CrtCheckMemory());
|
||||
nlassert(list < 2);
|
||||
if (!Touched[list])
|
||||
{
|
||||
// not linked in this list
|
||||
nlassert(PrevNotifiedObserver[list] == NULL);
|
||||
nlassert(NextNotifiedObserver[list] == NULL);
|
||||
return;
|
||||
}
|
||||
if (PrevNotifiedObserver[list])
|
||||
{
|
||||
PrevNotifiedObserver[list]->NextNotifiedObserver[list] = NextNotifiedObserver[list];
|
||||
}
|
||||
else
|
||||
{
|
||||
// this was the first node
|
||||
_FirstNotifiedObs[list] = NextNotifiedObserver[list];
|
||||
}
|
||||
if (NextNotifiedObserver[list])
|
||||
{
|
||||
NextNotifiedObserver[list]->PrevNotifiedObserver[list] = PrevNotifiedObserver[list];
|
||||
}
|
||||
else
|
||||
{
|
||||
// this was the last node
|
||||
_LastNotifiedObs[list] = PrevNotifiedObserver[list];
|
||||
}
|
||||
PrevNotifiedObserver[list] = NULL;
|
||||
NextNotifiedObserver[list] = NULL;
|
||||
Touched[list] = false;
|
||||
// nlassert(_CrtCheckMemory());
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
void CCDBNodeBranch::linkInModifiedNodeList()
|
||||
{
|
||||
// nlassert(_CrtCheckMemory());
|
||||
CCDBNodeBranch *curr = this;
|
||||
do
|
||||
{
|
||||
for(TObsList::iterator it = curr->_Observers.begin(); it != curr->_Observers.end(); ++it)
|
||||
{
|
||||
it->link(_CurrNotifiedObsList);
|
||||
}
|
||||
curr = curr->getParent();
|
||||
}
|
||||
while(curr);
|
||||
// nlassert(_CrtCheckMemory());
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
//-----------------------------------------------
|
||||
// addObserver
|
||||
//
|
||||
//-----------------------------------------------
|
||||
bool CCDBNodeBranch::addObserver(IPropertyObserver* observer,CTextId& id)
|
||||
{
|
||||
//test if this node is the desired one, if yes, add the observer to all the children nodes
|
||||
if ( id.getCurrentIndex() == id.size() )
|
||||
{
|
||||
for (uint i = 0; i < _Nodes.size(); ++i)
|
||||
{
|
||||
if (!_Nodes[i]->addObserver(observer,id))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// lookup next element from textid in my index => idx
|
||||
string str = id.readNext();
|
||||
ICDBNode *pNode = find( str );
|
||||
// Property not found.
|
||||
if(pNode == NULL)
|
||||
{
|
||||
nlwarning(" Property %s not found", id.toString().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// set property in child
|
||||
pNode->addObserver(observer,id);
|
||||
return true;
|
||||
|
||||
} // addObserver //
|
||||
|
||||
//-----------------------------------------------
|
||||
// removeObserver
|
||||
//
|
||||
//-----------------------------------------------
|
||||
bool CCDBNodeBranch::removeObserver(IPropertyObserver* observer, CTextId& id)
|
||||
{
|
||||
//test if this node is the desired one, if yes, remove the observer to all the children nodes
|
||||
if ( id.getCurrentIndex() == id.size() )
|
||||
{
|
||||
for (uint i = 0; i < _Nodes.size(); ++i)
|
||||
{
|
||||
if (!_Nodes[i]->removeObserver(observer, id))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// lookup next element from textid in my index => idx
|
||||
string str = id.readNext();
|
||||
ICDBNode *pNode = find( str );
|
||||
// Property not found.
|
||||
if(pNode == NULL)
|
||||
{
|
||||
nlwarning(" Property %s not found", id.toString().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove observer in child
|
||||
pNode->removeObserver(observer,id);
|
||||
return true;
|
||||
|
||||
} // removeObserver //
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
void CCDBNodeBranch::addBranchObserver(IPropertyObserver* observer)
|
||||
{
|
||||
CDBBranchObsInfo oi(observer, this);
|
||||
_Observers.push_front(oi);
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
bool CCDBNodeBranch::removeBranchObserver(IPropertyObserver* observer)
|
||||
{
|
||||
bool found = false;
|
||||
TObsList::iterator it = _Observers.begin();
|
||||
while (it != _Observers.end())
|
||||
{
|
||||
if (it->Observer == observer)
|
||||
{
|
||||
removeBranchInfoIt(it);
|
||||
it = _Observers.erase(it);
|
||||
found = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
void CCDBNodeBranch::removeAllBranchObserver()
|
||||
{
|
||||
TObsList::iterator it = _Observers.begin();
|
||||
while (it != _Observers.end())
|
||||
{
|
||||
removeBranchInfoIt(it);
|
||||
++it;
|
||||
}
|
||||
_Observers.clear();
|
||||
}
|
||||
*/
|
||||
|
||||
//-----------------------------------------------
|
||||
void CCDBNodeBranch::removeBranchInfoIt(TObsList::iterator it)
|
||||
{
|
||||
CDBBranchObsInfo *oi = &(*it);
|
||||
// if this node is currenlty being notified, update iterators
|
||||
if (oi == _CurrNotifiedObs)
|
||||
{
|
||||
_CurrNotifiedObs = NULL;
|
||||
}
|
||||
if (oi == _NextNotifiedObs)
|
||||
{
|
||||
nlassert(_CurrNotifiedObsList < 2);
|
||||
_NextNotifiedObs = _NextNotifiedObs->NextNotifiedObserver[1 - _CurrNotifiedObsList];
|
||||
}
|
||||
// unlink observer from both update lists
|
||||
oi->unlink(0);
|
||||
oi->unlink(1);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// Usefull for find
|
||||
//-----------------------------------------------
|
||||
class CCDBNodeBranchComp : public std::binary_function<ICDBNode *, ICDBNode *, bool>
|
||||
{
|
||||
public:
|
||||
bool operator()(const ICDBNode * x, const ICDBNode * y) const
|
||||
{
|
||||
return *(x->getName()) < *(y->getName());
|
||||
}
|
||||
};
|
||||
|
||||
class CCDBNodeBranchComp2 : public std::binary_function<ICDBNode *, const string &, bool>
|
||||
{
|
||||
public:
|
||||
bool operator()(const ICDBNode * x, const string & y) const
|
||||
{
|
||||
return *(x->getName()) < y;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
ICDBNode *CCDBNodeBranch::find(const std::string &nodeName)
|
||||
{
|
||||
if (!_Sorted)
|
||||
{
|
||||
_Sorted = true;
|
||||
sort(_NodesByName.begin(), _NodesByName.end(), CCDBNodeBranchComp());
|
||||
}
|
||||
|
||||
vector<ICDBNode*>::iterator it = lower_bound(_NodesByName.begin(), _NodesByName.end(), nodeName, CCDBNodeBranchComp2());
|
||||
if (it == _NodesByName.end())
|
||||
return NULL;
|
||||
else
|
||||
{
|
||||
if (*(*it)->getName() == nodeName)
|
||||
return *it;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef TRACE_READ_DELTA
|
||||
#undef TRACE_READ_DELTA
|
||||
#endif
|
||||
|
||||
#ifdef TRACE_WRITE_DELTA
|
||||
#undef TRACE_WRITE_DELTA
|
||||
#endif
|
||||
|
||||
#ifdef TRACE_SET_VALUE
|
||||
#undef TRACE_SET_VALUE
|
||||
#endif
|
||||
|
@ -0,0 +1,295 @@
|
||||
/** \file cdb_branch.h
|
||||
*
|
||||
* $Id: cdb_branch.h,v 1.2 2007/01/31 16:40:36 boucher Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef CDB_BRANCH_H
|
||||
#define CDB_BRANCH_H
|
||||
|
||||
#include "cdb.h"
|
||||
#include "game_share/ryzom_database_banks.h"
|
||||
|
||||
/**
|
||||
* Database Node which contains a set of properties
|
||||
* \author Stephane Coutelas
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CCDBNodeBranch : public ICDBNode
|
||||
{
|
||||
public:
|
||||
|
||||
// default constructor
|
||||
CCDBNodeBranch(const std::string &name) : ICDBNode(name)
|
||||
{
|
||||
_Parent = NULL;
|
||||
_IdBits = 0;
|
||||
_Sorted = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the structure of the database from a file
|
||||
* \param f is the stream
|
||||
*/
|
||||
void init( xmlNodePtr node, class NLMISC::IProgressCallback &progressCallBack, bool mapBanks=false );
|
||||
|
||||
/**
|
||||
* Add a new sub node
|
||||
* \param node is the new subnode
|
||||
* \param nodeName is the name of the node
|
||||
*/
|
||||
void attachChild( ICDBNode * node, std::string nodeName );
|
||||
|
||||
/**
|
||||
* Get a node
|
||||
* \param ids is the list of property index
|
||||
* \param idx is the property index of the current node(updated by the method,should be 0 at first call)
|
||||
*/
|
||||
ICDBNode * getNode( std::vector<uint16>& ids, uint idx );
|
||||
|
||||
/**
|
||||
* Get a node . Create it if it does not exist yet
|
||||
* \param id : the CTextId identifying the node
|
||||
*/
|
||||
ICDBNode * getNode (const CTextId& id, bool bCreate=true);
|
||||
|
||||
/**
|
||||
* Get a node. Return NULL if out of bounds (no warning)
|
||||
* \param idx is the node index
|
||||
*/
|
||||
ICDBNode * getNode( uint16 idx );
|
||||
|
||||
/**
|
||||
* Get a node index
|
||||
* \param node is a pointer to the node
|
||||
*/
|
||||
virtual bool getNodeIndex( ICDBNode* node , uint& index)
|
||||
{
|
||||
index=0;
|
||||
for ( std::vector<ICDBNode*>::const_iterator it = _Nodes.begin(); it != _Nodes.end(); it++)
|
||||
{
|
||||
if (*it == node)
|
||||
return true;
|
||||
index++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a backup of the database
|
||||
* \param id is the text id of the property/grp
|
||||
* \param f is the stream
|
||||
*/
|
||||
void write( CTextId& id, FILE * f);
|
||||
|
||||
/// Update the database from the delta, but map the first level with the bank mapping (see _CDBBankToUnifiedIndexMapping)
|
||||
void readAndMapDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream& s, TCDBBank bank );
|
||||
|
||||
/// Update the database from a stream coming from the FE
|
||||
void readDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream & f );
|
||||
|
||||
/**
|
||||
* Return the value of a property (the update flag is set to false)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \return the value of the property
|
||||
*/
|
||||
sint64 getProp( CTextId& id );
|
||||
|
||||
/**
|
||||
* Set the value of a property (the update flag is set to true)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \param value is the value of the property
|
||||
* \return bool : 'true' if property found.
|
||||
*/
|
||||
bool setProp( CTextId& id, sint64 value );
|
||||
|
||||
/// Clear the node and his children
|
||||
void clear();
|
||||
|
||||
/// Reset the data corresponding to the bank (works only on top level node)
|
||||
void resetBank( NLMISC::TGameCycle gc, TCDBBank bank)
|
||||
{
|
||||
//nlassert( getParent() == NULL );
|
||||
for ( uint i=0; i!=_Nodes.size(); ++i )
|
||||
{
|
||||
if ( _UnifiedIndexToBank[i] == bank )
|
||||
_Nodes[i]->resetData(gc);
|
||||
}
|
||||
}
|
||||
|
||||
/// Reset all leaf data from this point
|
||||
void resetData(NLMISC::TGameCycle gc)
|
||||
{
|
||||
for ( uint i=0; i!=_Nodes.size(); ++i )
|
||||
{
|
||||
_Nodes[i]->resetData(gc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~CCDBNodeBranch() { clear(); }
|
||||
|
||||
// the parent node for a branch (NULL by default)
|
||||
virtual void setParent(CCDBNodeBranch *parent) { _Parent=parent; }
|
||||
|
||||
virtual CCDBNodeBranch* getParent()
|
||||
{
|
||||
return _Parent;
|
||||
}
|
||||
|
||||
//get the number of nodes
|
||||
uint16 getNbNodes()
|
||||
{
|
||||
return (uint16)_Nodes.size();
|
||||
}
|
||||
|
||||
/// Count the leaves
|
||||
virtual uint countLeaves() const;
|
||||
|
||||
/// Find the leaf which count is specified (if found, the returned value is non-null and count is 0)
|
||||
virtual CCDBNodeLeaf *findLeafAtCount( uint& count );
|
||||
|
||||
virtual void display (const std::string &prefix);
|
||||
|
||||
void removeNode (CTextId& id);
|
||||
|
||||
/**
|
||||
* add an observer to a property
|
||||
* \param observer : pointer to an observer
|
||||
* \param id text id identifying the property
|
||||
* \return false if the node doen t exist
|
||||
*/
|
||||
//virtual bool addObserver(IPropertyObserver* observer, CTextId& id);
|
||||
|
||||
/** remove an obsever
|
||||
* \param observer : pointer to an observer
|
||||
* \return false if the node or observer doesn t exist
|
||||
*/
|
||||
//virtual bool removeObserver(IPropertyObserver* observer, CTextId& id);
|
||||
|
||||
// Add an observer to this branch. It will be notified of any change in the sub-leaves
|
||||
|
||||
// Add observer to all sub-leaves
|
||||
//virtual void addBranchObserver(IPropertyObserver* observer);
|
||||
|
||||
// Remove observer from all sub-leaves
|
||||
//virtual bool removeBranchObserver(IPropertyObserver* observer);
|
||||
|
||||
virtual bool isLeaf() const { return false; }
|
||||
|
||||
/** Update all observers of branchs that have been modified
|
||||
*/
|
||||
static void flushObserversCalls();
|
||||
|
||||
// mark this branch and parent branch as 'modified'. This is usually called by sub-leaves
|
||||
void linkInModifiedNodeList();
|
||||
|
||||
/// Find a subnode at this level
|
||||
ICDBNode * find (const std::string &nodeName);
|
||||
|
||||
/// Main init
|
||||
static void resetNodeBankMapping() { _UnifiedIndexToBank.clear(); }
|
||||
|
||||
/// Internal use only
|
||||
static void mapNodeByBank( ICDBNode *node, const std::string& bankStr, bool clientOnly, uint nodeIndex );
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
/** Struct identifying an observer of a db branch
|
||||
* This struct can be linked in a list so that we can update observers only once per pass.
|
||||
* An observer that watch a whole branch can be updated once and only once after each element of the branch has been modified
|
||||
*/
|
||||
class CDBBranchObsInfo
|
||||
{
|
||||
public:
|
||||
NLMISC::CRefPtr<IPropertyObserver> Observer;
|
||||
// 2 linked list are required : while the observer is notified, it can triger one other observer, so we must link it in another list
|
||||
bool Touched[2];
|
||||
CDBBranchObsInfo *PrevNotifiedObserver[2]; // NULL means this is the head
|
||||
CDBBranchObsInfo *NextNotifiedObserver[2];
|
||||
ICDBNode *Owner;
|
||||
public:
|
||||
CDBBranchObsInfo(IPropertyObserver *obs = NULL, ICDBNode *owner = NULL)
|
||||
{
|
||||
Owner = owner;
|
||||
Observer = obs;
|
||||
Touched[0] = Touched[1] = false;
|
||||
PrevNotifiedObserver[0] = PrevNotifiedObserver[1] = NULL;
|
||||
NextNotifiedObserver[0] = NextNotifiedObserver[1] = NULL;
|
||||
}
|
||||
~CDBBranchObsInfo()
|
||||
{
|
||||
// should have been unlinked
|
||||
nlassert(Touched[0] == false);
|
||||
nlassert(Touched[1] == false);
|
||||
nlassert(PrevNotifiedObserver[0] == NULL);
|
||||
nlassert(PrevNotifiedObserver[1] == NULL);
|
||||
nlassert(NextNotifiedObserver[0] == NULL);
|
||||
nlassert(NextNotifiedObserver[1] == NULL);
|
||||
}
|
||||
// Unlink from the given list. This also clear the '_Touched' flag
|
||||
void unlink(uint list);
|
||||
void link(uint list);
|
||||
};
|
||||
|
||||
typedef std::list<CDBBranchObsInfo> TObsList; // must use a list because pointers on CDBObserverInfo instances must remains valids
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
CCDBNodeBranch *_Parent;
|
||||
|
||||
/// database subnodes not sorted
|
||||
std::vector<ICDBNode*> _Nodes;
|
||||
|
||||
/// subnodes sorted by name
|
||||
std::vector<ICDBNode*> _NodesByName;
|
||||
|
||||
// number of bits required to stock my children's ids
|
||||
uint8 _IdBits : 7;
|
||||
bool _Sorted : 1;
|
||||
|
||||
// observers for this node or branch
|
||||
TObsList _Observers;
|
||||
|
||||
friend class CDBBranchObsInfo;
|
||||
// Global list of modified nodes
|
||||
static CDBBranchObsInfo *_FirstNotifiedObs[2];
|
||||
static CDBBranchObsInfo *_LastNotifiedObs[2];
|
||||
static uint _CurrNotifiedObsList; // 0 or 1 => tell in which list observers of modified values must be added
|
||||
// current & next observers being notified : if such observer if removed during notifcation, pointer will be valids
|
||||
static CDBBranchObsInfo *_CurrNotifiedObs;
|
||||
static CDBBranchObsInfo *_NextNotifiedObs;
|
||||
|
||||
/// Mapping from server database index to client database index (first-level nodes)
|
||||
static std::vector<uint> _CDBBankToUnifiedIndexMapping [NB_CDB_BANKS];
|
||||
|
||||
// Mapping from client database index to TCDBBank (first-level nodes)
|
||||
static std::vector<TCDBBank> _UnifiedIndexToBank;
|
||||
|
||||
/// Last index mapped
|
||||
static uint _CDBLastUnifiedIndex;
|
||||
|
||||
/// Number of bits for first-level branches, by bank
|
||||
static uint _FirstLevelIdBitsByBank [NB_CDB_BANKS];
|
||||
|
||||
/// called by clear
|
||||
//void removeAllBranchObserver();
|
||||
void removeBranchInfoIt(TObsList::iterator it);
|
||||
};
|
||||
|
||||
|
||||
#endif // CDB_BRANCH_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
/** \file cdb_check_sum.cpp
|
||||
* <File description>
|
||||
*
|
||||
* $Id: cdb_check_sum.cpp,v 1.1 2005/09/19 09:50:17 boucher Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//#include "stdpch.h"
|
||||
#include "cdb_check_sum.h"
|
||||
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
CCDBCheckSum::CCDBCheckSum()
|
||||
{
|
||||
//arbitrary values
|
||||
_Sum = 0;
|
||||
_Factor = 55665;
|
||||
_Const1 = 52845;
|
||||
_Const2 = 22719;
|
||||
};
|
||||
|
||||
///add an uint8 to the sum
|
||||
void CCDBCheckSum::add(uint8 el)
|
||||
{
|
||||
uint32 cipher = (el ^ (_Factor >> 8));
|
||||
_Factor = (cipher + _Factor) * _Const1 + _Const2;
|
||||
_Sum += cipher;
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
/** \file cdb_check_sum.h
|
||||
* <File description>
|
||||
*
|
||||
* $Id: cdb_check_sum.h,v 1.1 2005/09/19 09:50:17 boucher Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef NL_CDB_CHECK_SUM_H
|
||||
#define NL_CDB_CHECK_SUM_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* class implementing check sum for the client database
|
||||
* these check sum can be used to ensure that linked properties have all been modified
|
||||
* \author Nicolas Brigand
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CCDBCheckSum
|
||||
{
|
||||
public:
|
||||
///constructor
|
||||
CCDBCheckSum();
|
||||
|
||||
//clear the sum
|
||||
void clear()
|
||||
{
|
||||
_Sum = 0;
|
||||
};
|
||||
|
||||
///add an uint8 to the sum
|
||||
void add(uint8 el);
|
||||
|
||||
///add a value to the check sum
|
||||
template <class T>
|
||||
void add(const T & el)
|
||||
{
|
||||
T value = el;
|
||||
for (uint8 i=0; i< sizeof(T); i++)
|
||||
{
|
||||
uint8 tmp = (uint8)(value & 0xFF);
|
||||
add(tmp);
|
||||
value >>=8;
|
||||
}
|
||||
}
|
||||
|
||||
///add a vector to the sum
|
||||
template <class T>
|
||||
void addVector(const std::vector<T> & vect)
|
||||
{
|
||||
for (typename std::vector<T>::const_iterator it = vect.begin(); it != vect.end(); it++)
|
||||
add(*it);
|
||||
}
|
||||
|
||||
uint32 getSum()
|
||||
{
|
||||
return _Sum;
|
||||
}
|
||||
private:
|
||||
///the checsum result
|
||||
uint32 _Sum;
|
||||
|
||||
///the following values are used in the check algorithm
|
||||
uint32 _Factor;
|
||||
uint32 _Const1;
|
||||
uint32 _Const2;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // NL_CDB_CHECK_SUM_H
|
||||
|
||||
/* End of cdb_check_sum.h */
|
@ -0,0 +1,370 @@
|
||||
/** \file cdb_leaf.cpp
|
||||
* <File description>
|
||||
*
|
||||
* $Id: cdb_leaf.cpp,v 1.3 2007/07/27 15:14:50 cado Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//#include "stdpch.h"
|
||||
|
||||
|
||||
//#define TRACE_READ_DELTA
|
||||
//#define TRACE_WRITE_DELTA
|
||||
//#define TRACE_SET_VALUE
|
||||
|
||||
#define DELAYED_OBSERVERS
|
||||
|
||||
//////////////
|
||||
// Includes //
|
||||
//////////////
|
||||
#include "cdb_leaf.h"
|
||||
#include "game_share/xml_auto_ptr.h"
|
||||
#include "nel/misc/bit_mem_stream.h"
|
||||
#include <iostream.h>
|
||||
|
||||
////////////////
|
||||
// Namespaces //
|
||||
////////////////
|
||||
using namespace NLMISC;
|
||||
using namespace std;
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// init
|
||||
//-----------------------------------------------
|
||||
void CCDBNodeLeaf::init( xmlNodePtr node, NLMISC::IProgressCallback &progressCallBack, bool mapBanks )
|
||||
{
|
||||
CXMLAutoPtr type((const char*)xmlGetProp (node, (xmlChar*)"type"));
|
||||
nlassert((const char *) type != NULL);
|
||||
|
||||
// IF type is an INT with n bits [1,64].
|
||||
if ((type.getDatas()[0] == 'I') || (type.getDatas()[0] == 'U'))
|
||||
{
|
||||
uint nbBit = atoi(type.getDatas() + 1);
|
||||
if(nbBit>=1 && nbBit<=64)
|
||||
_Type=(ICDBNode::EPropType)nbBit;
|
||||
else
|
||||
{
|
||||
nlwarning("CCDBNodeLeaf::init : property is an INT and should be between [1,64] but it is %d bit(s).", nbBit);
|
||||
_Type = ICDBNode::UNKNOWN;
|
||||
}
|
||||
}
|
||||
else if (type.getDatas()[0] == 'S')
|
||||
{
|
||||
uint nbBit = atoi(type.getDatas() + 1);
|
||||
if(nbBit>=1 && nbBit<=64)
|
||||
_Type = (ICDBNode::EPropType)(nbBit+64);
|
||||
else
|
||||
{
|
||||
nlwarning("CCDBNodeLeaf::init : property is an SINT and should be between [1,64] but it is %d bit(s).", nbBit);
|
||||
_Type = ICDBNode::UNKNOWN;
|
||||
}
|
||||
}
|
||||
// ELSE
|
||||
else
|
||||
{
|
||||
// IF it is a TEXT.
|
||||
if(!strcmp(type, "TEXT"))
|
||||
_Type = ICDBNode::TEXT;
|
||||
// ELSE type unknown.
|
||||
else
|
||||
{
|
||||
nlwarning("CCDBNodeLeaf::init : type '%s' is unknown.", type.getDatas());
|
||||
_Type = ICDBNode::UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
} // init //
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// getNode
|
||||
//
|
||||
//-----------------------------------------------
|
||||
ICDBNode * CCDBNodeLeaf::getNode( std::vector<uint16>& ids, uint idx )
|
||||
{
|
||||
// assert that there are no indexes left in the index list
|
||||
nlassert( idx==ids.size());
|
||||
return this;
|
||||
} // getNode //
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// getNode
|
||||
//
|
||||
//-----------------------------------------------
|
||||
ICDBNode * CCDBNodeLeaf::getNode( uint16 idx )
|
||||
{
|
||||
return this;
|
||||
} // getNode //
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// getNode
|
||||
//
|
||||
//-----------------------------------------------
|
||||
ICDBNode * CCDBNodeLeaf::getNode (const CTextId& id, bool bCreate)
|
||||
{
|
||||
if (_DBSM->localUnmap(_Name) == id.readNext())
|
||||
{
|
||||
if (id.size() == id.getCurrentIndex())
|
||||
return this;
|
||||
}
|
||||
return NULL;
|
||||
} // getNode //
|
||||
|
||||
//-----------------------------------------------
|
||||
// write
|
||||
//
|
||||
//-----------------------------------------------
|
||||
/*
|
||||
void CCDBNodeLeaf::write( CTextId& id, FILE * f)
|
||||
{
|
||||
fprintf(f,"%"NL_I64"d\t%s\n",_Property,id.toString().c_str());
|
||||
} // write //
|
||||
*/
|
||||
|
||||
//-----------------------------------------------
|
||||
// readDelta
|
||||
//-----------------------------------------------
|
||||
void CCDBNodeLeaf::readDelta(NLMISC::TGameCycle gc, CBitMemStream & f )
|
||||
{
|
||||
// If the property Type is valid.
|
||||
if(_Type > UNKNOWN && _Type < Nb_Prop_Type)
|
||||
{
|
||||
// Read the Property Value according to the Property Type.
|
||||
uint64 recvd = 0;
|
||||
uint bits;
|
||||
if (_Type == TEXT)
|
||||
bits = 32;
|
||||
else if (_Type <= I64)
|
||||
bits = _Type;
|
||||
else
|
||||
bits = _Type - 64;
|
||||
f.serial(recvd, bits);
|
||||
|
||||
|
||||
// if the DB update is older than last DB update, abort (but after the read!!)
|
||||
//if(gc<_LastChangeGC)
|
||||
// return;
|
||||
|
||||
// bkup _oldProperty
|
||||
//_oldProperty = _Property;
|
||||
|
||||
// setup new one
|
||||
//_Property = (sint64)recvd;
|
||||
|
||||
// if signed
|
||||
/*if (! ((_Type == TEXT) || (_Type <= I64)))
|
||||
{
|
||||
// extend bit sign
|
||||
sint64 mask = (((sint64)1)<<bits)-(sint64)1;
|
||||
if( (_Property >> (bits-1))==1 )
|
||||
{
|
||||
_Property |= ~mask;
|
||||
}
|
||||
}
|
||||
if ( VerboseDatabase )
|
||||
{
|
||||
nlinfo( "CDB: Read value (%u bits) %"NL_I64"d", bits, _Property );
|
||||
}*/
|
||||
|
||||
// bkup the date of change
|
||||
//_LastChangeGC= gc;
|
||||
|
||||
//notifyObservers();
|
||||
|
||||
}
|
||||
else
|
||||
nlwarning("CCDBNodeLeaf::readDelta : Property Type Unknown ('%d') -> not serialized.", (uint)_Type);
|
||||
}// readDelta //
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// resetData
|
||||
//-----------------------------------------------
|
||||
void CCDBNodeLeaf::resetData(NLMISC::TGameCycle gc)
|
||||
{
|
||||
// Apply only if happens after the DB change
|
||||
/*if(gc>=_LastChangeGC)
|
||||
{
|
||||
_LastChangeGC= gc;
|
||||
setValue64(0);
|
||||
}*/
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
// getProp
|
||||
//
|
||||
//-----------------------------------------------
|
||||
sint64 CCDBNodeLeaf::getProp( CTextId& id )
|
||||
{
|
||||
// assert that there are no lines left in the textid
|
||||
nlassert( id.getCurrentIndex() == id.size() );
|
||||
|
||||
// Return the property value.
|
||||
return getValue64();
|
||||
} // getProp //
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// setProp
|
||||
// Set the value of a property (the update flag is set to true)
|
||||
// \param id is the text id of the property/grp
|
||||
// \param name is the name of the property
|
||||
// \param value is the value of the property
|
||||
// \return bool : 'false' if id is too long.
|
||||
//-----------------------------------------------
|
||||
bool CCDBNodeLeaf::setProp( CTextId& id, sint64 value )
|
||||
{
|
||||
// assert that there are no lines left in the textid
|
||||
if(id.getCurrentIndex() != id.size())
|
||||
return false;
|
||||
|
||||
// Set the property value (and set "_Changed" flag with 'true');
|
||||
CCDBNodeLeaf::setValue64(value);
|
||||
|
||||
// Done
|
||||
return true;
|
||||
}// setProp //
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// setPropCheckGC
|
||||
//-----------------------------------------------
|
||||
/*void CCDBNodeLeaf::setPropCheckGC(NLMISC::TGameCycle gc, sint64 value)
|
||||
{
|
||||
// Apply only if happens after the DB change
|
||||
if(gc>=_LastChangeGC)
|
||||
{
|
||||
// new recent date
|
||||
_LastChangeGC= gc;
|
||||
|
||||
// Set the property value (and set "_Changed" flag with 'true');
|
||||
CCDBNodeLeaf::setValue64(value);
|
||||
}
|
||||
}*/
|
||||
|
||||
//-----------------------------------------------
|
||||
// clear
|
||||
//
|
||||
//-----------------------------------------------
|
||||
void CCDBNodeLeaf::clear()
|
||||
{
|
||||
|
||||
} // clear //
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
//-----------------------------------------------
|
||||
void CCDBNodeLeaf::setValue64(sint64 prop)
|
||||
{
|
||||
if (_Property != prop)
|
||||
{
|
||||
// if (!_Changed)
|
||||
// {
|
||||
// _Changed = true;
|
||||
// }
|
||||
//
|
||||
// _oldProperty = _Property;
|
||||
_Property = prop;
|
||||
// notify observer
|
||||
//notifyObservers();
|
||||
}
|
||||
}
|
||||
|
||||
void CCDBNodeLeaf::setValue32(sint32 prop)
|
||||
{
|
||||
sint64 newVal = (sint64)prop;
|
||||
setValue64(newVal);
|
||||
}
|
||||
|
||||
void CCDBNodeLeaf::setValue16(sint16 prop)
|
||||
{
|
||||
sint64 newVal = (sint64)prop;
|
||||
setValue64(newVal);
|
||||
|
||||
}
|
||||
|
||||
void CCDBNodeLeaf::setValue8(sint8 prop)
|
||||
{
|
||||
sint64 newVal = (sint64)prop;
|
||||
setValue64(newVal);
|
||||
}
|
||||
|
||||
void CCDBNodeLeaf::setValueBool(bool prop)
|
||||
{
|
||||
sint64 newVal = (sint64)prop;
|
||||
setValue64(newVal);
|
||||
}
|
||||
|
||||
void CCDBNodeLeaf::display(const std::string &prefix)
|
||||
{
|
||||
nlinfo("%sL %s", prefix.c_str(), _DBSM->localUnmap(_Name).c_str());
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
// addObserver
|
||||
//
|
||||
//-----------------------------------------------
|
||||
/*
|
||||
bool CCDBNodeLeaf::addObserver(IPropertyObserver* observer,CTextId& id)
|
||||
{
|
||||
_Observers.push_back(observer);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
//-----------------------------------------------
|
||||
// removeObserver
|
||||
//
|
||||
//-----------------------------------------------
|
||||
/*
|
||||
bool CCDBNodeLeaf::removeObserver(IPropertyObserver* observer, CTextId& id)
|
||||
{
|
||||
std::vector<IPropertyObserver *>::iterator endIt = std::remove(_Observers.begin(), _Observers.end(), observer);
|
||||
if (endIt == _Observers.end()) return false; // no observer has been removed..
|
||||
_Observers.erase(endIt, _Observers.end());
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
//-----------------------------------------------
|
||||
/*void CCDBNodeLeaf::notifyObservers()
|
||||
{
|
||||
std::vector<IPropertyObserver*> obs = _Observers;
|
||||
// notify observer
|
||||
for (std::vector<IPropertyObserver*>::const_iterator it = obs.begin(); it != obs.end(); it++)
|
||||
{
|
||||
(*it)->update(this);
|
||||
}
|
||||
// mark parent branchs
|
||||
if (_Parent)
|
||||
{
|
||||
_Parent->linkInModifiedNodeList();
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef TRACE_READ_DELTA
|
||||
#undef TRACE_READ_DELTA
|
||||
#endif
|
||||
|
||||
#ifdef TRACE_WRITE_DELTA
|
||||
#undef TRACE_WRITE_DELTA
|
||||
#endif
|
||||
|
||||
#ifdef TRACE_SET_VALUE
|
||||
#undef TRACE_SET_VALUE
|
||||
#endif
|
||||
//#############################################################################################
|
||||
|
@ -0,0 +1,247 @@
|
||||
/** \file cdb_leaf.h
|
||||
*
|
||||
* $Id: cdb_leaf.h,v 1.3 2007/07/27 15:14:50 cado Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef CDB_LEAF_H
|
||||
#define CDB_LEAF_H
|
||||
|
||||
#include "cdb.h"
|
||||
#include "cdb_branch.h"
|
||||
#include "nel/misc/time_nl.h"
|
||||
|
||||
/**
|
||||
* Database node which contains a unique property
|
||||
* \author Stephane Coutelas
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CCDBNodeLeaf : public ICDBNode
|
||||
{
|
||||
public:
|
||||
// flush all observers calls for modified nodes
|
||||
static void flushObserversCalls();
|
||||
|
||||
|
||||
/// Return the value of the property.
|
||||
inline sint64 getValue64() { return _Property; }
|
||||
|
||||
/// Set the value of the property (set '_Changed' flag with 'true').
|
||||
void setValue64 (sint64 prop);
|
||||
|
||||
inline sint32 getValue32() { return *((sint32*)&_Property); }
|
||||
void setValue32 (sint32 prop);
|
||||
inline sint16 getValue16() { return *((sint16*)&_Property); }
|
||||
void setValue16 (sint16 prop);
|
||||
inline sint8 getValue8() { return *((sint8*)&_Property); }
|
||||
void setValue8 (sint8 prop);
|
||||
inline bool getValueBool() { return (_Property!=(sint64)0 ); }
|
||||
void setValueBool (bool prop);
|
||||
|
||||
/// Return the value of the property before the database change
|
||||
inline sint64 getOldValue64() { return 0; } //{ return _oldProperty; }
|
||||
inline sint32 getOldValue32() { return 0; } //{ return *((sint32*)&_oldProperty); }
|
||||
inline sint16 getOldValue16() { return 0; } //{ return *((sint16*)&_oldProperty); }
|
||||
inline sint8 getOldValue8() { return 0; } //{ return *((sint8*)&_oldProperty); }
|
||||
inline bool getOldValueBool() { return 0; } //{ return (_oldProperty!=(sint64)0 ); }
|
||||
|
||||
|
||||
/// Return the type of the property.
|
||||
inline const EPropType &type() const {return _Type;}
|
||||
|
||||
/// Set the property Type.
|
||||
inline void type(const EPropType &t) {_Type = t;}
|
||||
|
||||
/// Return 'true' if the property changed since last call.
|
||||
//inline const bool &changed() const {return _Changed;}
|
||||
|
||||
/// Set the property flag to known if the property changed since last call.
|
||||
//inline void changed(const bool &c) {_Changed = c;}
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
CCDBNodeLeaf(const std::string &name) : ICDBNode(name)
|
||||
{
|
||||
_Parent=0;
|
||||
//_Property = 0;
|
||||
//_oldProperty = 0;
|
||||
//_Type = UNKNOWN;
|
||||
//_Changed = false;
|
||||
//_LastChangeGC = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the structure of the database from a file
|
||||
* \param f is the stream
|
||||
*/
|
||||
void init( xmlNodePtr node, NLMISC::IProgressCallback &progressCallBack, bool mapBanks=false );
|
||||
|
||||
/**
|
||||
* Get a node
|
||||
* \param ids is the list of property index
|
||||
* \param idx is the property index of the current node(updated by the method)
|
||||
*/
|
||||
ICDBNode * getNode( std::vector<uint16>& ids, uint idx );
|
||||
|
||||
/**
|
||||
* Get a node
|
||||
* \param idx is the node index
|
||||
*/
|
||||
ICDBNode * getNode( uint16 idx );
|
||||
|
||||
/**
|
||||
* Get a node . Create it if it does not exist yet
|
||||
* \param id : the CTextId identifying the node
|
||||
*/
|
||||
ICDBNode * getNode (const CTextId& id, bool bCreate);
|
||||
|
||||
/**
|
||||
* Get a node index
|
||||
* \param node is a pointer to the node
|
||||
*/
|
||||
virtual bool getNodeIndex( ICDBNode* node , uint& index)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a backup of the database
|
||||
* \param id is the text id of the property/grp
|
||||
* \param f is the stream
|
||||
*/
|
||||
//void write( CTextId& id, FILE * f);
|
||||
|
||||
/**
|
||||
* Update the database from a stream coming from the FE
|
||||
* \param f : the stream.
|
||||
*/
|
||||
void readDelta(NLMISC::TGameCycle gc, NLMISC::CBitMemStream & f );
|
||||
|
||||
/**
|
||||
* Return the value of a property (the update flag is set to false)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \return the structure of the property
|
||||
*/
|
||||
sint64 getProp( CTextId& id );
|
||||
|
||||
/**
|
||||
* Set the value of a property (the update flag is set to true)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \param value is the value of the property
|
||||
* \return bool : 'false' if id is too long.
|
||||
*/
|
||||
bool setProp( CTextId& id, sint64 value );
|
||||
|
||||
/**
|
||||
* Set the value of a property, only if gc>=_LastChangeGC
|
||||
*/
|
||||
//void setPropCheckGC(NLMISC::TGameCycle gc, sint64 value);
|
||||
|
||||
/// Reset all leaf data from this point
|
||||
void resetData(NLMISC::TGameCycle gc);
|
||||
|
||||
/**
|
||||
* Clear the node and his children
|
||||
*/
|
||||
void clear();
|
||||
|
||||
|
||||
// the parent node for a branch (NULL by default)
|
||||
virtual void setParent(CCDBNodeBranch* parent) { _Parent=parent; }
|
||||
|
||||
//get the node parent
|
||||
virtual CCDBNodeBranch *getParent()
|
||||
{
|
||||
return _Parent;
|
||||
}
|
||||
|
||||
/// Count the leaves
|
||||
virtual uint countLeaves() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// Find the leaf which count is specified (if found, the returned value is non-null and count is 0)
|
||||
virtual CCDBNodeLeaf *findLeafAtCount( uint& count )
|
||||
{
|
||||
if ( count == 0 )
|
||||
return this;
|
||||
else
|
||||
{
|
||||
--count;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/// Debug purpose
|
||||
virtual void display(const std::string &prefix);
|
||||
|
||||
|
||||
virtual bool isLeaf() const { return true; }
|
||||
|
||||
/**
|
||||
* add an observer to a property
|
||||
* \param observer : pointer to an observer
|
||||
* \param id text id identifying the property
|
||||
* \return false if the node doen t exist
|
||||
*/
|
||||
//virtual bool addObserver(IPropertyObserver* observer, CTextId& id);
|
||||
|
||||
/** remove an obsever
|
||||
* \param observer : pointer to an observer
|
||||
* \param id text id identifying the property
|
||||
* \return false if the node or observer doesn t exist
|
||||
*/
|
||||
//virtual bool removeObserver(IPropertyObserver* observer, CTextId& id);
|
||||
|
||||
|
||||
/// get the last change GameCycle (server tick) for this value
|
||||
//NLMISC::TGameCycle getLastChangeGC() const {return _LastChangeGC;}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
CCDBNodeBranch * _Parent;
|
||||
|
||||
/// property value
|
||||
sint64 _Property;
|
||||
//sint64 _oldProperty;
|
||||
|
||||
/// property type
|
||||
EPropType _Type;
|
||||
|
||||
/// true if this value has changed
|
||||
//bool _Changed;
|
||||
|
||||
/// gamecycle (servertick) of the last change for this value.
|
||||
/// change are made in readDelta only for change >= _LastChangeGC
|
||||
//NLMISC::TGameCycle _LastChangeGC;
|
||||
|
||||
/// observers to call when the value really change
|
||||
//std::vector<IPropertyObserver*> _Observers;
|
||||
|
||||
private:
|
||||
//void notifyObservers();
|
||||
|
||||
};
|
||||
|
||||
////////////////////
|
||||
// INLINE MEMBERS //
|
||||
////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // CDB_LEAF_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,239 @@
|
||||
/** \file cdb_synchronised.cpp
|
||||
* <File description>
|
||||
*
|
||||
* $Id: cdb_synchronised.cpp,v 1.1 2005/09/19 09:50:17 boucher Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//#include "stdpch.h"
|
||||
|
||||
//#define TRACE_READ_DELTA
|
||||
//#define TRACE_WRITE_DELTA
|
||||
//#define TRACE_SET_VALUE
|
||||
|
||||
|
||||
//////////////
|
||||
// Includes //
|
||||
//////////////
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/debug.h"
|
||||
#include "nel/misc/file.h"
|
||||
#include "nel/misc/i_xml.h"
|
||||
#include "nel/misc/bit_mem_stream.h"
|
||||
|
||||
#include "cdb_synchronised.h"
|
||||
#include "../client/dummy_progress.h"
|
||||
|
||||
#include <iostream.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
////////////////
|
||||
// Namespaces //
|
||||
////////////////
|
||||
using namespace NLMISC;
|
||||
using namespace std;
|
||||
|
||||
|
||||
bool VerboseDatabase = false;
|
||||
uint32 NbDatabaseChanges = 0;
|
||||
|
||||
extern CDummyProgress progressCallback;
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// CCDBSynchronised
|
||||
//
|
||||
//-----------------------------------------------
|
||||
CCDBSynchronised::CCDBSynchronised() : _Database(0), _InitInProgress(true), _InitDeltaReceived(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// init
|
||||
//
|
||||
//-----------------------------------------------
|
||||
void CCDBSynchronised::init( const string &fileName, NLMISC::IProgressCallback &progressCallBack )
|
||||
{
|
||||
try
|
||||
{
|
||||
CIFile file;
|
||||
if (file.open (fileName))
|
||||
{
|
||||
// Init an xml stream
|
||||
CIXml read;
|
||||
read.init (file);
|
||||
|
||||
//Parse the parser output!!!
|
||||
CCDBNodeBranch::resetNodeBankMapping(); // in case the game is restarted from start
|
||||
_Database = new CCDBNodeBranch("SERVER");
|
||||
_Database->init( read.getRootNode (), progressCallBack, true );
|
||||
}
|
||||
}
|
||||
catch (Exception &e)
|
||||
{
|
||||
// Output error
|
||||
nlwarning ("CFormLoader: Error while loading the form %s: %s", fileName.c_str(), e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// readDelta
|
||||
//
|
||||
//-----------------------------------------------
|
||||
void CCDBSynchronised::readDelta( NLMISC::TGameCycle gc, CBitMemStream& s, TCDBBank bank )
|
||||
{
|
||||
nldebug("Update DB");
|
||||
|
||||
if( _Database == 0 )
|
||||
{
|
||||
nlwarning("<CCDBSynchronised::readDelta> the database has not been initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
//displayBitStream2( f, f.getPosInBit(), f.getPosInBit() + 64 );
|
||||
uint16 propertyCount = 0;
|
||||
s.serial( propertyCount );
|
||||
|
||||
if ( VerboseDatabase )
|
||||
nlinfo( "CDB: Reading delta (%hu changes)", propertyCount );
|
||||
NbDatabaseChanges += propertyCount;
|
||||
|
||||
for( uint i=0; i!=propertyCount; ++i )
|
||||
{
|
||||
_Database->readAndMapDelta( gc, s, bank );
|
||||
}
|
||||
|
||||
/*// Read "client only" property changes
|
||||
bool hasCOPropChanges;
|
||||
s.serialBit( hasCOPropChanges );
|
||||
if ( hasCOPropChanges )
|
||||
{
|
||||
uint32 nbCOPropChanges;
|
||||
s.serial( nbCOPropChanges, 4 );
|
||||
if ( nbCOPropChanges == 15 )
|
||||
{
|
||||
s.serial( nbCOPropChanges );
|
||||
}
|
||||
for ( uint i=0; i!=nbCOPropChanges; ++i )
|
||||
{
|
||||
string propName; //TEMP
|
||||
sint64 value; //TEMP
|
||||
s.serial( propName );
|
||||
s.serial( value );
|
||||
setProp( propName, value );
|
||||
}
|
||||
}*/
|
||||
|
||||
} // readDelta //
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// getProp
|
||||
//
|
||||
//-----------------------------------------------
|
||||
sint64 CCDBSynchronised::getProp( const string &name )
|
||||
{
|
||||
if( _Database != 0 )
|
||||
{
|
||||
ICDBNode::CTextId txtId( name );
|
||||
return _Database->getProp( txtId );
|
||||
}
|
||||
else
|
||||
throw CCDBSynchronised::EDBNotInit();
|
||||
} // getProp //
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// setProp
|
||||
// Set the value of a property (the update flag is set to true)
|
||||
// \param name is the name of the property
|
||||
// \param value is the value of the property
|
||||
// \return bool : 'true' if the property was found.
|
||||
//-----------------------------------------------
|
||||
bool CCDBSynchronised::setProp(const string &name, sint64 value)
|
||||
{
|
||||
if(_Database == 0)
|
||||
{
|
||||
nlwarning("<CCDBSynchronised::setProp> the database has not been initialized");
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef TRACE_SET_VALUE
|
||||
nlinfo("Set value %"NL_I64"d for Prop %s", value,name.c_str() );
|
||||
#endif
|
||||
|
||||
// Set the property.
|
||||
ICDBNode::CTextId txtId( name );
|
||||
return _Database->setProp( txtId, value );
|
||||
} // setProp //
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// getString
|
||||
//
|
||||
//-----------------------------------------------
|
||||
string CCDBSynchronised::getString( uint32 id )
|
||||
{
|
||||
map<uint32,string>::iterator itStr = _Strings.find( id );
|
||||
if( itStr != _Strings.end() )
|
||||
{
|
||||
return (*itStr).second;
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("<CCDBSynchronised::getString> string with id %d was not found",id);
|
||||
return "";
|
||||
}
|
||||
} // getString //
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// setString
|
||||
//
|
||||
//-----------------------------------------------
|
||||
void CCDBSynchronised::setString( uint32 id, const std::string &str )
|
||||
{
|
||||
_Strings[id]=str;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// clear
|
||||
//
|
||||
//-----------------------------------------------
|
||||
void CCDBSynchronised::clear()
|
||||
{
|
||||
if(_Database)
|
||||
{
|
||||
_Database->clear();
|
||||
delete _Database;
|
||||
_Database = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef TRACE_READ_DELTA
|
||||
#undef TRACE_READ_DELTA
|
||||
#endif
|
||||
|
||||
#ifdef TRACE_WRITE_DELTA
|
||||
#undef TRACE_WRITE_DELTA
|
||||
#endif
|
||||
|
||||
#ifdef TRACE_SET_VALUE
|
||||
#undef TRACE_SET_VALUE
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,137 @@
|
||||
/** \file cdb_synchronised.h
|
||||
*
|
||||
* $Id: cdb_synchronised.h,v 1.1 2005/09/19 09:50:17 boucher Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef CDB_SYNCHRONISED_H
|
||||
#define CDB_SYNCHRONISED_H
|
||||
|
||||
|
||||
#include "cdb.h"
|
||||
#include "cdb_branch.h"
|
||||
|
||||
/**
|
||||
* Class to manage a database of properties
|
||||
* \author Stephane Coutelas
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CCDBSynchronised
|
||||
{
|
||||
/// database
|
||||
NLMISC::CRefPtr<CCDBNodeBranch> _Database;
|
||||
|
||||
/// string associations
|
||||
std::map<uint32,std::string> _Strings;
|
||||
|
||||
/// True while the first database packet has not been completely processed (including branch observers)
|
||||
bool _InitInProgress;
|
||||
|
||||
/// The number of "init database packet" received
|
||||
uint8 _InitDeltaReceived;
|
||||
|
||||
public:
|
||||
|
||||
/// exception thrown when database is not initialized
|
||||
struct EDBNotInit : public NLMISC::Exception
|
||||
{
|
||||
EDBNotInit() : Exception ("Property Database not initialized") {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
CCDBSynchronised();
|
||||
|
||||
/**
|
||||
* Return a ptr on the node
|
||||
* \return ptr on the node
|
||||
*/
|
||||
CCDBNodeBranch * getNodePtr() { return _Database; }
|
||||
|
||||
/**
|
||||
* Build the structure of the database from a file
|
||||
* \param fileName is the name of file containing the database structure
|
||||
*/
|
||||
void init( const std::string &fileName, class NLMISC::IProgressCallback &progressCallBack );
|
||||
|
||||
/**
|
||||
* Update the database from a stream coming from the FE
|
||||
* \param f the stream
|
||||
*/
|
||||
void readDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream& s, TCDBBank bank );
|
||||
|
||||
/**
|
||||
* Return the value of a property (the update flag is set to false)
|
||||
* \param name is the name of the property
|
||||
* \return the value of the property
|
||||
*/
|
||||
sint64 getProp( const std::string &name );
|
||||
|
||||
/**
|
||||
* Set the value of a property (the update flag is set to true)
|
||||
* \param name is the name of the property
|
||||
* \param value is the value of the property
|
||||
* \return bool : 'true' if the property was found.
|
||||
*/
|
||||
bool setProp(const std::string &name, sint64 value);
|
||||
|
||||
/**
|
||||
* Return the string associated with id
|
||||
* \param id is the string id
|
||||
* \return the string
|
||||
*/
|
||||
std::string getString( uint32 id );
|
||||
|
||||
/**
|
||||
* Set a new string association
|
||||
* \param id is the string id
|
||||
* \param str is the new string
|
||||
*/
|
||||
void setString( uint32 id, const std::string &);
|
||||
|
||||
/**
|
||||
* Clear the database
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~CCDBSynchronised() { clear(); }
|
||||
|
||||
/// Return true while the first database packet has not been completely received
|
||||
bool initInProgress() const { return _InitInProgress; }
|
||||
|
||||
/// tests
|
||||
void test();
|
||||
|
||||
/// Reset the init state (if you relauch the game from scratch)
|
||||
void resetInitState() { _InitDeltaReceived = 0; _InitInProgress = true; }
|
||||
|
||||
/// Called after flushObserversCalls() as it calls the observers for branches
|
||||
void setChangesProcessed()
|
||||
{
|
||||
if ( allInitPacketReceived() )
|
||||
_InitInProgress = false;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
friend void impulseDatabaseInitPlayer( NLMISC::CBitMemStream &impulse );
|
||||
friend void impulseInitInventory( NLMISC::CBitMemStream &impulse );
|
||||
|
||||
void setInitPacketReceived() { ++_InitDeltaReceived; }
|
||||
bool allInitPacketReceived() const { return _InitDeltaReceived == 2; } // Classic database + inventory
|
||||
};
|
||||
|
||||
|
||||
#endif // CDB_SYNCHRONISED_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,576 @@
|
||||
/** \file client_cfg.cpp
|
||||
* <File description>
|
||||
*
|
||||
* $Id: client_cfg.cpp,v 1.4 2007/07/27 15:14:50 cado Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////
|
||||
// INCLUDE //
|
||||
/////////////
|
||||
//#include "stdpch.h"
|
||||
// Misc.
|
||||
#include "nel/misc/config_file.h"
|
||||
#include "nel/misc/bit_mem_stream.h"
|
||||
#include "nel/misc/hierarchical_timer.h"
|
||||
// Client.
|
||||
#include "client_cfg.h"
|
||||
//#include "entities.h"
|
||||
//#include "debug_client.h"
|
||||
// Game Share.
|
||||
#include "game_share/time_weather_season/time_and_season.h"
|
||||
#include "game_share/ryzom_version.h"
|
||||
|
||||
///////////
|
||||
// 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 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)
|
||||
#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)
|
||||
#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)
|
||||
|
||||
///////////
|
||||
// USING //
|
||||
///////////
|
||||
using namespace NLMISC;
|
||||
|
||||
|
||||
////////////
|
||||
// GLOBAL //
|
||||
////////////
|
||||
CClientConfig LastClientCfg;
|
||||
CClientConfig ClientCfg;
|
||||
//const string ConfigFileName = "client.cfg";
|
||||
|
||||
|
||||
////////////
|
||||
// EXTERN //
|
||||
////////////
|
||||
extern CRyzomTime RT;
|
||||
//extern string Cookie, FSAddr;
|
||||
|
||||
/////////////
|
||||
// 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() : R2Mode(true)
|
||||
{
|
||||
CConfigFile::setTimeout( 2000 );
|
||||
IsInvalidated = false;
|
||||
CreateOnMainland = 0;
|
||||
SelectCharacter = -1; // Default is no auto select
|
||||
FSHost = ""; // Default Host.
|
||||
NbConnections = 0;
|
||||
//ForceDeltaTime = 0; // Default ForceDeltaTime, disabled by default
|
||||
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
|
||||
//IdFilePath = "sheet_id.bin";
|
||||
//Sleep = -1; // Default : client does not sleep.
|
||||
//ProcessPriority = 0; // Default : NORMAL
|
||||
//UserSheet = "fyros.race_stats"; // Default sheet used.
|
||||
//AttackDist = 0.5f;
|
||||
//RyzomDay = 0;
|
||||
//RyzomTime = 0.0f;
|
||||
//ChangeDirAngle = 1.70f; // Default Angle.
|
||||
//SelectionDist = 150.f; // Default dist in meter.
|
||||
//LootDist = 4.f; // Default loot/harvest distance (in meter).
|
||||
//ForceLanguage = false;
|
||||
LanguageCode = "en"; // Default to english
|
||||
//DebugStringManager = false; // Default to no debug
|
||||
VerboseVP = false;
|
||||
VerboseAllTraffic = false;
|
||||
//DefaultEntity = "ccafb1.creature";
|
||||
RestrainPI = true;
|
||||
//DumpVSIndex = false;
|
||||
Check = false;
|
||||
//FPExceptions = false; // Disable Floating Point Exceptions.
|
||||
//NeedComputeVS = false; // Do not need to compute Visual Slots.
|
||||
AutoReloadFiles = false;
|
||||
//SimulateServerTick = false;
|
||||
SimulatePacketLossRatio= 0;
|
||||
//LogMemoryAllocation=false;
|
||||
//LogMemoryAllocationSize=8;
|
||||
// RequestQuit = 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;
|
||||
|
||||
READ_INT_DEV(CreateOnMainland);
|
||||
READ_INT_DEV(SelectCharacter);
|
||||
|
||||
// FSHost
|
||||
READ_STRING_FV(FSHost)
|
||||
READ_INT_DEV(NbConnections);
|
||||
// READ_INT_DEV(RequestQuit);
|
||||
|
||||
//////////
|
||||
// MISC //
|
||||
// Pre Data Path.
|
||||
/*try
|
||||
{
|
||||
CConfigFile::CVar &cvPreDataPath = ClientCfg.ConfigFile.getVar("PreDataPath");
|
||||
ClientCfg.PreDataPath.clear ();
|
||||
for (sint i = 0; i < cvPreDataPath.size(); i++)
|
||||
ClientCfg.PreDataPath.push_back(cvPreDataPath.asString(i));
|
||||
}
|
||||
catch(EUnknownVar &) {cfgWarning("Default value used for 'PreDataPath' !!!");}*/
|
||||
|
||||
// Data Path.
|
||||
try
|
||||
{
|
||||
CConfigFile::CVar &cvDataPath = ClientCfg.ConfigFile.getVar("DataPath");
|
||||
ClientCfg.DataPath.clear ();
|
||||
for (sint i = 0; i < cvDataPath.size(); i++)
|
||||
ClientCfg.DataPath.push_back(cvDataPath.asString(i));
|
||||
}
|
||||
catch(EUnknownVar &) {cfgWarning("Default value used for 'DataPath' !!!");}
|
||||
|
||||
// Data Path no recurse.
|
||||
try
|
||||
{
|
||||
CConfigFile::CVar &cvDataPathNoRecurse = ClientCfg.ConfigFile.getVar("DataPathNoRecurse");
|
||||
ClientCfg.DataPathNoRecurse.clear ();
|
||||
for (sint i = 0; i < cvDataPathNoRecurse.size(); i++)
|
||||
ClientCfg.DataPathNoRecurse.push_back(cvDataPathNoRecurse.asString(i));
|
||||
}
|
||||
catch(EUnknownVar &) {cfgWarning("Default value used for 'DataPathNoRecurse' !!!");}
|
||||
|
||||
{
|
||||
H_AUTO(InitRZAddSearchPath2)
|
||||
uint i;
|
||||
for (i = 0; i < ClientCfg.DataPath.size(); i++)
|
||||
{
|
||||
CPath::addSearchPath(ClientCfg.DataPath[i], true, false);
|
||||
}
|
||||
for (i = 0; i < ClientCfg.DataPathNoRecurse.size(); i++)
|
||||
{
|
||||
CPath::addSearchPath(ClientCfg.DataPathNoRecurse[i], false, false);
|
||||
}
|
||||
}
|
||||
|
||||
READ_BOOL_DEV(VerboseVP)
|
||||
READ_BOOL_DEV(VerboseAllTraffic)
|
||||
|
||||
READ_BOOL_DEV(RestrainPI)
|
||||
READ_BOOL_DEV(Check)
|
||||
READ_INT_DEV(SimulatePacketLossRatio)
|
||||
|
||||
READ_BOOL_FV(AutoReloadFiles)
|
||||
|
||||
// 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, bkup the ClientCfg into LastClientCfg
|
||||
if(firstTimeSetValues)
|
||||
LastClientCfg = ClientCfg;
|
||||
|
||||
// no more true.
|
||||
firstTimeSetValues= false;
|
||||
|
||||
}// load //
|
||||
|
||||
|
||||
static const char* NegFiltersNames[] =
|
||||
{
|
||||
"NegFiltersDebug",
|
||||
"NegFiltersInfo",
|
||||
"NegFiltersWarning",
|
||||
"NegFiltersAssert",
|
||||
"NegFiltersError",
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
void cbLogFilter (CConfigFile::CVar &var)
|
||||
{
|
||||
CLog *log = NULL;
|
||||
if (var.Name == "NegFiltersDebug")
|
||||
{
|
||||
log = DebugLog;
|
||||
}
|
||||
else if (var.Name == "NegFiltersInfo")
|
||||
{
|
||||
log = InfoLog;
|
||||
}
|
||||
else if (var.Name == "NegFiltersWarning")
|
||||
{
|
||||
log = WarningLog;
|
||||
}
|
||||
else if (var.Name == "NegFiltersAssert")
|
||||
{
|
||||
log = AssertLog;
|
||||
}
|
||||
else if (var.Name == "NegFiltersError")
|
||||
{
|
||||
log = ErrorLog;
|
||||
}
|
||||
else
|
||||
{
|
||||
nlstop;
|
||||
}
|
||||
|
||||
nlinfo ("Updating %s from config file", var.Name.c_str());
|
||||
|
||||
// remove all old filters from config file
|
||||
CConfigFile::CVar &oldvar = ClientCfg.ConfigFile.getVar (var.Name);
|
||||
for (sint j = 0; j < oldvar.size(); j++)
|
||||
{
|
||||
log->removeFilter (oldvar.asString(j).c_str());
|
||||
}
|
||||
|
||||
// add all new filters from config file
|
||||
for (sint i = 0; i < var.size(); i++)
|
||||
{
|
||||
log->addNegativeFilter (var.asString(i).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// init :
|
||||
//-----------------------------------------------
|
||||
void CClientConfig::init(const string &configFileName)
|
||||
{
|
||||
if(!CFile::fileExists(configFileName))
|
||||
nlwarning("CFG::init: '%s' Not Found !!!", configFileName.c_str ());
|
||||
|
||||
// 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 *var = NULL;
|
||||
for(const char **name = NegFiltersNames; *name; name++)
|
||||
{
|
||||
if ((var = ClientCfg.ConfigFile.getVarPtr (*name)) != NULL)
|
||||
{
|
||||
ClientCfg.ConfigFile.setCallback (*name, cbLogFilter);
|
||||
cbLogFilter(*var);
|
||||
}
|
||||
}
|
||||
|
||||
}// init //
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// init :
|
||||
//-----------------------------------------------
|
||||
void CClientConfig::release ()
|
||||
{
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
CConfigFile::CVar *varPtr = ConfigFile.getVarPtr(varName);
|
||||
if(varPtr)
|
||||
varPtr->forceAsInt(bVal);
|
||||
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)
|
||||
{
|
||||
CConfigFile::CVar *varPtr = 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 bVal)
|
||||
{
|
||||
CConfigFile::CVar *varPtr = ConfigFile.getVarPtr(varName);
|
||||
if(varPtr)
|
||||
varPtr->forceAsDouble(bVal);
|
||||
else
|
||||
nlwarning("CFG: Default value used for '%s' !!!",varName.c_str());
|
||||
}
|
||||
|
||||
string CClientConfig::readString (const std::string &varName)
|
||||
{
|
||||
string bVal = 0;
|
||||
CConfigFile::CVar *varPtr = ConfigFile.getVarPtr(varName);
|
||||
if(varPtr)
|
||||
bVal = varPtr->asString();
|
||||
else
|
||||
nlwarning("CFG: Default value used for '%s' !!!",varName.c_str());
|
||||
return bVal;
|
||||
}
|
||||
|
||||
void CClientConfig::writeString (const std::string &varName, const std::string &bVal)
|
||||
{
|
||||
CConfigFile::CVar *varPtr = ConfigFile.getVarPtr(varName);
|
||||
if(varPtr)
|
||||
varPtr->forceAsString(bVal);
|
||||
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;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
//string CClientConfig::getHtmlLanguageCode() const
|
||||
//{
|
||||
//if(LanguageCode=="wk")
|
||||
// return "en";
|
||||
//else
|
||||
// return LanguageCode;
|
||||
//}
|
@ -0,0 +1,180 @@
|
||||
/** \file client_cfg.h
|
||||
* <File description>
|
||||
*
|
||||
* $Id: client_cfg.h,v 1.4 2007/07/27 15:14:50 cado Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef CL_CLIENT_CFG_H
|
||||
#define CL_CLIENT_CFG_H
|
||||
|
||||
|
||||
//////////////
|
||||
// Includes //
|
||||
//////////////
|
||||
// Misc.
|
||||
#include "nel/misc/types_nl.h"
|
||||
//#include "nel/misc/vector.h"
|
||||
#include "nel/misc/config_file.h"
|
||||
// std.
|
||||
#include <string>
|
||||
// Game Share
|
||||
#include "game_share/gender.h"
|
||||
|
||||
|
||||
///////////
|
||||
// Using //
|
||||
///////////
|
||||
//using NLMISC::CVector;
|
||||
using std::string;
|
||||
|
||||
|
||||
//---------------------------------------------------
|
||||
// CClientConfig :
|
||||
// Struct to manage a config file for the client.
|
||||
//---------------------------------------------------
|
||||
struct CClientConfig
|
||||
{
|
||||
// the config file must be always be available
|
||||
NLMISC::CConfigFile ConfigFile;
|
||||
|
||||
bool R2Mode;
|
||||
|
||||
void init (const string &configFileName);
|
||||
bool IsInvalidated;
|
||||
|
||||
// Session id of mainland where to create new chars
|
||||
sint CreateOnMainland;
|
||||
/// Select character automatically (dont go to create perso) (-1 if no auto select)
|
||||
sint SelectCharacter;
|
||||
/// Host.
|
||||
string FSHost;
|
||||
/// Number of simulated clients
|
||||
uint NbConnections;
|
||||
/// Time inputs
|
||||
//uint ForceDeltaTime; // 0 to use real delta time
|
||||
/// Pre Data Path.
|
||||
//std::vector<string> PreDataPath;
|
||||
/// Data Path.
|
||||
std::vector<string> DataPath;
|
||||
/// Data Path no recurse.
|
||||
std::vector<string> DataPathNoRecurse;
|
||||
/// Update packed sheet Path.
|
||||
//std::vector<string> UpdatePackedSheetPath;
|
||||
/// True if we want the packed sheet to be updated if needed
|
||||
//bool UpdatePackedSheet;
|
||||
/// Path for the Id file.
|
||||
//string IdFilePath;
|
||||
/// Vector with some entities to spawn at the beginning.
|
||||
//std::vector<string> StartCommands;
|
||||
/// Prim file to load
|
||||
//std::vector<string> PrimFiles;
|
||||
/// To force the client to sleep a bit (in ms).
|
||||
//sint Sleep;
|
||||
/// Force process priority
|
||||
//sint ProcessPriority;
|
||||
/// The Sheet used by the user.
|
||||
//std::string UserSheet;
|
||||
/// Distance between 2 attackers.
|
||||
//float AttackDist;
|
||||
/// Change the direction once this angle is reached.
|
||||
//double ChangeDirAngle;
|
||||
/// Distance Maximum to be able to select an entity.
|
||||
//float SelectionDist;
|
||||
/// Distance Maximum to be able to loot/harvest a corpse.
|
||||
//float LootDist;
|
||||
bool VerboseVP;
|
||||
bool VerboseAllTraffic;
|
||||
// LIGO //
|
||||
//std::string LigoPrimitiveClass;
|
||||
// Default creature spawned when the entity do not exist
|
||||
//std::string DefaultEntity;
|
||||
// Restrain the predicted interval
|
||||
bool RestrainPI;
|
||||
// Dump Visual Slot IDs.
|
||||
//bool DumpVSIndex;
|
||||
// Font size for Help infos.
|
||||
// Enable/disable Floating Point Exceptions
|
||||
//bool FPExceptions;
|
||||
// Use to launch exceptions when there is something wrong
|
||||
bool Check;
|
||||
// Use PACS collision for all (Work In Progress).
|
||||
//bool UsePACSForAll;
|
||||
|
||||
//float ImpactTriggerTime;
|
||||
//bool NeedComputeVS;
|
||||
//bool ForceLanguage;
|
||||
std::string LanguageCode;
|
||||
//bool DebugStringManager;
|
||||
//bool PreCacheShapes;
|
||||
uint32 SimulatePacketLossRatio;
|
||||
//int CheckMemoryEveryNFrame; // -1 no check (default) else number frame to skip before a memory checking
|
||||
//bool LogMemoryAllocation; // false no log (default) else log each memory allocation in the file "alloc.memlog"
|
||||
//int LogMemoryAllocationSize; // Size of the block to log (default : 8)
|
||||
// Reload config files, teleport list and sheet_id.bin
|
||||
bool AutoReloadFiles;
|
||||
// SimulateServerTick
|
||||
//bool SimulateServerTick;
|
||||
// bool RequestQuit;
|
||||
|
||||
public:
|
||||
/// Constructor.
|
||||
CClientConfig();
|
||||
|
||||
static void setValues (); // Set the values of the ClientCfg instance
|
||||
static void setValuesOnFileChange (); // called when cfg modified
|
||||
|
||||
/// End process
|
||||
void release ();
|
||||
|
||||
bool readBool (const std::string &varName);
|
||||
void writeBool (const std::string &varName, bool val);
|
||||
sint32 readInt (const std::string &varName);
|
||||
void writeInt (const std::string &varName, sint32 val);
|
||||
double readDouble (const std::string &varName);
|
||||
void writeDouble (const std::string &varName, double val);
|
||||
void writeString (const std::string &varName, const std::string &bVal);
|
||||
|
||||
// return 0 / false if not succeed
|
||||
bool readBoolNoWarning (const std::string &varName);
|
||||
sint32 readIntNoWarning (const std::string &varName);
|
||||
double readDoubleNoWarning (const std::string &varName);
|
||||
std::string readString (const std::string &varName);
|
||||
|
||||
// Return LanguageCode but if "wk", then return "en"
|
||||
//string getHtmlLanguageCode() const;
|
||||
|
||||
};// CClientConfig //
|
||||
|
||||
|
||||
////////////
|
||||
// GLOBAL //
|
||||
////////////
|
||||
extern CClientConfig ClientCfg;
|
||||
extern const std::string ConfigFileName;
|
||||
|
||||
#endif // CL_CLIENT_CFG_H
|
||||
|
||||
/* End of client_cfg.h */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,181 @@
|
||||
// client_drone.cpp : Defines the entry point for the application.
|
||||
//
|
||||
|
||||
#include "simulated_client.h"
|
||||
#include "nel/misc/variable.h"
|
||||
#include "nel/net/service.h"
|
||||
#include "client_cfg.h"
|
||||
#include <fstream>
|
||||
#ifdef NL_OS_WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
|
||||
const TTime UpdatePeriod = 100;
|
||||
const TTime ExportPeriod = 2000;
|
||||
|
||||
CVariable<bool> RequestQuit("drone", "RequestQuit", "Set to true to start quiting", false);
|
||||
|
||||
/*
|
||||
* How to compile client_drone on Linux:
|
||||
* . cd code/ryzom/src_v2/client_drone
|
||||
* . ln -s ../client/gateway_fec_transport.cpp
|
||||
* . touch stdpch.h
|
||||
* . ls -1 *.cpp > Objects.mk
|
||||
* Then edit Objects.mk so that it looks like OBJS=obj1.o obj2.o ...
|
||||
* (because 'make update' only generates gateway_fec_transport.o)
|
||||
* . make
|
||||
*/
|
||||
|
||||
class CClientDrone : public NLNET::IService
|
||||
{
|
||||
public:
|
||||
|
||||
//
|
||||
void init(/* uint nbConnections*/ )
|
||||
{
|
||||
ClientCfg.init( "client_drone.cfg" );
|
||||
|
||||
CSheetId::init(false); // allow working without the sheet (only sheet_id.bin is needed)
|
||||
CSimulatedClient::initNetwork();
|
||||
Clients.resize( ClientCfg.NbConnections );
|
||||
for ( uint i=0; i!=Clients.size(); ++i )
|
||||
{
|
||||
Clients[i] = new CSimulatedClient( i );
|
||||
Clients[i]->start();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
bool update()
|
||||
{
|
||||
static uint nbQuit = 0;
|
||||
if ( nbQuit == Clients.size() )
|
||||
return false;
|
||||
|
||||
static TTime tLastExport = 0;
|
||||
TTime t0 = CTime::getLocalTime();
|
||||
if ( t0 - tLastExport >= ExportPeriod )
|
||||
{
|
||||
exportStates();
|
||||
tLastExport = t0;
|
||||
}
|
||||
|
||||
// Check for configuration files update.
|
||||
CConfigFile::checkConfigFiles();
|
||||
|
||||
// Update clients
|
||||
for ( uint i=0; i!=Clients.size(); ++i )
|
||||
{
|
||||
CSimulatedClient::TLoginState loginStateBeforeUpdating = Clients[i]->getCurrentLoginState();
|
||||
bool posInitialized = Clients[i]->UserEntity.isInitialized();
|
||||
|
||||
if ( RequestQuit )
|
||||
Clients[i]->requestQuit();
|
||||
|
||||
if ( loginStateBeforeUpdating < CSimulatedClient::LSQuitting )
|
||||
{
|
||||
if ( ! Clients[i]->update() )
|
||||
{
|
||||
++nbQuit;
|
||||
nldebug("Now %u have quit so far", nbQuit);
|
||||
}
|
||||
}
|
||||
else
|
||||
nldebug("Now updating client %u because quitting", i);
|
||||
|
||||
if ( Clients[i]->getCurrentLoginState() != loginStateBeforeUpdating )
|
||||
nlinfo( "Client %s to state %u", Clients[i]->name().c_str(), Clients[i]->getCurrentLoginState() );
|
||||
if ( Clients[i]->UserEntity.isInitialized() != posInitialized )
|
||||
nlinfo( "Client %s placed at %s", Clients[i]->name().c_str(), Clients[i]->UserEntity.pos().asVector().toString().c_str() );
|
||||
}
|
||||
|
||||
TTime t1 = CTime::getLocalTime();
|
||||
TTime elapsed = t1 - t0;
|
||||
if ( elapsed < UpdatePeriod )
|
||||
nlSleep( (uint32)(UpdatePeriod - elapsed) );
|
||||
t0 = t1;
|
||||
|
||||
if ( RequestQuit )
|
||||
RequestQuit = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
void release()
|
||||
{
|
||||
// Request disconnection
|
||||
nlinfo("Requesting disconnection...");
|
||||
RequestQuit = true;
|
||||
|
||||
// Wait for clean disconnection
|
||||
while ( update() )
|
||||
{
|
||||
nlSleep(100);
|
||||
}
|
||||
|
||||
// Release
|
||||
nlinfo("Releasing...");
|
||||
for ( uint i=0; i!=Clients.size(); ++i )
|
||||
{
|
||||
delete Clients[i];
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//
|
||||
void exportStates()
|
||||
{
|
||||
ofstream f( "client_drone_states.txt" );
|
||||
for ( uint i=0; i!=Clients.size(); ++i )
|
||||
{
|
||||
f << i << ": " << Clients[i]->getCurrentLoginState() << " (" << Clients[i]->UserEntity.pos().asVector().toString().c_str() << ") " << Clients[i]->_NetworkConnection.getMsPerTick() << " ms" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<CSimulatedClient*> Clients;
|
||||
};
|
||||
|
||||
//CClientDrone Drone;
|
||||
|
||||
NLNET::TUnifiedCallbackItem cbArray[1] = { "nop", NULL};
|
||||
|
||||
NLNET_SERVICE_MAIN(CClientDrone, "CDRN", "client_drone", 0, cbArray, "", "");
|
||||
/*
|
||||
*
|
||||
*/
|
||||
//int APIENTRY WinMain(HINSTANCE hInstance,
|
||||
// HINSTANCE hPrevInstance,
|
||||
// LPSTR lpCmdLine,
|
||||
// int nCmdShow)
|
||||
//{
|
||||
// new CApplicationContext;
|
||||
//
|
||||
// // Init
|
||||
// createDebug();
|
||||
// CFileDisplayer *ClientLogDisplayer = new CFileDisplayer("client_drone.log", true, "CLIENT_DRONE.LOG");
|
||||
// DebugLog->addDisplayer (ClientLogDisplayer);
|
||||
// InfoLog->addDisplayer (ClientLogDisplayer);
|
||||
// WarningLog->addDisplayer (ClientLogDisplayer);
|
||||
// ErrorLog->addDisplayer (ClientLogDisplayer);
|
||||
// AssertLog->addDisplayer (ClientLogDisplayer);
|
||||
// ClientCfg.init( "client_drone.cfg" );
|
||||
// if ( ClientCfg.RequestQuit )
|
||||
// return 0;
|
||||
//
|
||||
// // Connect and simulate clients
|
||||
// Drone.start( ClientCfg.NbConnections );
|
||||
// Drone.run();
|
||||
//
|
||||
// // Release
|
||||
// Drone.release();
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
/** \file entities_spoof.cpp
|
||||
* Spoofs of Ryzom client entity classes
|
||||
*
|
||||
* $Id: entities_spoof.cpp
|
||||
*/
|
||||
|
||||
#include "nel/net/module_manager.h"
|
||||
#include "entities_spoof.h"
|
||||
#include "simulated_client.h"
|
||||
//#include "../client/net_manager.h"
|
||||
#include "game_share/generic_xml_msg_mngr.h"
|
||||
#include "game_share/msg_client_server.h"
|
||||
|
||||
using namespace NLMISC;
|
||||
|
||||
extern CGenericXmlMsgHeaderManager GenericMsgHeaderMngr;
|
||||
|
||||
/*
|
||||
// extends spoofed client CUserEntity class
|
||||
*/
|
||||
void CUserEntity::sendToServer(CBitMemStream &out)
|
||||
{
|
||||
// Send Position & Orientation
|
||||
nlverify(GenericMsgHeaderMngr.pushNameToStream("POSITION", out));
|
||||
CPositionMsg positionMsg;
|
||||
positionMsg.X = (sint32)(pos().x * 1000);
|
||||
positionMsg.Y = (sint32)(pos().y * 1000);
|
||||
positionMsg.Z = (sint32)(pos().z * 1000);
|
||||
positionMsg.Heading = frontYaw(); //frand(6.28f);
|
||||
out.serial(positionMsg);
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,40 @@
|
||||
#ifndef ENTITIES_SPOOF_H
|
||||
#define ENTITIES_SPOOF_H
|
||||
|
||||
#include "nel/net/module.h"
|
||||
#include "network_connection.h"
|
||||
#include "cdb_synchronised.h"
|
||||
|
||||
/**
|
||||
// Spoof of client CEntityCL class
|
||||
*/
|
||||
class CEntityCL
|
||||
{
|
||||
public:
|
||||
|
||||
CEntityCL() : _Pos(NLMISC::CVectorD::Null) {}
|
||||
|
||||
const NLMISC::CVectorD& pos() const { return _Pos; }
|
||||
void pos(const NLMISC::CVectorD &vect) { _Pos = vect; }
|
||||
const NLMISC::CVector& front() const { return _Front; }
|
||||
void front(const NLMISC::CVector &vect) { _Front = vect; }
|
||||
float frontYaw() const {return (float)atan2(front().y, front().x);}
|
||||
const NLMISC::CVector& dir() const { return _Dir; }
|
||||
void dir(const NLMISC::CVector &vect) { _Dir = vect; }
|
||||
bool isInitialized() const { return ! _Pos.isNull(); }
|
||||
|
||||
private:
|
||||
NLMISC::CVectorD _Pos;
|
||||
NLMISC::CVector _Front, _Dir;
|
||||
};
|
||||
|
||||
/**
|
||||
// Spoof of client CUserEntity class
|
||||
*/
|
||||
class CUserEntity : public CEntityCL
|
||||
{
|
||||
public:
|
||||
void sendToServer(NLMISC::CBitMemStream &out);
|
||||
};
|
||||
|
||||
#endif // ENTITIES_SPOOF_H
|
@ -0,0 +1,92 @@
|
||||
/** \file impulse_decoder.cpp
|
||||
* <File description>
|
||||
*
|
||||
* $Id: impulse_decoder.cpp,v 1.1 2005/07/11 15:22:33 cado Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//#include "stdpch.h"
|
||||
|
||||
#include "impulse_decoder.h"
|
||||
|
||||
#include "game_share/action_factory.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
using namespace CLFECOMMON;
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
CImpulseDecoder::CImpulseDecoder()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
void CImpulseDecoder::decode(CBitMemStream &inbox, TPacketNumber receivedPacket, TPacketNumber receivedAck, TPacketNumber nextSentPacket, vector<CLFECOMMON::CAction *> &actions)
|
||||
{
|
||||
uint level;
|
||||
|
||||
for (level=0; level<3; ++level)
|
||||
{
|
||||
TPacketNumber *lAck;
|
||||
uint channel;
|
||||
|
||||
switch (level)
|
||||
{
|
||||
case 0: lAck = _LastAck0; channel = 0; break;
|
||||
case 1: lAck = _LastAck1; channel = receivedPacket&1; break;
|
||||
case 2: lAck = _LastAck2; channel = receivedPacket&3; break;
|
||||
}
|
||||
|
||||
bool keep = true;
|
||||
bool checkOnce = false;
|
||||
uint num = 0;
|
||||
|
||||
TPacketNumber lastAck = lAck[channel];
|
||||
|
||||
while (true)
|
||||
{
|
||||
bool next;
|
||||
inbox.serial(next);
|
||||
|
||||
if (!next)
|
||||
break;
|
||||
|
||||
if (!checkOnce)
|
||||
{
|
||||
checkOnce = true;
|
||||
keep = (receivedAck >= lAck[channel]);
|
||||
if (keep)
|
||||
lAck[channel] = nextSentPacket;
|
||||
}
|
||||
|
||||
++num;
|
||||
CAction *action = CActionFactory::getInstance()->unpack(inbox, false);
|
||||
|
||||
if (keep)
|
||||
{
|
||||
actions.push_back(action);
|
||||
nlinfo("CLIMPD: received new impulsion %d (len=%u) at level %d (channel %d)", action->Code, CActionFactory::getInstance()->size(action), level, channel, num, (keep) ? "" : " (discarded)", lastAck, nextSentPacket);
|
||||
}
|
||||
else
|
||||
{
|
||||
nlinfo("CLIMPD: discarded action %d (len=%u) at level %d (channel %d)", action->Code, CActionFactory::getInstance()->size(action), level, channel, num, (keep) ? "" : " (discarded)", lastAck, nextSentPacket);
|
||||
CActionFactory::getInstance()->remove(action);
|
||||
}
|
||||
}
|
||||
|
||||
if (checkOnce)
|
||||
nldebug("CLIMPD: at level %d (channel %d), %d actions%s (ReceivedAck=%d/lastAck=%d/nextSentPacket=%d)", level, channel, num, (keep) ? "" : " (discarded)", receivedAck, lastAck, nextSentPacket);
|
||||
}
|
||||
}
|
||||
|
||||
void CImpulseDecoder::reset()
|
||||
{
|
||||
uint i;
|
||||
for (i=0; i<1; ++i) _LastAck0[i] = -1;
|
||||
for (i=0; i<2; ++i) _LastAck1[i] = -1;
|
||||
for (i=0; i<4; ++i) _LastAck2[i] = -1;
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/** \file impulse_decoder.h
|
||||
* <File description>
|
||||
*
|
||||
* $Id: impulse_decoder.h,v 1.1 2005/07/11 15:22:33 cado Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef NL_IMPULSE_DECODER_H
|
||||
#define NL_IMPULSE_DECODER_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/bit_mem_stream.h"
|
||||
|
||||
#include "game_share/action.h"
|
||||
#include "game_share/entity_types.h"
|
||||
|
||||
|
||||
/**
|
||||
* <Class description>
|
||||
* \author Benjamin Legros
|
||||
* \author Nevrax France
|
||||
* \date 2001
|
||||
*/
|
||||
class CImpulseDecoder
|
||||
{
|
||||
private:
|
||||
CLFECOMMON::TPacketNumber _LastAck0[1];
|
||||
CLFECOMMON::TPacketNumber _LastAck1[2];
|
||||
CLFECOMMON::TPacketNumber _LastAck2[4];
|
||||
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CImpulseDecoder();
|
||||
|
||||
|
||||
///
|
||||
void decode(NLMISC::CBitMemStream &inbox, CLFECOMMON::TPacketNumber receivedPacket, CLFECOMMON::TPacketNumber receivedAck, CLFECOMMON::TPacketNumber nextSentPacket, std::vector<CLFECOMMON::CAction *> &actions);
|
||||
|
||||
///
|
||||
void reset();
|
||||
};
|
||||
|
||||
|
||||
#endif // NL_IMPULSE_DECODER_H
|
||||
|
||||
/* End of impulse_decoder.h */
|
@ -0,0 +1,869 @@
|
||||
/** \file network_connection.h
|
||||
* CNetworkConnection
|
||||
*
|
||||
* $Id: network_connection.h,v 1.3 2007/07/27 15:14:50 cado Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef NL_NETWORK_CONNECTION_H
|
||||
#define NL_NETWORK_CONNECTION_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/bit_set.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <hash_map>
|
||||
#include <list>
|
||||
#include <deque>
|
||||
#include <set>
|
||||
|
||||
#include <nel/misc/bit_mem_stream.h>
|
||||
#include <nel/net/inet_address.h>
|
||||
#include <nel/net/login_cookie.h>
|
||||
#include <nel/net/login_client.h>
|
||||
#include <nel/net/udp_sim_sock.h>
|
||||
#include <nel/misc/vectord.h>
|
||||
#include <nel/misc/md5.h>
|
||||
|
||||
#include "time_client.h"
|
||||
#include "game_share/entity_types.h"
|
||||
#include "property_decoder.h"
|
||||
#include "impulse_decoder.h"
|
||||
#include "game_share/action.h"
|
||||
#include "game_share/ryzom_entity_id.h"
|
||||
#include "game_share/action_block.h"
|
||||
#include "game_share/loot_harvest_state.h"
|
||||
|
||||
/*
|
||||
* ENABLE_INCOMING_MSG_RECORDER for recording/replaying incoming network messages
|
||||
*/
|
||||
#undef ENABLE_INCOMING_MSG_RECORDER
|
||||
|
||||
#ifdef ENABLE_INCOMING_MSG_RECORDER
|
||||
#include <nel/misc/file.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
// UNUSED
|
||||
const uint PropertiesPerEntity = 16;
|
||||
const uint EntitiesPerClient = 256;
|
||||
*/
|
||||
|
||||
class CCDBNodeBranch;
|
||||
class CSimulatedClient;
|
||||
|
||||
namespace CLFECOMMON
|
||||
{
|
||||
class CActionGeneric;
|
||||
class CActionGenericMultiPart;
|
||||
}
|
||||
|
||||
// Hierachical timer
|
||||
H_AUTO_DECL ( RZ_Client_Network_Connection_Set_Reference_Position )
|
||||
|
||||
//#define MEASURE_FE_SENDING
|
||||
|
||||
extern char * ConnectionStateCStr [9];
|
||||
|
||||
|
||||
/**
|
||||
* Exception thrown when the sending returns a "blocking operation interrupted".
|
||||
*/
|
||||
class EBlockedByFirewall : public NLNET::ESocket
|
||||
{};
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* Abstracts the connection client towards front-end
|
||||
* \author Benjamin Legros, Olivier Cado
|
||||
* \author Nevrax France
|
||||
* \date 2001-2002
|
||||
*/
|
||||
class CNetworkConnection
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
/*
|
||||
* DO LEAVE ENOUGH ROOM FOR FUTURE PROPERTIES !
|
||||
*/
|
||||
AddNewEntity = 32,
|
||||
RemoveOldEntity,
|
||||
ConnectionReady,
|
||||
LagDetected,
|
||||
ProbeReceived
|
||||
};
|
||||
|
||||
|
||||
struct TVPNodeClient : public CLFECOMMON::TVPNodeBase
|
||||
{
|
||||
struct TSlotContext
|
||||
{
|
||||
CNetworkConnection *NetworkConnection;
|
||||
CLFECOMMON::TCLEntityId Slot;
|
||||
NLMISC::TGameCycle Timestamp;
|
||||
};
|
||||
|
||||
// Static data
|
||||
static TSlotContext SlotContext;
|
||||
|
||||
///
|
||||
TVPNodeClient() : TVPNodeBase() {}
|
||||
|
||||
TVPNodeClient *a() { return (TVPNodeClient*)VPA; }
|
||||
TVPNodeClient *b() { return (TVPNodeClient*)VPB; }
|
||||
TVPNodeClient *parent() { return (TVPNodeClient*)VPParent; }
|
||||
|
||||
///
|
||||
void decodeDiscreetProperties( NLMISC::CBitMemStream& msgin )
|
||||
{
|
||||
msgin.serialBitAndLog( BranchHasPayload );
|
||||
if ( BranchHasPayload )
|
||||
{
|
||||
if ( isLeaf() )
|
||||
{
|
||||
SlotContext.NetworkConnection->decodeDiscreetProperty( msgin, PropIndex );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( a() ) a()->decodeDiscreetProperties( msgin );
|
||||
if ( b() ) b()->decodeDiscreetProperties( msgin );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void makeChildren()
|
||||
{
|
||||
VPA = new TVPNodeClient();
|
||||
VPA->VPParent = this;
|
||||
VPB = new TVPNodeClient();
|
||||
VPB->VPParent = this;
|
||||
}
|
||||
|
||||
void makeDescendants( uint nbLevels )
|
||||
{
|
||||
makeChildren();
|
||||
if ( nbLevels > 1 )
|
||||
{
|
||||
a()->makeDescendants( nbLevels-1 );
|
||||
b()->makeDescendants( nbLevels-1 );
|
||||
}
|
||||
}
|
||||
|
||||
void deleteBranches()
|
||||
{
|
||||
if ( a() )
|
||||
{ a()->deleteBranches();
|
||||
delete a();
|
||||
}
|
||||
if ( b() )
|
||||
{ b()->deleteBranches();
|
||||
delete b();
|
||||
}
|
||||
}
|
||||
|
||||
void deleteA()
|
||||
{
|
||||
if ( a() )
|
||||
{ a()->deleteBranches();
|
||||
delete a();
|
||||
}
|
||||
}
|
||||
|
||||
void deleteB()
|
||||
{
|
||||
if ( b() )
|
||||
{ b()->deleteBranches();
|
||||
delete b();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/// Additional info for position updates
|
||||
struct TPositionInfo
|
||||
{
|
||||
/**
|
||||
* Only for positions (property index 0): interval, in game cycle unit, between the current
|
||||
* position update and the next predicted one. In most cases the next real position update
|
||||
* will occur just before the predicted interval elapses.
|
||||
*
|
||||
* If the interval cannot be predicted yet (e.g. before having received two updates
|
||||
* for the same entity), PredictedInterval is set to ~0.
|
||||
*/
|
||||
NLMISC::TGameCycle PredictedInterval;
|
||||
|
||||
/// Is position interior (only for position)
|
||||
bool IsInterior;
|
||||
};
|
||||
|
||||
/**
|
||||
* A property change
|
||||
*/
|
||||
class CChange
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CChange( CLFECOMMON::TCLEntityId id = 0, uint8 prop = 255, NLMISC::TGameCycle gc = 0 ) :
|
||||
ShortId(id), Property(prop), GameCycle(gc) {}
|
||||
|
||||
/// Slot
|
||||
CLFECOMMON::TCLEntityId ShortId;
|
||||
|
||||
/// Property index
|
||||
uint8 Property;
|
||||
|
||||
/// The tick when the property changed, in server time
|
||||
NLMISC::TGameCycle GameCycle;
|
||||
|
||||
// These contextual additional properties must be set by hand (not by constructor)
|
||||
union
|
||||
{
|
||||
/// Position additional information (prediction & interior)
|
||||
TPositionInfo PositionInfo;
|
||||
|
||||
/// New entity additional information (dataset row)
|
||||
CLFECOMMON::TClientDataSetIndex NewEntityInfo;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/// The states of the connection to the server (if you change them, change ConnectionStateCStr)
|
||||
enum TConnectionState
|
||||
{
|
||||
NotInitialised = 0, // nothing happened yet
|
||||
NotConnected, // init() called
|
||||
Authenticate, // connect() called, identified by the login server
|
||||
Login, // connecting to the frontend, sending identification
|
||||
Synchronize, // connection accepted by the frontend, synchronizing
|
||||
Connected, // synchronized, connected, ready to work
|
||||
Probe, // connection lost by frontend, probing for response
|
||||
Stalled, // server is stalled
|
||||
Disconnect, // disconnect() called, or timeout, or connection closed by frontend
|
||||
Quit // quit() called
|
||||
};
|
||||
|
||||
typedef void (*TImpulseCallback)(NLMISC::CBitMemStream &, CLFECOMMON::TPacketNumber packet, void *arg);
|
||||
|
||||
static bool LoggingMode;
|
||||
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CNetworkConnection();
|
||||
|
||||
/// Destructor
|
||||
virtual ~CNetworkConnection();
|
||||
|
||||
/// @name Connection initialisation
|
||||
//@{
|
||||
|
||||
/**
|
||||
* Inits the client connection to the front-end.
|
||||
* \param cookie it s the cookie in string format that was passed to the exe command line (given by the nel_launcher)
|
||||
* \param addr it s the front end address in string format that was passed to the exe command line (given by the nel_launcher)
|
||||
*/
|
||||
void init(const std::string &cookie, const std::string &addr);
|
||||
|
||||
|
||||
/**
|
||||
* Connects to the front-end (using or not the login system, depending on what was specified at init())
|
||||
* \param result the message returned in case of an error
|
||||
* Returns true if no error occured.
|
||||
*/
|
||||
bool connect(std::string &result);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the callback called when a generic impulse comes
|
||||
*/
|
||||
void setImpulseCallback(TImpulseCallback callback, void *argument = NULL);
|
||||
|
||||
//@}
|
||||
|
||||
|
||||
/// @name Connection management
|
||||
//@{
|
||||
|
||||
/**
|
||||
* Tells if the client is yet connected or not
|
||||
*/
|
||||
bool isConnected();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the connection state
|
||||
*/
|
||||
TConnectionState getConnectionState() const { return _ConnectionState; }
|
||||
|
||||
|
||||
/**
|
||||
* Updates the whole connection with the frontend.
|
||||
*
|
||||
* Behaviour in login state when a firewall does not grant the sending:
|
||||
* - When a sending is refused (error "Blocking operation interrupted")
|
||||
* the exception EBlockedByFirewall in thrown. The first time, a time-out is armed.
|
||||
* - In a later attempt, if the time-out expired, the function sets state to
|
||||
* Disconnect, then throws EBlockedByFirewall.
|
||||
*
|
||||
* \return bool 'true' if data were sent/received.
|
||||
*/
|
||||
bool update();
|
||||
|
||||
|
||||
/**
|
||||
* Disconnects the current connection
|
||||
*/
|
||||
void disconnect();
|
||||
|
||||
//@}
|
||||
|
||||
|
||||
/**
|
||||
* Quit the game till the connection is reset
|
||||
*/
|
||||
void quit();
|
||||
|
||||
|
||||
/// @name Database management
|
||||
//@{
|
||||
|
||||
/**
|
||||
* Set database entry point
|
||||
*/
|
||||
void setDataBase(CCDBNodeBranch *database);
|
||||
|
||||
//@}
|
||||
|
||||
|
||||
|
||||
/// @name Push and Send
|
||||
//@{
|
||||
|
||||
/**
|
||||
* Buffers a bitmemstream, that will be converted into a generic action, to be sent later to the server (at next update).
|
||||
*/
|
||||
void push (NLMISC::CBitMemStream &msg);
|
||||
|
||||
/**
|
||||
* Buffers an action to be sent at next update (or later updates if network overload occurs)
|
||||
*/
|
||||
void push(CLFECOMMON::CAction *action);
|
||||
|
||||
/**
|
||||
* Buffers a target action (set targetOrPickup to true for target, false for pick-up
|
||||
*/
|
||||
void pushTarget(CLFECOMMON::TCLEntityId slot, LHSTATE::TLHState targetOrPickup);
|
||||
|
||||
/**
|
||||
* Send
|
||||
*/
|
||||
void send(NLMISC::TGameCycle);
|
||||
|
||||
/**
|
||||
* Send last information without changes (only acknowedges frontend)
|
||||
*/
|
||||
void send();
|
||||
|
||||
/**
|
||||
* Clear not acknownledged actions in sending buffer
|
||||
*/
|
||||
void flushSendBuffer() { _Actions.clear(); }
|
||||
|
||||
/**
|
||||
* Set player reference position
|
||||
*/
|
||||
// void setReferencePosition(const NLMISC::CVectorD &position) { _ImpulseDecoder.setReferencePosition(position); }
|
||||
|
||||
//@}
|
||||
|
||||
|
||||
/// @name Temp methods
|
||||
// @{
|
||||
|
||||
const std::vector<CChange> &getChanges() { return _Changes; }
|
||||
|
||||
void clearChanges() { _Changes.clear(); }
|
||||
|
||||
// @}
|
||||
|
||||
|
||||
/// @name Client time hints
|
||||
// @{
|
||||
NLMISC::TTime getCurrentClientTime() { return _CurrentClientTime; } // the time currently played at this frame (in the past)
|
||||
NLMISC::TGameCycle getCurrentClientTick() { return _CurrentClientTick; } // the tick for the current frame (also in the past)
|
||||
NLMISC::TGameCycle getCurrentServerTick() { return _CurrentServerTick; } // the last tick sent by the server.
|
||||
NLMISC::TTime getMachineTimeAtTick() { return _MachineTimeAtTick; } // the machine time at the beginning of the current tick
|
||||
NLMISC::TTicks getMachineTicksAtTick() { return _MachineTicksAtTick; }
|
||||
sint32 getMsPerTick() { return _MsPerTick; }
|
||||
NLMISC::TGameCycle getSynchronize() { return _Synchronize; }
|
||||
uint32 getBestPing() { return _BestPing; }
|
||||
uint32 getPing() const { return _InstantPing; }
|
||||
NLMISC::TTime getLCT() { return _LCT; } // Lag compensation time
|
||||
NLMISC::TTime getUpdateTime() { return _UpdateTime; }
|
||||
NLMISC::TTicks getUpdateTicks() { return _UpdateTicks; }
|
||||
// Return an estimated smooth server tick. Increment only and accelerate/decelerate according to network
|
||||
sint64 getCurrentSmoothServerTick() const { return _CurrentSmoothServerTick; }
|
||||
// Convert a GameCycle to a SmoothServerTick
|
||||
sint64 convertToSmoothServerTick(NLMISC::TGameCycle t) const;
|
||||
// @}
|
||||
|
||||
|
||||
/// Set the Lag Compensation Time in ms (default: 1000)
|
||||
void setLCT( NLMISC::TTime lct ) { _LCT = lct; }
|
||||
|
||||
/// Allocation statistics
|
||||
void displayAllocationStats();
|
||||
|
||||
/// Get Allocation statistics
|
||||
std::string getAllocationStats();
|
||||
|
||||
/// @name Network Stats Methods
|
||||
// @{
|
||||
|
||||
uint32 getSentBytes() { return _TotalSentBytes; }
|
||||
uint32 getPartialSentBytes() { uint32 ret = _PartialSentBytes; _PartialSentBytes = 0; return ret; }
|
||||
uint32 getReceivedBytes() { return _TotalReceivedBytes; }
|
||||
uint32 getPartialReceivedBytes() { uint32 ret = _PartialReceivedBytes; _PartialReceivedBytes = 0; return ret; }
|
||||
bool getConnectionQuality() { return _ConnectionQuality; }
|
||||
NLMISC::TTime getTimeSinceLastReceivedPacket() { return NLMISC::CTime::getLocalTime()-_LastReceivedNormalTime; }
|
||||
|
||||
|
||||
/// Return the average billed download rate in kbps, including all headers (UDP+IP+Ethernet)
|
||||
float getMeanDownload() { return (_MeanDownload.mean(ryzomGetLocalTime ())+20+8+14)*0.008f; }
|
||||
|
||||
/// Return the average billed upload rate in kbps, including all headers (UDP+IP+Ethernet)
|
||||
float getMeanUpload() { return (_MeanUpload.mean(ryzomGetLocalTime ())+20+8+14)*0.008f; }
|
||||
|
||||
/// Return the packet loss average
|
||||
float getMeanPacketLoss()
|
||||
{
|
||||
NLMISC::TTime time = ryzomGetLocalTime ();
|
||||
_MeanPackets.check(time);
|
||||
_MeanLoss.check(time);
|
||||
float dpk = _MeanPackets.Values.empty() ? 0.0f : _MeanPackets.Values.back().second-_MeanPackets.Values.front().second+1;
|
||||
float tloss = _MeanLoss.Content;
|
||||
return (dpk > 0.0f) ? std::min(100.0f, tloss*100.0f/dpk) : 0.0f;
|
||||
}
|
||||
|
||||
/// Get total lost packets
|
||||
uint32 getTotalLostPackets() const { return _TotalLostPackets; }
|
||||
|
||||
// @}
|
||||
|
||||
/// Accessor to the visual properties in database
|
||||
sint64 getVisualProp(CLFECOMMON::TCLEntityId slot, CLFECOMMON::TProperty prop) const;
|
||||
|
||||
/// Accessor to property decoder
|
||||
const CPropertyDecoder& getPropertyDecoder() const { return _PropertyDecoder; }
|
||||
|
||||
/// Get the NLMISC::CEntityId from the TCLEntityId
|
||||
CLFECOMMON::TSheetId get(CLFECOMMON::TCLEntityId id) const { return _PropertyDecoder.sheet(id); }
|
||||
|
||||
/// Get the TCLEntityId from the NLMISC::CEntityId
|
||||
sint get(CLFECOMMON::TSheetId id) const
|
||||
{
|
||||
TIdMap::const_iterator it = _IdMap.find(id);
|
||||
return (it != _IdMap.end()) ? (*it).second : -1;
|
||||
}
|
||||
|
||||
/// Set player's reference position
|
||||
void setReferencePosition(const NLMISC::CVectorD &position)
|
||||
{
|
||||
H_AUTO_USE ( RZ_Client_Network_Connection_Set_Reference_Position )
|
||||
_PropertyDecoder.setReferencePosition( position );
|
||||
}
|
||||
|
||||
/// Get local IP address
|
||||
const NLNET::CInetAddress& getAddress()
|
||||
{
|
||||
return _Connection.localAddr();
|
||||
}
|
||||
|
||||
/// Get socket
|
||||
NLNET::CUdpSock& getConnection()
|
||||
{
|
||||
return _Connection.UdpSock;
|
||||
}
|
||||
|
||||
/// Get userId
|
||||
uint32 getUserId()
|
||||
{
|
||||
if(_LoginCookie.isValid())
|
||||
return _LoginCookie.getUserId();
|
||||
else
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
/// Get connection state c_string
|
||||
char * getConnectionStateCStr()
|
||||
{
|
||||
return ConnectionStateCStr[_ConnectionState];
|
||||
}
|
||||
|
||||
/// Return the login cookie
|
||||
const NLNET::CLoginCookie& getLoginCookie() const
|
||||
{
|
||||
return _LoginCookie;
|
||||
}
|
||||
|
||||
void decodeDiscreetProperty( NLMISC::CBitMemStream& msgin, CLFECOMMON::TPropIndex propIndex );
|
||||
|
||||
NLMISC::TGameCycle lastSentCycle() const { return _LastSentCycle; }
|
||||
|
||||
protected:
|
||||
/// The current state of the connection
|
||||
TConnectionState _ConnectionState;
|
||||
|
||||
/// Connection Quality check
|
||||
bool _ConnectionQuality;
|
||||
|
||||
/// The address of the frontend service
|
||||
std::string _FrontendAddress;
|
||||
|
||||
/// The cookie for the login service
|
||||
NLNET::CLoginCookie _LoginCookie;
|
||||
|
||||
/// The UDP connection to the frontend
|
||||
NLNET::CUdpSimSock _Connection;
|
||||
|
||||
/// The receive buffer
|
||||
uint32 _ReceiveBuffer[65536];
|
||||
|
||||
/// The impulse decoder
|
||||
CImpulseDecoder _ImpulseDecoder;
|
||||
|
||||
/// The callback for generic actions
|
||||
TImpulseCallback _ImpulseCallback;
|
||||
|
||||
/// The callback argument
|
||||
void *_ImpulseArg;
|
||||
|
||||
|
||||
/// Position update tick queues (used for statistical interval prediction), one per slot
|
||||
//std::deque<NLMISC::TGameCycle> _PosUpdateTicks[256];
|
||||
|
||||
/// Position update interval sorted sets (used for statistical interval prediction), one per slot
|
||||
//std::multiset<NLMISC::TGameCycle> _PosUpdateIntervals[256];
|
||||
|
||||
/// MD5 hash keys of msg.xml and database.xml
|
||||
//NLMISC::CHashKeyMD5 _MsgXmlMD5;
|
||||
//NLMISC::CHashKeyMD5 _DatabaseXmlMD5;
|
||||
// if prec don't work, those may (if the server run on windows, prec won't work)
|
||||
//NLMISC::CHashKeyMD5 _AltMsgXmlMD5;
|
||||
//NLMISC::CHashKeyMD5 _AltDatabaseXmlMD5;
|
||||
|
||||
|
||||
/// @name Network statistics
|
||||
//@{
|
||||
|
||||
class CMeanComputer
|
||||
{
|
||||
public:
|
||||
CMeanComputer() : MeanPeriod(2000), Content(0.0f) {}
|
||||
std::deque< std::pair<NLMISC::TTime, float> > Values;
|
||||
uint32 MeanPeriod; // in ms
|
||||
float Content;
|
||||
|
||||
// checks all values have valid time (inside the mean period)
|
||||
void check(NLMISC::TTime time)
|
||||
{
|
||||
while (!Values.empty() && Values.front().first < time-MeanPeriod)
|
||||
{
|
||||
Content -= Values.front().second;
|
||||
Values.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
// updates the mean with a new value and time
|
||||
void update(float value, NLMISC::TTime time)
|
||||
{
|
||||
if (!Values.empty() && Values.back().first > time)
|
||||
return;
|
||||
|
||||
check(time);
|
||||
Values.push_back(std::make_pair(time, value));
|
||||
Content += value;
|
||||
}
|
||||
|
||||
// gets the mean
|
||||
float mean(NLMISC::TTime time)
|
||||
{
|
||||
check(time);
|
||||
return Content*1000.0f/(float)MeanPeriod;
|
||||
}
|
||||
};
|
||||
|
||||
/// The total received length (from the beginning)
|
||||
uint32 _TotalReceivedBytes;
|
||||
|
||||
/// The partial received length (since last read)
|
||||
uint32 _PartialReceivedBytes;
|
||||
|
||||
/// The total sent length
|
||||
uint32 _TotalSentBytes;
|
||||
|
||||
/// Partial sent length
|
||||
uint32 _PartialSentBytes;
|
||||
|
||||
/// Total lost packets
|
||||
uint32 _TotalLostPackets;
|
||||
|
||||
/// Mean download (payload bytes)
|
||||
CMeanComputer _MeanDownload;
|
||||
|
||||
/// Mean upload (payload bytes)
|
||||
CMeanComputer _MeanUpload;
|
||||
|
||||
/// Mean packets
|
||||
CMeanComputer _MeanPackets;
|
||||
|
||||
/// Mean lost
|
||||
CMeanComputer _MeanLoss;
|
||||
|
||||
//@}
|
||||
|
||||
|
||||
/// The property decoder
|
||||
CPropertyDecoder _PropertyDecoder;
|
||||
|
||||
/// The database entry
|
||||
CCDBNodeBranch *_DataBase;
|
||||
|
||||
|
||||
/// @name Header message decoding
|
||||
//@{
|
||||
|
||||
/// Was the header decoded for the last received message?
|
||||
bool _DecodedHeader;
|
||||
|
||||
/// The received number lastly decoded
|
||||
CLFECOMMON::TPacketNumber _CurrentReceivedNumber;
|
||||
|
||||
/// The message is in system mode
|
||||
bool _SystemMode;
|
||||
|
||||
/// Did we received a probe since last update
|
||||
bool _ReceivedSync;
|
||||
|
||||
uint _TotalMessages;
|
||||
|
||||
//@}
|
||||
|
||||
|
||||
|
||||
/// @name Client and Server packet numbering management
|
||||
//@{
|
||||
|
||||
CLFECOMMON::TPacketNumber _CurrentSendNumber; // number that will be used to send the next packet
|
||||
|
||||
CLFECOMMON::TPacketNumber _LastReceivedNumber; // number of the last packet receive from the server
|
||||
uint32 _AckBitMask; // this mask contains ack of old messages received by the server
|
||||
uint32 _LastAckBit; // a remember of the status of the previous received packet
|
||||
NLMISC::TTime _LastReceivedTime; // last time the client received something from the server
|
||||
|
||||
NLMISC::CBitSet _LongAckBitField;
|
||||
CLFECOMMON::TPacketNumber _LastAckInLongAck;
|
||||
|
||||
NLMISC::TGameCycle _LastSentCycle;
|
||||
|
||||
CLFECOMMON::TPacketNumber _LastReceivedPacketInBothModes;
|
||||
|
||||
NLMISC::TTime _LastReceivedNormalTime; // last time the client received valid normal message from the server
|
||||
|
||||
uint8 _ImpulseMultiPartNumber;
|
||||
|
||||
//@}
|
||||
|
||||
|
||||
/// @name Client and Server time management
|
||||
//@{
|
||||
|
||||
/// The stamps queues
|
||||
typedef std::deque<std::pair<sint32, NLMISC::TTime> > TStampQueue;
|
||||
|
||||
// used for lag compensation
|
||||
NLMISC::TTime _CurrentClientTime; // the time currently played at this frame (in the past)
|
||||
NLMISC::TGameCycle _CurrentClientTick; // the tick for the current frame (also in the past)
|
||||
NLMISC::TGameCycle _CurrentServerTick; // the last tick sent by the server.
|
||||
NLMISC::TTime _MachineTimeAtTick; // the machine time at the beginning of the current tick
|
||||
NLMISC::TTicks _MachineTicksAtTick;
|
||||
sint32 _MsPerTick;
|
||||
NLMISC::TGameCycle _Synchronize;
|
||||
uint32 _BestPing;
|
||||
uint32 _InstantPing;
|
||||
NLMISC::TTime _LCT; // Lag compensation time
|
||||
TStampQueue _PacketStamps;
|
||||
|
||||
NLMISC::TTime _UpdateTime;
|
||||
NLMISC::TTicks _UpdateTicks;
|
||||
NLMISC::TTime _LastSentSync;
|
||||
|
||||
NLMISC::TTime _LastSendTime;
|
||||
|
||||
//@}
|
||||
|
||||
std::list<CLFECOMMON::CActionBlock> _Actions;
|
||||
|
||||
/// Changes since
|
||||
std::vector<CChange> _Changes;
|
||||
|
||||
// TEMP
|
||||
uint32 _DummySend;
|
||||
|
||||
static bool _Registered;
|
||||
|
||||
/// @name Generic action multipart handling structures
|
||||
//@{
|
||||
struct CGenericMultiPartTemp
|
||||
{
|
||||
CGenericMultiPartTemp () : NbBlock(0xFFFFFFFF) { }
|
||||
uint32 NbBlock;
|
||||
uint32 NbCurrentBlock;
|
||||
uint32 TempSize;
|
||||
std::vector<std::vector<uint8> > Temp;
|
||||
|
||||
std::vector<bool> BlockReceived;
|
||||
|
||||
void set (CLFECOMMON::CActionGenericMultiPart *agmp, CNetworkConnection *parent);
|
||||
};
|
||||
|
||||
std::vector<CGenericMultiPartTemp> _GenericMultiPartTemp;
|
||||
//@}
|
||||
|
||||
/// @name NLMISC::CEntityId handling (for gamedev)
|
||||
//@{
|
||||
class CHash
|
||||
{
|
||||
public:
|
||||
size_t operator () (const CLFECOMMON::TSheetId &id) const { return id; }
|
||||
};
|
||||
|
||||
typedef std::hash_map<CLFECOMMON::TSheetId, CLFECOMMON::TCLEntityId, CHash> TIdMap;
|
||||
|
||||
TIdMap _IdMap;
|
||||
//@}
|
||||
|
||||
|
||||
TVPNodeClient *_VisualPropertyTreeRoot;
|
||||
|
||||
|
||||
/// \name Smooth ServerTick mgt.
|
||||
// @{
|
||||
sint64 _CurrentSmoothServerTick;
|
||||
NLMISC::TTime _SSTLastLocalTime;
|
||||
|
||||
void updateSmoothServerTick();
|
||||
// @}
|
||||
|
||||
private:
|
||||
|
||||
/// Set MsPerTick value
|
||||
void setMsPerTick(sint32 msPerTick);
|
||||
|
||||
|
||||
/// Builds the CBitMemStream from the next incoming packet
|
||||
bool buildStream(NLMISC::CBitMemStream &msgin);
|
||||
|
||||
/// @name Client automaton states and actions
|
||||
//@{
|
||||
|
||||
//
|
||||
void sendSystemLogin();
|
||||
bool stateLogin();
|
||||
NLMISC::TTime _LatestLoginTime;
|
||||
|
||||
//
|
||||
void receiveSystemSync(NLMISC::CBitMemStream &msgin);
|
||||
void sendSystemAckSync();
|
||||
bool stateSynchronize();
|
||||
NLMISC::TTime _LatestSyncTime;
|
||||
uint32 _LatestSync;
|
||||
|
||||
//
|
||||
void receiveNormalMessage(NLMISC::CBitMemStream &msgin);
|
||||
void sendNormalMessage();
|
||||
bool stateConnected();
|
||||
CLFECOMMON::TPacketNumber _LastReceivedAck;
|
||||
uint _NormalPacketsReceived;
|
||||
|
||||
//
|
||||
void receiveSystemProbe(NLMISC::CBitMemStream &msgin);
|
||||
void sendSystemAckProbe();
|
||||
bool stateProbe();
|
||||
std::vector<CLFECOMMON::TPacketNumber> _LatestProbes;
|
||||
CLFECOMMON::TPacketNumber _LatestProbe;
|
||||
NLMISC::TTime _LatestProbeTime;
|
||||
|
||||
//
|
||||
void receiveSystemStalled(NLMISC::CBitMemStream &msgin);
|
||||
bool stateStalled();
|
||||
|
||||
//
|
||||
void sendSystemDisconnection();
|
||||
|
||||
//
|
||||
bool stateQuit();
|
||||
void receiveSystemAckQuit(NLMISC::CBitMemStream &msgin);
|
||||
void sendSystemQuit();
|
||||
uint32 _QuitId;
|
||||
bool _ReceivedAckQuit;
|
||||
NLMISC::TTime _LatestQuitTime;
|
||||
|
||||
//
|
||||
void reset();
|
||||
|
||||
//@}
|
||||
|
||||
//
|
||||
bool decodeHeader(NLMISC::CBitMemStream &msgin, bool checkMessageNumber = true);
|
||||
|
||||
//
|
||||
void buildSystemHeader(NLMISC::CBitMemStream &msgout);
|
||||
|
||||
//
|
||||
void genericAction (CLFECOMMON::CActionGeneric *ag);
|
||||
void genericAction (CLFECOMMON::CActionGenericMultiPart *agmp);
|
||||
|
||||
//
|
||||
void statsSend(uint32 bytes);
|
||||
void statsReceive(uint32 bytes);
|
||||
|
||||
bool associationBitsHaveChanged( CLFECOMMON::TCLEntityId slot, uint32 associationBits )
|
||||
{
|
||||
bool res = ((uint16)associationBits != _PropertyDecoder.associationBits( slot ));
|
||||
_PropertyDecoder.associationBits( slot ) = (uint16)associationBits;
|
||||
return res;
|
||||
}
|
||||
|
||||
void decodeVisualProperties( NLMISC::CBitMemStream& msgin );
|
||||
|
||||
/// Return true if there is some messages to replay (in replay mode)
|
||||
bool dataToReplayAvailable();
|
||||
|
||||
uint32 _AssociationBits;
|
||||
|
||||
#ifdef ENABLE_INCOMING_MSG_RECORDER
|
||||
NLMISC::COFile _RecordedMessagesOut;
|
||||
|
||||
NLMISC::CIFile _RecordedMessagesIn;
|
||||
NLMISC::TGameCycle _NextClientTickToReplay; // ~0 when no more message
|
||||
NLMISC::CBitMemStream _NextMessageToReplay; // loaded at beginning of update(), read in buildStream()
|
||||
|
||||
bool _RecordIncomingMessagesOn;
|
||||
bool _ReplayIncomingMessagesOn;
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
friend struct CGenericMultiPartTemp;
|
||||
};
|
||||
|
||||
|
||||
#endif // NL_NETWORK_CONNECTION_H
|
||||
|
||||
/* End of network_connection.h */
|
@ -0,0 +1,194 @@
|
||||
/** \file property_decoder.cpp
|
||||
* <File description>
|
||||
*
|
||||
* $Id: property_decoder.cpp,v 1.1 2005/07/11 15:22:33 cado Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//#include "stdpch.h"
|
||||
|
||||
|
||||
|
||||
#include "property_decoder.h"
|
||||
#include "game_share/continuous_action.h"
|
||||
#include "game_share/action_position.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
using namespace CLFECOMMON;
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
CPropertyDecoder::CPropertyDecoder()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CPropertyDecoder::receive(TPacketNumber packetNumber, CAction *action)
|
||||
{
|
||||
if (!action->isContinuous())
|
||||
return;
|
||||
|
||||
if (action->Code == ACTION_POSITION_CODE)
|
||||
{
|
||||
CActionPosition *act = (CActionPosition *)(action);
|
||||
/*
|
||||
CPropertyEntry &px = _Entities[act->Slot].Properties[PROPERTY_POSX];
|
||||
CPropertyEntry &py = _Entities[act->Slot].Properties[PROPERTY_POSY];
|
||||
CPropertyEntry &pz = _Entities[act->Slot].Properties[PROPERTY_POSZ];
|
||||
*/
|
||||
#ifdef TEST_POSITION_CORRECTNESS
|
||||
#pragma message ("TEST_POSITION_CORRECTNESS")
|
||||
TCoord posx = (TCoord)(act->Position[0]);
|
||||
TCoord posy = (TCoord)(act->Position[1]);
|
||||
#endif
|
||||
|
||||
if ( act->IsRelative )
|
||||
{
|
||||
// Relative position (entity in a ferry...)
|
||||
act->Position[0] = (sint32)act->Position16[0];
|
||||
act->Position[1] = (sint32)act->Position16[1];
|
||||
act->Position[2] = (sint32)act->Position16[2];
|
||||
_Entities[act->Slot].PosIsRelative = true;
|
||||
_Entities[act->Slot].PosIsInterior = false;
|
||||
nlinfo( "Relative Pos: %d %d %d, Pos16: %hd %hd %hd, Date %u", (sint32)act->Position[0], (sint32)act->Position[1], (sint32)act->Position[2], act->Position16[0], act->Position16[1], act->Position16[2], act->GameCycle );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Absolute position
|
||||
//nlinfo( "RefPos: %d %d %d RefBits: %hd %hd %hd", _RefPosX, _RefPosY, _RefPosZ, _RefBitsX, _RefBitsY, _RefBitsZ );
|
||||
decodeAbsPos2D( act->Position[0], act->Position[1], act->Position16[0], act->Position16[1] );
|
||||
act->Position[2] = ((sint32)((sint16)act->Position16[2])) << 4;
|
||||
if (act->Interior)
|
||||
act->Position[2] += 2;
|
||||
//act->Position[2] = _RefPosZ + (((sint32)((sint16)(act->Position16[2] - _RefBitsZ))) << 4);
|
||||
//nlinfo( "Pos16: %hd %hd %hd => Pos: %d %d %d", act->Position16[0], act->Position16[1], act->Position16[2], (sint32)px.LastReceived, (sint32)py.LastReceived, (sint32)pz.LastReceived );
|
||||
_Entities[act->Slot].PosIsRelative = false;
|
||||
_Entities[act->Slot].PosIsInterior = act->Interior;
|
||||
//nlinfo( "Slot %hu: Absolute, Pos: %d %d %d, Pos16: %hu %hu %hu, Date %u", (uint16)act->CLEntityId, (sint32)act->Position[0], (sint32)act->Position[1], (sint32)act->Position[2], act->Position16[0], act->Position16[1], act->Position16[2], act->GameCycle );
|
||||
//nlinfo( " RefPos: %d %d %d, RefBits: %hu %hu %hu", _RefPosX, _RefPosY, _RefPosZ, _RefBitsX, _RefBitsY, _RefBitsZ );
|
||||
}
|
||||
/*
|
||||
px.LastReceived = act->Position[0];
|
||||
py.LastReceived = act->Position[1];
|
||||
pz.LastReceived = act->Position[2];
|
||||
//nldebug("CLPROPD: Received position (Id=%d) %d,%d (Pck=%d)", act->CLEntityId, act->Position[0], act->Position[1], packetNumber);
|
||||
*/
|
||||
#ifdef TEST_POSITION_CORRECTNESS
|
||||
#pragma message ("TEST_POSITION_CORRECTNESS")
|
||||
if ( ! (act->IsRelative) )
|
||||
{
|
||||
// Check if the compression algo for positions worked
|
||||
nlassertex( abs(posx - (TCoord)act->Position[0]) < 2000, ("Computed posX: %d Real posX: %d PosX16: %hu RefPosX: %d RefBitsX: %hu", (TCoord)(act->Position[0]), posx, act->Position16[0], _RefPosX, _RefBitsX) );
|
||||
nlassertex( abs(posy - (TCoord)act->Position[1]) < 2000, ("Computed posY: %d Real posY: %d PosY16: %hu RefPosY: %d RefBitsY: %hu", (TCoord)(act->Position[1]), posy, act->Position16[1], _RefPosY, _RefBitsY) );
|
||||
}
|
||||
nlinfo( "Receiving position %d %d %d m", posx/1000, posy/1000, (TCoord)act->Position[2]/1000 );
|
||||
#endif
|
||||
|
||||
}
|
||||
/*
|
||||
else
|
||||
{
|
||||
CContinuousAction *act = (CContinuousAction *)(action);
|
||||
|
||||
CPropertyEntry &property = _Entities[act->Slot].Properties[act->Code];
|
||||
|
||||
property.LastReceived = act->getValue();
|
||||
|
||||
nldebug("CLPROPD: Received (Id=%d,Act=%d)=(%"NL_I64"d)(Pck=%d)", act->Slot, act->Code, property.LastReceived, packetNumber);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void CPropertyDecoder::receive(TPacketNumber packetNumber, TPacketNumber ack, vector<CAction *> &actions)
|
||||
{
|
||||
// 1- process ack
|
||||
|
||||
//this->ack(packetNumber, ack);
|
||||
|
||||
|
||||
// 2- receive actions, decode them and store values
|
||||
|
||||
uint i;
|
||||
for (i=0; i<actions.size(); ++i)
|
||||
{
|
||||
receive(packetNumber, actions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
|
||||
void CPropertyDecoder::setReferencePosition(const NLMISC::CVectorD &position)
|
||||
{
|
||||
_RefPosX = (sint32)(position.x * 1000.0);
|
||||
_RefPosY = (sint32)(position.y * 1000.0);
|
||||
//_RefPosZ = (sint32)(position.z * 1000.0);
|
||||
|
||||
_RefBitsX = (uint16)(_RefPosX >> 4);
|
||||
_RefBitsY = (uint16)(_RefPosY >> 4);
|
||||
//_RefBitsZ = (uint16)(_RefPosZ >> 4);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
/*
|
||||
const CAction::TValue &CPropertyDecoder::getProperty(TCLEntityId entity, TProperty property) const
|
||||
{
|
||||
nlassert(entity < _Entities.size() && _Entities[entity].EntryUsed);
|
||||
|
||||
return _Entities[entity].Properties[property].LastReceived;
|
||||
}
|
||||
|
||||
void CPropertyDecoder::getPosition(TCLEntityId entity, CAction::TValue &posx, CAction::TValue &posy, CAction::TValue &posz) const
|
||||
{
|
||||
nlassert(entity < _Entities.size() && _Entities[entity].EntryUsed);
|
||||
const CEntityEntry &entry = _Entities[entity];
|
||||
posx = entry.Properties[PROPERTY_POSX].LastReceived;
|
||||
posy = entry.Properties[PROPERTY_POSY].LastReceived;
|
||||
posz = entry.Properties[PROPERTY_POSZ].LastReceived;
|
||||
}
|
||||
*/
|
||||
//
|
||||
|
||||
void CPropertyDecoder::clear()
|
||||
{
|
||||
uint sz = _Entities.size();
|
||||
_Entities.clear();
|
||||
_Entities.resize(sz);
|
||||
}
|
||||
|
||||
void CPropertyDecoder::setMaximumEntities(uint maximum)
|
||||
{
|
||||
_Entities.resize(maximum);
|
||||
}
|
||||
|
||||
void CPropertyDecoder::addEntity(TCLEntityId entity, TSheetId sheet)
|
||||
{
|
||||
nlassert(entity < _Entities.size() && !_Entities[entity].EntryUsed);
|
||||
|
||||
_Entities[entity].EntryUsed = true;
|
||||
_Entities[entity].Sheet = sheet;
|
||||
/*
|
||||
uint i;
|
||||
for (i=0; i<=LAST_CONTINUOUS_PROPERTY; ++i)
|
||||
_Entities[entity].Properties[i].init();
|
||||
*/
|
||||
}
|
||||
|
||||
bool CPropertyDecoder::removeEntity(TCLEntityId entity)
|
||||
{
|
||||
nlassertex(entity < _Entities.size(), ("entity=%hu size=%u", (uint16)entity,_Entities.size()) );
|
||||
|
||||
//Workaround: assert converted to test when failure in vision from the server
|
||||
if ( _Entities[entity].EntryUsed )
|
||||
{
|
||||
_Entities[entity].EntryUsed = false;
|
||||
_Entities[entity].Sheet = 0xffff;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
/** \file property_decoder.h
|
||||
* <File description>
|
||||
*
|
||||
* $Id: property_decoder.h,v 1.1 2005/07/11 15:22:33 cado Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef NL_PROPERTY_DECODER_H
|
||||
#define NL_PROPERTY_DECODER_H
|
||||
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/vector.h"
|
||||
#include "nel/misc/vectord.h"
|
||||
|
||||
#include "game_share/entity_types.h"
|
||||
#include "game_share/action.h"
|
||||
|
||||
/**
|
||||
* An engine that allows to encode/decode continuous properties using delta values.
|
||||
* \author Benjamin Legros
|
||||
* \author Nevrax France
|
||||
* \date 2001
|
||||
*/
|
||||
class CPropertyDecoder
|
||||
{
|
||||
private:
|
||||
/*
|
||||
/// A property entry, containing Garanted, ToGaranty and LastReceived values of action
|
||||
class CPropertyEntry
|
||||
{
|
||||
public:
|
||||
CLFECOMMON::CAction::TValue LastReceived;
|
||||
CLFECOMMON::TPacketNumber Packet;
|
||||
void init() { Packet = 0xFFFFFFFF; LastReceived = 0; }
|
||||
};
|
||||
*/
|
||||
|
||||
/// An entity entry, conainting properties for this entity
|
||||
class CEntityEntry
|
||||
{
|
||||
public:
|
||||
CEntityEntry() : EntryUsed(false), PosIsRelative(false), AssociationBits(0) {}
|
||||
CLFECOMMON::TSheetId Sheet;
|
||||
uint16 AssociationBits;
|
||||
bool EntryUsed;
|
||||
bool PosIsRelative;
|
||||
bool PosIsInterior;
|
||||
// CPropertyEntry Properties[CLFECOMMON::LAST_CONTINUOUS_PROPERTY+1];
|
||||
};
|
||||
|
||||
/// The entity entries
|
||||
std::vector<CEntityEntry> _Entities;
|
||||
|
||||
//
|
||||
uint16 _RefBitsX,
|
||||
_RefBitsY,
|
||||
_RefBitsZ;
|
||||
//
|
||||
sint32 _RefPosX,
|
||||
_RefPosY;
|
||||
// _RefPosZ;
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
CPropertyDecoder();
|
||||
|
||||
//
|
||||
void init(uint maximum) { setMaximumEntities(maximum); clear (); }
|
||||
void setMaximumEntities(uint maximum);
|
||||
void clear();
|
||||
void addEntity(CLFECOMMON::TCLEntityId entity, CLFECOMMON::TSheetId sheet);
|
||||
bool removeEntity(CLFECOMMON::TCLEntityId entity);
|
||||
uint16& associationBits( CLFECOMMON::TCLEntityId entity ) { return _Entities[entity].AssociationBits; }
|
||||
|
||||
bool isUsed(CLFECOMMON::TCLEntityId entity) const { return _Entities[entity].EntryUsed; }
|
||||
const CLFECOMMON::TSheetId sheet(CLFECOMMON::TCLEntityId entity) const { return _Entities[entity].Sheet; }
|
||||
|
||||
|
||||
/** Receives actions from the front end. Actually transmits actions received
|
||||
* by the client to the property decoder.
|
||||
* \param packetNumber the number of the packet received
|
||||
* \param ack the number of the acknowledged packet by the front end
|
||||
* \param actions the actions sent to the client by the front end
|
||||
*/
|
||||
void receive(CLFECOMMON::TPacketNumber packetNumber, CLFECOMMON::TPacketNumber ack, std::vector<CLFECOMMON::CAction *> &actions);
|
||||
|
||||
/** Receives single action from the front end. Actually transmits action received
|
||||
* by the client to the property decoder.
|
||||
* \param packetNumber the number of the packet received
|
||||
* \param ack the number of the acknowledged packet by the front end
|
||||
* \param action the action sent to the client by the front end
|
||||
*/
|
||||
void receive(CLFECOMMON::TPacketNumber packetNumber, CLFECOMMON::CAction *action);
|
||||
|
||||
/// Decode x and y
|
||||
void decodeAbsPos2D( sint32& x, sint32& y, uint16 x16, uint16 y16 )
|
||||
{
|
||||
x = _RefPosX + (((sint32)((sint16)(x16 - _RefBitsX))) << 4);
|
||||
y = _RefPosY + (((sint32)((sint16)(y16 - _RefBitsY))) << 4);
|
||||
}
|
||||
|
||||
/// Set player's reference position
|
||||
void setReferencePosition(const NLMISC::CVectorD &position);
|
||||
|
||||
|
||||
/// Retrieves a property value.
|
||||
// const CLFECOMMON::CAction::TValue &getProperty(CLFECOMMON::TCLEntityId entity, CLFECOMMON::TProperty property) const;
|
||||
|
||||
/// Retrieves an entity position.
|
||||
// void getPosition(CLFECOMMON::TCLEntityId entity, CLFECOMMON::CAction::TValue &posx, CLFECOMMON::CAction::TValue &posy, CLFECOMMON::CAction::TValue &posz) const;
|
||||
};
|
||||
|
||||
|
||||
#endif // NL_PROPERTY_DECODER_H
|
||||
|
||||
/* End of property_decoder.h */
|
@ -0,0 +1,192 @@
|
||||
#ifndef SIMULATED_CLIENT_H
|
||||
#define SIMULATED_CLIENT_H
|
||||
|
||||
#include "entities_spoof.h"
|
||||
#include "nel/misc/vector.h"
|
||||
#include "nel/misc/command.h"
|
||||
#include <vector>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
|
||||
class CUserCharMsg;
|
||||
|
||||
namespace NLNET
|
||||
{
|
||||
class IGatewayTransport;
|
||||
};
|
||||
|
||||
const uint DISABLED_CLIENT = ~0;
|
||||
|
||||
/**
|
||||
* An entity in the neighbourhood
|
||||
*/
|
||||
class CEntityDrone
|
||||
{
|
||||
public:
|
||||
CEntityDrone() {}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A light-weight client simulated by the drone
|
||||
*/
|
||||
class CSimulatedClient :
|
||||
public NLMISC::ICommandsHandler
|
||||
{
|
||||
public:
|
||||
|
||||
enum TLoginState
|
||||
{
|
||||
LSInitial,
|
||||
LSUserCharsReceiving,
|
||||
LSUserCharsReceived,
|
||||
LSNoUserChar,
|
||||
LSClientReady,
|
||||
LSQuitRequested,
|
||||
LSQuitting
|
||||
};
|
||||
|
||||
enum TDirection
|
||||
{
|
||||
DNE, DSE, DSW, DNW, DMaxDir=DNW
|
||||
};
|
||||
|
||||
// Main controls
|
||||
static void initNetwork(); // init network (call only once)
|
||||
CSimulatedClient( uint id=DISABLED_CLIENT );
|
||||
virtual ~CSimulatedClient();
|
||||
bool start();
|
||||
bool update();
|
||||
void requestQuit(); // can be called several times
|
||||
|
||||
// Utilities
|
||||
static CSimulatedClient *const currentContext() { return _CurrentContext; } // context for non-OO functions (callbacks...)
|
||||
std::string name() const;
|
||||
virtual const std::string &getCommandHandlerName() const { return _Name; }
|
||||
void setCurrentLoginState( TLoginState ls ) { if ( _CurrentLoginState < LSQuitRequested) _CurrentLoginState = ls; }
|
||||
void requestCreateChar();
|
||||
void requestCommandA( const std::string& arg );
|
||||
TLoginState getCurrentLoginState() const { return _CurrentLoginState; }
|
||||
void setInitPos( NLMISC::CBitMemStream &impulse );
|
||||
void tp( const NLMISC::CVectorD& dest, bool ackTP );
|
||||
void setId( uint id ) { _Id = id; }
|
||||
uint id() const { return _Id; }
|
||||
void sendClientReady();
|
||||
void disconnect();
|
||||
void requestString(uint32 stringId);
|
||||
|
||||
|
||||
CNetworkConnection &getNetworkConnection() { return _NetworkConnection;}
|
||||
|
||||
void setGatewayTransport(NLNET::IGatewayTransport *transport){_GatewayTransport = transport; }
|
||||
NLNET::IGatewayTransport *getGatewayTransport() { return _GatewayTransport; }
|
||||
|
||||
// Return a valid pointer if the slot is assigned, otherwise NULL
|
||||
CEntityDrone* getSlot( CLFECOMMON::TCLEntityId slot );
|
||||
|
||||
// Return the value of a visual property
|
||||
sint64 getVisualProp( CLFECOMMON::TCLEntityId slot, CLFECOMMON::TPropIndex prop ) const { return _NetworkConnection.getVisualProp( slot, prop ); }
|
||||
|
||||
// Return the position of an entity in sight
|
||||
NLMISC::CVectorD getPosition( CLFECOMMON::TCLEntityId slot ) const;
|
||||
|
||||
// Return the slot of the nearest entity (or ~0 if there is no other entity). If requiredSheet!=Unknown, only entities matching the sheet are taken in account.
|
||||
CLFECOMMON::TCLEntityId getNearestEntity( NLMISC::CSheetId requiredSheet=NLMISC::CSheetId::Unknown ) const;
|
||||
|
||||
// User entity
|
||||
CUserEntity UserEntity;
|
||||
|
||||
NLMISC_COMMAND_HANDLER_TABLE_BEGIN(CSimulatedClient)
|
||||
|
||||
NLMISC_COMMAND_HANDLER_ADD(CSimulatedClient, getNbUsedSlots, "Store the number of entities in vision", "")
|
||||
NLMISC_COMMAND_HANDLER_ADD(CSimulatedClient, getNearestEntity, "Store the slot of the nearest entity, with optional positive sheet filter", "[<onlySheet>]")
|
||||
NLMISC_COMMAND_HANDLER_ADD(CSimulatedClient, getVisualProp, "Store a visual property value", "<slot> <propIndex>")
|
||||
|
||||
NLMISC_COMMAND_HANDLER_ADD(CSimulatedClient, a, "Execute an admin command on you","<cmd> <arg>")
|
||||
NLMISC_COMMAND_HANDLER_ADD(CSimulatedClient, a_value, "Execute an admin command on you, take stored value as argument","<cmd> <arg>")
|
||||
NLMISC_COMMAND_HANDLER_ADD(CSimulatedClient, target, "Target a specified (or stored slot) ", "[<slot>]")
|
||||
NLMISC_COMMAND_HANDLER_ADD(CSimulatedClient, continueMission, "Click the current target with an Auto Mission", "[<intId>]")
|
||||
NLMISC_COMMAND_HANDLER_ADD(CSimulatedClient, sleep, "Sleep for seconds", "<seconds>")
|
||||
NLMISC_COMMAND_HANDLER_ADD(CSimulatedClient, sleepUntil, "Sleep until NLMISC::getLocalTime() reaches until", "<until>")
|
||||
NLMISC_COMMAND_HANDLER_ADD(CSimulatedClient, repeat, "Repeat the block going until endrepeat", "<count>")
|
||||
NLMISC_COMMAND_HANDLER_ADD(CSimulatedClient, displayScript, "Display the current script list", "")
|
||||
NLMISC_COMMAND_HANDLER_ADD(CSimulatedClient, disconnect, "Request disconnection", "")
|
||||
|
||||
NLMISC_COMMAND_HANDLER_TABLE_END
|
||||
|
||||
NLMISC_CLASS_COMMAND_DECL(getNbUsedSlots);
|
||||
NLMISC_CLASS_COMMAND_DECL(getNearestEntity);
|
||||
NLMISC_CLASS_COMMAND_DECL(getVisualProp);
|
||||
|
||||
NLMISC_CLASS_COMMAND_DECL(a);
|
||||
NLMISC_CLASS_COMMAND_DECL(a_value);
|
||||
NLMISC_CLASS_COMMAND_DECL(target);
|
||||
NLMISC_CLASS_COMMAND_DECL(continueMission);
|
||||
NLMISC_CLASS_COMMAND_DECL(sleep);
|
||||
NLMISC_CLASS_COMMAND_DECL(repeat);
|
||||
NLMISC_CLASS_COMMAND_DECL(sleepUntil);
|
||||
NLMISC_CLASS_COMMAND_DECL(displayScript);
|
||||
NLMISC_CLASS_COMMAND_DECL(disconnect);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
friend class CClientDrone; // accessing stats
|
||||
|
||||
void setIdAndName(uint id);
|
||||
bool autoLogin (const std::string &cookie, const std::string &fsaddr, bool firstConnection);
|
||||
bool updateEnterGame();
|
||||
bool updateInGame();
|
||||
|
||||
void send( NLMISC::TGameCycle gameCycle );
|
||||
void send();
|
||||
sint updateNetwork(); // return the game cycle delta between the previous call
|
||||
void processVision();
|
||||
void processScript();
|
||||
void sendMsgToServer(const std::string &sMsg, uint8 u8);
|
||||
|
||||
void selectCharAndEnter( uint charIndex );
|
||||
|
||||
|
||||
protected:
|
||||
std::string _Name;
|
||||
uint _Id;
|
||||
uint _UserId;
|
||||
CNetworkConnection _NetworkConnection;
|
||||
TLoginState _CurrentLoginState;
|
||||
//CCDBSynchronised _IngameDbMngr;
|
||||
TDirection _Direction;
|
||||
std::vector<std::string> _PendingCommands;
|
||||
CEntityDrone _VisionSlots[256]; // see getSlot()
|
||||
// CLFECOMMON::TCLEntityId _NearestSlot;
|
||||
// uint _NbUsedSlots;
|
||||
typedef std::list<std::string> CScriptList;
|
||||
CScriptList _Script;
|
||||
bool _ProcessingScript;
|
||||
|
||||
static CSimulatedClient *_CurrentContext;
|
||||
NLNET::TModulePtr _ModuleGateway;
|
||||
NLNET::IGatewayTransport *_GatewayTransport;
|
||||
|
||||
private:
|
||||
NLNET::TModulePtr _ModuleTest;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
class CScriptStack
|
||||
{
|
||||
public:
|
||||
static CScriptStack * getInstance() { if (!_Instance) _Instance = new CScriptStack(); return _Instance; }
|
||||
|
||||
NLMISC::CSString& top() { if (_Stack.empty()) _Stack.push(NLMISC::CSString()); return _Stack.top(); }
|
||||
|
||||
private:
|
||||
std::stack<NLMISC::CSString> _Stack;
|
||||
static CScriptStack *_Instance;
|
||||
};
|
||||
|
||||
#endif // SIMULATED_CLIENT_H
|
@ -0,0 +1,211 @@
|
||||
|
||||
|
||||
#include "nel/misc/random.h"
|
||||
#include "nel/net/module.h"
|
||||
#include "nel/net/module_builder_parts.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
using namespace NLNET;
|
||||
|
||||
/** A test module that transmit and receive message to test big message and message ordering.
|
||||
* Must work in collaboration with CFEServerModuleTest.
|
||||
*
|
||||
* The protocol is the following :
|
||||
* - Client wait server module up
|
||||
* - Client send a first 'hello' message
|
||||
* - -> server send back a 'start test' messages, then send 100 small message with serial number inside
|
||||
* - -> client receive the 100 small message
|
||||
* - -> client send 100 small messages with serial number inside
|
||||
* (this test the packet ordering basics)
|
||||
* - After server have received the 100 messages, it send 'part2' to the client
|
||||
* -> server start sending 100 message with variable size (from 10B to 1MB), one mesage by tick
|
||||
* -> client start sending 100 message of variable size (from 10B to 1MB with a predefined rule), on message by tick
|
||||
* (this test big message transfert, with ordering and bidirectionnal comm)
|
||||
* For each message series, the receiver part validate the message ordering.
|
||||
*/
|
||||
class CFEClientModuleTest : public CEmptyModuleServiceBehav<CEmptySocketBehav<CModuleBase> >
|
||||
{
|
||||
public:
|
||||
TModuleProxyPtr Server;
|
||||
|
||||
enum TTestState
|
||||
{
|
||||
ts_wait_start,
|
||||
ts_receive_part1,
|
||||
ts_wait_part2,
|
||||
ts_send_recv_part2,
|
||||
ts_receive_part2,
|
||||
ts_end
|
||||
};
|
||||
|
||||
TTestState TestState;
|
||||
|
||||
// serial counter for reception
|
||||
uint32 ReceiveSerial;
|
||||
// send counter
|
||||
uint32 SendCounter;
|
||||
|
||||
// random number generator for packet size
|
||||
CRandom RandS;
|
||||
CRandom RandR;
|
||||
|
||||
CFEClientModuleTest()
|
||||
: TestState(ts_end)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void onModuleUp(IModuleProxy *moduleProxy)
|
||||
{
|
||||
if (moduleProxy->getModuleClassName() == "FEServerModuleTest")
|
||||
{
|
||||
nlassert(TestState == ts_end);
|
||||
nlassert(Server == NULL);
|
||||
// store the server
|
||||
Server = moduleProxy;
|
||||
|
||||
nldebug("Test module is up, sending 'HELLO'");
|
||||
// start the comm by sending a
|
||||
CMessage start("HELLO");
|
||||
|
||||
Server->sendModuleMessage(this, start);
|
||||
|
||||
TestState = ts_wait_start;
|
||||
}
|
||||
}
|
||||
virtual void onModuleDown(IModuleProxy *moduleProxy)
|
||||
{
|
||||
if (moduleProxy == Server)
|
||||
{
|
||||
nldebug("Test module is down");
|
||||
TestState = ts_end;
|
||||
Server = NULL;
|
||||
}
|
||||
}
|
||||
virtual bool onProcessModuleMessage(IModuleProxy *senderModuleProxy, const CMessage &message)
|
||||
{
|
||||
string msgName = message.getName();
|
||||
if (msgName == "START")
|
||||
{
|
||||
nlassert(TestState == ts_wait_start);
|
||||
|
||||
nldebug("Received 'START', waiting for 100 message from server");
|
||||
// set in reception part 1
|
||||
TestState = ts_receive_part1;
|
||||
ReceiveSerial = 0;
|
||||
}
|
||||
else if (msgName == "MSG_PART1")
|
||||
{
|
||||
nlassert(TestState == ts_receive_part1);
|
||||
|
||||
uint32 serial0;
|
||||
nlRead(message, serial, serial0);
|
||||
|
||||
nlassert(serial0 == ReceiveSerial);
|
||||
++ReceiveSerial;
|
||||
|
||||
nldebug("Received 'MSG_PART1' number %u / 100", serial0);
|
||||
if (ReceiveSerial == 100)
|
||||
{
|
||||
// send 100 message to the server
|
||||
for (uint32 i=0; i<100; ++i)
|
||||
{
|
||||
CMessage msg("MSG_PART1");
|
||||
nlRead(message, serial, i);
|
||||
|
||||
Server->sendModuleMessage(this, msg);
|
||||
}
|
||||
TestState = ts_wait_part2;
|
||||
}
|
||||
}
|
||||
else if (msgName == "PART2")
|
||||
{
|
||||
nlassert(TestState == ts_wait_part2);
|
||||
|
||||
nldebug("Received 'PART2', begin send/receive varaible message");
|
||||
|
||||
TestState = ts_send_recv_part2;
|
||||
SendCounter = 0;
|
||||
ReceiveSerial = 0;
|
||||
|
||||
RandS.srand(123456);
|
||||
RandR.srand(123456);
|
||||
}
|
||||
else if (msgName == "MSG_PART2")
|
||||
{
|
||||
nlassert(TestState == ts_send_recv_part2
|
||||
|| TestState == ts_receive_part2 );
|
||||
|
||||
nlassert(ReceiveSerial <= 100);
|
||||
|
||||
uint32 serial0;
|
||||
nlRead(message, serial, serial0);
|
||||
nlassert(serial0 == ReceiveSerial);
|
||||
++ReceiveSerial;
|
||||
|
||||
uint32 size = RandR.rand()>>4;
|
||||
|
||||
for (uint i=0; i<size; ++i)
|
||||
{
|
||||
uint8 b;
|
||||
nlRead(message, serial, b);
|
||||
|
||||
nlassert(b == uint8(i));
|
||||
}
|
||||
// check that all the buffer have been read
|
||||
nlassert(message.length() == (uint32)message.getPos());
|
||||
|
||||
nldebug("Received 'MSG_PART2' number %u/100, size = %u", serial0, size);
|
||||
|
||||
if (ReceiveSerial == 100)
|
||||
{
|
||||
nldebug("End of part2, test terminated");
|
||||
TestState = ts_end;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void onModuleSecurityChange(IModuleProxy *moduleProxy)
|
||||
{
|
||||
// glop
|
||||
}
|
||||
|
||||
|
||||
virtual void onModuleUpdate()
|
||||
{
|
||||
if (TestState == ts_send_recv_part2)
|
||||
{
|
||||
CMessage message("MSG_PART2");
|
||||
message.serial(SendCounter);
|
||||
++SendCounter;
|
||||
|
||||
// select a packed size up to 1 MB
|
||||
uint32 size = RandS.rand()>>4;
|
||||
|
||||
for (uint i=0; i<size; ++i)
|
||||
{
|
||||
uint8 b = uint8(i);
|
||||
message.serial(b);
|
||||
}
|
||||
|
||||
nldebug("Sending 'MSG_PART2' number %u / 100, size = %u", SendCounter, size);
|
||||
// send
|
||||
Server->sendModuleMessage(this, message);
|
||||
|
||||
if (SendCounter == 100)
|
||||
{
|
||||
// all packed send, wait for reception to end now
|
||||
if (ReceiveSerial < 100)
|
||||
TestState = ts_receive_part2;
|
||||
else
|
||||
TestState = ts_end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
NLNET_REGISTER_MODULE_FACTORY(CFEClientModuleTest, string("FEClientModuleTest"));
|
@ -0,0 +1,356 @@
|
||||
/** \file time_client.cpp
|
||||
* <File description>
|
||||
*
|
||||
* $Id: time_client.cpp,v 1.1 2005/07/11 15:22:33 cado Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//#include "stdpch.h"
|
||||
|
||||
|
||||
/////////////
|
||||
// INCLUDE //
|
||||
/////////////
|
||||
// Misc;
|
||||
#include "nel/misc/debug.h"
|
||||
#include "nel/misc/hierarchical_timer.h"
|
||||
// client.
|
||||
#include "time_client.h"
|
||||
#include "client_cfg.h"
|
||||
#include "game_share/zc_shard_common.h"
|
||||
//#include "weather.h"
|
||||
//#include "game_share/light_cycle.h"
|
||||
// Std.
|
||||
#include <map>
|
||||
|
||||
|
||||
///////////
|
||||
// USING //
|
||||
///////////
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
|
||||
|
||||
////////////
|
||||
// GLOBAL //
|
||||
////////////
|
||||
sint64 T0 = 0; // Time for the last frame.
|
||||
sint64 T1 = 0; // Time for the current frame.
|
||||
sint64 TS = 0; // Time since the really first Frame.
|
||||
sint64 DT64 = 0; // Diff time with current and last frame in ms.
|
||||
float DT = 0.f; // Diff time with current and last frame in sec.
|
||||
TTime TSend = 0; // Next Time to send motions.
|
||||
TTime DTSend = 100; // Delta of time to generate the next time to send motions.
|
||||
double TimeInSec = 0.0; // Time for the current frame in second.
|
||||
double FirstTimeInSec = 0.0; // Game local origin time
|
||||
float TimeFactor = 1.f; // Factor applied to current date (local mode only)
|
||||
|
||||
|
||||
TTime LCT = 1000; // Default LCT (Lag Compensation time).
|
||||
TTime LocalTimeStep = 100; // Time Step factor on the client.
|
||||
TTime CurrentPacketTime = 0; // Local Time for the current packet.
|
||||
uint8 CurrentPacket = 0; // Packet currently valid.
|
||||
uint8 LastPacketReceived = 0; // Last received packet.
|
||||
uint8 LastPacketAck = 0; // Last acknowledged packet.
|
||||
|
||||
NLMISC::TGameCycle LastGameCycle = 0;
|
||||
|
||||
CRyzomTime RT;
|
||||
CClientDate SmoothedClientDate;
|
||||
|
||||
// Hierachical timer
|
||||
H_AUTO_DECL ( RZ_Client_Update_Time )
|
||||
|
||||
|
||||
///////////
|
||||
// LOCAL //
|
||||
///////////
|
||||
// Map with all time for each packet sent to the server.
|
||||
map<uint8, TTime> PacketTime;
|
||||
// Map with all Infos for each packet received.
|
||||
map<uint8, CPacketInfos> PacketInfos;
|
||||
|
||||
|
||||
///////////////
|
||||
// FUNCTIONS //
|
||||
///////////////
|
||||
//-----------------------------------------------
|
||||
// removePacketTime :
|
||||
// Remove the packet 'numPacket' from the 'PacketTime' list.
|
||||
//-----------------------------------------------
|
||||
void removePacketTime(uint8 numPacket)
|
||||
{
|
||||
PacketTime.erase(numPacket);
|
||||
}// removePacketTime //
|
||||
|
||||
//-----------------------------------------------
|
||||
// insertPacketTime :
|
||||
// Insert a packet in the PacketTime map.
|
||||
//-----------------------------------------------
|
||||
void insertPacketTime(uint8 numPacket, TTime time)
|
||||
{
|
||||
PacketTime.insert(make_pair(numPacket, time));
|
||||
}// insertPacketTime //
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// checkLocalTimeStep :
|
||||
// Check if the Local Time Step is still valid with the new packet.
|
||||
//-----------------------------------------------
|
||||
void checkLocalTimeStep(const CPacketInfos &packetInfos)
|
||||
{
|
||||
// Compute how many packets there are since the current packet.
|
||||
sint nbPacket = packetInfos.Num - CurrentPacket;
|
||||
if(nbPacket < 0)
|
||||
nbPacket += 256;
|
||||
|
||||
// \todo GUIGUI : check why this happen.
|
||||
if(nbPacket==0)
|
||||
return;
|
||||
|
||||
// Compute the predicted Local Time for this packet.
|
||||
TTime predictedTime = CurrentPacketTime + LocalTimeStep*nbPacket;
|
||||
|
||||
TTime localTimeStep = LocalTimeStep;
|
||||
|
||||
// If the predicted time is too small according to the min time computed for the packet -> increase 'LocalTimeStep'.
|
||||
if(predictedTime < packetInfos.Min)
|
||||
{
|
||||
// nlwarning("packetInfos.Min : %f", (double)packetInfos.Min);
|
||||
// nlwarning("CurrentPacketTime : %f", (double)CurrentPacketTime);
|
||||
// nlwarning("packetInfos.Min - CurrentPacketTime : %f", (double)((double)packetInfos.Min - (double)CurrentPacketTime));
|
||||
|
||||
LocalTimeStep = (packetInfos.Min - CurrentPacketTime)/nbPacket;
|
||||
|
||||
// nlwarning("LocalTimeStep : %f", (double)LocalTimeStep);
|
||||
}
|
||||
// If the predicted time is too big according to the max time computed for the packet -> increase 'LocalTimeStep'.
|
||||
else if(predictedTime > packetInfos.Max)
|
||||
{
|
||||
// nlwarning("packetInfos.Max : %f", (double)packetInfos.Max);
|
||||
// nlwarning("CurrentPacketTime : %f", (double)CurrentPacketTime);
|
||||
// nlwarning("packetInfos.Max - CurrentPacketTime : %f", (double)((double)packetInfos.Max - (double)CurrentPacketTime));
|
||||
|
||||
LocalTimeStep = (packetInfos.Max - CurrentPacketTime)/nbPacket;
|
||||
|
||||
// nlwarning("LocalTimeStep : %f", (double)LocalTimeStep);
|
||||
}
|
||||
|
||||
if(LocalTimeStep == 0)
|
||||
{
|
||||
LocalTimeStep = localTimeStep;
|
||||
// nlwarning("LocalTimeStep (corrected): %f", (double)LocalTimeStep);
|
||||
}
|
||||
}// checkLocalTimeStep //
|
||||
|
||||
//-----------------------------------------------
|
||||
// removePacket :
|
||||
// Remove the packet 'numPacket' from the 'PacketInfos' list.
|
||||
//-----------------------------------------------
|
||||
void removePacket(uint8 numPacket)
|
||||
{
|
||||
PacketInfos.erase(numPacket);
|
||||
}// removePacket //
|
||||
|
||||
//-----------------------------------------------
|
||||
// insertPacket :
|
||||
// Insert the packet received informations in a list.
|
||||
//-----------------------------------------------
|
||||
void insertPacket(const CPacketInfos &packetInfos)
|
||||
{
|
||||
// Upadte the last packet received.
|
||||
LastPacketReceived = packetInfos.Num;
|
||||
|
||||
// Insert the packet informations.
|
||||
PacketInfos.insert(make_pair(LastPacketReceived, packetInfos));
|
||||
|
||||
// Check Local Time Step with the new packet.
|
||||
checkLocalTimeStep(packetInfos);
|
||||
}// insertPacket //
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// getSentPacketTime :
|
||||
// Return the sent time for a given packet or 0 if the packet is not found
|
||||
//-----------------------------------------------
|
||||
TTime getSentPacketTime(uint8 numPacket)
|
||||
{
|
||||
map<uint8, TTime>::iterator it = PacketTime.find(numPacket);
|
||||
if(it != PacketTime.end())
|
||||
return (*it).second;
|
||||
else
|
||||
return 0;
|
||||
}// getSentPacketTime //
|
||||
|
||||
//-----------------------------------------------
|
||||
// ackPacketTimeBefore :
|
||||
//
|
||||
//-----------------------------------------------
|
||||
void ackPacketTimeBefore(uint8 ackPacketNumber)
|
||||
{
|
||||
// If the acknowledged packet is not in the list -> player do not have send any packet for the time.
|
||||
map<uint8, TTime>::iterator itEnd = PacketTime.find(ackPacketNumber);
|
||||
if(itEnd != PacketTime.end())
|
||||
{
|
||||
// If the packet cannot be found -> First valid packet the server is acknowledging
|
||||
map<uint8, TTime>::iterator itBegin = PacketTime.find(LastPacketAck);
|
||||
if(itBegin != PacketTime.end())
|
||||
{
|
||||
while(itBegin != itEnd)
|
||||
{
|
||||
//
|
||||
map<uint8, TTime>::iterator itTmp = itBegin;
|
||||
itBegin++;
|
||||
// Destroy packets between the last acknowledged packet and the recent one.
|
||||
PacketTime.erase(itTmp);
|
||||
|
||||
if(itBegin == PacketTime.end())
|
||||
itBegin = PacketTime.begin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LastPacketAck = ackPacketNumber;
|
||||
}// ackPacketTimeBefore //
|
||||
|
||||
//-----------------------------------------------
|
||||
// initClientTime
|
||||
//
|
||||
//-----------------------------------------------
|
||||
void initClientTime()
|
||||
{}
|
||||
|
||||
//-----------------------------------------------
|
||||
|
||||
void releaseClientTime()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// updateClientTime :
|
||||
//
|
||||
//-----------------------------------------------
|
||||
|
||||
void updateClientTime()
|
||||
{
|
||||
H_AUTO_USE ( RZ_Client_Update_Time )
|
||||
|
||||
// Last T0
|
||||
T0 = T1;
|
||||
|
||||
// Constant delta time ?
|
||||
//if (ClientCfg.ForceDeltaTime == 0)
|
||||
{
|
||||
T1 = ryzomGetLocalTime();
|
||||
if (T1 == T0)
|
||||
{
|
||||
// This case is known to occurs if the framerate is very fast (e.g. during the
|
||||
// loading stage) or if the machine has got a heavy load (e.g. lots of AGP data)
|
||||
// delaying the timer updates.
|
||||
//nlwarning ("getLocalTime has returned the same time! START");
|
||||
while (T1 == T0)
|
||||
{
|
||||
T1 = ryzomGetLocalTime();
|
||||
// give up the time slice to let time to other process
|
||||
NLMISC::nlSleep(0);
|
||||
}
|
||||
//nlwarning ("getLocalTime has returned the same time! END");
|
||||
}
|
||||
}
|
||||
/*else
|
||||
{
|
||||
// First time ?
|
||||
static bool firstTime = true;
|
||||
if (firstTime)
|
||||
{
|
||||
T1 = ryzomGetLocalTime();
|
||||
firstTime = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
T1 += ClientCfg.ForceDeltaTime;
|
||||
}
|
||||
}*/
|
||||
|
||||
if(T0 == T1)
|
||||
nlwarning("updateClientTime: T0 should not be = T1.");
|
||||
|
||||
// Update time variables
|
||||
DT64 = T1-T0;
|
||||
TS += DT64;
|
||||
DT = ((float)DT64)*0.001f;
|
||||
|
||||
TimeInSec = T1*0.001;
|
||||
|
||||
// First time ?
|
||||
if (FirstTimeInSec == 0.0)
|
||||
FirstTimeInSec = TimeInSec;
|
||||
}// updateClientTime //
|
||||
|
||||
|
||||
// update smoothed time
|
||||
/*void updateSmoothedTime()
|
||||
{
|
||||
#define REAL_SECONDS_TO_RYZOM_HOUR(s) (double(s) * 10 / double(RYZOM_HOURS_IN_TICKS))
|
||||
//
|
||||
CClientDate oldSmoothedClientDate = SmoothedClientDate;
|
||||
double dHour = REAL_SECONDS_TO_RYZOM_HOUR(DT);
|
||||
SmoothedClientDate.Hour += (float) dHour;
|
||||
if (SmoothedClientDate.Hour > WorldLightCycle.NumHours)
|
||||
{
|
||||
SmoothedClientDate.Day += (sint32) ceil(dHour / WorldLightCycle.NumHours);
|
||||
SmoothedClientDate.Hour = (float) fmod(SmoothedClientDate.Hour, WorldLightCycle.NumHours);
|
||||
}
|
||||
double smoothedClientDateInHour = (double) SmoothedClientDate.Day * 24 + SmoothedClientDate.Hour;
|
||||
double ryzomDateInHour = (double) RT.getRyzomDay() * 24 + (double) DayNightCycleHour;
|
||||
const double SMOOTHED_DATE_MAX_ERROR_IN_RYZOM_HOUR = REAL_SECONDS_TO_RYZOM_HOUR(10);
|
||||
double hourError = fabs(smoothedClientDateInHour - ryzomDateInHour);
|
||||
if (hourError > SMOOTHED_DATE_MAX_ERROR_IN_RYZOM_HOUR)
|
||||
{
|
||||
if (smoothedClientDateInHour < ryzomDateInHour)
|
||||
{
|
||||
// smoothed time is late
|
||||
SmoothedClientDate.Day = RT.getRyzomDay();
|
||||
SmoothedClientDate.Hour = DayNightCycleHour;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hourError > (2 * SMOOTHED_DATE_MAX_ERROR_IN_RYZOM_HOUR))
|
||||
{
|
||||
// if difference is too big, rescale smoothed time on server time
|
||||
SmoothedClientDate.Day = RT.getRyzomDay();
|
||||
SmoothedClientDate.Hour = DayNightCycleHour;
|
||||
}
|
||||
else
|
||||
{
|
||||
// cancel time increment (wait until server time is up with smoothed client time)
|
||||
SmoothedClientDate = oldSmoothedClientDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,136 @@
|
||||
/** \file time_client.h
|
||||
* <File description>
|
||||
*
|
||||
* $Id: time_client.h,v 1.1 2005/07/11 15:22:33 cado Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef CL_TIME_CLIENT_H
|
||||
#define CL_TIME_CLIENT_H
|
||||
|
||||
|
||||
/////////////
|
||||
// INCLUDE //
|
||||
/////////////
|
||||
// Misc.
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/time_nl.h"
|
||||
// Game Share
|
||||
#include "game_share/time_weather_season/time_and_season.h"
|
||||
//#include "client_cfg.h"
|
||||
|
||||
///////////
|
||||
// USING //
|
||||
///////////
|
||||
using NLMISC::TTime;
|
||||
|
||||
class CClientDate;
|
||||
|
||||
////////////
|
||||
// GLOBAL //
|
||||
////////////
|
||||
extern sint64 T0; // Time for the last frame.
|
||||
extern sint64 T1; // Time for the current frame.
|
||||
extern sint64 TS; // Time since the really first Frame.
|
||||
extern sint64 DT64; // Diff time with current and last frame in ms.
|
||||
extern float DT; // Diff time with current and last frame in sec.
|
||||
extern TTime TSend; // Next Time to send motions.
|
||||
extern TTime DTSend; // Delta of time to generate the next time to send motions.
|
||||
extern double TimeInSec; // Time for the current frame in second.
|
||||
extern double FirstTimeInSec; // Game local origin time
|
||||
|
||||
|
||||
extern TTime LCT;
|
||||
extern TTime LocalTimeStep;
|
||||
extern TTime CurrentPacketTime;
|
||||
extern uint8 CurrentPacket;
|
||||
extern uint8 LastPacketReceived;
|
||||
|
||||
extern NLMISC::TGameCycle LastGameCycle;
|
||||
|
||||
extern CRyzomTime RT;
|
||||
|
||||
extern CClientDate SmoothedClientDate;
|
||||
|
||||
///////////
|
||||
// CLASS //
|
||||
///////////
|
||||
class CPacketInfos
|
||||
{
|
||||
public:
|
||||
uint8 Num;
|
||||
TTime Min;
|
||||
TTime Max;
|
||||
|
||||
CPacketInfos() {};
|
||||
CPacketInfos(uint8 num, TTime min, TTime max)
|
||||
{
|
||||
Num = num;
|
||||
Min = min;
|
||||
Max = max;
|
||||
}
|
||||
};
|
||||
|
||||
/** A representation of time in the client
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2003
|
||||
*/
|
||||
class CClientDate
|
||||
{
|
||||
public:
|
||||
sint32 Day;
|
||||
float Hour;
|
||||
CClientDate(sint32 day = 0, float hour = 0.f) : Day(day), Hour(hour) {}
|
||||
};
|
||||
|
||||
// 'less' comparison between 2 dates
|
||||
inline bool operator < (const CClientDate &lhs, const CClientDate &rhs)
|
||||
{
|
||||
if (lhs.Day != rhs.Day) return lhs.Day < rhs.Day;
|
||||
return lhs.Hour < rhs.Hour;
|
||||
}
|
||||
// equality between 2 dates
|
||||
inline bool operator == (const CClientDate &lhs, const CClientDate &rhs)
|
||||
{
|
||||
return lhs.Day == rhs.Day && lhs.Hour == rhs.Hour;
|
||||
}
|
||||
|
||||
///////////////
|
||||
// FUNCTIONS //
|
||||
///////////////
|
||||
void removePacketTime(uint8 numPacket);
|
||||
///
|
||||
void insertPacketTime(uint8 numPacket, TTime time);
|
||||
void ackPacketTimeBefore(uint8 ackPacketNumber);
|
||||
|
||||
void removePacket(uint8 numPacket);
|
||||
/// Insert the packet received informations in a list.
|
||||
void insertPacket(const CPacketInfos &packetInfos);
|
||||
/// Return the sent time for a given packet or 0 if the packet is not found
|
||||
TTime getSentPacketTime(uint8 numPacket);
|
||||
|
||||
// Initialize interface properties linked to the client time
|
||||
void initClientTime();
|
||||
|
||||
// This update T0, T1, DT64, DT, TS & TimeInSec
|
||||
void updateClientTime();
|
||||
|
||||
// update smoothed time (useful for sky animation)
|
||||
//void updateSmoothedTime();
|
||||
|
||||
inline TTime ryzomGetLocalTime ()
|
||||
{
|
||||
return (TTime)(NLMISC::CTime::ticksToSecond (NLMISC::CTime::getPerformanceTime()) * 1000.0);
|
||||
}
|
||||
|
||||
inline NLMISC::TTicks ryzomGetPerformanceTime()
|
||||
{
|
||||
return NLMISC::CTime::getPerformanceTime();
|
||||
}
|
||||
|
||||
#endif // CL_TIME_CLIENT_H
|
||||
|
||||
/* End of time_client.h */
|
@ -0,0 +1,4 @@
|
||||
RootConfigFilename = "client_default.cfg";
|
||||
LanguageCode = "fr";
|
||||
StartupHost = "r2linux03:80";
|
||||
R2EDExtendedDebug = 0;
|
@ -0,0 +1,531 @@
|
||||
//////////////////////////
|
||||
//////////////////////////
|
||||
/// CLIENT CONFIG FILE ///
|
||||
//////////////////////////
|
||||
//////////////////////////
|
||||
|
||||
|
||||
// If you set this variable to 1, your client.cfg will be overwritten when you quit the client.
|
||||
// You will loose all the comments and identation in this file.
|
||||
SaveConfig = 1;
|
||||
|
||||
///////////////////
|
||||
// WINDOW CONFIG //
|
||||
///////////////////
|
||||
Driver3D="Auto"; // Valid values are "Auto" or "0", "OpengGL" or "1" & "Direct3D" or "2"
|
||||
// "Auto" will choose the best suited driver depending on hardware
|
||||
FullScreen = 1;
|
||||
Width = 1024;
|
||||
Height = 768;
|
||||
PositionX = 0;
|
||||
PositionY = 0;
|
||||
Frequency = 60;
|
||||
Depth = 32;
|
||||
Sleep = -1;
|
||||
ProcessPriority = 0; // -2 = idle, -1 = below normal, 0 = normal, 1 = above normal, 2 = high, 3 = real time
|
||||
Contrast = 0.0; // -1.0 ~ 1.0
|
||||
Luminosity = 0.0; // -1.0 ~ 1.0
|
||||
Gamma = 0.0; // -1.0 ~ 1.0
|
||||
Contrast_min = -1.0;
|
||||
Luminosity_min = -1.0;
|
||||
Gamma_min = -1.0;
|
||||
Contrast_max = 1.0;
|
||||
Luminosity_max = 1.0;
|
||||
Gamma_max = 1.0;
|
||||
|
||||
|
||||
////////////////
|
||||
// INTERFACES //
|
||||
////////////////
|
||||
|
||||
// the language to use as in ISO 639-2
|
||||
LanguageCode = "en"; // english
|
||||
|
||||
XMLInputFile = "input_config_v3.xml";
|
||||
|
||||
XMLLoginInterfaceFiles = {
|
||||
"login_config.xml",
|
||||
"login_widgets.xml",
|
||||
"login_main.xml",
|
||||
"login_keys.xml",
|
||||
};
|
||||
|
||||
XMLOutGameInterfaceFiles = {
|
||||
"out_v2_config.xml",
|
||||
"out_v2_widgets.xml",
|
||||
"out_v2_connect.xml",
|
||||
"out_v2_intro.xml",
|
||||
"out_v2_select.xml",
|
||||
"out_v2_appear.xml",
|
||||
"out_v2_location.xml",
|
||||
"out_v2_crash.xml",
|
||||
"out_v2_hierarchy.xml",
|
||||
"out_v2_keys.xml",
|
||||
};
|
||||
|
||||
|
||||
// The ligo primitive class file
|
||||
LigoPrimitiveClass = "world_editor_classes.xml";
|
||||
|
||||
VerboseLog = 1;
|
||||
|
||||
SignUpURL = "http://www.ryzom.com/subscribe";
|
||||
|
||||
///////////
|
||||
// MOUSE //
|
||||
///////////
|
||||
HardwareCursor = 1;
|
||||
|
||||
CursorSpeed = 1.0; // In pixels per mickey
|
||||
CursorSpeed_min = 0.5;
|
||||
CursorSpeed_max = 2.0;
|
||||
|
||||
CursorAcceleration = 40; // Threshold in mickey
|
||||
CursorAcceleration_min = 20;
|
||||
CursorAcceleration_max = 80;
|
||||
|
||||
FreeLookSpeed = 0.004; // In radian per mickey
|
||||
FreeLookSpeed_min = 0.0001;
|
||||
FreeLookSpeed_max = 0.01;
|
||||
|
||||
FreeLookAcceleration = 40; // Threshold in mickey
|
||||
FreeLookAcceleration_min = 20;
|
||||
FreeLookAcceleration_max = 80;
|
||||
|
||||
FreeLookInverted = 0;
|
||||
|
||||
///////////////////
|
||||
// RENDER CONFIG //
|
||||
///////////////////
|
||||
|
||||
// NB: thoses variables configure also the InGameConfigurator:
|
||||
// _min and _max define the bounds
|
||||
// _step defines the step (NB: take care of _min and _max!!)
|
||||
// _ps0 is the LOW preset, _ps1 is the MEDIUM preset, _ps2 is the NORMAL Preset, and _ps3 is the HIGH one
|
||||
|
||||
|
||||
// *** LANDSCAPE
|
||||
LandscapeTileNear = 50.000000;
|
||||
LandscapeTileNear_min = 20.000000;
|
||||
LandscapeTileNear_max = 100.000000;
|
||||
LandscapeTileNear_step = 10.0;
|
||||
LandscapeTileNear_ps0 = 20.0;
|
||||
LandscapeTileNear_ps1 = 40.0;
|
||||
LandscapeTileNear_ps2 = 50.0;
|
||||
LandscapeTileNear_ps3 = 80.0;
|
||||
|
||||
// NB: threshold is inverted ULandscape::setThreshold(), to be more intelligible
|
||||
LandscapeThreshold = 1000.0;
|
||||
LandscapeThreshold_min = 100.0; // Low quality => 0.01 threshold
|
||||
LandscapeThreshold_max = 2000.0; // High quality => 0.0005 threshold
|
||||
LandscapeThreshold_step = 100.0;
|
||||
LandscapeThreshold_ps0 = 100.0;
|
||||
LandscapeThreshold_ps1 = 500.0;
|
||||
LandscapeThreshold_ps2 = 1000.0;
|
||||
LandscapeThreshold_ps3 = 2000.0;
|
||||
|
||||
Vision = 500.000000;
|
||||
Vision_min = 200.000000;
|
||||
Vision_max = 800.000000;
|
||||
Vision_step = 100.000000;
|
||||
Vision_ps0 = 200.0;
|
||||
Vision_ps1 = 400.0;
|
||||
Vision_ps2 = 500.0;
|
||||
Vision_ps3 = 800.0;
|
||||
|
||||
MicroVeget = 1; // Enable/Disable MicroVeget.
|
||||
MicroVeget_ps0 = 0;
|
||||
MicroVeget_ps1 = 1;
|
||||
MicroVeget_ps2 = 1;
|
||||
MicroVeget_ps3 = 1;
|
||||
|
||||
MicroVegetDensity = 80.0;
|
||||
MicroVegetDensity_min = 10.0;
|
||||
MicroVegetDensity_max = 100.0;
|
||||
MicroVegetDensity_step = 10.0;
|
||||
MicroVegetDensity_ps0 = 10.0; // not used since disabled!
|
||||
MicroVegetDensity_ps1 = 30.0;
|
||||
MicroVegetDensity_ps2 = 80.0;
|
||||
MicroVegetDensity_ps3 = 100.0;
|
||||
|
||||
|
||||
// *** FX
|
||||
FxNbMaxPoly = 10000;
|
||||
FxNbMaxPoly_min = 2000;
|
||||
FxNbMaxPoly_max = 20000;
|
||||
FxNbMaxPoly_step= 2000;
|
||||
FxNbMaxPoly_ps0 = 2000;
|
||||
FxNbMaxPoly_ps1 = 6000;
|
||||
FxNbMaxPoly_ps2 = 10000;
|
||||
FxNbMaxPoly_ps3 = 16000;
|
||||
|
||||
Cloud = 1;
|
||||
Cloud_ps0 = 0 ;
|
||||
Cloud_ps1 = 1 ;
|
||||
Cloud_ps2 = 1 ;
|
||||
Cloud_ps3 = 1 ;
|
||||
|
||||
CloudQuality = 160.0;
|
||||
CloudQuality_min = 80.0;
|
||||
CloudQuality_max = 320.0;
|
||||
CloudQuality_step = 20.0;
|
||||
CloudQuality_ps0 = 80.0; // not used since disabled!
|
||||
CloudQuality_ps1 = 80.0;
|
||||
CloudQuality_ps2 = 160.0;
|
||||
CloudQuality_ps3 = 320.0;
|
||||
|
||||
CloudUpdate = 1;
|
||||
CloudUpdate_min = 1;
|
||||
CloudUpdate_max = 8;
|
||||
CloudUpdate_step= 1;
|
||||
CloudUpdate_ps0 = 1; // not used since disabled!
|
||||
CloudUpdate_ps1 = 1;
|
||||
CloudUpdate_ps2 = 1;
|
||||
CloudUpdate_ps3 = 3;
|
||||
|
||||
Shadows = 1;
|
||||
Shadows_ps0 = 0;
|
||||
Shadows_ps1 = 1;
|
||||
Shadows_ps2 = 1;
|
||||
Shadows_ps3 = 1;
|
||||
|
||||
Bloom = 1;
|
||||
Bloom_ps0 = 0;
|
||||
Bloom_ps1 = 1;
|
||||
Bloom_ps2 = 1;
|
||||
Bloom_ps3 = 1;
|
||||
|
||||
SquareBloom = 1;
|
||||
SquareBloom_ps0 = 0;
|
||||
SquareBloom_ps1 = 1;
|
||||
SquareBloom_ps2 = 1;
|
||||
SquareBloom_ps3 = 1;
|
||||
|
||||
DensityBloom = 255.0;
|
||||
DensityBloom_min = 0.0;
|
||||
DensityBloom_max = 255.0;
|
||||
DensityBloom_step = 1.0;
|
||||
DensityBloom_ps0 = 255.0;
|
||||
DensityBloom_ps1 = 255.0;
|
||||
DensityBloom_ps2 = 255.0;
|
||||
DensityBloom_ps3 = 255.0;
|
||||
|
||||
|
||||
// *** CHARACTERS
|
||||
SkinNbMaxPoly = 50000;
|
||||
SkinNbMaxPoly_min = 5000;
|
||||
SkinNbMaxPoly_max = 70000;
|
||||
SkinNbMaxPoly_step = 5000;
|
||||
SkinNbMaxPoly_ps0 = 10000;
|
||||
SkinNbMaxPoly_ps1 = 30000;
|
||||
SkinNbMaxPoly_ps2 = 50000;
|
||||
SkinNbMaxPoly_ps3 = 70000;
|
||||
|
||||
NbMaxSkeletonNotCLod = 20;
|
||||
NbMaxSkeletonNotCLod_min = 5;
|
||||
NbMaxSkeletonNotCLod_max = 30;
|
||||
NbMaxSkeletonNotCLod_step = 5;
|
||||
NbMaxSkeletonNotCLod_ps0 = 10;
|
||||
NbMaxSkeletonNotCLod_ps1 = 15;
|
||||
NbMaxSkeletonNotCLod_ps2 = 20;
|
||||
NbMaxSkeletonNotCLod_ps3 = 30;
|
||||
|
||||
CharacterFarClip = 100.0;
|
||||
CharacterFarClip_min = 50.0;
|
||||
CharacterFarClip_max = 200.0;
|
||||
CharacterFarClip_step = 10.0;
|
||||
CharacterFarClip_ps0 = 50.0;
|
||||
CharacterFarClip_ps1 = 80.0;
|
||||
CharacterFarClip_ps2 = 100.0;
|
||||
CharacterFarClip_ps3 = 200.0;
|
||||
|
||||
EnableRacialAnimation = 1;
|
||||
|
||||
// *** MISC
|
||||
// This is the actual aspect ratio of your screen (no relation with the resolution!!). Set 1.7777 if you got a 16/9 screen for instance
|
||||
ScreenAspectRatio = 1.33333;
|
||||
ForceDXTC = 1; // Enable/Disable DXTC.
|
||||
DivideTextureSizeBy2= 0; // Divide texture size
|
||||
DisableVtxProgram = 0; // Disable Hardware Vertex Program.
|
||||
DisableVtxAGP = 0; // Disable Hardware Vertex AGP.
|
||||
DisableTextureShdr = 0; // Disable Hardware Texture Shader.
|
||||
HDEntityTexture = 0;
|
||||
HDTextureInstalled = 1;
|
||||
WaitVBL = 0; // 0 or 1 to wait Vertical Sync.
|
||||
|
||||
//////////////////
|
||||
// GAME OPTIONS //
|
||||
//////////////////
|
||||
SelectWithRClick = 1;
|
||||
DisplayWeapons = 1;
|
||||
RotKeySpeedMax = 2.0;
|
||||
RotKeySpeedMax_min = 1.0;
|
||||
RotKeySpeedMax_max = 4.0;
|
||||
RotKeySpeedMin = 1.0;
|
||||
RotKeySpeedMin_min = 0.5;
|
||||
RotKeySpeedMin_max = 2.0;
|
||||
RotAccel = 3.0;
|
||||
FollowOnAtk = 0;
|
||||
AtkOnSelect = 0;
|
||||
ZCPacsPrim = "gen_bt_col_ext.pacs_prim";
|
||||
|
||||
/////////////////
|
||||
// PREFERENCES //
|
||||
/////////////////
|
||||
FPV = 0; // FPV(First Person View) : default is false (Third Person View).
|
||||
CameraHeight = 2.2; // Camera Height (in meter) from the ground (for the Third Person View).
|
||||
CameraDistance = 3.0; // Camera Distance(in meter) from the user (for the Third Person View).
|
||||
CameraDistStep = 1.0;
|
||||
CameraDistMin = 1.0;
|
||||
CameraDistMax = 5.0;
|
||||
CameraAccel = 5.0;
|
||||
CameraSpeedMin = 2.0;
|
||||
CameraSpeedMax = 100.0;
|
||||
CameraResetSpeed = 10.0; // Speed in radian/s
|
||||
|
||||
//////////////////
|
||||
// SOUND CONFIG //
|
||||
//////////////////
|
||||
SoundForceSoftwareBuffer= 1;
|
||||
SoundOn = 1;
|
||||
UseEax = 0;
|
||||
|
||||
MaxTrack = 32;
|
||||
MaxTrack_min = 4;
|
||||
MaxTrack_max = 32;
|
||||
MaxTrack_step = 4;
|
||||
|
||||
// This is the volume for "InGame" sound FXs
|
||||
SoundSFXVolume = 1.0;
|
||||
SoundSFXVolume_min = 0.0;
|
||||
SoundSFXVolume_max = 1.0;
|
||||
SoundSFXVolume_step = 0.001;
|
||||
|
||||
// This is volume for "InGame" music. Does not affect the MP3 player
|
||||
SoundGameMusicVolume = 0.5;
|
||||
SoundGameMusicVolume_min = 0.0;
|
||||
SoundGameMusicVolume_max = 1.0;
|
||||
SoundGameMusicVolume_step = 0.001;
|
||||
|
||||
// MISC
|
||||
PreDataPath = { "user", "patch", "data", "examples" };
|
||||
// DataPath = { "user", "patch", "data", "examples" };
|
||||
NeedComputeVS = 0;
|
||||
|
||||
NegFiltersDebug = {"Update DB", "Reading:", "Read Value :", "impulseCallBack", "CLIMPD:", "LNET" };
|
||||
NegFiltersInfo = { "CLIMPD:", "CPath::lookup" , "LNET" };
|
||||
NegFiltersWarning = { "'basics.Equipment Slot'.", "_usercolor.tga", "PACS" };
|
||||
|
||||
// Big screen shot
|
||||
ScreenShotWidth = 0;
|
||||
ScreenShotHeight = 0;
|
||||
ScreenShotFullDetail = 1; // 1 to switch full detail mode for characters (both standard & big screenshots)
|
||||
|
||||
// Read : "ID", "R G B A MODE [FX]"
|
||||
SystemInfoColors =
|
||||
{
|
||||
// OLD STUFF Here for compatibility
|
||||
"RG", "0 0 0 255 normal", // Black to see when there is an error
|
||||
"BC", "0 0 0 255 normal", // Black to see when there is an error
|
||||
"JA", "0 0 0 255 normal", // Black to see when there is an error
|
||||
"BL", "0 0 0 255 normal", // Black to see when there is an error
|
||||
"VE", "0 0 0 255 normal", // Black to see when there is an error
|
||||
"VI", "0 0 0 255 normal", // Black to see when there is an error
|
||||
|
||||
// NEW System Info Categories
|
||||
"SYS", "255 255 255 255 normal", // Default system messages
|
||||
"BC", "255 255 255 255 center", // Broadcast messages
|
||||
"TAGBC", "255 255 255 255 center", // Taged broadcast messages : color should remain white as some word are tagged
|
||||
"XP", "255 255 64 255 over", // XP Gain
|
||||
"SP", "255 255 64 255 over", // SP Gain
|
||||
"TTL", "255 255 64 255 over", // Title
|
||||
"TSK", "255 255 255 255 over", // Task
|
||||
"ZON", "255 255 255 255 center", // Zone
|
||||
"DG", "255 0 0 255 normal", // Damage to me
|
||||
"DMG", "255 0 0 255 normal", // Damage to me
|
||||
"DGP", "200 0 0 255 normal", // Damage to me from player
|
||||
"DGM", "255 128 64 255 normal", // Damage from me
|
||||
"MIS", "150 150 150 255 normal", // The opponent misses
|
||||
"MISM", "255 255 255 255 normal", // I miss
|
||||
"ITM", "0 200 0 255 over", // Item
|
||||
"ITMF", "220 0 220 255 over", // Item failed
|
||||
"SPL", "50 50 250 255 normal", // Spell to me
|
||||
"SPLM", "50 150 250 255 normal", // Spell from me
|
||||
"EMT", "255 150 150 255 normal", // Emote
|
||||
"MTD", "255 255 0 255 over", // Message Of The Day
|
||||
"FORLD","64 255 64 255 overonly", // Forage Locate Deposit
|
||||
"CHK", "255 120 60 255 center", // Tous ce qui ne remplit pas une condition
|
||||
"CHKCB","255 255 0 255 center", // Tous ce qui ne remplit pas une condition en combat (trop loin, cible invalide, pas assez de mana, etc.)
|
||||
"PVPTM","255 120 60 255 overonly", // PVP timer
|
||||
"THM", "255 255 64 255 over misc_levelup.ps", // Thema finished
|
||||
"AMB", "255 255 64 255 center", // Ambiance
|
||||
"ISE", "192 208 255 255 normal", // Item special effect
|
||||
"ISE2", "192 208 255 255 center", // Item special effect with center text (for effects without flying text)
|
||||
"OSM", "128 160 255 255 center", // Outpost state message
|
||||
"AROUND","255 255 0 255 around" // Only in around channel
|
||||
};
|
||||
|
||||
PrintfCommands ={
|
||||
"634","478","0 0 0 255","24","uiTextCommand1",
|
||||
"624","428","0 0 0 255","18","uiTextCommand2",
|
||||
"624","378","0 0 0 255","14","uiTextCommand3",
|
||||
"644","278","0 0 0 255","18","uiTextCommand4",
|
||||
"632","480","255 255 255 255","24","uiTextCommand1",
|
||||
"622","430","255 255 255 255","18","uiTextCommand2",
|
||||
"622","380","255 255 255 255","14","uiTextCommand3",
|
||||
"642","280","255 255 255 255","18","uiTextCommand4"
|
||||
};
|
||||
|
||||
PrintfCommandsFreeTrial ={
|
||||
"634","478","0 0 0 255","24","uiTextCommandFT1",
|
||||
"634","428","0 0 0 255","12","uiTextCommandFT2",
|
||||
"634","378","0 0 0 255","12","uiTextCommandFT3",
|
||||
"684","278","0 0 0 255","10","uiTextCommandFT4",
|
||||
"632","480","255 255 255 255","24","uiTextCommandFT1",
|
||||
"632","430","255 255 255 255","12","uiTextCommandFT2",
|
||||
"632","380","255 255 255 255","12","uiTextCommandFT3",
|
||||
"682","280","255 255 255 255","10","uiTextCommandFT4"
|
||||
};
|
||||
|
||||
DisplayMissingAnimFile = 0;
|
||||
|
||||
LoadingStringCount = 54;
|
||||
|
||||
|
||||
// Some R2 parameters ...
|
||||
|
||||
R2Mode = 1;
|
||||
R2EDEnabled = 1;
|
||||
R2EDExtendedDebug = 0;
|
||||
R2EDLightPalette = 0;
|
||||
R2ClientGw = "r2linux01";
|
||||
LoadLuaDebugger = 0;
|
||||
CheckR2ScenarioMD5 = 1;
|
||||
LevelDesignEnabled = 0;
|
||||
|
||||
Application = { "r2", "./client_ryzom_dev_rd.exe", "./" };
|
||||
StartupHost = "rsring03.juk.shards.nevrax.com";
|
||||
StartupPage = "/login2/r2_login.php";
|
||||
|
||||
DmCameraDistMax = 25;
|
||||
DmRun = 20;
|
||||
DmWalk = 6;
|
||||
|
||||
R2EDReloadFiles = {
|
||||
"r2ed.xml",
|
||||
"r2_basic_bricks.lua",
|
||||
"r2_components.lua",
|
||||
"r2_core.lua",
|
||||
"r2_features_default.lua",
|
||||
"r2_features_fauna.lua",
|
||||
"r2_features_npc_groups.lua",
|
||||
"r2_palette.lua",
|
||||
"r2_scenario.lua",
|
||||
"r2_ui.lua"
|
||||
};
|
||||
|
||||
XMLInterfaceFiles = {
|
||||
"config.xml",
|
||||
"widgets.xml",
|
||||
"player.xml",
|
||||
"inventory.xml",
|
||||
"interaction.xml",
|
||||
"phrase.xml",
|
||||
"harvest.xml",
|
||||
"macros.xml",
|
||||
"info_player.xml",
|
||||
"outpost.xml",
|
||||
"guild.xml",
|
||||
"taskbar.xml",
|
||||
"game_config.xml",
|
||||
"game_context_menu.xml",
|
||||
"player_trade.xml",
|
||||
"bot_chat_v4.xml",
|
||||
"compass.xml",
|
||||
"map.xml",
|
||||
"hierarchy.xml",
|
||||
"reset.xml",
|
||||
"actions.xml",
|
||||
"help.xml",
|
||||
"encyclopedia.xml",
|
||||
"commands.xml",
|
||||
"commands2.xml",
|
||||
"ring_access_point_filter.xml",
|
||||
"ring_window.xml",
|
||||
"bg_downloader.xml"
|
||||
};
|
||||
|
||||
XMLR2EDInterfaceFiles =
|
||||
{
|
||||
"r2ed.xml",
|
||||
"r2_triggers.xml",
|
||||
"r2_logic_entities.xml",
|
||||
"r2ed_acts.xml",
|
||||
"r2ed_scenario.xml",
|
||||
"r2ed_connect.xml"
|
||||
};
|
||||
|
||||
FogDistAndDepthLookupBias = 20; // bias for lookup of fog distance and depth
|
||||
|
||||
|
||||
// Hardware cursor textures
|
||||
// These will be extracted from the corresponding packed ui .tga files when they are loaded
|
||||
// *
|
||||
// * individual .tga files for hardware cursor bitmap not looked for, and not supported yet
|
||||
HardwareCursors =
|
||||
{"curs_can_pan.tga",
|
||||
"curs_can_pan_dup.tga",
|
||||
"curs_create.tga",
|
||||
"curs_create_multi.tga",
|
||||
"curs_create_vertex_invalid.tga",
|
||||
"curs_default.tga",
|
||||
"curs_dup.tga",
|
||||
"curs_L.tga",
|
||||
"curs_M.tga",
|
||||
"curs_pan.tga",
|
||||
"curs_pan_dup.tga",
|
||||
"curs_pick.tga",
|
||||
"curs_pick_dup.tga",
|
||||
"curs_R.tga",
|
||||
"curs_resize_BL_TR.tga",
|
||||
"curs_resize_BR_TL.tga",
|
||||
"curs_resize_LR.tga",
|
||||
"curs_resize_TB.tga",
|
||||
"curs_rotate.tga",
|
||||
"curs_scale.tga",
|
||||
"curs_stop.tga",
|
||||
"text_cursor.tga",
|
||||
"r2_hand_can_pan.tga",
|
||||
"r2_hand_pan.tga",
|
||||
"r2ed_tool_can_pick.tga",
|
||||
"r2ed_tool_can_rotate.tga",
|
||||
"r2ed_tool_pick.tga",
|
||||
"r2ed_tool_rotate.tga",
|
||||
"r2ed_tool_rotating.tga"};
|
||||
|
||||
ScenarioSavePath = "./My_Scenarios/";
|
||||
|
||||
// list ofpredefined keyset
|
||||
// name will be looked up in the translation file by searching 'uiCP_KeysetName_" + id
|
||||
// tooltip will be looked up in the translation file by searching 'uiCP_KeysetTooltip_" + id
|
||||
// 'bi.' stands for built-in
|
||||
// note : we add a dot in the name to be sure that there cannot be a conflict with character keyset name
|
||||
BuiltInKeySets =
|
||||
{
|
||||
"", // default ryzom keyboard layout
|
||||
"bi.zqsd", // european keyboard fps displacement style (NB : don't change this layout name, ryzom will automatically select it if keyboard if french or belgian)
|
||||
"bi.wasd", // english keyboard fps displacement style (NB : don't change this layout name, ryzom will automatically select it if keyboard is not french nor belgian)
|
||||
"bi.wow_alike" // 'world of warcraft' like keyboard style. (NB : not available for ring)
|
||||
};
|
||||
|
||||
//"Newbie Training", "Story Telling", "Mistery", "Hack & Slash", "Guild Training", "Other"
|
||||
ScenarioTypes = {"so_newbie_training","so_story_telling","so_mistery","so_hack_slash","so_guild_training","so_other"};
|
||||
|
||||
//ScenarioLanguages = {"French", "Deutsch", "English", "Other"};
|
||||
ScenarioLanguages = {"fr","de","en","other_lang"};
|
||||
|
||||
|
||||
BackgroundDownloader = 1;
|
||||
CreateAccountURL = "http://www.ryzom.com/profile";
|
||||
|
||||
BuildName="PRE_RELEASE_HEAD 135";
|