Guest User

SMSG_UPDATE_OBJECT packet structure

a guest
Apr 24th, 2016
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.00 KB | None | 0 0
  1. /*
  2. * Links:
  3. * Link1: https://github.com/TrinityCore/TrinityCore/blob/3.3.5/src/server/game/Entities/Object/Updates/UpdateData.h
  4. * Link2: https://github.com/TrinityCore/TrinityCore/blob/3.3.5/src/server/game/Entities/Object/ObjectGuid.h
  5. * Link3: https://github.com/TrinityCore/TrinityCore/blob/3.3.5/src/server/game/Entities/Unit/Unit.h
  6. * Link4: https://github.com/TrinityCore/TrinityCore/blob/3.3.5/src/server/game/Entities/Object/Updates/UpdateFields.h
  7. */
  8. SMSG_UPDATE_OBJECT {
  9.     // Total number of Update Blocks in this packet
  10.     uint32_t  updateBlockCount;
  11.    
  12.     UPDATE_BLOCK {
  13.         // Update Type: see enum OBJECT_UPDATE_TYPE in Link1
  14.         uint8_t  updateType;
  15.         // Bitmask (type uint8_t) + non-zero GUID bytes:
  16.         uint*_t  *packedGUID;
  17.         // Object Type: see enum TypeID in Link2
  18.         uint8_t  objectType;
  19.        
  20.         //------------------------------
  21.         // Movement Update Block:
  22.         //------------------------------
  23.         // Update Flags: see enum OBJECT_UPDATE_FLAGS in Link1
  24.         uint16_t  updateFlags;
  25.         if (UPDATEFLAG_LIVIING) {
  26.             // Movement Flags: see enum MovementFlags in Link3
  27.             uint32_t  movementFlags;
  28.             // Extra Movement Flags: see enum MovementFlags2 in Link3
  29.             uint16_t  extraMovementFlags;
  30.             // Time stamp
  31.             uint32_t  time;
  32.             // Object position (x, y, z)
  33.             float  position[3];
  34.             // Object orientation
  35.             float  orientation;
  36.  
  37.             if (MOVEMENT_FLAG_ONTRANSPORT) {
  38.                 // Packed GUID of transportation object that is transporting this object
  39.                 uint8_t  *transportGUID;
  40.                 // Position of the transportation object(x, y, z, o)
  41.                 float  transportPosition[4];
  42.                 uint32_t  transportTime;
  43.                 // Seat number on the transportation object that this object occupies
  44.                 uint8_t  transportSeat;
  45.                 if (MOVEMENTFLAG2_INTERPOLATED_MOVEMENT) {
  46.                     uint32_t  transportTime;
  47.                 }
  48.             }
  49.             if (MOVEMENT_FLAG_SWIMMING | MOVEMENT_FLAG_FLYING | EXTRA_MOVEMENT_FLAG_ALWAYS_ALLOW_PITCHING) {
  50.                 float  swimPitch;
  51.             }
  52.             uint32_t  fallTime;
  53.             if (MOVEMENT_FLAG_FALLING) {
  54.                 float  fallVelocity;
  55.                 float  fallSinAngle;
  56.                 float  fallCosAngle;
  57.                 float  fallSpeed;
  58.             }
  59.             if (MOVEMENT_FLAG_SPLINE_ELEVATION) {
  60.                 float  splineElevation;
  61.             }
  62.  
  63.             // Movement Speeds (in this order):
  64.             // MOVE_WALK, MOVE_RUN, MOVE_RUN_BACK,
  65.             // MOVE_SWIM, MOVE_SWIM_BACK, MOVE_FLIGHT,
  66.             // MOVE_FLIGHT_BACK, MOVE_TURN_RATE, MOVE_PITCH_RATE
  67.             float  speeds[9];
  68.             if (MOVEMENT_FLAG_SPLINE_ENABLED || hasSplineData) {
  69.                 uint32_t  splineFlags;
  70.                 if (SPLINE_FLAG_FINAL_TARGET) {
  71.                     uint64_t  finalSplineTargetGUID;
  72.                 }
  73.                 else if (SPLINE_FLAG_FINAL_ORIENTATION) {
  74.                     float  finalSplineOrientation;
  75.                 }
  76.                 else if (SPLINE_FLAG_FINAL_POINT) {
  77.                     float  finalSplineCoords[3];
  78.                 }
  79.                 uint32_t  splineTime;
  80.                 uint32_t  splineFullTime;
  81.                 uint32_t  splineID;
  82.                 float  splineDurationMultiplier;
  83.                 float  splineDurationMultiplierNext;
  84.                 float  splineVerticalAcceleration;
  85.                 uint32_t  splineStartTime;
  86.                 uint32_t  splineCount;
  87.                 float  splineWayPoint[splineCount][3];
  88.                 uint8_t  splineMode;
  89.                 float  splineEndPoint[3];
  90.             }
  91.         }
  92.         else { // !UPDATE_FLAG_LIVIING
  93.             if (UPDATE_FLAG_GO_POSITION) {
  94.                 uint8_t  *goTransportPackedGUID;
  95.                 float  goPosition[3];
  96.                 float  transportOffsets[3];
  97.                 float  goOrientation; //=transportOffsets orientation
  98.                 float  corpseOrientation               
  99.             }
  100.             else if (UPDATE_FLAG_STATIONARY_OBJECT) {
  101.                 float  stationaryPosition[3];
  102.                 float  stationaryOrientation;
  103.             }
  104.         }
  105.        
  106.         // I fail to see the point of this 2 flags, since you have to send packed GUID of this object
  107.         // at the very beginning of the update block but oh well.
  108.         if (UPDATE_FLAG_UNKNOWN_1) {  //0x008  // HIGH GUID
  109.             uint32_t  unknown1;
  110.         }
  111.         if (UPDATE_FLAG_LOW_GUID) {
  112.             uint32_t  lowGUID;
  113.         }
  114.  
  115.         if (UPDATE_FLAG_ATTACKING_TARGET) {
  116.             uint8_t  *targetPackedGUID;
  117.         }
  118.         if (UPDATE_FLAG_TRANSPORT) {
  119.             uint32_t  unknownTransportTimer;
  120.         }
  121.         if (UPDATE_FLAG_VEHICLE) {
  122.             uint32_t  vehicleID;
  123.             float  vehicleOrientation;
  124.         }
  125.  
  126.         // Copied, ripped-off magic from I can't remember where. Never tested this myself.
  127.         if (UPDATE_FLAG_GO_ROTATION) {
  128.             uint64_t packedQuarternion; // -> packed
  129.             /*//Magic:
  130.             float x = (packed >> 42)*(1.0f/2097152.0f);
  131.             float y = (((packed << 22) >> 32) >> 11)*(1.0f/1048576.0f);
  132.             float z = (packed << 43 >> 43)*(1.0f/1048576.0f);
  133.  
  134.             float w = x*x + y*y + z*z;
  135.             if (Math.Abs(w - 1.0f) >= (1/1048576.0f))
  136.                 w = (float) Math.Sqrt(1.0f - w);
  137.             else
  138.                 w = 0.0f;
  139.             */
  140.         }
  141.  
  142.         //-----------------------------
  143.         // Values update block
  144.         //-----------------------------    
  145.         // Depends on object Type:
  146.         // For player it's  (PLAYER_END + 31) / 32, where PLAYER_END is enum
  147.         // value from Link4.
  148.         // Basically you allocate enough DWORDs that can hold all values update flags
  149.         uint8_t  maskSize;
  150.         // Values update mask
  151.         uint32_t  updateMask[maskSize];
  152.         for every bit set in "updateMask"
  153.             uint32_t  updateField;
  154.            
  155.     }  
  156. }
Add Comment
Please, Sign In to add comment