Advertisement
finland9149

Growtopia sign's source codee.

Nov 22nd, 2019
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. void updateSign(ENetPeer* peer, int foreground, int x, int y, string text, int background)
  2. {
  3. PlayerMoving sign;
  4. sign.packetType = 0x3;
  5. sign.characterState = 0x0;
  6. sign.x = x;
  7. sign.y = y;
  8. sign.punchX = x;
  9. sign.punchY = y;
  10. sign.XSpeed = 0;
  11. sign.YSpeed = 0;
  12. sign.netID = -1;
  13. sign.plantingTree = foreground;
  14. SendPacketRaw(4, packPlayerMoving(&sign), 56, 0, peer, ENET_PACKET_FLAG_RELIABLE);
  15. int hmm = 8, wot = text.length(), lol = 0, wut = 5;
  16. int yeh = hmm + 3 + 1, idk = 15 + wot, lmao = -1, yey = 2; //idk = text_len + 15, wut = type(?), wot = text_len, yey = len of text_len
  17. int ok = 52 + idk;
  18. int kek = ok + 4, yup = ok - 8 - idk;
  19. int thonk = 4, magic = 56, wew = ok + 5 + 4;
  20. int wow = magic + 4 + 5;
  21. BYTE* data = new BYTE[kek];
  22. ENetPacket* p = enet_packet_create(0, wew, ENET_PACKET_FLAG_RELIABLE);
  23. for (int i = 0; i < kek; i++) data[i] = 0;
  24. memcpy(data, &wut, thonk);
  25. memcpy(data + yeh, &hmm, thonk); //read discord
  26. memcpy(data + yup, &x, 4);
  27. memcpy(data + yup + 4, &y, 4);
  28. memcpy(data + 4 + yup + 4, &idk, thonk);
  29. memcpy(data + magic, &foreground, yey);
  30. memcpy(data + magic + 2, &background, yey); //p100 fix by the one and only lapada
  31. memcpy(data + thonk + magic, &lol, thonk);
  32. memcpy(data + magic + 4 + thonk, &yey, 1);
  33. memcpy(data + wow, &wot, yey); //data + wow = text_len
  34. memcpy(data + yey + wow, text.c_str(), wot); //data + text_len_len + text_len_offs = text
  35. memcpy(data + ok, &lmao, thonk); //end ?
  36. memcpy(p->data, &thonk, thonk);
  37. memcpy((char*)p->data + thonk, data, kek); //kek = data_len
  38. ENetPeer* currentPeer;
  39. for (currentPeer = server->peers;
  40. currentPeer < &server->peers[server->peerCount];
  41. ++currentPeer)
  42. {
  43. if (currentPeer->state != ENET_PEER_STATE_CONNECTED)
  44. continue;
  45. if (isHere(peer, currentPeer)) {
  46. enet_peer_send(currentPeer, 0, p);
  47. }
  48. }
  49. delete data;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement