mystara
Member
|
Bug in order of parameters?
Gaah, I cannot seem to figure out this bug.
It seems that the bytes in my TCP message are being reversed somewhere.
Client side:
Code:
void Server::sendData(Vec pos)
{
File f;
f.writeMem();
f.putByte(MY_MESSAGE);
f.putFlt(pos.x); f.putFlt(pos.y);f.putFlt(pos.z);
f.pos(0);
Gui.msgBox("Pos is", S+pos);
tcp.dataFull(f, f.size());
}
Server side:
Code:
if (connection.receive(0))
{
connection.data.pos(0);
Byte msgType = connection.data.getByte();
if (msgType == MY_MESSAGE)
{
Vec pos = Vec(connection.data.getFlt(),
connection.data.getFlt(), connection.data.getFlt());
Gui.msgBox("Position", S + pos);
}
}
Output at client: 1.0, 2.0, 3.0
Output at server: 3.0, 2.0, 1.0
No idea why :(
(This post was last modified: 06-12-2011 02:15 PM by mystara.)
|
|
06-11-2011 10:31 PM |
|
Esenthel
Administrator
|
RE: Bug in order of parameters?
Vec(connection.data.getFlt(),
connection.data.getFlt(), connection.data.getFlt());
C++ sets function parameters from last to first, so do manually:
pos.x=getflt
pos.y=getflt
pos.z=getflt
|
|
06-13-2011 11:36 AM |
|
mystara
Member
|
RE: Bug in order of parameters?
Ah, thanks. I never would have figured that out
|
|
06-13-2011 08:05 PM |
|