www.pudn.com > 3D_OnlineGame_Humen.rar > FileFunctionItem.cpp
#include "stdafx.h" #include "XMudClient.h" #include "FileFunctionItem.h" #include "MenuCreateNew.h" #include "faceplate.h" extern char g_tszPathName[256]; extern CListplayerlist; CList itemlist; BOOL GetItemInfo(CString sItemFile) { CItemInfo *lpItemInfo; char szFileName[256]; lstrcpy( szFileName, g_tszPathName ); lstrcat( szFileName, "\\" ); lstrcat( szFileName, sItemFile ); CStringList strls; char * ps; CString strtmp; CString buf; double ftmp; int itmp; CFile file; LPTSTR lpsz; CString parm=CString("\t"); if( !file.Open( szFileName, CFile::modeRead ) ) { return FALSE; } CArchive ar(&file,CArchive::load); while(ar.ReadString(buf)) { int i=0; ps=strtok((char*)(LPCSTR)buf,(const char*)parm); if(ps==NULL) { ar.Close(); file.Close(); return FALSE; } strls.AddTail(ps); for(;;) { ps=strtok(NULL,(const char*)parm); if(ps==NULL)break; i++; strls.AddTail(ps); } if (i!=13) { ar.Close(); file.Close(); return FALSE; } lpItemInfo = new CItemInfo; if(!lpItemInfo)return FALSE; strtmp=strls.GetAt(strls.FindIndex(0)); lpItemInfo->m_sCNAME=strtmp.Mid(1,strtmp.GetLength()-2); strtmp=strls.GetAt(strls.FindIndex(1)); lpItemInfo->m_sENAME=strtmp.Mid(1,strtmp.GetLength()-2); strtmp=strls.GetAt(strls.FindIndex(2)); lpsz = strtmp.GetBuffer(20); itmp=strtol(lpsz,'\0',10); strtmp.ReleaseBuffer(); lpItemInfo->m_iWEIGHT=itmp; strtmp=strls.GetAt(strls.FindIndex(3)); lpItemInfo->m_sTYPE=strtmp.Mid(1,strtmp.GetLength()-2); strtmp=strls.GetAt(strls.FindIndex(4)); lpItemInfo->m_sDATA_DBF=strtmp.Mid(1,strtmp.GetLength()-2); strtmp=strls.GetAt(strls.FindIndex(5)); lpsz = strtmp.GetBuffer(20); itmp=strtol(lpsz,'\0',10); strtmp.ReleaseBuffer(); lpItemInfo->m_iEFFACT=itmp; strtmp=strls.GetAt(strls.FindIndex(6)); lpsz = strtmp.GetBuffer(20); itmp=strtol(lpsz,'\0',10); strtmp.ReleaseBuffer(); lpItemInfo->m_iEFFNUM=itmp; strtmp=strls.GetAt(strls.FindIndex(7)); lpItemInfo->m_sXFILENAME=strtmp.Mid(1,strtmp.GetLength()-2); strtmp=strls.GetAt(strls.FindIndex(8)); lpsz = strtmp.GetBuffer(20); ftmp=strtod(lpsz,'\0'); strtmp.ReleaseBuffer(); lpItemInfo->m_fSCALE=ftmp; strtmp=strls.GetAt(strls.FindIndex(9)); lpsz = strtmp.GetBuffer(20); ftmp=strtod(lpsz,'\0'); strtmp.ReleaseBuffer(); lpItemInfo->m_fROTATION_X=ftmp; strtmp=strls.GetAt(strls.FindIndex(10)); lpsz = strtmp.GetBuffer(20); ftmp=strtod(lpsz,'\0'); strtmp.ReleaseBuffer(); lpItemInfo->m_fROTATION_Y=ftmp; strtmp=strls.GetAt(strls.FindIndex(11)); lpsz = strtmp.GetBuffer(20); ftmp=strtod(lpsz,'\0'); strtmp.ReleaseBuffer(); lpItemInfo->m_fROTATION_Z=ftmp; strtmp=strls.GetAt(strls.FindIndex(12)); lpItemInfo->m_sKIND=strtmp.Mid(1,strtmp.GetLength()-2); strtmp=strls.GetAt(strls.FindIndex(13)); lpsz = strtmp.GetBuffer(20); itmp=strtol(lpsz,'\0',10); strtmp.ReleaseBuffer(); lpItemInfo->m_iVALUE=itmp; strls.RemoveAll(); itemlist.AddTail(lpItemInfo); } ar.Close(); file.Close(); return TRUE; } void ItemEffect(int iValue, int iPos) { }