Beispiel #1
0
void CDDom::Process( void )
{
	if( GetRunTime() == RUN_CLOSED )
		return;

	if( GetRunTime() == RUN_COOLDOWN )
	{
		if( m_dwRoundTime != 0 && m_dwRoundTime < GetTickCount() )
		{
			m_dwRoundTime = 0;
			StartRound();
		}
	}
	else if( GetRunTime() == RUN_FIGHT )
	{
		if( GetTime() > 0 )
		{
			DecreaseTime();
		}
		else
		{
			const DDOM_TEAM tA = m_Base[BASE_A].GetTouchTeam();
			const DDOM_TEAM tB = m_Base[BASE_B].GetTouchTeam();
			if( tA != MAX_TEAM && tB != MAX_TEAM )
			{
				if( tA == tB )
				{
					Capped( tA ); //ATTENTION
					ResetCapTeam(); 
				} 
			}	
		}
	}
}
Beispiel #2
0
void CDDom::Kill( CUser* pAttack, CUser* pTarget )
{
	if( GetRunTime() != RUN_FIGHT )
		return;
	if( IsInvalidObj( pAttack ) || IsInvalidObj( pTarget ) )
		return;
	if( IsValidTeam( pAttack->m_ddomTeam, pTarget->m_ddomTeam ) )
	{
		CDDomTeam* pDomAttack = &m_DomTeam[ pAttack->m_ddomTeam ];
		CDDomTeam* pDomDefend = &m_DomTeam[ pTarget->m_ddomTeam ];
		if( pDomAttack == NULL || pDomDefend == NULL )
			return;

		//Increase( pAttack->m_ddomTeam, INC_KILL );
		//Increase( pTarget->m_ddomTeam, INC_DEATH );

		pDomAttack->Increase( pAttack->m_idPlayer, INC_KILL );
		pDomDefend->Increase( pTarget->m_idPlayer, INC_DEATH );

		CString strKill;
		strKill.Format( "[%s] %s has killed [%s] %s", GetName( pAttack->m_ddomTeam ), pAttack->GetName(), 
			GetName( pTarget->m_ddomTeam ), pTarget->GetName() );
		Send( strKill, FONT_MIDMED, DoubleDom::Color::nGoldCol );
	}
}
Beispiel #3
0
void CDDom::Capped( DDOM_TEAM team )
{
	if( GetRunTime() == RUN_CLOSED )
		return;

	m_DomTeam[team].Increase( m_idCapUser, INC_CAPTURE );
	m_idCapUser = 0;

	if( m_DomTeam[team].GetCaptures() >= DoubleDom::Queue::nRounds )
	{
		End();
		return;
	} 

/*#ifdef __LEA_MONDE
	g_UserMng.AddDominationWireframe();
#endif*/

	CString strCaptured;
	strCaptured.Format( "Team %s has increased the score, new round in 9 seconds", GetName( team ) );
	Send( strCaptured );
	SetRunTime( RUN_COOLDOWN );
	m_dwRoundTime = GetTickCount() + 9000;
	m_dwRound++;
}
Beispiel #4
0
BOOL CDDom::Kick( CUser* pUser )
{
	if( IsValidObj( pUser ) == FALSE )
		return FALSE;

	vector<u_long>::iterator it = find( m_User.begin(), m_User.end(), pUser->m_idPlayer );
	if( it != m_User.end() )
	{
		m_User.erase( it );
	}

	if( m_DomTeam[TEAM_A].GetAmount() == 0 && m_DomTeam[TEAM_B].GetAmount() == 0 )
		return FALSE;
	if( m_DomTeam[TEAM_A].Remove( pUser ) == FALSE )
	{
		if( m_DomTeam[TEAM_B].Remove( pUser ) == FALSE )
		{
			return FALSE;
		}
	} 

	if( GetRunTime() != RUN_CLOSED )
	{
		if( m_DomTeam[TEAM_A].GetAmount() == 0 || m_DomTeam[TEAM_B].GetAmount() == 0 )
			End();
	} 
	
	return TRUE;
}
Beispiel #5
0
BOOL CDDom::Start( vector<u_long>& playerList  )
{
	if( GetRunTime() != RUN_CLOSED )
		return FALSE;
	SetRunTime( RUN_FIGHT );

	g_DPCoreClient.SendSystem("Double Domination has started!");

#ifdef __NEW_FONT
	Send( "Double Domination Start", FONT_MIDMED, DoubleDom::Color::nBlueCol );
	//g_UserMng.AddTextFontType(  );
#endif

	m_splitSize = playerList.size() / 2;
	for( vector<u_long>::iterator it = playerList.begin(); it != playerList.end(); ++it )
	{
		CUser*	pUser	= static_cast<CUser*>( prj.GetUserByID( (*it ) ) );
		if( IsValidObj( pUser ) )
		{
			Join( pUser );
		}
	}
	m_splitSize = 0;
	return TRUE;
}
Beispiel #6
0
void CDDom::Touch( CUser* pUser, DDOM_BASE base )
{
	if( IsValidObj( pUser ) == FALSE )
		return;
	if( IsValidBase( base ) == FALSE )
		return;
	if( GetRunTime() != RUN_FIGHT )
		return; 
	if( pUser->IsDie() )
		return; 

	const DDOM_TEAM teamUser = pUser->m_ddomTeam;
	if( IsValidTeamOne( teamUser ) )
	{
		DDOM_TEAM team = m_Base[base].GetTouchTeam();
		if( team != MAX_TEAM )
		{
			if( team == pUser->m_ddomTeam )
			{
				pUser->AddTextD3D( "This base is already captured by your team.", 0xFFFF0000 );
				return;
			}
		}

		CString strTouch;
		strTouch.Format( "[%s] %s captured %s base", GetName( teamUser ), pUser->GetName(), GetBaseName( base ) );
		//SendBaseTouch( strTouch, base, pUser->m_ddomTeam ); //ATTENTION
		Send( strTouch );

		m_Base[base].SetTouchedBy( teamUser );
		const DDOM_BASE opBase = GetOponentBase( base );

		
		m_idCapUser = pUser->m_idPlayer;
		BOOL bTouchTime = FALSE;
		DDOM_TEAM opTeam = m_Base[opBase].GetTouchTeam(); 
		if( opTeam == pUser->m_ddomTeam )
		{
			bTouchTime = TRUE;
			CString strFontText; 
			strFontText.Format( "Both bases have been dominated by %s team. Countdown start", GetName( teamUser ) );
			Send( strFontText, FONT_MIDMED, DoubleDom::Color::nBlueCol );
			SetTime();
		}
		else
		{
			if( GetTime() == 1 || GetTime() == 2 )
			{
				ResetTime();
				Send( "Last second save", FONT_MIDMED, DoubleDom::Color::nBlueCol );
			}
		}
		m_DomTeam[ teamUser ].Increase( pUser->m_idPlayer, INC_TOUCH );
		SendTouch( pUser->m_ddomTeam, base, bTouchTime ); 
	}
}
Beispiel #7
0
void CDDom::Send( CString strMessage )
{
	if( GetRunTime() == RUN_CLOSED )
		return;

	for( vector<u_long>::iterator it = m_User.begin(); it != m_User.end(); ++it )
	{
		CUser*	pUser		= static_cast<CUser*>( prj.GetUserByID( (*it ) ) );
		if( IsValidObj( pUser ) )
		{
			pUser->AddTextD3D( strMessage, DoubleDom::Color::nBlueCol );
		}
	}
}
Beispiel #8
0
void CDDom::SendScore( void )
{
	if( GetRunTime() == RUN_CLOSED )
		return;

	for( vector<u_long>::iterator it = m_User.begin(); it != m_User.end(); ++it )
	{
		CUser*	pUser		= static_cast<CUser*>( prj.GetUserByID( (*it ) ) );
		if( IsValidObj( pUser ) )
		{
			pUser->SendDDomScore();
		}
	}
}
Beispiel #9
0
void CDDom::SendTouch( DDOM_TEAM team, DDOM_BASE base, BOOL bCaptured )
{
	if( GetRunTime() == RUN_CLOSED )
		return;

	for( vector<u_long>::iterator it = m_User.begin(); it != m_User.end(); ++it )
	{
		CUser*	pUser		= static_cast<CUser*>( prj.GetUserByID( (*it ) ) );
		if( IsValidObj( pUser ) )
		{
			pUser->SendDDomTouch( team, base, bCaptured );
		}
	}
}
Beispiel #10
0
void CDDom::Send( CString strMessage, FONT_MSG font, D3DCOLOR d3dcolor )
{
	if( GetRunTime() == RUN_CLOSED )
		return;
	for( vector<u_long>::iterator it = m_User.begin(); it != m_User.end(); ++it )
	{
		CUser*	pUser		= static_cast<CUser*>( prj.GetUserByID( (*it ) ) );
		if( IsValidObj( pUser ) )
		{
#ifdef __NEW_FONT
			//pUser->SendTextFont( strMessage, static_cast<u_int>( font ), d3dcolor );
			pUser->AddTextD3D( strMessage, d3dcolor );//
#else
			pUser->AddTextD3D( strMessage, d3dcolor );
#endif
		}
	}
}
/*************************************************************************************
EXTERNAL
*************************************************************************************/
int getEmuDevParameter( void*_pParam, int _paramId)
{
clemuGPU * clDevice;
cl_int status = SDK_FAILURE;

 clDevice = (clemuGPU * )GetRunTime()->GetActiveDev(0);

    if (clDevice)
	{
      switch( _paramId )
	  {
	  case CLEMU_PARAM_DEV_NAME:
		  (*(const char**)_pParam) = clDevice->GetDevNm();
		  break;
	  }
      status = SDK_SUCCESS;
	}

	return(status);
}
Beispiel #12
0
void CDDom::End( void )
{
	if( GetRunTime() == RUN_CLOSED )
		return;

	SendTouch( MAX_TEAM, BASE_A );
	SendTouch( MAX_TEAM, BASE_B ); 

	CDDomTeam& team = m_DomTeam[TEAM_A].GetCaptures() > m_DomTeam[TEAM_B].GetCaptures() ? m_DomTeam[TEAM_A] : m_DomTeam[TEAM_B];
	
	if( m_DomTeam[TEAM_A].GetAmount() == 0 )
		team = m_DomTeam[TEAM_B];
	else if( m_DomTeam[TEAM_B].GetAmount() == 0 )
		team = m_DomTeam[TEAM_A];

	DDOM_TEAM dteam = m_DomTeam[TEAM_A].GetCaptures() > m_DomTeam[TEAM_B].GetCaptures() ? TEAM_A : TEAM_B; 

	team.SendPrize();
	CString strTeam;
	strTeam.Format( "Team %s has won the Double Domination game! You can now join at Is!", GetName( dteam ) );
	//this->Send( strTeam );
	//this->Send( "The game has ended!" );
	//g_DPCoreClient.SendSystem( strTeam );
	g_DPCoreClient.SendSystem( strTeam );
	
	ReturnAll();
	
	m_dwRound = 0;
	m_dwRoundTime = 0;
	m_idCapUser = 0;
	m_splitSize = 0;
	m_wTime = 0 ;
	m_RunTime = RUN_CLOSED;
	m_User.clear();

	m_Base[BASE_A].SetTouchedBy( MAX_TEAM );
	m_Base[BASE_B].SetTouchedBy( MAX_TEAM );

	m_DomTeam[TEAM_A].Init();
	m_DomTeam[TEAM_B].Init();
}
Beispiel #13
0
void CDDom::StartRound( void )
{
	if( GetRunTime() != RUN_COOLDOWN )
		return;

	CString strRound;
	strRound.Format( "The round: %u has begun", m_dwRound +1 );
	for( vector<u_long>::iterator it = m_User.begin(); it != m_User.end(); ++it )
	{
		CUser*	pUser	= static_cast<CUser*>( prj.GetUserByID( (*it ) ) );
		if( IsValidObj( pUser ) )
		{
			pUser->AddTextD3D( strRound, DoubleDom::Color::nBlueCol );
			Safe( pUser );
		} 
	}

	SendTouch( MAX_TEAM, BASE_A );
	SendTouch( MAX_TEAM, BASE_B ); 
	SetRunTime( RUN_FIGHT );
}
Beispiel #14
0
BOOL CDDom::Join( CUser* pUser )
{
	if( GetRunTime() != RUN_FIGHT )
	{
		if( IsValidObj( pUser ) )
		{
			pUser->AddTextD3D( "No match available", 0xFFFF0000 );
		}
		return FALSE;
	}

	__int64 domRandom = xxRandom();
	DDOM_TEAM domTeam =  static_cast<DDOM_TEAM>( domRandom & 0x01 );
	if( IsValidTeamOne( domTeam ) == FALSE )
		return FALSE;
	if( m_DomTeam[domTeam].GetAmount() >= m_splitSize )
		domTeam = GetOponentTeam( domTeam );
	CString strTeam = GetName( domTeam );
	if( strTeam.IsEmpty() == true )
		return FALSE;
	if( m_DomTeam[domTeam].Add( pUser, domTeam ) != TRUE )
		return FALSE;

	m_User.push_back( pUser->m_idPlayer );

	pUser->m_ddomTeam = domTeam;
	Safe( pUser );
	pUser->SendAdditionalMover( static_cast<CMover*>( pUser ) ); //hey!

	CString strJoin;
	strJoin.Format( "You have been set to %s team", strTeam );
	pUser->AddTextD3D( "You have joined the double domination", DoubleDom::Color::nBlueCol );
	pUser->AddTextD3D( strJoin, DoubleDom::Color::nBlueCol );
	
	SendScore();

	return TRUE;
}
Beispiel #15
0
void CTimer::Update(void)
{
	real curr = GetRunTime();
	
	// time between updates
	static real last = curr;

	delta = curr - last;
	last = curr;

	// framerate
	static real start = curr;
	static uint count = 0;

	count++;

	if(curr - start >= 1.0)
	{
		fps = count / (curr - start);
		start = curr;
		count = 0;
	}
}
int runCLEMU(const char * _device_type,
		   int _domainDim,
		   int _domain[],
		   int _group[],
		   const char * _program_location,
		   const char * _program_nm,
		   const char*_kernel_entry_name,
		   int _nbr_arg,
		   ClKrnlArg _args[])
{
clemuGPU * clDevice;
 cl_int status = SDK_SUCCESS;

 clDevice = (clemuGPU * )GetRunTime()->GetActiveDev(0);

clemuKernelJob *newJob;
   newJob = new clemuKernelJob;
   assert(newJob);
   newJob->initJob(clDevice,
	               _program_location,
                   _program_nm,
		           _kernel_entry_name,
		           _domainDim,
				   _domain,
				   _group,
				   _nbr_arg,
		           _args);
   clDevice->attachJob(newJob);
   clDevice->scheduleNextJob();

// delete job
clemuKernelJob *oldJob;
   oldJob = clDevice->fundJob(newJob->GetId());
   clDevice->detachJob(oldJob);
   delete oldJob;
   return(status);
}
Beispiel #17
0
/*
 * the order status transaction
 */
int ordstat( int t_num,
	     int w_id_arg,		/* warehouse id */
	     int d_id_arg,		/* district id */
	     int byname,		/* select by c_id or c_last? */
	     int c_id_arg,		/* customer id */
	     char c_last_arg[]	        /* customer last name, format? */
)
{
	int            w_id = w_id_arg;
	int            d_id = d_id_arg;
	int            c_id = c_id_arg;
	int            c_d_id = d_id;
	int            c_w_id = w_id;
	char            c_first[17];
	char            c_middle[3];
	char            c_last[17];
	int           c_balance;	//goda:float -> int
	int            o_id;
	char            o_entry_d[25];
	int            o_carrier_id;
	int            ol_i_id;
	int            ol_supply_w_id;
	int            ol_quantity;
	int           ol_amount;	//goda:float -> int
	char            ol_delivery_d[25];
	int            namecnt;

	int             n;
	int             proceed = 0;

	MYSQL_STMT*   mysql_stmt;
        MYSQL_BIND    param[6];
        MYSQL_BIND    column[5];

/* goda [ */
	char		tempquery[500];
	MYSQL_RES *resp = NULL;
	MYSQL_ROW row;
	int max_o_id;
	struct timespec tbuf;
	double runtime;
/* ] goda */ 


	/*EXEC SQL WHENEVER NOT FOUND GOTO sqlerr;*/
	/*EXEC SQL WHENEVER SQLERROR GOTO sqlerr;*/

	if (byname) {
		strcpy(c_last, c_last_arg);
		proceed = 1;
		/*EXEC_SQL SELECT count(c_id)
			INTO :namecnt
		        FROM customer
			WHERE c_w_id = :c_w_id
			AND c_d_id = :c_d_id
		        AND c_last = :c_last;*/

/* goda commentout 
		mysql_stmt = stmt[t_num][20];

                memset(param, 0, sizeof(MYSQL_BIND) * 3); /* initialize *
                param[0].buffer_type = MYSQL_TYPE_LONG;
                param[0].buffer = &c_w_id;
                param[1].buffer_type = MYSQL_TYPE_LONG;
                param[1].buffer = &c_d_id;
                param[2].buffer_type = MYSQL_TYPE_STRING;
                param[2].buffer = c_last;
                param[2].buffer_length = strlen(c_last);
                if( mysql_stmt_bind_param(mysql_stmt, param) ) goto sqlerr;
                if( mysql_stmt_execute(mysql_stmt) ) goto sqlerr;

                if( mysql_stmt_store_result(mysql_stmt) ) goto sqlerr;
                memset(column, 0, sizeof(MYSQL_BIND) * 1); /* initialize *
                column[0].buffer_type = MYSQL_TYPE_LONG;
                column[0].buffer = &namecnt;
                if( mysql_stmt_bind_result(mysql_stmt, column) ) goto sqlerr;
                switch( mysql_stmt_fetch(mysql_stmt) ) {
                    case 0: //SUCCESS
                        break;
                    case 1: //ERROR
                    case MYSQL_NO_DATA: //NO MORE DATA
                    default:
                        mysql_stmt_free_result(mysql_stmt);
                        goto sqlerr;
                }
                mysql_stmt_free_result(mysql_stmt);
*/

/* goda [ */
		sprintf(tempquery,"SELECT count(c_id) FROM customer WHERE c_w_id = %d AND c_d_id = %d AND c_last = '%s'",c_w_id,c_d_id,c_last);
		GetStartTime(&tbuf);
		if(mysql_query(ctx[t_num],tempquery)) goto sqlerr;
		runtime = GetRunTime(&tbuf);
		query_log[20].runCount++;
		query_log[20].runTime += runtime;
		resp = mysql_use_result(ctx[t_num]);
		if((row = mysql_fetch_row(resp)) != NULL){
			namecnt = atoi(row[0]);
		}
		else{
			//NO RESULT
			mysql_free_result(resp);
			goto sqlerr;
		}
		mysql_free_result(resp);
/* ] goda */ 


		proceed = 2;
		/*EXEC_SQL DECLARE c_byname_o CURSOR FOR
		        SELECT c_balance, c_first, c_middle, c_last
		        FROM customer
		        WHERE c_w_id = :c_w_id
			AND c_d_id = :c_d_id
			AND c_last = :c_last
			ORDER BY c_first;
		proceed = 3;
		EXEC_SQL OPEN c_byname_o;*/

/* goda commentout
		mysql_stmt = stmt[t_num][21];

		memset(param, 0, sizeof(MYSQL_BIND) * 3); /* initialize *
		param[0].buffer_type = MYSQL_TYPE_LONG;
                param[0].buffer = &c_w_id;
                param[1].buffer_type = MYSQL_TYPE_LONG;
                param[1].buffer = &c_d_id;
                param[2].buffer_type = MYSQL_TYPE_STRING;
                param[2].buffer = c_last;
                param[2].buffer_length = strlen(c_last);
                if( mysql_stmt_bind_param(mysql_stmt, param) ) goto sqlerr;
                if( mysql_stmt_execute(mysql_stmt) ) goto sqlerr;

		if( mysql_stmt_store_result(mysql_stmt) ) goto sqlerr;
                memset(column, 0, sizeof(MYSQL_BIND) * 4); /* initialize *
		column[0].buffer_type = MYSQL_TYPE_FLOAT;
		column[0].buffer = &c_balance;
		column[1].buffer_type = MYSQL_TYPE_STRING;
		column[1].buffer = c_first;
		column[1].buffer_length = sizeof(c_first);
		column[2].buffer_type = MYSQL_TYPE_STRING;
		column[2].buffer = c_middle;
		column[2].buffer_length = sizeof(c_middle);
		column[3].buffer_type = MYSQL_TYPE_STRING;
		column[3].buffer = c_last;
		column[3].buffer_length = sizeof(c_last);
		if( mysql_stmt_bind_result(mysql_stmt, column) ) goto sqlerr;
*/

/* goda [ */
		sprintf(tempquery,"SELECT c_balance, c_first, c_middle, c_last FROM customer WHERE c_w_id = %d AND c_d_id = %d AND c_last = '%s' ORDER BY c_first",c_w_id,c_d_id,c_last);
		GetStartTime(&tbuf);
		if(mysql_query(ctx[t_num],tempquery)) goto sqlerr;
		runtime = GetRunTime(&tbuf);
		query_log[21].runCount++;
		query_log[21].runTime += runtime;
		resp = mysql_use_result(ctx[t_num]);
		
/* ] goda */ 

		if (namecnt % 2)
			namecnt++;	/* Locate midpoint customer; */

		for (n = 0; n < namecnt / 2; n++) {
			proceed = 4;

/* goda commentout
			/*EXEC_SQL FETCH c_byname_o
			  INTO :c_balance, :c_first, :c_middle, :c_last;*
			switch( mysql_stmt_fetch(mysql_stmt) ) {
			    case 0: //SUCCESS
                            case MYSQL_DATA_TRUNCATED:
				break;
			    case 1: //ERROR
			    case MYSQL_NO_DATA: //NO MORE DATA
			    default:
				mysql_stmt_free_result(mysql_stmt);
				goto sqlerr;
			}
*/
/* goda [ */
			if((row = mysql_fetch_row(resp)) != NULL){
				c_balance = atoi(row[0]);
				sprintf(c_first,"%s",row[1]);
				sprintf(c_middle,"%s",row[2]);
				sprintf(c_last,"%s",row[3]);
			}
			else{
				//NO RESULT
				mysql_free_result(resp);
				goto sqlerr;
			}
/* ] goda */ 
		}
		proceed = 5;
		/*EXEC_SQL CLOSE  c_byname_o;*/

//goda commentout		mysql_stmt_free_result(mysql_stmt);

		mysql_free_result(resp);


	} else {		/* by number */
		proceed = 6;
		/*EXEC_SQL SELECT c_balance, c_first, c_middle, c_last
			INTO :c_balance, :c_first, :c_middle, :c_last
		        FROM customer
		        WHERE c_w_id = :c_w_id
			AND c_d_id = :c_d_id
			AND c_id = :c_id;*/
/* goda commentout
		mysql_stmt = stmt[t_num][22];

		memset(param, 0, sizeof(MYSQL_BIND) * 3); /* initialize *
		param[0].buffer_type = MYSQL_TYPE_LONG;
		param[0].buffer = &c_w_id;
		param[1].buffer_type = MYSQL_TYPE_LONG;
		param[1].buffer = &c_d_id;
		param[2].buffer_type = MYSQL_TYPE_LONG;
		param[2].buffer = &c_id;
		if( mysql_stmt_bind_param(mysql_stmt, param) ) goto sqlerr;
		if( mysql_stmt_execute(mysql_stmt) ) goto sqlerr;

		if( mysql_stmt_store_result(mysql_stmt) ) goto sqlerr;
		memset(column, 0, sizeof(MYSQL_BIND) * 4); /* initialize *
		column[0].buffer_type = MYSQL_TYPE_FLOAT;
		column[0].buffer = &c_balance;
		column[1].buffer_type = MYSQL_TYPE_STRING;
		column[1].buffer = c_first;
		column[1].buffer_length = sizeof(c_first);
		column[2].buffer_type = MYSQL_TYPE_STRING;
		column[2].buffer = c_middle;
		column[2].buffer_length = sizeof(c_middle);
		column[3].buffer_type = MYSQL_TYPE_STRING;
		column[3].buffer = c_last;
		column[3].buffer_length = sizeof(c_last);
		if( mysql_stmt_bind_result(mysql_stmt, column) ) goto sqlerr;
		switch( mysql_stmt_fetch(mysql_stmt) ) {
		    case 0: //SUCCESS
                    case MYSQL_DATA_TRUNCATED:
			break;
		    case 1: //ERROR
		    case MYSQL_NO_DATA: //NO MORE DATA
		    default:
			mysql_stmt_free_result(mysql_stmt);
			goto sqlerr;
		}
		mysql_stmt_free_result(mysql_stmt);
*/
/* goda [ */
		sprintf(tempquery,"SELECT c_balance, c_first, c_middle, c_last FROM customer WHERE c_w_id = %d AND c_d_id = %d AND c_id = %d",c_w_id,c_d_id,c_id);
		GetStartTime(&tbuf);
		if(mysql_query(ctx[t_num],tempquery)) goto sqlerr;
		runtime = GetRunTime(&tbuf);
		query_log[22].runCount++;
		query_log[22].runTime += runtime;
		resp = mysql_use_result(ctx[t_num]);
		if((row = mysql_fetch_row(resp)) != NULL){
			c_balance = atoi(row[0]);
			sprintf(c_first,"%s",row[1]);
			sprintf(c_middle,"%s",row[2]);
			sprintf(c_last,"%s",row[3]);
		}
		else{
			//NO RESULT
			mysql_free_result(resp);
			goto sqlerr;
		}
		mysql_free_result(resp);
/* ] goda */ 

	}

	/* find the most recent order for this customer */

	proceed = 7;
	/*EXEC_SQL SELECT o_id, o_entry_d, COALESCE(o_carrier_id,0)
		INTO :o_id, :o_entry_d, :o_carrier_id
	        FROM orders
	        WHERE o_w_id = :c_w_id
		AND o_d_id = :c_d_id
		AND o_c_id = :c_id
		AND o_id = (SELECT MAX(o_id)
		    	    FROM orders
		    	    WHERE o_w_id = :c_w_id
		  	    AND o_d_id = :c_d_id
		    	    AND o_c_id = :c_id);*/
/* goda commentout 
	mysql_stmt = stmt[t_num][23];

	memset(param, 0, sizeof(MYSQL_BIND) * 6); /* initialize *
	param[0].buffer_type = MYSQL_TYPE_LONG;
	param[0].buffer = &c_w_id;
	param[1].buffer_type = MYSQL_TYPE_LONG;
	param[1].buffer = &c_d_id;
	param[2].buffer_type = MYSQL_TYPE_LONG;
	param[2].buffer = &c_id;
	param[3].buffer_type = MYSQL_TYPE_LONG;
	param[3].buffer = &c_w_id;
	param[4].buffer_type = MYSQL_TYPE_LONG;
	param[4].buffer = &c_d_id;
	param[5].buffer_type = MYSQL_TYPE_LONG;
	param[5].buffer = &c_id;
	if( mysql_stmt_bind_param(mysql_stmt, param) ) goto sqlerr;
	if( mysql_stmt_execute(mysql_stmt) ) goto sqlerr;

	if( mysql_stmt_store_result(mysql_stmt) ) goto sqlerr;
	memset(column, 0, sizeof(MYSQL_BIND) * 3); /* initialize *
	column[0].buffer_type = MYSQL_TYPE_LONG;
        column[0].buffer = &o_id;
	column[1].buffer_type = MYSQL_TYPE_STRING;
	column[1].buffer = o_entry_d;
	column[1].buffer_length = sizeof(o_entry_d);
	column[2].buffer_type = MYSQL_TYPE_LONG;
        column[2].buffer = &o_carrier_id;
	if( mysql_stmt_bind_result(mysql_stmt, column) ) goto sqlerr;
        switch( mysql_stmt_fetch(mysql_stmt) ) {
            case 0: //SUCCESS
                break;
            case 1: //ERROR
            case MYSQL_NO_DATA: //NO MORE DATA
            default:
                mysql_stmt_free_result(mysql_stmt);
                goto sqlerr;
        }
        mysql_stmt_free_result(mysql_stmt);
*/
/* goda [ */
/* preprocess to get max_o_id */
		sprintf(tempquery,"SELECT MAX(o_id) FROM orders WHERE o_w_id = %d AND o_d_id = %d AND o_c_id = %d",c_w_id,c_d_id,c_id);
		if(mysql_query(ctx[t_num],tempquery)) goto sqlerr;
		resp = mysql_use_result(ctx[t_num]);
		if((row = mysql_fetch_row(resp)) != NULL){
			max_o_id = atoi(row[0]);
		}
		else{
			//NO RESULT
			mysql_free_result(resp);
			goto sqlerr;
		}
		mysql_free_result(resp);

	proceed = 70;
		//sprintf(tempquery,"SELECT o_id, o_entry_d, COALESCE(o_carrier_id,0) FROM orders WHERE o_w_id = %d AND o_d_id = %d AND o_c_id = %d AND o_id = (SELECT MAX(o_id) FROM orders WHERE o_w_id = %d AND o_d_id = %d AND o_c_id = %d)",c_w_id,c_d_id,c_id,c_w_id,c_d_id,c_id);
		sprintf(tempquery,"SELECT o_id, o_entry_d, o_carrier_id FROM orders WHERE o_w_id = %d AND o_d_id = %d AND o_c_id = %d AND o_id = %d",c_w_id,c_d_id,c_id,max_o_id);
		GetStartTime(&tbuf);
		if(mysql_query(ctx[t_num],tempquery)) goto sqlerr;
		runtime = GetRunTime(&tbuf);
		query_log[23].runCount++;
		query_log[23].runTime += runtime;

		resp = mysql_use_result(ctx[t_num]);
		if((row = mysql_fetch_row(resp)) != NULL){
			sprintf(o_entry_d,"%s",row[1]);
			if(row[2] != NULL){
				o_carrier_id = atoi(row[2]);
			}
			else{
				o_carrier_id = 0;
			}
		}
		else{
			//NO RESULT
			mysql_free_result(resp);
			goto sqlerr;
		}
		mysql_free_result(resp);
/* ] goda */ 


	/* find all the items in this order */
	proceed = 8;
	/*EXEC_SQL DECLARE c_items CURSOR FOR
		SELECT ol_i_id, ol_supply_w_id, ol_quantity, ol_amount,
                       ol_delivery_d
		FROM order_line
	        WHERE ol_w_id = :c_w_id
		AND ol_d_id = :c_d_id
		AND ol_o_id = :o_id;*/
/* goda commentout
	mysql_stmt = stmt[t_num][24];

	memset(param, 0, sizeof(MYSQL_BIND) * 3); /* initialize *
	param[0].buffer_type = MYSQL_TYPE_LONG;
	param[0].buffer = &c_w_id;
	param[1].buffer_type = MYSQL_TYPE_LONG;
	param[1].buffer = &c_d_id;
	param[2].buffer_type = MYSQL_TYPE_LONG;
	param[2].buffer = &o_id;
	if( mysql_stmt_bind_param(mysql_stmt, param) ) goto sqlerr;
	if( mysql_stmt_execute(mysql_stmt) ) goto sqlerr;

	if( mysql_stmt_store_result(mysql_stmt) ) goto sqlerr;
        memset(column, 0, sizeof(MYSQL_BIND) * 5); /* initialize *	
	column[0].buffer_type = MYSQL_TYPE_LONG;
        column[0].buffer = &ol_i_id;
	column[1].buffer_type = MYSQL_TYPE_LONG;
        column[1].buffer = &ol_supply_w_id;
	column[2].buffer_type = MYSQL_TYPE_LONG;
        column[2].buffer = &ol_quantity;
	column[3].buffer_type = MYSQL_TYPE_FLOAT;
        column[3].buffer = &ol_amount;
	column[4].buffer_type = MYSQL_TYPE_STRING;
        column[4].buffer = ol_delivery_d;
        column[4].buffer_length = sizeof(ol_delivery_d);
	if( mysql_stmt_bind_result(mysql_stmt, column) ) goto sqlerr;
*/
/* goda [ */
		sprintf(tempquery,"SELECT ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_delivery_d FROM order_line WHERE ol_w_id = %d AND ol_d_id = %d AND ol_o_id = %d",c_w_id,c_d_id,o_id);
		GetStartTime(&tbuf);
		if(mysql_query(ctx[t_num],tempquery)) goto sqlerr;
		runtime = GetRunTime(&tbuf);
		query_log[24].runCount++;
		query_log[24].runTime += runtime;
		resp = mysql_use_result(ctx[t_num]);
/* ] goda */ 


	/*proceed = 9;
	EXEC_SQL OPEN c_items;

	EXEC SQL WHENEVER NOT FOUND GOTO done;*/

	for (;;) {
		proceed = 10;
		/*EXEC_SQL FETCH c_items
			INTO :ol_i_id, :ol_supply_w_id, :ol_quantity,
			:ol_amount, :ol_delivery_d;*/
/* goda commentout
		switch( mysql_stmt_fetch(mysql_stmt) ) {
		    case 0: //SUCCESS
		    case MYSQL_DATA_TRUNCATED:
			break;
		    case MYSQL_NO_DATA: //NO MORE DATA
			mysql_stmt_free_result(mysql_stmt);
			goto done;
		    case 1: //ERROR
		    default:
			mysql_stmt_free_result(mysql_stmt);
			goto sqlerr;
		}
*/
		if((row = mysql_fetch_row(resp)) != NULL){
			ol_i_id = atoi(row[0]);
			ol_supply_w_id = atoi(row[1]);
			ol_quantity = atoi(row[2]);
			ol_amount = atoi(row[3]);
			sprintf(ol_delivery_d,"%s",row[4]);
		}
		else{
			//NO RESULT
			mysql_free_result(resp);
			goto done;
			//goto sqlerr;
		}
		mysql_free_result(resp);
	}

done:
	/*EXEC_SQL CLOSE c_items;*/
        /*EXEC_SQL COMMIT WORK;*/
	if( mysql_commit(ctx[t_num]) ) goto sqlerr;

	return (1);

sqlerr:
        fprintf(stderr, "ordstat %d:%d\n",t_num,proceed);
	outputQuery(tempquery);
	error(ctx[t_num],mysql_stmt);
        /*EXEC SQL WHENEVER SQLERROR GOTO sqlerrerr;*/
	/*EXEC_SQL ROLLBACK WORK;*/
	mysql_rollback(ctx[t_num]);
sqlerrerr:
	return (0);
}
Beispiel #18
0
float Root::GetAverageFps() const {
	return floor(mTotalNumFrames / GetRunTime());
}