Exemple #1
0
void VLL_Sep::EvalDerivs()
  {
  FlashTank::EvalDerivs();

  double QmIn, QmOut, MegIn, MegOut;
  QmIn   = 0.0;
  QmOut  = 0.0;
  MegIn  = 0.0;
  MegOut = 0.0;
  for (int i=0; i<NoFlwIOs(); i++)
    {
    SpConduit & Cd=*IOConduit(i);
    if (IO_In(i))
      {
      QmIn  += Cd.Qm(Water())+Cd.Qm(Steam());
      MegIn += Cd.Qm(MEG());
      }
    else if (IO_Out(i) && IOId_Self(i)==VLLIO_boot)
      {
      QmOut  += Cd.Qm(Water())+Cd.Qm(Steam());
      MegOut += Cd.Qm(MEG());
      }
    }

  dH2oSettled = QmIn*H2ORemEff-QmOut;
  dMEGSettled = MegIn*H2ORemEff-MegOut;
  }
Exemple #2
0
void VLL_Sep::EvalProducts()
  {

  Contents.ZeroDeriv();
  QFeed().QZero();

  SigmaQIn(QFeed(), 0xffffffff);

  double  TQvIn=0.0;
  double  QvIn=0.0;
  for (int i=0; i<NoFlwIOs(); i++)
    if (IO_In(i))
      {
      QvIn=IOConduit(i)->QVolume(som_SL);
      TQvIn+=QvIn;
      }
  double  TQvInX=QFeed().QVolume(som_SL);

  /* hss I have included a variable to define the % of water removed in the boot.
     Previously it was 100%, which Andre Vogel says is incorrect.  The user now
     has the ability to set the efficiency at a lower value and hence allow some
     of the water to leave with the condensate. 20/01/97

     12/01/2000 hss I have included MEG in the boot contents, as it is also removed
     from the system via the boot. */

  SpMArray OutImg, BootImg;
  OutImg = Contents.MArray();
  OutImg[Water()] -= H2oSettled;
  OutImg[MEG()]   -= MEGSettled;
  SetProdMakeup(PMU_IOId | PMU_Image, VLLIO_out,  OutImg, Contents.Temp(), Contents.Press(), Contents.Model());

  // The Boot
  BootImg = Contents.MArray();
  double LoBLFScl=1.0e-6;
  double BootLiqFrac=(BootImg[Water()]+BootImg[MEG()])/GTZ(BootImg.Mass(som_SL));
  double BootLiqScl=1;
  // @BootLiqFrac==0 then this =1
  double OthrLiqScl=Range(0.0, 0.0+2*(LoBLFScl-BootLiqFrac)/LoBLFScl, 1.0);

  for (i=0; i<SDB.No(); i++)
    if (SDB[i].IsVap())
      BootImg[i] = 0;
    else if (i==Water() || i==MEG())
      BootImg[i] *= BootLiqScl;
    else
      BootImg[i] *= OthrLiqScl;

  SetProdMakeup(PMU_IOId | PMU_Image, VLLIO_boot, BootImg, Contents.Temp(), Contents.Press(), Contents.Model());
  /* OLD
  BootImg = Contents.MArray();
  BootImg[Water()] = 0.0;
  BootImg[MEG()] = 0.0;
  SetProdMakeup(PMU_IOId | PMU_Blocking, VLLIO_boot, BootImg, Contents.Temp(), Contents.Press(), Contents.Model());
  */
  EvalProducts_SurgeLevel(ContentHgtOrd);

  }
Exemple #3
0
Shred::Shred(const int shred_x, const int shred_y,
        const long longi, const long lati)
    :
        longitude(longi), latitude(lati),
        shredX(shred_x), shredY(shred_y),
        type(),
        activeListAll(),
        activeListFrequent(),
        shiningList(),
        fallList(),
        weather(WEATHER_CLEAR)
{
    if ( LoadShred() ) return; // successfull loading
    // new shred generation:
    Block * const null_stone = Normal(NULLSTONE);
    Block * const air  = Normal(AIR);
    Block * const sky  = Normal(SKY);
    Block * const star = Normal(STAR);
    SetAllLightMapNull();
    for (int i=0; i<SHRED_WIDTH; ++i)
    for (int j=0; j<SHRED_WIDTH; ++j) {
        PutBlock(null_stone, i, j, 0);
        for (int k=1; k<HEIGHT-1; ++k) {
            PutBlock(air, i, j, k);
        }
        PutBlock(((qrand()%5) ? sky : star), i, j, HEIGHT-1);
    }
    switch ( type = static_cast<shred_type>
            (GetWorld()->GetMap()->TypeOfShred(longi, lati)) )
    {
    case SHRED_WASTE:     WasteShred(); break;
    case SHRED_WATER:     Water();      break;
    case SHRED_PLAIN:     Plain();      break;
    case SHRED_MOUNTAIN:  Mountain();   break;
    case SHRED_DESERT:    Desert();     break;
    case SHRED_HILL:      Hill(false);  break;
    case SHRED_DEAD_HILL: Hill(true);   break;
    case SHRED_FOREST:      Forest(false); break;
    case SHRED_DEAD_FOREST: Forest(true);  break;
    case SHRED_NULLMOUNTAIN: NullMountain(); break;
    case SHRED_TESTSHRED: TestShred();  break;
    case SHRED_PYRAMID:   Pyramid();    break;
    case SHRED_CASTLE:    Castle();     break;
    case SHRED_CHAOS:     ChaosShred(); break;
    case SHRED_EMPTY: break;
    case SHRED_ACID_LAKE: Water(ACID ); break;
    case SHRED_LAVA_LAKE: Water(STONE); break;
    case SHRED_CRATER:    Water(AIR);   break;
    case SHRED_NORMAL_UNDERGROUND: NormalUnderground(); break;
    }
} // Shred::Shred(int shred_x, shred_y, long longi, lati, Shred * mem)
Exemple #4
0
void VLL_Sep::ApplyDerivs(double dTime, flag DoDbg)
  {
  FlashTank::ApplyDerivs(dTime, DoDbg);

  H2oSettled += dH2oSettled*dTime;
  H2oSettled  = Range(0.0 , H2oSettled, Contents.SpMass(Water()));

  MEGSettled += dMEGSettled*dTime;
  MEGSettled  = Range(0.0 , MEGSettled, Contents.SpMass(MEG()));

  TotalSettled = H2oSettled + MEGSettled;

  }
Exemple #5
0
double FlashTank::mH2oVVFrac(pMdlNode This)
  {
  if (This->NoFlwIOs()==2)
    {
    int i= (This->IO_In(0) ? 0 : 1);
    rSpConduit q=*This->IOConduit(i);
    SpMArray S;
    S[Water()]=1;
    double p=Contents.Press();//This->mPMean(NULL);
    return q.QVolume(S)/q.QVolume(som_SL);
//    return This->Contents.QVolume(q,S,p)/This->Contents.QVolume(q,som_SL,p);
    }
  return dNAN();
  };
Exemple #6
0
flag VLL_Sep::DataXchg(DataChangeBlk & DCB)
  {
  if (FlashTank::DataXchg(DCB))
    return 1;

  switch(DCB.lHandle)
    {
    case xidBH2oIf:
      //DCB.D = (H2oSettled*SDB[Water()].msVolume(Contents.Temp(), Contents.Press(), Contents.MArray()))/BootVolume;
      DCB.D = (H2oSettled*SDB[Water()].msVolume(Contents.Temp(), Contents.Press(), Contents.Ovr(), Contents.MArray())
              + MEGSettled*SDB[MEG()].msVolume(Contents.Temp(), Contents.Press(), Contents.Ovr(), Contents.MArray()))/BootVolume;
      return 1;
    }
  return 0;
  };
Exemple #7
0
/*---GET COMMANDS FOR SPELLS---*/
void Player::Gem_Abilities(const Vector<MyString>& commands)
{
	if (enemy != nullptr)
	{
		bool red = false;
		bool blue = false;
		bool yellow = false;
		bool black = false;
		bool white = false;

		CheckGems(red, blue, yellow, black, white);

		//Check the command introduced for casting the correct spell
		if (commands[0] == "1")
		{
			Fire(commands, red, blue, black);
		}
		else if (commands[0] == "2")
		{
			Water(commands, blue, red, yellow);
		}
		else if (commands[0] == "3")
		{
			Electricity(commands, yellow, blue, white);
		}
		else if (commands[0] == "4")
		{
			Darkness(commands, black, red, white);
		}
		else if (commands[0] == "5")
		{
			Brightness(commands, white, black, yellow);
		}
	}
	else
	{
		printf("You can't cast a spell without an objective, Simon.\n");
	}
}
Exemple #8
0
//==========================================================================
// never checked mhm
double DewPt(rSpContainer Contents, rSpConduit Qi, double P)
  {
  //  Y0 lb/MMscf
  //  OpPres kPa abs
  //  IF (OpPres > RZero) AND (Y0 > RZero) THEN
  //    IF ((27.248 - 0.8446 * LN (OpPres) - LN (Y0)) <> RZero) THEN
  //      GasOutletDP := (5214.4 - 38.34 * LN (OpPres)) /
  //                     (27.248 - 0.8446 * LN (OpPres) - LN (Y0));

  double VolFlw=Qi.QMass(som_ALL)*Qi.NRho(som_Vap);//44Qi);      // m^3/s


  double H2oMassFlw=Qi.Qm(Water())+Qi.Qm(Steam());  // kg/s
  double Y0=kg_2_lb(H2oMassFlw)/GTZ(Nm3_2_MMscf(VolFlw));
  if ((P > 1.0) && (Y0 > 1.0e-10))
    {
    double Den= 27.248 - 0.8446 * log(P) - log(Y0);
    if (fabs(Den) > 1.0e-10)
      return (5214.4 - 38.34 * log(P)) / Den;
    }
  return dNAN();
  }
Exemple #9
0
INT16 InternalGoAsFarAsPossibleTowards(SOLDIERTYPE *pSoldier, INT16 sDesGrid, INT8 bReserveAPs, INT8 bAction, INT8 fFlags )
{
	INT16 sLoop,sAPCost;
	INT16 sTempDest,sGoToGrid;
	INT16 sOrigin;
	UINT16 usMaxDist;
	UINT8 ubDirection,ubDirsLeft,ubDirChecked[8],fFound = FALSE;
	INT8 bAPsLeft, fPathFlags;
	UINT8 ubRoomRequired = 0, ubTempRoom;

	if ( bReserveAPs == -1 )
	{
		// default reserve points
		if ( CREATURE_OR_BLOODCAT( pSoldier ) )
		{
			bReserveAPs = 0;
		}
		else
		{
			bReserveAPs = MAX_AP_CARRIED;
		}
	}

	sTempDest = -1;

	// obtain maximum roaming distance from soldier's sOrigin
	usMaxDist = RoamingRange(pSoldier,&sOrigin);

	if ( pSoldier->bOrders <= CLOSEPATROL && (pSoldier->bTeam == CIV_TEAM || pSoldier->ubProfile != NO_PROFILE ) )
	{
		if ( InARoom( pSoldier->usPatrolGrid[0], &ubRoomRequired ) )
		{
			// make sure this doesn't interfere with pathing for scripts
			if ( pSoldier->sAbsoluteFinalDestination != NOWHERE )
			{
				ubRoomRequired = 0;
			}
		}
	}

	pSoldier->usUIMovementMode = DetermineMovementMode(pSoldier, bAction );
	if ( pSoldier->usUIMovementMode == RUNNING && fFlags & FLAG_CAUTIOUS )
	{
		pSoldier->usUIMovementMode = WALKING;
	}

#ifdef DEBUGDECISIONS
	sprintf(tempstr,"%s wants to go towards %d (has range %d)",pSoldier->name,sDesGrid,usMaxDist);
	AIPopMessage(tempstr);
#endif

	// if soldier is ALREADY at the desired destination, quit right away
	if (sDesGrid == pSoldier->sGridNo)
	{
		return(NOWHERE);
	}

	// don't try to approach go after noises or enemies actually in water
	// would be too easy to throw rocks in water, etc. & distract the AI
	if (Water(sDesGrid))
	{
		return(NOWHERE);
	}

	fPathFlags = 0;
	if ( CREATURE_OR_BLOODCAT( pSoldier ) )
	{	/*
		if ( PythSpacesAway( pSoldier->sGridNo, sDesGrid ) <= PATH_CLOSE_RADIUS )
		{
			// then do a limited range path search and see if we can get there
			gubNPCDistLimit = 10;
			if ( !LegalNPCDestination( pSoldier, sDesGrid, ENSURE_PATH, NOWATER, fPathFlags) )
			{
				gubNPCDistLimit = 0;
				return( NOWHERE );
			}
			else
			{
				// allow attempt to path without 'good enough' flag on
				gubNPCDistLimit = 0;
			}
		}
		else
		{
		*/
			fPathFlags = PATH_CLOSE_GOOD_ENOUGH;
		//}
	}

	// first step: try to find an OK destination at or near the desired gridno
	if (!LegalNPCDestination(pSoldier,sDesGrid,ENSURE_PATH,NOWATER,fPathFlags))
	{
#ifdef DEBUGDECISIONS
		AIPopMessage("destination Grid # itself not valid, looking around it");
#endif
		if ( CREATURE_OR_BLOODCAT( pSoldier ) )
		{
			// we tried to get close, failed; abort!
			return( NOWHERE );
		}
		else
		{
			// else look at the 8 nearest gridnos to sDesGrid for a valid destination

			// clear ubDirChecked flag for all 8 directions
			for (ubDirection = 0; ubDirection < 8; ubDirection++)
				ubDirChecked[ubDirection] = FALSE;

			ubDirsLeft = 8;

			// examine all 8 spots around 'sDesGrid'
			// keep looking while directions remain and a satisfactory one not found
			for (ubDirsLeft = 8; ubDirsLeft != 0; ubDirsLeft--)
			{
				if (fFound)
				{
					break;
				}
				// randomly select a direction which hasn't been 'checked' yet
				do
				{
					ubDirection = (UINT8) Random(8);
				}
				while (ubDirChecked[ubDirection]);

				ubDirChecked[ubDirection] = TRUE;

				// determine the gridno 1 tile away from current friend in this direction
				sTempDest = NewGridNo(sDesGrid,DirectionInc( (INT16)(ubDirection + 1) ));

				// if that's out of bounds, ignore it & check next direction
				if (sTempDest == sDesGrid)
					continue;

				if (LegalNPCDestination(pSoldier,sTempDest,ENSURE_PATH,NOWATER,0))
				{
					fFound = TRUE;            // found a spot

#ifdef DEBUGDECISIONS
					AINumMessage("Found a spot!  ubDirection = ",ubDirection + 1);
#endif

					break;                   // stop checking in other directions
				}
			}

			if (!fFound)
			{
#ifdef DEBUGDECISIONS
				AINumMessage("Couldn't find OK destination around grid #",sDesGrid);
#endif

				return(NOWHERE);
			}

			// found a good grid #, this becomes our actual desired grid #
			sDesGrid = sTempDest;
		}
	}

 // HAVE FOUND AN OK destination AND PLOTTED A VALID BEST PATH TO IT


#ifdef DEBUGDECISIONS
 AINumMessage("Chosen legal destination is gridno ",sDesGrid);
 AINumMessage("Tracing along path, pathRouteToGo = ",pSoldier->pathRouteToGo);
#endif

 sGoToGrid = pSoldier->sGridNo;      // start back where soldier is standing now
 sAPCost = 0;		      // initialize path cost counter

 // we'll only go as far along the plotted route as is within our
 // permitted roaming range, and we'll stop as soon as we're down to <= 5 APs

 for (sLoop = 0; sLoop < (pSoldier->usPathDataSize - pSoldier->usPathIndex); sLoop++)
  {
   // what is the next gridno in the path?

	 //sTempDest = NewGridNo( sGoToGrid,DirectionInc( (INT16) (pSoldier->usPathingData[sLoop] + 1) ) );
	 sTempDest = NewGridNo( sGoToGrid,DirectionInc( (INT16) (pSoldier->usPathingData[sLoop]) ) );
   //NumMessage("sTempDest = ",sTempDest);

   // this should NEVER be out of bounds
   if (sTempDest == sGoToGrid)
    {
#ifdef BETAVERSION
     sprintf(tempstr,"GoAsFarAsPossibleTowards: ERROR - gridno along valid route is invalid!  guynum %d, sTempDest = %d",pSoldier->ubID,sTempDest);

#ifdef RECORDNET
     fprintf(NetDebugFile,"\n\t%s\n",tempstr);
#endif

     PopMessage(tempstr);
     SaveGame(ERROR_SAVE);
#endif

     break;           // quit here, sGoToGrid is where we are going
    }

   // if this takes us beyond our permitted "roaming range"
   if (SpacesAway(sOrigin,sTempDest) > usMaxDist)
     break;           // quit here, sGoToGrid is where we are going


	 if ( ubRoomRequired )
	 {
		if ( !( InARoom( sTempDest, &ubTempRoom ) && ubTempRoom == ubRoomRequired ) )
		{
		 // quit here, limited by room!
		 break;
		}
	 }

   if ( (fFlags & FLAG_STOPSHORT) && SpacesAway( sDesGrid, sTempDest ) <= STOPSHORTDIST )
	 {
     break;           // quit here, sGoToGrid is where we are going
	 }

   // if this gridno is NOT a legal NPC destination
   // DONT'T test path again - that would replace the traced path! - Ian
   // NOTE: It's OK to go *THROUGH* water to try and get to the destination!
   if (!LegalNPCDestination(pSoldier,sTempDest,IGNORE_PATH,WATEROK,0))
     break;           // quit here, sGoToGrid is where we are going


   // CAN'T CALL PathCost() HERE! IT CALLS findBestPath() and overwrites
   //       pathRouteToGo !!!  Gotta calculate the cost ourselves - Ian
   //
   //ubAPsLeft = pSoldier->bActionPoints - PathCost(pSoldier,sTempDest,FALSE,FALSE,FALSE,FALSE,FALSE);

	 if (gfTurnBasedAI)
	 {
		 // if we're just starting the "costing" process (first gridno)
		 if (sLoop == 0)
			{
			/*
			 // first, add any additional costs - such as intermediate animations, etc.
			 switch(pSoldier->anitype[pSoldier->anim])
				{
				 // in theory, no NPC should ever be in one of these animations as
				 // things stand (they don't medic anyone), but leave it for robustness
				 case START_AID   :
				 case GIVING_AID  : sAnimCost = AP_STOP_FIRST_AID;
					break;

				 case TWISTOMACH  :
				 case COLLAPSED   : sAnimCost = AP_GET_UP;
					break;

				 case TWISTBACK   :
				 case UNCONSCIOUS : sAnimCost = (AP_ROLL_OVER + AP_GET_UP);
					break;

				 default          : sAnimCost = 0;
				}

			 // this is our first cost
			 sAPCost += sAnimCost;
			 */

			 if (pSoldier->usUIMovementMode == RUNNING)
			 {
				sAPCost += AP_START_RUN_COST;
			 }
			}

		 // ATE: Direction here?
		 sAPCost += EstimateActionPointCost( pSoldier, sTempDest, (INT8) pSoldier->usPathingData[sLoop], pSoldier->usUIMovementMode, (INT8) sLoop, (INT8) pSoldier->usPathDataSize );

		 bAPsLeft = pSoldier->bActionPoints - sAPCost;
	 }

	 // if after this, we have <= 5 APs remaining, that's far enough, break out
	 // (the idea is to preserve APs so we can crouch or react if
	 // necessary, and benefit from the carry-over next turn if not needed)
	 // This routine is NOT used by any GREEN AI, so such caution is warranted!

	 if ( gfTurnBasedAI && (bAPsLeft < bReserveAPs) )
		 break;
	 else
		{
		 sGoToGrid = sTempDest;    // we're OK up to here

		 // if exactly 5 APs left, don't bother checking any further
		 if ( gfTurnBasedAI && (bAPsLeft == bReserveAPs) )
			 break;
		}		
  }


 // if it turned out we couldn't go even 1 tile towards the desired gridno
 if (sGoToGrid == pSoldier->sGridNo)
  {
#ifdef DEBUGDECISIONS
   sprintf(tempstr,"%s will go NOWHERE, path doesn't meet criteria",pSoldier->name);
   AIPopMessage(tempstr);
#endif

   return(NOWHERE);             // then go nowhere
  }
 else
  {
   // possible optimization - stored path IS good if we're going all the way
   if (sGoToGrid == sDesGrid)
	 {
     pSoldier->bPathStored = TRUE;
		 pSoldier->sFinalDestination = sGoToGrid;
	 }
	 else if ( pSoldier->usPathIndex == 0 )
	 {
		// we can hack this surely! -- CJC
     pSoldier->bPathStored = TRUE; 
		 pSoldier->sFinalDestination = sGoToGrid;
		 pSoldier->usPathDataSize = sLoop + 1;
	 }

#ifdef DEBUGDECISIONS
		ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_BETAVERSION, L"%d to %d with %d APs left", pSoldier->ubID, sGoToGrid, pSoldier->bActionPoints );
 #endif


		return( sGoToGrid );
  }
}
Exemple #10
0
int LegalNPCDestination(SOLDIERTYPE *pSoldier, INT16 sGridno, UINT8 ubPathMode, UINT8 ubWaterOK, UINT8 fFlags)
{
	BOOLEAN fSkipTilesWithMercs;
 
	if ((sGridno < 0) || (sGridno >= GRIDSIZE))
  {
#ifdef RECORDNET
   fprintf(NetDebugFile,"LegalNPC->sDestination: ERROR - rcvd invalid gridno %d",gridno);
#endif

#ifdef BETAVERSION
   NumMessage("LegalNPC->sDestination: ERROR - rcvd invalid gridno ",gridno);
#endif

   return(FALSE);
  }

	// return false if gridno on different level from merc
	if ( GridNoOnVisibleWorldTile( pSoldier->sGridNo ) && gpWorldLevelData[ pSoldier->sGridNo ].sHeight != gpWorldLevelData[ sGridno ].sHeight )
	{
		return( FALSE );
	}


	// skip mercs if turnbased and adjacent AND not doing an IGNORE_PATH check (which is used almost exclusively by GoAsFarAsPossibleTowards)
	fSkipTilesWithMercs = (gfTurnBasedAI && ubPathMode != IGNORE_PATH && SpacesAway( pSoldier->sGridNo, sGridno ) == 1 );

 // if this gridno is an OK destination
 // AND the gridno is NOT in a tear-gassed tile when we have no gas mask
 // AND someone is NOT already standing there
 // AND we're NOT already standing at that gridno
 // AND the gridno hasn't been black-listed for us

 // Nov 28 98: skip people in destination tile if in turnbased
 if ( ( NewOKDestination(pSoldier, sGridno, fSkipTilesWithMercs, pSoldier->bLevel ) ) &&
				( !InGas( pSoldier, sGridno ) ) &&
				( sGridno != pSoldier->sGridNo ) &&
				( sGridno != pSoldier->sBlackList ) )
 /*
 if ( ( NewOKDestination(pSoldier, sGridno, FALSE, pSoldier->bLevel ) ) &&
				( !(gpWorldLevelData[ sGridno ].ubExtFlags[0] & (MAPELEMENT_EXT_SMOKE | MAPELEMENT_EXT_TEARGAS | MAPELEMENT_EXT_MUSTARDGAS)) || ( pSoldier->inv[ HEAD1POS ].usItem == GASMASK || pSoldier->inv[ HEAD2POS ].usItem == GASMASK ) ) &&
				( sGridno != pSoldier->sGridNo ) &&
				( sGridno != pSoldier->sBlackList ) )*/
 /*
 if ( ( NewOKDestination(pSoldier,sGridno,ALLPEOPLE, pSoldier->bLevel ) ) &&
				( !(gpWorldLevelData[ sGridno ].ubExtFlags[0] & (MAPELEMENT_EXT_SMOKE | MAPELEMENT_EXT_TEARGAS | MAPELEMENT_EXT_MUSTARDGAS)) || ( pSoldier->inv[ HEAD1POS ].usItem == GASMASK || pSoldier->inv[ HEAD2POS ].usItem == GASMASK ) ) &&
				( sGridno != pSoldier->sGridNo ) &&
				( sGridno != pSoldier->sBlackList ) )
				*/
   {
    
	  // if water's a problem, and gridno is in a water tile (bridges are OK)
		if (!ubWaterOK && Water(sGridno))
		  return(FALSE);

    // passed all checks, now try to make sure we can get there!
    switch (ubPathMode)
     {
      // if finding a path wasn't asked for (could have already been done,
      // for example), don't bother
      case IGNORE_PATH     :	return(TRUE);

      case ENSURE_PATH     :	if ( FindBestPath( pSoldier, sGridno, pSoldier->bLevel, WALKING, COPYROUTE, fFlags ) )
															{
			   												return(TRUE);        // legal destination
															}
      												else // got this far, but found no clear path,
															{
																// so test fails
        												return(FALSE);
															}
															// *** NOTE: movement mode hardcoded to WALKING !!!!!
			case ENSURE_PATH_COST:	return(PlotPath(pSoldier,sGridno,FALSE,FALSE,FALSE,WALKING,FALSE,FALSE,0));

      default              :
#ifdef BETAVERSION
			     NumMessage("LegalNPC->sDestination: ERROR - illegal pathMode = ",ubPathMode);
#endif
			     return(FALSE);
     }
   }
 else  // something failed - didn't even have to test path
   return(FALSE);       	// illegal destination
}
Exemple #11
0
void CLimnStream::Dump(LPCTSTR Where, DWORD What) 
  {
  if (0 && What)
    {
    Dbg.Lock();
    Dbg.PrintLn("Dump %s ----------------------------------------- %s : %s", m_bIsMassForm?"MassForm":"FracForm", Where, Tag);

    if (0)
      {
      Dbg.PrintLn("");
      Dbg.PrintLn("Data:");
      for (int r = 0 ; r < gs_DWCfg.RowCount(); r++ )
        {
        Dbg.Print("%3i)", r);
        for (int c= 0 ; c < gs_DWCfg.ColCount(); c++ )
          Dbg.Print(" %10.2f", m_Data[r*gs_DWCfg.ColCount() + c]);
        Dbg.PrintLn("");
        }
      Dbg.PrintLn("");
      }

    if (What)
      {
      MVector V=Vector;
      for (int i=0; i<V.Count(); i++)
        Dbg.PrintLn("M[%-25s] : %15.4f", gs_MVDefn[i].Symbol(), V.M[i]*(m_bIsMassForm?3.6:1.0));
      Dbg.PrintLn("");
      }
    if (What & 0x01)
      Dbg.PrintLn("Water  : %10.4f", Water());
    if (What & 0x02)
      Dbg.PrintLn("FeSi   : %10.4f", FeSi());

    if (What & 0x04)
      {
      Dbg.PrintLn("Ore:");
      Dbg.Indent(4);
      Dbg.Print("%10s", "Size\\SG");
      for (int iSG = 0 ; iSG < nSGs(); iSG++ )
        Dbg.Print(" %10.4f", MeanSG(iSG ));
      Dbg.PrintLn("");
      Dbg.Print("%10s", "-------");
      for (int iSG = 0 ; iSG < nSGs(); iSG++ )
        Dbg.Print(" %10s", "--------");
      Dbg.PrintLn("");
      for (int iOSz = 0 ; iOSz < nOreSizes() ; iOSz++ )
        {
        Dbg.Print("%+10.2f", MeanOreSize(iOSz));
        for (int iSG = 0 ; iSG < nSGs(); iSG++ )
          Dbg.Print(" %10.4f", Ore(iOSz, iSG ));
        Dbg.PrintLn("");
        }
      Dbg.Indent(-4);
      }

    if (What & 0x08)
      {
      Dbg.PrintLn("");
      Dbg.PrintLn("Diamonds:");
      for (int iSG = 0 ; iSG < nSGs(); iSG++ )
        {
        Dbg.PrintLn("SG : %s", SGText(iSG));
        Dbg.Indent(2);

        bool DoIt=false;
        for (int iOSz = 0 ; !DoIt && iOSz < nOreSizes() ; iOSz++ )
          {
          for (int iDSz = 0 ; !DoIt && iDSz< nDiamondSizes(); iDSz++ )
            DoIt=Diamond(iDSz, iOSz, iSG )>1.0e-6;
          }

        if (!DoIt)
          {
          Dbg.Print("%10s", "");
          Dbg.PrintLn("ZERO");
          }
        else
          {
          Dbg.Print("%10s", "OSz\\DSz");
          for (int iDSz = 0 ; iDSz< nDiamondSizes(); iDSz++ )
            Dbg.Print(" %10s", DiamondSizeText(iDSz));
          Dbg.PrintLn("");
          Dbg.Print("%10s", "-------");
          for (int iDSz = 0 ; iDSz< nDiamondSizes(); iDSz++ )
            Dbg.Print(" %10s", "--------");
          Dbg.PrintLn("");
          for (int iOSz = 0 ; iOSz < nOreSizes() ; iOSz++ )
            {
            Dbg.Print("%+10.2f", MeanOreSize(iOSz));
            for (int iDSz = 0 ; iDSz< nDiamondSizes(); iDSz++ )
              Dbg.Print(" %10.4f", Diamond(iDSz, iOSz, iSG ));
            Dbg.PrintLn("");
            }
          }
        Dbg.Indent(-2);
        }
      }
    Dbg.PrintLn("-------------------------------------------------------");
    Dbg.UnLock();
    }
  };
int main(void)
{
	char s[] = "1442936700,0,1,4,#2346W,3,#0800O#1900C#0900O#1800C";  // for str_processing test
	
	
	RCC_ClocksTypeDef RCC_Clocks;

	/* SysTick end of count event each 10ms */
	RCC_GetClocksFreq(&RCC_Clocks);
	SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
	RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_RNG, ENABLE);
	RNG_Cmd(ENABLE);
	/* Initialize the timer for dht11 */
	tim_init(TIM2);
	/* Initialize the SRAM ****************************************************/
	PSRAM_Init();
	/* Initialize the LCD *****************************************************/
	LCD_Init();
	LCD_LOG_Init();
  LCD_LOG_SetHeader((uint8_t*)" Ethernet test");
	LCD_LOG_SetFooter ((uint8_t*)"     localtime: ");
	/* Add your application code here */
	/* Configure ethernet (GPIOs, clocks, MAC, DMA) */
	ETH_BSP_Config();
	/* Initilaize the LwIP stack */
	LwIP_Init();
	schedule_init(&schedule_got,schedule_string); // schedule string store in schedule_string
	DNS_Init();
	//while(!schedule_got); // wait until string got
	
	LCD_DisplayStringLine(Line2, (uint8_t*)schedule_string);
	LCD_DisplayStringLine(Line3, (uint8_t*)"0");
	/* Main Loop */
	
	//process ste str form internet

	Str_Split(s, Init_time);   // s is temp string

	RTC_Config();
	Time_Date_Setting(Init_time->year, Init_time->mon, Init_time->day, Init_time->hour +3, Init_time->min, Init_time->sec);
	
	
	
	
	while (1)
	{
		uint8_t year, mon, day;
		uint8_t hour, min, sec;
		RTC_TimeTypeDef RTC_TimeStruct_main;
		RTC_DateTypeDef RTC_DateStruct_main;
		RTC_GetDate(RTC_Format_BIN, &RTC_DateStruct_main);
		RTC_GetTime(RTC_Format_BIN, &RTC_TimeStruct_main);
		
		year = RTC_DateStruct_main.RTC_Year;	
		mon = RTC_DateStruct_main.RTC_Month;
		day = RTC_DateStruct_main.RTC_Date;
		hour = RTC_TimeStruct_main.RTC_Hours;
		min = RTC_TimeStruct_main.RTC_Minutes;
		sec = RTC_TimeStruct_main.RTC_Seconds;
		
		//detect whether it is time to turn on Motor and LED, then execute it.
		Soak(day, hour, min );
		Water(day, hour, min, sec);
		Light(mon, day, hour, min);
		//detect over
			
		/* check if any packet received */
		if (ETH_CheckFrameReceived())
		{
			/* process received ethernet packet */
			LwIP_Pkt_Handle();
		}
		/* handle periodic timers for LwIP */
		LwIP_Periodic_Handle(LocalTime);
		
	}
}
Exemple #13
0
	Water loadWater(ZombieEntry entry) {
		return Water(entry.getChildEntry("seeFloorImage").getSprite());
	}
Exemple #14
0
flag VLL_Sep::EvalPressureSens()
  {
  ExtraH2oSettled=0.0;
//  SetVLEMixFrac(H2oSettled);

  double BigDiff=0.0;

  // Must be closed and have contents
  if (!Contents.Closed() || Contents.Mass()< 1.0e-6)
    {
    ZeroVLSensitivities(0);
    return True;
    }

  Contents.SetHoldVentExpand();
  ContStartInfo Start(Contents);

//  ContStartInfo Start(C);
  // Vapour Sensitivity
  double QMassV=1.0;
  double DeltaFrac=Range(1.0e-6, 0.1*Max(1.0, Start.MassV)/NZ(fabs(QMassV)), 1.0);
  Contents.AddM(Contents, som_Vap, DeltaFrac);
  double AvgPSensV=(Contents.Press()-Start.Pres)/DeltaFrac;
  RestoreContents(Contents, Start);

  // Liquid Sensitivity
  double QMassL=1.0;
  DeltaFrac=Range(1.0e-6, 0.1*Max(1.0, Start.MassL)/NZ(fabs(QMassL)), 1.0);
  Contents.AddM(Contents, som_SL, DeltaFrac);
  double AvgPSensL=(Contents.Press()-Start.Pres)/DeltaFrac;
  RestoreContents(Contents, Start);

  SetEquilibratingV2L(0, Contents, Start);
  //SetVLSensitivities(0, Contents, Start);
  SetStaticHeadSensitivities(0, Contents, Start);
  // Flash to Equilibrium


  ContStartInfo Equil(Contents);

  double DeltaMass, Mv0, Mv1, P0, P1;
  JoinRec & J=Joins[0];
  for (int c=0; c<J.NConns(); c++)
    {
    int i=J.IONo(c);
    SpConduit &Cd=*IOConduit(i);

    double XH2OScl;
    if (IOId_Self(i)==VLLIO_boot)
      XH2OScl=1.0;
    else if (IO_In(i))
      XH2OScl=1.0-H2ORemEff;
    else
      XH2OScl=0.0;

    // Transfer to retain equil due to movement of vapour
    RestoreContents(Contents, Equil);

    DeltaMass=Max(1.0e-6, 0.001*Equil.MassV);
    P0=Contents.Press();
    Contents.AddM(Cd, som_Vap, DeltaMass);
    P1=Contents.Press();
    double PSensV=(fabs(P1-P0)>1.0e-6) ? (P1-P0)/DeltaMass : AvgPSensV;

    Mv0=Contents.Mass(som_Vap);
    ExtraH2oSettled=XH2OScl*Cd.Qm(Steam())*DeltaMass/GTZ(Cd.QMass(som_Vap));
    ConvergeStates();
    Mv1=Contents.Mass(som_Vap);
    double V2LQVFrac=(Mv0-Mv1)/DeltaMass;

    // Transfer to retain equil due to movement of liquor
    RestoreContents(Contents, Equil);

    DeltaMass=Max(1.0e-6, 0.001*Equil.MassL);
    P0=Contents.Press();
    Contents.AddM(Cd, som_SL, DeltaMass);
    P1=Contents.Press();
    //double PSensL=(P1-P0)/DeltaMass;
    double PSensL=(fabs(P1-P0)>1.0e-6) ? (P1-P0)/DeltaMass : AvgPSensL;

    Mv0=Contents.Mass(som_Vap);
    ExtraH2oSettled=XH2OScl*Cd.Qm(Water())*DeltaMass/GTZ(Cd.QMass(som_Liq));
    ConvergeStates();
    Mv1=Contents.Mass(som_Vap);

    double V2LQLFrac=(Mv0-Mv1)/DeltaMass;

    Set_IO_PSensVL(i, PSensV, PSensL);
    Set_IO_V2LQmFact(i, V2LQVFrac, V2LQLFrac);

//    dbgpln("     V2L  V:%14.6g L:%14.6g  %14.6g %14.6g  %s",
//      V2LQVFrac, V2LQLFrac, XH2OScl, ExtraH2oSettled, Nd_Rmt(i)->FullObjTag());
    }

  RestoreContents(Contents, Start);
  ExtraH2oSettled=0.0;

  Contents.ClrHoldVentExpand();

  return true;//False;
  };
Exemple #15
0
void VLL_Sep::SetVLEMixFrac(double H2OSettled)
  {
  VLE.SetMixFrac(1.0, 1.0);
  VLE.SetMixFrac(Water.ci(), 1.0, 1.0-H2oSettled/GTZ(Contents.SpMass(Water())));
  }