Advertisement
tm512

Untitled

Jun 26th, 2011
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. // [tm512] P_MakeMobjBuffer
  2. // Cycle the thinker list, creating an array of bitmasks saying whether the mobj is there anymore or not.
  3. // Sent to clients upon connect so they can remove items that aren't still on the map.
  4.  
  5. uint8_t *P_MakeMobjBuffer (void)
  6. {
  7. int i, j;
  8. thinker_t *current;
  9. uint8_t *mobjbuf = malloc(MAX_MOBJ_BUFFER);
  10.  
  11. current = thinkercap.next;
  12. i = 1;
  13. j = 0;
  14. memset(mobjbuf, 0, sizeof(mobjbuf));
  15.  
  16. while (current != &thinkercap)
  17. {
  18. if (current->function.acp1 == (actionf_p1)P_MobjThinker)
  19. {
  20. if(((mobj_t*)current)->netid == i) // The mobj for "i" is still here
  21. {
  22. mobjbuf[j] |= 1 << (i % 8);
  23. printf("Writing %i to the mobj buffer\n", i);
  24. current = current->next;
  25. }
  26.  
  27. j += (!(++i % 8));
  28.  
  29. if(j == MAX_MOBJ_BUFFER - 1)
  30. I_Error("P_MakeMobjBuffer: Buffer overflow\n");
  31. }
  32. }
  33.  
  34. return mobjbuf;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement