Puts player "slot" position info into the passed in buffer Returns the number of bytes used
| 1892 | // Puts player "slot" position info into the passed in buffer |
| 1893 | // Returns the number of bytes used |
| 1894 | int MultiStuffPosition(int slot, uint8_t *data) { |
| 1895 | int size; |
| 1896 | int count = 0; |
| 1897 | uint8_t flags = 0; |
| 1898 | |
| 1899 | object *obj = &Objects[Players[slot].objnum]; |
| 1900 | |
| 1901 | size = START_DATA(MP_PLAYER_POS, data, &count); |
| 1902 | MultiAddByte(slot, data, &count); |
| 1903 | |
| 1904 | if (slot == Player_num) { |
| 1905 | // tell the reciever to expect fire information, only if |
| 1906 | // we fired this frame and it isn't going to be a seperate packet |
| 1907 | // (like secondaries in a non-peer to peer, are sent reliably) |
| 1908 | if (Player_fire_packet[slot].fired_on_this_frame == PFP_FIRED) |
| 1909 | flags |= MPF_FIRED; |
| 1910 | } |
| 1911 | |
| 1912 | // Send timestamp |
| 1913 | if (slot == Player_num) |
| 1914 | MultiAddFloat(Gametime, data, &count); |
| 1915 | else |
| 1916 | MultiAddFloat(NetPlayers[slot].packet_time, data, &count); |
| 1917 | |
| 1918 | // Do position |
| 1919 | MultiAddPositionData(&obj->pos, data, &count); |
| 1920 | |
| 1921 | // Do orientation |
| 1922 | angvec angs; |
| 1923 | vm_ExtractAnglesFromMatrix(&angs, &obj->orient); |
| 1924 | |
| 1925 | MultiAddShort(angs.p, data, &count); |
| 1926 | MultiAddShort(angs.h, data, &count); |
| 1927 | MultiAddShort(angs.b, data, &count); |
| 1928 | |
| 1929 | // Do roomnumber and terrain flag |
| 1930 | |
| 1931 | MultiAddShort(CELLNUM(obj->roomnum), data, &count); |
| 1932 | |
| 1933 | // Fill flags |
| 1934 | if (OBJECT_OUTSIDE(obj)) |
| 1935 | flags |= MPF_OUTSIDE; |
| 1936 | if (Players[slot].flags & PLAYER_FLAGS_AFTERBURN_ON) |
| 1937 | flags |= MPF_AFTERBURNER; |
| 1938 | if (Players[slot].flags & PLAYER_FLAGS_THRUSTED) |
| 1939 | flags |= MPF_THRUSTED; |
| 1940 | if (Objects[Players[slot].objnum].weapon_fire_flags & WFF_SPRAY) |
| 1941 | flags |= MPF_SPRAY; |
| 1942 | if (Objects[Players[slot].objnum].weapon_fire_flags & WFF_ON_OFF) |
| 1943 | flags |= MPF_ON_OFF; |
| 1944 | if (Players[slot].flags & PLAYER_FLAGS_DEAD) // || Players[slot].flags & PLAYER_FLAGS_DYING) |
| 1945 | flags |= MPF_DEAD; |
| 1946 | if (Players[slot].flags & PLAYER_FLAGS_HEADLIGHT) |
| 1947 | flags |= MPF_HEADLIGHT; |
| 1948 | |
| 1949 | // Do velocity |
| 1950 | vector *vel = &obj->mtype.phys_info.velocity; |
| 1951 | vector *rotvel = &obj->mtype.phys_info.rotvel; |
no test coverage detected