void ScoreLoopThread::SubmitScore(AppData_t *app, double result, unsigned int mode) {
	qDebug() << "Submitting score " << result;
	/* Create a ScoreController */
	SC_Error_t rc = SC_Client_CreateScoreController(app->client, &app->scoreController, SubmitScoreCompletionCallback, app);
	if (rc != SC_OK) {
		HandleError(app, rc);
		return;
	}

	/* Create and configure the score */
	rc = SC_Client_CreateScore(app->client, &app->score);
	if (rc != SC_OK) {
		SC_ScoreController_Release(app->scoreController); /* Cleanup Controller */
		HandleError(app, rc);
		return;
	}
	SC_Score_SetLevel(app->score, result);
	SC_Score_SetResult(app->score, result * 100);
	SC_Score_SetMode(app->score, mode);

	/* Submit the score */
	rc = SC_ScoreController_SubmitScore(app->scoreController, app->score);
	if (rc != SC_OK) {
		SC_ScoreController_Release(app->scoreController); /* Cleanup Controller */
		SC_Score_Release(app->score); /* Cleanup Score */
		HandleError(app, rc);
		return;
	}
	qDebug() << "Submitting Score...";
}
Ejemplo n.º 2
0
void CScores::DoSubmitScore()
{
	unsigned int aMode = 1;	
	unsigned int aLevel = 1;
	double aScore = (double)g_localhighscore;
	double aMinorResult = (double)s3eDeviceGetInt(S3E_DEVICE_OS); // Save OS type as Minor Result
	
	/* Create the score and set score data */
	SC_Score_h score;
	
	SC_Error_t retCode = SC_Score_New(&score);
	if (retCode == SC_OK) {
		SC_Score_SetResult(score, aScore);
		SC_Score_SetMode(score, aMode);
		SC_Score_SetLevel(score, aLevel);
		SC_Score_SetMinorResult(score, aMinorResult);

		retCode = SC_ScoreController_SubmitScore(m_scoreController, score);
		// See OnRequestSuccessSubmit()
	}
	
	/* SC_ScoreController_SubmitScore takes the ownership, we can safely release it */
	SC_Score_Release(score);
	
	if (retCode != SC_OK) {
		OnRequestFailed(retCode);
	}
}