tm512

Untitled

Jun 26th, 2011
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. uint8_t *P_MakeMobjBuffer (void)
  2. {
  3. int i, j;
  4. thinker_t *current;
  5. uint8_t *mobjbuf = malloc(MAX_MOBJ_BUFFER);
  6.  
  7. current = thinkercap.next;
  8. i = 1;
  9. j = 0;
  10. memset(mobjbuf, 0, MAX_MOBJ_BUFFER);
  11.  
  12. while (current != &thinkercap)
  13. {
  14. if (current->function.acp1 == (actionf_p1)P_MobjThinker && ((mobj_t*)current)->type != MT_PLAYER)
  15. {
  16. if(((mobj_t*)current)->netid == i) // The mobj for "i" is still here
  17. {
  18. mobjbuf[j] |= 1 << (i % 8);
  19. current = current->next;
  20. }
  21.  
  22. j += (!(++i % 8));
  23.  
  24. if(j == MAX_MOBJ_BUFFER - 1)
  25. I_Error("P_MakeMobjBuffer: Buffer overflow\n");
  26. }
  27. else
  28. current = current->next;
  29. }
  30. /*
  31. void *p = mobjbuf;
  32. for (i = 0; i < 63; i++)
  33. printf("%i ", ReadUInt8((uint8_t**)&p));
  34. printf("\n");
  35. */
  36. free(mobjbuf);
  37. mobjbuf = NULL;
  38. return mobjbuf;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment