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

📄 citem.cpp

📁 国内著名网络游戏dragon的服务端完整源码 内附完整数据库结构
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		ret= SQLGetData(hStmt, 2, SQL_C_CHAR, &CPotion[c].Name, sizeof(Name), &cbValue) ;
		ret= SQLGetData(hStmt, 3, SQL_C_CHAR, &CPotion[c].Han_Name, sizeof(Han_Name), &cbValue) ;
		EatRearWhiteChar(CPotion[c].Han_Name );
		if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
			printf("\nString GET Error!!! (%d)", ret) ;
			return -1 ;
		}

//		tmp+= 5 ;
		tmp = &CPotion[c].lv;
		for(i=4; i <= nCols; i++) {
			ret= SQLGetData(hStmt, i, SQL_C_SLONG, tmp, sizeof(int), &cbValue) ;
			//fprintf(stdout, "\n [%3d][%8x] %d", i, tmp, *tmp) ;
			tmp++ ;
		}
		c++ ;
		
		ret= SQLFetch(hStmt) ;
		m_Much  = 0;
	}
//	printf("\n<<<<<< %d Cols.>>>>>>>>", nCols) ;
//	printf("\n<<<<<< %d Rows.>>>>>>>>", c) ;
	SQLFreeStmt(hStmt, SQL_DROP) ;
//	printf("       Item_Potion    (%3d:%3d) reading process complete.\r\n", c, nCols ) ;
	return c ;
}


int CItem_Tool::getAllData(void)
{
	if(Num_Of_CItem_Tool <= 0) {
		//fprintf(stdout, "\n	No item's available ") ;
		return -4 ; // No item's available
	}
	HSTMT hStmt= NULL ;
	RETCODE ret ;
	SWORD nCols ;
	char query_stmt[80]= {0, } ;
	SDWORD cbValue ;
	int *tmp ;
	int c= 1, i ;
	SQLAllocStmt(hDBC, &hStmt);
	
	strcpy(query_stmt, "select * from Item_Tool order by item_id") ;
	ret= SQLExecDirect(hStmt, (UCHAR *)query_stmt, SQL_NTS) ;

	if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
		printf("\nItem Tool: ExecDirect Error ") ;
		return -1 ;
	}

	SQLNumResultCols(hStmt, &nCols) ;
	
	ret= SQLFetch(hStmt) ;
	if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
		LPVOID lpMsgBuf;
		FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
			FORMAT_MESSAGE_IGNORE_INSERTS,    NULL,
			GetLastError(),
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
			(LPTSTR) &lpMsgBuf,    0,    NULL );// Process any inserts in lpMsgBuf.
		// ...// Display the string.
		printf("\nLast Error: %s", (LPCTSTR)lpMsgBuf) ;
		// Free the buffer.
		LocalFree( lpMsgBuf );
		printf("\nItem7: Fetch Error ") ;
		return -1 ;
	}
		
	while( ret == SQL_SUCCESS)
	{
		// Accquire the DATA
		ret= SQLGetData(hStmt, 1, SQL_C_SLONG, &c, sizeof(int), &cbValue) ;
		if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
			printf("\nError!!! (%d)", ret) ;
			return -1 ;
		}
		CTool[c].Item_id = c;
		ret= SQLGetData(hStmt, 2, SQL_C_CHAR, &CTool[c].Name, sizeof(Name), &cbValue) ;
		ret= SQLGetData(hStmt, 3, SQL_C_CHAR, &CTool[c].Han_Name, sizeof(Han_Name), &cbValue) ;
		EatRearWhiteChar( CTool[c].Han_Name );
		if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
			printf("\nString GET Error!!! (%d)", ret) ;
			return -1 ;
		}

//		tmp+= 5 ;
		tmp = &CTool[c].lv;
		for(i=4; i <= nCols; i++) {
			ret= SQLGetData(hStmt, i, SQL_C_SLONG, tmp, sizeof(int), &cbValue) ;
			//fprintf(stdout, "\n [%3d][%8x] %d", i, tmp, *tmp) ;
			tmp++ ;
		}
		c++ ;
		
		ret= SQLFetch(hStmt) ;
		m_Much  = 0;
	}
//	printf("\n<<<<<< %d Cols.>>>>>>>>", nCols) ;
//	printf("\n<<<<<< %d Rows.>>>>>>>>", c) ;
	SQLFreeStmt(hStmt, SQL_DROP) ;
//	printf("       Item_Tool      (%3d:%3d) reading process complete.\r\n", c, nCols ) ;
	return c ;
}

int CItem_Weapon::getAllData(void)
{
	if(Num_Of_CItem_Weapon <= 0) {
		//fprintf(stdout, "\n	No item's available ") ;
		return -4 ; // No item's available
	}
	HSTMT hStmt= NULL ;
	RETCODE ret ;
	SWORD nCols ;
	char query_stmt[80]= {0, } ;
	SDWORD cbValue ;
	int *tmp ;
	int c= 1, i ;
	SQLAllocStmt(hDBC, &hStmt);
	
	strcpy(query_stmt, "select * from Item_Weapon order by item_id") ;
	ret= SQLExecDirect(hStmt, (UCHAR *)query_stmt, SQL_NTS) ;

	if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
		printf("\nItem Weapon: ExecDirect Error ") ;
		return -1 ;
	}

	SQLNumResultCols(hStmt, &nCols) ;
	
	ret= SQLFetch(hStmt) ;
	if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
		LPVOID lpMsgBuf;
		FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
			FORMAT_MESSAGE_IGNORE_INSERTS,    NULL,
			GetLastError(),
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
			(LPTSTR) &lpMsgBuf,    0,    NULL );// Process any inserts in lpMsgBuf.
		// ...// Display the string.
		printf("\nLast Error: %s", (LPCTSTR)lpMsgBuf) ;
		// Free the buffer.
		LocalFree( lpMsgBuf );
		printf("\nItem7: Fetch Error ") ;
		return -1 ;
	}
		
	while(ret == SQL_SUCCESS)
	{
		// Accquire the DATA
		ret= SQLGetData(hStmt, 1, SQL_C_SLONG, &c, sizeof(int), &cbValue) ;
		if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
			printf("\nError!!! (%d)", ret) ;
			return -1 ;
		}
		CWeapon[c].Item_id = c;
		ret= SQLGetData(hStmt, 2, SQL_C_CHAR, &CWeapon[c].Name, sizeof(Name), &cbValue) ;
		ret= SQLGetData(hStmt, 3, SQL_C_CHAR, &CWeapon[c].Han_Name, sizeof(Han_Name), &cbValue) ;
		EatRearWhiteChar( CWeapon[c].Han_Name );
		if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
			printf("\nString GET Error!!! (%d)", ret) ;
			return -1 ;
		}

//		tmp+= 5 ;
		tmp = &CWeapon[c].lv;
		for(i=4; i <= nCols; i++) {
			ret= SQLGetData(hStmt, i, SQL_C_SLONG, tmp, sizeof(int), &cbValue) ;
			//fprintf(stdout, "\n [%3d][%8x] %d", i, tmp, *tmp) ;
			tmp++ ;
		}
		c++ ;
		
		ret= SQLFetch(hStmt) ;
		m_Much  = 0;
	}
//	printf("\n<<<<<< %d Cols. %d Rows", nCols, c) ;
	SQLFreeStmt(hStmt, SQL_DROP) ;
//	printf("       Item_Weapon    (%3d:%3d) reading process complete.\r\n", c, nCols ) ;
	return c ;
}




int CItem_Disposable::getAllData(void)
{
	if(Num_Of_CItem_Disposable <= 0) {
		//fprintf(stdout, "\n	No item's available ") ;
		return -4 ; // No item's available
	}
	HSTMT hStmt= NULL ;
	RETCODE ret ;
	SWORD nCols ;
	char query_stmt[80]= {0, } ;
	SDWORD cbValue ;
	int *tmp ;
	int c= 1, i ;
	SQLAllocStmt(hDBC, &hStmt);
	
	strcpy(query_stmt, "select * from Item_Disposable order by item_id") ;
	ret= SQLExecDirect(hStmt, (UCHAR *)query_stmt, SQL_NTS) ;

	if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
		printf("\nItem Disposable: ExecDirect Error ") ;
		return -1 ;
	}

	SQLNumResultCols(hStmt, &nCols) ;
	
	ret= SQLFetch(hStmt) ;
	if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
		LPVOID lpMsgBuf;
		FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
			FORMAT_MESSAGE_IGNORE_INSERTS,    NULL,
			GetLastError(),
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
			(LPTSTR) &lpMsgBuf,    0,    NULL );// Process any inserts in lpMsgBuf.
		// ...// Display the string.
		printf("\nLast Error: %s", (LPCTSTR)lpMsgBuf) ;
		// Free the buffer.
		LocalFree( lpMsgBuf );
		printf("\nItem7: Fetch Error ") ;
		return -1 ;
	}
		
	while(ret == SQL_SUCCESS)
	{
		// Accquire the DATA
		ret= SQLGetData(hStmt, 1, SQL_C_SLONG, &c, sizeof(int), &cbValue) ;
		if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
			printf("\nError!!! (%d)", ret) ;
			return -1 ;
		}
		CDisposable[c].Item_id = c;
		ret= SQLGetData(hStmt, 2, SQL_C_CHAR, &CDisposable[c].Name, sizeof(Name), &cbValue) ;
		ret= SQLGetData(hStmt, 3, SQL_C_CHAR, &CDisposable[c].Han_Name, sizeof(Han_Name), &cbValue) ;
		EatRearWhiteChar( CDisposable[c].Han_Name );
		if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
			printf("\nString GET Error!!! (%d)", ret) ;
			return -1 ;
		}

		tmp = &CDisposable[c].lv;
		for(i=4; i <= nCols; i++) {
			ret= SQLGetData(hStmt, i, SQL_C_SLONG, tmp, sizeof(int), &cbValue) ;
			//fprintf(stdout, "\n [%3d][%8x] %d", i, tmp, *tmp) ;
			tmp++ ;
		}
		c++ ;
		
		ret= SQLFetch(hStmt) ;
		m_Much  = 0;
	}
//	printf("\n<<<<<< %d Cols.>>>>>>>>", nCols) ;
//	printf("\n<<<<<< %d Rows.>>>>>>>>", c) ;
	SQLFreeStmt(hStmt, SQL_DROP) ;
//	printf("       Item_Disposable(%3d:%3d) reading process complete.\r\n", c, nCols ) ;
	return c ;
}

int CItem_Armor::getAllData(void)
{
	if(Num_Of_CItem_Armor <= 0) {
		//fprintf(stdout, "\n	No item's available ") ;
		return -4 ; // No item's available
	}
	HSTMT hStmt= NULL ;
	RETCODE ret ;
	SWORD nCols ;
	char query_stmt[80]= {0, } ;
	SDWORD cbValue ;
	int *tmp ;
	int c= 1, i ;
	SQLAllocStmt(hDBC, &hStmt);
	
	strcpy(query_stmt, "select * from Item_Armor order by item_id") ;
	ret= SQLExecDirect(hStmt, (UCHAR *)query_stmt, SQL_NTS) ;

	if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
		printf("\nItem Armor: ExecDirect Error ") ;
		return -1 ;
	}

	SQLNumResultCols(hStmt, &nCols) ;
	
	ret= SQLFetch(hStmt) ;
	if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) 
	{
		LPVOID lpMsgBuf;
		FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
			FORMAT_MESSAGE_IGNORE_INSERTS,    NULL,
			GetLastError(),
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
			(LPTSTR) &lpMsgBuf,    0,    NULL );// Process any inserts in lpMsgBuf.
		// ...// Display the string.
		printf("\nLast Error: %s", (LPCTSTR)lpMsgBuf) ;
		// Free the buffer.
		LocalFree( lpMsgBuf );
		printf("\nItem7: Fetch Error ") ;
		return -1 ;
	}
		
	while(ret == SQL_SUCCESS)
	{
		// Accquire the DATA
		ret= SQLGetData(hStmt, 1, SQL_C_SLONG, &c, sizeof(int), &cbValue) ;
		if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
			printf("\nError!!! (%d)", ret) ;
			return -1 ;
		}
		CArmor[c].Item_id = c;
		ret= SQLGetData(hStmt, 2, SQL_C_CHAR, &CArmor[c].Name, sizeof(Name), &cbValue) ;
		ret= SQLGetData(hStmt, 3, SQL_C_CHAR, &CArmor[c].Han_Name, sizeof(Han_Name), &cbValue) ;
		EatRearWhiteChar( CArmor[c].Han_Name );
		if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
			printf("\nString GET Error!!! (%d)", ret) ;
			return -1 ;
		}

//		tmp+= 5 ;
		tmp = &CArmor[c].lv;
		for(i=4; i <= nCols; i++) {
			ret= SQLGetData(hStmt, i, SQL_C_SLONG, tmp, sizeof(int), &cbValue) ;
			//fprintf(stdout, "\n [%3d][%8x] %d", i, tmp, *tmp) ;
			tmp++ ;
		}
		c++ ;
		
		ret= SQLFetch(hStmt) ;
		m_Much  = 0;
	}
//	printf("\n<<<<<< %d Cols.>>>>>>>>", nCols) ;
//	printf("\n<<<<<< %d Rows.>>>>>>>>", c) ;
	SQLFreeStmt(hStmt, SQL_DROP) ;
//	printf("       Item_Armor     (%3d:%3d) reading process complete.\r\n", c, nCols ) ;
	return c ;
}

int CItem_Accessory::getAllData(void)
{
	if(Num_Of_CItem_Accessory <= 0) {
		//fprintf(stdout, "\n	No item's available ") ;
		return -4 ; // No item's available
	}
	HSTMT hStmt= NULL ;
	RETCODE ret ;
	SWORD nCols ;
	char query_stmt[80]= {0, } ;
	SDWORD cbValue ;
	int *tmp ;
	int c= 1, i ;
	SQLAllocStmt(hDBC, &hStmt);
	
	strcpy(query_stmt, "select * from Item_Accessory order by item_id") ;
	ret= SQLExecDirect(hStmt, (UCHAR *)query_stmt, SQL_NTS) ;

	if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
		printf("\nItem Accessory: ExecDirect Error ") ;
		return -1 ;
	}

	SQLNumResultCols(hStmt, &nCols) ;
	
	ret= SQLFetch(hStmt) ;
	if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
		LPVOID lpMsgBuf;
		FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
			FORMAT_MESSAGE_IGNORE_INSERTS,    NULL,
			GetLastError(),
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
			(LPTSTR) &lpMsgBuf,    0,    NULL );// Process any inserts in lpMsgBuf.
		// ...// Display the string.
		printf("\nLast Error: %s", (LPCTSTR)lpMsgBuf) ;
		// Free the buffer.
		LocalFree( lpMsgBuf );
		printf("\nItem7: Fetch Error ") ;
		return -1 ;
	}
		
	while(ret == SQL_SUCCESS)
	{
		// Accquire the DATA

		ret= SQLGetData(hStmt, 1, SQL_C_SLONG, &c, sizeof(int), &cbValue) ;
		if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
			printf("\nError!!! (%d)", ret) ;
			return -1 ;
		}
		CAccessory[c].Item_id = c;

		ret= SQLGetData(hStmt, 2, SQL_C_CHAR, &CAccessory[c].Name, sizeof(Name), &cbValue) ;
		ret= SQLGetData(hStmt, 3, SQL_C_CHAR, &CAccessory[c].Han_Name, sizeof(Han_Name), &cbValue) ;
		EatRearWhiteChar( CAccessory[c].Han_Name );
		if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
			printf("\nString GET Error!!! (%d)", ret) ;
			return -1 ;
		}
	
//		tmp+= 5 ;
		tmp = &CAccessory[c].lv;
		for(i=4; i <= nCols; i++) {
			ret= SQLGetData(hStmt, i, SQL_C_SLONG, tmp, sizeof(int), &cbValue) ;
			//fprintf(stdout, "\n [%3d][%8x] %d", i, tmp, *tmp) ;
			tmp++ ;
		}
		c++ ;
		
		ret= SQLFetch(hStmt) ;
		m_Much  = 0;		// 弊 酒捞袍捞 倔付唱 乐唱 檬扁拳 1215
	}
//	printf("\n<<<<<< %d Cols.>>>>>>>>", nCols) ;
//	printf("\n<<<<<< %d Rows.>>>>>>>>", c) ;
	SQLFreeStmt(hStmt, SQL_DROP) ;
//	printf("       Item_Accessory (%3d:%3d) reading process complete.\r\n", c, nCols ) ;
	return c ;
}	
	
int CItem_Etc::getAllData(void)
{	
	if(Num_Of_CItem_Etc <= 0) {
		//fprintf(stdout, "\n	No item's available ") ;
		return -4 ; // No item's available
	}
	HSTMT hStmt= NULL ;
	RETCODE ret ;
	SWORD nCols ;
	char query_stmt[80]= {0, } ;
	SDWORD cbValue ;
	int *tmp ;
	int c= 1, i ;
	SQLAllocStmt(hDBC, &hStmt);
	
	strcpy(query_stmt, "select * from Item_Etc order by item_id") ;
	ret= SQLExecDirect(hStmt, (UCHAR *)query_stmt, SQL_NTS) ;
	
	if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
		printf("\nItem Etc: ExecDirect Error ") ;
		return -1 ;
	}
	
	SQLNumResultCols(hStmt, &nCols) ;
	
	ret= SQLFetch(hStmt) ;
	if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
		LPVOID lpMsgBuf;
		FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
			FORMAT_MESSAGE_IGNORE_INSERTS,    NULL,
			GetLastError(),
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
			(LPTSTR) &lpMsgBuf,    0,    NULL );// Process any inserts in lpMsgBuf.
		// ...// Display the string.
		printf("\nLast Error: %s", (LPCTSTR)lpMsgBuf) ;
		// Free the buffer.
		LocalFree( lpMsgBuf );
		printf("\nItem7: Fetch Error ") ;
		return -1 ;
	}
		
	while(ret == SQL_SUCCESS)
	{
		// Accquire the DATA
		ret= SQLGetData(hStmt, 1, SQL_C_SLONG, &c, sizeof(int), &cbValue) ;
		CEtc[c].Item_id = c;
		ret= SQLGetData(hStmt, 2, SQL_C_CHAR, &CEtc[c].Name, sizeof(Name), &cbValue) ;
		ret= SQLGetData(hStmt, 3, SQL_C_CHAR, &CEtc[c].Han_Name, sizeof(Han_Name), &cbValue) ;
		EatRearWhiteChar( CEtc[c].Han_Name );
		tmp = &CEtc[c].lv;
		for(i=4; i <= nCols; i++) {
			ret= SQLGetData(hStmt, i, SQL_C_SLONG, tmp, sizeof(int), &cbValue) ;
			tmp++ ;
		}
		c++ ;
		
		ret= SQLFetch(hStmt) ;
		m_Much  = 0;
	}
	SQLFreeStmt(hStmt, SQL_DROP) ;
	return c ;
}








// *****************************************************************************************
// *****************************************************************************************

⌨️ 快捷键说明

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