hash.cpp
上传用户:garry_shen
上传日期:2015-04-15
资源大小:45647k
文件大小:11k
- #include "stdafx.h"
- #include "hash.h"
- #include "Config.h"
- #include "wgsDS_API.h"
- #include "wgsCommon.h"
- #include "Common.h"
- #include "XmudOS.h"
- #include "Player.h"
- extern rmfullglobals myglobs;
- extern char g_tszPathName[256];
- static BOOL DSOK = TRUE;
- static int DSFailCount = 0;
- int DSWait(int *lpnRet)
- {
- return *lpnRet;
- }
- void szHashName(CString name, char *buf)
- {
- char temp[21], temp2[10], userdir[60];
- unsigned int all,i;
- userdir[0] = 0;
- strncpy(temp,name,20);
- for (all=0,i=0;i<strlen(temp);i++) {
- all+=temp[i];
- sprintf(temp2,"%02X",temp[i]);
- strcat(userdir, temp2);
- }
- sprintf(buf,"playersave\%02X\_%s",all%256,userdir);
- }
- void szHash2(CString name, char *buf)
- {
- char temp[21];
- CString szTemp;
- unsigned int all,i;
- szTemp = name;
- szTemp.MakeLower();
- strncpy(temp,szTemp,20);
- for (all=0,i=0;i<strlen(temp);i++) {
- all+=temp[i];
- }
- sprintf(buf,"%02X",all%256);
- }
- int nGetPlayerNumber(char *szUser, char *szPath, char *szFile)
- {
- FILE *fp;
- char filebuf1[256], buf1[256];
- int nRet=-1;
- sprintf( filebuf1,"%s\%s\%s", g_tszPathName, szPath, szFile);
- fp = fopen( filebuf1, "r");
- if( fp ) {
- nRet = 0;
- while( fgets( buf1,sizeof( buf1), fp) != NULL ) {
- nRet++;
- }
- fclose( fp);
- }else {
- fp = fopen( filebuf1, "w+");
- if( fp) {
- nRet=0;
- fclose(fp);
- }
- }
- return nRet;
- }
- int AddPlayer(char *szUser, char *szPath, char *szFile, char *CName, char *EName, char *Password)
- {
- char buffer[1024],filebuf1[256];
- int nRet = 0;
- FILE *fp;
- sprintf(buffer,"%s %s %s",CName,EName,Password);
-
- sprintf( filebuf1,"%s\%s\%s", g_tszPathName, szPath, szFile);
- if( (fp=fopen( filebuf1,"r")) != NULL) { //