MCPcopy Create free account
hub / github.com/cuberite/cuberite / HandleServerSpawnObjectVehicle

Method HandleServerSpawnObjectVehicle

Tools/ProtoProxy/Connection.cpp:2235–2309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2233
2234
2235bool cConnection::HandleServerSpawnObjectVehicle(void)
2236{
2237 #ifdef _DEBUG
2238 // DEBUG:
2239 // This packet is still troublesome when DataIndicator != 0
2240 AString Buffer;
2241 m_ServerBuffer.ResetRead();
2242 m_ServerBuffer.ReadAll(Buffer);
2243 m_ServerBuffer.ResetRead();
2244 UInt32 PacketLen, PacketType;
2245 m_ServerBuffer.ReadVarInt(PacketLen);
2246 m_ServerBuffer.ReadVarInt(PacketType);
2247 if (Buffer.size() > 128)
2248 {
2249 // Only log up to 128 bytes
2250 Buffer.erase(128, AString::npos);
2251 }
2252 DataLog(Buffer.data(), Buffer.size(), "Buffer while parsing the PACKET_SPAWN_OBJECT_VEHICLE packet (%d bytes):", Buffer.size());
2253 #endif // _DEBUG
2254
2255 HANDLE_SERVER_PACKET_READ(ReadVarInt, UInt32, EntityID);
2256 HANDLE_SERVER_PACKET_READ(ReadByte, Byte, ObjType);
2257 HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosX);
2258 HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosY);
2259 HANDLE_SERVER_PACKET_READ(ReadBEInt, int, PosZ);
2260 HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Pitch);
2261 HANDLE_SERVER_PACKET_READ(ReadByte, Byte, Yaw);
2262 HANDLE_SERVER_PACKET_READ(ReadBEInt, int, DataIndicator);
2263 AString ExtraData;
2264 short VelocityX = 0;
2265 short VelocityY = 0;
2266 short VelocityZ = 0;
2267 if (DataIndicator != 0)
2268 {
2269 HANDLE_SERVER_PACKET_READ(ReadBEShort, short, SpeedX);
2270 HANDLE_SERVER_PACKET_READ(ReadBEShort, short, SpeedY);
2271 HANDLE_SERVER_PACKET_READ(ReadBEShort, short, SpeedZ);
2272 VelocityX = SpeedX; VelocityY = SpeedY; VelocityZ = SpeedZ; // Speed vars are local to this scope, but we need them available later
2273 /*
2274 // This doesn't seem to work - for a falling block I'm getting no extra data at all
2275 int ExtraLen = 0;
2276 switch (ObjType)
2277 {
2278 case OBJECT_FALLING_BLOCK: ExtraLen = 4; break; // int: BlockType | (BlockMeta << 12)
2279 case OBJECT_ARROW:
2280 case OBJECT_SNOWBALL:
2281 case OBJECT_EGG:
2282 case OBJECT_EYE_OF_ENDER:
2283 case OBJECT_DRAGON_EGG:
2284 case OBJECT_FISHING_FLOAT:
2285 {
2286 ExtraLen = 4; break; // int: EntityID of the thrower
2287 }
2288 // TODO: Splash potions
2289 }
2290 if ((ExtraLen > 0) && !m_ServerBuffer.ReadString(ExtraData, ExtraLen))
2291 {
2292 return false;

Callers

nothing calls this directly

Calls 6

PrintableAbsIntTripletFunction · 0.85
ResetReadMethod · 0.80
ReadAllMethod · 0.80
sizeMethod · 0.80
c_strMethod · 0.80
ReadVarIntMethod · 0.45

Tested by

no test coverage detected