⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rmtool.cpp

📁 网络游戏龙族服务器端管理工具 rmtool 源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// RMTool.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "RMTool.h"
#include "MainFrm.h"
#include "ChildFrm.h"
#include "RMToolDoc.h"
//#include "IClientNet.h"
#include "Logindlg.h"
#include "Packet.h"
#include "ServerView.h"
#include "CharacterFrame.h"
#include "CharacterDoc.h"
#include "CharacterView.h"
#include "WaitDlg.h"
#include "SelectServersetDlg.h"
#include "Registry.h"

#include "Propertys.h"

#include "hsel.h"
#include "CharMgrView.h"		// BBD Test
#include "ChildFrm2.h"			// BBD Test

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//傈开 函荐 急攫篮 捞镑俊辑 
IOleDBThread *g_pDb		= NULL;		//IOleDbThread 牢磐其捞胶 器牢磐 
IFileTransfer *g_pFt	= NULL;
IClientNet	  *g_pNet	= NULL;

int CURRENT_SERVERSET_NUM = 0;
int DRAGON_DB[ MAX_SERVERSET_NUM ];		//CreateDBConnection();肺 罐酒柯 蔼...
char g_CurDbName[ MAX_SERVERSET_NUM ][ MAX_SCHEMA_BUFFER_SIZE ];		//泅犁 Connection俊 急琶登绢廉乐绰 DB Name
bool DecoadFile( char *filename, void *pData, int size );		//窃荐 急攫..hel.lib


//0: 惑侩 辑滚  (蜡乔弛)
//1: 2焙 辑滚   (秋墨匙胶)
//2: 俺惯磊 辑滚(海鸥)

int	TOTAL_DB = 0;
int g_nUsDragon = 0;

char g_szSetupPath[ 0xff ] ;//= "./setup.ini";

NationAccount g_NationAccount;
int g_iNation;
//皋葛府 穿荐甫 茫扁 困窃..
//CMemoryState oldMemory, newMemory, diffMemory;


/////////////////////////////////////////////////////////////////////////////
// CRMToolApp

BEGIN_MESSAGE_MAP(CRMToolApp, CWinApp)
	//{{AFX_MSG_MAP(CRMToolApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard file based document commands
	ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
	ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
	// Standard print setup command
	ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRMToolApp construction

inline BOOL CannotAccess( int type )
{	
	//甸绢柯 鸥涝捞 logintype捞尔 鞍栏搁 俊矾.
	if( (int)(((CRMToolApp*)AfxGetApp())->m_LogInfo.LoginType) == type ) 
	{
		MessageBox(NULL,"WARRING!! You Don't Have The Authority of ACCESS","WARRING",MB_OK);
		return TRUE;
	}
		
	return FALSE;
}

inline BOOL CanAccess( DWORD type )
{
	//郴 鸥涝俊 type啊 绝绰啊?
//	int zz = ((CRMToolApp*)AfxGetApp())->m_LogInfo.LoginType;
//	int zzz = zz & type;
	if( ( ((CRMToolApp*)AfxGetApp())->m_LogInfo.LoginType & type ) == type ) 
		return TRUE;

	MessageBox(NULL,"WARRING!! You Don't Have The Authority of ACCESS","WARRING",MB_OK);
	return FALSE;
}

void DisconnectionAllUser() //kyo
{
	PACKET_KICKOFF_USERALL packet;
	packet.bPtcl = PTCL_RM;
	packet.bHeader = MSG_RM_KICKOFF_USER_ALL;
	
	//g_pNet->Send(m_pApp->m_nCI[ m_nCurServerSet ], (char*)&packet,  2);
}

void ConnectionAllUser() //kyo
{
	PACKET_RM_PROXY_CONTROL packet((BYTE)1 ,(BYTE)5 ,(WORD)3000);
	//g_pNet->Send(GetConnection(),(char*)&packet, packet.GetPacketSize());
}
/*
inline CString GetInstalledPath()
{
	CString strKey;
	strKey = TEXT("SOFTWARE\\RMTool");
	
	CRegistry reg(HKEY_LOCAL_MACHINE);  
	CRegVal regval;
	CString result;

	if(reg.LoadKey(strKey, "Exe", regval))  
	{
		regval.GetValue(result);	
		return result;
	}
	return strKey;//020303 lsw
}
*/

inline void SetDBName( int nDbIndex, char* szName )
{
	if( nDbIndex < 0 ) return;

	memset(g_CurDbName[ nDbIndex ], 0, MAX_SCHEMA_BUFFER_SIZE);
	memcpy(g_CurDbName[ nDbIndex ], szName, strlen(szName)); 
}

//inline void CheckCompactMessage()	//compact滚傈捞搁 荤侩且荐 绝霸茄促. 

// 021115 巩磊凯罐酒辑 官府 免仿窍扁
inline int MessageBoxPrintf( const int iBoxType, const TCHAR* szMessage, ... )
{//惑磊鸥涝, 力格, 郴侩

	TCHAR szBuffer[ 1024 ];
	va_list valist; //valist = (char*)&szMessage + sizeof( szMessage);

	va_start ( valist, szMessage);

	_vsntprintf( szBuffer, sizeof( szBuffer)/sizeof( TCHAR), szMessage,valist );

	va_end (valist);
	return AfxMessageBox( szBuffer, iBoxType, NULL );
}

inline void LeaveLogInFile( const TCHAR* szMessage, ... )
{
	TCHAR szBuffer[1024];
	va_list valist;
	va_start( valist, szMessage );
	_vsntprintf( szBuffer, sizeof( szBuffer)/sizeof( TCHAR), szMessage, valist );
	va_end( valist);

	CTime time =  CTime::GetCurrentTime();
	FILE *pf;
	if( !(pf = fopen( LOG_FILE, "a+" ) ) )return;
	CString szLog;
	szLog.Format( "%d:%d:%d:%d:%d\t%s\n", time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), szBuffer );
	fputs( szLog.GetBuffer(0), pf ) ;
	fclose( pf );	
}

const char* ToString( char *buf, int iValue )
{
	if( buf == NULL ) return NULL;
	memset( buf, 0x00, sizeof( buf ) );
	sprintf( buf, "%d", iValue );
	return buf;
}

inline bool IsChrloginfoInDrDB()//靛贰帮叼厚俊辑 chr_log_info甫 啊廉坷绰啊?
{
	if( g_nUsDragon == 100 ) 
	{
		return true;
	}
	return false;
}

CRMToolApp::CRMToolApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
	memset(m_ServerInfo, 0, sizeof(m_ServerInfo));
	memset(m_ServerSetInfo, 0, sizeof(m_ServerSetInfo));
	memset(m_ListenerInfo, 0, sizeof(m_ListenerInfo));
	memset(m_nCI, 0, sizeof(m_nCI));
	memset(m_szDownloadPath, 0, sizeof(m_szDownloadPath));
	memset(m_szRemoteGameServerDataPath, 0, sizeof(m_szRemoteGameServerDataPath));
	memset(m_szGameServerDataPath, 0, sizeof(m_szGameServerDataPath));
	memset(m_szUploadPath, 0, sizeof(m_szUploadPath));
	memset(m_szServerExecAddress, 0, sizeof(m_szServerExecAddress));
	memset(m_szLocalAddress, 0, sizeof(m_szLocalAddress));
	memset(g_CurDbName, 0, sizeof(g_CurDbName));
	m_CharacterDocCount = 0;
	m_ServerDocCount = 0;

	memset(m_MapInfo, 0, sizeof(m_MapInfo));
	memset(m_MapInfoUNI, 0, sizeof(m_MapInfoUNI));

	memset(m_nMapCount, 0, sizeof(m_nMapCount));
	memset(m_DbSchema, 0, sizeof(m_DbSchema));
	memset(m_nDbCount, 0, sizeof(m_nDbCount));
	memset(m_ItemTable, 0, sizeof(m_ItemTable));
	memset(m_SkillList, 0, sizeof(m_SkillList));
//	m_nNewServersetIndex = 0;

	char symbol[ NUM_OF_SERVER_STATUS ] = {'X','T','P','C','1','2','3','4','5','6','O','-','C','R','O'};
	memcpy(m_StatusSymbol,symbol, sizeof(symbol));

//#ifdef FOR_JAPAN
	//m_SkillListUNI = new TotalSkillUNI[120];
//#endif
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CRMToolApp object

CRMToolApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CRMToolApp initialization

BOOL CRMToolApp::InitInstance()
{

	{	// BLOCK: doc template registration
		// Register the document template.  Document templates serve
		// as the connection between documents, frame windows and views.
		// Attach this form to another document or frame window by changing
		// the document or frame class in the constructor below.
	}


#ifdef _DEBUG
//	oldMemory.Checkpoint();
#endif
	//
	SetSetupIniPath();
	g_iNation = CheckConfigSetting();

	if( ( g_iNation==NATION_NOTHING ) )	//惫啊 技泼登菌绰瘤 犬牢
	{
		//牧乔弊窍扁.
		CPropertys cProperty("Configration Setting" );
		cProperty.SetWizardMode();

		if( cProperty.DoModal() == ID_WIZFINISH )
			cProperty.SaveAllPageData();
		else
		{
			AfxMessageBox("CANCLE Configration Setting!!");
			return false;
		}

	}

	//牧乔弊 佬扁

	if( false == GetNationInfo( g_iNation, g_NationAccount ) )
		return false;
	//g_NationAccount = GetNationInfo( chNation );
	//if( NULL == g_NationAccout ) return false;

	CWaitDlg dlg;
	dlg.Create(IDD_WAIT);
	dlg.Set("Initializing and connecting database....");
	dlg.ShowWindow(SW_SHOW);
	
	//Database 檬扁拳 棺 Dragon DB 立加 
	if(!InitDatabase())
	{
		AfxMessageBox("Cannot Initialize Database!");
		return FALSE;
	}
	dlg.ShowWindow(SW_HIDE);

	AfxEnableControlContainer();

	// 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

	if (!AfxSocketInit())						//家南 檬扁拳...  救窍搁 烹脚救凳.. ぱ.ぱ
	{
		AfxMessageBox("Failure To Socket!");
		PostQuitMessage(0);
	}

	if(!InitFTModule())
	{
		AfxMessageBox("Cannot Initialize FileTransfer Module!");
		PostQuitMessage(0);
	}

	
	// Change the registry key under which our settings are stored.
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	CMultiDocTemplate* pDocTemplate;
	
	//Server Tool Template
	pDocTemplate = new CMultiDocTemplate(
		IDR_MAINFRAME,			//		IDR_SERVERTYPE,		// BBD 040330
		RUNTIME_CLASS(CRMToolDoc),
		RUNTIME_CLASS(CChildFrame), 
		RUNTIME_CLASS(CServerView));
	AddDocTemplate(pDocTemplate);

	//Character Tool Template
	pDocTemplate = new CMultiDocTemplate(
		IDR_CHARACTERTYPE,
		RUNTIME_CLASS(CCharacterDoc),
		RUNTIME_CLASS(CCharacterFrame), 
		RUNTIME_CLASS(CCharacterView));
	AddDocTemplate(pDocTemplate);

	//<! BBD Test
	pDocTemplate = new CMultiDocTemplate(
		IDR_CHARMGRTYPE,
		RUNTIME_CLASS(CRMToolDoc),
		RUNTIME_CLASS(CChildFrame2), 
		RUNTIME_CLASS(CCharMgrView));
	AddDocTemplate(pDocTemplate);
	//> BBD Test
	
	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;


	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	//if (!ProcessShellCommand(cmdInfo))	return FALSE;		//袍敲复绊福霸 窍绰 芒阑 唱坷霸 窃..
	
	// The main window has been initialized, so show and update it.
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();

	if(!InitClientNet())
	{
		AfxMessageBox("Cannot Initialize ClientNet Module!");
		PostQuitMessage(0);
	}

	dlg.ShowWindow(SW_SHOW);
	dlg.Set("Loading server data and item tables... ");

	


#ifdef __COMPACT__
	//扁夯 Setting -> ini技泼
	LoadDefaultSetting(); 

	if(!LogInProxy()) 
	{
		//return FALSE;
	}

	if( !ConnectProxyListener() )
	{
		MessageBox(NULL,"Fail to ConnectProxyListener()","Error",MB_OK);
		return FALSE;
	}
	
#else
	//郴何俊辑 葛电巴阑 秦搬且 版快
	
	if(!InitTotalDB())
	{
		//AfxMessageBox("Cannot connect Total DB!");
		return FALSE;
	}


	//<! BBD 040105		怕惫,富饭捞 辑滚惑怕 瘤盔侩
	if(!pMainFrame->InitRMServerStatus())
	{
		MessageBox(NULL, "error", "InitRMServerStaus failed", MB_OK);
		return FALSE;
	}
	//> BBD 040105		怕惫,富饭捞 辑滚惑怕 瘤盔侩

	#ifdef __LOGIN_MODE__
		//Login 贸府 
		CLoginDlg logindlg;
		if(logindlg.DoModal() == IDCANCEL)
		{
			PostQuitMessage(0);
			return FALSE;
		}

	#endif

	#ifdef __KOYANGHI__
		SetDefaultLogin();		//郴部 抛胶飘绰 肺变决蝶.
	#endif


  	//dlg.ShowWindow(SW_HIDE);	//kyo 021007 见扁绰吧 酒贰肺 颗辫

	//扁夯 Setting Load	
	LoadDefaultSetting();
	if(!InitDragonDB())
		MessageBox(NULL, "fail to init dragon DB",NULL,NULL);
	dlg.ShowWindow(SW_HIDE);

	LoadItemTable(); // 021115 怕惫俊辑 捞抚捞 救焊捞绰 巩力锭巩俊

//CreateItemInfoFile(); //kyo 酒捞袍捞抚父 啊廉棵荐 乐绰瘤 抛胶飘

	LoadSkillTable();

	if(!LogInProxy())
	{
		//return FALSE;
	}

#endif


	//葛电 ServerSet狼 沥焊甫 罐酒柯促..
	if(!GetServerInfo())	
	{
		MessageBox(NULL,"Fail to get server info","Error",MB_OK);
		return FALSE;
	}
	
	

	dlg.ShowWindow(SW_HIDE);

	switch(m_DefaultView)
	{
	//ServerView
	case 1:
		{
		//	dlg.ShowWindow(SW_SHOW);
		//	dlg.Set("Receiving server informations...");

			//DefaultServerSet阑 悸泼 救沁阑锭 绊福绰 芒阑 顿款促. 
//			if(m_DefaultServerSetIndex == 0)
//			{
//				CSelectServersetDlg dlg;
//				m_DefaultServerSetIndex = dlg.DoModal();
//				//m_nNewServersetIndex = dlg.DoModal();
//			}
			
			OpenServerTemplate();
		//	dlg.ShowWindow(SW_HIDE);
		}
		break;

	//Character View
	case 2:
		{
			//InitExtDatabase();

			//Character Template Load
			POSITION pos = GetFirstDocTemplatePosition();
			pDocTemplate = (CMultiDocTemplate*)GetNextDocTemplate(pos);
			pDocTemplate = (CMultiDocTemplate*)GetNextDocTemplate(pos);
			pDocTemplate->OpenDocumentFile(NULL);
		}
		break;

	//All View
	case 3:
		{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -