1
/***************************************************************************
2
* Copyright (C) 2009 by The qGo Project *
4
* This file is part of qGo. *
6
* qGo is free software: you can redistribute it and/or modify *
7
* it under the terms of the GNU General Public License as published by *
8
* the Free Software Foundation; either version 2 of the License, or *
9
* (at your option) any later version. *
11
* This program is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU General Public License for more details. *
16
* You should have received a copy of the GNU General Public License *
17
* along with this program; if not, see <http://www.gnu.org/licenses/> *
18
* or write to the Free Software Foundation, Inc., *
19
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20
***************************************************************************/
33
/* This is a huge pain in the ass and probably just
34
* a waste of time. Its like, if I don't want to allocate
35
* the records and copy the data to them because that's a
36
* waste, then its like I have to override an accessor
37
* function. So then I guess its like a RecordShell that
38
* returns a record offset by the index * sizeof the record.
39
* and then maybe a type case */
44
virtual unsigned int size() = 0;
50
RecordShell(class PacketRecord & p, void * d) : records(p), data(d) {};
51
class PacketRecord & operator[](int i) { return *(PacketRecord *)((char *)data + (i * records.size())); };
53
class PacketRecord & records;
57
class ZeroPaddedString
60
ZeroPaddedString(int s, char * d) : size(s), data(d) {};
61
unsigned char operator[] (int index) { };
62
void operator=(char *) {};
69
class OROPlayerListPacket : public ProtocolPacket
72
OROPlayerListPacket(char * p) : data(p), playerRecord(pr, p) { };
74
unsigned short unknown(void) { return *(unsigned short * )data; };
75
unsigned char playerRecords(void) { return (unsigned char )((char *)data)[2]; };
76
/* Need to pass it data pointer, but then offset by RecordShell ?
77
* or RecordShell does all offsets, data */
78
class PlayerRecord : public PacketRecord
81
PlayerRecord(void) : name(10) {};
82
unsigned int size(void) { return 0x28; };
83
ZeroPaddedString name;
84
unsigned short id(void) { return (unsigned short)*((char *)this + 0x0a); };
85
unsigned char specialIdByte(void) { return (unsigned char)*((char *)this + 0xc); };
86
unsigned char rankByte(void) { return (unsigned char)*((char *)this + 0xd); };
87
unsigned char unknown2;
88
unsigned char countryCode;
89
unsigned char inviteByte;
90
unsigned char unknown3;
91
unsigned short rankScore;
93
unsigned short losses;
94
unsigned short unknown4;
95
unsigned short unknown5;
97
const class RecordShell playerRecord;