Skip to content

Commit

Permalink
Fix write and read S32 vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
BlockMen committed Apr 12, 2014
1 parent 7cdbb80 commit e149d1a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/util/serialize.h
Expand Up @@ -166,14 +166,14 @@ inline v2s16 readV2S16(const u8 *data)
inline void writeV2S32(u8 *data, v2s32 p)
{
writeS32(&data[0], p.X);
writeS32(&data[2], p.Y);
writeS32(&data[4], p.Y);
}

inline v2s32 readV2S32(const u8 *data)
{
v2s32 p;
p.X = readS32(&data[0]);
p.Y = readS32(&data[2]);
p.Y = readS32(&data[4]);
return p;
}

Expand Down Expand Up @@ -346,6 +346,19 @@ inline v2s16 readV2S16(std::istream &is)
return readV2S16((u8*)buf);
}

inline void writeV2S32(std::ostream &os, v2s32 p)
{
char buf[8] = {0};
writeV2S32((u8*)buf, p);
os.write(buf, 8);
}
inline v2s32 readV2S32(std::istream &is)
{
char buf[8] = {0};
is.read(buf, 8);
return readV2S32((u8*)buf);
}

inline void writeV3S16(std::ostream &os, v3s16 p)
{
char buf[6] = {0};
Expand Down

0 comments on commit e149d1a

Please sign in to comment.