float ABaseCharacter::TakeDamage(float Damage, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, class AActor* DamageCauser)
{
	if (Health > 0.f)
	{
		/* Modify based based on gametype rules */
		//ASGameMode* MyGameMode = Cast<ASGameMode>(GetWorld()->GetAuthGameMode());
		//Damage = MyGameMode ? MyGameMode->ModifyDamage(Damage, this, DamageEvent, EventInstigator, DamageCauser) : Damage;


		const float ActualDamage = Super::TakeDamage(Damage, DamageEvent, EventInstigator, DamageCauser);
		if (ActualDamage > 0.f)
		{
			Health -= ActualDamage;
			if (Health <= 0)
			{
				bool bCanDie = true;

				/* Check the damagetype, always allow dying if the cast fails, otherwise check the property if player can die from damagetype */
				if (DamageEvent.DamageTypeClass)
				{
					UShooterDamageType* DmgType = Cast<UShooterDamageType>(DamageEvent.DamageTypeClass->GetDefaultObject());
					bCanDie = (DmgType == nullptr || (DmgType && DmgType->GetCanDieFrom()));
				}

				if (bCanDie)
				{
					Die(ActualDamage, DamageEvent, EventInstigator, DamageCauser);
				}
				else
				{
					/* Player cannot die from this damage type, set hitpoints to 1.0 */
					Health = 1.0f;
				}
			}
			else
			{
				/* Shorthand for - if x != null pick1 else pick2 */
				//APawn* Pawn = EventInstigator ? EventInstigator->GetPawn() : nullptr;
				PlayHit(false, ActualDamage, DamageEvent, EventInstigator->GetPawn(), DamageCauser);
			}
		}
		GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, FString::SanitizeFloat(Health));
		return ActualDamage;
	}
	else
	{
		ApplyPhysicsToTheRagdolledBody(DamageEvent);

	}
	return 0;
}
Пример #2
0
//=========================================================
// Special takedamage for func_breakable. Allows us to make
// exceptions that are breakable-specific
// bitsDamageType indicates the type of damage sustained ie: DMG_CRUSH
//=========================================================
int CBreakable :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType )
{
	Vector	vecTemp;

	// if Attacker == Inflictor, the attack was a melee or other instant-hit attack.
	// (that is, no actual entity projectile was involved in the attack so use the shooter's origin).
	if ( pevAttacker == pevInflictor )
	{
		vecTemp = pevInflictor->origin - ( pev->absmin + ( pev->size * 0.5 ) );

		// if a client hit the breakable with a crowbar, and breakable is crowbar-sensitive, break it now.
		if ( FBitSet ( pevAttacker->flags, FL_CLIENT ) &&
				 FBitSet ( pev->spawnflags, SF_BREAK_CROWBAR ) && (bitsDamageType & DMG_CLUB))
			flDamage = pev->health;
	}
	else
	// an actual missile was involved.
	{
		vecTemp = pevInflictor->origin - ( pev->absmin + ( pev->size * 0.5 ) );
	}

	if (!IsBreakable())
		return 0;

	// Breakables take double damage from the crowbar
	if ( bitsDamageType & DMG_CLUB )
		flDamage *= 2;

	// Boxes / glass / etc. don't take much poison damage, just the impact of the dart - consider that 10%
	if ( bitsDamageType & DMG_POISON )
		flDamage *= 0.1;

// this global is still used for glass and other non-monster killables, along with decals.
	g_vecAttackDir = vecTemp.Normalize();

// do the damage
	pev->health -= flDamage;
	if (pev->health <= 0)
	{
		Killed( pevAttacker, GIB_NORMAL );
		Die();
		return 0;
	}

	// Make a shard noise each time func breakable is hit.
	// Don't play shard noise if cbreakable actually died.

	DamageSound();

	return 1;
}
Пример #3
0
void Projectile_Mine::OnCollideWithObject(Object* object)
{

	if ((!dud) && (armTimer <= 0.0f))
	{


		// Mines only explode on contact with slugs
		if (object->GetType() == ObjectType_Slug)
			Die();

	}

}
Пример #4
0
void TMakeMissile::Move()
{
	if( Age % ShotInt == 0 ) {
		FOwner->Add(new TMissile(FOwner,FOwner->HeroPos.X,FOwner->HeroPos.Y,SetNum,MissileNum));
		Inc(MissileNum);
		FOwner->Add(new TMissile(FOwner,FOwner->HeroPos.X,FOwner->HeroPos.Y,SetNum,MissileNum));
		Inc(MissileNum);
	}

	if( Age >= (ShotInt*((MaxLock / 2) - 1)) ) {
		Die();
	}
	TOBJ::Move();
}
void ASCharacter::KilledBy(class APawn* EventInstigator)
{
	if (Role == ROLE_Authority && !bIsDying)
	{
		AController* Killer = nullptr;
		if (EventInstigator != nullptr)
		{
			Killer = EventInstigator->Controller;
			LastHitBy = nullptr;
		}

		Die(Health, FDamageEvent(UDamageType::StaticClass()), Killer, nullptr);
	}
}
Пример #6
0
int main()
{
	int parent_x, parent_y;
START:
	head = (psnakeHead)malloc(sizeof(snakeHead));
	head -> length = 0;
	head -> row = 14;
	head -> col = 14;
	head -> pbody = NULL;
	head -> headdirection = RIGHT;
	InitSnake(head);

    initscr();  
    raw();                  /* close row buffer */
    cbreak();               /* put termial to CBREAK mode */  
    noecho();  
    curs_set(FALSE);            /* set cursor invisible */  
    keypad(stdscr,TRUE);    /* recognise user's function key,F1,F2,...
							   display some message about title and wall */  
    signal(SIGALRM, StartAlarm);  
	getmaxyx(stdscr, parent_y, parent_x);
	WINDOW *welwin = newwin(29, parent_x, 0, 0);
	WINDOW *lelwin = newwin(7, parent_x, 30, 0);
	if (!welwin || !lelwin) {
		Die("Unable to allocate window memory\n");
	}
	Welcome(welwin, 29, parent_x);
	int speed = Choice(lelwin);
    Set_ticker(speed);  
	DrawWalls();
    StartAlarm();
    foodpos = DisplayFood(head);
    while(!isfailed && chinput !='q') {
        chinput = getch();
		ControlSnake(chinput, head);
    }
    if(isfailed) {
		ClearScr(LEFT_EDGE+1, RIGHT_EDGE-1, TOP_ROW+1, BUT_ROW-1);		//mark
		free(head -> pbody);
		free(head);
		head = NULL;
    }
    if(isrestart) {
        isfailed = 0;
        isrestart = 0;      // clear the flag
        goto START;    		// go to the START statement
    }
	endwin();
	return 0;
}
Пример #7
0
/*
 * IDEInit - set up for communication with the IDE
 */
void IDEInit( void )
{
    if( !VxDPresent() ) {
        Die( "WDEBUG.386 not present!" );
    }
    for( ;; ) {
        if( VxDLink( EDITOR_LINK_NAME ) == NULL ) {
            VxDConnect();
            break;
        }
        TimeSlice();
    }

} /* IDEInit */
Пример #8
0
Файл: ex17.c Проект: Dekuben/cEx
struct Connection* DatabaseOpen(const char* filename,
char mode)
{
	struct Connection *conn = malloc(sizeof(struct Connection));
	if (!conn) Die("Memory Error!", conn);

	conn->db = malloc(sizeof(struct Database));
	if(!conn->db) Die("Memory Error!", conn);

	if(mode == 'c')
	{
		conn->file = fopen(filename, "w");
	}
	else
	{
		conn->file = fopen(filename, "r+");
		if(conn->file)	DatabaseLoad(conn);
	}

	if(!conn->file) Die("Failed to open the file!", conn);

	return conn;
}//end of function databaseopen
Пример #9
0
void ANimModCharacter::KilledBy(APawn* EventInstigator)
{
	if (Role == ROLE_Authority && !bIsDying)
	{
		AController* Killer = NULL;
		if (EventInstigator != NULL)
		{
			Killer = EventInstigator->Controller;
			LastHitBy = NULL;
		}

		Die(Health, FDamageEvent(UDamageType::StaticClass()), Killer, NULL);
	}
}
Пример #10
0
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) {
	HOOKPROC hkprcKeyboard;
	static HINSTANCE hinstDll;
	static HHOOK hhookKeyboard;

	hinstDll = LoadLibrary("MediaKeyHook.dll");
	if (!hinstDll) Die("LoadLibrary");

	hkprcKeyboard = (HOOKPROC)GetProcAddress(hinstDll, "KeyboardProc");
	if (!hkprcKeyboard) Die("GetProcAddress");

	hhookKeyboard = SetWindowsHookEx(WH_KEYBOARD, hkprcKeyboard, hinstDll, 0);
	if (!hhookKeyboard) Die("SetWindowsHookEx");
	
	MSG msg;
	while (GetMessage(&msg, NULL, 0, 0)) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	UnhookWindowsHookEx(hhookKeyboard);
	return EXIT_SUCCESS;
}
Пример #11
0
int
Atoi(char *p)
{
	int i;
	char *q;
	errno = 0;
	i = (int)strtol(p, &q, 10);
	if (errno != 0 || q == p || i < 0 || *q != '\0')
		Die(gettext("illegal argument -- %s\n"), p);
		/*NOTREACHED*/
	else
		return (i);
	return (0);	/* keep gcc happy */
}
Пример #12
0
//-----------------------------------------------------------------------------------------------------------------------------------
void UIObject::Update(float elapsedSeconds)
{
  assert(m_type != UIType::kUnSet);

	BaseObject::Update(elapsedSeconds);

	m_currentLifeTime += elapsedSeconds;
	if (m_currentLifeTime > m_lifeTime)
	{
		// This UIObject has been alive for longer than its lifetime so it dies
		// and will be cleared up by whatever manager is in charge of it
		Die();
	}
}
Пример #13
0
double GetTemp(long mat, long id)
{
  double T, f;

  /***************************************************************************/

  /***** Temperature from interface ******************************************/

  /* Reset values */

  f = 1.0;
  T = -1.0;

  /* Get density factor from multi-physics interface */

  IFCPoint(mat, &f, &T, id);

  /* Check value */

  if (T > 0.0)
    return T;
  
  /***************************************************************************/

  /***** Temperature from material *******************************************/
  
  /* Get Temperature */

  if ((mat > VALID_PTR) && (RDB[mat + MATERIAL_TMS_MODE] != TMS_MODE_NONE))
    {
      /* Use minimum temperature */
      
      T = RDB[mat + MATERIAL_TMS_TMIN];

      /* Check with maximum */

      if (T != RDB[mat + MATERIAL_TMS_TMAX])
	Die(FUNCTION_NAME, "Error in temperature (%s) %E %E", 
	    GetText(mat + MATERIAL_PTR_NAME),
	    RDB[mat + MATERIAL_TMS_TMAX], T);
    }
  else
    T = 0.0;

  /* Return value */

  return T;

  /***************************************************************************/
}
Пример #14
0
// Break when triggered
void CBreakable::BreakUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
	// for a respawnable entity, ON means someone wants it to respawn- but this one's solid already.
	if (m_iRespawnTime && useType == USE_ON)
		return;
	if ( IsBreakable() )
	{
		pev->angles.y = m_angle;
		UTIL_MakeVectors(pev->angles);
		g_vecAttackDir = gpGlobals->v_forward;

		Die();
	}
}
Пример #15
0
/* Function: GSIWriteHeader()
 * Date:     SRE, Wed Aug  5 10:36:02 1998 [St. Louis]
 *
 * Purpose:  Write the first record to an open GSI file:
 *           "GSI" <nfiles> <nkeys>
 *
 * Args:     fp      - open file to write to.
 *           nfiles  - number of files indexed
 *           nkeys   - number of keys indexed          
 *
 * Returns:  void
 */
void
GSIWriteHeader(FILE *fp, int nfiles, long nkeys)
{
  char       key[GSI_KEYSIZE];
  sqd_uint16 f1;
  sqd_uint32 f2;

  /* beware potential range errors!
   */
  if (nfiles > SQD_UINT16_MAX) Die("GSI: nfiles out of range");
  if (nkeys > SQD_UINT32_MAX)  Die("GSI: nkeys out of range");

  f1 = (sqd_uint16) nfiles;
  f2 = (sqd_uint32) nkeys;
  f1 = sre_hton16(f1);
  f2 = sre_hton32(f2);
  strcpy(key, "GSI");

  if (fwrite(key,   1, GSI_KEYSIZE, fp) < GSI_KEYSIZE) PANIC;
  if (fwrite(&f1,   2,  1, fp) < 1)  PANIC;
  if (fwrite(&f2,   4,  1, fp) < 1)  PANIC;
  return;
}
Пример #16
0
struct Connection*
OpenDatabase( const char* filename, char mode ) {
    struct Connection *conn = malloc( sizeof( struct Connection ) );
    if ( !conn ) {
        Die( "Memory error" );
    }
    conn->db = malloc( sizeof( struct Database ) );
    if ( !conn->db ) {
        Die( "Memory error." );
    }
    if ( mode == 'c' ) {
        conn->file = fopen( filename, "w" );
    } else {
        conn->file = fopen( filename, "r+" );
        if ( conn->file ) {
            LoadDatabase( conn );
        }
    }
    if ( !conn->file ) {
        Die( "Failed to open the file." );
    }
    return conn;
}
Пример #17
0
int start_listen() {

    printf("start listen.\n");
    if ((sockserver = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
        Die("Failed to create socket");
    }
    printf("create socket success. (socket = %d)\n", sockserver);

    memset(&echoserver, 0, sizeof(echoserver));
    echoserver.sin_family = AF_INET;
    echoserver.sin_addr.s_addr = htonl(INADDR_ANY);
    echoserver.sin_port = htons(1102);
    if (bind(sockserver, (struct sockaddr *) &echoserver,
             sizeof(echoserver)) < 0) {
        Die("Failed to bind the server socket");
    }
    printf("bind socket success.\n");

    if (listen(sockserver, MAXPENDING) < 0 ) {
        Die("Failed to listen on server socket");
    }
    printf("listen socket success.\n");
}
Пример #18
0
static bool_t fault_handler (int code, Word_t pc)
{
  lib7_state_t	    *lib7_state = SELF_VPROC->vp_state;
  extern Word_t request_fault[];

  if (*SELF_VPROC->vp_inLib7Flag) 
    Die ("win32:fault_handler: bogus fault not in Lib7: %#x\n", code);

  /* Map the signal to the appropriate Lib7 exception. */
  switch (code) {
    case EXCEPTION_INT_DIVIDE_BY_ZERO: 
      lib7_state->lib7_fault_exception = DivId;
      lib7_state->lib7_faulting_program_counter = pc;
      break;
    case EXCEPTION_INT_OVERFLOW:
      lib7_state->lib7_fault_exception = OverflowId;
      lib7_state->lib7_faulting_program_counter = pc;
      break;
    default:
      Die ("win32:fault_handler: unexpected fault @%#x, code = %#x", pc, code);
  }
  return TRUE;
}
Пример #19
0
/* Function: DetermineAlphabet()
 * 
 * Purpose:  From a set of sequences (raw or aligned), make a good
 *           guess whether they're Nucleic, Amino, or something
 *           else, and set alphabet accordingly. 
 *           
 *           If Alphabet_type is already set, that means our
 *           autodetection was overridden from the command line, 
 *           and we just set the other globals accordingly.  
 */
void
DetermineAlphabet(char **rseqs, int  nseq)
{
  int idx;
  int other, nucleic, amino;
  int type;
  
  /* Autodetection of alphabet type.
   */
  type = hmmNOTSETYET;
  other = nucleic = amino = 0;
  for (idx = 0; idx < nseq; idx++) {
    switch (Seqtype(rseqs[idx])) {
    case kRNA:      nucleic++;   break;
    case kDNA:      nucleic++;   break;
    case kAmino:    amino++;     break;
    case kOtherSeq: other++;     break;
    default: Die("No such alphabet type");
    }
  }

  if      (nucleic == nseq) type = hmmNUCLEIC;
  else if (amino   == nseq) type = hmmAMINO;
  else if (nucleic > amino && nucleic > other) {
    Warn("Looks like nucleic acid sequence, hope that's right");
    type = hmmNUCLEIC;
  }
  else if (amino > nucleic && amino > other) {
    Warn("Looks like amino acid sequence, hope that's right");
    type = hmmAMINO;
  }
  else Die("Sorry, I can't tell if that's protein or DNA"); 

  /* Now set up the alphabet.
   */
  SetAlphabet(type);
}
Пример #20
0
int main(int argc, char **argv)
{
	int serversock, clientsock;
	struct sockaddr_in echoserver, echoclient;
	if (argc != 2) {
		fprintf(stderr, "USAGE: echoserver <port>\n");
		exit(1);
	}
	/* Create the TCP socket */
	if ((serversock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
		Die("Failed to create socket");
	}
	/* Construct the server sockaddr_in structure */
	memset(&echoserver, 0, sizeof(echoserver));
	echoserver.sin_family = AF_INET;
	echoserver.sin_addr.s_addr = htonl(INADDR_ANY);
	echoserver.sin_port = htons(atoi(argv[1]));
	/* Bind the server socket */
	if (bind(serversock, (struct sockaddr *) &echoserver, sizeof(echoserver)) < 0) {
		Die("Failed to bind the server socket");
	}
	/* Listen on the server socket */
	if (listen(serversock, MAXPENDING) < 0) {
		Die("Failed to listen on server socket");
	}
	/* Run until cancelled */
	while (1) {
		unsigned int clientlen = sizeof(echoclient);
		/* Wait for client connection */
		if ((clientsock = accept(serversock, (struct sockaddr *) &echoclient, &clientlen)) < 0) {
			Die("Failed to accept client connection");
		}
		fprintf(stdout, "Client connected: %s\n", inet_ntoa(echoclient.sin_addr));
		HandleClient(clientsock);
	}
	exit(0);
}
Пример #21
0
int elfIPCServer::StartIPCServer() {

	elfspeed = new ElfSpeed();
	int serversock, clientsock;
	struct sockaddr_in echoserver, echoclient;

	/* Create the TCP socket */
	if ((serversock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
		Die("Failed to create socket");
	}
	/* Construct the server sockaddr_in structure */
	memset(&echoserver, 0, sizeof(echoserver)); /* Clear struct */
	echoserver.sin_family = AF_INET; /* Internet/IP */
	echoserver.sin_addr.s_addr = htonl(INADDR_ANY); /* Incoming addr */
	echoserver.sin_port = htons(getpid()); /* server port */

	/* Bind the server socket */
	if (bind(serversock, (struct sockaddr *) &echoserver, sizeof(echoserver)) < 0) {
		Die("Failed to bind the server socket");
	}
	/* Listen on the server socket */
	if (listen(serversock, MAXPENDING) < 0) {
		Die("Failed to listen on server socket");
	}
	/* Run until cancelled */
	LOGDD("server with fd: %d closed! \n", serversock);
	while (1) {
		unsigned int clientlen = sizeof(echoclient);
		/* Wait for client connection */
		if ((clientsock = accept(serversock, (struct sockaddr *) &echoclient,(socklen_t *)&clientlen)) < 0) {
			Die("Failed to accept client connection");
		}
		fprintf(stdout, "Client connected: %s\n",
				inet_ntoa(echoclient.sin_addr));
		HandleClient(clientsock);
	}
}
Пример #22
0
void EnemyPrisonerRock::processUpdate()
{
//	BelowFeetLadderCheck();

	if(ipFlags.S_ON_GROUND)
	{
		velModifier = 0;
		velYModifier = 0;
	}
	else
	{
//		velYModifier += (gravityConstant * time);
	}

	if((player_spr->GetFrameSet() == ENEMY_PRISONER_ANIM_DEATH)&& !player_spr->IsAnimating())
		Die();

	if(ipFlags.S_ATTACK)
	{
		if((player_spr->GetFrameSet() == ENEMY_PRISONER_ANIM_THROW) && !player_spr->IsAnimating())
			ipFlags.S_ATTACK = false;
	}

	//Transition Movement State
//	TransitionMovement(ipFlags.CurMState);

	// Apply Velocity Modifier
	if(!ipFlags.S_DAMAGED)
	{
		if(!ipFlags.S_ATTACK)
			switch(ipFlags.CurMState)
			{
				case move_stop:
					stop();
					break;

				case move_left:
					processLeft();
					break;

				case move_right:
					processRight();
					break;

				default:
					break;
			}
	}
}
Пример #23
0
void CFuncLight :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
	m_hActivator = pActivator;
	
	if( IsLockedByMaster( ))
		return;

	if( m_iState == STATE_DEAD )
		return; // lamp is broken

	if( useType == USE_TOGGLE )
	{
		if( m_iState == STATE_OFF )
			useType = USE_ON;
		else useType = USE_OFF;
	}

	if( useType == USE_ON )
	{
		if( m_flDelay )
		{
			// make flickering delay
			m_iState = STATE_TURN_ON;
			LIGHT_STYLE( m_iStyle, "mmamammmmammamamaaamammma" );
			pev->frame = 0; // light texture is on
			SetThink( Flicker );
			SetNextThink( m_flDelay );
		}
		else
		{         // instant enable
			m_iState = STATE_ON;
			LIGHT_STYLE( m_iStyle, "k" );
			pev->frame = 0; // light texture is on
			UTIL_FireTargets( pev->target, this, this, USE_ON );
		}
	}
	else if( useType == USE_OFF )
	{
		LIGHT_STYLE( m_iStyle, "a" );
		UTIL_FireTargets( pev->target, this, this, USE_OFF );
		pev->frame = 1;// light texture is off
		m_iState = STATE_OFF;
	}
	else if( useType == USE_SET )
	{
		// a script die (dramatic effect)
		Die();
	}
}
Пример #24
0
void Move( char key )
{
    int x, y;
    int pos = 0;
    int i;
    int d[4][2] = {
        {0,-1},
        {-1,0},
        {0,1},
        {1,0},
    };
    switch ( key )
    {
        case 'w':
            pos = 0;
            break;
        case 'a':
            pos = 1;
            break;
        case 's':
            pos = 2;
            break;
        case 'd':
            pos = 3;
            break;
        default:
            break;
    }
    x = snake[len-1][0];
    y = snake[len-1][1];
    for ( i = len-1; i > 0; --i )
    {
        snake[i][0] = snake[i-1][0];
        snake[i][1] = snake[i-1][1];
    }
    snake[0][0] += d[pos][0];
    snake[0][1] += d[pos][1];
    if ( Eat() )
    {
        snake[len][0] = x;
        snake[len][1] = y;
        ++len;
        CreatFood();
    }
    else if ( Die() )
    {
        gameOver = 1;
    }
}
Пример #25
0
int main(int argc, char **argv) {

  //Lets just set up our signal handler over here
  signal(SIGINT, ctrlCHandler);

  if(argc!=3) {
    printf("Usage: %s <IP> <port-num>\n", argv[0]);
    exit(1);
  }

  int port; 
  struct sockaddr_in serv_addr;
  char recvBuf[RECVBUFSIZE];

  //Now we have the port number
  port = atoi(argv[2]);
  sockFd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

  memset(&serv_addr, 0, sizeof(struct sockaddr_in));
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_port = htons(port);
  serv_addr.sin_addr.s_addr = inet_addr(argv[1]);

 //Connection of the client to the socket 
  if (connect(sockFd, (struct sockaddr *) &serv_addr, sizeof(serv_addr))<0) 
  	Die("connect() failed");

  pthread_create(&network_thread, NULL, sendFunc, NULL);


  memset(recvBuf, 0, RECVBUFSIZE);
  while(1) {
  	read(sockFd, &recvBuf, RECVBUFSIZE);
  	printf("%s", recvBuf);
  	fflush(stdout);
 	
 	//If we see this. lets just log out.
 	if(!strncmp(recvBuf, "Logging off", 11)) {
      break;
    }
    memset(recvBuf, 0, RECVBUFSIZE);
  }

  printf("\nExitting the client.\n");
  close(sockFd);
  //Cancel/join the recv thread.
  pthread_cancel(network_thread);
  return 0;
}
Пример #26
0
void TBlur::Fadeout()
{
	if( Alpha > 0 ) {
		Alpha -= 8;
		if( Alpha < 0 ) Alpha = 0;
		Sprite[0]->GetSpr()->SetColor(Alpha, ctAlpha);
	}

	//完全に消えたらポーズ解除
	if( Alpha == 0 ) {
		FOwner->AfterLoopEvent = MMove;
		Die();
	}

}
Пример #27
0
clientHandle_t *
getClientHandle()
{
    int i;
    for (i = 0; i < MAX_THREADS; i++) {
	if (clientHandles[i].ch_state == CH_FREE) {
	    clientHandles[i].ch_state = CH_INUSE;
	    nThreads++;
	    return &clientHandles[i];
	}
    }
    Die(1, "No free client handles!\n");

    return (clientHandle_t *) NULL;	/* quiet compiler. */
}
Пример #28
0
//-----------------------------------------------------------------------------------------------------------------------------------
void GameObject::Update(float elapsedSeconds)
{
	BaseObject::Update(elapsedSeconds);

	if (IsActive())
	{
		if (m_health <= 0)
		{
			Die();
		}

		assert(m_rigidBody);
		m_rigidBody->Update(elapsedSeconds);
	}
}
/* Function: PAMPrior()
 * 
 * Purpose:  Produces an ad hoc "Dirichlet mixture" prior for
 *           match emissions, using a PAM matrix. 
 *           
 *           Side effect notice: PAMPrior() replaces the match
 *           emission section of an existing Dirichlet prior,
 *           which is /expected/ to be a simple one-component 
 *           kind of prior. The insert emissions /must/ be a
 *           one-component prior (because of details in how 
 *           PriorifyEmissionVector() is done). However, 
 *           the transitions /could/ be a mixture Dirichlet prior 
 *           without causing problems. In other words, the
 *           -p and -P options of hmmb can coexist, but there
 *           may be conflicts. PAMPrior() checks for these,
 *           so there's no serious problem, except that the
 *           error message from PAMPrior() might be confusing to
 *           a user. 
 */
void
PAMPrior(char *pamfile, struct p7prior_s *pri, float wt)
{
  FILE  *fp;
  char  *blastpamfile;            /* BLAST looks in aa/ subdirectory of BLASTMAT */
  int  **pam;
  float  scale;
  int    xi, xj;
  int    idx1, idx2;

  if (Alphabet_type != hmmAMINO)
    Die("PAM prior is only valid for protein sequences");
  if (pri->strategy != PRI_DCHLET)
    Die("PAM prior may only be applied over an existing Dirichlet prior");
  if (pri->inum != 1)
    Die("PAM prior requires that the insert emissions be a single Dirichlet");
  if (MAXDCHLET < 20)
    Die("Whoa, code is misconfigured; MAXDCHLET must be >= 20 for PAM prior");

  blastpamfile = FileConcat("aa", pamfile);

  if ((fp = fopen(pamfile, "r")) == NULL &&
      (fp = EnvFileOpen(pamfile, "BLASTMAT", NULL)) == NULL &&
      (fp = EnvFileOpen(blastpamfile, "BLASTMAT", NULL)) == NULL)
    Die("Failed to open PAM scoring matrix file %s", pamfile);
  if (! ParsePAMFile(fp, &pam, &scale))
    Die("Failed to parse PAM scoring matrix file %s", pamfile);
  fclose(fp);
  free(blastpamfile);

  pri->strategy = PRI_PAM;
  pri->mnum     = 20;
  
  /* Convert PAM entries back to conditional prob's P(xj | xi),
   * which we'll use as "pseudocounts" weighted by wt.
   */
  for (xi = 0; xi < Alphabet_size; xi++)
    for (xj = 0; xj < Alphabet_size; xj++)
      {
        idx1 = Alphabet[xi] - 'A';
        idx2 = Alphabet[xj] - 'A';
        pri->m[xi][xj] = aafq[xj] * exp((float) pam[idx1][idx2] * scale);
      }
  
  /* Normalize so that rows add up to wt.
   * i.e. Sum(xj) mat[xi][xj] = wt for every row xi
   */
  for (xi = 0; xi < Alphabet_size; xi++)
    {
      pri->mq[xi] = 1. / Alphabet_size;
      FNorm(pri->m[xi], Alphabet_size);
      FScale(pri->m[xi], Alphabet_size, wt);
    }

  Free2DArray((void **)pam,27);
}
Пример #30
0
/* Function: GSI64WriteHeader()
 * Date:     SRE, Wed Aug  5 10:36:02 1998 [St. Louis]
 *
 * Purpose:  Write the first record to an open GSI64 file:
 *           "GSI64" <nfiles> <nkeys>
 *
 * Args:     fp      - open file to write to.
 *           nfiles  - number of files indexed
 *           nkeys   - number of keys indexed          
 *
 * Returns:  void
 */
void
GSI64WriteHeader(FILE *fp, int nfiles, long long nkeys)
{
  char       key[GSI64_KEYSIZE];
  sqd_uint16 f1;
  sqd_uint64 f2;

  /* beware potential range errors!
   */
  if (nfiles > SQD_UINT16_MAX) Die("GSI64: nfiles out of range");
  if (nkeys > SQD_UINT64_MAX)  Die("GSI64: nkeys out of range");

  f1 = (sqd_uint16) nfiles;
  f2 = (sqd_uint64) nkeys;
#if 0 /* HACK no byteswap */
  f1 = sre_htons(f1);
  f2 = sre_htonl(f2);
#endif
  strcpy(key, "GSI64");

  if (fwrite(key,   1, GSI64_KEYSIZE, fp) < GSI64_KEYSIZE) PANIC;
  if (fwrite(&f1,   2,  1, fp) < 1)  PANIC;
  if (fwrite(&f2,   8,  1, fp) < 1)  PANIC;
}