Skip to content

Instantly share code, notes, and snippets.

@bzar
Created April 6, 2015 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bzar/faf0580bbeecd6c8233e to your computer and use it in GitHub Desktop.
Save bzar/faf0580bbeecd6c8233e to your computer and use it in GitHub Desktop.
C4A submit code for Space Rocks!
void HighScoreManager::submitToCompo4All()
{
spNetC4AProfilePointer profile = nullptr;
bool needed = false;
for(Entry& e : entries)
{
if(!e.submitted)
{
needed = true;
break;
}
}
if(!needed)
return;
try
{
spInitNet();
profile = spNetC4AGetProfile();
if(!profile)
{
throw C4AException("No C4A profile found!");
}
for(Entry& e : entries)
{
if(e.submitted)
continue;
spNetC4ACommitScore(profile, "spacerocks", e.score, nullptr, 10000);
while(spNetC4AGetStatus() == SP_C4A_PROGRESS);
if(spNetC4AGetStatus() != SP_C4A_OK);
{
throw C4AException("Could not submit score to C4A!");
}
e.submitted = true;
}
}
catch(C4AException e)
{
std::cerr << "ERROR: " << e.what() << std::endl;
}
if(profile)
{
spNetC4AFreeProfile(profile);
}
spQuitNet();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment