aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2003-03-28 05:51:43 +0000
committerH. Peter Anvin <hpa@zytor.com>2003-03-28 05:51:43 +0000
commit97117a4ed0666afd9bac1b332412a9137487651a (patch)
tree0df8fa396f60e64bdb57c3e5cf4c9ee0f0108547
parente98e408926dda6874d884f13df0682251cd7a08f (diff)
downloadgrv-97117a4ed0666afd9bac1b332412a9137487651a.tar.gz
grv-97117a4ed0666afd9bac1b332412a9137487651a.tar.xz
grv-97117a4ed0666afd9bac1b332412a9137487651a.zip
More fixes for Windows compatibility: avoid %ll formats; fix the new
networking abstraction
-rw-r--r--drawlevel.c4
-rw-r--r--highscore.c12
-rw-r--r--netopen.c10
-rw-r--r--play.c10
-rw-r--r--scoretbl.c26
5 files changed, 34 insertions, 28 deletions
diff --git a/drawlevel.c b/drawlevel.c
index 774d6f9..f6afba8 100644
--- a/drawlevel.c
+++ b/drawlevel.c
@@ -803,7 +803,7 @@ void drawlevel(void)
int e;
levelscreen();
- lprintf(1,1,"SCORE:% lld", gp.Sc);
+ lprintf(1,1,"SCORE:% " PRId64, gp.Sc);
locate(1,18);
color(14,gp.c);
@@ -919,7 +919,7 @@ void drawlevel(void)
void update_score(void)
{
color(0,gp.c);
- lprintf(1,7,"%- 11lld",gp.Sc);
+ lprintf(1,7,"%- 11" PRId64, gp.Sc);
}
void update_shots(void)
diff --git a/highscore.c b/highscore.c
index bd1df34..35ebc9f 100644
--- a/highscore.c
+++ b/highscore.c
@@ -173,10 +173,11 @@ void highscore_show(int myrank, int upload)
lprint(1,15,"THE TOP TEN");
for ( i = 0 ; i < 10 ; i++ ) {
- lprintf(i+4,4,"%2d %-13lld %-9.9s (%2d)",
- i+1, bests.total[i].score,
- bests.total[i].player,
- bests.total[i].endlvl+1);
+ if ( bests.total[i].score )
+ lprintf(i+4,4,"%2d %-13" PRId64 " %-9.9s (%2d)",
+ i+1, bests.total[i].score,
+ bests.total[i].player,
+ bests.total[i].endlvl+1);
if ( i+1 == myrank ) {
color(0,gp.c2);
@@ -211,7 +212,8 @@ void highscore_show(int myrank, int upload)
/* Don't use %3d; we only want the highlight bar to wrap the text,
not spill over. Therefore we need to adjust the starting position
to make the numbers line up... */
- lprintf(x,y+(i < 99), " %d %lld ", i+1, bests.total[i].score);
+ if ( bests.total[i].score )
+ lprintf(x,y+(i < 99), " %d %" PRId64 " ", i+1, bests.total[i].score);
x++;
if ( x > 23 ) {
diff --git a/netopen.c b/netopen.c
index 1beb5ce..94b5bde 100644
--- a/netopen.c
+++ b/netopen.c
@@ -125,7 +125,7 @@ char *fgets_network(char *s, int size, netcon_t nc)
int fputs_network(const char *s, netcon_t nc)
{
int b = strlen(s);
- int sl, btc;
+ int sl;
while ( b ) {
sl = NETCON_BUF - nc->buffill; /* Space left */
@@ -141,20 +141,22 @@ int fputs_network(const char *s, netcon_t nc)
sl = b;
memcpy(nc->bufdata, s, sl);
+
+ nc->buffill += sl;
+ nc->bufdata += sl;
s += sl;
b -= sl;
}
+
+ return 0;
}
netcon_t fopen_network(const char *name, int port, int is_write)
{
struct hostent *he;
SOCKET sock;
- int sock_fd;
- FILE *f;
struct in_addr **haddr;
struct sockaddr_in si;
- int sockopt = SO_SYNCHRONOUS_NONALERT;
struct netcon *nc = malloc(sizeof(struct netcon));
if ( !nc )
diff --git a/play.c b/play.c
index ce73489..b35aaf4 100644
--- a/play.c
+++ b/play.c
@@ -433,7 +433,7 @@ static void move_player_to(int x, int y)
int64_t SSq = gp.Bon ? (int64_t)(gp.Level * exp(6.0*rnd()+3.0)) : 0;
if ( SSq ) {
- message(0, "Bonus: %lld points", SSq);
+ message(0, "Bonus: %" PRId64 " points", SSq);
} else {
message(0, "Sorry, no bonus!!");
}
@@ -623,7 +623,7 @@ static void super_bonus(void)
gp.SBs += SB;
lprintf(8,15,"SUPER BONUS");
- sprintf(buf, "%lld POINTS", SB);
+ sprintf(buf, "%" PRId64 " POINTS", SB);
color(14,4);
lprint(10,21-(strlen(buf)+1)/2,buf);
color(15,4);
@@ -673,14 +673,14 @@ static void end_level(int done)
sbon = (int64_t)( (30000.0*(gp.Level+1))/gp.Tid *
(double)(gp.OrigBar-gp.Bar)/gp.OrigBar +
0.5 );
- lprintf(10, 8, "PERFORMANCE BONUS: %lld", sbon);
+ lprintf(10, 8, "PERFORMANCE BONUS: %" PRId64 , sbon);
gp.Sc += sbon;
lprint(11, 7, "컴컴컴컴컴컴컴컴컴컴컴컴컴컴");
lprintf(12, 8, "TOP PERFORMANCES, LEVEL %d", gp.Level+1);
lprint(20, 8, "YOUR TOTAL SCORE AT THIS");
- lprintf(21, 8, "LEVEL WAS %lld", gp.Sc-gp.StScore);
+ lprintf(21, 8, "LEVEL WAS %" PRId64, gp.Sc-gp.StScore);
/* Show level high scores */
@@ -725,7 +725,7 @@ static void end_level(int done)
int64_t s = bests.level[gp.Level].score[i].score;
color(0,(rank == i+1) ? gp.c : gp.c2);
if ( s )
- lprintf(16+i,21, " %d %lld ", i+1, s);
+ lprintf(16+i,21, " %d %" PRId64 " ", i+1, s);
}
}
diff --git a/scoretbl.c b/scoretbl.c
index c9932b5..7bd3469 100644
--- a/scoretbl.c
+++ b/scoretbl.c
@@ -165,7 +165,7 @@ void highscore_parse(void *f, char (*mygets)(char *, int, void *))
{
char line[MAXLINE], pname[MAXLINE];
uint64_t gameid;
- long long score;
+ int64_t score;
long time_ms;
int lvl;
unsigned char *pptr;
@@ -174,17 +174,17 @@ void highscore_parse(void *f, char (*mygets)(char *, int, void *))
if ( !strchr(line, '\n') )
return; /* Something bogus here... */
- if ( sscanf(line, "TS %llx %lld %d %[0-9a-f]",
+ if ( sscanf(line, "TS %" SCNx64 " %" SCNd64 " %d %[0-9a-f]",
&gameid, &score, &lvl, pname) == 4 ) {
highscore_add_total(gameid, score, lvl-1, &pptr);
if ( pptr ) {
strncpy(pptr, unquote(pname), PLAYER_LEN+1);
pptr[PLAYER_LEN] = '\0';
}
- } else if ( sscanf(line, "LS %llx %d %lld",
+ } else if ( sscanf(line, "LS %" SCNx64 " %d %" SCNd64,
&gameid, &lvl, &score) == 3 ) {
highscore_add_level_score(gameid, lvl-1, score);
- } else if ( sscanf(line, "LT %llx %d %ld",
+ } else if ( sscanf(line, "LT %" SCNx64 " %d %" SCNd32,
&gameid, &lvl, &time_ms) == 3 ) {
highscore_add_level_time(gameid, lvl-1, time_ms);
}
@@ -203,10 +203,10 @@ int highscore_write(void *f, int (*myputs)(char *, void *))
for ( i = 0 ; i < MAX_BEST ; i++ ) {
if ( bests.total[i].score ) {
- sprintf(buffer, "TS %llx %lld %d %s\n", bests.total[i].gameid,
- bests.total[i].score, bests.total[i].endlvl+1,
- quote(bests.total[i].player));
- if ( myputs(buffer, f) )
+ sprintf(buffer, "TS %" PRIx64 " %" PRId64 " %d %s\n",
+ bests.total[i].gameid, bests.total[i].score,
+ bests.total[i].endlvl+1, quote(bests.total[i].player));
+ if ( myputs(buffer, f) == EOF )
return -1;
}
}
@@ -214,16 +214,18 @@ int highscore_write(void *f, int (*myputs)(char *, void *))
for ( i = 0 ; i < MAX_LEVEL ; i++ ) {
for ( j = 0 ; j < MAX_PER_LEVEL ; j++ ) {
if ( bests.level[i].score[j].score )
- sprintf(buffer, "LS %llx %d %lld\n", bests.level[i].score[j].gameid,
+ sprintf(buffer, "LS %" PRIx64 " %d %" PRId64 "\n",
+ bests.level[i].score[j].gameid,
i+1, bests.level[i].score[j].score);
- if ( myputs(buffer, f) )
+ if ( myputs(buffer, f) == EOF )
return -1;
}
for ( j = 0 ; j < MAX_PER_LEVEL ; j++ ) {
if ( bests.level[i].time_ms[j].time_ms != NO_TIME )
- sprintf(f, "LT %llx %d %d\n", bests.level[i].time_ms[j].gameid,
+ sprintf(buffer, "LT %" PRIx64 " %d %" PRId32 "\n",
+ bests.level[i].time_ms[j].gameid,
i+1, bests.level[i].time_ms[j].time_ms);
- if ( myputs(buffer, f) )
+ if ( myputs(buffer, f) == EOF )
return -1;
}
}