Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to not send game version informations #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pvpgn/src/client/bnchat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ typedef struct _user_info
char curr_gamepass[MAX_GAMEPASS_LEN];
int count, clantag;
char const * inviter;
int ignoreversion;

} t_user_info;

Expand Down Expand Up @@ -368,6 +369,7 @@ void usage(char const * progname)
" -o NAME, --owner=NAME report CD owner as NAME\n"
" -k KEY, --cdkey=KEY report CD key as KEY\n"
" -l LANG --lang=LANG report language as LANG (default \"enUS\")\n"
" -i, --ignore-version ignore version request (do not send game version, CD owner/key)\n"
" -h, --help, --usage show this information and exit\n"
" -v, --version print version number and exit\n");
std::exit(EXIT_FAILURE);
Expand All @@ -382,6 +384,7 @@ int read_commandline(int argc, char * * argv,
char const * * cdowner,
char const * * cdkey,
char const * * gamelang,
int * ignoreversion,
int * useansi)
{
int a;
Expand Down Expand Up @@ -636,6 +639,10 @@ int read_commandline(int argc, char * * argv,
std::fprintf(stderr,"%s: option \"%s\" requires an argument\n",argv[0],argv[a]);
usage(argv[0]);
}
else if (std::strcmp(argv[a], "-i")==0 || std::strcmp(argv[a], "--ignore-version")==0)
{
*ignoreversion = 1;
}
else
{
std::fprintf(stderr,"%s: unknown option \"%s\"\n",argv[0],argv[a]);
Expand Down Expand Up @@ -721,9 +728,10 @@ extern int main(int argc, char * argv[])
/* default values */
user.archtag = ARCHTAG_WINX86;
user.gamelang = CLIENT_COUNTRYINFO_109_GAMELANG;
user.ignoreversion = 0;

read_commandline(argc,argv,&servname,&servport,&user.clienttag,&user.archtag,&changepass,
&newacct,&user.channel,&user.cdowner,&user.cdkey,&user.gamelang,&client.useansi);
&newacct,&user.channel,&user.cdowner,&user.cdkey,&user.gamelang,&user.ignoreversion,&client.useansi);

client.fd_stdin = fileno(stdin);
if (tcgetattr(client.fd_stdin,&client.in_attr_old)>=0)
Expand Down Expand Up @@ -771,7 +779,7 @@ extern int main(int argc, char * argv[])
}

if ((client.sd = client_connect(argv[0],
servname,servport,user.cdowner,user.cdkey,user.clienttag,
servname,servport,user.cdowner,user.cdkey,user.clienttag,user.ignoreversion,
&client.saddr,&client.sessionkey,&client.sessionnum,user.archtag,user.gamelang))<0)
{
std::fprintf(stderr,"%s: fatal error during handshake\n",argv[0]);
Expand Down
6 changes: 5 additions & 1 deletion pvpgn/src/client/bnstat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ void usage(char const * progname)
std::fprintf(stderr,
" -o NAME, --owner=NAME report CD owner as NAME\n"
" -k KEY, --cdkey=KEY report CD key as KEY\n"
" -i, --ignore-version ignore version request (do not send game version, CD owner/key)\n"
" -p PLR, --player=PLR print stats for player PLR\n"
" --bnetd also print BNETD-specific stats\n"
" --fsgs also print FSGS-specific stats\n"
Expand Down Expand Up @@ -134,6 +135,7 @@ extern int main(int argc, char * argv[])
int use_fsgs=0;
unsigned int screen_width,screen_height;
int munged=0;
int ignoreversion=0;

if (argc<1 || !argv || !argv[0])
{
Expand Down Expand Up @@ -332,6 +334,8 @@ extern int main(int argc, char * argv[])
else if (std::strcmp(argv[a],"-h")==0 || std::strcmp(argv[a],"--help")==0 || std::strcmp(argv[a],"--usage")
==0)
usage(argv[0]);
else if (std::strcmp(argv[a],"-i")==0 || std::strcmp(argv[a],"--ignore-version")==0)
ignoreversion=1;
else if (std::strcmp(argv[a],"-v")==0 || std::strcmp(argv[a],"--version")==0)
{
std::printf("version "PVPGN_VERSION"\n");
Expand Down Expand Up @@ -388,7 +392,7 @@ extern int main(int argc, char * argv[])
}
}

if ((sd = client_connect(argv[0],servname,servport,cdowner,cdkey,clienttag,&saddr,&sessionkey,&sessionnum,ARCHTAG_WINX86,CLIENT_COUNTRYINFO_109_GAMELANG))<0)
if ((sd = client_connect(argv[0],servname,servport,cdowner,cdkey,clienttag,ignoreversion,&saddr,&sessionkey,&sessionnum,ARCHTAG_WINX86,CLIENT_COUNTRYINFO_109_GAMELANG))<0)
{
std::fprintf(stderr,"%s: fatal error during handshake\n",argv[0]);
if (changed_in)
Expand Down
9 changes: 8 additions & 1 deletion pvpgn/src/client/client_connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ int get_defversioninfo(char const * progname, char const * clienttag, unsigned i
*exeinfo = "";
*checksum = 0;

if (std::strcmp(clienttag,CLIENTTAG_BNCHATBOT)==0)
return 0;

std::fprintf(stderr,"%s: unsupported clienttag \"%s\"\n",progname,clienttag);
// aaron: dunno what we should return in case of this.. but returning nothing was definetly wrong
return -1;
Expand All @@ -155,7 +158,7 @@ namespace pvpgn
namespace client
{

extern int client_connect(char const * progname, char const * servname, unsigned short servport, char const * cdowner, char const * cdkey, char const * clienttag, struct sockaddr_in * saddr, unsigned int * sessionkey, unsigned int * sessionnum, char const * archtag, char const * gamelang)
extern int client_connect(char const * progname, char const * servname, unsigned short servport, char const * cdowner, char const * cdkey, char const * clienttag, int ignoreversion, struct sockaddr_in * saddr, unsigned int * sessionkey, unsigned int * sessionnum, char const * archtag, char const * gamelang)
{
struct hostent * host;
char const * username;
Expand Down Expand Up @@ -329,6 +332,9 @@ extern int client_connect(char const * progname, char const * servname, unsigned
*sessionnum = bn_int_get(rpacket->u.server_authreq_109.sessionnum);
/* FIXME: also get filename and equation */

if (!ignoreversion)
{

if (!(packet = packet_create(packet_class_bnet)))
{
std::fprintf(stderr,"%s: could not create packet\n",progname);
Expand Down Expand Up @@ -369,6 +375,7 @@ extern int client_connect(char const * progname, char const * servname, unsigned
std::fprintf(stderr,"AUTHREPLY_109 failed - closing connection\n");
goto error_rpacket;
}
}
}
else
std::fprintf(stderr,"We didn't get a sessionkey, don't expect login to work!");
Expand Down
2 changes: 1 addition & 1 deletion pvpgn/src/client/client_connect.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace pvpgn
namespace client
{

extern int client_connect(char const * progname, char const * servname, unsigned short servport, char const * cdowner, char const * cdkey, char const * clienttag, struct sockaddr_in * saddr, unsigned int * sessionkey, unsigned int * sessionnum, char const * archtag, char const * gamelang);
extern int client_connect(char const * progname, char const * servname, unsigned short servport, char const * cdowner, char const * cdkey, char const * clienttag, int ignoreversion, struct sockaddr_in * saddr, unsigned int * sessionkey, unsigned int * sessionnum, char const * archtag, char const * gamelang);

}

Expand Down