summaryrefslogtreecommitdiff
path: root/src/server/heightScore.c
diff options
context:
space:
mode:
authorTomas Chvatal (scarabeus) <tomas.chvatal@gmail.com>2008-10-22 22:53:48 +0200
committerTomas Chvatal (scarabeus) <tomas.chvatal@gmail.com>2008-10-22 22:53:48 +0200
commit130d45bfc935da1702a7b5c246a099ea3b4a0bdf (patch)
tree5cc4b029f24e7a3cfaf1fcbc671772059a9b8e73 /src/server/heightScore.c
parent44daf03024fbf7cbffa10349044786f6ab784821 (diff)
Ident all code correctly.
Diffstat (limited to 'src/server/heightScore.c')
-rw-r--r--src/server/heightScore.c139
1 files changed, 66 insertions, 73 deletions
diff --git a/src/server/heightScore.c b/src/server/heightScore.c
index 5c42ad6..7689d3f 100644
--- a/src/server/heightScore.c
+++ b/src/server/heightScore.c
@@ -11,92 +11,85 @@
static textFile_t *textFile;
-void initHeightScore(char *file)
+void
+initHeightScore(char *file)
{
- int i;
-
- textFile = loadTextFile(file);
-
- if( textFile == NULL )
- {
- fprintf(stderr, _("I am unable to load: \"%s\" !\n"), file);
- fprintf(stderr, _("Creating: \"%s\"\n"), file);
- textFile = newTextFile(file);
- }
- else
- {
+ int i;
+
+ textFile = loadTextFile(file);
+
+ if (textFile == NULL) {
+ fprintf(stderr, _("I am unable to load: \"%s\" !\n"), file);
+ fprintf(stderr, _("Creating: \"%s\"\n"), file);
+ textFile = newTextFile(file);
+ }
+ else {
#ifdef DEBUG
- printf(_("Scorefile: \"%s\"\n"), file);
+ printf(_("Scorefile: \"%s\"\n"), file);
#endif
- return;
- }
+ return;
+ }
- if( textFile == NULL )
- {
- fprintf(stderr, _("I was unable to create: \"%s\" !\n"), file);
- return;
- }
+ if (textFile == NULL) {
+ fprintf(stderr, _("I was unable to create: \"%s\" !\n"), file);
+ return;
+ }
- for( i = 0 ; i < HEIGHTSCORE_MAX_PLAYERS ; i++ )
- {
- addList(textFile->text, strdup("no_name 0") );
- }
+ for (i = 0; i < HEIGHTSCORE_MAX_PLAYERS; i++) {
+ addList(textFile->text, strdup("no_name 0"));
+ }
- saveTextFile(textFile);
+ saveTextFile(textFile);
}
-int addPlayerInHighScore(char *name, int score)
+int
+addPlayerInHighScore(char *name, int score)
{
- int i;
-
- if( score <= 0 )
- {
- return -1; // Ha ha ha
- }
-
- for( i = 0 ; i < HEIGHTSCORE_MAX_PLAYERS ; i++ )
- {
- char *line;
- char thisName[STR_NAME_SIZE];
- int thisCore;
-
- line = (char *) textFile->text->list[i];
- sscanf(line, "%s %d", thisName, &thisCore);
-
- if( score >= thisCore )
- {
- char new[STR_SIZE];
-
- sprintf(new, "%s %d", name, score);
- insList(textFile->text, i, strdup(new) );
- delListItem(textFile->text, HEIGHTSCORE_MAX_PLAYERS, free);
- //printTextFile(textFile);
- saveTextFile(textFile);
-
- return 0;
- }
- }
-
- return -1;
+ int i;
+
+ if (score <= 0) {
+ return -1; // Ha ha ha
+ }
+
+ for (i = 0; i < HEIGHTSCORE_MAX_PLAYERS; i++) {
+ char *line;
+ char thisName[STR_NAME_SIZE];
+ int thisCore;
+
+ line = (char *) textFile->text->list[i];
+ sscanf(line, "%s %d", thisName, &thisCore);
+
+ if (score >= thisCore) {
+ char new[STR_SIZE];
+
+ sprintf(new, "%s %d", name, score);
+ insList(textFile->text, i, strdup(new));
+ delListItem(textFile->text, HEIGHTSCORE_MAX_PLAYERS, free);
+ //printTextFile(textFile);
+ saveTextFile(textFile);
+
+ return 0;
+ }
+ }
+
+ return -1;
}
-char* getTableItem(int index)
+char *
+getTableItem(int index)
{
- if( textFile != NULL &&
- index >= 0 &&
- index < textFile->text->count )
- {
- return (char *)textFile->text->list[index];
- }
-
- return NULL;
+ if (textFile != NULL && index >= 0 && index < textFile->text->count) {
+ return (char *) textFile->text->list[index];
+ }
+
+ return NULL;
}
-void quitHeightScore()
+void
+quitHeightScore()
{
- if( textFile != NULL )
- {
- saveTextFile(textFile);
- destroyTextFile(textFile);
- }
+ if (textFile != NULL) {
+ saveTextFile(textFile);
+ destroyTextFile(textFile);
+ }
}