-
-
Save bzar/faf0580bbeecd6c8233e to your computer and use it in GitHub Desktop.
C4A submit code for Space Rocks!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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