From 871410044ecbac0d2dd67a7c98f8bcd2df9410eb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 18 Aug 2015 11:49:36 +0000 Subject: - naming conflict; - 64-bit issues; - warning fixes; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@14987 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Xfire/src/Xfire_base.cpp | 81 ++++---- protocols/Xfire/src/Xfire_base.h | 4 +- protocols/Xfire/src/Xfire_game.cpp | 266 +++++++++++++-------------- protocols/Xfire/src/Xfire_game.h | 160 ++++++---------- protocols/Xfire/src/Xfire_gamelist.cpp | 15 +- protocols/Xfire/src/Xfire_voicechat.cpp | 76 ++++---- protocols/Xfire/src/Xfire_voicechat.h | 13 +- protocols/Xfire/src/addgamedialog.cpp | 118 ++++++------ protocols/Xfire/src/dummyxfiregameresolver.h | 41 ++--- protocols/Xfire/src/main.cpp | 118 ++++++------ protocols/Xfire/src/options.cpp | 44 +++-- protocols/Xfire/src/searching4games.cpp | 141 +++++++------- protocols/Xfire/src/sendtypingpacket.cpp | 17 +- protocols/Xfire/src/sendtypingpacket.h | 8 +- protocols/Xfire/src/tools.cpp | 51 ++--- protocols/Xfire/src/variablevalue.cpp | 79 ++++---- protocols/Xfire/src/variablevalue.h | 25 +-- 17 files changed, 577 insertions(+), 680 deletions(-) (limited to 'protocols/Xfire') diff --git a/protocols/Xfire/src/Xfire_base.cpp b/protocols/Xfire/src/Xfire_base.cpp index 47ecf165b7..b5f9d12201 100644 --- a/protocols/Xfire/src/Xfire_base.cpp +++ b/protocols/Xfire/src/Xfire_base.cpp @@ -110,12 +110,12 @@ void Xfire_base::readStringfromDB(char*name, unsigned int dbid, char**to) return; //wert aus der dblesen - mir_snprintf(temp, _countof(temp), "%s_%i", name, dbid); - if (!db_get_s(NULL, protocolname, temp, &dbv)) { + mir_snprintf(m_temp, "%s_%i", name, dbid); + if (!db_get_s(NULL, protocolname, m_temp, &m_dbv)) { //string setzen - setString(dbv.pszVal, to); + setString(m_dbv.pszVal, to); //dbval wieder freigeben - db_free(&dbv); + db_free(&m_dbv); } } @@ -127,12 +127,12 @@ void Xfire_base::readStringfromDB(char*name, unsigned int dbid, int id, char**to return; //wert aus der dblesen - mir_snprintf(temp, _countof(temp), "%s_%i_%i", name, dbid, id); - if (!db_get_s(NULL, protocolname, temp, &dbv)) { + mir_snprintf(m_temp, "%s_%i_%i", name, dbid, id); + if (!db_get_s(NULL, protocolname, m_temp, &m_dbv)) { //string setzen - setString(dbv.pszVal, to); + setString(m_dbv.pszVal, to); //dbval wieder freigeben - db_free(&dbv); + db_free(&m_dbv); } } @@ -144,12 +144,12 @@ void Xfire_base::readUtf8StringfromDB(char*name, unsigned int dbid, char**to) return; //wert aus der dblesen - mir_snprintf(temp, _countof(temp), "%s_%i", name, dbid); - if (!db_get_utf(NULL, protocolname, temp, &dbv)) { + mir_snprintf(m_temp, "%s_%i", name, dbid); + if (!db_get_utf(NULL, protocolname, m_temp, &m_dbv)) { //string setzen - setString(dbv.pszVal, to); + setString(m_dbv.pszVal, to); //dbval wieder freigeben - db_free(&dbv); + db_free(&m_dbv); } } @@ -161,12 +161,12 @@ void Xfire_base::readUtf8StringfromDB(char*name, unsigned int dbid, int id, char return; //wert aus der dblesen - mir_snprintf(temp, _countof(temp), "%s_%i_%i", name, dbid, id); - if (!db_get_utf(NULL, protocolname, temp, &dbv)) { + mir_snprintf(m_temp, "%s_%i_%i", name, dbid, id); + if (!db_get_utf(NULL, protocolname, m_temp, &m_dbv)) { //string setzen - setString(dbv.pszVal, to); + setString(m_dbv.pszVal, to); //dbval wieder freigeben - db_free(&dbv); + db_free(&m_dbv); } } @@ -179,8 +179,8 @@ void Xfire_base::writeStringtoDB(char*name, unsigned int dbid, int id, char*val) return; //wert aus der dblesen - mir_snprintf(temp, _countof(temp), "%s_%i_%i", name, dbid, id); - db_set_s(NULL, protocolname, temp, val); + mir_snprintf(m_temp, "%s_%i_%i", name, dbid, id); + db_set_s(NULL, protocolname, m_temp, val); } //schreibt einen stringval in die db welche unterid hat @@ -191,8 +191,8 @@ void Xfire_base::writeStringtoDB(char*name, unsigned int dbid, char*val) return; //wert aus der dblesen - mir_snprintf(temp, _countof(temp), "%s_%i", name, dbid); - db_set_s(NULL, protocolname, temp, val); + mir_snprintf(m_temp, "%s_%i", name, dbid); + db_set_s(NULL, protocolname, m_temp, val); } //schreibt einen stringval in die db welche unterid hat @@ -203,8 +203,8 @@ void Xfire_base::writeUtf8StringtoDB(char*name, unsigned int dbid, int id, char* return; //wert aus der dblesen - mir_snprintf(temp, _countof(temp), "%s_%i_%i", name, dbid, id); - db_set_utf(NULL, protocolname, temp, val); + mir_snprintf(m_temp, "%s_%i_%i", name, dbid, id); + db_set_utf(NULL, protocolname, m_temp, val); } //schreibt einen stringval in die db welche unterid hat @@ -215,8 +215,8 @@ void Xfire_base::writeUtf8StringtoDB(char*name, unsigned int dbid, char*val) return; //wert aus der dblesen - mir_snprintf(temp, _countof(temp), "%s_%i", name, dbid); - db_set_utf(NULL, protocolname, temp, val); + mir_snprintf(m_temp, "%s_%i", name, dbid); + db_set_utf(NULL, protocolname, m_temp, val); } @@ -228,8 +228,8 @@ void Xfire_base::writeBytetoDB(char*name, unsigned int dbid, int val) return; //wert aus der dblesen - mir_snprintf(temp, _countof(temp), "%s_%i", name, dbid); - db_set_b(NULL, protocolname, temp, val); + mir_snprintf(m_temp, "%s_%i", name, dbid); + db_set_b(NULL, protocolname, m_temp, val); } //schreibt einen wordwert in die db @@ -240,8 +240,8 @@ void Xfire_base::writeWordtoDB(char*name, unsigned int dbid, int val) return; //wert aus der dblesen - mir_snprintf(temp, _countof(temp), "%s_%i", name, dbid); - db_set_w(NULL, protocolname, temp, val); + mir_snprintf(m_temp, "%s_%i", name, dbid); + db_set_w(NULL, protocolname, m_temp, val); } @@ -253,8 +253,8 @@ unsigned char Xfire_base::readBytefromDB(char*name, unsigned int dbid, int defau return 0; //wert aus der dblesen - mir_snprintf(temp, _countof(temp), "%s_%i", name, dbid); - return db_get_b(NULL, protocolname, temp, defaultval); + mir_snprintf(m_temp, "%s_%i", name, dbid); + return db_get_b(NULL, protocolname, m_temp, defaultval); } //liest einen wordval aus der db und gibt es zurück @@ -265,8 +265,8 @@ unsigned int Xfire_base::readWordfromDB(char*name, unsigned int dbid, int defaul return 0; //wert aus der dblesen - mir_snprintf(temp, _countof(temp), "%s_%i", name, dbid); - return db_get_w(NULL, protocolname, temp, defaultval); + mir_snprintf(m_temp, "%s_%i", name, dbid); + return db_get_w(NULL, protocolname, m_temp, defaultval); } //entfernt einen dbeintrag @@ -277,13 +277,12 @@ BOOL Xfire_base::removeDBEntry(char*name, unsigned int dbid) return 0; //wert aus der dblesen - mir_snprintf(temp, _countof(temp), "%s_%i", name, dbid); + mir_snprintf(m_temp, "%s_%i", name, dbid); //eintrag entfernen - if (!db_get(NULL, protocolname, temp, &dbv)) { - db_free(&dbv); - db_unset(NULL, protocolname, temp); - + if (!db_get(NULL, protocolname, m_temp, &m_dbv)) { + db_free(&m_dbv); + db_unset(NULL, protocolname, m_temp); return TRUE; } return FALSE; @@ -297,12 +296,12 @@ BOOL Xfire_base::removeDBEntry(char*name, unsigned int dbid, int id) return 0; //wert aus der dblesen - mir_snprintf(temp, _countof(temp), "%s_%i_%i", name, dbid, id); + mir_snprintf(m_temp, "%s_%i_%i", name, dbid, id); //eintrag entfernen - if (!db_get(NULL, protocolname, temp, &dbv)) { - db_free(&dbv); - db_unset(NULL, protocolname, temp); + if (!db_get(NULL, protocolname, m_temp, &m_dbv)) { + db_free(&m_dbv); + db_unset(NULL, protocolname, m_temp); return TRUE; } diff --git a/protocols/Xfire/src/Xfire_base.h b/protocols/Xfire/src/Xfire_base.h index 717bf38fac..9654c5a50f 100644 --- a/protocols/Xfire/src/Xfire_base.h +++ b/protocols/Xfire/src/Xfire_base.h @@ -41,9 +41,9 @@ extern HANDLE XFireIconFolder; class Xfire_base { private: //vars - DBVARIANT dbv; + DBVARIANT m_dbv; public: - char temp[128]; + char m_temp[128]; //funktionen/tools void setString(char*from, char**to); void appendString(char*from, char**to); diff --git a/protocols/Xfire/src/Xfire_game.cpp b/protocols/Xfire/src/Xfire_game.cpp index d71881d908..186a3c91ec 100644 --- a/protocols/Xfire/src/Xfire_game.cpp +++ b/protocols/Xfire/src/Xfire_game.cpp @@ -7,11 +7,11 @@ BOOL Xfire_game::haveExtraGameArgs() { //kein launcher stirng, dann abbruch - if (!this->launchparams) + if (!m_launchparams) return FALSE; //wenn platzhalter vorhanden, dann TRUE zurück - if (this->inString(this->launchparams, "%UA_LAUNCHER_EXTRA_ARGS%")) + if (inString(m_launchparams, "%UA_LAUNCHER_EXTRA_ARGS%")) return TRUE; return FALSE; @@ -21,18 +21,18 @@ BOOL Xfire_game::haveExtraGameArgs() BOOL Xfire_game::start_game(char*ip, unsigned int port, char*) { //launchparam prüfen ob gefüllt? - if (this->launchparams == NULL) + if (m_launchparams == NULL) return FALSE; //ist launchparam großgenug für eibne urlprüfung? - if (mir_strlen(this->launchparams) > 5) { + if (mir_strlen(m_launchparams) > 5) { //launchparams ne url? dann openurl funktion von miranda verwenden - if (this->launchparams[0] == 'h'&& - this->launchparams[1] == 't'&& - this->launchparams[2] == 't'&& - this->launchparams[3] == 'p'&& - this->launchparams[4] == ':') { - Utils_OpenUrl(this->launchparams); + if (m_launchparams[0] == 'h'&& + m_launchparams[1] == 't'&& + m_launchparams[2] == 't'&& + m_launchparams[3] == 'p'&& + m_launchparams[4] == ':') { + Utils_OpenUrl(m_launchparams); return 0; } } @@ -41,17 +41,17 @@ BOOL Xfire_game::start_game(char*ip, unsigned int port, char*) int networksize = 0; char* mynetworkparams = NULL; - if (this->networkparams) { + if (m_networkparams) { if (ip) { char portstr[6] = ""; int pwsize = 255; //größe des netzwerparams berechnen - if (this->pwparams) - pwsize += mir_strlen(this->pwparams); + if (m_pwparams) + pwsize += mir_strlen(m_pwparams); - mynetworkparams = new char[mir_strlen(this->networkparams) + pwsize]; - strcpy_s(mynetworkparams, mir_strlen(this->networkparams) + pwsize, this->networkparams); + mynetworkparams = new char[mir_strlen(m_networkparams) + pwsize]; + strcpy_s(mynetworkparams, mir_strlen(m_networkparams) + pwsize, m_networkparams); //port begrenzen port = port % 65535; @@ -62,7 +62,7 @@ BOOL Xfire_game::start_game(char*ip, unsigned int port, char*) str_replace(mynetworkparams, "%UA_GAME_HOST_PORT%", portstr); //passwort dialog, nur wenn SHIFT gehalten wird beim join, da sonst immer gefragt wird - if (GetAsyncKeyState(VK_LSHIFT) && this->pwparams) { + if (GetAsyncKeyState(VK_LSHIFT) && m_pwparams) { char password[256] = ""; //passwort maximal 255 zeichen if (ShowPwdDlg(password)) { @@ -70,7 +70,7 @@ BOOL Xfire_game::start_game(char*ip, unsigned int port, char*) //speicher frei? if (mypwargs != NULL) { - strcpy_s(mypwargs, pwsize, this->pwparams); + strcpy_s(mypwargs, pwsize, m_pwparams); str_replace(mypwargs, "%UA_GAME_HOST_PASSWORD%", password); str_replace(mynetworkparams, "%UA_LAUNCHER_PASSWORD_ARGS%", mypwargs); delete[] mypwargs; @@ -90,18 +90,18 @@ BOOL Xfire_game::start_game(char*ip, unsigned int port, char*) } if (mynetworkparams) - networksize = mir_strlen(mynetworkparams) + mir_strlen(this->networkparams); + networksize = mir_strlen(mynetworkparams) + mir_strlen(m_networkparams); } //extra parameter int extraparamssize = 0; - if (this->extraparams) { - extraparamssize = mir_strlen(this->extraparams); + if (m_extraparams) { + extraparamssize = mir_strlen(m_extraparams); } //temporäres array anlegen char*temp = NULL; - temp = new char[mir_strlen(this->launchparams) + networksize + extraparamssize + 1]; + temp = new char[mir_strlen(m_launchparams) + networksize + extraparamssize + 1]; if (temp == NULL) { //wenn nwparams gesetzt, leeren @@ -112,7 +112,7 @@ BOOL Xfire_game::start_game(char*ip, unsigned int port, char*) } //launcherstring ins temporäre array - strcpy_s(temp, mir_strlen(this->launchparams) + 1, this->launchparams); + strcpy_s(temp, mir_strlen(m_launchparams) + 1, m_launchparams); //netzwerkparameter ? if (mynetworkparams) { @@ -122,8 +122,8 @@ BOOL Xfire_game::start_game(char*ip, unsigned int port, char*) else str_replace(temp, "%UA_LAUNCHER_NETWORK_ARGS%", ""); - if (this->extraparams) - str_replace(temp, "%UA_LAUNCHER_EXTRA_ARGS%", this->extraparams); + if (m_extraparams) + str_replace(temp, "%UA_LAUNCHER_EXTRA_ARGS%", m_extraparams); else str_replace(temp, "%UA_LAUNCHER_EXTRA_ARGS%", ""); @@ -171,7 +171,7 @@ BOOL Xfire_game::start_game(char*ip, unsigned int port, char*) BOOL Xfire_game::checkpath(PROCESSENTRY32* processInfo) { //gibts net, weg mit dir - if (this->path == NULL) + if (m_path == NULL) return FALSE; //versuche ein processhandle des speils zubekommen @@ -189,13 +189,13 @@ BOOL Xfire_game::checkpath(PROCESSENTRY32* processInfo) GetLongPathName(fpath, fpath, _countof(fpath)); //alles in kelinbuchstaben umwandeln - this->strtolowerT(fpath); + strtolowerT(fpath); - if (this->wildcmp(_A2T(this->path), fpath)) - //if (mir_strcmp(this->path,fpath)==0) + if (wildcmp(_A2T(m_path), fpath)) + //if (mir_strcmp(m_path,fpath)==0) { //pfad stimmt überein, commandline prüfen - if (checkCommandLine(op, this->mustcontain, this->notcontain)) { + if (checkCommandLine(op, m_mustcontain, m_notcontain)) { //handle zuamachen CloseHandle(op); //positive antwort an die gamedetection @@ -204,11 +204,11 @@ BOOL Xfire_game::checkpath(PROCESSENTRY32* processInfo) } else //prüfe den multipfad { - int size = mpath.size(); + int size = m_mpath.size(); for (int j = 0; j < size; j++) { - if (mir_tstrcmpi(_A2T(mpath.at(j)), fpath) == 0) { + if (mir_tstrcmpi(_A2T(m_mpath.at(j)), fpath) == 0) { //pfad stimmt überein, commandline prüfen - if (checkCommandLine(op, this->mustcontain, this->notcontain)) { + if (checkCommandLine(op, m_mustcontain, m_notcontain)) { //handle zumachen CloseHandle(op); //positive antwort an die gamedetection @@ -220,35 +220,27 @@ BOOL Xfire_game::checkpath(PROCESSENTRY32* processInfo) //is nich das game, handle zumachen CloseHandle(op); } - else //if (this->mustcontain==NULL&&this->notcontain==NULL) //spiele die was bestimmtes im pfad benötigen skippen + else //if (m_mustcontain==NULL&&m_notcontain==NULL) //spiele die was bestimmtes im pfad benötigen skippen { - char* exename = strrchr(this->path, '\\') + 1; - - //kleiner fix bei fehlerhaften pfaden kann keine exe ermittelt werden also SKIP - if ((unsigned int)exename == 0x1) + char *exename = strrchr(m_path, '\\') + 1; + if ((INT_PTR)exename == 0x1) return FALSE; //vergleich die exenamen - if (_stricmp(exename, _T2A(processInfo->szExeFile)) == 0) { + if (_stricmp(exename, _T2A(processInfo->szExeFile)) == 0) return TRUE; - } - else //anderen pfade des games noch durchprüfen - { - int size = mpath.size(); - for (int j = 0; j < size; j++) { - //exenamen rausfischen - char* exename = strrchr(mpath.at(j), '\\') + 1; - //mhn keien exe, nächsten pfad prüfen - if ((unsigned int)exename == 0x1) - continue; + //anderen pfade des games noch durchprüfen + int size = m_mpath.size(); + for (int j = 0; j < size; j++) { + //mhn keien exe, nächsten pfad prüfen + exename = strrchr(m_mpath.at(j), '\\') + 1; + if ((INT_PTR)exename == 0x1) + continue; - //exe vergleichen - if (_stricmp(exename, _T2A(processInfo->szExeFile)) == 0) { - //positive antwort an die gamedetection - return TRUE; - } - } + //exe vergleichen + if (_stricmp(exename, _T2A(processInfo->szExeFile)) == 0) //positive antwort an die gamedetection + return TRUE; } } @@ -259,21 +251,21 @@ BOOL Xfire_game::checkpath(PROCESSENTRY32* processInfo) //icondaten setzen void Xfire_game::setIcon(HICON hicon, HANDLE handle) { - this->hicon = hicon; - this->iconhandl = handle; + m_hicon = hicon; + m_iconhandl = handle; } //liest gamewerte aus der db void Xfire_game::readFromDB(unsigned dbid) { //lese alle string werte aus der db und befülle die passenden variablen damit - this->readStringfromDB("gamepath", dbid, &this->path); + this->readStringfromDB("gamepath", dbid, &m_path); //8.3 fix, prüfe auf ~ pfad, wenn ja pfad var umwalnd in longname - if (this->path) { + if (m_path) { BOOL found = FALSE; - for (unsigned int i = 0; i < mir_strlen(this->path); i++) { - if (this->path[i] == '~') { + for (unsigned int i = 0; i < mir_strlen(m_path); i++) { + if (m_path[i] == '~') { found = TRUE; break; } @@ -281,33 +273,33 @@ void Xfire_game::readFromDB(unsigned dbid) //gefunden? dann stirng wandeln und in pfad speichern if (found) { char ctemp[MAX_PATH] = ""; - strcpy_s(ctemp, MAX_PATH, this->path); + strcpy_s(ctemp, MAX_PATH, m_path); GetLongPathNameA(ctemp, ctemp, sizeof(ctemp)); this->strtolower(ctemp); - this->setString(ctemp, &this->path); + setString(ctemp, &m_path); } } - this->readStringfromDB("gamelaunch", dbid, &this->launchparams); - this->readStringfromDB("gamenetargs", dbid, &this->networkparams); - this->readStringfromDB("gamepwargs", dbid, &this->pwparams); - this->readStringfromDB("gameuserargs", dbid, &this->userparams); - this->readStringfromDB("gamecmdline", dbid, &this->mustcontain); - this->readStringfromDB("gamencmdline", dbid, &this->notcontain); + readStringfromDB("gamelaunch", dbid, &m_launchparams); + readStringfromDB("gamenetargs", dbid, &m_networkparams); + readStringfromDB("gamepwargs", dbid, &m_pwparams); + readStringfromDB("gameuserargs", dbid, &m_userparams); + readStringfromDB("gamecmdline", dbid, &m_mustcontain); + readStringfromDB("gamencmdline", dbid, &m_notcontain); //alle sonstigen werte - this->id = this->readWordfromDB("gameid", dbid); - this->send_gameid = this->readWordfromDB("gamesendid", dbid); - if (this->send_gameid == 0) - this->send_gameid = this->id; - this->setstatusmsg = this->readWordfromDB("gamesetsmsg", dbid, 0); - this->custom = this->readBytefromDB("gamecustom", dbid, 0); - this->skip = this->readBytefromDB("gameskip", this->id, 0); - this->notinstartmenu = this->readBytefromDB("notinstartmenu", this->id, 0); - this->noicqstatus = this->readBytefromDB("gamenostatus", this->id, 0); - this->readStringfromDB("gameextraparams", this->id, &this->extraparams); - this->readStringfromDB("customgamename", this->id, &this->customgamename); - this->readUtf8StringfromDB("statusmsg", this->id, &this->statusmsg); + m_id = this->readWordfromDB("gameid", dbid); + m_send_gameid = this->readWordfromDB("gamesendid", dbid); + if (m_send_gameid == 0) + m_send_gameid = m_id; + m_setstatusmsg = this->readWordfromDB("gamesetsmsg", dbid, 0); + m_custom = this->readBytefromDB("gamecustom", dbid, 0); + m_skip = this->readBytefromDB("gameskip", m_id, 0); + m_notinstartmenu = this->readBytefromDB("notinstartmenu", m_id, 0); + m_noicqstatus = this->readBytefromDB("gamenostatus", m_id, 0); + readStringfromDB("gameextraparams", m_id, &m_extraparams); + readStringfromDB("customgamename", m_id, &m_customgamename); + this->readUtf8StringfromDB("statusmsg", m_id, &m_statusmsg); //mehrere pfade int size = this->readWordfromDB("gamemulti", dbid, 0); @@ -316,7 +308,7 @@ void Xfire_game::readFromDB(unsigned dbid) this->readStringfromDB("gamepath", dbid, j, &tpath); if (tpath) { - mpath.push_back(tpath); + m_mpath.push_back(tpath); } } @@ -327,17 +319,17 @@ void Xfire_game::readFromDB(unsigned dbid) //läd spielnamen aus, sowie icon void Xfire_game::setNameandIcon() { - if (this->customgamename) { - this->setString(this->customgamename, &this->name); + if (m_customgamename) { + setString(m_customgamename, &m_name); } else { - //std::string game=GetGame(this->id,0,&this->iconhandl,&this->hicon,TRUE); + //std::string game=GetGame(m_id,0,&m_iconhandl,&m_hicon,TRUE); //zielbuffer für den namen char buf[XFIRE_MAXSIZEOFGAMENAME] = "Unknown Game"; //name des spiels auslesen - this->getGamename(this->id, buf, XFIRE_MAXSIZEOFGAMENAME); + this->getGamename(m_id, buf, XFIRE_MAXSIZEOFGAMENAME); //namen setzen - this->setString(buf, &this->name); + setString(buf, &m_name); } } @@ -345,62 +337,60 @@ void Xfire_game::setNameandIcon() void Xfire_game::writeToDB(unsigned dbid) { //alle stringwerte schreiben - this->writeStringtoDB("gamepath", dbid, this->path); - this->writeStringtoDB("gamelaunch", dbid, this->launchparams); - this->writeStringtoDB("gamenetargs", dbid, this->networkparams); - this->writeStringtoDB("gamepwargs", dbid, this->pwparams); - this->writeStringtoDB("gameuserargs", dbid, this->userparams); - this->writeStringtoDB("gamecmdline", dbid, this->mustcontain); - this->writeStringtoDB("gamencmdline", dbid, this->notcontain); + writeStringtoDB("gamepath", dbid, m_path); + writeStringtoDB("gamelaunch", dbid, m_launchparams); + writeStringtoDB("gamenetargs", dbid, m_networkparams); + writeStringtoDB("gamepwargs", dbid, m_pwparams); + writeStringtoDB("gameuserargs", dbid, m_userparams); + writeStringtoDB("gamecmdline", dbid, m_mustcontain); + writeStringtoDB("gamencmdline", dbid, m_notcontain); //alle sonstigen werte - this->writeWordtoDB("gameid", dbid, this->id); - if (this->send_gameid != 0 && this->send_gameid != this->id) this->writeWordtoDB("gamesendid", dbid, this->send_gameid); - if (this->setstatusmsg != 0) this->writeWordtoDB("gamesetsmsg", dbid, this->setstatusmsg); - if (this->custom != 0) this->writeBytetoDB("gamecustom", dbid, this->custom); + this->writeWordtoDB("gameid", dbid, m_id); + if (m_send_gameid != 0 && m_send_gameid != m_id) this->writeWordtoDB("gamesendid", dbid, m_send_gameid); + if (m_setstatusmsg != 0) writeWordtoDB("gamesetsmsg", dbid, m_setstatusmsg); + if (m_custom != 0) writeBytetoDB("gamecustom", dbid, m_custom); //wenn gesetzt, dann eintrag machen - if (this->skip != 0) - this->writeBytetoDB("gameskip", this->id, this->skip); + if (m_skip != 0) + writeBytetoDB("gameskip", m_id, m_skip); else //wenn nicht eintrag aus db löschen - this->removeDBEntry("gameskip", this->id); - if (this->notinstartmenu != 0) - this->writeBytetoDB("notinstartmenu", this->id, this->notinstartmenu); + removeDBEntry("gameskip", m_id); + if (m_notinstartmenu != 0) + writeBytetoDB("notinstartmenu", m_id, m_notinstartmenu); else //wenn nicht eintrag aus db löschen - this->removeDBEntry("notinstartmenu", this->id); - if (this->noicqstatus != 0) - this->writeBytetoDB("gamenostatus", this->id, this->noicqstatus); + removeDBEntry("notinstartmenu", m_id); + if (m_noicqstatus != 0) + writeBytetoDB("gamenostatus", m_id, m_noicqstatus); else //wenn nicht eintrag aus db löschen - this->removeDBEntry("gamenostatus", this->id); - if (this->extraparams != 0) - this->writeStringtoDB("gameextraparams", this->id, this->extraparams); + removeDBEntry("gamenostatus", m_id); + if (m_extraparams != 0) + writeStringtoDB("gameextraparams", m_id, m_extraparams); else //wenn nicht eintrag aus db löschen - this->removeDBEntry("gameextraparams", this->id); - if (this->customgamename != 0) - this->writeStringtoDB("customgamename", this->id, this->customgamename); + removeDBEntry("gameextraparams", m_id); + if (m_customgamename != 0) + writeStringtoDB("customgamename", m_id, m_customgamename); else //wenn nicht eintrag aus db löschen - this->removeDBEntry("customgamename", this->id); - if (this->statusmsg != 0) - this->writeUtf8StringtoDB("statusmsg", this->id, this->statusmsg); + removeDBEntry("customgamename", m_id); + if (m_statusmsg != 0) + this->writeUtf8StringtoDB("statusmsg", m_id, m_statusmsg); else //wenn nicht eintrag aus db löschen - this->removeDBEntry("statusmsg", this->id); - + removeDBEntry("statusmsg", m_id); - - //mehrere pfade - int size = mpath.size(); + // mehrere pfade + int size = m_mpath.size(); if (size > 0) { - this->writeWordtoDB("gamemulti", dbid, mpath.size()); + this->writeWordtoDB("gamemulti", dbid, m_mpath.size()); for (int j = 0; j < size; j++) { - this->writeStringtoDB("gamepath", dbid, j, mpath.at(j)); + writeStringtoDB("gamepath", dbid, j, m_mpath.at(j)); } } - //sendid 0 dann standard id reinladen - if (this->send_gameid == 0) - this->send_gameid = this->id; + // sendid 0 dann standard id reinladen + if (m_send_gameid == 0) + m_send_gameid = m_id; } -//erzeugt ein menüpunkt +// erzeugt ein menüpunkt void Xfire_game::createMenuitem(unsigned int pos, int dbid) { char servicefunction[100]; @@ -413,16 +403,16 @@ void Xfire_game::createMenuitem(unsigned int pos, int dbid) CMenuItem mi; mi.root = Menu_CreateRoot(MO_MAIN, LPGENT("Start game"), 500084000); - mir_snprintf(temp, _countof(temp), servicefunction, this->id); + mir_snprintf(m_temp, _countof(m_temp), servicefunction, m_id); //wenn die servicefunktion schon exisitert vernichten, hehe - if (ServiceExists(temp)) - DestroyServiceFunction(temp); - CreateServiceFunctionParam(temp, StartGame, this->id); - mi.pszService = temp; + if (ServiceExists(m_temp)) + DestroyServiceFunction(m_temp); + CreateServiceFunctionParam(m_temp, StartGame, m_id); + mi.pszService = m_temp; mi.position = 500090002 + pos; - mi.hIcolibItem = this->hicon ? this->hicon : LoadIcon(hinstance, MAKEINTRESOURCE(ID_OP)); - mi.name.a = menuitemtext(this->name); - this->menuhandle = Menu_AddMainMenuItem(&mi); + mi.hIcolibItem = m_hicon ? m_hicon : LoadIcon(hinstance, MAKEINTRESOURCE(ID_OP)); + mi.name.a = menuitemtext(m_name); + m_menuhandle = Menu_AddMainMenuItem(&mi); //menu aktualisieren ob hidden this->refreshMenuitem(); @@ -431,15 +421,15 @@ void Xfire_game::createMenuitem(unsigned int pos, int dbid) //entfernt menüpunkt void Xfire_game::remoteMenuitem() { - if (menuhandle != NULL) { - Menu_RemoveItem(menuhandle); - menuhandle = NULL; + if (m_menuhandle != NULL) { + Menu_RemoveItem(m_menuhandle); + m_menuhandle = NULL; } } //aktualisiert menüpunkt ob hidden void Xfire_game::refreshMenuitem() { - if (menuhandle != NULL) - Menu_ShowItem(menuhandle, !this->notinstartmenu); + if (m_menuhandle != NULL) + Menu_ShowItem(m_menuhandle, !m_notinstartmenu); } \ No newline at end of file diff --git a/protocols/Xfire/src/Xfire_game.h b/protocols/Xfire/src/Xfire_game.h index f4e36c4155..3a1087c4be 100644 --- a/protocols/Xfire/src/Xfire_game.h +++ b/protocols/Xfire/src/Xfire_game.h @@ -38,141 +38,99 @@ using namespace std; //externe funktion die das spielstarten steuern extern INT_PTR StartGame(WPARAM wParam, LPARAM lParam, LPARAM fParam); -class Xfire_game : public Xfire_base { +class Xfire_game : public Xfire_base +{ public: //id des spiels - unsigned int id; + unsigned int m_id; //handle des menuitems - HGENMENU menuhandle; + HGENMENU m_menuhandle; //spiel soll bei der detection übersprungen werden - BOOL skip; + BOOL m_skip; //voicehat? - BOOL voicechat; + BOOL m_voicechat; //es soll kein icq und co status gesetzt werden - BOOL noicqstatus; + BOOL m_noicqstatus; //handelt es sich um ein "custom" spiel - BOOL custom; + BOOL m_custom; //soll ein spez. status gesetzt werden - BOOL setstatusmsg; + BOOL m_setstatusmsg; //iconhandle von miranda - HANDLE iconhandl; + HANDLE m_iconhandl; //hicon vom icon des spiels - HICON hicon; + HICON m_hicon; //dont show in startmenü - BOOL notinstartmenu; + BOOL m_notinstartmenu; //pfad des spiels wenn es laufen sollte - char* path; + char* m_path; //startparameter des spiels - char* launchparams; + char* m_launchparams; //netzwerkparameter - char* networkparams; + char* m_networkparams; //username parameter - char* userparams; + char* m_userparams; //passwort paramter - char* pwparams; + char* m_pwparams; //mustcontain parameter - char* mustcontain; + char* m_mustcontain; //notcontain parameter - char* notcontain; + char* m_notcontain; //spielname - char* name; + char* m_name; //extraparameter - char* extraparams; + char* m_extraparams; //custom gamename - char* customgamename; + char* m_customgamename; //custom statusmsg for xfire - char* statusmsg; + char* m_statusmsg; //mehrere pfade - vector mpath; + vector m_mpath; //zu sende gameid - signed short send_gameid; + signed short m_send_gameid; //konstruktor - Xfire_game() { + Xfire_game() + { //vars leer setzen - path = NULL; - launchparams = NULL; - networkparams = NULL; - userparams = NULL; - pwparams = NULL; - mustcontain = NULL; - notcontain = NULL; - name = NULL; - menuhandle = NULL; - iconhandl = NULL; - hicon = NULL; - extraparams = NULL; - customgamename = NULL; - statusmsg = NULL; - id = skip = noicqstatus = custom = setstatusmsg = send_gameid = notinstartmenu = voicechat = 0; + m_path = NULL; + m_launchparams = NULL; + m_networkparams = NULL; + m_userparams = NULL; + m_pwparams = NULL; + m_mustcontain = NULL; + m_notcontain = NULL; + m_name = NULL; + m_menuhandle = NULL; + m_iconhandl = NULL; + m_hicon = NULL; + m_extraparams = NULL; + m_customgamename = NULL; + m_statusmsg = NULL; + m_id = m_skip = m_noicqstatus = m_custom = m_setstatusmsg = m_send_gameid = m_notinstartmenu = m_voicechat = 0; } //dekonstruktor - ~Xfire_game() { + ~Xfire_game() + { //entferne dyn arrays - if (path) - { - delete[] path; - path = NULL; - } - if (launchparams) - { - delete[] launchparams; - launchparams = NULL; - } - if (networkparams) - { - delete[] networkparams; - networkparams = NULL; - } - if (userparams) - { - delete[] userparams; - userparams = NULL; - } - if (pwparams) - { - delete[] pwparams; - pwparams = NULL; - } - if (mustcontain) - { - delete[] mustcontain; - mustcontain = NULL; - } - if (notcontain) - { - delete[] notcontain; - notcontain = NULL; - } - if (name) - { - delete[] name; - name = NULL; - } - if (extraparams) - { - delete[] extraparams; - extraparams = NULL; - } - if (customgamename) - { - delete[] customgamename; - customgamename = NULL; - } - if (statusmsg) - { - delete[] statusmsg; - statusmsg = NULL; - } + delete[] m_path; + delete[] m_launchparams; + delete[] m_networkparams; + delete[] m_userparams; + delete[] m_pwparams; + delete[] m_mustcontain; + delete[] m_notcontain; + delete[] m_name; + delete[] m_extraparams; + delete[] m_customgamename; + delete[] m_statusmsg; - for (unsigned int i = 0; i < mpath.size(); i++) { - if (mpath.at(i) != NULL) - delete mpath.at(i); - } - mpath.clear(); + for (unsigned int i = 0; i < m_mpath.size(); i++) + if (m_mpath.at(i) != NULL) + delete m_mpath.at(i); + m_mpath.clear(); remoteMenuitem(); } diff --git a/protocols/Xfire/src/Xfire_gamelist.cpp b/protocols/Xfire/src/Xfire_gamelist.cpp index c9b3340e03..4a71684947 100644 --- a/protocols/Xfire/src/Xfire_gamelist.cpp +++ b/protocols/Xfire/src/Xfire_gamelist.cpp @@ -16,7 +16,7 @@ Xfire_game* Xfire_gamelist::getGamebyGameid(unsigned int gameid) { for (unsigned int i = 0; i < gamelist.size(); i++) { Xfire_game* game = (Xfire_game*)gamelist.at(i); - if (game->id == gameid) + if (game->m_id == gameid) return game; } return NULL; @@ -33,7 +33,7 @@ void Xfire_gamelist::readGamelist(int anz) //lese das spiel ein game->readFromDB(i); //icons laden - Xfire_icon_cache icon = this->iconmngr.getGameIconEntry(game->id); + Xfire_icon_cache icon = this->iconmngr.getGameIconEntry(game->m_id); game->setIcon(icon.hicon, icon.handle); //in die liste einfügen gamelist.push_back(game); @@ -76,9 +76,8 @@ BOOL Xfire_gamelist::getnextGame(Xfire_game**currentgame) nextgameid++; //muss das spiel geskippt werden, dann nochmal funktion aufrufen um das nächste game zubekommen - if ((*currentgame)->skip || (*currentgame)->id == 32 || (*currentgame)->id == 33 || (*currentgame)->id == 34 || (*currentgame)->id == 35) { + if ((*currentgame)->m_skip || (*currentgame)->m_id == 32 || (*currentgame)->m_id == 33 || (*currentgame)->m_id == 34 || (*currentgame)->m_id == 35) return getnextGame(currentgame); - } return TRUE; } @@ -99,7 +98,7 @@ void Xfire_gamelist::Block(BOOL block) void Xfire_gamelist::Addgame(Xfire_game* newgame) { //spielicon auslesen - Xfire_icon_cache icon = this->iconmngr.getGameIconEntry(newgame->id); + Xfire_icon_cache icon = this->iconmngr.getGameIconEntry(newgame->m_id); newgame->setIcon(icon.hicon, icon.handle); gamelist.push_back(newgame); @@ -110,7 +109,7 @@ BOOL Xfire_gamelist::Removegame(int id) { std::vector::iterator i = gamelist.begin(); while (i != gamelist.end()) { - if ((*i)->id == id) { + if ((*i)->m_id == (unsigned)id) { (*i)->remoteMenuitem(); gamelist.erase(i); return TRUE; @@ -149,7 +148,7 @@ void Xfire_gamelist::createStartmenu() Xfire_game* game = (Xfire_game*)gamelist.at(sorttemp[i - 1]); Xfire_game* game2 = (Xfire_game*)gamelist.at(sorttemp[i]); //sortieren - if (mir_strcmp(game->name, game2->name) > 0) { + if (mir_strcmp(game->m_name, game2->m_name) > 0) { int tempi = sorttemp[i - 1]; sorttemp[i - 1] = sorttemp[i]; sorttemp[i] = tempi; @@ -189,7 +188,7 @@ BOOL Xfire_gamelist::Gameinlist(int id, int*dbid) for (unsigned int i = 0; i < gamelist.size(); i++) { Xfire_game* game = (Xfire_game*)gamelist.at(i); if (game) { - if (game->id == id) { + if (int(game->m_id) == id) { //soll eine dbid zurückgeliefert werden? dann setzen if (dbid) *dbid = i; diff --git a/protocols/Xfire/src/Xfire_voicechat.cpp b/protocols/Xfire/src/Xfire_voicechat.cpp index acca27d1c9..732fa359ca 100644 --- a/protocols/Xfire/src/Xfire_voicechat.cpp +++ b/protocols/Xfire/src/Xfire_voicechat.cpp @@ -4,20 +4,20 @@ //konstruktor Xfire_voicechat::Xfire_voicechat() { - this->resetCurrentvoicestatus(); - ipport = NULL; - tsrDLL = NULL; - tsrGetServerInfo = NULL; - pid = 0; + resetCurrentvoicestatus(); + m_ipport = NULL; + m_tsrDLL = NULL; + m_tsrGetServerInfo = NULL; + m_pid = 0; } //dekonstruktor Xfire_voicechat::~Xfire_voicechat() { //geladene tsr remote dll freigeben - if (tsrDLL) { - FreeLibrary(tsrDLL); - tsrDLL = NULL; + if (m_tsrDLL) { + FreeLibrary(m_tsrDLL); + m_tsrDLL = NULL; } } @@ -25,7 +25,7 @@ Xfire_voicechat::~Xfire_voicechat() void Xfire_voicechat::initVoicechat() { //tsremotedll laden - tsrDLL = this->loadTSR(); + m_tsrDLL = loadTSR(); } //prüft ob das paket schonmal versendet wurde, soll unnötigen nwtraffic reduzieren, *ÜBERLEGUNG* ob wirklich notwendig @@ -34,12 +34,13 @@ BOOL Xfire_voicechat::alreadySend(SendGameStatus2Packet* packet) if (packet == NULL) return FALSE; - if (packet->ip[3] != lastpacket.ip[3] || - packet->ip[2] != lastpacket.ip[2] || - packet->ip[1] != lastpacket.ip[1] || - packet->ip[0] != lastpacket.ip[0] || - packet->port != lastpacket.port) { - lastpacket = *packet; + if (packet->ip[3] != m_lastpacket.ip[3] || + packet->ip[2] != m_lastpacket.ip[2] || + packet->ip[1] != m_lastpacket.ip[1] || + packet->ip[0] != m_lastpacket.ip[0] || + packet->port != m_lastpacket.port) + { + m_lastpacket = *packet; return TRUE; } @@ -53,7 +54,7 @@ BOOL Xfire_voicechat::checkVoicechat(SendGameStatus2Packet* packet) if (packet == NULL) return FALSE; //jeh nach letzten status handeln - switch (currentvoice) { + switch (m_currentvoice) { case XFIREVOICECHAT_TS2: if (checkforTS2(packet)) { return alreadySend(packet); @@ -115,13 +116,13 @@ BOOL Xfire_voicechat::checkVoicechat(SendGameStatus2Packet* packet) //setzte currentvoice auf 0 zurück, falls es einen disconnect gab void Xfire_voicechat::resetCurrentvoicestatus() { - currentvoice = XFIREVOICECHAT_NOVOICE; - lastpacket.ip[3] = 0; - lastpacket.ip[2] = 0; - lastpacket.ip[1] = 0; - lastpacket.ip[0] = 0; - lastpacket.port = 0; - pid = 0; + m_currentvoice = XFIREVOICECHAT_NOVOICE; + m_lastpacket.ip[3] = 0; + m_lastpacket.ip[2] = 0; + m_lastpacket.ip[1] = 0; + m_lastpacket.ip[0] = 0; + m_lastpacket.port = 0; + m_pid = 0; } //resettet das packet auf 0 @@ -211,7 +212,7 @@ HMODULE Xfire_voicechat::loadTSR(char*, BOOL nolocaltest) XFireLog("TSRemote.dll successfully loaded!"); //getserverinfo funktion holen - tsrGetServerInfo = (LPtsrGetServerInfo)GetProcAddress(tsrDLL, "tsrGetServerInfo"); + m_tsrGetServerInfo = (LPtsrGetServerInfo)GetProcAddress(tsrDLL, "tsrGetServerInfo"); return tsrDLL; } @@ -249,7 +250,7 @@ BOOL Xfire_voicechat::checkforTS3(SendGameStatus2Packet *packet) } //voiceid zuweisen - this->currentvoice = XFIREVOICECHAT_TS3; + m_currentvoice = XFIREVOICECHAT_TS3; packet->gameid = XFIREVOICECHAT_TS3; //ip zuweisen packet->ip[3] = ipport->ip[3]; @@ -273,20 +274,18 @@ BOOL Xfire_voicechat::checkforTS2(SendGameStatus2Packet* packet) TtsrServerInfo serverinfo = { 0 }; //get funktion ist nicht initialisiert - if (this->tsrGetServerInfo == NULL || packet == NULL) { + if (m_tsrGetServerInfo == NULL || packet == NULL) return FALSE; - } //infos holen - this->tsrGetServerInfo(&serverinfo); + m_tsrGetServerInfo(&serverinfo); //auswerten wenn serverip gesetzt if (serverinfo.ServerIp[0] != 0) { char * pos = strrchr(serverinfo.ServerIp, ':'); - if (pos == 0) { + if (pos == 0) return FALSE; - } - + *pos = 0; unsigned int ip = inet_addr(serverinfo.ServerIp); pos++; @@ -299,12 +298,13 @@ BOOL Xfire_voicechat::checkforTS2(SendGameStatus2Packet* packet) packet->ip[2] = HIBYTE(LOWORD(ip)); packet->ip[1] = LOBYTE(HIWORD(ip)); packet->ip[0] = HIBYTE(HIWORD(ip)); + //gameid/voice zuweisen packet->gameid = XFIREVOICECHAT_TS2; - this->currentvoice = XFIREVOICECHAT_TS2; + m_currentvoice = XFIREVOICECHAT_TS2; + //ab in die db writeToDatabase(packet); - return TRUE; } @@ -319,12 +319,12 @@ BOOL Xfire_voicechat::checkforMumble(SendGameStatus2Packet* packet) return FALSE; //gültige pid - if (this->pid != 0 && !this->isValidPid(this->pid)) { - this->pid = 0; + if (m_pid != 0 && !this->isValidPid(m_pid)) { + m_pid = 0; return FALSE; } else { - if (!this->getPidByProcessName(_T("mumble.exe"), &this->pid)) { + if (!this->getPidByProcessName(_T("mumble.exe"), &m_pid)) { return FALSE; } } @@ -338,7 +338,7 @@ BOOL Xfire_voicechat::checkforMumble(SendGameStatus2Packet* packet) //liste auslesen if (GetExtendedTcpTable(ptab, &size, FALSE, AF_INET, TCP_TABLE_OWNER_PID_CONNECTIONS, 0) == NO_ERROR) { for (unsigned int i = 0; i < ptab->dwNumEntries; i++) { - if (ptab->table[i].dwOwningPid == this->pid && ptab->table[i].dwLocalAddr != ptab->table[i].dwRemoteAddr) //verbindung gefunden, hoffentlich + if (ptab->table[i].dwOwningPid == m_pid && ptab->table[i].dwLocalAddr != ptab->table[i].dwRemoteAddr) //verbindung gefunden, hoffentlich { unsigned char*rip = (unsigned char*)&ptab->table[i].dwRemoteAddr; XFireLog("IP %x,%x", ptab->table[i].dwRemoteAddr, ptab->table[i].dwRemotePort); @@ -351,7 +351,7 @@ BOOL Xfire_voicechat::checkforMumble(SendGameStatus2Packet* packet) packet->port = r(ptab->table[i].dwRemotePort); //mumble packet->gameid = XFIREVOICECHAT_MUMBLE; - this->currentvoice = XFIREVOICECHAT_MUMBLE; + m_currentvoice = XFIREVOICECHAT_MUMBLE; //table wieder freigeben free(ptab); //mumble läuft + ip gefunden also TRUE diff --git a/protocols/Xfire/src/Xfire_voicechat.h b/protocols/Xfire/src/Xfire_voicechat.h index 22da7485bc..c07997770d 100644 --- a/protocols/Xfire/src/Xfire_voicechat.h +++ b/protocols/Xfire/src/Xfire_voicechat.h @@ -76,17 +76,18 @@ using namespace xfirelib; class Xfire_voicechat : public Xfire_base { private: //interner status, des aktiven voicechats - XFIREVOICECHATTYPE currentvoice; + XFIREVOICECHATTYPE m_currentvoice; //ipportport structur für ts3 - ts3IPPORT* ipport; + ts3IPPORT* m_ipport; //statuspacket caching - SendGameStatus2Packet lastpacket; + SendGameStatus2Packet m_lastpacket; //tsremotedll - HMODULE tsrDLL; + HMODULE m_tsrDLL; //tsrGetServerInfo funktion vom tsremotedll - LPtsrGetServerInfo tsrGetServerInfo; + LPtsrGetServerInfo m_tsrGetServerInfo; //pid für mumble - DWORD pid; + DWORD m_pid; + public: Xfire_voicechat(); ~Xfire_voicechat(); diff --git a/protocols/Xfire/src/addgamedialog.cpp b/protocols/Xfire/src/addgamedialog.cpp index ea257308ca..016c170a5c 100644 --- a/protocols/Xfire/src/addgamedialog.cpp +++ b/protocols/Xfire/src/addgamedialog.cpp @@ -252,7 +252,7 @@ BOOL OpenFileDialog(HWND hwndDlg, OPENFILENAMEA*ofn, char*exe) //backslash suchen exename = strrchr(exe, '\\') + 1; //kein backslash dann normal ret als exenamen verwenden - if ((int)exename == 1) exename = exe; + if ((INT_PTR)exename == 1) exename = exe; //filterstring aufbauen mir_snprintf(szFilter, _countof(szFilter), "%s|%s|%s|*.*|", exename, exename, Translate("All Files")); //umbruch in 0 wandeln @@ -374,10 +374,10 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) //neuen gameeintrag anlegen Xfire_game* newgame = new Xfire_game(); //gameid und sendid setzen - newgame->id = gameid1; - newgame->send_gameid = gameid1; + newgame->m_id = gameid1; + newgame->m_send_gameid = gameid1; //es handelt sich um einen customeintrag, man staune xD - newgame->custom = 1; + newgame->m_custom = 1; //launcherexe abfragen if (xfire_GetPrivateProfileString(gameidtemp, "LauncherExe", "", ret, 512, inipath)) { @@ -386,7 +386,7 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) //lowercase pfad newgame->strtolower(ofn.lpstrFile); //pfad dem spiel zuordnen - newgame->setString(ofn.lpstrFile, &newgame->launchparams); + newgame->setString(ofn.lpstrFile, &newgame->m_launchparams); } else { //speicher freigeben @@ -402,7 +402,7 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) //lowercase pfad newgame->strtolower(ofn.lpstrFile); //pfad dem spiel zuordnen - newgame->setString(ofn.lpstrFile, &newgame->path); + newgame->setString(ofn.lpstrFile, &newgame->m_path); } else { //speicher freigeben @@ -416,7 +416,7 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) //lowercase pfad newgame->strtolower(ofn.lpstrFile); //pfad dem spiel zuordnen - newgame->setString(ofn.lpstrFile, &newgame->path); + newgame->setString(ofn.lpstrFile, &newgame->m_path); } else { //speicher freigeben @@ -427,18 +427,17 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) //prüfe ob schon ein launchstring festgelegt wurde, wenn nicht die detectexe nehmen - if (!newgame->launchparams&&newgame->path) { - newgame->setString(newgame->path, &newgame->launchparams); - } + if (!newgame->m_launchparams && newgame->m_path) + newgame->setString(newgame->m_path, &newgame->m_launchparams); //prüfe ob schon ein detectexe festgelegt wurde, wenn nicht die launchstring nehmen - if (newgame->launchparams&&!newgame->path) { - newgame->setString(newgame->launchparams, &newgame->path); + if (newgame->m_launchparams && !newgame->m_path) { + newgame->setString(newgame->m_launchparams, &newgame->m_path); } //LauncherUrl wird der launcherstring überschrieben if (xfire_GetPrivateProfileString(gameidtemp, "LauncherUrl", "", ret, 512, inipath)) { - newgame->setString(ret, &newgame->launchparams); + newgame->setString(ret, &newgame->m_launchparams); } else if (xfire_GetPrivateProfileString(gameidtemp, "Launch", "", ret, 512, inipath)) { str_replace(ret, "%UA_LAUNCHER_EXE_PATH%", ""); //erstmal unwichtige sachen entfernen @@ -446,22 +445,22 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) str_replace(ret, "%UA_LAUNCHER_LOGIN_ARGS%", ""); // - auch entfernen //ein leerzeichen anfügen - newgame->appendString(" ", &newgame->launchparams); + newgame->appendString(" ", &newgame->m_launchparams); //nun commandline des launchstringes dranhängen - newgame->appendString(ret, &newgame->launchparams); + newgame->appendString(ret, &newgame->m_launchparams); } //restliche wichtige felder einfügen if (xfire_GetPrivateProfileString(gameidtemp, "LauncherPasswordArgs", "", ret, 512, inipath)) - newgame->setString(ret, &newgame->pwparams); + newgame->setString(ret, &newgame->m_pwparams); if (xfire_GetPrivateProfileString(gameidtemp, "LauncherNetworkArgs", "", ret, 512, inipath)) - newgame->setString(ret, &newgame->networkparams); + newgame->setString(ret, &newgame->m_networkparams); if (xfire_GetPrivateProfileString(gameidtemp, "CommandLineMustContain[0]", "", ret, 512, inipath)) - newgame->setString(ret, &newgame->mustcontain); + newgame->setString(ret, &newgame->m_mustcontain); if (xfire_GetPrivateProfileString(gameidtemp, "XUSERSendId", "", ret, 512, inipath)) - newgame->send_gameid = atoi(ret); + newgame->m_send_gameid = atoi(ret); if (xfire_GetPrivateProfileString(gameidtemp, "XUSERSetStatusMsg", "", ret, 512, inipath)) - newgame->setstatusmsg = atoi(ret); + newgame->m_setstatusmsg = atoi(ret); //namen setzen und icon laden newgame->setNameandIcon(); @@ -502,42 +501,38 @@ INT_PTR CALLBACK DlgAddGameProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) SetDlgItemText(hwndDlg, IDOK, TranslateT("Apply")); //namen vorbelegen - if (editgame->customgamename) - SetDlgItemTextA(hwndDlg, IDC_ADD_NAME, editgame->customgamename); - else if (editgame->name) - SetDlgItemTextA(hwndDlg, IDC_ADD_NAME, editgame->name); + if (editgame->m_customgamename) + SetDlgItemTextA(hwndDlg, IDC_ADD_NAME, editgame->m_customgamename); + else if (editgame->m_name) + SetDlgItemTextA(hwndDlg, IDC_ADD_NAME, editgame->m_name); //gameid setzen und feld schreibschützen char gameid[10] = ""; - _itoa_s(editgame->id, gameid, 10, 10); + _itoa_s(editgame->m_id, gameid, 10, 10); SetDlgItemTextA(hwndDlg, IDC_ADD_ID, gameid); EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_ID), FALSE); //sendgameid setzen, bei -1 leer lassen - if (editgame->send_gameid != -1) { - _itoa_s(editgame->send_gameid, gameid, 10, 10); + if (editgame->m_send_gameid != -1) { + _itoa_s(editgame->m_send_gameid, gameid, 10, 10); SetDlgItemTextA(hwndDlg, IDC_ADD_SENDID, gameid); } //launcherstring - if (editgame->launchparams) { - SetDlgItemTextA(hwndDlg, IDC_ADD_LAUNCHEREXE, editgame->launchparams); - } + if (editgame->m_launchparams) + SetDlgItemTextA(hwndDlg, IDC_ADD_LAUNCHEREXE, editgame->m_launchparams); //detectstring - if (editgame->path) { - SetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, editgame->path); - } + if (editgame->m_path) + SetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, editgame->m_path); //statusmsg - if (editgame->statusmsg) { - SetDlgItemTextA(hwndDlg, IDC_ADD_STATUSMSG, editgame->statusmsg); - } + if (editgame->m_statusmsg) + SetDlgItemTextA(hwndDlg, IDC_ADD_STATUSMSG, editgame->m_statusmsg); //mustcontain parameter - if (editgame->mustcontain) { - SetDlgItemTextA(hwndDlg, IDC_ADD_CUSTOMPARAMS, editgame->mustcontain); - } + if (editgame->m_mustcontain) + SetDlgItemTextA(hwndDlg, IDC_ADD_CUSTOMPARAMS, editgame->m_mustcontain); } //dialog übersetzen TranslateDialogDefault(hwndDlg); @@ -597,9 +592,9 @@ INT_PTR CALLBACK DlgAddGameProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) } else { //spielname zuordnen - newgame->setString(temp, &newgame->customgamename); + newgame->setString(temp, &newgame->m_customgamename); //spielnamen fürs menü - newgame->setString(temp, &newgame->name); + newgame->setString(temp, &newgame->m_name); } //spielid nur setzen/prüfen, wenn kein editgame if (!editgame) { @@ -621,9 +616,9 @@ INT_PTR CALLBACK DlgAddGameProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) return MessageBox(hwndDlg, TranslateT("This game ID is already in use."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); } //gameid zuordnen - newgame->id = gameid; + newgame->m_id = gameid; //standardmäßig wird bei einem customeintrag keine id versendet - newgame->send_gameid = -1; + newgame->m_send_gameid = -1; } } //zu sendene spielid @@ -632,7 +627,7 @@ INT_PTR CALLBACK DlgAddGameProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) //standardmäßig wird bei einem customeintrag keine id versendet int sendid = atoi(temp); if (sendid > 0) - newgame->send_gameid = sendid; + newgame->m_send_gameid = sendid; } //launcher exe @@ -641,7 +636,7 @@ INT_PTR CALLBACK DlgAddGameProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) //lowercase pfad newgame->strtolower(temp); //detect exe - newgame->setString(temp, &newgame->launchparams); + newgame->setString(temp, &newgame->m_launchparams); } //detectexe GetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, temp, _countof(temp)); @@ -653,25 +648,24 @@ INT_PTR CALLBACK DlgAddGameProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) //lowercase pfad newgame->strtolower(temp); //detect exe - newgame->setString(temp, &newgame->path); + newgame->setString(temp, &newgame->m_path); //wenn kein launcher exe/pfad angeben wurde, dann den gamepath nehmen - if (!newgame->launchparams) - newgame->setString(temp, &newgame->launchparams); - + if (!newgame->m_launchparams) + newgame->setString(temp, &newgame->m_launchparams); } //mustcontain parameter GetDlgItemTextA(hwndDlg, IDC_ADD_CUSTOMPARAMS, temp, _countof(temp)); if (mir_strlen(temp)) { - newgame->setString(temp, &newgame->mustcontain); + newgame->setString(temp, &newgame->m_mustcontain); } //statusmsg speichern GetDlgItemTextA(hwndDlg, IDC_ADD_STATUSMSG, temp, _countof(temp)); if (mir_strlen(temp)) { - newgame->setString(temp, &newgame->statusmsg); - newgame->setstatusmsg = 1; + newgame->setString(temp, &newgame->m_statusmsg); + newgame->m_setstatusmsg = 1; } //custom eintrag aktivieren - newgame->custom = 1; + newgame->m_custom = 1; //spiel in die gameliste einfügen, aber nur im nicht editmodus if (!editgame) xgamelist.Addgame(newgame); @@ -697,7 +691,6 @@ INT_PTR CALLBACK DlgAddGameProcMain(HWND hwndDlg, UINT uMsg, WPARAM, LPARAM lPar switch (uMsg) { case WM_INITDIALOG: { - TCITEMA tci = { 0 }; int iTotal; RECT rcClient; @@ -711,12 +704,13 @@ INT_PTR CALLBACK DlgAddGameProcMain(HWND hwndDlg, UINT uMsg, WPARAM, LPARAM lPar hPage = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDGAME), hwndDlg, DlgAddGameProc); //bei editgame keine spiellisteauswahl + TCITEMA tcia = { 0 }; if (!editgame) { iTotal = TabCtrl_GetItemCount(hwndTab); - tci.mask = TCIF_PARAM | TCIF_TEXT; - tci.lParam = (LPARAM)hPage; - tci.pszText = Translate("Supported Games"); - SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci); + tcia.mask = TCIF_PARAM | TCIF_TEXT; + tcia.lParam = (LPARAM)hPage; + tcia.pszText = Translate("Supported Games"); + SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tcia); MoveWindow(hPage, 3, 24, rcClient.right - 10, rcClient.bottom - 28, 1); iTotal++; } @@ -725,10 +719,10 @@ INT_PTR CALLBACK DlgAddGameProcMain(HWND hwndDlg, UINT uMsg, WPARAM, LPARAM lPar hPage = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDGAME2), hwndDlg, DlgAddGameProc2); iTotal = TabCtrl_GetItemCount(hwndTab); - tci.mask = TCIF_PARAM | TCIF_TEXT; - tci.lParam = (LPARAM)hPage; - tci.pszText = Translate("Custom game"); - SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci); + tcia.mask = TCIF_PARAM | TCIF_TEXT; + tcia.lParam = (LPARAM)hPage; + tcia.pszText = Translate("Custom game"); + SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tcia); MoveWindow(hPage, 3, 24, rcClient.right - 10, rcClient.bottom - 28, 1); iTotal++; diff --git a/protocols/Xfire/src/dummyxfiregameresolver.h b/protocols/Xfire/src/dummyxfiregameresolver.h index 54b28c27a5..ab2d8c2edb 100644 --- a/protocols/Xfire/src/dummyxfiregameresolver.h +++ b/protocols/Xfire/src/dummyxfiregameresolver.h @@ -28,41 +28,40 @@ #include "xdebug.h" namespace xfirelib { - struct DummyXFireGame; - class DummyXFireGameResolver : public XFireGameResolver { + + class DummyXFireGameResolver : public XFireGameResolver + { public: XFireGame *resolveGame(int gameid, int iterator, BuddyListGamesPacket *packet); - }; - - class DummyXFireGame : public XFireGame { + class DummyXFireGame : public XFireGame + { public: // TODO !!!!!!!!!!!!! this->packet = packet should NOT be used !! // we need to create a copy of packet, because it will be deleted as soon // as all listeners are notified !!! - void init(int gameid, std::string gamename, BuddyListGamesPacket *packet, int iterator) { - this->gameid = gameid; - this->gamename = gamename; - this->packet = packet; + void init(int gameid, std::string gamename, BuddyListGamesPacket *packet, int iterator) + { + m_gameid = gameid; + m_gamename = gamename; + m_packet = packet; - memcpy(ip,packet->ips->at(iterator),4); - port = packet->ports->at(iterator); - XDEBUG(( "init .. %d / %s\n", gameid, gamename.c_str() )); + memcpy(m_ip, packet->ips->at(iterator), 4); + m_port = packet->ports->at(iterator); + XDEBUG(("init .. %d / %s\n", gameid, gamename.c_str())); } - int getGameId() { return gameid; } - std::string getGameName() { return gamename; } + int getGameId() { return m_gameid; } + std::string getGameName() { return m_gamename; } - BuddyListGamesPacket *packet; - int gameid; - char ip[4]; - long port; - std::string gamename; + BuddyListGamesPacket *m_packet; + int m_gameid; + char m_ip[4]; + long m_port; + std::string m_gamename; }; - }; - #endif diff --git a/protocols/Xfire/src/main.cpp b/protocols/Xfire/src/main.cpp index e9c881ca94..a3047ca48b 100644 --- a/protocols/Xfire/src/main.cpp +++ b/protocols/Xfire/src/main.cpp @@ -1225,12 +1225,12 @@ static void SetStatusLate(LPVOID param) static void SendAck(LPVOID param) { - ProtoBroadcastAck(protocolname, (MCONTACT)param, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)1, 0); + ProtoBroadcastAck(protocolname, (DWORD_PTR)param, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)1, 0); } static void SendBadAck(LPVOID param) { - ProtoBroadcastAck(protocolname, (MCONTACT)param, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)0, LPARAM(Translate("XFire does not support offline messaging!"))); + ProtoBroadcastAck(protocolname, (DWORD_PTR)param, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)0, LPARAM(Translate("XFire does not support offline messaging!"))); } static INT_PTR UserIsTyping(WPARAM hContact, LPARAM lParam) @@ -1332,10 +1332,8 @@ static void ConnectingThread(LPVOID params) if (myClient != NULL&&myClient->client != NULL) myClient->run(); - else { - mir_cslock lck(connectingMutex); + else return; - } if (myClient->client->connected) sendonrecieve = TRUE; @@ -1556,7 +1554,7 @@ BOOL IsXFireContact(MCONTACT hContact) MCONTACT CList_FindContact(int uid) { for (MCONTACT hContact = db_find_first(protocolname); hContact; hContact = db_find_next(hContact, protocolname)) - if (db_get_dw(hContact, protocolname, "UserId", -1) == uid) + if (db_get_dw(hContact, protocolname, "UserId", -1) == DWORD(uid)) return hContact; return 0; @@ -1941,7 +1939,7 @@ int RebuildContactMenu(WPARAM hContact, LPARAM) Xfire_game* game = xgamelist.getGamebyGameid(gameid); //hat das spiel netzwerkparameter? if (game) { - if (game->networkparams) { + if (game->m_networkparams) { //is beim buddy ein port hinterlegt, also spielt er im internet? if (!db_get_dw(hContact, protocolname, "Port", 0)) { //nein, dann join button auch ausblenden @@ -1984,10 +1982,10 @@ void SetXFireGameStatusMsg(Xfire_game* game) //kein gameobject, dann abbrechen if (!game) return; - if (!game->statusmsg) - xgamelist.getIniValue(game->id, "XUSERStatusMsg", statusmsg, 100); + if (!game->m_statusmsg) + xgamelist.getIniValue(game->m_id, "XUSERStatusMsg", statusmsg, 100); else - strcpy_s(statusmsg, 100, game->statusmsg); + strncpy_s(statusmsg, game->m_statusmsg, _TRUNCATE); if (statusmsg[0] != 0) if (myClient != NULL) @@ -2078,7 +2076,7 @@ void gamedetectiont(void*) tm * mytm = gmtime(&t3); //statusmsg von xfire zurücksetzen - if (currentgame->setstatusmsg) { + if (currentgame->m_setstatusmsg) { if (myClient != NULL) if (myClient->client->connected) if (bpStatus == ID_STATUS_ONLINE) @@ -2087,10 +2085,10 @@ void gamedetectiont(void*) myClient->Status(statusmessage[1]); } - mir_snprintf(temp, _countof(temp), Translate("Last game: %s playtime: %.2d:%.2d:%.2d"), currentgame->name, mytm->tm_hour, mytm->tm_min, mytm->tm_sec); + mir_snprintf(temp, Translate("Last game: %s playtime: %.2d:%.2d:%.2d"), currentgame->m_name, mytm->tm_hour, mytm->tm_min, mytm->tm_sec); db_set_s(NULL, protocolname, "LastGame", temp); - if (currentgame->noicqstatus != TRUE&&db_get_b(NULL, protocolname, "autosetstatusmsg", 0)) + if (currentgame->m_noicqstatus != TRUE&&db_get_b(NULL, protocolname, "autosetstatusmsg", 0)) SetOldStatusMsg(); db_set_w(NULL, protocolname, "currentgame", 0); @@ -2099,9 +2097,9 @@ void gamedetectiont(void*) //popup wieder aktivieren, menuservice funk aufrufen, nur wenn popups vorher abgestellt wurden if (disabledpopups) if (db_get_b(NULL, protocolname, "nopopups", 0)) { - if (ServiceExists("Popup/EnableDisableMenuCommand")) { + if (ServiceExists("Popup/EnableDisableMenuCommand")) CallService("Popup/EnableDisableMenuCommand", NULL, NULL); - } + disabledpopups = FALSE; } //sound wieder aktivieren, nur wenn es vorher abgestellt wurde @@ -2122,12 +2120,11 @@ void gamedetectiont(void*) delete packet; } - else //noch offen - { + else { //noch offen //XFireLog("Spiel noch offen...",""); //nur nwspiele nach ip/port scannen - if (db_get_b(NULL, protocolname, "ipportdetec", 0)) - if (currentgame->networkparams != NULL&¤tgame->send_gameid > 0) { + if (db_get_b(NULL, protocolname, "ipportdetec", 0)) { + if (currentgame->m_networkparams != NULL && currentgame->m_send_gameid > 0) { SendGameStatusPacket *packet = new SendGameStatusPacket(); //verscueh serverip und port zu scannen @@ -2144,24 +2141,20 @@ void gamedetectiont(void*) XFireLog("NO IPPort", ""); } - packet->gameid = currentgame->send_gameid; + packet->gameid = currentgame->m_send_gameid; if (db_get_b(NULL, protocolname, "sendgamestatus", 1)) if (myClient != NULL) myClient->client->send(packet); - if (currentgame->noicqstatus != TRUE&&db_get_b(NULL, protocolname, "autosetstatusmsg", 0)) + if (currentgame->m_noicqstatus != TRUE && db_get_b(NULL, protocolname, "autosetstatusmsg", 0)) SetGameStatusMsg(); } - else { - XFireLog("GetServerIPPort failed", ""); - } + else XFireLog("GetServerIPPort failed", ""); + delete packet; } - //XFireLog("fertig...",""); - //packet->=xf[currentgame].gameid2; + } } - - //if (op!=NULL) CloseHandle(op); } else { //XFireLog("nach spiel suchen...",""); @@ -2186,20 +2179,20 @@ void gamedetectiont(void*) if (nextgame->checkpath(processInfo)) { SendGameStatusPacket *packet = new SendGameStatusPacket(); - XFireLog("XFire Gamedetection - Spiel gefunden: %i", nextgame->id); + XFireLog("XFire Gamedetection - Spiel gefunden: %i", nextgame->m_id); if (myClient != NULL) if (myClient->client->connected) { currentgame = nextgame; pid = processInfo->th32ProcessID; - db_set_w(NULL, protocolname, "currentgame", currentgame->id); - db_set_s(NULL, protocolname, "currentgamename", currentgame->name); - packet->gameid = currentgame->send_gameid; + db_set_w(NULL, protocolname, "currentgame", currentgame->m_id); + db_set_s(NULL, protocolname, "currentgamename", currentgame->m_name); + packet->gameid = currentgame->m_send_gameid; t1 = time(NULL); if (db_get_b(NULL, protocolname, "sendgamestatus", 1)) { - XFireLog("XFire Gamedetection - Sendgame-ID: %i", currentgame->send_gameid); - if (currentgame->send_gameid > 0) { + XFireLog("XFire Gamedetection - Sendgame-ID: %i", currentgame->m_send_gameid); + if (currentgame->m_send_gameid > 0) { XFireLog("XFire Gamedetection - Setzte Status für XFire"); myClient->client->send(packet); } @@ -2211,18 +2204,16 @@ void gamedetectiont(void*) NotifyEventHooks(hookgamestart, 1, 0); //statusmsg für xfire setzen - if (currentgame->setstatusmsg) { + if (currentgame->m_setstatusmsg) SetXFireGameStatusMsg(currentgame); - } - if (currentgame->noicqstatus != TRUE&&db_get_b(NULL, protocolname, "autosetstatusmsg", 0)) { + if (currentgame->m_noicqstatus != TRUE && db_get_b(NULL, protocolname, "autosetstatusmsg", 0)) { BackupStatusMsg(); SetGameStatusMsg(); } //popup abschalten, menuservice funk aufrufen if (db_get_b(NULL, protocolname, "nopopups", 0)) { - if (ServiceExists("Popup/EnableDisableMenuCommand") && db_get_b(NULL, "Popup", "ModuleIsEnabled", 0) == 1) /**/ - { + if (ServiceExists("Popup/EnableDisableMenuCommand") && db_get_b(NULL, "Popup", "ModuleIsEnabled", 0) == 1) { disabledpopups = TRUE; CallService("Popup/EnableDisableMenuCommand", NULL, NULL); } @@ -2422,11 +2413,10 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc db_set_s(hContact, protocolname, "RVoice", gname); if (gameob) { - if ((unsigned char)gameob->ip[3] != 0) // wenn ip, dann speichern - { - mir_snprintf(temp, _countof(temp), "%d.%d.%d.%d", (unsigned char)gameob->ip[3], (unsigned char)gameob->ip[2], (unsigned char)gameob->ip[1], (unsigned char)gameob->ip[0]); + if ((unsigned char)gameob->m_ip[3] != 0) { // wenn ip, dann speichern + mir_snprintf(temp, _countof(temp), "%d.%d.%d.%d", (unsigned char)gameob->m_ip[3], (unsigned char)gameob->m_ip[2], (unsigned char)gameob->m_ip[1], (unsigned char)gameob->m_ip[0]); db_set_s(hContact, protocolname, "VServerIP", temp); - db_set_w(hContact, protocolname, "VPort", (unsigned long)gameob->port); + db_set_w(hContact, protocolname, "VPort", gameob->m_port); } else { db_unset(hContact, protocolname, "VServerIP"); @@ -2459,9 +2449,8 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc //popup, wenn jemand was spielt if (db_get_b(NULL, protocolname, "gamepopup", 0) == 1) { - char temp[256] = ""; - - mir_snprintf(temp, _countof(temp), Translate("%s is playing %s."), + char szMsg[256] = ""; + mir_snprintf(szMsg, _countof(szMsg), Translate("%s is playing %s."), //ist ein nick gesetzt? (entry->nick.length() == 0 ? //nein dann username @@ -2471,15 +2460,15 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc , gname); if (gameob) { - if ((unsigned char)gameob->ip[3] != 0) { - mir_snprintf(temp, _countof(temp), Translate("%s is playing %s on server %d.%d.%d.%d:%d."), + if ((unsigned char)gameob->m_ip[3] != 0) { + mir_snprintf(szMsg, _countof(szMsg), Translate("%s is playing %s on server %d.%d.%d.%d:%d."), //ist ein nick gesetzt? (entry->nick.length() == 0 ? //nein dann username entry->username.c_str() : //klar, dann nick nehmen - entry->nick.c_str()) - , gname, (unsigned char)gameob->ip[3], (unsigned char)gameob->ip[2], (unsigned char)gameob->ip[1], (unsigned char)gameob->ip[0], (unsigned long)gameob->port); + entry->nick.c_str()), + gname, (unsigned char)gameob->m_ip[3], (unsigned char)gameob->m_ip[2], (unsigned char)gameob->m_ip[1], (unsigned char)gameob->m_ip[0], (unsigned long)gameob->m_port); } } @@ -2489,43 +2478,43 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc */ if (entry->lastpopup == NULL) { //größe des popupstrings - int size = mir_strlen(temp) + 1; + int size = mir_strlen(szMsg) + 1; //popup darstellen - displayPopup(NULL, temp, PLUGIN_TITLE, 0, hicongame); + displayPopup(NULL, szMsg, PLUGIN_TITLE, 0, hicongame); //letzten popup definieren entry->lastpopup = new char[size]; //string kopieren - strcpy_s(entry->lastpopup, size, temp); + strcpy_s(entry->lastpopup, size, szMsg); } else { - if (mir_strcmp(entry->lastpopup, temp) != 0) { + if (mir_strcmp(entry->lastpopup, szMsg) != 0) { delete[] entry->lastpopup; entry->lastpopup = NULL; //größe des popupstrings - int size = mir_strlen(temp) + 1; + int size = mir_strlen(szMsg) + 1; //popup darstellen - displayPopup(NULL, temp, PLUGIN_TITLE, 0, hicongame); + displayPopup(NULL, szMsg, PLUGIN_TITLE, 0, hicongame); //letzten popup definieren entry->lastpopup = new char[size]; //string kopieren - strcpy_s(entry->lastpopup, size, temp); + strcpy_s(entry->lastpopup, size, szMsg); } } } if (gameob) { - if ((unsigned char)gameob->ip[3] != 0) { + if ((unsigned char)gameob->m_ip[3] != 0) { //ip und port in kontakt speichern - mir_snprintf(temp, _countof(temp), "%d.%d.%d.%d", (unsigned char)gameob->ip[3], (unsigned char)gameob->ip[2], (unsigned char)gameob->ip[1], (unsigned char)gameob->ip[0]); + mir_snprintf(temp, _countof(temp), "%d.%d.%d.%d", (unsigned char)gameob->m_ip[3], (unsigned char)gameob->m_ip[2], (unsigned char)gameob->m_ip[1], (unsigned char)gameob->m_ip[0]); db_set_s(hContact, protocolname, "ServerIP", temp); - db_set_w(hContact, protocolname, "Port", (unsigned long)gameob->port); + db_set_w(hContact, protocolname, "Port", gameob->m_port); //lass das query arbeiten if (dontscan == FALSE) if (ServiceExists("GameServerQuery/Query") && db_get_b(NULL, protocolname, "gsqsupport", 0)) { GameServerQuery_query gsqq = { 0 }; - gsqq.port = gameob->port; + gsqq.port = gameob->m_port; gsqq.xfiregameid = entry->game; strncpy(gsqq.ip, temp, _countof(gsqq.ip) - 1); CallService("GameServerQuery/Query", (WPARAM)entry, (LPARAM)&gsqq); @@ -2746,19 +2735,16 @@ void CreateGroup(char*grpn, char*field) int val = db_get_b(NULL, protocolname, field, 0); - if (val == 0) { + if (val == 0) strcpy_s(grp, _countof(grp), grpn);//((char*)clan->name[i].c_str()); - } else { char temp[255]; - DBVARIANT dbv; mir_snprintf(temp, _countof(temp), "%d", val - 1); if (!db_get_s(NULL, "CListGroups", temp, &dbv)) { mir_snprintf(grp, _countof(grp), "%s\\%s", &dbv.pszVal[1], grpn); db_free(&dbv); } - else //gruppe existiert nciht mehr, auf root alles legen - { + else { //gruppe existiert nciht mehr, auf root alles legen strcpy_s(grp, _countof(grp), grpn); db_set_b(NULL, protocolname, field, 0); } diff --git a/protocols/Xfire/src/options.cpp b/protocols/Xfire/src/options.cpp index fd1a9c9f3c..efde5c0404 100644 --- a/protocols/Xfire/src/options.cpp +++ b/protocols/Xfire/src/options.cpp @@ -250,13 +250,15 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (dbv.pszVal != NULL) db_free(&dbv); - //den login lowercasen - int size = mir_strlen(login); - BOOL mustlowercase = FALSE; - for (int i = 0; i < size; i++) { - if (login[i] >= 'A'&&login[i] <= 'Z') - mustlowercase = TRUE; - login[i] = tolower(login[i]); + // den login lowercasen + bool mustlowercase = false; + { + int size = (int)mir_strlen(login); + for (int i = 0; i < size; i++) { + if (login[i] >= 'A'&&login[i] <= 'Z') + mustlowercase = true; + login[i] = tolower(login[i]); + } } if (mustlowercase) { MessageBox(NULL, TranslateT("The username must be lowercase, so it will be lowercased saved."), TranslateT("XFire Options"), MB_OK | MB_ICONINFORMATION); @@ -287,7 +289,7 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR //neue preferencen sichern if (bpStatus != ID_STATUS_OFFLINE&&bpStatus != ID_STATUS_CONNECTING) { - int size = sizeof(xfireconfigitems) / sizeof(xfireconfigitem); + int size = _countof(xfireconfigitems); for (int i = 0; i < size; i++) { if (!(BYTE)IsDlgButtonChecked(hwndDlg, xfireconfigitems[i].id)) { db_set_b(NULL, protocolname, xfireconfigitems[i].dbentry, 0); @@ -846,7 +848,7 @@ static INT_PTR CALLBACK DlgProcOpts6(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, TRUE); Xfire_game* xgtemp = xgamelist.getGamebyGameid(gameid); - if (xgtemp && xgtemp->custom) { + if (xgtemp && xgtemp->m_custom) { ShowWindow(GetDlgItem(hwndDlg, IDC_MANADDED), SW_SHOW); ShowWindow(GetDlgItem(hwndDlg, IDC_EDITGAME), SW_SHOW); } @@ -896,22 +898,22 @@ static INT_PTR CALLBACK DlgProcOpts6(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (xgamelist.Gameinlist(gameid, &dbid)) { Xfire_game* game = xgamelist.getGame(dbid); if (game) { - game->skip = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DONTDETECT); - game->noicqstatus = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOSTATUSMSG); - game->notinstartmenu = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOTINSTARTMENU); + game->m_skip = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DONTDETECT); + game->m_noicqstatus = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOSTATUSMSG); + game->m_notinstartmenu = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOTINSTARTMENU); //extra parameter auslesen und das gameobj schreiben char str[128] = ""; GetDlgItemTextA(hwndDlg, IDC_EXTRAPARAMS, str, _countof(str)); if (str[0] != 0) { //extra parameter sind gesetzt, zuweisen - game->setString(str, &game->extraparams); + game->setString(str, &game->m_extraparams); } else { //extra parameter leer, wenn gesetzt entfernen/freigeben - if (game->extraparams) { - delete[] game->extraparams; - game->extraparams = NULL; + if (game->m_extraparams) { + delete[] game->m_extraparams; + game->m_extraparams = NULL; } } @@ -921,13 +923,9 @@ static INT_PTR CALLBACK DlgProcOpts6(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetDlgItemText(hwndDlg, IDC_TEXTSTATUS, TranslateT("Configuration saved!")); } - else { - SetDlgItemText(hwndDlg, IDC_TEXTSTATUS, TranslateT("Game not found?!")); - } - } - else { - SetDlgItemText(hwndDlg, IDC_TEXTSTATUS, TranslateT("Game not found?!")); + else SetDlgItemText(hwndDlg, IDC_TEXTSTATUS, TranslateT("Game not found?!")); } + else SetDlgItemText(hwndDlg, IDC_TEXTSTATUS, TranslateT("Game not found?!")); //gamelist unblocken xgamelist.Block(FALSE); @@ -973,4 +971,4 @@ int OptInit(WPARAM wParam, LPARAM) odp.ptszTab = LPGENT("Games"); Options_AddPage(wParam, &odp); return 0; -} \ No newline at end of file +} diff --git a/protocols/Xfire/src/searching4games.cpp b/protocols/Xfire/src/searching4games.cpp index 476273172d..c9b5192da4 100644 --- a/protocols/Xfire/src/searching4games.cpp +++ b/protocols/Xfire/src/searching4games.cpp @@ -189,7 +189,7 @@ void Scan4Games(LPVOID) } //spiele von db laden - if (loadgamesfromdb) + if (loadgamesfromdb) { if (foundgames > 0) { //spieliste einlesen xgamelist.readGamelist(foundgames); @@ -202,27 +202,24 @@ void Scan4Games(LPVOID) searching = FALSE; return; } - else if (foundgames == 0) { + if (foundgames == 0) { searching = FALSE; //dummymenü punkt entfernen //CallService(MS_CLIST_REMOVEMAINMENUITEM, ( WPARAM )dummymenu, 0 ); //gamelist unblocken xgamelist.Block(FALSE); - return; } - else - foundgames = 0; - else foundgames = 0; + } + else foundgames = 0; HWND hwnd = NULL; //suche dialog anzeigen - if (!db_get_b(NULL, protocolname, "dontdissstatus", 0)) { + if (!db_get_b(NULL, protocolname, "dontdissstatus", 0)) mir_forkthread(ShowSearchDialog, &hwnd); - } mir_strcpy(inipath, XFireGetFoldersPath("IniFile")); mir_strcat(inipath, "xfire_games.ini"); @@ -363,43 +360,36 @@ void Scan4Games(LPVOID) mir_strcat(path, ret2); } } - else { - *(path) = 0; - } + else *(path) = 0; } else if (xfire_GetPrivateProfileString(temp, "DetectExe[0]", "", ret2, 255, inipath)) { cutforlaunch = path + mir_strlen(path); mir_strcat(path, ret2); multiexe = TRUE; - if (!CheckPath(path, path_r)) { + if (!CheckPath(path, path_r)) *(path) = 0; - } } else if (xfire_GetPrivateProfileString(temp, "DetectExe", "", ret2, 255, inipath)) { cutforlaunch = path + mir_strlen(path); //wenn backslash bei detectexe, dann diesen skippen (eveonline bug) - if (ret2[0] == '\\') { + if (ret2[0] == '\\') mir_strcat(path, (char*)&ret2[1]); - } - else { + else mir_strcat(path, ret2); - } - if (!CheckPath(path, path_r)) { + if (!CheckPath(path, path_r)) *(path) = 0; - } } else if (xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret2, 255, inipath)) { cutforlaunch = path + mir_strlen(path); mir_strcat(path, ret2); } - //prüfe ob existent, dann ist das spiel installiert if (path[0] != 0 && GetFileAttributesA(path) != 0xFFFFFFFF) { Xfire_game* newgame = new Xfire_game(); - newgame->id = i; + newgame->m_id = i; //8.3 pfade umwandeln //GetLongPathNameA(path,path,sizeof(path)); @@ -409,46 +399,45 @@ void Scan4Games(LPVOID) path[ii] = tolower(path[ii]); if (path_r[0] == 0) - newgame->setString(path, &newgame->path); + newgame->setString(path, &newgame->m_path); else { //lowercase wildcard pfad for (unsigned int ii = 0; ii < mir_strlen(path_r); ii++) path_r[ii] = tolower(path_r[ii]); - newgame->setString(path_r, &newgame->path); + newgame->setString(path_r, &newgame->m_path); } //spiel mit mehreren exefiles if (multiexe) { multiexe = FALSE; - for (int i = 1; i < 9; i++) { - mir_snprintf(ret, _countof(ret), "DetectExe[%d]", i); + for (int j = 1; j < 9; j++) { + mir_snprintf(ret, _countof(ret), "DetectExe[%d]", j); if (xfire_GetPrivateProfileString(temp, ret, "", ret2, 512, inipath)) { - char* pos = strrchr(path, '\\'); - if (pos != 0) { - pos++; - *pos = 0; + char *p = strrchr(path, '\\'); + if (p != 0) { + p++; + *p = 0; } mir_strcat(path, ret2); - if (!CheckPath(path)) { + if (!CheckPath(path)) *(path) = 0; - } else { - for (unsigned int i2 = 0; i2 < mir_strlen(path); i2++) - path[i2] = tolower(path[i2]); + for (unsigned int k = 0; k < mir_strlen(path); k++) + path[k] = tolower(path[k]); char* mpathtemp = new char[mir_strlen(path) + 1]; mir_strcpy(mpathtemp, path); - newgame->mpath.push_back(mpathtemp); + newgame->m_mpath.push_back(mpathtemp); } } } } //für launcherstring anpassen - char* pos = strrchr(path, '\\'); - if (pos != 0) { - pos++; - *pos = 0; + char* p = strrchr(path, '\\'); + if (p != 0) { + p++; + *p = 0; } xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret2, 255, inipath); // anfügen if (cutforlaunch != 0) *cutforlaunch = 0; @@ -461,8 +450,8 @@ void Scan4Games(LPVOID) mir_strcat(path, ret2); - newgame->setString(path, &newgame->launchparams); - newgame->appendString(" ", &newgame->launchparams); + newgame->setString(path, &newgame->m_launchparams); + newgame->appendString(" ", &newgame->m_launchparams); xfire_GetPrivateProfileString(temp, "Launch", "", ret2, 512, inipath); str_replace(ret2, "%UA_LAUNCHER_EXE_DIR%", launchpath); @@ -470,46 +459,46 @@ void Scan4Games(LPVOID) //str_replace(ret2,"%UA_LAUNCHER_EXTRA_ARGS%",""); // - auch entfernen str_replace(ret2, "%UA_LAUNCHER_LOGIN_ARGS%", ""); // - auch entfernen - newgame->appendString(ret2, &newgame->launchparams); + newgame->appendString(ret2, &newgame->m_launchparams); /*if (xfire_GetPrivateProfileString(temp, "LauncherLoginArgs", "", ret2, 512, inipath)) { - str_replace(xf[foundgames].launchparams,"%UA_LAUNCHER_LOGIN_ARGS%",ret2); // - auch entfernen + str_replace(xf[foundgames].m_launchparams,"%UA_LAUNCHER_LOGIN_ARGS%",ret2); // - auch entfernen } else*/ - // str_replace(xf[foundgames].launchparams,"%UA_LAUNCHER_LOGIN_ARGS%",""); // - auch entfernen + // str_replace(xf[foundgames].m_launchparams,"%UA_LAUNCHER_LOGIN_ARGS%",""); // - auch entfernen if (xfire_GetPrivateProfileString(temp, "LauncherPasswordArgs", "", ret2, 512, inipath)) - newgame->setString(ret2, &newgame->pwparams); + newgame->setString(ret2, &newgame->m_pwparams); if (xfire_GetPrivateProfileString(temp, "LauncherNetworkArgs", "", ret2, 512, inipath)) - newgame->setString(ret2, &newgame->networkparams); + newgame->setString(ret2, &newgame->m_networkparams); if (xfire_GetPrivateProfileString(temp, "CommandLineMustContain[0]", "", ret2, 512, inipath)) - newgame->setString(ret2, &newgame->mustcontain); + newgame->setString(ret2, &newgame->m_mustcontain); if (xfire_GetPrivateProfileString(temp, "XUSERSendId", "", ret2, 512, inipath)) - newgame->send_gameid = atoi(ret2); + newgame->m_send_gameid = atoi(ret2); if (xfire_GetPrivateProfileString(temp, "XUSERSetStatusMsg", "", ret2, 512, inipath)) - newgame->setstatusmsg = atoi(ret2); + newgame->m_setstatusmsg = atoi(ret2); //launcherurl? if (xfire_GetPrivateProfileString(temp, "LauncherUrl", "", ret2, 512, inipath)) - newgame->setString(ret2, &newgame->launchparams); + newgame->setString(ret2, &newgame->m_launchparams); //soll alle string, welche nicht in der commandline eines spiels sein soll in einen string pakcen semikolon getrennt mir_snprintf(ret, _countof(ret), "CommandLineMustNotContain[0]"); - int i = 0; + int k = 0; while (xfire_GetPrivateProfileString(temp, ret, "", ret2, 512, inipath)) { - if (!newgame->notcontain) newgame->setString("", &newgame->notcontain); - if (i > 0) - newgame->appendString(";", &newgame->notcontain); - newgame->appendString(ret2, &newgame->notcontain); + if (!newgame->m_notcontain) newgame->setString("", &newgame->m_notcontain); + if (k > 0) + newgame->appendString(";", &newgame->m_notcontain); + newgame->appendString(ret2, &newgame->m_notcontain); - i++; - mir_snprintf(ret, _countof(ret), "CommandLineMustNotContain[%d]", i); + k++; + mir_snprintf(ret, _countof(ret), "CommandLineMustNotContain[%d]", k); } newgame->setNameandIcon(); @@ -547,16 +536,14 @@ void Scan4Games(LPVOID) Xfire_game* newgame = new Xfire_game(); - newgame->id = i; + newgame->m_id = i; //8.3 pfade umwandeln - //GetLongPathNameA(ret2,ret2,sizeof(ret2)); - //lowercase pfad - for (unsigned int i = 0; i < mir_strlen(ret2); i++) - ret2[i] = tolower(ret2[i]); + for (unsigned int k = 0; k < mir_strlen(ret2); k++) + ret2[k] = tolower(ret2[k]); - newgame->setString(ret2, &newgame->path); + newgame->setString(ret2, &newgame->m_path); //launch parameterstring @@ -567,8 +554,8 @@ void Scan4Games(LPVOID) *(strrchr(launchpath, '\\')) = 0; } - newgame->setString(ret2, &newgame->launchparams); - newgame->appendString(" ", &newgame->launchparams); + newgame->setString(ret2, &newgame->m_launchparams); + newgame->appendString(" ", &newgame->m_launchparams); xfire_GetPrivateProfileString(temp, "Launch", "", ret2, 512, inipath); @@ -578,35 +565,35 @@ void Scan4Games(LPVOID) //str_replace(ret2,"%UA_LAUNCHER_EXTRA_ARGS%",""); // - auch entfernen str_replace(ret2, "%UA_LAUNCHER_LOGIN_ARGS%", ""); // - auch entfernen - newgame->appendString(ret2, &newgame->launchparams); + newgame->appendString(ret2, &newgame->m_launchparams); if (xfire_GetPrivateProfileString(temp, "LauncherPasswordArgs", "", ret2, 512, inipath)) - newgame->setString(ret2, &newgame->pwparams); + newgame->setString(ret2, &newgame->m_pwparams); if (xfire_GetPrivateProfileString(temp, "LauncherNetworkArgs", "", ret2, 512, inipath)) - newgame->setString(ret2, &newgame->networkparams); + newgame->setString(ret2, &newgame->m_networkparams); if (xfire_GetPrivateProfileString(temp, "CommandLineMustContain[0]", "", ret2, 512, inipath)) - newgame->setString(ret2, &newgame->mustcontain); + newgame->setString(ret2, &newgame->m_mustcontain); if (xfire_GetPrivateProfileString(temp, "XUSERSendId", "", ret2, 512, inipath)) - newgame->send_gameid = atoi(ret2); + newgame->m_send_gameid = atoi(ret2); if (xfire_GetPrivateProfileString(temp, "XUSERSetStatusMsg", "", ret2, 512, inipath)) - newgame->setstatusmsg = atoi(ret2); + newgame->m_setstatusmsg = atoi(ret2); //soll alle string, welche nicht in der commandline eines spiels sein soll in einen string pakcen semikolon getrennt mir_snprintf(ret, _countof(ret), "CommandLineMustNotContain[0]"); - int i = 0; + int k = 0; while (xfire_GetPrivateProfileString(temp, ret, "", ret2, 512, inipath)) { - if (!newgame->notcontain) newgame->setString("", &newgame->notcontain); - if (i > 0) - newgame->appendString(";", &newgame->notcontain); - newgame->appendString(ret2, &newgame->notcontain); + if (!newgame->m_notcontain) newgame->setString("", &newgame->m_notcontain); + if (k > 0) + newgame->appendString(";", &newgame->m_notcontain); + newgame->appendString(ret2, &newgame->m_notcontain); - i++; - mir_snprintf(ret, _countof(ret), "CommandLineMustNotContain[%d]", i); + k++; + mir_snprintf(ret, _countof(ret), "CommandLineMustNotContain[%d]", k); } newgame->setNameandIcon(); diff --git a/protocols/Xfire/src/sendtypingpacket.cpp b/protocols/Xfire/src/sendtypingpacket.cpp index df38f5bd5e..58965d8fe2 100644 --- a/protocols/Xfire/src/sendtypingpacket.cpp +++ b/protocols/Xfire/src/sendtypingpacket.cpp @@ -49,26 +49,27 @@ namespace xfirelib void SendTypingPacket::initIMIndex() { - string str_sid(sid); + string str_sid(m_sid); if (imindexes.count(str_sid) < 1) - imindex = imindexes[str_sid] = 1; + m_imindex = imindexes[str_sid] = 1; else - imindex = ++imindexes[str_sid]; + m_imindex = ++imindexes[str_sid]; } void SendTypingPacket::setSid(const char *sid) { - memcpy(this->sid, sid, 16); + memcpy(m_sid, sid, 16); } int SendTypingPacket::getPacketContent(char *buf) { - if (imindex == 0) initIMIndex(); + if (m_imindex == 0) + initIMIndex(); int index = 0; VariableValue val; val.setName("sid"); - val.setValue(sid, 16); + val.setValue(m_sid, 16); index += val.writeName(buf, index); buf[index++] = 3; @@ -87,7 +88,7 @@ namespace xfirelib index += val.writeValue(buf, index); val.setName("imindex"); - val.setValueFromLong(imindex, 4); + val.setValueFromLong(m_imindex, 4); index += val.writeName(buf, index); buf[index++] = 02; index += val.writeValue(buf, index); @@ -100,4 +101,4 @@ namespace xfirelib return index; } -} \ No newline at end of file +} diff --git a/protocols/Xfire/src/sendtypingpacket.h b/protocols/Xfire/src/sendtypingpacket.h index 0ba3637a47..4507310538 100644 --- a/protocols/Xfire/src/sendtypingpacket.h +++ b/protocols/Xfire/src/sendtypingpacket.h @@ -40,9 +40,7 @@ namespace xfirelib { class SendTypingPacket : public XFireSendPacketContent { public: - SendTypingPacket() { - imindex = 0; - } + SendTypingPacket() : m_imindex(0) {} virtual ~SendTypingPacket() { } void init(Client *client, string username); @@ -58,12 +56,12 @@ namespace xfirelib { /** * SID of the user to who the message should be sent. */ - char sid[16]; + char m_sid[16]; /** * A running counter for each buddy. (will be initialized to 0 by default.. and.. * shouldn't be a problem to leave it 0) */ - long imindex; + long m_imindex; protected: void initIMIndex(); diff --git a/protocols/Xfire/src/tools.cpp b/protocols/Xfire/src/tools.cpp index 3f33a9e45b..bb9b8e0d79 100644 --- a/protocols/Xfire/src/tools.cpp +++ b/protocols/Xfire/src/tools.cpp @@ -371,23 +371,24 @@ BOOL GetServerIPPort(DWORD pid, char*, unsigned long localaddr, char*ip1, char*i return FALSE; } - //wir wollen alles was da reinkommt haben - static int I = 1; - static DWORD b; - if (WSAIoctl(s, _WSAIOW(IOC_VENDOR, 1), &I, sizeof(I), NULL, NULL, &b, NULL, NULL) == SOCKET_ERROR) { - //DUMP("IOCTL Error",""); - /*closesocket(s); - return FALSE;*/ - XFireLog("IOCTL error %d", WSAGetLastError()); - //unter bestimmten umständen schlägt es hier fehl, dann lass trotzdem ip weiter erkennen + // wir wollen alles was da reinkommt haben + { + int I = 1; + DWORD b; + if (WSAIoctl(s, _WSAIOW(IOC_VENDOR, 1), &I, sizeof(I), NULL, NULL, &b, NULL, NULL) == SOCKET_ERROR) { + //DUMP("IOCTL Error",""); + /*closesocket(s); + return FALSE;*/ + XFireLog("IOCTL error %d", WSAGetLastError()); + //unter bestimmten umständen schlägt es hier fehl, dann lass trotzdem ip weiter erkennen + } } //socket soll timeout auswerfen, wenn nix kommt, damit der gamethread nicht hängt //DUMP("timeout>>>",""); static int timeout = 200; - if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout) == SOCKET_ERROR)) { + if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout) == SOCKET_ERROR)) XFireLog("setsockopt(SO_RCVTIMEO) error %d", WSAGetLastError()); - } //updstruct, nur mit wichtigen sachen struct mpacket @@ -559,19 +560,21 @@ BOOL GetServerIPPort2(DWORD pid, char*, unsigned long localaddr, char*ip1, char* msockaddr.sin_family = AF_INET; msockaddr.sin_port = 0; - //socket an nw binden + // socket an nw binden if (bind(s, (sockaddr *)&msockaddr, sizeof(msockaddr)) == SOCKET_ERROR) { closesocket(s); return FALSE; } - //wir wollen alles was da reinkommt haben - static int I = 1; - DWORD b; - if (WSAIoctl(s, _WSAIOW(IOC_VENDOR, 1), &I, sizeof(I), NULL, NULL, &b, NULL, NULL) == SOCKET_ERROR) { - /*closesocket(s); - return FALSE;*/ - //unter bestimmten umständen schlägt es hier fehl, dann lass trotzdem ip weiter erkennen + // wir wollen alles was da reinkommt haben + { + int I = 1; + DWORD b; + if (WSAIoctl(s, _WSAIOW(IOC_VENDOR, 1), &I, sizeof(I), NULL, NULL, &b, NULL, NULL) == SOCKET_ERROR) { + /*closesocket(s); + return FALSE;*/ + //unter bestimmten umständen schlägt es hier fehl, dann lass trotzdem ip weiter erkennen + } } //socket soll timeout auswerfen, wenn nix kommt, damit der gamethread nicht hängt @@ -665,13 +668,12 @@ BOOL GetServerIPPort2(DWORD pid, char*, unsigned long localaddr, char*ip1, char* return TRUE; } - -char * getItem(char * string, char delim, int count) +char* getItem(char *string, char delim, int count) { static char item[255]; char i = 0; - while (*string != '\0'&&count > 0) { + while (*string != '\0' && count > 0) { if (*string == delim) { item[i] = 0; i = 0; @@ -689,9 +691,8 @@ char * getItem(char * string, char delim, int count) if (count > 1) item[0] = 0; - for (unsigned int i = 0; i < mir_strlen(item); i++) { - item[i] = tolower(item[i]); - } + for (unsigned int j = 0; j < mir_strlen(item); j++) + item[j] = tolower(item[j]); return item; } diff --git a/protocols/Xfire/src/variablevalue.cpp b/protocols/Xfire/src/variablevalue.cpp index 6d3050da34..bf719d7f08 100644 --- a/protocols/Xfire/src/variablevalue.cpp +++ b/protocols/Xfire/src/variablevalue.cpp @@ -33,29 +33,28 @@ namespace xfirelib { VariableValue::VariableValue() { - value = 0; + m_value = 0; } VariableValue::~VariableValue() { - if (value) - delete[] value; + delete[] m_value; } void VariableValue::setName(std::string name) { - this->name = name; + m_name = name; } void VariableValue::setValueLength(int valueLength) { - this->valueLength = valueLength; + m_valueLength = valueLength; } void VariableValue::setValue(char * value) { - if (this->value) delete[] this->value; - this->value = value; + if (m_value) delete[] m_value; + m_value = value; } void VariableValue::setValue(std::string value) @@ -66,41 +65,26 @@ namespace xfirelib void VariableValue::setValue(const char *value, int valueLength) { - this->value = new char[valueLength]; - memcpy(this->value, value, valueLength); - this->valueLength = valueLength; + m_value = new char[valueLength]; + memcpy(m_value, value, valueLength); + m_valueLength = valueLength; } void VariableValue::setValueFromLong(long value, int bytes) { - this->valueLength = bytes; - this->value = new char[bytes]; + m_valueLength = bytes; + m_value = new char[bytes]; for (int i = 0; i < bytes; i++) { - this->value[i] = value % 256; + m_value[i] = value % 256; value = value / 256; } } - std::string VariableValue::getName() - { - return name; - } - - int VariableValue::getValueLength() - { - return valueLength; - } - - char* VariableValue::getValue() - { - return value; - } - long VariableValue::getValueAsLong() { long intVal = 0; - for (int i = 0; i < valueLength; i++) { - intVal += ((unsigned char)value[i]) * myPow(256, i); + for (int i = 0; i < m_valueLength; i++) { + intVal += ((unsigned char)m_value[i]) * myPow(256, i); } return intVal; } @@ -120,7 +104,7 @@ namespace xfirelib char* namestr = new char[nameLength + 1]; namestr[nameLength] = 0; memcpy(namestr, packet + index + read, nameLength); - name = string(namestr); + m_name = string(namestr); read += nameLength; delete[] namestr; return read; @@ -129,17 +113,18 @@ namespace xfirelib int VariableValue::readValue(char *packet, int index, int length, int ignoreZeroAfterLength) { int read = 0; - valueLength = length; - if (valueLength < 0) { - valueLength = (unsigned char)packet[index + read]; read++; - if (ignoreZeroAfterLength) read++; + m_valueLength = length; + if (m_valueLength < 0) { + m_valueLength = (unsigned char)packet[index + read]; read++; + if (ignoreZeroAfterLength) + read++; } - if (value) delete[] value; - value = new char[valueLength]; - memcpy(value, packet + index + read, valueLength); - read += valueLength; - + if (m_value) + delete[] m_value; + m_value = new char[m_valueLength]; + memcpy(m_value, packet + index + read, m_valueLength); + read += m_valueLength; return read; } @@ -148,14 +133,14 @@ namespace xfirelib VariableValue *value = this; int nameLength = packet[index]; - int i = 1; int attLengthLength = 0; int attLength = 0; string name; - for (; i <= nameLength; i++) { + int i = 1; + for (; i <= nameLength; i++) name += packet[index + i]; - } + value->setName(name); index += i; @@ -179,14 +164,14 @@ namespace xfirelib int VariableValue::writeName(char *buf, int index) { - int len = name.length(); + int len = m_name.length(); buf[index] = len; - memcpy(buf + index + 1, name.c_str(), len); + memcpy(buf + index + 1, m_name.c_str(), len); return len + 1; } int VariableValue::writeValue(char *buf, int index) { - memcpy(buf + index, value, valueLength); - return valueLength; + memcpy(buf + index, m_value, m_valueLength); + return m_valueLength; } }; diff --git a/protocols/Xfire/src/variablevalue.h b/protocols/Xfire/src/variablevalue.h index 29e12743cb..190c044667 100644 --- a/protocols/Xfire/src/variablevalue.h +++ b/protocols/Xfire/src/variablevalue.h @@ -25,20 +25,22 @@ namespace xfirelib { - class VariableValue { + class VariableValue + { public: VariableValue(); ~VariableValue(); void setName(std::string name); void setValueLength(int valueLength); - void setValue( char * value ); - void setValue( std::string value ); - void setValue( const char *value, int valueLength ); - void setValueFromLong( long value, int bytes ); - std::string getName(); - int getValueLength(); - char* getValue(); + void setValue(char * value); + void setValue(std::string value); + void setValue(const char *value, int valueLength); + void setValueFromLong(long value, int bytes); + + __forceinline std::string getName() { return m_name; } + __forceinline int getValueLength() { return m_valueLength; } + __forceinline char* getValue() { return m_value; } int readName(char *packet, int index); int readValue(char *packet, int index, int length = -1, int ignoreZeroAfterLength = 0); @@ -53,11 +55,10 @@ namespace xfirelib { private: long myPow(int x, int y); - std::string name; - char *value; - int valueLength; + std::string m_name; + char* m_value; + int m_valueLength; }; - }; #endif -- cgit v1.2.3