?? creadargument.cpp
字號(hào):
#include "Stdafx.h"
#include <stdio.h>
#include "hong_sub.h"
#include "CReadArgument.h"
//#include "chigamec.h"
HINSTANCE hDll; //傈開函薦唱 糕滾肺 貿(mào)府
SessionParameter m_SessParam;
CClientBill *g_pBill;
CUnicheck *g_unitel;
//2001/02/19 zhh 汲疙: 牢磊藹闌 弊措肺 ip客 port肺 鏡 薦 樂綽 版快 弊 牢磊藹狼 Command[]俊輯狼 困摹.
//2001/02/20 zhh 汲疙: 抗甫甸絹輯 onegame狼 版快 dragonraja.exe /moya IP Port 扼綽 牢磊肺 角青登骨肺,
//2001/02/20 zhh 汲疙: IP_pos[11] = 1; Port_pos[11]= 2; 撈 等促.
void CClientBill::initipNport()
{
for(int i=0;i<MAX_BILL_CORP;i++) IP_pos[i]=-1;
for( i=0;i<MAX_BILL_CORP;i++) Port_pos[i]=-1; //Command[]俊 port啊 甸絹 樂綽 困摹
::memset(IP,0,40);
port=0;
sockfd=0;
//nownuri
IP_pos[0] = 1;
Port_pos[0]= 2;
//Mezzy System
IP_pos[6] = 1;
Port_pos[6]= 2;
//WeverNet
IP_pos[7] = 1;
Port_pos[7]= 2;
IP_pos[10] = 1;
Port_pos[10]= 2;
IP_pos[11] = 1;
Port_pos[11]= 2;
IP_pos[14] = 1;
Port_pos[14]= 2;
IP_pos[15] = 1;
Port_pos[15]= 2;
}
CClientBill::CClientBill(const char *szLine)
{
initipNport(); //努貳膠 郴何狼 函薦祦E檬扁拳.
g_unitel=NULL; //蠟聰炮 纴E丒努貳膠 檬扁拳.
CommandLine=NULL;
Command=NULL; //Command肺 逞鈞勐 巴甸闌 啊府懦 器牢磐
CommandLineSlash=NULL; //逞鈞勐 牢磊藹 / 肺 備盒茄促
CommandLineSlashBackup=NULL; //strtok甫 角青竅竵ECommandszLine撈 函竅骨肺 促矯 盔惑汗蓖 矯虐眮E困茄巴
CommandLineBackup = NULL;
WhatLineIUse=-1; //鈞欣 訣眉狼 雀急牢羴E備盒. -1撈竵E輛樊力啊 酒聰扼綽 秮E
CommandNum=0; //逞鈞勐 牢磊藹狼 箭磊
CommandNumSlash=0; //逞鈞勐 牢磊藹狼 箭磊
#ifdef JAPAN_LOCALIZING_ //030207 lsw
CoInitialize(NULL);
HRESULT hr = m_pNgcEncrypto.CreateInstance(__uuidof(NgcEncrypt));
if(FAILED(hr))
{
::MessageBox(NULL,"NGC init error ", "Error",0);
}
/*
WCHAR* wszJapanTID= NULL;
_bstr_t code = L"D819FA2C-4429-4511-AC6E-9823F743881F ";
m_pNgcEncrypto->Encode(code, &wszJapanTID);
*/
//
// ::MessageBox(NULL,szLine,"In",0);
WCHAR wszLine[100] = {0,};//酒膠虐甫 蠟內(nèi)靛肺 函券
::MultiByteToWideChar(CP_ACP, 0, szLine, strlen(szLine), wszLine, sizeof(WCHAR)*100);
WCHAR* result= NULL;
m_pNgcEncrypto->Decode( wszLine, &result);
// MessageBox(NULL,(char*)result,"Decode1",0);
::WideCharToMultiByte(CP_ACP, 0, result,-1, m_szJapanTID, sizeof(m_szJapanTID), NULL, NULL);
// MessageBox(NULL,m_szJapanTID,"Decode2",0);
m_pNgcEncrypto = NULL;
WhatLineIUse=-1;
return;
#endif
const int len = lstrlen(szLine)+1; //牢磊藹撈 絕絹檔 老竄籃 眉農(nóng)甫 茄促.
if(len>-1)
{
CommandLine = new char[len];
CommandLineBackup = new char[len]; //2001/02/19 zhh 汲疙: strtok狼 版快 角力 郴儈闌 官操絹 滾府骨肺 歸訣撈 鞘夸竅促.
CommandLineSlash = new char[len]; //逞絹柯 牢磊藹 / 肺 備盒茄促
CommandLineSlashBackup = new char[len]; //strtok甫 角青竅擱 CommandszLine撈 函竅骨肺 促矯 盔惑汗蓖 矯虐扁 困茄巴
::strcpy(CommandLine,szLine);
::strcpy(CommandLineBackup,szLine);
::strcpy(CommandLineSlash,szLine);
::strcpy(CommandLineSlashBackup,szLine);
CheckLine(); //絹恫 牢磊藹撈 逞絹 吭綽瘤 犬牢竅絆
PutLine(); //弊吧 肋扼輯 Command[]俊 持綽促
DecideLine(); //逞絹柯 牢磊藹闌 秦寸竅綽 訣眉啊 勒綽瘤 犬牢茄促.
}
else
{
WhatLineIUse=-1; //-1撈擱 瀝咀欄肺 靜綽 葷恩撈促. 輛樊力啊 酒聰促
}
}
CClientBill::CClientBill() //弊成 父甸絹 初籃巴 揮. 靜瘤 臼綽促.
{
CommandLine=NULL;
Command=NULL; //Command肺 逞絹柯 巴甸闌 啊府懦 器牢磐
WhatLineIUse=0; //絹蠢 訣眉狼 雀急欄肺
CommandNum=0; //逞絹柯 牢磊藹狼 箭磊
}
//2001/02/19 zhh 汲疙: new肺 父電 巴甸 delete.
CClientBill::~CClientBill()
{
if(Command!=NULL)
{
for(int i=0;i<CommandNum;i++)
if(Command[i]!=NULL)
delete Command[i];
// delete Command;
}
if(CommandSlash!=NULL)
{
for(int i=0;i<CommandNumSlash;i++)
if(CommandSlash[i]!=NULL)
delete CommandSlash[i];
// delete CommandSlash;
}
if(CommandLine) //逞絹柯 牢磊藹
delete CommandLine;
if(CommandLineBackup) //逞絹柯 牢磊藹
delete CommandLineBackup;
if(CommandLine) //逞絹柯 牢磊藹
delete CommandLineSlash;
if(CommandLineBackup) //逞絹柯 牢磊藹
delete CommandLineSlashBackup;
if(g_unitel)
delete g_unitel;
if(sockfd!=0)
closesocket(sockfd);
}
//2001/02/19 zhh 汲疙: 鞏磊凱 蓋 第狼 white space甫 絕矩促.
int CClientBill::EatRearWhiteChar(char* eatit )
{
char* szWhite = " \t\n\r";
char* pRear;
pRear = eatit + strlen( eatit ) - 1;
if ( pRear )
{
while ( eatit <= pRear )
{
if ( strchr( szWhite, *pRear ) )
{
*pRear-- = 0;
}
else
{
break;
}
}
}
return 0;
}
//2001/02/19 zhh 汲疙:
int CClientBill::CheckLine()
{
char *p;
p=strtok(CommandLine," ");
if(p)
CommandNum++;
while(p!=NULL)
{
p=strtok(NULL," ");
if(p) CommandNum++;
}
p=NULL;
p=strtok(CommandLineSlash,"/");
if(p)
CommandNumSlash++;
while(p!=NULL)
{
p=strtok(NULL,"/");
if(p) CommandNumSlash++;
}
return 0;
}
int CClientBill::PutLine()
{
strcpy(CommandLine,CommandLineBackup);
strcpy(CommandLineSlash,CommandLineSlashBackup);
if( 0 >= CommandNum)
{
return 0;
}
Command = new char* [CommandNum];
CommandSlash = new char* [CommandNumSlash];
for(int i=0;i<CommandNum;i++) Command[i]=NULL;
for( i=0;i<CommandNumSlash;i++) CommandSlash[i]=NULL;
i=0;
char *p;
p=strtok(CommandLine," ");
if(p)
{
Command[i] = new char [lstrlen(p)+1];
strcpy(Command[i],p);
i++;
}
while(p!=NULL)
{
p=strtok(NULL," ");
if(p && strcmp(p," "))
{
Command[i] = new char [lstrlen(p)+1];
strcpy(Command[i],p);
i++;
}
}
i=0;
p=NULL;
p=strtok(CommandLineSlash,"/");
if(p)
{
CommandSlash[i] = new char [lstrlen(p)+1];
EatRearWhiteChar(p);
strcpy(CommandSlash[i],p);
i++;
}
while(p!=NULL)
{
p=strtok(NULL,"/");
if(p/* && strcmp(p," ")*/)
{
CommandSlash[i] = new char [lstrlen(p)+1];
EatRearWhiteChar(p);
strcpy(CommandSlash[i],p);
i++;
}
}
return 0;
}
char* CClientBill::ReturnUserID() //輛樊力 訣眉俊 肺弊牢 茄 ID //泅力 葛福綽 巴籃 NowNuri揮.楷扁登菌欄骨肺 眠饒眠啊.
{
memset(Return,0,sizeof(Return));
if(WhatLineIUse<0) return NULL;
switch(WhatLineIUse)
{
case 0:
case 1:
case 2:
return UserID;
break;
case 3:
{
memset(UserID,0,sizeof(UserID));
strcpy(UserID,g_unitel->Uniwin_szpUserID);
}
case 4:
case 5:
case 6:
case 7:
return UserID;
break;
case 8:
WiseTop_ID();
return UserID;
break;
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
return UserID;
break;
default: return NULL;
break;
}
return NULL;
}
char* CClientBill::ReturnUserPW() //輛樊力 訣眉俊 肺弊牢 茄 PW
{
if(WhatLineIUse<0) return NULL;
memset(Return,0,sizeof(Return));
return NULL;
}
int CClientBill::ReturnLineNum()
{
// _asm int 3;
if(WhatLineIUse<0)
return -1;
return WhatLineIUse;
}
char* CClientBill::ReturnCharValue(int Where)
{
if(Where>CommandNum) return NULL;
memset(Return,0,sizeof(Return));
strcpy(Return,Command[Where]);
return Return;
}
int CClientBill::ReturnNumValue(int Where)
{
if(Where>CommandNum) return -1;
return (atoi(Command[Where]));
}
void CClientBill::DisplayAllCommand() //叼滾彪儈
{
for(int i=0;i<CommandNum;i++)
MessageBox(NULL,Command[i],"White Space",NULL);
for( i=0;i<CommandNumSlash;i++)
MessageBox(NULL,CommandSlash[i],"Slash",NULL);
// if(CommandNum==0 && CommandNumSlash==0)
// return;
char ip[20];
int port;
char dis[100],linename[20];
if(ReturnLineNum()<0) return;
wsprintf(ip,ReturnIPaddress());
port = ReturnPORTNumber();
switch(WhatLineIUse)
{
case 0: strcpy(linename,"Nownuri"); break;
case 1: strcpy(linename,"Thrunet"); break;
case 2: strcpy(linename,"Channel i"); break;
case 3: strcpy(linename,"Unitel"); break;
case 4: strcpy(linename,"Netsgo"); break;
case 5: strcpy(linename,"Kornet World"); break;
case 6: strcpy(linename,"Mezzy System"); break;
case 7: strcpy(linename,"WeverNet"); break;
case 8: strcpy(linename,"WiseTop"); break;
case 9: strcpy(linename,"MediaWeb"); break;
case 10: strcpy(linename,"Pcbang.com"); break;
case 11: strcpy(linename,"One Game"); break;
case 12: strcpy(linename,"Excite Game"); break;
case 13: strcpy(linename,"UnitelWeb"); break;
case 14: strcpy(linename,"Chollian"); break;
case 15: strcpy(linename,"HyunJuComputer"); break;
default: strcpy(linename,"Can't Detect Line"); break;
}
sprintf(dis,"ip : %s port : %d LineName:%s",ip,port,linename);
MessageBox(NULL,dis,linename,NULL);
}
int CClientBill::ReturnHeader()
{
if(WhatLineIUse<0) return 0;
return(WhatLineIUse+710);
}
int CClientBill::ReturnPayPORTNumber() //霸撈飄傀撈 器飄 鍋齲
{
if(WhatLineIUse<0) return 0;
if(IP_pos[WhatLineIUse]==-1 || Port_pos[WhatLineIUse]==-1) //父距 牢磊藹欄肺 酒撈喬客 器飄啊 逞絹坷瘤 臼欄擱
switch(WhatLineIUse)
{
case 1:
// if(ThrunetIP==NULL)
// return 9010;
return ThrunetPort;
// return 5000;
// return g_GameInfo.port;
break;
case 2:
return m_SessParam.nPortNum;
// return htons(m_SessParam.nPortNum);
break;
case 3:
return Unitel_Port();
case 4:
return Netsgo_Port();
case 5:
return 9000;
default:
// MessageBox(NULL,"Can't Detect Line","Please Ask Release Corp.",NULL);
break;
}
int port = atoi(Command[ Port_pos[WhatLineIUse] ]);
if(port<0) port=0;
return (port);
}
char* CClientBill::ReturnPayIPaddress() //霸撈飄傀撈 酒撈喬 鍋齲
{
if(WhatLineIUse<0) return NULL;
memset(Return,0,sizeof(Return));
if(IP_pos[WhatLineIUse]==-1 || Port_pos[WhatLineIUse]==-1) //父距 牢磊藹欄肺 酒撈喬客 器飄啊 逞絹坷瘤 臼欄擱
switch(WhatLineIUse)
{
case 1:
// if(ThrunetIP==NULL)
{
memset(Return,0,sizeof(Return));
// strcpy(Return, g_GameInfo.server);
// strcpy(Return, "203.248.248.228");
strcpy(Return, ThrunetIP);
return Return;
}
break;
// return ThrunetIP;
case 2:
{
// _asm int 3;
strcpy(Return, m_SessParam.lpszIPAddress);
return Return;
}
break;
case 3:
Unitel_IP();
return Return;
case 4:
Netsgo_IP();
return Return;
case 5:
KornetWorld_IP();
// PostQuitMessage(0);
return Return;
default:
// MessageBox(NULL,"Can't Detect Line","Please Ask Release Corp.",NULL);
break;
}
memset(Return,0,sizeof(Return));
strcpy(Return, Command[ IP_pos[WhatLineIUse] ]);
return Return;
}
char* CClientBill::ReturnIPaddress() //霸撈飄傀撈 酒撈喬 鍋齲
{
// _asm int 3;
if(WhatLineIUse<0) return NULL;
memset(Return,0,sizeof(Return));
if(IP[0]!=0) //撈固 林家啊 樂欄擱
{
return IP;
}
if(IP_pos[WhatLineIUse]==-1 || Port_pos[WhatLineIUse]==-1) //父距 牢磊藹欄肺 酒撈喬客 器飄啊 逞絹坷瘤 臼欄擱
switch(WhatLineIUse)
{
case 1:
// if(ThrunetIP==NULL)
{
memset(Return,0,sizeof(Return));
// strcpy(Return, g_GameInfo.server);
// strcpy(Return, "203.248.248.228");
strcpy(Return, ThrunetIP);
return Return;
}
break;
// return ThrunetIP;
case 2:
{
// _asm int 3;
strcpy(Return, m_SessParam.lpszIPAddress);
return Return;
}
break;
case 3:
Unitel_IP();
return Return;
case 4:
Netsgo_IP();
return Return;
case 5:
KornetWorld_IP();
strcpy(IP,Return);
// PostQuitMessage(0);
return IP;
case 8:
WiseTop_IP();
strcpy(IP,Return);
return IP;
case 9:
strcpy(IP,"211.174.52.137");
return IP;
default:
// MessageBox(NULL,"Can't Detect Line","Please Ask Release Corp.",NULL);
break;
}
memset(Return,0,sizeof(Return));
strcpy(Return, Command[ IP_pos[WhatLineIUse] ]);
return Return;
}
int CClientBill::ReturnPORTNumber() //霸撈飄傀撈 器飄 鍋齲
{
if(WhatLineIUse<0) return 0;
if(IP_pos[WhatLineIUse]==-1 || Port_pos[WhatLineIUse]==-1) //父距 牢磊藹欄肺 酒撈喬客 器飄啊 逞絹坷瘤 臼欄擱
switch(WhatLineIUse)
{
case 1:
// if(ThrunetIP==NULL)
// return 9010;
return ThrunetPort;
// return 5000;
// return g_GameInfo.port;
break;
case 2:
return m_SessParam.nPortNum;
// return htons(m_SessParam.nPortNum);
break;
case 3:
return Unitel_Port();
case 4:
return Netsgo_Port();
case 5:
return KornetWorld_Port();
case 8:
return WiseTop_Port();
case 9:
return 9001;
case 12: //excite game
return this->port;
case 13:
return Unitel_Port();
default:
// MessageBox(NULL,"Can't Detect Line","Please Ask Release Corp.",NULL);
break;
}
int port = atoi(Command[ Port_pos[WhatLineIUse] ]);
if(port<0) port=0;
return (port);
}
void CheckGameSocketAndSendHeartBeat(void* ThreadParam); //30檬俊 茄鍋究 霸烙 家南撈 摧灑擱 輛樊力 家南檔 摧綽促.
int CClientBill::SendSpecifiedMessage(HWND hwnd) //秦寸訣眉啊 霸撈飄傀撈輯滾肺 立加茄 饒 絹恫 漂瀝茄 瀝焊甫 朝妨林扁甫 盔且版快 朝府綽 竊薦
{
// _asm int 3;
if(WhatLineIUse<0) return 0;
unsigned long hHeartBeatSensor = _beginthread( CheckGameSocketAndSendHeartBeat, NULL,(void*) 1);
if (hHeartBeatSensor == -1)
return -2;
switch(WhatLineIUse)
{
case 0:
break;
case 1:
// MessageBox(NULL,"asdfasdf","haha",NULL);
if(Thrunet_SendMessage()==0)
{
PostQuitMessage(0);
return -1;
}
else return 1;
break;
case 2:
if(Channel_i_SendEncryptedData()==0)
{
PostQuitMessage(0);
return -2;
}
else
return 2;
break;
case 3:
g_unitel->Uniwin_Init(hwnd);
if(Unitel_SendMessage()==0) return -3;
else return 3;
break;
case 4:
if(Netsgo_SendMessage()==0) return -4;
else return 4;
break;
case 5: //內(nèi)齒巋靛綽 家泡闌 竅唱 凱絹輯 20檬 郴寇俊輯 皋矯瘤 酒公芭唱 竅唱究 焊郴擱 等促.
// if(MakePaySocket(2)!=1) return -5;
if(Kornet_SendMessage()==0) return -5;
else return 5;
break;
case 6:
break;
case 12:
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -