stoneage8.5/石器时代8.5客户端最新源代码/石器源码/other/PtternSeparationBin.cpp

132 lines
3.8 KiB
C++
Raw Permalink Normal View History

2020-06-23 17:31:16 +08:00
#include "../systeminc/version.h"
2020-06-23 15:27:59 +08:00
#ifdef _PTTERN_SEPARATION_BIN
#include <windows.h>
#include "../systeminc/system.h"
#include "../systeminc/loadrealbin.h"
#include "../systeminc/loadsprbin.h"
#include "../systeminc/unpack.h"
#include "../systeminc/sprmgr.h"
#include "../systeminc/anim_tbl.h"
#include "PtternSeparationBin.h"
#include "../wgs\tea.h"
#include "../systeminc\VMProtectSDK.h"
extern ADRNBIN adrnbuff[MAX_GRAPHICS];
extern unsigned long bitmapnumbertable[MAX_GRAPHICS];
extern SPRITEDATA SpriteData[mxSPRITE];
//cary 2001 07 10
extern FILE *Realbinfp[MAX_GRAPHICS];
int MaxAdrnID = 0;
void InitPteernSeparationBin(LPCTSTR lpszPath)
{
TCHAR szFind[MAX_PATH];
lstrcpy(szFind, lpszPath);
lstrcat(szFind, "\\");
2020-06-23 17:31:16 +08:00
lstrcat(szFind, "*.*"); // 找所有文件
2020-06-23 15:27:59 +08:00
WIN32_FIND_DATA wfd;
HANDLE hFind = FindFirstFile(szFind, &wfd);
2020-06-23 17:31:16 +08:00
if (hFind == INVALID_HANDLE_VALUE) // 如果没有找到或查找失败
2020-06-23 15:27:59 +08:00
return;
int index = 2;
do
{
if (wfd.cFileName[0] == '.')
2020-06-23 17:31:16 +08:00
continue; // 过滤这两个目录
2020-06-23 15:27:59 +08:00
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
TCHAR szFile[MAX_PATH];
TCHAR szFindAdrnName[MAX_PATH];
TCHAR szFindRealName[MAX_PATH];
TCHAR szFindSprAdrnName[MAX_PATH];
TCHAR szFindSprName[MAX_PATH];
char FilePath[200];
GetCurrentDirectory(200,FilePath);
wsprintf(szFile, "%s//%s", FilePath, lpszPath);
wsprintf(szFile, "%s//%s", lpszPath, wfd.cFileName);
#ifdef _SA_VERSION_25
wsprintf(szFindAdrnName, "%s//adrn.es", szFile);
wsprintf(szFindRealName, "%s//real.es", szFile);
#endif
if(AdrnInit(szFindAdrnName, szFindRealName, index)==TRUE){
#ifdef _SA_VERSION_25
wsprintf(szFindSprAdrnName, "%s//spradrn.es", szFile);
wsprintf(szFindSprName, "%s//spr.es", szFile);
#endif
extern BOOL InitSprBinFileOpen( char *SPR_BIN, char *SPRADRN_BIN );
InitSprBinFileOpen(szFindSprName,szFindSprAdrnName);
index++;
if(index>100)break;
}
2020-06-23 17:31:16 +08:00
InitPteernSeparationBin(szFile); // 如果找到的是目录,则进入此目录进行递归
2020-06-23 15:27:59 +08:00
}
else
{
}
} while (FindNextFile(hFind, &wfd));
2020-06-23 17:31:16 +08:00
FindClose(hFind); // 关闭查找句柄
2020-06-23 15:27:59 +08:00
}
int nextMaxAdrnID=0;
BOOL AdrnInit(LPCTSTR strAdrnFileName, LPCTSTR strRealFileName, int index)
{
ADRNBIN tmpadrnbuff;
FILE *Realfp, *Addrbinfp;
nextMaxAdrnID = MaxAdrnID;
int maxid = MaxAdrnID;
if (fopen_s(&Addrbinfp,strAdrnFileName, "rb")){
return FALSE;
}
if(fopen_s(&Realfp, strRealFileName, "rb")){
return FALSE;
}
#ifdef _BUDING_
extern int getfilesize(FILE* fp);
int size = getfilesize(Addrbinfp);
char * sadrnbin = (char*)malloc(size);
fread(sadrnbin,1,size,Addrbinfp);
2020-06-23 17:31:16 +08:00
TEA解密((long*)sadrnbin,(size/4),(long *)_BUDING_);
2020-06-23 15:27:59 +08:00
int i=0;
for(i;i<size/sizeof(ADRNBIN);i++){
memcpy(&tmpadrnbuff,sadrnbin+i*sizeof(ADRNBIN),sizeof(ADRNBIN));
adrnbuff[tmpadrnbuff.bitmapno + maxid] = tmpadrnbuff;
Realbinfp[tmpadrnbuff.bitmapno + maxid] = Realfp;
if((ULONG)MaxAdrnID < tmpadrnbuff.bitmapno + maxid){
MaxAdrnID = tmpadrnbuff.bitmapno + maxid;
}
if( tmpadrnbuff.attr.bmpnumber != 0
#ifdef _NOFANLIMAP_
&& tmpadrnbuff.attr.bmpnumber > 1500
#endif
){
bitmapnumbertable[tmpadrnbuff.attr.bmpnumber] = tmpadrnbuff.bitmapno + maxid;
}
}
fclose(Addrbinfp);
free(sadrnbin);
#else
while(!feof(Addrbinfp)){
fread(&tmpadrnbuff, sizeof(tmpadrnbuff), 1, Addrbinfp);
adrnbuff[tmpadrnbuff.bitmapno + maxid] = tmpadrnbuff;
Realbinfp[tmpadrnbuff.bitmapno + maxid] = Realfp;
if((ULONG)MaxAdrnID < tmpadrnbuff.bitmapno + maxid){
MaxAdrnID = tmpadrnbuff.bitmapno + maxid;
}
if( tmpadrnbuff.attr.bmpnumber != 0 ){
bitmapnumbertable[tmpadrnbuff.attr.bmpnumber] = tmpadrnbuff.bitmapno + maxid;
}
}
fclose(Addrbinfp);
#endif
return TRUE;
}
#endif