DeflateStream::DeflateStream(IStream *stream, CompressMode mode, bool ac) { SPADES_MARK_FUNCTION(); this->baseStream = stream; this->mode = mode; autoClose = ac; zstream.zalloc = Z_NULL; zstream.zfree = Z_NULL; zstream.opaque = Z_NULL; position = 0; int ret; if(mode == CompressModeCompress) { ret = deflateInit(&zstream, 5); }else if(mode == CompressModeDecompress){ ret = inflateInit(&zstream); }else{ SPInvalidEnum("mode", mode); } if(ret != Z_OK){ SPRaise("Failed to initialize zlib deflator/inflator: %s", zError(ret)); } valid = true; reachedEOF = false; bufferPos = 0; }
Weapon *Weapon::CreateWeapon(WeaponType type, Player *p, const GameProperties &gp) { SPADES_MARK_FUNCTION(); switch (gp.protocolVersion) { case ProtocolVersion::v075: switch (type) { case RIFLE_WEAPON: return new RifleWeapon3(p->GetWorld(), p); case SMG_WEAPON: return new SMGWeapon3(p->GetWorld(), p); case SHOTGUN_WEAPON: return new ShotgunWeapon3(p->GetWorld(), p); default: SPInvalidEnum("type", type); } case ProtocolVersion::v076: switch (type) { case RIFLE_WEAPON: return new RifleWeapon4(p->GetWorld(), p); case SMG_WEAPON: return new SMGWeapon4(p->GetWorld(), p); case SHOTGUN_WEAPON: return new ShotgunWeapon4(p->GetWorld(), p); default: SPInvalidEnum("type", type); } default: SPInvalidEnum("protocolVersion", gp.protocolVersion); } }
Weapon *Weapon::CreateWeapon(WeaponType type, Player *p) { SPADES_MARK_FUNCTION(); switch(type){ case RIFLE_WEAPON: return new RifleWeapon(p->GetWorld(), p); case SMG_WEAPON: return new SMGWeapon(p->GetWorld(), p); case SHOTGUN_WEAPON: return new ShotgunWeapon(p->GetWorld(), p); default: SPInvalidEnum("type", type); } }
int IAudioStream::GetStride() { SPADES_MARK_FUNCTION(); int stride; switch(GetSampleFormat()){ case UnsignedByte: stride = 1; break; case SignedShort: stride = 2; break; case SingleFloat: stride = 4; break; default: SPInvalidEnum("GetSampleFormat", GetSampleFormat()); } return stride * GetNumChannels(); }