summaryrefslogtreecommitdiff
path: root/protocols/Xfire/src/clanbuddylistnamespacket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Xfire/src/clanbuddylistnamespacket.cpp')
-rw-r--r--protocols/Xfire/src/clanbuddylistnamespacket.cpp124
1 files changed, 63 insertions, 61 deletions
diff --git a/protocols/Xfire/src/clanbuddylistnamespacket.cpp b/protocols/Xfire/src/clanbuddylistnamespacket.cpp
index 76269a01cf..b84b959049 100644
--- a/protocols/Xfire/src/clanbuddylistnamespacket.cpp
+++ b/protocols/Xfire/src/clanbuddylistnamespacket.cpp
@@ -23,90 +23,92 @@
*/
#include "stdafx.h"
-#include <vector>
-#include <string>
#include "clanbuddylistnamespacket.h"
#include "xfireparse.h"
#include "variablevalue.h"
#include "xdebug.h"
-namespace xfirelib {
- using namespace std;
+using namespace std;
- ClanBuddyListNamesPacket::ClanBuddyListNamesPacket() {
- usernames = 0;
- nicks = 0;
- userids = 0;
- clanid = 0;
- }
- ClanBuddyListNamesPacket::~ClanBuddyListNamesPacket() {
- delete usernames;
- delete nicks;
- delete userids;
- }
+namespace xfirelib
+{
+ ClanBuddyListNamesPacket::ClanBuddyListNamesPacket()
+ {
+ usernames = 0;
+ nicks = 0;
+ userids = 0;
+ clanid = 0;
+ }
- void ClanBuddyListNamesPacket::parseContent(char *buf, int length, int numberOfAtts) {
- int index = 0;
+ ClanBuddyListNamesPacket::~ClanBuddyListNamesPacket()
+ {
+ delete usernames;
+ delete nicks;
+ delete userids;
+ }
- VariableValue friends;
+ void ClanBuddyListNamesPacket::parseContent(char *buf, int, int)
+ {
+ int index = 0;
- XDEBUG2( "Len: %d\n", length );
+ VariableValue friends;
- index+=2; //paar bytes überspringen
+ XDEBUG2("Len: %d\n", length);
- index += friends.readValue(buf,index,2);
- this->clanid = friends.getValueAsLong();
+ index += 2; //paar bytes überspringen
- index+=4; //paar bytes überspringen
+ index += friends.readValue(buf, index, 2);
+ this->clanid = friends.getValueAsLong();
- userids = new vector<long>;
+ index += 4; //paar bytes überspringen
- index += friends.readValue(buf,index);
-
- int numberOfIds = friends.getValueAsLong();
+ userids = new vector<long>;
- XDEBUG2( "numberofId: %d\n", numberOfIds );
+ index += friends.readValue(buf, index);
- for(int i = 0 ; i < numberOfIds ; i++) {
- index += friends.readValue(buf,index,4);
- userids->push_back(friends.getValueAsLong());
- XDEBUG3( "UserID: %ld %ld\n",i+1, friends.getValueAsLong() );
- }
+ int numberOfIds = friends.getValueAsLong();
- XDEBUG2( "NextByte: %c\n",buf[index] );
- XDEBUG2( "NextByte: %c\n",buf[index+1] );
+ XDEBUG2("numberofId: %d\n", numberOfIds);
- index+=3; //nächsten 3 skippen
+ for (int i = 0; i < numberOfIds; i++) {
+ index += friends.readValue(buf, index, 4);
+ userids->push_back(friends.getValueAsLong());
+ XDEBUG3("UserID: %ld %ld\n", i + 1, friends.getValueAsLong());
+ }
- XDEBUG2( "NextByte: %c\n",buf[index] );
- XDEBUG2( "NextByte: %c\n",buf[index+1] );
-
- usernames = new vector<string>;
- index = readStrings(usernames,buf,index);
+ XDEBUG2("NextByte: %c\n", buf[index]);
+ XDEBUG2("NextByte: %c\n", buf[index + 1]);
- index+=3; //nächsten 3 skippen
+ index += 3; //nächsten 3 skippen
- nicks = new vector<string>;
- index = readStrings(nicks,buf,index);
+ XDEBUG2("NextByte: %c\n", buf[index]);
+ XDEBUG2("NextByte: %c\n", buf[index + 1]);
- }
+ usernames = new vector<string>;
+ index = readStrings(usernames, buf, index);
- int ClanBuddyListNamesPacket::readStrings(vector<string> *strings, char *buf, int index) {
- VariableValue friends;
- index += friends.readValue(buf,index,2);
- //index ++; // Ignore 00
- int numberOfStrings = friends.getValueAsLong();
- XDEBUG3( "name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings );
- for(int i = 0 ; i < numberOfStrings ; i++) {
- int length = (unsigned char)buf[index++];
- index++;
- index += friends.readValue(buf,index,length);
- string stringvalue = string(friends.getValue(),length);
- strings->push_back(stringvalue);
- XDEBUG(( "String length: %2d : %s\n", length, stringvalue.c_str() ));
- }
- return index;
- }
+ index += 3; //nächsten 3 skippen
+ nicks = new vector<string>;
+ index = readStrings(nicks, buf, index);
+ }
+
+ int ClanBuddyListNamesPacket::readStrings(vector<string> *strings, char *buf, int index)
+ {
+ VariableValue friends;
+ index += friends.readValue(buf, index, 2);
+ //index ++; // Ignore 00
+ int numberOfStrings = friends.getValueAsLong();
+ XDEBUG3("name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings);
+ for (int i = 0; i < numberOfStrings; i++) {
+ int length = (unsigned char)buf[index++];
+ index++;
+ index += friends.readValue(buf, index, length);
+ string stringvalue = string(friends.getValue(), length);
+ strings->push_back(stringvalue);
+ XDEBUG(("String length: %2d : %s\n", length, stringvalue.c_str()));
+ }
+ return index;
+ }
};