2014-06-01 17:55:23 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the DXX-Rebirth project <http://www.dxx-rebirth.com/>.
|
|
|
|
* It is copyright by its individual contributors, as recorded in the
|
|
|
|
* project's Git history. See COPYING.txt at the top level for license
|
|
|
|
* terms and a link to the Git history.
|
|
|
|
*/
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Segment Loading Stuff
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "segment.h"
|
2014-07-20 01:09:55 +00:00
|
|
|
#include "physfsx.h"
|
2014-10-04 17:33:25 +00:00
|
|
|
#include "physfs-serial.h"
|
|
|
|
|
|
|
|
DEFINE_SERIAL_UDT_TO_MESSAGE(wallnum_t, w, (w.value));
|
|
|
|
ASSERT_SERIAL_UDT_MESSAGE_SIZE(wallnum_t, 2);
|
|
|
|
DEFINE_SERIAL_UDT_TO_MESSAGE(side, s, (s.wall_num, s.tmap_num, s.tmap_num2));
|
|
|
|
ASSERT_SERIAL_UDT_MESSAGE_SIZE(side, 6);
|
|
|
|
|
|
|
|
void segment_side_wall_tmap_write(PHYSFS_file *fp, const side &side)
|
|
|
|
{
|
|
|
|
PHYSFSX_serialize_write(fp, side);
|
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-10-04 17:53:09 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_II)
|
2006-03-20 17:12:09 +00:00
|
|
|
/*
|
2011-06-01 07:59:55 +00:00
|
|
|
* reads a segment2 structure from a PHYSFS_file
|
2006-03-20 17:12:09 +00:00
|
|
|
*/
|
2014-10-21 03:14:36 +00:00
|
|
|
void segment2_read(segment *s2, PHYSFS_file *fp)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2011-06-01 07:59:55 +00:00
|
|
|
s2->special = PHYSFSX_readByte(fp);
|
|
|
|
s2->matcen_num = PHYSFSX_readByte(fp);
|
|
|
|
s2->value = PHYSFSX_readByte(fp);
|
|
|
|
s2->s2_flags = PHYSFSX_readByte(fp);
|
|
|
|
s2->static_light = PHYSFSX_readFix(fp);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2011-06-01 07:59:55 +00:00
|
|
|
* reads a delta_light structure from a PHYSFS_file
|
2006-03-20 17:12:09 +00:00
|
|
|
*/
|
2011-06-01 07:59:55 +00:00
|
|
|
void delta_light_read(delta_light *dl, PHYSFS_file *fp)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2011-06-01 07:59:55 +00:00
|
|
|
dl->segnum = PHYSFSX_readShort(fp);
|
|
|
|
dl->sidenum = PHYSFSX_readByte(fp);
|
|
|
|
dl->dummy = PHYSFSX_readByte(fp);
|
|
|
|
dl->vert_light[0] = PHYSFSX_readByte(fp);
|
|
|
|
dl->vert_light[1] = PHYSFSX_readByte(fp);
|
|
|
|
dl->vert_light[2] = PHYSFSX_readByte(fp);
|
|
|
|
dl->vert_light[3] = PHYSFSX_readByte(fp);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2011-06-01 07:59:55 +00:00
|
|
|
* reads a dl_index structure from a PHYSFS_file
|
2006-03-20 17:12:09 +00:00
|
|
|
*/
|
2011-06-01 07:59:55 +00:00
|
|
|
void dl_index_read(dl_index *di, PHYSFS_file *fp)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2011-06-01 07:59:55 +00:00
|
|
|
di->segnum = PHYSFSX_readShort(fp);
|
|
|
|
di->sidenum = PHYSFSX_readByte(fp);
|
|
|
|
di->count = PHYSFSX_readByte(fp);
|
|
|
|
di->index = PHYSFSX_readShort(fp);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
2014-10-21 03:14:36 +00:00
|
|
|
void segment2_write(const segment *s2, PHYSFS_file *fp)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
PHYSFSX_writeU8(fp, s2->special);
|
|
|
|
PHYSFSX_writeU8(fp, s2->matcen_num);
|
|
|
|
PHYSFSX_writeU8(fp, s2->value);
|
|
|
|
PHYSFSX_writeU8(fp, s2->s2_flags);
|
|
|
|
PHYSFSX_writeFix(fp, s2->static_light);
|
|
|
|
}
|
|
|
|
|
|
|
|
void delta_light_write(delta_light *dl, PHYSFS_file *fp)
|
|
|
|
{
|
|
|
|
PHYSFS_writeSLE16(fp, dl->segnum);
|
|
|
|
PHYSFSX_writeU8(fp, dl->sidenum);
|
|
|
|
PHYSFSX_writeU8(fp, dl->dummy);
|
|
|
|
PHYSFSX_writeU8(fp, dl->vert_light[0]);
|
|
|
|
PHYSFSX_writeU8(fp, dl->vert_light[1]);
|
|
|
|
PHYSFSX_writeU8(fp, dl->vert_light[2]);
|
|
|
|
PHYSFSX_writeU8(fp, dl->vert_light[3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void dl_index_write(dl_index *di, PHYSFS_file *fp)
|
|
|
|
{
|
|
|
|
PHYSFS_writeSLE16(fp, di->segnum);
|
|
|
|
PHYSFSX_writeU8(fp, di->sidenum);
|
|
|
|
PHYSFSX_writeU8(fp, di->count);
|
|
|
|
PHYSFS_writeSLE16(fp, di->index);
|
|
|
|
}
|
2014-10-04 17:53:09 +00:00
|
|
|
#endif
|