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

📄 citem.cpp

📁 国内著名网络游戏dragon的服务端完整源码 内附完整数据库结构
💻 CPP
📖 第 1 页 / 共 3 页
字号:
}





// *****************************************************************************************
// *****************************************************************************************
// *****************************************************************************************
//    Item 积己 
//	  Item 积己 
// *****************************************************************************************
// *****************************************************************************************
// *****************************************************************************************

int ItemGen_successrate( t_connection c[], int cn, int type, int tableno, int itemtype, int itemno )
{
	CHARLIST *ch;

	if( cn >= LOGIN_MAX_CONNECTIONS ) return 0;
	if( cn < 0 ) return 0;

	ch = &c[cn].chrlst;
	if( ch->bAlive != ALIVE_ ) return 0;
//----------------------------------------------------  Check Variables 裹困...
	return 100;
}

/*
#define IATTR_DURATION			0
#define IATTR_LIMIT				1	
#define IATTR_ATTR				2
#define IATTR_ID				3
#define IATTR_RESERVED0			4
#define IATTR_RESERVED1			5

#define IA2_HIDE			0x00000001
#define IA2_NOTMOVE			0x00000002
#define IA2_POISONED		0x00000004
#define IA2_OPENED			0x00000008
#define IA2_BROKEN			0x00000010
#define IA2_HOUSE			0x00000020
#define IA2_MAGIC			0x00000040
#define IA2_CANNOTUSE		0x00000080
#define IA2_NOIDENTIFIED	0x00000100
#define IA2_DOOR			0x00000200
#define IA2_BOX				0x00000400
#define IA2_CHAIR			0x00000800
#define IA2_TABLE			0x00001000


#define	PLANT			0
#define	MINERAL			1
#define	HERB			2
#define	COOK			3 
#define	POTION			4
#define	TOOL			5
#define	WEAPON			6
#define	DISPOSABLE		7
#define	ARMOR			8
#define	ACCESSORY		9
#define	ETC				10
#define MAP				11	
*/



unsigned int ItemGen_Duration( int type, int no )
{
	return 0;
}

unsigned int ItemGen_Limit( int type, int no )
{
	return 0;
}

unsigned int ItemGen_Attr( int type, int no )
{
	return 0;
}

unsigned int ItemGen_DbId( int type, int no )
{
	return 0;
}


#define GetAttr2( attr2, a )		((attr2) & (a))
#define SetAttr2( attr2, b )		{(attr2) |=(b);}




void RecvItemDoorOpenClose( int cn, t_item_door_open_close *p )
{
	LPITEMLIST i;
	int item_id = p->item_id;

	if( item_id < 0 ) return;
	if( item_id >= MAX_ITEM_LIST ) return;

	i = &ItemList[ item_id ];

	if( (i->attr[ IATTR_ATTR] & IA2_DOOR) == 0 ) return; // 巩捞 酒聪匙...

	if( p->openclose == 0 ) // 凯绢林技夸..
	{
		if( i->attr[ IATTR_ATTR] & IA2_OPENED ) return; // 凯妨 乐栏搁 府畔.
		//
		// 咯扁辑 connections[cn].chrslt啊  凯荐 乐绰瘤 八荤茄促.
		//
		i->attr[ IATTR_ATTR] |= IA2_OPENED;

		SetArea( CHANGE_IA2_ATTR_ITEM_AREA, item_id );
	}
	else // 摧酒林技夸.
	{
		if( (i->attr[ IATTR_ATTR] & IA2_OPENED) == 0 ) return; // 摧囚 乐栏搁 府畔.
		//
		// 咯扁辑 connections[cn].chrslt啊  摧阑荐 乐绰瘤 八荤茄促.
		//
		i->attr[ IATTR_ATTR] &= (~(IA2_OPENED) );

		SetArea( CHANGE_IA2_ATTR_ITEM_AREA, item_id );
	}
}


void SendItemAttrChange( t_connection c[], int cn, int id, int attr )
{	
	t_packet packet;
	
	packet.h.header.type = CMD_ITEM_ATTR_CHANGE;
	{
		packet.u.item_attr_change.item_id = id;	// ####
		packet.u.item_attr_change.array = attr;
		packet.u.item_attr_change.attr  = ItemList[id].attr[ attr];
	}
	packet.h.header.size = sizeof( item_attr_change );
	
	QueuePacket(c, cn, &packet, 1);
}	


void SendItemFoot_On_Trap0( t_connection c[], int cn, int item_id ) // ####
{	
}	
	
// 1209 KHS
void SendItemFoot_On_Trap1( t_connection c[], int cn, int item_id ) // ####
{	
}	
		
	
// 1207 KHS	
void CheckItemTimeElapsed( void )
{	
	static DWORD time;
	static int count;
	int s,e;

	
	if( g_curr_time < time )  return;
	time = g_curr_time + 3;
	
	if( count >= MAX_ITEM_LIST ) count = 0;
	s = count;
	count += ( MAX_ITEM_LIST/ 10 );
	e = count;
	if( e >= MAX_ITEM_LIST ) e = MAX_ITEM_LIST;		// 茄锅俊 MAX_ITEM_LIST/3沥档父 Check茄促. 辑滚 何淬阑 临捞扁 困秦.
	
	for( int m = s ; m < e ; m ++)
	{
		if( ItemList[m].bAlive == 0 ) continue;
	
		unsigned int attr2 = ItemList[m].attr[ IATTR_ATTR];
		if( (attr2 & IA2_BOX) | (attr2 & IA2_DOOR) )
		{
			if( GetAttr2( attr2, IA2_BOX ) && GetAttr2( attr2, IA2_OPENED ) ) 
			{
				if( time > ItemList[m].attr[ IATTR_LIMIT] ) // 柄柳第 倔付埃狼 矫埃捞 瘤车促. 
				{
					ItemList[m].attr[ IATTR_ATTR] = IA2_BOX;
					SetArea( CHANGE_IA2_ATTR_ITEM_AREA, m );
					continue;
				}
			}
		}
	
		if( attr2 & IA2_FARM0 )
		{
			if( ItemList[m].attr[IATTR_DURATION] < g_curr_time )
			{
				ItemList[m].attr[IATTR_ATTR ] &= ~(IA2_FARM0);
				ItemList[m].attr[IATTR_ATTR ] |= IA2_FARM1;
				ItemList[m].attr[IATTR_DURATION ] = g_curr_time + 60;
				SetArea( CHANGE_IA2_ATTR_ITEM_AREA, m );
				SetArea( CHANGE_IA2_DURATION_ITEM_AREA, m );
			}
		}

		if( attr2 & IA2_FARM1 )
		{
			if( ItemList[m].attr[IATTR_DURATION] < g_curr_time )
			{
				ItemList[m].attr[IATTR_ATTR ] &= ~(IA2_FARM1);
				ItemList[m].attr[IATTR_ATTR ] |= IA2_FARM2;
				ItemList[m].attr[IATTR_DURATION ] = g_curr_time + 60;
				SetArea( CHANGE_IA2_ATTR_ITEM_AREA, m );
				SetArea( CHANGE_IA2_DURATION_ITEM_AREA, m );
			}
		}

		if( attr2 & IA2_FARM2 )
		{
			if( ItemList[m].attr[IATTR_DURATION] < g_curr_time )
			{
				ItemList[m].attr[IATTR_ATTR ] &= ~(IA2_FARM2);
				ItemList[m].attr[IATTR_ATTR ] |= IA2_FARM3;
				ItemList[m].attr[IATTR_DURATION ] = g_curr_time + 60;
				SetArea( CHANGE_IA2_ATTR_ITEM_AREA, m );
				SetArea( CHANGE_IA2_DURATION_ITEM_AREA, m );
			}
		}

		if( attr2 & IA2_FARM2 )
		{
			if( ItemList[m].attr[IATTR_DURATION] < g_curr_time )
			{
				ItemList[m].attr[IATTR_ATTR ] &= ~(IA2_FARM2);
				ItemList[m].attr[IATTR_ATTR ] |= IA2_FARM3;
				ItemList[m].attr[IATTR_DURATION ] = g_curr_time + 60;
				SetArea( CHANGE_IA2_ATTR_ITEM_AREA, m );
				SetArea( CHANGE_IA2_DURATION_ITEM_AREA, m );
			}
		}

		if( attr2 & IA2_FARM3 )
		{
			if( ItemList[m].attr[IATTR_DURATION] < g_curr_time )
			{
				ItemList[m].attr[IATTR_ATTR ] &= ~(IA2_FARM3);
				ItemList[m].attr[IATTR_ATTR ] |= IA2_FARM4;
				ItemList[m].attr[IATTR_DURATION ] = g_curr_time + 60;
				SetArea( CHANGE_IA2_ATTR_ITEM_AREA, m );
				SetArea( CHANGE_IA2_DURATION_ITEM_AREA, m );
			}
		}


		if( attr2 & IA2_FIRE )
		{
			if( ItemList[m].attr[IATTR_DURATION] < g_curr_time )
			{
				ItemList[m].bAlive = REMOVE_;
				SetArea( REMOVE_ITEM_AREA, m );
			}
		}
	}
}





//-----------------------------------------------------------------------
// 酒捞袍 积己 窃荐 ( 10/24 )
//-----------------------------------------------------------------------
/*
DWORD ItemAttr_Make_First( int type, int itemno, int success_rate )
{
	switch( type )
	{
		case	PLANT			:	return global_time + (21600 * 60);
		case	MINERAL			:
		case	HERB			:	
		case	COOK			:	return global_time + (21600 * 60);
		case	POTION			:
		case	TOOL			:	
		case	WEAPON			:
		case	DISPOSABLE		:
		case	ARMOR			:
		case	ACCESSORY		:
		case	ETC				:
		break;
	}
	return 0L;
}
*/



//////////////////////////////////////////////////////////////////////////
// 某腐磐 牢亥配府俊辑 后镑 茫扁, 绝栏搁 0阑 府畔

int SearchInv( ItemAttr inv[3][3][8], int &a, int &b, int &c )
{
	for( a=0; a<3; a++)
	for( b=0; b<3; b++)
	for( c=0; c<8; c++)
	{
		if( !inv[a][b][c].item_no )
			return 1;
	}

	return 0;	
}

int SearchInv_invert( ItemAttr inv[3][3][8], int &a, int &b, int &c )
{
	for( a=2; a >=0; a--)
	for( b=2; a >=0; b--)
	for( c=7; c >=0; c--)
	{
		if( !inv[a][b][c].item_no )
			return 1;
	}

	return 0;	
}

/////////////////////////////////// //0101 //////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//	酒捞袍 锅龋客 鸥涝捞 倾侩等 蔼阑 逞菌绰瘤甫 魄窜窍绰 窃荐
//
//		颇扼皋磐绰 鸥涝苞 锅龋甫 涝仿 罐绊
//		器牢磐肺 府畔茄促.	肋 给 灯阑 版快 NULL府畔
//
////////////////////////////////////////////////////////////////////////////////
void getItemIndex(int item_no, int &type, int &index)		// 0415_2	// 困摹甫 官厕
{
	type= item_no / 1000 ;
	index= item_no % 1000 ;
}

CItem *ItemUnit( ItemAttr item )		// 0415_2
{
	int type, num;
	getItemIndex( item.item_no, type, num );
	return ItemUnit( type, num );
}

CItem *ItemUnit( int item_no )
{
	return ItemUnit( item_no/1000, item_no%1000);
}

CItem *ItemUnit( int type, int item_no )
{
	if( (type<0) || (type>10) ) return NULL;
	if( (item_no<=0) || (item_no > Item_Ref.nItem[type]) ) return NULL;

	switch( type )
	{
		case 	PLANT		:	return &CPlant		[item_no];	break;
		case 	MINERAL		:	return &CMineral	[item_no];	break;
		case 	HERB		:	return &CHerb		[item_no];	break;
		case 	COOK		:	return &CCook		[item_no];	break;
		case 	POTION		:	return &CPotion		[item_no];	break;
		case 	TOOL		:	return &CTool		[item_no];	break;
		case 	WEAPON		:	return &CWeapon		[item_no];	break;
		case 	DISPOSABLE	:	return &CDisposable	[item_no];	break;
		case 	ARMOR		:	return &CArmor		[item_no];	break;
		case 	ACCESSORY	:	return &CAccessory	[item_no];	break;
		case 	ETC			:	return &CEtc		[item_no];	break;
	}
	return NULL;
//	return Item_Ref.Item_Info[type][item_no];
}



///////////////////////////////////////////////
// 厘馒 捞固瘤甫 啊廉柯促
/////////////////////////////////////////////////
int GetItemView( int item_no, int is_man )
{
	CItem *t;
	int type, num;
	getItemIndex( item_no, type, num );
	
	t = ItemUnit( type, num );
	if( !t ) return 0;
	else return t->GetItemShow( is_man );
}

ItemAttr GenerateItem( const int item_no, DWORD dur)
{
	ItemAttr item = {0, };
	CItem *t = ItemUnit( item_no );
	if( !t ) {return item;}
	if(!t->GetItemImage() || !t->GetObjectNumber()){return item;}//坷宏璃飘 捞固瘤 逞滚 绝栏搁 瘤况咙

	item.item_no = item_no;
	
	if( !dur ) 
	{
		item.attr[IATTR_DURATION] = CreateItemDuration( item_no/1000 , item_no%1000 );
	}
	else
	{
		if( t->GetRbutton() == DIVIDE_ITEM ) 
		{
			item.attr[IATTR_DURATION] = dur;
		}
		else 
		{
			item.attr[IATTR_DURATION] = MAKELONG( dur, dur );
		}
	}
	item.attr[IATTR_LIMIT] = g_curr_time;

	return item;
}

SItemchange itemchange[MAX_CHANGE_ITEM_COUNT];//010708 lsw
int ichangeItemCount=0;
int LoadChangeItem()//010708 lsw
{
	HSTMT		hStmt = NULL;
	RETCODE		retCode;
	SDWORD		cbValue;

	SQLAllocStmt(hDBC, &hStmt);
	retCode = SQLExecDirect(hStmt, (UCHAR *)"Select * from item_change order by original", SQL_NTS);
	if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
	{		
		int i = 0;
		retCode = SQLFetch(hStmt);
		while( retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
		{
			if(i >= MAX_CHANGE_ITEM_COUNT)//020730 lsw
			{
				SQLFreeStmt(hStmt, SQL_DROP);
				return 0;
			}

			retCode = SQLGetData(hStmt, 1, SQL_C_LONG,	&itemchange[i].origin_item_no		, 0, &cbValue);
			retCode = SQLGetData(hStmt, 2, SQL_C_LONG,	&itemchange[i].will_change_item_no	, 0, &cbValue);
			retCode = SQLGetData(hStmt, 3, SQL_C_LONG,	&itemchange[i].add_soksung			, 0, &cbValue);
			retCode = SQLGetData(hStmt, 4, SQL_C_LONG,	&itemchange[i].add_grade			, 0, &cbValue);
			
			ichangeItemCount=i;			
			i++;

			retCode = SQLFetch(hStmt);
			if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
			{
			}
			else if( retCode == SQL_NO_DATA ) 
			{
				break;
			}
			else
			{
				SQLFreeStmt(hStmt, SQL_DROP);
				return 0;
			}
		}	
	}		


	SQLFreeStmt(hStmt, SQL_DROP);		// 0308 YGI
	return(1);
}




⌨️ 快捷键说明

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