////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Generates a GUID based on the specified seed value. The same seeds will create the same GUIDs on the same machine.
//
VOID GenGuid(GUID* pGuid, PULONG pSeed)
{
	ULONG i;
	pGuid->Data1 = MyRandom(pSeed);
	pGuid->Data2 = (USHORT)MyRandom(pSeed);
	pGuid->Data3 = (USHORT)MyRandom(pSeed);
	for (i=0; i<8; i++)
		pGuid->Data4[i] = (UCHAR)MyRandom(pSeed);
}
예제 #2
0
 void main()
 {
   Print("Hello\n");
   PrintNum(MyRandom(200));
   Halt();	// Optional. Just print stats
 }
예제 #3
0
OSErr DecodeOrdinal(AEDesc ordData, long count, long* index,
    				Boolean* allFlag, Boolean* zeroFlag)
/* this routine is used whenever an element is specified by an absolute position
  within a sequence of elements - such as "word 3 of window 'johnson'", "any line
  of item 17 of window 'Kelvin'", etc.  The data specifying the position can be
  a positive integer (which just means the actual position of the element in the
  sequence: 1 for the first element, 2 for the second, etc.), a negative integer
  (which indicates position relative to the last element of the sequence: -1 is
  the last element, -2 the next to last, etc.), or a descriptor of typeAbsoluteOrdinal:
  kAEFirst, kAELast, kAEMiddle, kAEAny, or kAEAll.  
  
  DecodeOrdinal takes the data specifying the position, and a count of all the elements
  in the sequence under consideration, and returns (whenever possible) a positive integer
  (in the return VAR index) representing the actual position of the element in the sequence 
  (1 for first, 2 for second, etc.).  It also returns flags indicating (a) whether the 
  ordinal was kAEAll and (b) whether the count was 0; both of these are conditions that 
  many calling routines will have to special-case.  In the case of kAEAll, the return VAR 
  index is set to the count; in the case of count = 0, the return VAR index is set to 0.
  
  There are a few error conditions:  (a) count < 0; (b) bad ordData (not an integer, and
  not one of the five defined absolute ordinal specifiers).  **CHECK - should "integer ordData
  out of range" (for example, an integer > count, or < -count, or = 0) be an error,
  or should we allow that so that people can talk about "the hypothetical element
  beyond the last", or whatever?  For now, let's make that a non-error.
  
  INPUTS:	ordData		a descriptor that specifies an ordinal - either
  						an integer (positive or negative) or something
						of typeAbsoluteOrdinal
			count		the total number of elements in the group involved
						(number of windows, number or chars, or whatever)
			index		return VAR for the actual position being described
			allFlag		return VAR: TRUE if the ordData was kAEAll, FALSE o.w.
			zeroFlag	return VAR: TRUE if the count was zero (for many
						calling routines this is an error condition), FALSE o.w.
  OUTPUTS:	error code (noErr if none)
*/
{
	OSErr myErr;
#if !defined(_PLATFORM_WIN32_) || !defined(PORTING_HACK)
	DescType absOrd;
	long intOrd;

  myErr = genericErr;
  *index = count;
  *allFlag = kODFalse;
  
  *zeroFlag = (count == 0);
  if (count < 0)
  {
	  myErr = errAEBadData;
	  goto exit;
	}
  
  myErr = MyAECoerceDescPtr(ordData, typeAbsoluteOrdinal, (Ptr)&absOrd,
  							sizeof(absOrd), &gActSize);
  if (myErr == noErr)
    {
	  /* got an absolute ordinal */
	  /* note that, as we enter here, index == count and myErr == noErr */
	  *allFlag = (absOrd == kAEAll);
	  if (*allFlag)
	  	goto exit;	/* finish up */
		
	  if ((absOrd != kAEFirst) && (absOrd != kAELast)
	  		&& (absOrd != kAEMiddle) && (absOrd != kAEAny))
	    {
		  myErr = errAEBadData;
		  goto exit;
		}
		
	  if (*zeroFlag || (absOrd == kAELast))
	  	goto exit; /* in both cases, index == count (already done) */
		
	  if (absOrd == kAEFirst)
	  	*index = 1;
	  else if (absOrd == kAEMiddle)
	  	*index = (count + 1) / 2;
	  else
	  	*index = MyRandom(count);
	  
	  goto exit;
	}	/* of absolute ordinal */
	
  /* try actual integer */
  myErr = MyAECoerceDescPtr(ordData, typeLongInteger, (Ptr)&intOrd,
  								sizeof(intOrd), &gActSize);
  if (myErr)
	goto exit;
	  
  if (intOrd < 0)
  	*index = count + intOrd + 1;	/* e.g., intOrd == -1 means index == count */
  else
  	*index = intOrd;
  
  /* should we validate index here (wrt count)?  let's skip it for now */
  
exit:	/* finish up */
#endif // !defined(_PLATFORM_WIN32_) || !defined(PORTING_HACK)
  return myErr;
}
예제 #4
0
/*-----------------------------------------------------------------
 * @Desc: generate a random Playground
 *	
 * @Ret: void
 *
 *-----------------------------------------------------------------*/
void
InventPlayground (void)
{
  int anElement;
  int newElement;
  int row, layer;
  int color = GELB;

  /* first clear the playground: we depend on this !! */
  ClearPlayground ();

  for (color = GELB; color < TO_COLORS; color++)
    {
      for (layer = 1; layer < NUM_LAYERS - 1; layer++)
	{
	  for (row = 0; row < NUM_LINES; row++)
	    {
	      if (ToPlayground[color][layer][row] != KABEL)
		continue;

	      newElement = MyRandom (TO_ELEMENTS);
	      if (MyRandom (MAX_PROB) > ElementProb[newElement])
		{
		  row--;
		  continue;
		}

	      switch (newElement)
		{
		case EL_KABEL:	/* has not to be set any more */
		  anElement = ToPlayground[color][layer - 1][row];
		  if (BlockClass[anElement] == NON_CONNECTOR)
		    ToPlayground[color][layer][row] = LEER;
		  break;

		case EL_KABELENDE:
		  anElement = ToPlayground[color][layer - 1][row];
		  if (BlockClass[anElement] == NON_CONNECTOR)
		    ToPlayground[color][layer][row] = LEER;
		  else
		    ToPlayground[color][layer][row] = KABELENDE;
		  break;

		case EL_VERSTAERKER:
		  anElement = ToPlayground[color][layer - 1][row];
		  if (BlockClass[anElement] == NON_CONNECTOR)
		    ToPlayground[color][layer][row] = LEER;
		  else
		    ToPlayground[color][layer][row] = VERSTAERKER;
		  break;

		case EL_FARBTAUSCHER:
		  if (layer != 2)
		    {		/* only existing on layer 2 */
		      row--;
		      continue;
		    }

		  anElement = ToPlayground[color][layer - 1][row];
		  if (BlockClass[anElement] == NON_CONNECTOR)
		    ToPlayground[color][layer][row] = LEER;
		  else
		    ToPlayground[color][layer][row] = FARBTAUSCHER;
		  break;

		case EL_VERZWEIGUNG:
		  if (row > NUM_LINES - 3)
		    {
		      /* try again */
		      row--;
		      break;
		    }

		  anElement = ToPlayground[color][layer - 1][row + 1];
		  if (BlockClass[anElement] == NON_CONNECTOR)
		    {
		      /* try again */
		      row--;
		      break;
		    }

		  /* dont destroy verzweigungen in prev. layer */
		  anElement = ToPlayground[color][layer - 1][row];
		  if (anElement == VERZWEIGUNG_O
		      || anElement == VERZWEIGUNG_U)
		    {
		      row--;
		      break;
		    }
		  anElement = ToPlayground[color][layer - 1][row + 2];
		  if (anElement == VERZWEIGUNG_O
		      || anElement == VERZWEIGUNG_U)
		    {
		      row--;
		      break;
		    }

		  /* cut off kabels in last layer, if any */
		  anElement = ToPlayground[color][layer - 1][row];
		  if (BlockClass[anElement] == CONNECTOR)
		    ToPlayground[color][layer - 1][row] = KABELENDE;

		  anElement = ToPlayground[color][layer - 1][row + 2];
		  if (BlockClass[anElement] == CONNECTOR)
		    ToPlayground[color][layer - 1][row + 2] = KABELENDE;

		  /* set the verzweigung itself */
		  ToPlayground[color][layer][row] = VERZWEIGUNG_O;
		  ToPlayground[color][layer][row + 1] = VERZWEIGUNG_M;
		  ToPlayground[color][layer][row + 2] = VERZWEIGUNG_U;

		  row += 2;
		  break;

		case EL_GATTER:
		  if (row > NUM_LINES - 3)
		    {
		      /* try again */
		      row--;
		      break;
		    }

		  anElement = ToPlayground[color][layer - 1][row];
		  if (BlockClass[anElement] == NON_CONNECTOR)
		    {
		      /* try again */
		      row--;
		      break;
		    }
		  anElement = ToPlayground[color][layer - 1][row + 2];
		  if (BlockClass[anElement] == NON_CONNECTOR)
		    {
		      /* try again */
		      row--;
		      break;
		    }


		  /* cut off kabels in last layer, if any */
		  anElement = ToPlayground[color][layer - 1][row + 1];
		  if (BlockClass[anElement] == CONNECTOR)
		    ToPlayground[color][layer - 1][row + 1] = KABELENDE;

		  /* set the GATTER itself */
		  ToPlayground[color][layer][row] = GATTER_O;
		  ToPlayground[color][layer][row + 1] = GATTER_M;
		  ToPlayground[color][layer][row + 2] = GATTER_U;

		  row += 2;
		  break;

		default:
		  row--;
		  break;

		}		/* switch NewElement */

	    }			/* for row */

	}			/* for layer */

    }				/* for color */

}				/* InventPlayground */
예제 #5
0
/*-----------------------------------------------------------------
 * @Desc: animiert Gegner beim Uebernehm-Spiel
 * 
 * @Ret: void
 * @Int:
 *-----------------------------------------------------------------*/
void
EnemyMovements (void)
{
  static int Actions = 3;
  static int MoveProbability = 100;
  static int TurnProbability = 10;
  static int SetProbability = 80;

  int action;
  static int direction = 1;	/* start with this direction */
  int row = CapsuleCurRow[OpponentColor] - 1;

  if (NumCapsules[ENEMY] == 0)
    return;


  action = MyRandom (Actions);
  switch (action)
    {
    case 0:			/* Move along */
      if (MyRandom (100) <= MoveProbability)
	{
	  row += direction;
	  if (row > NUM_LINES - 1)
	    row = 0;
	  if (row < 0)
	    row = NUM_LINES - 1;
	}
      break;

    case 1:			/* Turn around */
      if (MyRandom (100) <= TurnProbability)
	{
	  direction *= -1;
	}
      break;

    case 2:			/* Try to set  capsule */
      if (MyRandom (100) <= SetProbability)
	{
	  if ((row >= 0) &&
	      (ToPlayground[OpponentColor][0][row] != KABELENDE) &&
	      (ActivationMap[OpponentColor][0][row] == INACTIVE))
	    {
	      NumCapsules[ENEMY]--;
	      Takeover_Set_Capsule_Sound ();
	      ToPlayground[OpponentColor][0][row] = VERSTAERKER;
	      ActivationMap[OpponentColor][0][row] = ACTIVE1;
	      CapsuleCountdown[OpponentColor][0][row] = CAPSULE_COUNTDOWN;
	      row = -1;		/* For the next capsule: startpos */
	    }
	} /* if MyRandom */

      break;

    default:
      break;

    }	/* switch action */

  CapsuleCurRow[OpponentColor] = row + 1;

  return;
}	/* EnemyMovements */
예제 #6
0
파일: MAKECHAR.CPP 프로젝트: mhjlam1/bam
void
MakeChar::Setup()
{
	BAM_Guy		*pGuy;
	BAM_Button	*pButton;
	uchar			*pback;
	CelHeader	*pbackCH;
	int			x;
	uint			rNumBord;

	//======================================================
	// setup background cel filled with black
	TRACK_MEM("MakeChar background cel");
	gback = ACreateCel(&rNumBack,0,0,320,400,CI_BLACK,100);
	pback = AGetResData(gback);
	pbackCH = (CelHeader*)pback;

	// copy this anim into the dynamic cel that we will use
	gbackAnim = ALoad(RES_ANIM,8150);
	CopyCel(pbackCH,0,0,RES_ANIM,8150,1,FALSE);

	pGuy = &back;
	pGuy->SetRes(RES_CEL,rNumBack);
	pGuy->SetPos(0,0);
	pGuy->SetContext(gSelf);
	pGuy->Setup(CT_ROST);
	pGuy->SetPri(100);

	//pal.FadeToBlack();
	pal.Load(8150);

	// pick a gender catagory
	switch (ARandom(3))
	{
		case 0:
			bGlobal.curCat = G_MEN;
			break;

		case 1:
			bGlobal.curCat = G_WOMEN;
			break;

		case 2:
			bGlobal.curCat = G_OTHER;
			break;

	}

	//======================================================
	// lets copy in all the borders and boundaries into the background

	gPortBord = ALoad(RES_ANIM,8154);
	rNumBord = 8154;
	CopyCel((CelHeader*)pback,108,67,RES_ANIM,rNumBord,3,TRUE);	// Name Frame
	CopyCel((CelHeader*)pback,108,92,RES_ANIM,rNumBord,1,TRUE);	// Portrait Frame
	CopyCel((CelHeader*)pback,157,92,RES_ANIM,rNumBord,4,TRUE);	// Arrow Buttons Frame
	CopyCel((CelHeader*)pback,108,191,RES_ANIM,rNumBord,5,TRUE);	// Gender Buttons Frame
	CopyCel((CelHeader*)pback,108,222,RES_ANIM,rNumBord,6,TRUE);	// Name Buttons Frame
	CopyCel((CelHeader*)pback,108,253,RES_ANIM,rNumBord,7,TRUE);	// 'Done' Button Frame
	CopyCel((CelHeader*)pback,21,281,RES_ANIM,rNumBord,10,TRUE);	// Option Button Frame

	//=============================================
	// Write the necessary text into the background

	pFontMgr->SetRes(9050);
	SetFontColors(CI_SKIP,64,74);

	pTxt = sqbMakeChar.Load(MAKECHAR_SQB,1);
	ASetString(206,  99, pTxt, (uchar *)pbackCH, pbackCH->width, NULL);
	pTxt = sqbMakeChar.Load(MAKECHAR_SQB,2);
	ASetString(206, 116, pTxt, (uchar *)pbackCH, pbackCH->width, NULL);
	pTxt = sqbMakeChar.Load(MAKECHAR_SQB,3);
	ASetString(206, 133, pTxt, (uchar *)pbackCH, pbackCH->width, NULL);
	pTxt = sqbMakeChar.Load(MAKECHAR_SQB,4);
	ASetString(206, 150, pTxt, (uchar *)pbackCH, pbackCH->width, NULL);
	pTxt = sqbMakeChar.Load(MAKECHAR_SQB,5);
	ASetString( 70, 198, pTxt, (uchar *)pbackCH, pbackCH->width, NULL);
	pTxt = sqbMakeChar.Load(MAKECHAR_SQB,6);
	ASetString( 82, 229, pTxt, (uchar *)pbackCH, pbackCH->width, NULL);

	pFontMgr->SetRes(9052);
	SetFontColors(CI_SKIP,93,76,74,74,48,CI_BLACK);
	pTxt = sqbMakeChar.Load(MAKECHAR_SQB,7);
	pFontMgr->SetString(0,330, pTxt, (uchar *)pbackCH, pbackCH->width, NULL, DG_JUST_CENTER);

	SetFontColors(CI_SKIP,45,46,47,49,50,CI_BLACK);
	pTxt = sqbMakeChar.Load(MAKECHAR_SQB,8);
	pFontMgr->SetString(0,372, pTxt, (uchar *)pbackCH, pbackCH->width, NULL, DG_JUST_CENTER);
	pFontMgr->SetRes(9050);
	SetFontColors(CI_SKIP,64,74);


	switch(bGlobal.curCat)
	{
		case G_MEN:
			sqbRes = MEN_SQB;
			if(!maxMenNameNum)
				maxMenNameNum = atoi(sqbMakeChar.Load(MEN_SQB,1));
			//add 2 to num to get zero based random num past first sqb used above
			curNameNum = MyRandom(maxMenNameNum,curNameNum) + 2;
			break;
		case G_WOMEN:
			sqbRes = WOMEN_SQB;
			if(!maxWomenNameNum)
				maxWomenNameNum = atoi(sqbMakeChar.Load(WOMEN_SQB,1));
			curNameNum = MyRandom(maxWomenNameNum,curNameNum) + 2;
			break;
		case G_OTHER:
			sqbRes = OTHER_SQB;
			if(!maxOtherNameNum)
				maxOtherNameNum = atoi(sqbMakeChar.Load(OTHER_SQB,1));
			curNameNum = MyRandom(maxOtherNameNum,curNameNum) + 2;
			break;
	}


	pTxt = sqbMakeChar.Load(sqbRes,curNameNum);
	TRACK_MEM("NameText");	gNameText = AMalloc(20);
	char *pText = ADerefAs(char, gNameText);
	strcpy(bGlobal.curName,pTxt);
	strcpy(pText,pTxt);
	BAM_Box	*pBox = &nameBox;
	pBox->SetColors(CI_SKIP,64,74,64,74,64,74,155,142);
	pBox->Create(111, 71, 105, 15, 200, gNameText, 16, gSelf, rNumBack,0,0);
	pBox->SetupReplies(REPLY_DESELECTED);	// let us know when text changes
	//pBox->Select(TRUE); //makes the box edit active

	//======================================================
	// setup current portrait -randomly init.

	LoadCover();
	LoadFace();
	LoadBody();
	LoadBanner();

	//======================================================
	// lets setup up all the buttons

	uint32 posY[4] =  { 95, 112, 129, 146 };

	for(x=0; x<4; x++)
	{
		// create left arrow button
		pButton = &leftArrowB[x];
		pButton->Create(159, posY[x], 200, RES_ANIM, 8156, 1, gSelf);
		pButton->SetupReplies(REPLY_DESELECTED);
		pButton->fIsToggle = FALSE;		// click-type button
		pButton->SetOwnerCel(rNumBack);		// draws itself into this DCEL, instead of being drawn by Animate() directly
		pButton->Select(FALSE);				// set button to unselected state - will cause drawing into master cel

		// create right arrow button
		pButton = &rightArrowB[x];
		pButton->Create(180, posY[x], 200, RES_ANIM, 8157, 1, gSelf);
		pButton->SetupReplies(REPLY_DESELECTED);
		pButton->fIsToggle = FALSE;		// click-type button
		pButton->SetOwnerCel(rNumBack);		// draws itself into this DCEL, instead of being drawn by Animate() directly
		pButton->Select(FALSE);				// set button to unselected state - will cause drawing into master cel
	}


	// disk button
	pButton = &diskB;
	pButton->Create(23, 285, 200, RES_ANIM, 129, 1, gSelf);
	pButton->SetupReplies(REPLY_DESELECTED);
	pButton->fIsToggle = FALSE;		// click-type button
	pButton->SetOwnerCel(rNumBack);		// draws itself into this DCEL, instead of being drawn by Animate() directly
	pButton->Select(FALSE);				// set button to unselected state - will cause drawing into master cel

	pButton = &randomCharB;
	pButton->Create(159, 163, 200, RES_ANIM, 8158, 1, gSelf);
	pButton->SetupReplies(REPLY_DESELECTED);
	pButton->fIsToggle = FALSE;		// click-type button
	pButton->SetOwnerCel(rNumBack);		// draws itself into this DCEL, instead of being drawn by Animate() directly
	pButton->SetTextJustify(DG_JUST_CENTER, DG_JUST_CENTER);
	pTxt = sqbMakeChar.Load(MAKECHAR_SQB,9);
	pButton->SetCelText(1, pTxt);
	pButton->SetColors(1, 93, 90);				// inactive colors
	pButton->SetCelText(2, pTxt);
	pButton->SetColors(2, 155, 142);				// active colors
	pButton->Draw();
	pButton->Select(FALSE);				// set button to unselected state - will cause drawing into master cel

	pButton = &manB;
	pButton->Create(110, 194, 200, RES_ANIM, 8158, 1, gSelf);
	pButton->SetupReplies(REPLY_ACTIVATED | REPLY_DEACTIVATED);
	pButton->fIsToggle = TRUE;			// click-type button
	pButton->SetOwnerCel(rNumBack);		// draws itself into this DCEL, instead of being drawn by Animate() directly
	pButton->SetTextJustify(DG_JUST_CENTER, DG_JUST_CENTER);
	pTxt = sqbMakeChar.Load(MAKECHAR_SQB,10);
	pButton->SetCelText(1, pTxt);
	pButton->SetColors(1, 93, 90);				// inactive colors
	pButton->SetCelText(2, pTxt);
	pButton->SetColors(2, 155, 142);				// active colors
	pButton->Draw();
	if(bGlobal.curCat == G_MEN)
		pButton->Select(TRUE);				// set button to unselected state - will cause drawing into master cel
	else
		pButton->Select(FALSE);				// set button to unselected state - will cause drawing into master cel

	pButton = &womanB;
	pButton->Create(152, 194, 200, RES_ANIM, 8158, 1, gSelf);
	pButton->SetupReplies(REPLY_ACTIVATED | REPLY_DEACTIVATED);
	pButton->fIsToggle = TRUE;			// click-type button
	pButton->SetOwnerCel(rNumBack);		// draws itself into this DCEL, instead of being drawn by Animate() directly
	pButton->SetTextJustify(DG_JUST_CENTER, DG_JUST_CENTER);
	pTxt = sqbMakeChar.Load(MAKECHAR_SQB,11);
	pButton->SetCelText(1, pTxt);
	pButton->SetColors(1, 93, 90);				// inactive colors
	pButton->SetCelText(2, pTxt);
	pButton->SetColors(2, 155, 142);				// active colors
	pButton->Draw();
	if(bGlobal.curCat == G_WOMEN)
		pButton->Select(TRUE);				// set button to unselected state - will cause drawing into master cel
	else
		pButton->Select(FALSE);				// set button to unselected state - will cause drawing into master cel

	pButton = &otherB;
	pButton->Create(194, 194, 200, RES_ANIM, 8158, 1, gSelf);
	pButton->SetupReplies(REPLY_ACTIVATED | REPLY_DEACTIVATED);
	pButton->fIsToggle = TRUE;			// click-type button
	pButton->SetOwnerCel(rNumBack);		// draws itself into this DCEL, instead of being drawn by Animate() directly
	pButton->SetTextJustify(DG_JUST_CENTER, DG_JUST_CENTER);
	pTxt = sqbMakeChar.Load(MAKECHAR_SQB,12);
	pButton->SetCelText(1, pTxt);
	pButton->SetColors(1, 93, 90);				// inactive colors
	pButton->SetCelText(2, pTxt);
	pButton->SetColors(2, 155, 142);				// active colors
	pButton->Draw();
	if(bGlobal.curCat == G_OTHER)
		pButton->Select(TRUE);				// set button to unselected state - will cause drawing into master cel
	else
		pButton->Select(FALSE);				// set button to unselected state - will cause drawing into master cel

	pButton = &customNameB;
	pButton->Create(110, 225, 200, RES_ANIM, 8158, 1, gSelf);
	pButton->SetupReplies(REPLY_DESELECTED);
	pButton->fIsToggle = FALSE;		// click-type button
	pButton->SetOwnerCel(rNumBack);		// draws itself into this DCEL, instead of being drawn by Animate() directly
	pButton->SetTextJustify(DG_JUST_CENTER, DG_JUST_CENTER);
	pTxt = sqbMakeChar.Load(MAKECHAR_SQB,13);
	pButton->SetCelText(1, pTxt);
	pButton->SetColors(1, 93, 90);				// inactive colors
	pButton->SetCelText(2, pTxt);
	pButton->SetColors(2, 155, 142);				// active colors
	pButton->Draw();
	pButton->Select(FALSE);				// set button to unselected state - will cause drawing into master cel

	pButton = &randomNameB;
	pButton->Create(152, 225, 200, RES_ANIM, 8158, 1, gSelf);
	pButton->SetupReplies(REPLY_DESELECTED);
	pButton->fIsToggle = FALSE;		// click-type button
	pButton->SetOwnerCel(rNumBack);		// draws itself into this DCEL, instead of being drawn by Animate() directly
	pButton->SetTextJustify(DG_JUST_CENTER, DG_JUST_CENTER);
	pTxt = sqbMakeChar.Load(MAKECHAR_SQB,9);
	pButton->SetCelText(1, pTxt);
	pButton->SetColors(1, 93, 90);				// inactive colors
	pButton->SetCelText(2, pTxt);
	pButton->SetColors(2, 155, 142);				// active colors
	pButton->Draw();
	pButton->Select(FALSE);				// set button to unselected state - will cause drawing into master cel

	pButton = &doneB;
	pButton->Create(110, 256, 200, RES_ANIM, 8158, 1, gSelf);
	pButton->SetupReplies(REPLY_DESELECTED);
	pButton->fIsToggle = FALSE;		// click-type button
	pButton->SetOwnerCel(rNumBack);		// draws itself into this DCEL, instead of being drawn by Animate() directly
	pButton->SetTextJustify(DG_JUST_CENTER, DG_JUST_CENTER);
	pTxt = sqbMakeChar.Load(MAKECHAR_SQB,14);
	pButton->SetCelText(1, pTxt);
	pButton->SetColors(1, 93, 90);				// inactive colors
	pButton->SetCelText(2, pTxt);
	pButton->SetColors(2, 155, 142);				// active colors
	pButton->Draw();
	pButton->Select(FALSE);				// set button to unselected state - will cause drawing into master cel

	BAM_Room::Setup();
	pGraphMgr->Animate();
	pal.FadeUp();

}
예제 #7
0
void OSSMWeatherer_c::WeatherLE (LERec *theLE)
// returns true if LE properties are modified
{
	Boolean			bDecay = false;
	OilComponent	component;
	
	double		tHours, p [2][3], prNum = 0.0, prDen = 0.0, XINT = 0.0, xProb, rNum;
	short		i, ipr = 0;
	
	/// JOLM 1/11/99
	// for some reason, non-weathering oil sometimes weathers one LE
	// Conservative LEs are not supposed to weather , so check that here
	// code goes here, if dispersing naturally, don't want to weather here, check if AdiosDataH exists - outside?
	
	if(theLE -> pollutantType == OIL_CONSERVATIVE || theLE -> dispersionStatus == HAVE_DISPERSED) return;// no weathering
	// what about chemicals with half life?
	
	componentsList -> GetListItem ((Ptr) &component, theLE -> pollutantType - 1);
	//componentsList -> GetListItem ((Ptr) &component, theLE -> pollutantType );
	//	printf ("component.halfLife [0] = %f, [1] = %f, [2] = %f\n", component.halfLife [0], component.halfLife [1], component.halfLife [2]);
	//	printf ("component.percent  [0] = %f, [1] = %f, [2] = %f\n", component.percent [0], component.percent [1], component.percent [2]);
	
	///////////////////////////////
	// JLM 3/11/99 tHours should be the age of the oil in hours 
	// and not the RunDuration  !!  (Gasoline evaporates based on how old it is !!)
	//
	// old code
	//	tHours = (double) model -> GetRunDuration () / 3600.0;		// duration converted from seconds to hours
	//	//	tHours = fmod (tHours, 1.0);
	//
	tHours = (double) ( model -> GetModelTime () - theLE -> releaseTime)/ 3600.0  + theLE -> ageInHrsWhenReleased;
	///////////////////////////////
	
	// temporary fudge, probably won't weather chemicals, just have mass decrease, maybe need a new category for dissolved LEs
	if(theLE -> pollutantType == CHEMICAL /*&& (*theLE).z > 0*/)
	{
		double fracLeft = 0.;
		for(i = 0;i<3;i++)
		{	// only actually using first component...
			if(component.percent[i] > 0.0)
			{
				fracLeft +=  (component.percent[i])*pow(0.5,tHours/(component.halfLife[i]));
			}
		}
		fracLeft = _max (0.0,fracLeft);
		fracLeft = _min (1.0,fracLeft);
		//if (fracLeft < 0.001)
		if (fracLeft == 0.0)
			theLE -> statusCode = OILSTAT_EVAPORATED; // I don't think this will happen
		return;
	}
	
	XINT = (double) model -> GetTimeStep () / 3600.0;			// time step converted from seconds to hours
	
	// put this in for debugging to visualize LEs disappearing
	/*if(theLE -> pollutantType == CHEMICAL && (*theLE).z == 0)
	{
		// the settable half life needs to be a field in LEList since it could be different for different spills
		// possibly set the component.halfLife for each spill during Step()
		double thisComponent_XK = 0.693147 / component.halfLife [0],p0,p1;
		if (-thisComponent_XK * (tHours + XINT) < -100)
		{
     		p0 = 0.0;
      		p1 = 0.0;
		}
		else
		{
			//			printf ("Exponent computed\n");
     		p0 = exp (-thisComponent_XK * tHours);
     		p1 = exp (-thisComponent_XK * (tHours + XINT));
		}
		
		//		printf ("p [0][i] = %f, p[1][i] = %f\n", p[0][i], p[1][i]);;
      	prNum = (p0 - p1);
      	prDen = p0;
		
		xProb = prNum / prDen;
		rNum = (double) MyRandom ();
		//if (rNum <= xProb && theLE -> mass != 0)
		if (rNum <= xProb && theLE -> statusCode != OILSTAT_EVAPORATED)
		{
			//theLE -> mass = 0;
			theLE -> statusCode = OILSTAT_EVAPORATED; //JLM,10/20/98 
			//		printf ("LE [%d] Evaporated\n", theLE -> leKey);
		}
		else
		{
			xProb = 0;
			ipr = 0;
		}
		return;
	}*/
		
	for (i = 0; i <= 2; ++i)
	{
		if (-component.XK [i] * (tHours + XINT) < -100)
		{
     		p [0][i] = 0.0;
      		p [1][i] = 0.0;
		}
		else
		{
			//			printf ("Exponent computed\n");
     		p [0][i] = exp (-component.XK [i] * tHours);
     		p [1][i] = exp (-component.XK [i] * (tHours + XINT));
		}
		
		//		printf ("p [0][i] = %f, p[1][i] = %f\n", p[0][i], p[1][i]);;
      	prNum += component.percent [i] * (p[0][i] - p[1][i]);
      	prDen += component.percent [i] *  p[0][i];
	}
	
	xProb = prNum / prDen;
	rNum = (double) MyRandom ();
	if (rNum <= xProb && theLE -> mass != 0)
	{
		theLE -> mass = 0;
		theLE -> statusCode = OILSTAT_EVAPORATED; //JLM,10/20/98 
		//		printf ("LE [%d] Evaporated\n", theLE -> leKey);
	}
	else
	{
		xProb = 0;
		ipr = 0;
	}
	
	//	printf ("tHours = %f, prNum = %f, prDen = %f, xProb = %f\n", tHours, prNum, prDen, xProb);

//	while (Button ());

	return;
}
예제 #8
0
int Random::PageOut()
{
    return frameTable[MyRandom(numFrames)];
}