Fixing cppcheck issue. Adding parameter to set first player name.

This commit is contained in:
lotodore
2011-02-25 17:10:02 +00:00
parent b2e0d7c719
commit 9264aa86eb
+5 -3
View File
@@ -38,7 +38,7 @@ namespace po = boost::program_options;
#define BUF_SIZE 1024 #define BUF_SIZE 1024
struct NetSession { struct NetSession {
NetSession(boost::asio::io_service &ioService) : recBufPos(0), socket(ioService) {} NetSession(boost::asio::io_service &ioService) : recBufPos(0), authSession(NULL), socket(ioService) {}
boost::array<char, BUF_SIZE> recBuf; boost::array<char, BUF_SIZE> recBuf;
size_t recBufPos; size_t recBufPos;
boost::array<char, BUF_SIZE> sendBuf; boost::array<char, BUF_SIZE> sendBuf;
@@ -114,6 +114,7 @@ main(int argc, char *argv[])
("server,s", po::value<string>(), "PokerTH server name") ("server,s", po::value<string>(), "PokerTH server name")
("port,P", po::value<string>(), "PokerTH server port") ("port,P", po::value<string>(), "PokerTH server port")
("numGames,n", po::value<unsigned>(), "Number of games to open") ("numGames,n", po::value<unsigned>(), "Number of games to open")
("firstId,f", po::value<int>(), "First id of username testx")
; ;
po::variables_map vm; po::variables_map vm;
@@ -124,7 +125,7 @@ main(int argc, char *argv[])
cout << desc << endl; cout << desc << endl;
return 1; return 1;
} }
if (!vm.count("server") || !vm.count("port") || !vm.count("numGames")) { if (!vm.count("server") || !vm.count("port") || !vm.count("numGames") || !vm.count("firstId")) {
cout << "Missing option!" << endl << desc << endl; cout << "Missing option!" << endl << desc << endl;
return 1; return 1;
} }
@@ -132,6 +133,7 @@ main(int argc, char *argv[])
string server(vm["server"].as<string>()); string server(vm["server"].as<string>());
string port = vm["port"].as<string>(); string port = vm["port"].as<string>();
unsigned numGames = vm["numGames"].as<unsigned>(); unsigned numGames = vm["numGames"].as<unsigned>();
int firstId = vm["firstId"].as<int>();
// Initialise gsasl. // Initialise gsasl.
Gsasl *authContext; Gsasl *authContext;
@@ -193,7 +195,7 @@ main(int argc, char *argv[])
int errorCode = gsasl_client_start(authContext, "SCRAM-SHA-1", &session->authSession); int errorCode = gsasl_client_start(authContext, "SCRAM-SHA-1", &session->authSession);
if (errorCode == GSASL_OK) { if (errorCode == GSASL_OK) {
ostringstream param; ostringstream param;
param << "test" << i + 1; param << "test" << i + firstId;
cout << "User " << param.str() << " logging in." << endl; cout << "User " << param.str() << " logging in." << endl;
session->name = param.str(); session->name = param.str();
gsasl_property_set(session->authSession, GSASL_AUTHID, session->name.c_str()); gsasl_property_set(session->authSession, GSASL_AUTHID, session->name.c_str());