particles.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. Minetest
  3. Copyright (C) 2020 sfan5 <sfan5@live.de>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #include "particles.h"
  17. #include "util/serialize.h"
  18. void ParticleParameters::serialize(std::ostream &os, u16 protocol_ver) const
  19. {
  20. writeV3F32(os, pos);
  21. writeV3F32(os, vel);
  22. writeV3F32(os, acc);
  23. writeF32(os, expirationtime);
  24. writeF32(os, size);
  25. writeU8(os, collisiondetection);
  26. os << serializeLongString(texture);
  27. writeU8(os, vertical);
  28. writeU8(os, collision_removal);
  29. animation.serialize(os, 6); /* NOT the protocol ver */
  30. writeU8(os, glow);
  31. writeU8(os, object_collision);
  32. writeU16(os, node.param0);
  33. writeU8(os, node.param2);
  34. writeU8(os, node_tile);
  35. }
  36. void ParticleParameters::deSerialize(std::istream &is, u16 protocol_ver)
  37. {
  38. pos = readV3F32(is);
  39. vel = readV3F32(is);
  40. acc = readV3F32(is);
  41. expirationtime = readF32(is);
  42. size = readF32(is);
  43. collisiondetection = readU8(is);
  44. texture = deSerializeLongString(is);
  45. vertical = readU8(is);
  46. collision_removal = readU8(is);
  47. animation.deSerialize(is, 6); /* NOT the protocol ver */
  48. glow = readU8(is);
  49. object_collision = readU8(is);
  50. // This is kinda awful
  51. u16 tmp_param0 = readU16(is);
  52. if (is.eof())
  53. return;
  54. node.param0 = tmp_param0;
  55. node.param2 = readU8(is);
  56. node_tile = readU8(is);
  57. }