📄 rmtool.cpp
字号:
bool IncordFile( char *filename, void *pData, int size )
{
CHSEL_STREAM m_hsel;
FILE *fp = fopen( filename, "wb" );
if( !fp ) return false;
HselInit eninit;
eninit.iEncryptType = HSEL_ENCRYPTTYPE_RAND;
eninit.iDesCount = HSEL_DES_TRIPLE;
eninit.iCustomize = HSEL_KEY_TYPE_DEFAULT;
eninit.iSwapFlag = HSEL_SWAP_FLAG_ON;
if (!m_hsel.Initial(eninit))
{
return false;
}
HselInit deinit;
deinit = m_hsel.GetHSELCustomizeOption();
const int nVersion = m_hsel.GetVersion();
fwrite((void *)(&nVersion), sizeof(nVersion), 1, fp );
fwrite((void *)(&deinit), sizeof(HselInit), 1, fp );
m_hsel.Encrypt((char*)pData, size);
fwrite( pData, 1, size, fp );
fclose( fp );
return true;
}
BOOL CRMToolApp::InitTotalDB()
{
WCHAR wszAddress[ 0xff ];
WCHAR wszDBName[ 0xff ];
ID_PASS sIdPass;
int ret = DecoadFile( DECOADINGFILE_BIN, &sIdPass, sizeof( ID_PASS ) );
if( !ret )
{
AfxMessageBox( "Failed to Read 'IdPassword.bin' File" );
return false;
}
g_pDb->KSCToUnicode( sIdPass.m_szID2, g_NationAccount.szTotal_DB_Account );
g_pDb->KSCToUnicode( sIdPass.m_szPASS2, g_NationAccount.szTotal_DB_Password );
g_pDb->KSCToUnicode( sIdPass.m_szID1, g_NationAccount.szDragon_Account );
g_pDb->KSCToUnicode( sIdPass.m_szPASS1, g_NationAccount.szDragon_Password);
g_pDb->KSCToUnicode(g_NationAccount.szTotal_DB_Address, wszAddress);
g_pDb->KSCToUnicode(g_NationAccount.szTotal_DB_Default_Table, wszDBName);
TOTAL_DB = g_pDb->CreateDBConnection();
//#ifdef _DEBUG
char path[ MAX_PATH ];
__PATH
//int z = ::GetPrivateProfileInt("Admin","DB",-10,path);
if( -10 != ::GetPrivateProfileInt("Admin","DB",-10,path) )
{
char szBuffer1[100], szBuffer2[100], szBuffer3[100], szBuffer4[100], szBuffer5[100];
//::WideCharToMultiByte(CP_ACP, 0, g_NationAccount.szTotal_DB_Default_Table,-1, szBuffer1, 100, NULL, NULL);
::WideCharToMultiByte(CP_ACP, 0, wszDBName,-1, szBuffer1, 100, NULL, NULL);
::WideCharToMultiByte(CP_ACP, 0, g_NationAccount.szTotal_DB_Account,-1, szBuffer2, 100, NULL, NULL);
::WideCharToMultiByte(CP_ACP, 0, g_NationAccount.szTotal_DB_Password,-1, szBuffer3, 100, NULL, NULL);
::WideCharToMultiByte(CP_ACP, 0, g_NationAccount.szDragon_Account,-1, szBuffer4, 100, NULL, NULL);
::WideCharToMultiByte(CP_ACP, 0, g_NationAccount.szDragon_Password,-1, szBuffer5, 100, NULL, NULL);
CString Mess;
Mess.Format( "TotalDB IP = %s, \n TotalDB Name = %s, \n TotalDB Account = %s\n TotaDB Pass = %s \n Dragon Name = %s \nDragon Account = %s \n Dragon Pass = %s", g_NationAccount.szTotal_DB_Address, szBuffer1, szBuffer2, szBuffer3, g_NationAccount.szDragon_DB_DefaultName, szBuffer4, szBuffer5 );
AfxMessageBox( Mess );
}
//#endif
int result = 0;
// result = g_pDb->Initialize(wszAddress, wszDBName,
/// g_NationAccount.szTotal_DB_Account, g_NationAccount.szTotal_DB_Password, (BYTE)TOTAL_DB );
result = g_pDb->Initialize(L"HBRND", L"TotalDB",L"sa",L"13306243",(BYTE)TOTAL_DB);
if(result > 0)
{
g_pDb->ReleaseDBConnection( (BYTE)TOTAL_DB);
CString szMsg;
szMsg.Format( "ERRor : Initialized TotalDB : Error result = %d ", result );
AfxMessageBox( szMsg );
TOTAL_DB = 0;
return FALSE;
}
return TRUE;
}
BOOL CRMToolApp::LoadItemTable()
{
char szQuery[ 0xff ];
WCHAR wszQuery[ 0xff ];
char* itemtbl[ MAX_ITEM_TYPE ] = {"Item_Plant", "Item_Mineral", "Item_Herb","Item_Cook","Item_Potion",
"Item_Tool","Item_Weapon","Item_Disposable","Item_Armor","Item_Accessory",
"Item_Etc"};
int ret; ret = 0;
for(int j=0; j<CURRENT_SERVERSET_NUM; j++)
{
if( DRAGON_DB[ j ] == -1) continue; //秦寸 DragonDB啊 立加俊 角菩沁栏搁 蔼阑 持瘤 臼绰促.
if(j == 0) continue; //蜡乔弛篮 秋墨匙胶 鞍栏骨肺 唱吝俊 秋墨匙胶吧肺 墨乔窍磊
for(int i=0; i<MAX_ITEM_TYPE ; i++)
{
sprintf(szQuery,"select item_id, Han_Name, Image_Number, object, "
"Mouse_MR from %s order by item_id",itemtbl[i]);
g_pDb->KSCToUnicode(szQuery, wszQuery);
if(i != 6 && i != 8) //item_weapon苞 item_armor篮 HanName鞘靛 辨捞啊 促福促.. 噶且..ぱ_-;;
{
ItemData buffer[1000]; //HanNAme 鞘靛 辨捞 31漏府肺 老窜 罐篮促澜..
m_nItemNum[ j ][ i ] = g_pDb->OpenRecord(wszQuery, buffer, 1000, (BYTE)DRAGON_DB[ j ]);
if(m_nItemNum[ j ] < 0)
{
CString str;
str.Format("Fail to ItemTable dbcon:%d itemtype:%d", j, i);
AfxMessageBox(str);
return FALSE;
}
for(int k=0; k<m_nItemNum[ j ][ i ]; k++) //51楼府 备炼眉肺 墨乔..
{
m_ItemTable[ j ][ i ][ k ].item_id = buffer[ k ].item_id;
m_ItemTable[ j ][ i ][ k ].mouse_mr = buffer[ k ].mouse_mr;
m_ItemTable[ j ][ i ][ k ].image_number = buffer[ k ].image_number;
m_ItemTable[ j ][ i ][ k ].object = buffer[ k ].object;
memcpy( (void*)(&m_ItemTable[ j ][ i ][ k ].han_name), buffer[ k ].han_name, strlen(buffer[ k ].han_name));
}
}
else //item_weapon捞芭唱 , item_armor牢 版快
{
m_nItemNum[ j ][ i ] = g_pDb->OpenRecord(wszQuery, m_ItemTable[ j ][ i ], 1000, (BYTE)DRAGON_DB[ j ]);
if(m_nItemNum[ j ] < 0)
{
CString str;
str.Format("Fail to ItemTable dbcon:%d itemtype:%d", j, i);
AfxMessageBox(str);
return FALSE;
}
}
}
}
//秋墨匙胶 Item Data甫 蜡乔弛肺 墨乔
memcpy(m_nItemNum[0], m_nItemNum[1], sizeof(m_nItemNum[1]));
memcpy(m_ItemTable[ 0 ], m_ItemTable[ 1 ], sizeof(m_ItemTable[ 1 ]));
return TRUE;
}
/*
[0][i]= &CPlant[i] ;
[1][i]= &CMineral[i] ;
[2][i]= &CHerb[i] ;
[3][i]= &CCook[i] ;
[4][i]= &CPotion[i] ;
[5][i]= &CTool[i] ;
[6][i]= &CWeapon[i] ;
[7][i]= &CDisposable[i] ;
[8][i]= &CArmor[i] ;
[9][i]= &CAccessory[i] ;
[10][i]= &CEtc[i] ;k
*/
#define SKILLTABLE_LOC 0 //霉锅掳 叼厚俊辑 啊部柯促.
BOOL CRMToolApp::LoadSkillTable()
{
char szQuery[ 0xff ];
WCHAR wszQuery[ 0xff ];
sprintf(szQuery, "select NO#, Skill_Minute from skillmain where NO# < 87 order by no# asc");
g_pDb->KSCToUnicode(szQuery, wszQuery);
//俺惯磊 DB俊辑 Skill Table阑 啊廉坷磊
int ret;
if( g_iNation != NATION_JAPAN )
{
ret = g_pDb->OpenRecord(wszQuery, m_SkillList + 1, 100, (BYTE)DRAGON_DB[ SKILLTABLE_LOC ]);
}
else
{
ret = g_pDb->OpenRecord(wszQuery, m_SkillListUNI + 1, 100, (BYTE)DRAGON_DB[ SKILLTABLE_LOC ]);
}
if(ret < 0)
{
::MessageBoxW(NULL,wszQuery,0,0);
AfxMessageBox("Fail to query skill table!");
return FALSE;
}
sprintf(szQuery, "select NO#, Skill_Minute from skillmain where NO# > 100 order by no# asc");
g_pDb->KSCToUnicode(szQuery, wszQuery);
//俺惯磊 DB俊辑 Skill Table阑 啊廉坷磊..
if( g_iNation != NATION_JAPAN )
{
ret = g_pDb->OpenRecord(wszQuery, m_SkillList + 101, 100, (BYTE)DRAGON_DB[ SKILLTABLE_LOC ]);
}
else
{
ret = g_pDb->OpenRecord(wszQuery, m_SkillListUNI + 101, 100, (BYTE)DRAGON_DB[ SKILLTABLE_LOC ]);
SetSkillList( &m_SkillList[0], &m_SkillListUNI[0] );
}
if(ret < 0)
{
::MessageBoxW(NULL,wszQuery,0,0);
AfxMessageBox("Fail to query skill table!");
return FALSE;
}
return TRUE;
}
BOOL CRMToolApp::LogChar( int nServerSet, CString szInfo)
{
// if(m_LogInfo.LoginType == 10000)
// return TRUE;
#ifdef RM_LOG_MODE
char szQuery[ 1024 ];
WCHAR wszQuery[ 1024 ];
//kyo now
sprintf(szQuery,"EXEC UP_RM_LOG '%s',%d,'%s','%s'",m_LogInfo.ID, nServerSet + 200, m_szLocalAddress, szInfo);
g_pDb->KSCToUnicode(szQuery,wszQuery);
return g_pDb->ExecuteSQL(wszQuery,(BYTE)TOTAL_DB);
#endif
return true;
}
CString CRMToolApp::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
}
int CRMToolApp::CheckConfigSetting() //惫啊利侩勤绰啊 舅酒焊绰巴..
{
char path[ MAX_PATH ];
__PATH
char buffer[256];
::GetCurrentDirectory(256, buffer);
//char szTmp[ 0xf ]="";
CString szTmp;
::GetPrivateProfileString( "Nation","nation",NULL_NATION_NAME, szTmp.GetBuffer(0), 16, path );
//葛滴 措巩磊肺 父电第
szTmp.MakeUpper();
int iReturn;
//if( strlen( szTmp.GetBuffer(0)) <= 0 ) // 021119 惫啊啊 呈公腹酒辑廉 扁成 府畔茄促.
// iReturn = NATION_NOTHING;
//else
// iReturn = NATION_KOREA;
if( 0 == strcmp( "KOREA", szTmp.GetBuffer(0)) )
iReturn = NATION_KOREA;
else if( 0 == strcmp( "TAIWAN", szTmp.GetBuffer(0)) )
iReturn = NATION_TAIWAN;
else if( 0 == strcmp( "CHINA", szTmp.GetBuffer(0)) )
iReturn = NATION_CHINA;
else if( 0 == strcmp( "HONGKONG", szTmp.GetBuffer(0)) )
iReturn = NATION_HONGKONG;
else if( 0 == strcmp( "THAILAND", szTmp.GetBuffer(0)) )
iReturn = NATION_THAILAND;
else if( 0 == strcmp( "USA", szTmp.GetBuffer(0)) )
iReturn = NATION_USA;
else if( 0 == strcmp( "JAPAN", szTmp.GetBuffer(0)) )
iReturn = NATION_JAPAN;
else if( 0 == strcmp( "MAL", szTmp.GetBuffer(0)) )
iReturn = NATION_MAL;
else
iReturn = NATION_NOTHING;
return iReturn;
}
BOOL CRMToolApp::GetNationInfo(int iNation, NationAccount& stNation)
{
iNation;
//NationAccount stNatio/n;
char path[ MAX_PATH ];
char Key[ 128 ];
int i;
__PATH
CURRENT_SERVERSET_NUM = ::GetPrivateProfileInt("ServerTool","TotalServersetNum",0,path);
if( NULL == ::GetPrivateProfileString("TotalDBAddress", "DBAddress","",stNation.szTotal_DB_Address, 20, path) ) goto Error;
if( NULL == ::GetPrivateProfileString("TotalDBAddress", "DBName","",stNation.szTotal_DB_Default_Table, 20, path) ) goto Error;
//if( ::GetPrivateProfileString("ServerTool", "GameDBName","",stNation.szDragon_DB_DefaultName, 20, path) < 0 ) goto Error;
for(i=0; i<CURRENT_SERVERSET_NUM ; i++)
{
sprintf(Key,"ServersetDBAddress%d",i+1);
if( NULL == ::GetPrivateProfileString("ServerTool", Key,"",stNation.szDragon_DB_Address[ i ], MAX_PATH, path) ) goto Error;
sprintf(Key,"GameDBName%d",i+1);
if( NULL == ::GetPrivateProfileString("ServerTool", Key,"",stNation.szDragon_DB_DefaultName[ i ], MAX_PATH , path) ) goto Error;
sprintf( Key, "ServersetIndex%d", i+1);
if( 0 > (stNation.iDragon_DB_ServerIndex[ i ] = ::GetPrivateProfileInt( "ServerTool", Key, -1, path))) goto Error;
}
g_nUsDragon = ::GetPrivateProfileInt("Admin","usingDragon",0,path); //chr_log_info甫 dragonDB俊辑 佬扁/静扁窍霸茄促. 100锅栏肺 瘤沥
return true;
Error:
AfxMessageBox( "Failed to Read INI File" );
return false;
}
void CRMToolApp::SetSetupIniPath()
{
//sprintf(g_szSetupPath,"./Setup.ini",GetInstalledPath());
sprintf(g_szSetupPath, _SET_UP_INI);//GetInstalledPath());
}
BOOL CRMToolApp::ConnectProxyListener()
{
if( !GetTotalDBDateByProxyListener( CONNECT_PROXYLISTENER_NUM ) ) //贸澜 楷搬等 巴父 啊瘤绊 柯促.
return FALSE;
return TRUE;
}
BOOL CRMToolApp::GetTotalDBDateByProxyListener( int iServersetNum)
{
_ASSERTE( iServersetNum >=0 && iServersetNum <= MAX_SERVERSET_NUM );
if( !g_pFt->Connect( m_ProxyIp[ iServersetNum ], RMTOOL_CONNECT_PORT ) )
return FALSE;
PACKET_RMSERVER_INFO packet;
packet.bPtcl = PTCL_RM;
packet.bHeader = MSG_RM_REQUEST_RMINFO;
if( !g_pFt->Send((char*)&packet, sizeof( packet) ) )
return FALSE;
//if( !g_pFt->CloseClientSocket() )
// return FALSE;
/*
char path[ MAX_PATH ];
__PATH
char keyname[ 0xff ];
for(int i=1 ; i<= CURRENT_SERVERSET_NUM ; i++)
{
sprintf(keyname,"ServersetIndex%d",i);
m_ServerSetInfo[ i-1 ].nServerSetIndex = ::GetPrivateProfileInt("ServerTool",keyname,0,path); //ServerSetNum 罐酒柯促.
sprintf(keyname,"ServersetName%d",i);
::GetPrivateProfileString("ServerTool",keyname,"",m_ServerSetInfo[ i-1 ].szSetName ,
sizeof(m_ServerSetInfo[ i-1 ].szSetName), path); //ServerSetName 罐酒柯促.
swprintf(sql,L"EXEC UP_RM_SERVER_INFO %d", m_ServerSetInfo[ i-1 ].nServerSetIndex);
ret = g_pDb->OpenRecord(sql, rcvData, 100, TOTAL_DB);
for(int k=0 ; k<ret ; k++)
{
memcpy(&m_ServerInfo[ i-1 ][ k ], &rcvData[ k ], sizeof(rcvData[0]));
}
//memcpy(m_ServerInfo[ i-1 ], &rcvData, sizeof(rcvData));
if(ret < 0)
//MessageBox(NULL,"Failed query ServerInfo","Error",MB_OK);
return FALSE;
else
m_ServerSetInfo[ i-1 ].nServerNum = ret;
}
*/
return TRUE;
/*
if( !GetTotalDBDate() )
{
MessageBox(NULL,"Fail to GetTotalDBData()","Error",MB_OK);
return FALSE;
}
*/
}
void CRMToolApp::CreateItemInfoFile()
{
CStdioFile ItemFile;
ItemFile.Open( "iteminfo.txt", CFile::modeCreate | CFile::modeWrite, NULL );
for( int i = 0; i < MAX_ITEM_TYPE; i++)
for( int j = 0; j < MAX_ITEM_NUM; j++)
{
CString writeFormat;
//CString tmp2;
CString tmp = m_ItemTable[0][i][j].han_name;
tmp.TrimLeft(tmp);
tmp.TrimRight(tmp);
writeFormat.Format( "%d\t%s\n",m_ItemTable[0][i][j].item_id, tmp );
//writeFormat.Format( "%d\t%s",m_ItemTable[0][i][j].item_id, m_ItemTable[0][i][j].han_name );
ItemFile.WriteString( writeFormat );
}
ItemFile.Close();
}
void CRMToolApp::SetDefaultLogin()
{
//LoginInfo dfLogin;//("kyo", "1", "test", "1.1.1.1", 10000);
strcpy( m_LogInfo.ID , "kyo");
strcpy( m_LogInfo.Password , "1");
strcpy( m_LogInfo.Name, "kyo");
strcpy( m_LogInfo.IP, "1.0.0.1");
m_LogInfo.LoginType = MASK_ADMINISTRATOR;
}
BOOL CRMToolApp::LogCharInFile(const CString& szServerName,const CString& szDB,const CString& szFunction, const CString& szPage, const CString& szChrName,
const CString& szChrId, const CString& szTypeName, const int value, const CString& szTmp)
{//颇老俊 肺弊巢扁扁.. 叼厚持扁傈俊 楷嚼涝聪促...
FILE *fp;
if ( NULL == (fp = fopen( "捞镑阑林格窍扼.txt", "a+") )) return 0;
if ( NULL == fprintf( fp,"'%s', '%s','%s','%s','%s','%s','%s','%s','%d','%s' \n",
m_LogInfo.ID, szServerName, szDB, szFunction, szPage, szChrName, szChrId, szTypeName, value, szTmp) ) return 0;
fclose( fp );
return 0;
}
BOOL CRMToolApp::LogCharExtend( const CString szServerName,const CString szDB,const CString szFunction, const CString szPage, const CString szChrName,
const CString szChrId, const CString szTypeName, const int value, const CString szTmp)
{//叼厚つし 肺弊持扁
char szQuery[ 1024 ];
WCHAR wszQuery[ 1024 ];
//kyo now
sprintf(szQuery,"EXEC UP_RM_LOG_EXTENSION '%s', '%s','%s','%s','%s','%s','%s','%s','%d','%s'" ,
m_LogInfo.ID, szServerName, szDB, szFunction, szPage, szChrName, szChrId, szTypeName, value, szTmp);
g_pDb->KSCToUnicode(szQuery,wszQuery);
return g_pDb->ExecuteSQL(wszQuery,(BYTE)TOTAL_DB);
}
void CRMToolApp::SetSkillList( TotalSkill* skill, TotalSkillUNI* skillUNI )
{
for( int i=0;i < 120 ; i++ )
{
skill[i].num = skillUNI[i].num;
::WideCharToMultiByte(CP_ACP, 0,skillUNI[i].name, -1, skill[i].name, 100, NULL, NULL);
}
}
void CRMToolApp::SetMapInfo( RM_GET_MAP_NAME *mapinfo, RM_GET_MAP_NAME_UNI *mapinfoUNI )
{
for( int i=0;i<100;i++)
{
mapinfo[i].dwNation = mapinfoUNI[i].dwNation;
::WideCharToMultiByte(CP_ACP, 0, mapinfoUNI[i].szwMapFile,-1, &mapinfo[i].szMapFile[0], 100, NULL, NULL);
::WideCharToMultiByte(CP_ACP, 0, mapinfoUNI[i].szwMapName,-1, &mapinfo[i].szMapName[0], 100, NULL, NULL);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -