cmdcreatenewplayer.cpp
上传用户:garry_shen
上传日期:2015-04-15
资源大小:45647k
文件大小:11k
源码类别:

游戏引擎

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. #include "XmudOS.h"
  3. #include "MainWnd.h"
  4. #include "CmdPlayerLogon.h"
  5. #include "MapMapInfo.h"
  6. #include "Common.h"
  7. #include "hash.h"
  8. #include "wgsDS_API.h"
  9. extern char g_tszPathName[256];
  10. extern rmfullglobals myglobs;
  11. extern CList <TClientConData *,TClientConData* >playersocketlist;
  12. extern CList <TDataUser*,TDataUser*>userlist;
  13. extern void GetXFileName(CPlayerInfo *lpPlayerInfo);
  14. extern void GetPlayerTitle(CPlayerInfo *lpPlayerInfo);
  15. void CCmdPlayerLogon::PlayerCreateCmdProc(char *UserName,char *PlayerName,char *stNewPlayerName,char *stPassword,
  16.   char *stChineseName,char *sex,char *Strength,
  17.   char *Int,char *dex,char *con,char *Result)
  18. {
  19. CPlayerInfo* lpPlayerInfo;
  20. char szPath[256], szFileName[256];
  21. int nRet=0, nTest;
  22. char szTest[256];
  23. CString sResultMsg;
  24. int i,sum;
  25. int istrength,iint,icon,idex,itmp;
  26. i = 0;
  27. while(stChineseName[i] != NULL){
  28. if(((stChineseName[i]>='xa1')&&(stChineseName[i]<='xf9')) &&
  29. (((stChineseName[i+1]>='x40')&&(stChineseName[i+1]<='x7e'))||((stChineseName[i+1]>='xa1')&&(stChineseName[i+1]<='xfe'))))
  30. i += 2;
  31. else if((stChineseName[i]>='x21')&&(stChineseName[i]<='x7e'))
  32. i++;
  33. else
  34. ReturnResult(szPlayerCNameErrMsg)
  35. }
  36. istrength=strtol(Strength,'',10);
  37. iint = strtol(Int,'',10);
  38. idex = strtol(con,'',10);
  39. icon = strtol(dex,'',10);
  40. CString strtmp = stNewPlayerName;
  41. sum = strtmp.GetLength( );
  42. for(i=0;i<sum;i++)
  43. {
  44. if(!isalpha(strtmp.GetAt(i) ) ){
  45. ReturnResult(szSystemRigged)
  46. }
  47. }
  48. strtmp = stPassword;
  49. sum = strtmp.GetLength( );
  50. if ( sum < 5 ){
  51. ReturnResult(szSystemRigged)
  52. }
  53. for(i=0;i<sum;i++){
  54. if(iscntrl(strtmp.GetAt(i) ) ){
  55. ReturnResult(szSystemRigged)
  56. }
  57. }
  58. if(istrength<MINATTR||iint<MINATTR||icon<MINATTR||idex<MINATTR){
  59. ReturnResult(szSystemRigged);
  60. }
  61. if(istrength>MAXATTR||iint>MAXATTR||icon>MAXATTR||idex>MAXATTR){
  62. ReturnResult(szSystemRigged);
  63. }
  64. sum = istrength+iint+icon+idex;
  65. if(sum>BASEATTR){
  66. ReturnResult(szSystemRigged)
  67. }
  68. lpPlayerInfo = new CPlayerInfo;
  69. if( !lpPlayerInfo ){
  70. sprintf(szTest,"ERROR (%s,%s) New lpPlayerInfo fail",
  71. stNewPlayerName, UserName);
  72. AddRecordMsg(szTest);
  73. ReturnResult(szOutOfMemoryErrMsg)
  74. }
  75. szHashName(UserName, szPath);
  76. strcpy(szFileName,UserName);
  77. strcat(szFileName,".sav");
  78. EnterCriticalSection(&myglobs.csUserlist);
  79. nTest = FindPlayer(UserName,szPath,szFileName,stNewPlayerName);
  80. if (nTest == 1) {
  81. LeaveCriticalSection(&myglobs.csUserlist);
  82. ReturnResult(szPlayerAccountHasExistErrMsg);
  83. }
  84. if (nTest <= 0) {
  85. sprintf(szTest,"ERROR (%s,%s) Find Player, err=%d",
  86. stNewPlayerName, UserName, nTest);
  87. AddRecordMsg(szTest);
  88. LeaveCriticalSection(&myglobs.csUserlist);
  89. ReturnResult(szDiskReadErrMsg);
  90. }
  91. nTest = AddPlayer(UserName,szPath,szFileName,stChineseName,stNewPlayerName,"1");
  92. LeaveCriticalSection(&myglobs.csUserlist);
  93. if (nTest <= 0) {
  94. sprintf(szTest,"ERROR (%s,%s) Add Player, err=%d",
  95. stNewPlayerName, UserName, nTest);
  96. AddRecordMsg(szTest);
  97. ReturnResult(szDiskWriteErrMsg);
  98. }
  99. lpPlayerInfo->szCName = stChineseName;
  100. lpPlayerInfo->szEName = stNewPlayerName;
  101. lpPlayerInfo->nShen = 0;
  102. lpPlayerInfo->szSex = sex;
  103. lpPlayerInfo->nAge = 14;
  104. lpPlayerInfo->nStr = istrength;
  105. lpPlayerInfo->nInt = iint;
  106. lpPlayerInfo->nCon = icon;
  107. lpPlayerInfo->nDex = idex;
  108. lpPlayerInfo->nEff_jing = 100;
  109. lpPlayerInfo->nMax_jing = 100;
  110. lpPlayerInfo->nEff_qi = 100;
  111. lpPlayerInfo->nMax_qi = 100;
  112. lpPlayerInfo->nEff_jingli = 0;
  113. lpPlayerInfo->nMax_jingli = 0;
  114. lpPlayerInfo->nAdd_Jingli = 0;
  115. lpPlayerInfo->nEff_force = 0;
  116. lpPlayerInfo->nMax_force = 0;
  117. lpPlayerInfo->nAdd_force = 0;
  118. lpPlayerInfo->nCombat_exp = 0;
  119. lpPlayerInfo->nScore = 0;
  120. lpPlayerInfo->nQianNeng = 99;
  121. lpPlayerInfo->szFamily = "礚