MapInfo.cpp
上传用户:garry_shen
上传日期:2015-04-15
资源大小:45647k
文件大小:10k
- #include "stdafx.h"
- #include "XMudClient.h"
- #include "D3DRMScreen.h"
- #include "MapInfo.h"
- #include "MenuCreateNew.h"
- #include "FacePlate.h"
- #include "MyMusic.h"
- #include <Imm.h>
- #include "MyDInput.h"
- extern char g_szReceive[];
- extern char g_tszPathName[256];
- //extern char g_szSrvActiveBuf[2048];
- extern rmfullglobals myglobs;
- extern D3DAppInfo* d3dapp;
- extern LPDIRECT3DRM3 g_lpD3DRM;
- extern CRITICAL_SECTION csAnimation;
- extern CList <animationCallbackArgs *, animationCallbackArgs *> animationlist;
- extern animationCallbackArgs *cb;
- extern CList <CMapInfo *, CMapInfo *> maplist;
- extern CList<CPlayerInfo*,CPlayerInfo*>playerlist;
- extern CPlayerInfo * lpPlayerInfo;
- extern CList<CSkillInfo*,CSkillInfo*>skilllist;
- extern CSkillInfo * lpSkillInfo;
- extern CList<CEquipInfo*,CEquipInfo*>equiplist;
- extern CList<CEquipInfo*,CEquipInfo*>equiprentlist;
- extern CStringList g_equiprentlist;
- extern CEquipInfo *lpEquipInfo;
- extern CList<CExitInfo * ,CExitInfo*> exitlist;
- extern CExitInfo *lpExitInfo;
- extern int g_nGameState;
- extern BOOL g_bClientNet;
- extern LPDIRECT3DRMFRAME3 g_lpplayer;
- extern void QuitResolution(void);
- BOOL GetNewMap(CString strtmp)
- {
- CMapInfo * lpMapInfo;
- int i,j;
- CStringList strls,strlsmap;
- CString parm;
- double ftmp;
- LPTSTR lpsz;
- char *ps;
- BOOL bFindHead=FALSE;
- // strtmp = g_szReceive;
- lpsz = strtmp.GetBuffer(strtmp.GetLength()+1);
- parm=CString("t");
- ps=strtok(lpsz,(const char*)parm);
- strls.AddTail(ps);
- for(;;)
- {
- ps=strtok(NULL,(const char*)parm);
- if(ps==NULL)break;
- strls.AddTail(ps);
- }
- j = strls.GetCount();
- for(i=0;i<j;i++)
- {
- if(!bFindHead)
- {
- strtmp = strls.GetAt( strls.FindIndex(i));
- if(!lstrcmp("'MAPDATA'",strtmp) )
- bFindHead = TRUE;
- }
- else
- {
- strtmp = strls.GetAt( strls.FindIndex(i));
- if(!stricmp(strtmp,"'MAPDATAEND'"))
- break;
- else
- strlsmap.AddTail(strtmp);
- }
- }//end for(;;)
- strls.RemoveAll();
- if(!bFindHead)return FALSE;
- POSITION pos;
- pos = strlsmap.FindIndex(0);
- lpMapInfo = new CMapInfo;
- strtmp = strlsmap.GetNext(pos);
- lpMapInfo->m_sCNAME = strtmp.Mid(1,strtmp.GetLength()-2);
- strtmp = strlsmap.GetNext(pos);
- lpMapInfo->m_sENAME = strtmp.Mid(1,strtmp.GetLength()-2);
- strtmp = strlsmap.GetNext(pos);
- lpMapInfo->m_sXFILENAME = strtmp.Mid(1,strtmp.GetLength()-2);
- maplist.AddTail(lpMapInfo);
- for(i=0;i<strlsmap.GetCount();i++)
- {
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i));
- if(!stricmp(strtmp,"'EXITDATA'"))
- {
- lpMapInfo = new CMapInfo;
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+1));
- lpMapInfo->m_sEXIT_DBF = strtmp.Mid(1,strtmp.GetLength()-2);
-
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+2));
- lpMapInfo->m_sCNAME = strtmp.Mid(1,strtmp.GetLength()-2);;
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+3));
- lpMapInfo->m_sENAME = strtmp.Mid(1,strtmp.GetLength()-2);;
- strtmp = strlsmap.GetAt( strlsmap.FindIndex(i+4));
- strtmp = strtmp.Mid(1,strtmp.GetLength()-2);
- lpsz = strtmp.GetBuffer(20);
- ftmp=strtod(lpsz,' ');
- strtmp.ReleaseBuffer();
- lpMapInfo->m_fPOSITION_X = ftmp;
-
- strtmp = strlsmap.GetAt( strlsmap.FindIndex(i+5));
- strtmp = strtmp.Mid(1,strtmp.GetLength()-2);
- lpsz = strtmp.GetBuffer(20);
- ftmp=strtod(lpsz,' ');
- strtmp.ReleaseBuffer();
- lpMapInfo->m_fPOSITION_Z = ftmp;
- maplist.AddTail(lpMapInfo);
- i += 5;
- }
- else if(!stricmp(strtmp,"'NPCDATA'"))
- {
- lpMapInfo = new CMapInfo;
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+1));
- lpMapInfo->m_sCNAME = strtmp.Mid(1,strtmp.GetLength()-2);
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+2));
- lpMapInfo->m_sENAME = strtmp.Mid(1,strtmp.GetLength()-2);
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+3));
- lpMapInfo->m_sXFILENAME = strtmp.Mid(1,strtmp.GetLength()-2);
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+4));
- lpMapInfo->m_sNPC_DBF = strtmp.Mid(1,strtmp.GetLength()-2);
- if(lpMapInfo->m_sNPC_DBF.IsEmpty())
- lpMapInfo->m_sNPC_DBF = "κ﹎";
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+5));
- lpMapInfo->m_sMAPINFO = strtmp.Mid(1,strtmp.GetLength()-2);
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+6));
- lpMapInfo->szPerson = strtmp.Mid(1,strtmp.GetLength()-2);
- maplist.AddTail(lpMapInfo);
- i += 6;
- }
- else if(!stricmp(strtmp,"'PLAYDATA'"))
- {
- lpMapInfo = new CMapInfo;
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+1));
- lpMapInfo->m_sCNAME = strtmp.Mid(1,strtmp.GetLength()-2);
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+2));
- lpMapInfo->m_sENAME = strtmp.Mid(1,strtmp.GetLength()-2);
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+3));
- lpMapInfo->m_sXFILENAME = strtmp.Mid(1,strtmp.GetLength()-2);
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+4));
- lpMapInfo->m_sPLAYER_DBF = strtmp.Mid(1,strtmp.GetLength()-2);
- if(lpMapInfo->m_sPLAYER_DBF.IsEmpty())
- lpMapInfo->m_sPLAYER_DBF = "κ﹎";
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+5));
- lpMapInfo->m_sMAPINFO = strtmp.Mid(1,strtmp.GetLength()-2);
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+6));
- lpMapInfo->szPerson = strtmp.Mid(1,strtmp.GetLength()-2);
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+7));
- lpMapInfo->szPlayerIP = strtmp.Mid(1,strtmp.GetLength()-2);
- strtmp = strlsmap.GetAt(strlsmap.FindIndex(i+8));
- lpMapInfo->m_sTITLE = strtmp.Mid(1,strtmp.GetLength()-2);
- maplist.AddTail(lpMapInfo);
- i += 8;
- }
- }
- return TRUE;
- }
- CString GetMapMessage(CString sFileName)
- {
- CString buf;
- CFile file;
- char szFileName[256];
- strcpy(szFileName,g_tszPathName);
- strcat(szFileName,"\muddata\mapmsg.dat");
- if( !file.Open( szFileName, CFile::modeRead , NULL ) )
- {
- return sFileName;
- }
- CArchive ar(&file,CArchive::load);
- while(ar.ReadString(buf))
- {
- if( sFileName == buf )
- {
- ar.ReadString(buf);
- sFileName = CString("