MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / writeToFile

Method writeToFile

src/game/ServerItem.cpp:39–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39void ServerItem::writeToFile(std::ostream& out) const {
40 char buffer[ServerListCache::max_string + 1]; // ServerListCache::max_string is inherited from ServerListCache.h
41
42 // write out desc.
43 memset(buffer, 0, sizeof(buffer));
44 int copyLength = int(description.size() < ServerListCache::max_string ? description.size() : ServerListCache::max_string);
45 strncpy(&buffer[0], description.c_str(), copyLength);
46 out.write(buffer, sizeof(buffer));
47
48 // write out name
49 memset(buffer, 0, sizeof(buffer));
50 copyLength = int(name.size() < ServerListCache::max_string ? name.size() : ServerListCache::max_string);
51 strncpy(&buffer[0], name.c_str(), copyLength);
52 out.write(buffer, sizeof(buffer));
53
54 // write out pingpacket
55 ping.writeToFile(out);
56
57 // write out favorite status
58 nboPackUInt8(buffer, favorite);
59 out.write(buffer, 1);
60
61 // write out recent status
62 nboPackUInt8(buffer, recent);
63 out.write(buffer, 1);
64
65 // write out recent time
66 memset(buffer, 0, sizeof(buffer));
67 nboPackInt32(buffer, (int32_t)recentTime);
68 out.write(&buffer[0], 4);
69
70 // write out current time
71 memset(buffer, 0, sizeof(buffer));
72 nboPackInt32(buffer, (int32_t)updateTime);
73 out.write(&buffer[0], 4);
74}
75
76std::string ServerItem::getServerKey() const {
77 // Get the server's server key

Callers 1

saveCacheMethod · 0.45

Calls 5

nboPackUInt8Function · 0.85
nboPackInt32Function · 0.85
c_strMethod · 0.80
sizeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected