diff options
| author | relnev <relnev@5198baeb-e213-0410-be47-fc2ff85ca46f> | 2003-01-08 09:52:19 +0000 |
|---|---|---|
| committer | relnev <relnev@5198baeb-e213-0410-be47-fc2ff85ca46f> | 2003-01-08 09:52:19 +0000 |
| commit | 507a7479adb2cab5218bbb64950b739dcd79b6d5 (patch) | |
| tree | 6e45861e91df133f156fdf216167e588497784ac /Source/Serialize.cpp | |
| parent | 8efed35df02822682576bae088f5b6a5c78e8dc9 (diff) | |
| download | blackshades-507a7479adb2cab5218bbb64950b739dcd79b6d5.tar.gz | |
completed FSRead serialization
git-svn-id: svn://svn.icculus.org/blackshades/trunk@45 5198baeb-e213-0410-be47-fc2ff85ca46f
Diffstat (limited to 'Source/Serialize.cpp')
| -rw-r--r-- | Source/Serialize.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/Source/Serialize.cpp b/Source/Serialize.cpp index 3826a3f..cc92897 100644 --- a/Source/Serialize.cpp +++ b/Source/Serialize.cpp @@ -6,12 +6,29 @@ /* these all read big-endian data */ +int ReadBool(int fd, int count, bool *b) +{ + while (count--) { + unsigned char buf[1]; + + if (read(fd, buf, 1) != 1) { + STUB_FUNCTION; + } + + *b = (buf[0] != 0) ? true : false; + + b++; + } +} + int ReadShort(int fd, int count, short *s) { while (count--) { unsigned char buf[2]; - read(fd, buf, 2); + if (read(fd, buf, 2) != 2) { + STUB_FUNCTION; + } *s = (short)((buf[0] << 8) | buf[1]); @@ -24,7 +41,9 @@ int ReadInt(int fd, int count, int *s) while (count--) { unsigned char buf[4]; - read(fd, buf, 2); + if (read(fd, buf, 4) != 4) { + STUB_FUNCTION; + } *s = (int)((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]); |
