MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / processMessage

Method processMessage

source/tests/mocks/ODClientTest.cpp:86–448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86bool ODClientTest::processMessage(ServerNotificationType cmd, ODPacket& packetReceived)
87{
88 OD_LOG_INF("ServerNotificationType=" + ServerNotification::typeString(cmd));
89 switch(cmd)
90 {
91 case ServerNotificationType::loadLevel:
92 {
93 std::string odVersion;
94 BOOST_CHECK(packetReceived >> odVersion);
95
96 OD_LOG_INF("odVersion=" + odVersion);
97 // Map
98 int32_t mapSizeX;
99 int32_t mapSizeY;
100 BOOST_CHECK(packetReceived >> mapSizeX);
101 BOOST_CHECK(packetReceived >> mapSizeY);
102 OD_LOG_INF("map x=" + Helper::toString(mapSizeX) + ", y=" + Helper::toString(mapSizeX));
103 BOOST_CHECK(mapSizeX == 10);
104 BOOST_CHECK(mapSizeY == 20);
105
106 // Map infos
107 std::string str;
108 BOOST_CHECK(packetReceived >> str);
109 OD_LOG_INF("level filename=" + str);
110 BOOST_CHECK(packetReceived >> str);
111 OD_LOG_INF("level description=" + str);
112 BOOST_CHECK(packetReceived >> str);
113 OD_LOG_INF("level background music=" + str);
114 BOOST_CHECK(packetReceived >> str);
115 OD_LOG_INF("level fight music=" + str);
116
117 BOOST_CHECK(packetReceived >> str);
118 OD_LOG_INF("level tileset=" + (str.empty() ? "default" : str));
119
120 uint32_t nb;
121 // We read the seats
122 BOOST_CHECK(mSeats.empty());
123 BOOST_CHECK(packetReceived >> nb);
124 while(nb > 0)
125 {
126 --nb;
127 SeatData* seat = new SeatData;
128 seat->importFromPacket(packetReceived);
129 mSeats.push_back(seat);
130 OD_LOG_INF("Read seat id=" + Helper::toString(seat->getId()));
131 }
132
133 // We expect to have as many seats as players (+ rogue seat)
134 BOOST_CHECK(mSeats.size() == (mPlayers.size() + 1));
135
136 // We do not read the following data as it would imply to embed creature definitions
137 // and many other stuff
138 ODPacket packSend;
139 packSend << ClientNotificationType::levelOK;
140 send(packSend);
141 return true;
142 }
143

Callers

nothing calls this directly

Calls 5

clearMethod · 0.80
toStringFunction · 0.50
importFromPacketMethod · 0.45
getIdMethod · 0.45

Tested by

no test coverage detected