diff --git a/dlls/monster/CBaseMonster.cpp b/dlls/monster/CBaseMonster.cpp index 934c0533..edcce57d 100644 --- a/dlls/monster/CBaseMonster.cpp +++ b/dlls/monster/CBaseMonster.cpp @@ -7023,6 +7023,8 @@ int CBaseMonster::GetScheduleTableIdx() { return i; } } + + return -1; } //========================================================= diff --git a/dlls/monster/monsters.h b/dlls/monster/monsters.h index 278fd366..e11514f9 100644 --- a/dlls/monster/monsters.h +++ b/dlls/monster/monsters.h @@ -105,10 +105,10 @@ EXPORT BOOL IsFacing(entvars_t* pevTest, const Vector& reference); #define bits_MEMORY_MOVE_FAILED ( 1 << 5 )// Movement has already failed #define bits_MEMORY_FLINCHED ( 1 << 6 )// Has already flinched #define bits_MEMORY_KILLED ( 1 << 7 )// HACKHACK -- remember that I've already called my Killed() -#define bits_MEMORY_CUSTOM4 ( 1 << 12 ) // Monster-specific memory -#define bits_MEMORY_CUSTOM3 ( 1 << 13 ) // Monster-specific memory -#define bits_MEMORY_CUSTOM2 ( 1 << 14 ) // Monster-specific memory -#define bits_MEMORY_CUSTOM1 ( 1 << 15 ) // Monster-specific memory +#define bits_MEMORY_CUSTOM4 ( 1 << 8 ) // Monster-specific memory +#define bits_MEMORY_CUSTOM3 ( 1 << 9 ) // Monster-specific memory +#define bits_MEMORY_CUSTOM2 ( 1 << 10 ) // Monster-specific memory +#define bits_MEMORY_CUSTOM1 ( 1 << 11 ) // Monster-specific memory // trigger conditions for scripted AI // these MUST match the CHOICES interface in halflife.fgd for the base monster @@ -197,7 +197,7 @@ class EXPORT CGib : public CBaseEntity if (baseIdx != -1) { \ return baseIdx; \ } \ - for (int i = 0; i < ARRAYSIZE(m_scheduleList); i++) { \ + for (int i = 0; i < (int)ARRAYSIZE(m_scheduleList); i++) { \ if (m_scheduleList[i] == m_pSchedule) { \ return baseClass::GetScheduleTableSize() + i; \ } \ diff --git a/dlls/mstream.cpp b/dlls/mstream.cpp index 22b407b4..f23dfa65 100644 --- a/dlls/mstream.cpp +++ b/dlls/mstream.cpp @@ -105,6 +105,22 @@ float mstream::readBitCoord() { return 0; } +bool mstream::endBitReading() { + if (currentBit) { + pos++; + currentBit = 0; + + if (pos >= end) { + eomFlag = true; + pos = end; + } + + return true; + } + + return false; +} + uint64_t mstream::write( void * src, uint64_t bytes ) { if (eomFlag) @@ -160,6 +176,22 @@ uint8_t mstream::writeBits(uint32_t value, uint8_t bitCount) { return bitCount; } +bool mstream::endBitWriting() { + if (currentBit == 0 || currentBit == 8) { + return false; + } + + while (currentBit != 8 && writeBit(0)); + + currentBit = 0; + pos++; + + if (pos + 1 >= end) { + eomFlag = true; + return true; + } +} + bool mstream::writeBitCoord(const float f) { int signbit = f <= -0.125; int intval = abs((int32)f); @@ -214,6 +246,20 @@ void mstream::seek( uint64_t to ) } } +void mstream::seekBits(uint64_t to) { + pos = start + (to >> 3); + currentBit = to & 0x7; + eomFlag = false; + if (pos < start) { + pos = start; + eomFlag = true; + } + if (pos >= end) { + pos = end; + eomFlag = true; + } +} + void mstream::seek( uint64_t to, int whence ) { switch(whence) @@ -254,6 +300,10 @@ uint64_t mstream::tell() return pos - start; } +uint64_t mstream::tellBits() { + return (pos - start) * 8 + currentBit; +} + char * mstream::getBuffer() { return (char*)start; diff --git a/dlls/mstream.h b/dlls/mstream.h index 3d1744d1..0c0cdb6a 100644 --- a/dlls/mstream.h +++ b/dlls/mstream.h @@ -32,6 +32,10 @@ class EXPORT mstream float readBitCoord(); + // increment to the next byte if current bit is not 0 + // true if position was incremented + bool endBitReading(); + // returns number of bytes that could be written into the buffer uint64_t write(void * src, uint64_t bytes); @@ -41,6 +45,10 @@ class EXPORT mstream // write bitCount bits from value. Returns bits written uint8_t writeBits(uint32_t value, uint8_t bitCount); + // write zeroes into the remaining bits at the current byte, then increment the position to the next byte + // true if position was incremented + bool endBitWriting(); + // write Half-Life vector as bits (used in sound message) bool writeBitVec3Coord(const float* fa); @@ -50,6 +58,9 @@ class EXPORT mstream // returns the offset in the buffer uint64_t tell(); + // returns the offset in the buffer, accurate to the bit + uint64_t tellBits(); + // returns the size of the buffer uint64_t size(); @@ -63,6 +74,9 @@ class EXPORT mstream // resets eom flag if set to a valid position void seek(uint64_t to); + // position is given in bits + void seekBits(uint64_t to); + // like seek but implements SEEK_CUR/SET/END functionality void seek(uint64_t to, int whence);