示例#1
0
文件: InSector.cpp 项目: Mazuk/LK8000
// This is called from main DoCalculations each time, only when running a real task
void InSector(NMEA_INFO *Basic, DERIVED_INFO *Calculated)
{
  static int LastStartSector = -1;

  if (ActiveWayPoint<0) return;
  LockTaskData();

// Paragliders task system
// Case A: start entering the sector/cylinder
//		you must be outside sector when gate is open.
//		you are warned that you are already inside sector before the gate is open, when gate is opening in <10 minutes
//		task restart is manual
// Case B: start exiting the sector

  // by default, we are not in the sector
  Calculated->IsInSector = false;

  if(ActiveWayPoint == 0) {
	CheckStart(Basic, Calculated, &LastStartSector);
  } else {
	if(IsFinalWaypoint()) {
		LastStartSector = -1;
		AddAATPoint(Basic, Calculated, ActiveWayPoint-1);
		CheckFinish(Basic, Calculated);
	} else {
		if (!UseGates()) CheckRestart(Basic, Calculated, &LastStartSector); // 100507
		if (ActiveWayPoint>0) {
			CheckInSector(Basic, Calculated);
			LastStartSector = -1;
		}
	}
  }                   
  UnlockTaskData();
}
示例#2
0
BOOL CheckRestart(NMEA_INFO *Basic, DERIVED_INFO *Calculated, int *LastStartSector) {
  if((Basic->Time - Calculated->TaskStartTime < 3600)
     &&(ActiveWayPoint<=1)) {

    CheckStart(Basic, Calculated, LastStartSector);
  }
  return FALSE;
}
示例#3
0
void Type3Machine::EnterChar(char ch, int pos, int line)
{
	if (_currentLexemePosition == -100)
	{
		_currentLexemePosition = pos;
		_curlexline = line;
	}
	if (!_start)
	{
		CheckStart(ch);
		if (!_start) _isError = true;
		return;
	}

	if (((_step - 1) > 0) && (_step - 1 != 0) && (_buffer[_step - 1] == _buffer[0]) && ch != '\\')
	{
		_isFinished = true;
		CheckType();
		return;
	}

	int listcount = _words->count();
	_isFinished = true;
	for (int i = 0; i < listcount; i++)
	{
		if (strchr((char*)_words->get(i), ch) != nullptr)
		{
			_isFinished = false;
			_buffer[_step++] = ch;
			_buffer[_step] = '\0';
			break;
		}
	}

	if (_isFinished)
	{
		if (_buffer[strlen(_buffer) - 1] != _buffer[0])
		{
			_isFinished = false;
			_isError = true;
		}
	}
}
示例#4
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
  }
}
示例#5
0
文件: ghost.cpp 项目: Laxa/ddnet
void CGhost::OnNewSnapshot()
{
	CServerInfo ServerInfo;
	Client()->GetServerInfo(&ServerInfo);
	if(!IsRace(&ServerInfo) || !g_Config.m_ClRaceGhost || Client()->State() != IClient::STATE_ONLINE)
		return;
	if(!m_pClient->m_Snap.m_pGameInfoObj || m_pClient->m_Snap.m_SpecInfo.m_Active || !m_pClient->m_Snap.m_pLocalCharacter || !m_pClient->m_Snap.m_pLocalPrevCharacter)
		return;

	bool RaceFlag = m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_RACETIME;
	bool ServerControl = RaceFlag && g_Config.m_ClRaceGhostServerControl;

	if(!ServerControl)
		CheckStartLocal(false);
	else
		CheckStart();

	if(m_Recording)
		AddInfos(m_pClient->m_Snap.m_pLocalCharacter);

	int RaceTick = -m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer;
	m_LastRaceTick = RaceFlag ? RaceTick : -1;
}
示例#6
0
void Type2Machine::EnterChar(char ch, int pos, int line)
{
	if (_currentLexemePosition == -100)
	{
		_currentLexemePosition = pos;
		_curlexline = line;
	}
	if (!_start)
	{
		CheckStart(ch);
		if (!_start) _isError = true;
		return;
	}

	int listcount = _words->count();
	_isFinished = true;
	if (ch == '\0')
		return;
	for (int i = 0; i < listcount; i++)
	{
		if (strchr((char*)_words->get(i), ch) != nullptr)
		{
			_isFinished = false;
			if (_step >= Chunck * _chunckcount) //50 * кол-во кусков
			{
				_chunckcount++;
				char* _buffer2 = (char*)heap_my.get_mem(sizeof(char) * Chunck * _chunckcount);
				strcpy_s(_buffer2, strlen(_buffer), _buffer);
				heap_my.free_mem(_buffer);
				_buffer = _buffer2;
			}
			_buffer[_step++] = ch;
			_buffer[_step] = '\0';
			break;
		}
	}
}
示例#7
0
void Type1Machine::EnterChar(char ch, int pos, int line)
{
	if (_currentLexemePosition == -100)
	{
		_currentLexemePosition = pos;
		_curlexline = line;
	}
	if (!_start)
	{
		CheckStart(ch);
		if (!_start) _isError = true;
		return;
	}
	int listcount = _potentialwords.count();
	char temp[Chunck];
	bool f = false;
	
	if (listcount == 0)
	{
		_isError = true;
		return;
	}

	if (listcount == 1 && ((strlen(_buffer) >= strlen((char*)_potentialwords.get(0)))))
	{
		if (strcmp(_buffer, (char*)_potentialwords.get(0)) == 0)
		{
			_isFinished = true;
			_potentialwords.~List();
			_potentialwords = List(sizeof(char[Chunck]));
			return;
		}
		else
		{
			_isError = true;
			return;
		}
	}

	for (int i = 0; i < listcount; i++)
	{
		strcpy_s(temp, (char*)_potentialwords.get(i));
		bool ftemp;
		if (!f) ftemp = (temp[_step] != ch);
		else 
			ftemp = (temp[_step - 1] != ch);
		if (ftemp)
		{
			//test for missed space
			char stemp[Chunck];
			strcpy_s(stemp, (char*)_potentialwords.get(i));
			stemp[strlen(stemp) - 1] = '\0';
			if (strcmp(stemp, _buffer) == 0 && temp[strlen(temp) - 1] == ' ')
			{
				char sstemp[Chunck];
				sprintf_s(sstemp, "Maybe you misse space? Maybe you mean \"%s\"?", temp);
				errorReporter.WarningReport(logfile, sstemp, _curlexline, _currentLexemePosition + (int)strlen(_buffer));
			}
			//
			_potentialwords.remove(i);
			listcount--;
			i--;
		}
		else if (!f)
		{
			if (_step >= Chunck * _chunckcount) //Chunck * кол-во кусков
			{
				_chunckcount++;
				char* _buffer2 = (char*)heap_my.get_mem(sizeof(char) * Chunck * _chunckcount);
				strcpy_s(_buffer2, strlen(_buffer), _buffer);
				heap_my.free_mem(_buffer);
				_buffer = _buffer2;
			}
			_buffer[_step++] = ch;
			_buffer[_step] = '\0';
			f = true;
		}
	}
}
void JavaInterface::CheckAttachCurrentThread() {
   CheckStart();
   self()->CheckAttachThread();
}