aboutsummaryrefslogtreecommitdiffstats
path: root/highscore.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2003-03-25 06:51:28 +0000
committerH. Peter Anvin <hpa@zytor.com>2003-03-25 06:51:28 +0000
commit0be1b930914e6ffbeadd83e3b54d137f60192d8d (patch)
tree72bb89913d2527ede56a535f9551444de928dd67 /highscore.c
parent4ededeb8f873a58c94427bda3bdf6a40ade0a153 (diff)
downloadgrv-0be1b930914e6ffbeadd83e3b54d137f60192d8d.tar.gz
grv-0be1b930914e6ffbeadd83e3b54d137f60192d8d.tar.xz
grv-0be1b930914e6ffbeadd83e3b54d137f60192d8d.zip
Add infrastructure for network highscore server (not ready yet)
Diffstat (limited to 'highscore.c')
-rw-r--r--highscore.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/highscore.c b/highscore.c
new file mode 100644
index 0000000..8db12bc
--- /dev/null
+++ b/highscore.c
@@ -0,0 +1,56 @@
+/*
+ * highscore.c
+ *
+ * Handle uploads and downloads to the highscore database
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+#include "grv.h"
+#include "highscore.h"
+#include "network.h"
+
+static const char score_server[] = "grvscore.zytor.com";
+static int score_port = 22392;
+
+static const char score_file[] = "grvscore.dat";
+
+void highscore_download(void)
+{
+ FILE *f;
+
+ f = fopen(score_file, "r");
+ if ( f ) {
+ highscore_parse(f);
+ fclose(f);
+ }
+
+ if ( !gp.nonet ) {
+ if ( (f = fopen_network(score_server, score_port, 0)) ) {
+ highscore_parse(f);
+ fclose(f);
+ }
+ }
+}
+
+void highscore_upload(void)
+{
+ FILE *f;
+
+ f = fopen(score_file, "w");
+ if ( f ) {
+ highscore_write(f);
+ fclose(f);
+ }
+
+ if ( !gp.nonet ) {
+ if ( (f = fopen_network(score_server, score_port, 1)) ) {
+ highscore_write(f);
+ fclose(f);
+ }
+ }
+}
+