Subversion Repositories Games.Descent

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
  3.  * It is copyright by its individual contributors, as recorded in the
  4.  * project's Git history.  See COPYING.txt at the top level for license
  5.  * terms and a link to the Git history.
  6.  */
  7.  
  8. /*
  9.  *
  10.  * Segment Loading Stuff
  11.  *
  12.  */
  13.  
  14.  
  15. #include "segment.h"
  16. #include "physfsx.h"
  17. #include "physfs-serial.h"
  18.  
  19. namespace dcx {
  20.  
  21. #if 0
  22. DEFINE_SERIAL_UDT_TO_MESSAGE(wallnum_t, w, (w.value));
  23. ASSERT_SERIAL_UDT_MESSAGE_SIZE(wallnum_t, 2);
  24. #endif
  25.  
  26. namespace {
  27.  
  28. struct composite_side
  29. {
  30.         const shared_side &sside;
  31.         const unique_side &uside;
  32. };
  33.  
  34. DEFINE_SERIAL_UDT_TO_MESSAGE(composite_side, s, (s.sside.wall_num, s.uside.tmap_num, s.uside.tmap_num2));
  35. ASSERT_SERIAL_UDT_MESSAGE_SIZE(composite_side, 6);
  36.  
  37. }
  38.  
  39. void segment_side_wall_tmap_write(PHYSFS_File *fp, const shared_side &sside, const unique_side &uside)
  40. {
  41.         PHYSFSX_serialize_write(fp, composite_side{sside, uside});
  42. }
  43.  
  44. }
  45.  
  46. #if defined(DXX_BUILD_DESCENT_II)
  47. namespace dsx {
  48.  
  49. /*
  50.  * reads a delta_light structure from a PHYSFS_File
  51.  */
  52. void delta_light_read(delta_light *dl, PHYSFS_File *fp)
  53. {
  54.         dl->segnum = PHYSFSX_readShort(fp);
  55.         dl->sidenum = PHYSFSX_readByte(fp);
  56.         PHYSFSX_readByte(fp);
  57.         dl->vert_light[0] = PHYSFSX_readByte(fp);
  58.         dl->vert_light[1] = PHYSFSX_readByte(fp);
  59.         dl->vert_light[2] = PHYSFSX_readByte(fp);
  60.         dl->vert_light[3] = PHYSFSX_readByte(fp);
  61. }
  62.  
  63.  
  64. /*
  65.  * reads a dl_index structure from a PHYSFS_File
  66.  */
  67. void dl_index_read(dl_index *di, PHYSFS_File *fp)
  68. {
  69.         di->segnum = PHYSFSX_readShort(fp);
  70.         di->sidenum = PHYSFSX_readByte(fp);
  71.         di->count = PHYSFSX_readByte(fp);
  72.         di->index = PHYSFSX_readShort(fp);
  73. }
  74.  
  75. void segment2_write(const cscusegment s2, PHYSFS_File *fp)
  76. {
  77.         PHYSFSX_writeU8(fp, s2.s.special);
  78.         PHYSFSX_writeU8(fp, s2.s.matcen_num);
  79.         PHYSFSX_writeU8(fp, s2.s.station_idx);
  80.         PHYSFSX_writeU8(fp, s2.s.s2_flags);
  81.         PHYSFSX_writeFix(fp, s2.u.static_light);
  82. }
  83.  
  84. void delta_light_write(const delta_light *dl, PHYSFS_File *fp)
  85. {
  86.         PHYSFS_writeSLE16(fp, dl->segnum);
  87.         PHYSFSX_writeU8(fp, dl->sidenum);
  88.         PHYSFSX_writeU8(fp, 0);
  89.         PHYSFSX_writeU8(fp, dl->vert_light[0]);
  90.         PHYSFSX_writeU8(fp, dl->vert_light[1]);
  91.         PHYSFSX_writeU8(fp, dl->vert_light[2]);
  92.         PHYSFSX_writeU8(fp, dl->vert_light[3]);
  93. }
  94.  
  95. void dl_index_write(const dl_index *di, PHYSFS_File *fp)
  96. {
  97.         PHYSFS_writeSLE16(fp, di->segnum);
  98.         PHYSFSX_writeU8(fp, di->sidenum);
  99.         PHYSFSX_writeU8(fp, di->count);
  100.         PHYSFS_writeSLE16(fp, di->index);
  101. }
  102.  
  103. }
  104. #endif
  105.