示例#1
0
文件: testmain.c 项目: doniexun/rtos
int SetArrivalTime(oneHop * desiredPath, int trainNum) {
  /* Take in the path desired by a task and determine if this path is feasible.
   * If the path is feasible, mark the arrival times in the trafficMap and return
   * speed train should go at. If there is a colision return COLISION.
   * If route is not clear, route is not marked in the path, but collision point is
   * marked broken.
   */

  int WillCollide;              /* Is this train going to collide with anything */
  int Tspeed;                   /* speed to set the train to */
  int CollisionPoint;           /* If there is a collision where it will take place */

  Tspeed = 6;
  WillCollide = CheckSpeed(desiredPath, trainNum, speedLookup(trainNum, Tspeed));
  if (!WillCollide) {
    MarkRoute(desiredPath, trainNum, speedLookup(trainNum, Tspeed));
    return Tspeed;
  }
  Tspeed = 2;
  WillCollide = CheckSpeed(desiredPath, trainNum, speedLookup(trainNum, Tspeed));
  if (!WillCollide) {
    MarkRoute(desiredPath, trainNum, speedLookup(trainNum, Tspeed));
    return Tspeed;
  }
  Tspeed = 10;
  WillCollide = CheckSpeed(desiredPath, trainNum, speedLookup(trainNum, Tspeed));
  if (!WillCollide) {
    MarkRoute(desiredPath, trainNum, speedLookup(trainNum, Tspeed));
    return Tspeed;
  }
  /* Picking different speeds is not doing much good, lets find the point
   * of collision and try to avoid it.
   */
  CollisionPoint = CheckSpeed(desiredPath, trainNum, speedLookup(trainNum, 6));
  breakSeg(desiredPath[CollisionPoint].thisNode);
  return COLISION;
}
示例#2
0
bool CCar::SetSpeed(int speed)
{
	if (m_speed == speed)
		return true;

	if (CheckSpeed(m_gear, speed))
	{
		m_speed = speed;
		return true;
	}
	else
	{
		return false;
	}
}
示例#3
0
bool CCar::SetGear(GEAR gear)
{
	if (m_gear == gear)
		return true;

	if (CheckSpeed(gear, m_speed))
	{
		m_gear = gear;
		return true;
	}
	else
	{
		return false;
	}
}
示例#4
0
文件: Test.cpp 项目: Tumba/Keeper
PLUGIN_EXPORT void PLUGIN_CALL ProcessTick()
{
     
	static int timer = 0;
	static int time = 0;
	timer ++;
	time ++;
/*	for(int i = 0;i < MAX_PLAYERS;i++)
	{ 
		if(!IsConnected[i]) continue;
		if(ToKick[i] == 0) continue;
		g_Invoke->callNative(&PAWN::ResetPlayerWeapons,i);
	}*/
	if(time == 200)
	{
		  for(int i = 0;i < MAX_VEHICLES;i++)
		  {
			  if(SaveCord[i] > 0)
			  {
				  SaveCord[i] --;
				  if(SaveCord[i] == 0)
				  {
					  float x[3];float z;
					  g_Invoke->callNative(&PAWN::GetVehiclePos,i,&x[0],&x[1],&x[2]);
					  g_Invoke->callNative(&PAWN::GetVehicleZAngle,i,&z);
					  Vehicle[i].posx = x[0];
					  Vehicle[i].posy = x[1];
					  Vehicle[i].posz = x[2];
					  Vehicle[i].posa = z;
					  
				  }

			  }
		  }
		  for(int i = 0;i < MAX_PLAYERS;i++)
		  {
			  if(!IsConnected[i]) continue;
			  
			  if(ToKick[i] > 0)
			  {
			      ToKick[i] -= 1;
				  if(ToKick[i] == 0) g_Invoke->callNative(&PAWN::Kick,i);
				  continue;
			  }
			  if(ToBan[i] > 0)
			  {
			      ToBan[i] -= 1;
				  if(ToBan[i] == 0) g_Invoke->callNative(&PAWN::Ban,i);
				  continue;
			  }
			  CheckLag(i);
			  if(g_Invoke->callNative(&PAWN::GetPlayerState,i) == PLAYER_STATE_ONFOOT) AirCheck(i);
			  if(GunNoCheck[i] <= 0 && g_Invoke->callNative(&PAWN::GetPlayerState,i) == PLAYER_STATE_ONFOOT)
			  {
				   CheckGun(i); 
			       CheckAmmo(i);
			  }
			  else  GunNoCheck[i] --;
			//  CheckHealth(i);
			//  CheckArmour(i);
			  if(g_Invoke->callNative(&PAWN::GetPlayerSpecialAction,i) == 2)
			  {
				  SafeKick(i,"JetPack",AC_JETPACK);
				  continue;
			  }
			  if(RemoveCheck[i] != 0)
			  {
				  if(g_Invoke->callNative(&PAWN::GetPlayerState,i) == PLAYER_STATE_ONFOOT)
				  {
					  RemoveCheck[i] = 0;
					  continue;
				  }
				  RemoveCheck[i] --;
				  if(RemoveCheck[i] == 0)
				  {
					   if(g_Invoke->callNative(&PAWN::GetPlayerState,i) == PLAYER_STATE_DRIVER)
					   {
						   SafeKick(i,"Анти RemovePlayerFromVehicle",AC_REMOVE);
					       continue;
					   }
				  }
				 
			  }
		  }
		  time = 0;
	}
	if(timer == 20)
	{
		  for(int i = 0;i < MAX_PLAYERS;i++)
		  {
			  if(!IsConnected[i]) continue;
			  DeathTimes[i] = false;
			  if(ToKick[i] > 0) continue;
			  if(g_Invoke->callNative(&PAWN::GetPlayerState,i) == PLAYER_STATE_DRIVER && !IsAdmin(i)) CheckSpeed(i);
			  if(!IsAdmin(i)) FlyCheck(i);
			  if(g_Invoke->callNative(&PAWN::GetPlayerState,i) == PLAYER_STATE_DRIVER || g_Invoke->callNative(&PAWN::GetPlayerState,i) == PLAYER_STATE_PASSENGER) CarAir(i);

		  }
		  timer = 0;
	}
  
}