Пример #1
0
BOOL C4TransferZones::Set(int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, C4Object *pObj)
	{
	C4TransferZone *pZone;
	// Empty zone: clear existing object zones
	if (!iWdt || !iHgt) { ClearPointers(pObj); return TRUE; }	
	// Update existing zone
	if (pZone=Find(pObj))
		{
		pZone->X=iX; pZone->Y=iY;
		pZone->Wdt=iWdt; pZone->Hgt=iHgt;
		}
	// Allocate and add new zone
	else
		Add(iX,iY,iWdt,iHgt,pObj);
	// Success
	return TRUE;
	}
Пример #2
0
void C4SoundInstance::Execute() {
  // Object deleted?
  if (pObj && !pObj->Status) ClearPointers(pObj);
  // initial values
  int32_t iVol = iVolume * 256 * Config.Sound.SoundVolume / 100,
          iPan = C4SoundInstance::iPan;
  // bound to an object?
  if (pObj) {
    int iAudibility = pObj->Audible;
    // apply custom falloff distance
    if (iFalloffDistance) {
      iAudibility = BoundBy<int32_t>(
          100 + (iAudibility - 100) * C4AudibilityRadius / iFalloffDistance, 0,
          100);
    }
    iVol = iVol * iAudibility / 100;
    iPan += pObj->AudiblePan;
  }
  // sound off?
  if (!iVol) {
    // stop, if started
    if (isStarted()) {
#ifdef HAVE_LIBSDL_MIXER
      Mix_HaltChannel(iChannel);
#endif
      iChannel = -1;
    }
  } else {
    // start
    if (!isStarted())
      if (!CheckStart()) return;
// set volume & panning
#ifdef HAVE_LIBSDL_MIXER
    Mix_Volume(iChannel, (iVol * MIX_MAX_VOLUME) / (100 * 256));
    // Mix_SetPanning(iChannel, ((100 + iPan) * 256) / 200, ((100 - iPan) * 256)
    // / 200);
    Mix_SetPanning(iChannel, BoundBy((100 - iPan) * 256 / 100, 0, 255),
                   BoundBy((100 + iPan) * 256 / 100, 0, 255));
#endif
  }
}