aboutsummaryrefslogtreecommitdiff
path: root/src/util/serialize.h
diff options
context:
space:
mode:
authorBlockMen <nmuelll@web.de>2014-04-12 17:39:51 +0200
committerBlockMen <nmuelll@web.de>2014-04-12 17:39:51 +0200
commite149d1ad9a623b9f8ca597839f7b850841c54781 (patch)
treeea968bc3e764932732fc6c5df503986c245cc685 /src/util/serialize.h
parent7cdbb805d9f230b2cf00150884dc3fa4fbcde16f (diff)
downloadminetest-e149d1ad9a623b9f8ca597839f7b850841c54781.tar.gz
minetest-e149d1ad9a623b9f8ca597839f7b850841c54781.tar.bz2
minetest-e149d1ad9a623b9f8ca597839f7b850841c54781.zip
Fix write and read S32 vectors
Diffstat (limited to 'src/util/serialize.h')
-rw-r--r--src/util/serialize.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/util/serialize.h b/src/util/serialize.h
index 63713f7c4..3f9925287 100644
--- a/src/util/serialize.h
+++ b/src/util/serialize.h
@@ -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;
}
@@ -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};