X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Futility.h;h=97f902b995f8ee8699f1712a00fa1861a6923e67;hb=fadf248892eae825b57d283032594ed924d8dbea;hp=7c1fde6f0798200d0149a80e0ea56a6dda7076ad;hpb=eed727c61b51f46f6d172c56ecd26a3b1752d449;p=oweals%2Fminetest.git diff --git a/src/utility.h b/src/utility.h index 7c1fde6f0..97f902b99 100644 --- a/src/utility.h +++ b/src/utility.h @@ -32,9 +32,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common_irrlicht.h" #include "debug.h" -#include "strfnd.h" #include "exceptions.h" #include "porting.h" +#include "strfnd.h" // For trim() extern const v3s16 g_6dirs[6]; @@ -148,6 +148,19 @@ inline v3f readV3F1000(u8 *data) return p; } +inline void writeV2F1000(u8 *data, v2f p) +{ + writeF1000(&data[0], p.X); + writeF1000(&data[4], p.Y); +} +inline v2f readV2F1000(u8 *data) +{ + v2f p; + p.X = (float)readF1000(&data[0]); + p.Y = (float)readF1000(&data[4]); + return p; +} + inline void writeV2S16(u8 *data, v2s16 p) { writeS16(&data[0], p.X); @@ -274,6 +287,45 @@ inline v3f readV3F1000(std::istream &is) return readV3F1000((u8*)buf); } +inline void writeV2F1000(std::ostream &os, v2f p) +{ + char buf[8]; + writeV2F1000((u8*)buf, p); + os.write(buf, 8); +} +inline v2f readV2F1000(std::istream &is) +{ + char buf[8]; + is.read(buf, 8); + return readV2F1000((u8*)buf); +} + +inline void writeV2S16(std::ostream &os, v2s16 p) +{ + char buf[4]; + writeV2S16((u8*)buf, p); + os.write(buf, 4); +} +inline v2s16 readV2S16(std::istream &is) +{ + char buf[4]; + is.read(buf, 4); + return readV2S16((u8*)buf); +} + +inline void writeV3S16(std::ostream &os, v3s16 p) +{ + char buf[6]; + writeV3S16((u8*)buf, p); + os.write(buf, 6); +} +inline v3s16 readV3S16(std::istream &is) +{ + char buf[6]; + is.read(buf, 6); + return readV3S16((u8*)buf); +} + /* None of these are used at the moment */