MCPcopy Create free account
hub / github.com/crossuo/crossuo / CPacketBookHeaderChange

Method CPacketBookHeaderChange

src/Network/Packets.cpp:1238–1278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1236}
1237
1238CPacketBookHeaderChange::CPacketBookHeaderChange(CGumpBook *gump)
1239 : CPacket(1)
1240{
1241 // FIXME: PACKET: check if this should be ASCII or UTF8
1242 auto title = wstr_to_utf8(gump->m_EntryTitle->m_Entry.GetTextW());
1243 auto author = wstr_to_utf8(gump->m_EntryAuthor->m_Entry.GetTextW());
1244 auto titlelen = (uint16_t)title.length();
1245 auto authorlen = (uint16_t)author.length();
1246 size_t size = 16 + title.length() + author.length();
1247 Resize(size, true);
1248
1249 WriteUInt8(0xD4);
1250 WriteUInt16BE((uint16_t)size);
1251 WriteUInt32BE(gump->Serial);
1252 WriteUInt16BE((uint16_t)0x0000); //flags
1253 WriteUInt16BE((uint16_t)gump->PageCount);
1254 WriteUInt16BE(titlelen);
1255 if (titlelen != 0u)
1256 {
1257 const char *str = title.c_str();
1258
1259 for (int i = 0; i < titlelen; i++)
1260 {
1261 char ch = *(str + i);
1262 *Ptr++ = ch;
1263 }
1264 *Ptr = 0;
1265 }
1266 WriteUInt16BE(authorlen);
1267 if (authorlen != 0u)
1268 {
1269 const char *str = author.c_str();
1270
1271 for (int i = 0; i < authorlen; i++)
1272 {
1273 char ch = *(str + i);
1274 *Ptr++ = ch;
1275 }
1276 *Ptr = 0;
1277 }
1278}
1279
1280CPacketBookPageData::CPacketBookPageData(CGumpBook *gump, int page)
1281 : CPacket(1)

Callers

nothing calls this directly

Calls 4

wstr_to_utf8Function · 0.85
GetTextWMethod · 0.80
lengthMethod · 0.80
c_strMethod · 0.80

Tested by

no test coverage detected