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

📄 mysql.cpp

📁 国内著名网络游戏dragon的服务端完整源码 内附完整数据库结构
💻 CPP
📖 第 1 页 / 共 5 页
字号:
int InitSkillMapTable( void )
{
	HSTMT hStmt= NULL ;
	RETCODE ret ;
	SDWORD cbValue ;
	int c;
	
	SQLAllocStmt(hDBC, &hStmt);
	ret= SQLExecDirect(hStmt, (UCHAR *)"select * from SkillMapTable order by No", SQL_NTS) ;
	
	if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
		MyLog( LOG_NORMAL, "'SkillMapTable' : ExecDirect Error ") ;
		SQLFreeStmt(hStmt, SQL_DROP);
		return -1 ;
	}	
	
	//SQLNumResultCols(hStmt, &nCols) ;
	ret= SQLFetch(hStmt) ;
	if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) 
	{
		MyLog( LOG_NORMAL, "'SkillMapTable' : Fetch Error ") ;
		return -1 ;
	}	
	
	int tno;
	
	c = 0;
	while(c < MAX_SKILLMAPTABLE && ret == SQL_SUCCESS)
	{	
		ret = SQLGetData(hStmt,  1, SQL_C_LONG,	&tno							,   0, &cbValue);
		SkillMapTable[tno].NO = tno;
		//< CSD-030324
		// thai2 YGI
		//ret = SQLGetData(hStmt,  2, SQL_C_CHAR,	SkillMapTable[tno].han_name		,  30, &cbValue);
		//EatRearWhiteChar( SkillMapTable[tno].han_name );
		//> CSD-030324
		ret = SQLGetData(hStmt,  3, SQL_C_LONG,	&SkillMapTable[tno].Item_id		,	0, &cbValue);
		ret = SQLGetData(hStmt,  4, SQL_C_LONG,	&SkillMapTable[tno].Skill_type	,	0, &cbValue);
		ret = SQLGetData(hStmt,  5, SQL_C_LONG,	&SkillMapTable[tno].demand		,	0, &cbValue);
		ret = SQLGetData(hStmt,  6, SQL_C_LONG,	&SkillMapTable[tno].table[0]	,	0, &cbValue);
		ret = SQLGetData(hStmt,  7, SQL_C_LONG,	&SkillMapTable[tno].table[1]	,	0, &cbValue);
		ret = SQLGetData(hStmt,  8, SQL_C_LONG,	&SkillMapTable[tno].table[2]	,	0, &cbValue);
		ret = SQLGetData(hStmt,  9, SQL_C_LONG,	&SkillMapTable[tno].table[3]	,	0, &cbValue);
		ret = SQLGetData(hStmt, 10, SQL_C_LONG,	&SkillMapTable[tno].table[4]	,	0, &cbValue);
		ret = SQLGetData(hStmt, 11, SQL_C_LONG,	&SkillMapTable[tno].table[5]	,	0, &cbValue);
		ret = SQLGetData(hStmt, 12, SQL_C_LONG,	&SkillMapTable[tno].table[6]	,	0, &cbValue);
		ret = SQLGetData(hStmt, 13, SQL_C_LONG,	&SkillMapTable[tno].table[7]	,	0, &cbValue);
		ret = SQLGetData(hStmt, 14, SQL_C_LONG,	&SkillMapTable[tno].table[8]	,	0, &cbValue);
		ret = SQLGetData(hStmt, 15, SQL_C_LONG,	&SkillMapTable[tno].table[9]	,	0, &cbValue);
		ret = SQLGetData(hStmt, 16, SQL_C_LONG,	&SkillMapTable[tno].table[10]	,	0, &cbValue);
		
		//011014 lsw >
		ret = SQLGetData(hStmt, 17, SQL_C_LONG,	&SkillMapTable[tno].new_item[0]	,	0, &cbValue);
		ret = SQLGetData(hStmt, 18, SQL_C_LONG,	&SkillMapTable[tno].new_item_pro[0]	,	0, &cbValue);
		ret = SQLGetData(hStmt, 19, SQL_C_LONG,	&SkillMapTable[tno].new_item[1]	,	0, &cbValue);
		ret = SQLGetData(hStmt, 20, SQL_C_LONG,	&SkillMapTable[tno].new_item_pro[1]	,	0, &cbValue);
		ret = SQLGetData(hStmt, 21, SQL_C_LONG,	&SkillMapTable[tno].new_item[2]	,	0, &cbValue);
		ret = SQLGetData(hStmt, 22, SQL_C_LONG,	&SkillMapTable[tno].new_item_pro[2]	,	0, &cbValue);
		//011014 lsw <
		
		
		if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) { MyLog( LOG_NORMAL, "'SkillMapTable' : Error!!! (%d)", ret) ; return -1 ;}
		c++ ;
		ret= SQLFetch(hStmt) ;
	}	
	
	SQLFreeStmt(hStmt, SQL_DROP) ;
	
	MyLog( LOG_NORMAL, "	.SkillMapTable		%4d data Loaded", c) ;
	
	SkillMapTableCount = c;
	
	return c ;
}								


char * GetMessageBBS_public( int count )			// 0306 YGI
{		
	SDWORD		cbValue;
	HSTMT		hStmt = NULL;
	RETCODE		retCode;
	char		szQuerry[128];
	int			len;
	char		*msg=NULL;
	
	sprintf( szQuerry, "SELECT DataLength(con), con FROM bbs WHERE no = %d", count );
	SQLAllocStmt(hDBC, &hStmt);
	
	retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
	if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
	{	
		retCode = SQLFetch( hStmt );
		retCode = SQLGetData(hStmt, 1, SQL_C_ULONG, &len, 0, &cbValue);
		if( !len ) 
		{
			SQLFreeStmt(hStmt, SQL_DROP);
			return msg;
		}
		msg = new char[len+1];
		memset( msg, 0, len+1 );
		retCode = SQLGetData(hStmt, 2, SQL_C_CHAR, msg, len+1, &cbValue);
		SQLFreeStmt(hStmt, SQL_DROP);
		
		return msg;
	}
	SQLFreeStmt(hStmt, SQL_DROP);		// 0308 YGI
	return msg;
}		






int GetBelieveAndFaith_SQL( int &believe, int &faith, char *name )		// 0405 YGI
{	
	HSTMT		hStmt = NULL;
	RETCODE		retCode;
	SDWORD		cbValue;
	char		szQuerry[255];
	
	sprintf(szQuerry, "select believe_god , faith from chr_info2 where name='%s'", name );		// 0414 YGI
	SQLAllocStmt(hDBC, &hStmt);
	retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
	if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
	{	
		retCode = SQLFetch(hStmt);
		
		retCode = SQLGetData(hStmt, 1, SQL_C_ULONG, &believe,	0, &cbValue);
		retCode = SQLGetData(hStmt, 2, SQL_C_ULONG, &faith,		0, &cbValue);
	}		
	else 
	{
		SQLFreeStmt(hStmt, SQL_DROP);
		return 0;
	}
	SQLFreeStmt(hStmt, SQL_DROP);
	return 1;
}

int UpdateFaith_SQL( short int faith, char *name )		// 0405 YGI
{	
	HSTMT		hStmt = NULL;
	RETCODE		retCode;
	char		szQuerry[255];
	
	sprintf(szQuerry, "Update chr_info2 SET faith = %d where name='%s'", faith, name );
	SQLAllocStmt(hDBC, &hStmt);
	retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
	SQLFreeStmt(hStmt, SQL_DROP);
	
	if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO) return 1;
	else return 0;
}

int UpdateEvaName( char *my_name, char *eva_name )		// 傈档茄 荤恩 捞抚阑 叼厚俊 诀单捞飘 茄促. // 0405 YGI
{
	HSTMT		hStmt = NULL;
	RETCODE		retCode;
	char		szQuerry[255];
	
	sprintf(szQuerry, "Update chr_info SET evangelist = '%s' where name='%s'", eva_name, my_name );
	SQLAllocStmt(hDBC, &hStmt);
	retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
	SQLFreeStmt(hStmt, SQL_DROP);
	
	if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO) return 1;
	else return 0;
}

int GetEvangelist( char *my_name, char *eva_name )		// 唱甫 傈档茄 荤恩 捞抚 啊廉坷扁
{
	SDWORD		cbValue;
	HSTMT		hStmt = NULL;
	RETCODE		retCode;
	char		szQuerry[128];
	
	sprintf( szQuerry, "select evangelist from chr_info where name = '%s'", my_name);
	
	SQLAllocStmt(hDBC, &hStmt);
	retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
	if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
	{	
		retCode = SQLFetch( hStmt );
		retCode = SQLGetData(hStmt, 1, SQL_C_CHAR,	eva_name, 0, &cbValue);
		
		if(retCode == SQL_SUCCESS)
		{
			SQLFreeStmt(hStmt, SQL_DROP);
			return (1);
		}
		else 
		{
			SQLFreeStmt(hStmt, SQL_DROP);		// 0308 YGI
			return( 0 );
		}
	}
	SQLFreeStmt(hStmt, SQL_DROP);		// 0308 YGI
	return 1;
}

void SubtractFaith( char *name )		// 昏力甫 且 版快 磊扁甫 傈档茄 荤恩狼 脚居缴阑 憋绰促.
{
	char eva_name[20] = {0, };
	if( GetEvangelist( name, eva_name ) )
	{
		if( eva_name[0] )
		{
			int believe, faith;
			GetBelieveAndFaith_SQL( believe, faith, eva_name );
			faith -= 10;
			if( faith < 0 ) faith = 0;
			UpdateFaith_SQL( (short int )faith, eva_name );
		}
	}
}


//// 0405 YGI
int GetGodFood_SQL( int &god_food, DWORD &god_food_date, char *name )
{
	SDWORD		cbValue;
	HSTMT		hStmt = NULL;
	RETCODE		retCode;
	char		szQuerry[128];
	char		date[10];
	
	sprintf( szQuerry, "SELECT god_food, god_food_date FROM chr_info2 WHERE name = '%s'", name);
	
	SQLAllocStmt(hDBC, &hStmt);
	retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
	if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
	{	
		retCode = SQLFetch( hStmt );
		retCode = SQLGetData(hStmt, 1, SQL_C_ULONG,	&god_food, 0, &cbValue);
		retCode = SQLGetData(hStmt, 2, SQL_C_CHAR,	date, 9, &cbValue); god_food_date = (DWORD) atof( date );
		
		if(retCode == SQL_SUCCESS)
		{
			SQLFreeStmt(hStmt, SQL_DROP);
			return (1);
		}
		else 
		{
			SQLFreeStmt(hStmt, SQL_DROP);		
			return( 0 );
		}
	}
	SQLFreeStmt(hStmt, SQL_DROP);	
	return 1;
}



char *GodIndex2Name[] = { "EDELBLHOY", "TEFFERY", "LETTY", };	// 0410 YGI		俊胆宏肺捞, 抛其府, 弊尔郡海福, 蜡乔弛, 饭萍, 秋墨匙胶, 拳坊瞒
int GetGodMeetingTime( TIMESTAMP_STRUCT &day, TIMESTAMP_STRUCT &month, TIMESTAMP_STRUCT &year, int god_index )
{		
	SDWORD		cbValue;
	HSTMT		hStmt = NULL;
	RETCODE		retCode;
	char		szQuerry[128];
	DWORD		bbs_count=0;
	
	// char *index2name[] = { "EDELBLHOY", };			// 0410 YGI
	
	sprintf( szQuerry, "SELECT day_time, month_time, year_time FROM god_meeting_time WHERE god_name = '%s'", GodIndex2Name[god_index-1] );
	SQLAllocStmt(hDBC, &hStmt);
	retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
	if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
	{	
		retCode = SQLFetch( hStmt );
		
		retCode = SQLGetData(hStmt, 1, SQL_C_TIMESTAMP,	&day,	sizeof( TIMESTAMP_STRUCT ), &cbValue);
		retCode = SQLGetData(hStmt, 2, SQL_C_TIMESTAMP,	&month, sizeof( TIMESTAMP_STRUCT ), &cbValue);
		retCode = SQLGetData(hStmt, 3, SQL_C_TIMESTAMP,	&year,  sizeof( TIMESTAMP_STRUCT ), &cbValue);
	}
	
	if(retCode == SQL_SUCCESS)
	{
		SQLFreeStmt(hStmt, SQL_DROP);
		return ( 1 );
	}
	else 
	{
		SQLFreeStmt(hStmt, SQL_DROP);
		return( 0 );
	}
}

int GetMeetingMessage( int god_type, int text_type, int text_num, char *msg )
{		
	SDWORD		cbValue;
	HSTMT		hStmt = NULL;
	RETCODE		retCode;
	char		szQuerry[128];
	
	char		text_field[20];
	
	switch( text_type )
	{
	case 300/*YEAR_MEETING */:		sprintf( text_field, "year_text%d", text_num ); break;
	case 200/*MONTH_MEETING */:		sprintf( text_field, "month_text%d", text_num ); break;
	case 100/*DAY_MEETING */:		sprintf( text_field, "day_text%d", text_num ); break;
	default : return NULL;
	}
	
	sprintf( szQuerry, "SELECT %s FROM god_meeting_time WHERE god_name = '%s'", text_field,text_field, GodIndex2Name[god_type-1] );
	SQLAllocStmt(hDBC, &hStmt);
	
	retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
	if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
	{	
		retCode = SQLFetch( hStmt );
		retCode = SQLGetData(hStmt, 1, SQL_C_CHAR, msg, MAX_GOD_TEXT, &cbValue);
		msg[MAX_GOD_TEXT-1] = 0;
		EatRearWhiteChar( msg );
		SQLFreeStmt(hStmt, SQL_DROP);
		return 1;
	}
	SQLFreeStmt(hStmt, SQL_DROP);
	return 0;
}		

int UpdateCharStatusByKein( t_connection c[], short int cn )		// 0410 YGI
{
	CHARLIST *ch = &c[cn].chrlst;
	if( !ch ) return 0; 
	
	k_char_update_data p;
	
	p.believe_god		= ch->believe_god;
	p.faith				= ch->faith;
	p.god_cast_level	= ch->god_cast_level;
	sprintf( p.name, "%s", ch->Name );
	
	return ( UpdateCharStatusByKein( &p ) );
}

int UpdateCharStatusByKein( k_char_update_data *ch )		// 0410 YGI
{
	HSTMT		hStmt = NULL;
	RETCODE		retCode;
	char		szQuerry[255];
	
	
	sprintf(szQuerry, "UPDATE chr_info2 SET god_cast_level=%d, believ

⌨️ 快捷键说明

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