[gunzemulator] r361 committed - Fixed MUID creation.

0 views
Skip to first unread message

gunzem...@googlecode.com

unread,
Jun 30, 2010, 7:24:40 PM6/30/10
to gogo-dev...@googlegroups.com
Revision: 361
Author: cg.wowus.cg
Date: Wed Jun 30 16:20:09 2010
Log: Fixed MUID creation.
http://code.google.com/p/gunzemulator/source/detail?r=361

Modified:
/trunk/cockpit/src/packet/Parameters.cpp
/trunk/cockpit/test/test_parameters.cpp

=======================================
--- /trunk/cockpit/src/packet/Parameters.cpp Fri Jun 25 16:32:59 2010
+++ /trunk/cockpit/src/packet/Parameters.cpp Wed Jun 30 16:20:09 2010
@@ -256,9 +256,23 @@
type = 0x09;
}

+// MUIDs are strange. We need to swap the high and low DWORDs when we talk
to the client.
+// It's because they aren't TRUE uint64_ts... they're structs with the
same basic layout.
Buffer MUID::serialize() const
{
- return serialize_built_in(value.quad);
+ // Notice the swap?
+ uint64_t lowBytes = value.quad & 0xFFFFFFFF00000000;
+ uint64_t highBytes = value.quad & 0x00000000FFFFFFFF;
+
+ lowBytes >>= sizeof(uint32_t) * 8;
+ lowBytes &= 0x00000000FFFFFFFF;
+
+ highBytes <<= sizeof(uint32_t) * 8;
+ highBytes &= 0xFFFFFFFF00000000;
+
+ uint64_t final = highBytes | lowBytes;
+
+ return serialize_built_in(final);
}

blob::blob(boost::uint32_t eleCount, boost::uint32_t eleSize)
=======================================
--- /trunk/cockpit/test/test_parameters.cpp Wed Jun 23 09:54:48 2010
+++ /trunk/cockpit/test/test_parameters.cpp Wed Jun 30 16:20:09 2010
@@ -114,8 +114,8 @@
BOOST_CHECK(packit1.get_type() == 0x09);

uint8_t expected[] = {
- 0x88, 0x77, 0x66, 0x55,
- 0x44, 0x33, 0x22, 0x11
+ 0x44, 0x33, 0x22, 0x11,
+ 0x88, 0x77, 0x66, 0x55
};

check_array_equal(packit1.serialize().data(), expected,
countof(expected));

Reply all
Reply to author
Forward
0 new messages