cmdcreatenewplayer.cpp
上传用户:garry_shen
上传日期:2015-04-15
资源大小:45647k
文件大小:11k
源码类别:
游戏引擎
开发平台:
Visual C++
- #include "stdafx.h"
- #include "XmudOS.h"
- #include "MainWnd.h"
- #include "CmdPlayerLogon.h"
- #include "MapMapInfo.h"
- #include "Common.h"
- #include "hash.h"
- #include "wgsDS_API.h"
- extern char g_tszPathName[256];
- extern rmfullglobals myglobs;
- extern CList <TClientConData *,TClientConData* >playersocketlist;
- extern CList <TDataUser*,TDataUser*>userlist;
- extern void GetXFileName(CPlayerInfo *lpPlayerInfo);
- extern void GetPlayerTitle(CPlayerInfo *lpPlayerInfo);
- void CCmdPlayerLogon::PlayerCreateCmdProc(char *UserName,char *PlayerName,char *stNewPlayerName,char *stPassword,
- char *stChineseName,char *sex,char *Strength,
- char *Int,char *dex,char *con,char *Result)
- {
- CPlayerInfo* lpPlayerInfo;
- char szPath[256], szFileName[256];
- int nRet=0, nTest;
- char szTest[256];
- CString sResultMsg;
- int i,sum;
- int istrength,iint,icon,idex,itmp;
- i = 0;
- while(stChineseName[i] != NULL){
- if(((stChineseName[i]>='xa1')&&(stChineseName[i]<='xf9')) &&
- (((stChineseName[i+1]>='x40')&&(stChineseName[i+1]<='x7e'))||((stChineseName[i+1]>='xa1')&&(stChineseName[i+1]<='xfe'))))
- i += 2;
- else if((stChineseName[i]>='x21')&&(stChineseName[i]<='x7e'))
- i++;
- else
- ReturnResult(szPlayerCNameErrMsg)
- }
- istrength=strtol(Strength,' ',10);
- iint = strtol(Int,' ',10);
- idex = strtol(con,' ',10);
- icon = strtol(dex,' ',10);
- CString strtmp = stNewPlayerName;
- sum = strtmp.GetLength( );
- for(i=0;i<sum;i++)
- {
- if(!isalpha(strtmp.GetAt(i) ) ){
- ReturnResult(szSystemRigged)
- }
- }
- strtmp = stPassword;
- sum = strtmp.GetLength( );
- if ( sum < 5 ){
- ReturnResult(szSystemRigged)
- }
- for(i=0;i<sum;i++){
- if(iscntrl(strtmp.GetAt(i) ) ){
- ReturnResult(szSystemRigged)
- }
- }
- if(istrength<MINATTR||iint<MINATTR||icon<MINATTR||idex<MINATTR){
- ReturnResult(szSystemRigged);
- }
- if(istrength>MAXATTR||iint>MAXATTR||icon>MAXATTR||idex>MAXATTR){
- ReturnResult(szSystemRigged);
- }
- sum = istrength+iint+icon+idex;
- if(sum>BASEATTR){
- ReturnResult(szSystemRigged)
- }
- lpPlayerInfo = new CPlayerInfo;
- if( !lpPlayerInfo ){
- sprintf(szTest,"ERROR (%s,%s) New lpPlayerInfo fail",
- stNewPlayerName, UserName);
- AddRecordMsg(szTest);
- ReturnResult(szOutOfMemoryErrMsg)
- }
- szHashName(UserName, szPath);
- strcpy(szFileName,UserName);
- strcat(szFileName,".sav");
- EnterCriticalSection(&myglobs.csUserlist);
- nTest = FindPlayer(UserName,szPath,szFileName,stNewPlayerName);
- if (nTest == 1) {
- LeaveCriticalSection(&myglobs.csUserlist);
- ReturnResult(szPlayerAccountHasExistErrMsg);
- }
- if (nTest <= 0) {
- sprintf(szTest,"ERROR (%s,%s) Find Player, err=%d",
- stNewPlayerName, UserName, nTest);
- AddRecordMsg(szTest);
- LeaveCriticalSection(&myglobs.csUserlist);
- ReturnResult(szDiskReadErrMsg);
- }
- nTest = AddPlayer(UserName,szPath,szFileName,stChineseName,stNewPlayerName,"1");
- LeaveCriticalSection(&myglobs.csUserlist);
- if (nTest <= 0) {
- sprintf(szTest,"ERROR (%s,%s) Add Player, err=%d",
- stNewPlayerName, UserName, nTest);
- AddRecordMsg(szTest);
- ReturnResult(szDiskWriteErrMsg);
- }
- lpPlayerInfo->szCName = stChineseName;
- lpPlayerInfo->szEName = stNewPlayerName;
- lpPlayerInfo->nShen = 0;
- lpPlayerInfo->szSex = sex;
- lpPlayerInfo->nAge = 14;
- lpPlayerInfo->nStr = istrength;
- lpPlayerInfo->nInt = iint;
- lpPlayerInfo->nCon = icon;
- lpPlayerInfo->nDex = idex;
- lpPlayerInfo->nEff_jing = 100;
- lpPlayerInfo->nMax_jing = 100;
- lpPlayerInfo->nEff_qi = 100;
- lpPlayerInfo->nMax_qi = 100;
- lpPlayerInfo->nEff_jingli = 0;
- lpPlayerInfo->nMax_jingli = 0;
- lpPlayerInfo->nAdd_Jingli = 0;
- lpPlayerInfo->nEff_force = 0;
- lpPlayerInfo->nMax_force = 0;
- lpPlayerInfo->nAdd_force = 0;
- lpPlayerInfo->nCombat_exp = 0;
- lpPlayerInfo->nScore = 0;
- lpPlayerInfo->nQianNeng = 99;
- lpPlayerInfo->szFamily = "礚