From 01c24f02287dad4137e53e06a340d0acd8013891 Mon Sep 17 00:00:00 2001 From: Rafael Barreto Date: Thu, 19 Aug 2010 19:46:56 +0000 Subject: [PATCH] checking if file system has space to write (linux only), reverting the protocol to make it compatible with 1.1.0.1, tagging AUTH as WiP, tunning the player/bot collision... preparing to release patch git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5656 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/client.cpp | 2 ++ source/src/clients2c.cpp | 4 +++- source/src/physics.cpp | 4 ++-- source/src/protocol.cpp | 2 +- source/src/protocol.h | 4 ++-- source/src/scoreboard.cpp | 15 ++++++++++----- source/src/server.cpp | 25 +++++++++++++++++++------ source/src/server.h | 2 +- source/src/stream.cpp | 19 +++++++++++++++++++ 9 files changed, 59 insertions(+), 18 deletions(-) diff --git a/source/src/client.cpp b/source/src/client.cpp index ef9d7552..98c76c99 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -571,6 +571,7 @@ void gets2c() // get updates from the server } // for AUTH: +/* vector authkeys; VARP(autoauth, 0, 1, 1); @@ -631,6 +632,7 @@ ICOMMANDF(hasauthkey, ARG_2EST, (char *name, char *desc) { return (_hasauthkey(n COMMAND(genauthkey, ARG_1STR); COMMAND(saveauthkeys, ARG_NONE); ICOMMANDF(auth, ARG_1EST, (char *desc) { return tryauth(desc); }); +*/ // :for AUTH // sendmap/getmap commands, should be replaced by more intuitive map downloading diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 211b984f..46687454 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -631,7 +631,8 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) break; } - // for AUTH: + // for AUTH: WIP + /* case SV_AUTHREQ: { extern int autoauth; @@ -655,6 +656,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) } break; } + */ // :for AUTH case SV_GIBDAMAGE: diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 96274a90..a2ab1aa9 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -527,8 +527,8 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) if(pl->type!=ENT_BOUNCE && hitplayer) { vec dr(hitplayer->o.x-pl->o.x,hitplayer->o.y-pl->o.y,0); - float dist = dr.ufmagxy(), - push = (dist > 0.1f ? dr.dotxy(d)*1.1f/dist : dr.dotxy(d) * 11.0f); + float invdist = ufInvSqrt(dr.sqrxy()), + push = (invdist < 10.0f ? dr.dotxy(d)*1.1f*invdist : dr.dotxy(d) * 11.0f); pl->o.x -= f*d.x*push; pl->o.y -= f*d.y*push; diff --git a/source/src/protocol.cpp b/source/src/protocol.cpp index a9ae015e..89245d2e 100644 --- a/source/src/protocol.cpp +++ b/source/src/protocol.cpp @@ -319,7 +319,7 @@ static const int msgsizes[] = // size inclusive message token, 0 f { SV_SERVINFO, 5, SV_WELCOME, 2, SV_INITCLIENT, 0, SV_POS, 0, SV_POSC, 0, SV_POSN, 0, SV_TEXT, 0, SV_TEAMTEXT, 0, SV_TEXTME, 0, SV_TEAMTEXTME, 0, SV_SOUND, 2, SV_VOICECOM, 2, SV_VOICECOMTEAM, 2, SV_CDIS, 2, - SV_SHOOT, 0, SV_EXPLODE, 0, SV_SUICIDE, 1, SV_AKIMBO, 2, SV_RELOAD, 3, SV_AUTHREQ, 0, SV_AUTHTRY, 0, SV_AUTHANS, 0, SV_AUTHCHAL, 0, + SV_SHOOT, 0, SV_EXPLODE, 0, SV_SUICIDE, 1, SV_AKIMBO, 2, SV_RELOAD, 3, SV_AUTHT, 0, /*SV_AUTHREQ, 0, SV_AUTHTRY, 0, SV_AUTHANS, 0, SV_AUTHCHAL, 0,*/ SV_GIBDIED, 5, SV_DIED, 5, SV_GIBDAMAGE, 6, SV_DAMAGE, 6, SV_HITPUSH, 6, SV_SHOTFX, 6, SV_THROWNADE, 8, SV_TRYSPAWN, 1, SV_SPAWNSTATE, 23, SV_SPAWN, 3, SV_SPAWNDENY, 2, SV_FORCEDEATH, 2, SV_RESUME, 0, SV_DISCSCORES, 0, SV_TIMEUP, 2, SV_EDITENT, 10, SV_ITEMACC, 2, diff --git a/source/src/protocol.h b/source/src/protocol.h index 316baa7b..fc357293 100644 --- a/source/src/protocol.h +++ b/source/src/protocol.h @@ -5,7 +5,7 @@ #define CUBE_SERVINFO_PORT_LAN 28762 #define CUBE_SERVINFO_PORT(serverport) (serverport+1) #define CUBE_SERVINFO_TO_SERV_PORT(servinfoport) (servinfoport-1) -#define PROTOCOL_VERSION 1131 // bump when protocol changes (use negative numbers for mods!) +#define PROTOCOL_VERSION 1130 // bump when protocol changes (use negative numbers for mods!) #define DEMO_VERSION 2 // bump when demo format changes #define DEMO_MAGIC "ASSAULTCUBE_DEMO" #define DEMO_MINTIME 10000 // don't keep demo recordings with less than 10 seconds @@ -20,7 +20,7 @@ enum { SV_SERVINFO = 0, SV_WELCOME, SV_INITCLIENT, SV_POS, SV_POSC, SV_POSN, SV_TEXT, SV_TEAMTEXT, SV_TEXTME, SV_TEAMTEXTME, SV_SOUND, SV_VOICECOM, SV_VOICECOMTEAM, SV_CDIS, - SV_SHOOT, SV_EXPLODE, SV_SUICIDE, SV_AKIMBO, SV_RELOAD, SV_AUTHREQ, SV_AUTHTRY, SV_AUTHANS, SV_AUTHCHAL, + SV_SHOOT, SV_EXPLODE, SV_SUICIDE, SV_AKIMBO, SV_RELOAD, SV_AUTHT, /*SV_AUTHREQ, SV_AUTHTRY, SV_AUTHANS, SV_AUTHCHAL,*/ SV_GIBDIED, SV_DIED, SV_GIBDAMAGE, SV_DAMAGE, SV_HITPUSH, SV_SHOTFX, SV_THROWNADE, SV_TRYSPAWN, SV_SPAWNSTATE, SV_SPAWN, SV_SPAWNDENY, SV_FORCEDEATH, SV_RESUME, SV_DISCSCORES, SV_TIMEUP, SV_EDITENT, SV_ITEMACC, diff --git a/source/src/scoreboard.cpp b/source/src/scoreboard.cpp index c9bebf10..a7307070 100644 --- a/source/src/scoreboard.cpp +++ b/source/src/scoreboard.cpp @@ -184,7 +184,9 @@ void renderscore(playerent *d) } } -void renderteamscore(teamscore *t) +int totalplayers = 0; + +int renderteamscore(teamscore *t) { if(!scorelines.empty()) // space between teams { @@ -192,7 +194,8 @@ void renderteamscore(teamscore *t) space.s[0] = 0; } sline &line = scorelines.add(); - defformatstring(plrs)("(%d %s)", t->teammembers.length(), t->teammembers.length() == 1 ? "player" : "players"); + int n = t->teammembers.length(); + defformatstring(plrs)("(%d %s)", n, n == 1 ? "player" : "players"); // float ratio = SCORERATIO(t->frags, t->deaths); switch(orderscorecolumns) { @@ -213,6 +216,7 @@ void renderteamscore(teamscore *t) static color teamcolors[2] = { color(1.0f, 0, 0, 0.2f), color(0, 0, 1.0f, 0.2f) }; line.bgcolor = &teamcolors[team_base(t->team)]; loopv(t->teammembers) renderscore(t->teammembers[i]); + return n; } extern bool watchingdemo; @@ -227,7 +231,8 @@ void renderscores(void *menu, bool init) vector scores; if(!watchingdemo) scores.add(player1); - loopv(players) if(players[i]) scores.add(players[i]); + totalplayers = 1; + loopv(players) if(players[i]) { scores.add(players[i]); totalplayers++; } scores.sort(scorecmp); discscores.sort(discscorecmp); @@ -356,8 +361,8 @@ const char *asciiscores(bool destjpg) if(s) { string sdesc; - filtertext(sdesc, s->sdesc, 1); - formatstring(text)(", %s:%d %s", s->name, s->port, sdesc); + filtertext(sdesc, s->sdesc, 1); + formatstring(text)(", %s:%d %s", s->name, s->port, sdesc); addstr(buf, text); } } diff --git a/source/src/server.cpp b/source/src/server.cpp index 59900611..3e58ae07 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -463,7 +463,7 @@ void enddemorecord() demofile &d = demofiles.add(); formatstring(d.info)("%s: %s, %s, %.2f%s", asctime(), modestr(gamemode), smapname, len > 1024*1024 ? len/(1024*1024.f) : len/1024.0f, len > 1024*1024 ? "MB" : "kB"); //formatstring(d.file)("%s_%s_%s", timestring(), behindpath(smapname), modestr(gamemode, true)); // 20100522_10.08.48_ac_mines_DM.dmo - formatstring(d.file)( "%s_%s_%s", modestr(gamemode, true), behindpath(smapname), timestring( true, "%Y.%m.%d_%H%M")); // DM_ac_mines.2010.05.22_1008.dmo + formatstring(d.file)( "%s_%s_%s", modestr(gamemode, true), behindpath(smapname), timestring( true, "%Y.%m.%d_%H%M")); // DM_ac_mines.2010.05.22_1008.dmo if(mr) { concatformatstring(d.info, ", %d mr", mr); concatformatstring(d.file, "_%dmr", mr); } defformatstring(msg)("Demo \"%s\" recorded\nPress F10 to download it from the server..", d.info); sendservmsg(msg); @@ -1964,7 +1964,7 @@ struct voteinfo if( ( servmillis - callmillis > 10*1000 && stats[VOTE_YES] - stats[VOTE_NO] > 0.34f*total && totalclients > 4 ) || stats[VOTE_YES] > requiredcount*total || admin || adminvote == VOTE_YES ) end(VOTE_YES); - else if(forceend || !valid_client(owner) || stats[VOTE_NO] > requiredcount * total || + else if(forceend || !valid_client(owner) || (boot && !valid_client(boot)) || stats[VOTE_NO] >= stats[VOTE_YES]+stats[VOTE_NEUTRAL] || adminvote == VOTE_NO) end(VOTE_NO); else return; @@ -2181,7 +2181,8 @@ void disconnect_client(int n, int reason) if(*scoresaved && mastermode == MM_MATCH) senddisconnectedscores(-1); } -// for AUTH: +// for AUTH: WIP +/* client *findauth(uint id) { loopv(clients) if(clients[i]->authreq == id) return clients[i]; @@ -2239,6 +2240,7 @@ void answerchallenge(client *cl, uint id, char *val) sendf(cl->clientnum, 1, "ris", SV_SERVMSG, "not connected to authentication server"); } } +*/ // :for AUTH void sendwhois(int sender, int cn) @@ -2911,6 +2913,7 @@ void process(ENetPacket *packet, int sender, int chan) } // for AUTH: + /* case SV_AUTHTRY: { string desc, name; @@ -2929,6 +2932,15 @@ void process(ENetPacket *packet, int sender, int chan) if(!desc[0]) answerchallenge(cl, id, ans); break; } + */ + + case SV_AUTHT: + { +/* int n = getint(p); + loopi(n) getint(p);*/ + if (cl) disconnect_client(cl->clientnum, DISC_TAGT); // remove this in the future, when auth is complete + break; + } // :for AUTH case SV_PING: @@ -3828,12 +3840,13 @@ void localconnect() void processmasterinput(const char *cmd, int cmdlen, const char *args) { - uint id; +// AUTH WiP +// uint id; string val; - if(sscanf(cmd, "failauth %u", &id) == 1) authfailed(id); +/* if(sscanf(cmd, "failauth %u", &id) == 1) authfailed(id); else if(sscanf(cmd, "succauth %u", &id) == 1) authsucceeded(id); else if(sscanf(cmd, "chalauth %u %s", &id, val) == 2) authchallenged(id, val); - else if(!strncmp(cmd, "cleargbans", cmdlen)) cleargbans(); + else*/ if(!strncmp(cmd, "cleargbans", cmdlen)) cleargbans(); else if(sscanf(cmd, "addgban %s", val) == 1) addgban(val); } diff --git a/source/src/server.h b/source/src/server.h index 9ec85b5b..81c53f41 100644 --- a/source/src/server.h +++ b/source/src/server.h @@ -405,7 +405,7 @@ const char *messagenames[SV_NUM] = { "SV_SERVINFO", "SV_WELCOME", "SV_INITCLIENT", "SV_POS", "SV_POSC", "SV_POSN", "SV_TEXT", "SV_TEAMTEXT", "SV_TEXTME", "SV_TEAMTEXTME", "SV_SOUND", "SV_VOICECOM", "SV_VOICECOMTEAM", "SV_CDIS", - "SV_SHOOT", "SV_EXPLODE", "SV_SUICIDE", "SV_AKIMBO", "SV_RELOAD", "SV_AUTHREQ", "SV_AUTHTRY", "SV_AUTHANS", "SV_AUTHCHAL", + "SV_SHOOT", "SV_EXPLODE", "SV_SUICIDE", "SV_AKIMBO", "SV_RELOAD", "SV_AUTHT", /*"SV_AUTHREQ", "SV_AUTHTRY", "SV_AUTHANS", "SV_AUTHCHAL",*/ "SV_GIBDIED", "SV_DIED", "SV_GIBDAMAGE", "SV_DAMAGE", "SV_HITPUSH", "SV_SHOTFX", "SV_THROWNADE", "SV_TRYSPAWN", "SV_SPAWNSTATE", "SV_SPAWN", "SV_SPAWNDENY", "SV_FORCEDEATH", "SV_RESUME", "SV_DISCSCORES", "SV_TIMEUP", "SV_EDITENT", "SV_ITEMACC", diff --git a/source/src/stream.cpp b/source/src/stream.cpp index 47c9faa0..af2eafd8 100644 --- a/source/src/stream.cpp +++ b/source/src/stream.cpp @@ -360,9 +360,16 @@ bool stream::getline(char *str, int len) return true; } +#ifdef __linux__ +#include +#define MINFSSIZE 50000000 // 50MB +#endif + struct filestream : stream { FILE *file; + u_long f_frsize; + fsblkcnt_t f_bavail; filestream() : file(NULL) {} ~filestream() { close(); } @@ -371,6 +378,18 @@ struct filestream : stream { if(file) return false; file = fopen(name, mode); +#ifdef __linux__ + struct statvfs buf; + if(file && strchr(mode,'w')) + { + int fail = fstatvfs(fileno(file), &buf); + if (fail || buf.f_frsize * (buf.f_bavail / 1000) < MINFSSIZE) + { + close(); + return false; + } + } +#endif return file!=NULL; }