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


#include "stdafx.h" 
 
extern struct OBJECT_INFO object_info[MAX_NUM_OBJ]; 
 
int sendshopcode1(SOCKET s, BYTE code) 
{ 
	// 1E 00 00 00 EF 0A 77 2C 00 00 
	BYTE lpSource[6]; 
	int ret; 
 
	memset(lpSource, 0x00, sizeof(lpSource)); 
 
	lpSource[0]  = 0x00; 
	lpSource[1]  = 0x00; 
	lpSource[2]  = 0x00; 
	lpSource[3]  = 0x00; 
	lpSource[4]  = 0xEF; 
	lpSource[5]  = code; 
 
	ret = add_pack_chain(s, lpSource, 6, 0, FALSE); 
 
//	 
 
	return ret; 
} 
// 个人商店处理 
void TF_pshop(SOCKET s, LPBYTE lpTarget) 
{ 
 
	int n, i, j, a, index, number, id; 
 
	struct NOVELITY novelity; 
	struct OBJECT_INFO info; 
 
	BYTE code[7][8]; 
 
	char name[32], tmp[2]; 
 
	n = find_obj(s); 
 
	if (n == MAX_NUM_USER) return; 
	//	MessageBoxA(NULL, object_info[n].shop_name, "", 0); 
 
	if (lpTarget[5] == 0x00) 
	{ 
	} 
	else if (lpTarget[5] == 0x01) 
	{ 
		if (strcmp(object_info[n].shop_name, "\\") == 0) return; 
 
		for(i=0;i<7;i++) 
		{ 
			object_info[n].shop[i][0] = 0x00; 
			object_info[n].shop[i][1] = 0x00; 
			object_info[n].shop[i][2] = 0x00; 
			object_info[n].shop[i][3] = 0x00; 
			object_info[n].shop[i][4] = 0x00; 
			object_info[n].shop[i][5] = 0x00; 
			object_info[n].shop[i][6] = 0x00; 
			object_info[n].shop[i][7] = 0x00; 
		} 
 
		object_info[n].playerstatus = 0; 
 
		strcpy(object_info[n].shop_name, "\\"); 
 
		sendshopcode1(s, 0x07); 
		closeshopstatus(s, object_info[n].ServerID, 35, TRUE); 
	} 
 
	else if (lpTarget[5] == 0x02) 
	{ 
		// 00 01 02 03 04 05 06 07 
		// 2B 00 00 00 EF 02 05 31 31 31 31 31 01 00 0A 00 01 00 E8 03 00 00 发送数据 
 
		/* 
	 
	  30 00 00 00 EF 02 07 33 34 32 33 34 32 33 03 00  
0A 00 F2 00 7A 00 00 00  
0B 00 16 00 01 00 00 00  
11 00 15 00 22 00 00 00 发送数据 
*/ 
		if (strcmp(object_info[n].shop_name, "\\") != 0) return; 
 
		if (lpTarget[6] > 13) return; 
 
		strcpy(name,""); 
 
		for(i=0;i7) return; 
 
		for(i=0;i<(int)lpTarget[7 + lpTarget[6]];i++) 
		{ 
			novelity = getuserNovelityinfo(n, lpTarget[a + 0]); 
 
			if (novelity.have) 
			{ 
				number = (int)lpTarget[a + 2] + lpTarget[a + 3] * 256; 
				if (number > novelity.number) return; 
 
				code[i][0] = lpTarget[a + 0]; 
				code[i][1] = lpTarget[a + 1]; 
				code[i][2] = lpTarget[a + 2]; 
				code[i][3] = lpTarget[a + 3]; 
				code[i][4] = lpTarget[a + 4]; 
				code[i][5] = lpTarget[a + 5]; 
				code[i][6] = lpTarget[a + 6]; 
				code[i][7] = lpTarget[a + 7]; 
			} 
			else 
			{ 
				//sysmessage(s, 0x01, "系统警告,含有非法数据", 0, FALSE); 
				return; 
			} 
 
			a+=8; 
		} 
 
		for(i=0;i<7;i++) 
		{ 
			for(j=0;j<8;j++) 
			{ 
				object_info[n].shop[i][j] = code[i][j]; 
			} 
		} 
 
		strcpy(object_info[n].shop_name, name); 
 
		object_info[n].playerstatus = 1; 
 
		sendshopcode1(s, 0x08); 
		openshopstatus(s, object_info[n].ServerID, name, 35, TRUE);	 
	} 
	else if (lpTarget[5] == 0x03) 
	{ 
		// 00 01 02 03 04 05 06 07 08 09 
		// 05 00 00 00 EF 03 22 28 00 00 
		id = (int)lpTarget[6] + (int)lpTarget[7] * 256; 
 
		index = find_id(id); 
 
		info = object_info[index];	 
	/*		sprintf(tmp1, "%d // %d - %d - %d - %d - %d - %d - %d - %d", 
					index, info.shop[i][0], info.shop[i][1], info.shop[i][2], info.shop[i][3], 
					info.shop[i][4], info.shop[i][5], info.shop[i][6], info.shop[i][7]); 
				MessageBoxA(NULL, tmp1, object_info[index].shop_name, 0); 
				*/ 
		if (index == MAX_NUM_USER) return; 
 
		if (strcmp(object_info[index].shop_name, "\\") == 0) return; 
 
		info = object_info[index];	 
 
		lookshop(s, 0x03, info); 
 
	} 
	else if (lpTarget[5] == 0x06) 
	{ 
		if (strcmp(object_info[n].shop_name, "\\") == 0) return; 
 
		info = object_info[n];	 
 
		lookshop(s, 0x0B, info); 
	} 
} 
 
void sendopenpshop_info(SOCKET s) 
{ 
	; 
} 
 
// 商店打开状态 
int openshopstatus(SOCKET s, int ServerID, char *name, int distance, BOOL broadcast) 
{ 
	// 00 01 02 03 04 05 06 07 08 09 10 
	// 6A 00 00 00 EF 09 22 28 00 00 05 31 31 31 31 31 
	BYTE lpSource[128]; 
 
	BYTE buf[2]; 
	int len, i, ret; 
 
	len = strlen(name); 
 
	memset(lpSource, 0x00, sizeof(lpSource)); 
 
	lpSource[0]  = 0x00; 
	lpSource[1]  = 0x00; 
	lpSource[2]  = 0x00; 
	lpSource[3]  = 0x00; 
	lpSource[4]  = 0xEF; 
	lpSource[5]  = 0x09; 
	Encode2(buf, ServerID); 
	lpSource[6]  = buf[1]; 
	lpSource[7]  = buf[0]; 
	lpSource[8]  = 0x00; 
	lpSource[9]  = 0x00; 
	lpSource[10] = len; 
	for(i=0;i