I can't seem to figure this out. For some reason i get no errors at all when i do this:
Code:
ByteStream packet = PacketInt1(UNLIMITEDSIG);
But when i do this:
Code:
ByteStream packet(PacketInt1(UNLIMITEDSIG));
I get a whole bunch of errors associated with the "packet" object.
Both of these statements should call this constructor:
Code:
template <class T> ByteStream(const T& data);
This is the errors i get when i call the second method:
Code:
G:\GServerEmulator\src\Player.cpp: In member function `void Player::InitializeClient()':
G:\GServerEmulator\src\Player.cpp:138: error: assignment of function `ByteStream packet(PacketInt1)'
G:\GServerEmulator\src\Player.cpp:138: error: cannot convert `PacketInt1' to `ByteStream ()(PacketInt1)' in assignment
G:\GServerEmulator\src\Player.cpp:142: error: invalid operands of types `ByteStream ()(PacketInt1)' and `const char[2]' to binary `operator<<'
G:\GServerEmulator\src\Player.cpp:147: error: assignment of function `ByteStream packet(PacketInt1)'
G:\GServerEmulator\src\Player.cpp:147: error: cannot convert `PacketInt1' to `ByteStream ()(PacketInt1)' in assignment
G:\GServerEmulator\src\Player.cpp:152: error: no match for 'operator<<' in 'packet << PacketInt1(((int)i))'
G:\GServerEmulator\src\/ByteStream.h: In constructor `ByteStream::ByteStream(const T&) [with T = ByteStream ()(PacketInt1)]':
G:\GServerEmulator\src\Player.cpp:122: instantiated from here
G:\GServerEmulator\src\/ByteStream.h:91: error: invalid application of `sizeof' to a function type
G:\GServerEmulator\src\/ByteStream.h:92: error: invalid application of `sizeof' to a function type
Heres the full code for that function:
Code:
void Player::InitializeClient()
{
//Allow more than 8 players
ByteStream packet(PacketInt1(UNLIMITEDSIG));
//PacketInt1(73);
WritePacket(packet);
if(Account::loadOnly)
{
Player* duplicatePlayer = server.FindPlayer(Account::name);
if(duplicatePlayer)
{
//To do:
}
}
if(clientType == CLIENTPLAYER)
{
//Send staff guild tags
packet = PacketInt1(SSTAFFGUILDS);
const vector<string>& staffGuilds = server.GetStaffGuilds();
for(unsigned int i = 0; i < staffGuilds.size(); ++i)
packet << "\"" << staffGuilds[i] << "\",";
WritePacket(packet);
//Send the players properties
packet = PacketInt1(SPLAYERPROPS);
for(unsigned int i = 0; i < PROPS_COUNT; ++i)
{
if (sendInit[i])
packet << PacketInt1(i) << GetProperty(i);
}
WritePacket(packet);
}
}
Heres the constructor for ByteStream
Code:
template <class T>
ByteStream::ByteStream(const T& data)
{
buffer = 0;
Clear(sizeof(T));
Write((char*)&data, sizeof(T));
}
The compiler is mingw