MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / MultiCheckToRepositionPowerups

Function MultiCheckToRepositionPowerups

Descent3/multi_server.cpp:1886–1935  ·  view source on GitHub ↗

Checks to see if its any powerups need repositioning on the client machine

Source from the content-addressed store, hash-verified

1884
1885// Checks to see if its any powerups need repositioning on the client machine
1886void MultiCheckToRepositionPowerups() {
1887 int i;
1888 static int invis_id = -2;
1889
1890 if (invis_id == -2) {
1891 invis_id = FindObjectIDName("InvisiblePowerup");
1892 }
1893
1894 int changed = 0;
1895
1896 for (i = 0; i <= Highest_object_index; i++) {
1897 object *obj = &Objects[i];
1898 if (obj->type != OBJ_POWERUP)
1899 continue;
1900
1901 if (obj->id == invis_id)
1902 continue;
1903
1904 if (obj->flags & OF_DEAD)
1905 continue;
1906
1907 if (obj->flags & OF_STOPPED_THIS_FRAME) {
1908 // Send out our positional change
1909 int count = 0;
1910 uint8_t data[MAX_GAME_DATA_SIZE];
1911 int size = START_DATA(MP_POWERUP_REPOSITION, data, &count);
1912 changed++;
1913
1914 MultiAddUshort(i, data, &count);
1915 // memcpy (&data[count],&obj->pos,sizeof(vector));
1916 // count+=sizeof(vector);
1917 MultiAddVector(obj->pos, data, &count);
1918
1919 // Send room number and terrain flag
1920 MultiAddUshort(CELLNUM(obj->roomnum), data, &count);
1921
1922 if (OBJECT_OUTSIDE(obj))
1923 MultiAddByte(1, data, &count);
1924 else
1925 MultiAddByte(0, data, &count);
1926
1927 END_DATA(count, data, size);
1928 MultiSendReliablyToAllExcept(Player_num, data, count, NETSEQ_OBJECTS, false);
1929 }
1930 }
1931
1932 if (changed > 0) {
1933 mprintf(0, "Stopped=%d\n", changed);
1934 }
1935}
1936
1937// Checks to see if its time to respawn any powerups
1938void MultiCheckToRespawnPowerups() {

Callers 1

MultiDoServerFrameFunction · 0.85

Calls 7

FindObjectIDNameFunction · 0.85
START_DATAFunction · 0.85
MultiAddUshortFunction · 0.85
MultiAddVectorFunction · 0.85
MultiAddByteFunction · 0.85
END_DATAFunction · 0.85

Tested by

no test coverage detected