⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cbmap.h

📁 赤壁之战(游戏原码)
💻 H
📖 第 1 页 / 共 2 页
字号:
//- Tian Yue
#endif	// TNEBUG

// 初始化
///////////
// 初始化图素数据(Unit, Ground, Region)
// initialize ground, unit, region data and map library
void MAP_InitMap();
// initialize ground, unit, region data
void MAP_InitGUR();
// initialize map library
void MAP_InitMapLib();

// 初始化地形图素数据
void MAP_ResetGround();

// 初始化单元图素数据
void MAP_ResetUnit();

// 初始化区域图素数据
void MAP_ResetRegion();
///////////

//- Tian Yue
#ifndef	TNEBUG

// 地形图素
///////////
// 读地形图素数据文件
// defined in file CBFile.cpp
// hwnd			:	错误处理时窗口句柄
// filename		:	地形图素数据文件名
// path			:	文件路径
// reutrn value	:	TRUE if succeeded
BOOL MAP_ReadGroundFile( HWND hwnd, LPCTSTR filename, LPCTSTR pathDAT, LPCTSTR pathBMP );

// 对地形图素解码
// 在调用此函数之前应该判断code值是否为MAP_DATA_NONE
// codeG	:	地形图素代码(压缩)(入口)
// pstctG	:	地形图素代码(展开)(出口)
extern void MAP_GroundDeCode(WORD codeG, struct MAP_GROUND_CODE_STRUCT * pstctG);

// 对地形图素加码
// stctG		:	地形图素代码(展开)(入口)
// return value	:	地形图素代码(压缩)(出口)
extern WORD MAP_GroundEnCode(struct MAP_GROUND_CODE_STRUCT stctG);

// 取得地形图素数据
// nLayer		:	层号
// nCol			:	列号
// nRow			:	行号
// return value	:	地形图素代码(压缩)
extern WORD MAP_GetGroundData( int nLayer, int nCol, int nRow );

// 设置地形图素数据
// nLayer	:	层号
// nCol		:	列号
// nRow		:	行号
// codeG	:	地形图素代码(压缩)
extern void MAP_SetGroundData( int nLayer, int nCol, int nRow, WORD codeG );

// 得到地形图素在屏幕的相对位置和大小(点)
// lprcS		:	屏幕内格子的相对坐标指针(入口)
// nLayer		:	层号
// nCol			:	列号
// nRow			:	行号
// nFile		:	文件号
// return value	:	地形图素在屏幕的相对位置和大小(点)
RECT MAP_GetGroundRect( CONST POINT ptOff, int nLayer, int nCol, int nRow, int nFile );
///////////

// 单元图素
///////////
// 读单元图素数据定义文件
// defined in file CBFile.cpp
// hwnd			:	错误处理时窗口句柄
// filename		:	单元图素数据文件名
// path			:	文件路径
// reutrn value	:	TRUE if succeeded
BOOL MAP_ReadUnitFile( HWND hwnd, LPCTSTR filename, LPCTSTR pathDAT, LPCTSTR pathBMP );

// 对单元图素解码
// 在调用此函数之前应该判断code值是否为MAP_DATA_NONE
// codeU	:	单元图素代码(压缩)(入口)
// pstctU	:	单元图素代码(展开)(出口)
extern void MAP_UnitDeCode(DWORD codeU, struct MAP_UNIT_CODE_STRUCT * pstctU);

// 对单元图素加码
// stctU		:	单元图素代码(展开)(入口)
// return value	:	单元图素代码(压缩)(出口)
extern DWORD MAP_UnitEnCode(struct MAP_UNIT_CODE_STRUCT stctU);

// 对单元图素数据进行操作
// 得到单元数据(压缩)
// nCol			:	列号
// nRow			:	行号
// return value	:	单元数据(压缩)
DWORD MAP_GetUnitData( int nCol, int nRow );

// 得到显示/设置数据(压缩)
// 产生单元数据和删除单元数据,都在这一个函数里
// 但是只被CTRL_UNIT_Create()和CTRL_UNIT_Destroy()调用
// 外部函数在产生或删除单元时不直接使用这个函数
// nLayer		:	层号,目的位置
// nCol			:	列号,目的位置
// nRow			:	行号,目的位置
// codeU		:	单元数据(压缩)
// return value	:	产生的单元压缩代码Ex(codeUEx)
WORD MAP_SetUnitData( int nLayer, int nCol, int nRow, DWORD codeU );

// 直接得到数组内数据
// nCol			:	列号
// nRow			:	行号
// return value	:	单元数据(但不是压缩码)
extern WORD MAP_GetUnitDataEx( int nCol, int nRow );

// 直接设置数组内数据
// nCol			:	列号
// nRow			:	行号
// wCode		:	单元数据(但不是压缩码)
extern void MAP_SetUnitDataEx( int nCol, int nRow, WORD wCode );

// 得到显示图素数据,此函数专门用于显示
// 当输入的行列号不在该单元的显示位置时,则返回失败
// nCol			:	列号
// nRow			:	行号
// pstctCF		:	帧数据结构(出口)
// reutrn value	:	TRUE if succeeded
BOOL MAP_GetUnitFrameData( int nCol, int nRow, struct CTRL_FRAME_STRUCT *pstctCF, BOOL bDone=TRUE );

// 移动整个单元
// 当目的位置被其它单元占据时返回失败
// 只被CTRL_UNIT_Move()调用,其他人不直接调用此函数
// only used by CTRL_UNIT_Move()
// pDraw		:	unit control frame struct 单元帧控制结构
// return value	:	TRUE if succeeded
BOOL MAP_MoveUnit( struct CTRL_FRAME_STRUCT *pDraw, int nType );

//- Tian Yue
#endif	// TNEBUG

// 得到单元结构
// nCol			:	列号
// nRow			:	行号
// return value	:	单元结构指针
extern struct UNIT_STRUCT *MAP_GetUnit( int nCol, int nRow );

// 得到单元结构
// dwCode		:	单元的压缩代码
// return value	:	单元结构指针
extern struct UNIT_STRUCT *MAP_GetUnit( WORD wCode );

//- Tian Yue
#ifndef	TNEBUG

// 得到单元图素在屏幕的相对位置和大小(点)
// lprcS		:	屏幕内格子的相对坐标指针(入口)
// pstctCF		:	帧结构指针(入口)
// return value	:	单元图素在屏幕的相对位置和大小(点)
RECT MAP_GetUnitRect( CONST POINT ptOff, CONST struct CTRL_FRAME_STRUCT *pstctCF );

// 得到单元的旧相对位置和大小,用于在旧位置上擦除该单元
// lprcS		:	屏幕内格子的相对坐标指针
// pstctCF		:	帧结构指针(入口)
// return value	:	单元图素在屏幕的上一个位置的相对位置和大小(点)
RECT MAP_GetUnitRectLast( CONST POINT ptOff, CONST struct CTRL_FRAME_STRUCT *stctCF );
///////////

// 特殊图素
///////////
// 读取特殊地形图素数据
// defined in file CBFile.cpp
// hwnd			:	错误处理时窗口句柄
// filename		:	特殊图素数据文件名
// path			:	文件路径
// reutrn value	:	TRUE if succeeded
BOOL MAP_ReadSpecFile( HWND hwnd, LPCTSTR filename , LPCTSTR path );

// 得到显示图素数据,return not null for pstct is valid
// nLayer		:	层号
// nCol			:	列号
// nRow			:	行号
// nAttr		:	属性
// pstctCF		:	帧结构指针(出口)
// reutrn value	:	TRUE if succeeded
BOOL MAP_GetSpecFrameData( int nLayer, int nCol, int nRow, int nAttr, struct CTRL_FRAME_STRUCT *pstctCF );
///////////

// 区域图素
///////////
// 对区域图素解码
// 在调用此函数之前应该判断code值是否为MAP_DATA_NONE
// codeR	:	区域图素(压缩)(入口)
// pstctR	:	区域图素(展开)(出口)
extern void MAP_RegionDeCode(WORD codeR, struct MAP_REGION_CODE_STRUCT * pstctR);

// 对区域图素加码
// stctR		:	区域图素(展开)(入口)
// return value	:	区域图素(压缩)(出口)
extern WORD MAP_RegionEnCode(struct MAP_REGION_CODE_STRUCT stctR);

// 对区域数据的操作
// 填充区域, 递归函数
// pt		:	填充点种子,格子为单位
// nPlayer	:	填充内容,游戏者编号
void MAP_FillRegion( POINT pt, int nPlayer );

// 清除区域
// pt	:	填充点种子,格子为单位
void MAP_ClearRegion( POINT pt );

// 直接将压缩后的代码设置到区域数组中
// nCol		:	列号
// nRow		:	行号
// codeR	:	区域数据代码(压缩)
extern void MAP_SetRegionData( int nCol, int nRow, int codeR );

// 直接从区域数组中取出数据
// nCol			:	列号
// nRow			:	行号
// return value	:	区域数据代码(压缩)
extern WORD MAP_GetRegionData( int nCol, int nRow );

#define	MAP_REGION_ERROR_CANNOT		3
#define	MAP_REGION_ERROR_UNDER		4
#define	MAP_REGION_ERROR_TUDI		0
#define	MAP_REGION_ERROR_SHIPYARD	2
#define	MAP_REGION_ERROR_FLAG		1
#define	MAP_REGION_ERROR_SHORT		5
#define	MAP_REGION_ERROR_SHIP		6
#define	MAP_REGION_ERROR_OUT		7
#define	MAP_REGION_ERROR_RES		8
#define	MAP_REGION_ERROR_SHADOW		9
#define	MAP_REGION_ERROR_WATER		10
#define	MAP_REGION_ERROR_BANK		11
#define	MAP_REGION_SUCCESS			20
// 检测是否可以在此片地域上修建建筑,return 10 if successful
// nLayer		:	层号
// pt			:	测试点,格子为单位
// codeU		:	建筑代码(压缩)
// codeUEx		:	出发点的单元,检测时可以取得此点,MAP_DATA_NONE时无效
// return value	:	错误代码,见上
int MAP_TestRegion( int nLayer, POINT pt, DWORD codeU, WORD codeUEx=MAP_DATA_NONE );

// 自动找到一个可以放置该单元的位置,在10格范围内寻找
// nZ, nX, nY	:	开始的坐标
// codeU		:	该单元的压缩代码
// codeUEx		:	出发点的单元,检测时可以取得此点,MAP_DATA_NONE时无效
// return		:	(-1,-1)时为没有找到
POINT MAP_FindRegion( int nZ, int nX, int nY, DWORD codeU, WORD codeUEx=MAP_DATA_NONE );

// 只有在CBBuild.cpp中使用,建造建筑时用
// 检测是否可以在此片地域上修建建筑
// nLayer		:	层号
// pt			:	测试点,格子为单位
// codeU		:	建筑代码(压缩)
// pnRet		:	返回值数组
// nRetNum		:	返回数组的个数
void MAP_TestRegionBuild( int nLayer, POINT pt, DWORD codeU, int *pnRet, int nRetNum );
///////////

// 探测附近函数
///////////
#define	MAP_LOCATION_MAX	16
// 查询探测附近的单元和地形情况
// 最大距离为10
//    0
//  7   1
//6       2
//  5   3
//    4
#define	MAP_SENSER_MAX	10
// 从自己算起,向外延伸10格
// First Dimension:		Even or Odd
// Second Dimension:	Distance from center
// Third Dimension:		max senser items
extern POINT MAP_ptSenser[2][MAP_SENSER_MAX][8*MAP_SENSER_MAX]; // 当中心为第偶数行时使用

// read senser file, defined in CBFile.cpp
// 读取探测数据
// hwnd			:	错误处理时窗口句柄
// filename		:	探测数据文件名
// path			:	文件路径
// reutrn value	:	TRUE if succeeded
BOOL MAP_ReadSenserFile( HWND hwnd, LPCTSTR filename, LPCTSTR path );
///////////

///////////
// 读单元图素动画数据定义文件
// defined in file CBFile.cpp
// hwnd			:	错误处理时窗口句柄
// filename		:	单元图素数据文件名
// path			:	文件路径
// reutrn value	:	TRUE if succeeded
BOOL MAP_ReadAniSeqFile( HWND hwnd, LPCTSTR filename, LPCTSTR path );

// 读扩充的单元图素动画数据定义文件
// defined in file CBFile.cpp
// hwnd			:	错误处理时窗口句柄
// filename		:	单元图素数据文件名
// path			:	文件路径
// reutrn value	:	TRUE if succeeded
BOOL MAP_ReadAniSeqFileEx( HWND hwnd, LPCTSTR filename, LPCTSTR path );
///////////

///////////
// 读取缩略图数据文件
// defined in file CBFile.cpp
// hwnd			:	错误处理时窗口句柄
// filename		:	单元图素数据文件名
// path			:	文件路径
// reutrn value	:	TRUE if succeeded
BOOL MAP_ReadMiniFile( HWND hwnd, LPCTSTR filename, LPCTSTR path );
///////////

///////////
// 读取其它数据
BOOL MAP_ReadOtherFile( HWND hwnd, LPCTSTR filename, LPCTSTR pathDAT, LPCTSTR pathBMP );

// 计算其它数据的矩形区域
// ptOff	:	屏幕左上角相对于整个战场的坐标
// nLayer, nCol, nRow	:	在战场的三维坐标
// nFile	:	其它数据结构的文件号
// return	:	相对于屏幕的点坐标和范围
RECT MAP_GetOtherRect( CONST POINT ptOff, int nLayer, int nCol, int nRow, int nFile );
///////////

//- Tian Yue
#endif	// TNEBUG
#endif	// __CBMAP_H__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -