www.pudn.com > gamedata.rar > map.c


#include "stdafx.h" 
 
extern struct NOVELITY_MAP_INFO map[MAX_NUM_MAP]; 
/* 
说明 
地图解析问题 
方法: 
一维数值 
 
  判断 x y 坐标物品方法为 
 
 
  ((x * (y - 1) + x) - 1) 
 
*/ 
// 加载地图文件 
BOOL load_map_image() 
{ 
	FILE *fp, *fp_map; 
 
	char tmp[255]; 
	char strPath[255], filename[255]; 
 
//	TCHAR map_name[32]; 
 
	char n1[20], n2[20], n3[20], n4[20], n5[20], n6[20], n7[20]; 
 
	BYTE buf[4]; 
	int xy[2];  
	BYTE f[2]; 
	int i, j, h, z, number; 
 
	unsigned long a;  
 
	GetExeDir(strPath); 
 
	sprintf(filename, "%smap\\def.ini", strPath); 
 
//	MessageBoxA(NULL, filename, "",0); 
 
	fp = fopen(filename, "r"); 
 
	if (fp != NULL) 
	{ 
		fscanf(fp, "数量 = %s\n", tmp); 
		number = atoi(tmp); 
 
 
 
		for (i=0;i map[m].max_x) continue; 
		for(j=_y;j<=y_;j++) 
		{ 
			if (j> map[m].max_y) continue; 
			 
		//	if (map[m].map_info[n].code[0] == 0x00)  continue;  
			n = (map[m].max_x * (j - 1) + i - 1); 
 
			if ((map[m].map_info[n].code[26] == 0x00) && (i % 2 == 0) && (j % 2 == 0))  
			{  
				point.x = i; point.y = j; return point;  
			} 
		} 
	} 
 
	point.x = 0; 
	point.y = 0; 
 
	return point; 
} 
//  检测这个范围内的坐标是否,被占用 
BOOL tfnewxy(int m, int b, int number, int new_x, int new_y) 
{ 
	int i, j, _x, _y, x_, y_, tmp_x, tmp_y; 
	long n; 
		 
	tmp_x = map[m].map_info[b].code[1] + map[m].map_info[b].code[2] * 256;	 
	tmp_y = map[m].map_info[b].code[3] + map[m].map_info[b].code[4] * 256; 
 
	_x = max_(number, tmp_x) - number + 1; 
	_y = max_(number, tmp_y) - number + 1; 
 
	x_ = tmp_x + number; 
	y_ = tmp_y + number; 
 
	for(i=_x;i<=x_;i++) 
	{ 
		if (i> map[m].max_x) continue; 
		for(j=_y;j<=y_;j++) 
		{ 
			if (j> map[m].max_y) continue; 
			n = (map[m].max_x * (j - 1) + i - 1); 
		//	if (map[m].map_info[n].code[0] == 0x00)  continue; 
			if (map[m].map_info[n].code[26] == 0x00) { new_x = i; new_y = j; return TRUE; } 
		} 
	} 
 
	return FALSE; 
} 
// 给该用户一个新的坐标 
// 如果新的目标坐标没有被占用则返回这个坐标 
// 否则返回新坐标 
 
int getmapstatuscode(BYTE code1, BYTE code2) 
{ 
	int i; 
	for(i=0;i