Esempio n. 1
0
static void _stdcall SaveGame2() {
	char buf[MAX_PATH];
	GetSavePath(buf, "gv");

	dlog_f("Saving game: %s\r\n", DL_MAIN, buf);

	DWORD size, unused = 0;
	HANDLE h = CreateFileA(buf, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
	if (h != INVALID_HANDLE_VALUE) {
		SaveGlobals(h);
		WriteFile(h, &unused, 4, &size, 0);
		unused++;
		WriteFile(h, &unused, 4, &size, 0);
		PerksSave(h);
		SaveArrays(h);
		CloseHandle(h);
	} else {
		dlogr("ERROR creating sfallgv!", DL_MAIN);
		DisplayConsoleMessage(SaveSfallDataFailMsg);
		PlaySfx("IISXXXX1");
	}
	GetSavePath(buf, "fs");
	h = CreateFileA(buf, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
	if (h != INVALID_HANDLE_VALUE) {
		FileSystemSave(h);
	}
	CloseHandle(h);
}
Esempio n. 2
0
void FlashMenuText( char *text, float activetime, u_int16_t sfx )
{
  if( text )
  {
    strcpy( FlashText, text );
    FlashTextActive = activetime;
    if( sfx != 0xFF )
    {
      PlaySfx( sfx, 1.0F );
    }
  }
}
Esempio n. 3
0
/*===================================================================
	Procedure	:	Check if im in an Active Teleport....
	Input		:	void
	Output		:	true/false
===================================================================*/
bool TeleportsAreaCheck( VECTOR * NewPos , VECTOR * OldPos ,u_int16_t Group, OBJECT *obj )
{
	TELEPORT * TPpnt;
	TELEPORT * newTPpnt;

	TPpnt = TeleportsGroupLink[Group];
	
	while( TPpnt )
	{
		if( TPpnt->Status == TELEPORTACTIVE )
		{
			TeleportsZoneCheck( OldPos , NewPos , TPpnt );
			if( Entry )
			{

				PlaySfx( SFX_Teleport, 1.0F );

//				StartShipScreenShake( 10.0F );
				
				
				// Were in the Zone....
				newTPpnt = Teleports;
				newTPpnt += TPpnt->Links[Random_Range(TPpnt->num_links)];
				obj->Group = newTPpnt->Group;
				obj->Pos = newTPpnt->Pos;
#if TELEPORTS_VERSION_NUMBER >= 2
				QuatFromDirAndUp( &newTPpnt->Dir, &newTPpnt->Up, &obj->Quat);
				QuatToMatrix( &obj->Quat, &obj->Mat );
#endif
				return true;
			}
		}
		TPpnt = TPpnt->NextInGroup;
	}
	return false;
}
Esempio n. 4
0
/*-------------------------------------------------------------------
    Procedure   :       Update a trigger var..and then checks to see if 
                        all the triggers associated with any condition that this
                        trigger is used in is complete if it is Set the events off...
    Input       :       TRIGGERVAR * TrigVar
                        int Op
                        int Val
    Output      :       nothing
-------------------------------------------------------------------*/
void ModifyTriggerVar( TRIGGERVAR * TrigVar , int Op , int Val )
{
    BOOL    Doit;
    int     i;
    TRIGGER * Trig;
    int     old_state;
    uint32  flags;
    int     count;

    old_state = TrigVar->State;
    switch( Op )
    {
    case TRIGGEROP_Set:
        TrigVar->State = Val;
        break;
    case TRIGGEROP_Reset:
        TrigVar->State = TrigVar->InitState;
        break;
    case TRIGGEROP_Inc:
        TrigVar->State += Val;
        break;
    case TRIGGEROP_Dec:
        TrigVar->State -= Val;
        break;
    case TRIGGEROP_Or:
        TrigVar->State |= Val;
        break;
    case TRIGGEROP_And:
        TrigVar->State &= Val;
        break;
    case TRIGGEROP_Xor:
        TrigVar->State ^= Val;
        break;
    case TRIGGEROP_Multiply:
        TrigVar->State *= Val;
        break;
    case TRIGGEROP_Divide:
        TrigVar->State /= Val;
        break;
    case TRIGGEROP_Random:
        TrigVar->State = (int) Random_Range( (uint16) Val );
        break;
    case TRIGGEROP_Setflag:
        TrigVar->State |= FLAG_MASK( Val );
        break;
    case TRIGGEROP_Clearflag:
        TrigVar->State &= ~FLAG_MASK( Val );
        break;
    }

    if( TrigVar->State == old_state ) return;

#ifdef DEBUG_TRIGGERS
    DebugPrintf( "modifytrigvar: var=%s(=%d) op=%d val=%d -> %d\n",
        TrigVar->Name, old_state, Op, Val, TrigVar->State );
#endif

    for( i = 0 ; i < TrigVar->NumOfTriggers ; i++ )
    {
        Trig = TrigVar->Triggers[i];
        Doit = FALSE;

        switch( Trig->Type )
        {
        case TRIGGERTYPE_Equal:
            if( TrigVar->State == Trig->ActiveState )
                Doit = TRUE;
            break;
        case TRIGGERTYPE_NotEqual:
            if( TrigVar->State != Trig->ActiveState )
                Doit = TRUE;
            break;
        case TRIGGERTYPE_Less:
            if( TrigVar->State < Trig->ActiveState )
                Doit = TRUE;
            break;
        case TRIGGERTYPE_Greater:
            if( TrigVar->State > Trig->ActiveState )
                Doit = TRUE;
            break;
        case TRIGGERTYPE_LessEqual:
            if( TrigVar->State <= Trig->ActiveState )
                Doit = TRUE;
            break;
        case TRIGGERTYPE_GreaterEqual:
            if( TrigVar->State >= Trig->ActiveState )
                Doit = TRUE;
            break;
        case TRIGGERTYPE_FlagCount:
            count = 0;
            for ( flags = TrigVar->State; flags; flags >>= 1 )
            {
                if ( flags & 1 )
                    count++;
            }
            if ( count == Trig->ActiveState )
                Doit = TRUE;
            break;
        case TRIGGERTYPE_FlagTest:
            if ( TrigVar->State & FLAG_MASK( Trig->ActiveState ) )
                Doit = TRUE;
            break;
        }

        if ( Doit )
        {
#ifdef DEBUG_TRIGGERS
            DebugPrintf( "modifytrigvar: trigger %d (type=%d, activestate=%d) activated (was %d)\n",
                Trig - Triggers, (int) Trig->Type, Trig->ActiveState, Trig->Active );
#endif
            if( !(_strnicmp( "secret" , &TrigVar->Name[0], 6 ) ) )
            {
                PlaySfx( SFX_Secret, 1.0F );
            }
        }

        Trig->Active = Doit;

        if( Trig->Active )
        {
            TestAllConditions( Trig );
        }
    }
}
Esempio n. 5
0
void control_ship( USERCONFIG *conf, SHIPCONTROL *ctrl )
{
  int   j, joystick;
  float mouse_dx;
  float mouse_dy;
  float pitch_sign;
  float turn_sign;
  float MaxMove, MaxTurbo, MaxTurn, MaxRoll, MaxBank;

  ctrl->pitch   = 0.0F;
  ctrl->yaw   = 0.0F;
  ctrl->roll    = 0.0F;
  ctrl->bank    = 0.0F;
  ctrl->right   = 0.0F;
  ctrl->up    = 0.0F;
  ctrl->forward = 0.0F;
  ctrl->cruise_control = 0;
  ctrl->turbo   = 0;
  ctrl->fire_primary = 0;
  ctrl->fire_secondary = 0;
  ctrl->fire_mine = 0;
  ctrl->select_primary = 0;
  ctrl->select_secondary = 0;
  ctrl->select_next_primary = 0;
  ctrl->select_prev_primary = 0;
  ctrl->select_next_secondary = 0;
  ctrl->select_prev_secondary = 0;
  ctrl->drop_primary = 0;
  ctrl->drop_secondary = 0;
  ctrl->drop_shield = 0;
  ctrl->drop_ammo = 0;

  if ( !conf )
    return; // bail if no config supplied

  if ( CurrentMenu )
    return; // disable bike controls if using menus

  mouse_dx = mouse_states[ new_input ].xrel * conf->mouse_x_sensitivity * 4.0F;
  mouse_dy = mouse_states[ new_input ].yrel * conf->mouse_y_sensitivity * 4.0F;

#if 0
  if ( mouse_dx < -MAX_MOUSE_DELTA_X )
    mouse_dx = -MAX_MOUSE_DELTA_X;
  else if ( mouse_dx > MAX_MOUSE_DELTA_X )
    mouse_dx = MAX_MOUSE_DELTA_X;
  if ( mouse_dy < -MAX_MOUSE_DELTA_Y )
    mouse_dy = -MAX_MOUSE_DELTA_Y;
  else if ( mouse_dy > MAX_MOUSE_DELTA_Y )
    mouse_dy = MAX_MOUSE_DELTA_Y;
#endif

// TODO
// win32 appear to return greator values even in some resolution
// we should also configure a fine control setting for the mouse to turn on/off the fabs() trick
#ifdef WIN32
	mouse_dx = mouse_dx * (float) fabs( mouse_dx ) * MouseXFactor; // factor = 0.000625
	mouse_dy = mouse_dy * (float) fabs( mouse_dy ) * MouseYFactor; // factor = -0.000625
#else
	mouse_dx = mouse_dx * (float) fabs( mouse_dx ) * 0.01f; // tweaked for linux
	mouse_dy = mouse_dy * (float) fabs( mouse_dy ) * -0.01f;
#endif

#if 0
  if ( mouse_dx < -framelag )
    mouse_dx = -framelag;
  if ( mouse_dx > framelag )
    mouse_dx = framelag;
  if ( mouse_dy < -framelag )
    mouse_dy = -framelag;
  if ( mouse_dy > framelag )
    mouse_dy = framelag;
#endif

  pitch_sign = ( conf->invert_pitch ) ? -1.0F : 1.0F;
  turn_sign = ( conf->invert_turn ) ? -1.0F : 1.0F;

  if ( key_held( &conf->full_rear_view ) )
    FullRearView = true;
  else
    FullRearView = false;

  if( key_held( &conf->show_messages))
	  ShowMessages = true;
  else
	  ShowMessages = false;

  if( key_held( &conf->show_stats))
	  ShowStatistics = true;
  else
	  ShowStatistics = false;

  if( key_held( &conf->show_networkinfo))
	  ShowNetworkInfo = true;
  else
	  ShowNetworkInfo = false;

  if ( key_pressed( &conf->headlights ) )
		Ships[WhoIAm].headlights = !Ships[WhoIAm].headlights;

  ctrl->slide_mode = key_held( &conf->move );
  ctrl->roll_mode = key_held( &conf->roll );
  if ( ctrl->slide_mode )
  {
    if ( key_held( &conf->left ) )
    {
      ctrl->right -= MoveAccell * MaxMoveSpeed * framelag;
    }
    if ( key_held( &conf->right ) )
    {
      ctrl->right += MoveAccell * MaxMoveSpeed * framelag;
    }
    if ( mouse_dx != 0.0F )
    {
      ctrl->right += MoveAccell * MaxMoveSpeed * mouse_dx;
    }

    if ( key_held( &conf->up ) )
    {
      ctrl->up += MoveAccell * MaxMoveSpeed * framelag;
    }
    if ( key_held( &conf->down ) )
    {
      ctrl->up -= MoveAccell * MaxMoveSpeed * framelag;
    }
    if ( mouse_dy != 0.0F )
    {
      ctrl->up += MoveAccell * MaxMoveSpeed * mouse_dy;
    }
  }
  else
  {
    if ( ctrl->roll_mode )
    {
      if ( key_held( &conf->left ) )
      {
        ctrl->roll += RollAccell * MaxRollSpeed * framelag;
      }
      if ( key_held( &conf->right ) )
      {
        ctrl->roll -= RollAccell * MaxRollSpeed * framelag;
      }
      if ( mouse_dx != 0.0F )
      {
        ctrl->roll -= RollAccell * MaxRollSpeed* mouse_dx;
      }
    }
    else
    {
      if ( key_held( &conf->left ) )
      {
        ctrl->yaw  -= TurnAccell * MaxTurnSpeed * framelag;
        ctrl->bank += BankAccell * MaxBankAngle * framelag;
      }
      if ( key_held( &conf->right ) )
      {
        ctrl->yaw  += TurnAccell * MaxTurnSpeed * framelag;
        ctrl->bank -= BankAccell * MaxBankAngle * framelag;
      }
      if ( mouse_dx != 0.0F )
      {
        ctrl->yaw  += TurnAccell * MaxTurnSpeed * mouse_dx * turn_sign;
        ctrl->bank -= BankAccell * MaxBankAngle * mouse_dx * turn_sign;
      }
    }
    
    if ( key_held( &conf->down ) )
    {
      ctrl->pitch -= TurnAccell * MaxTurnSpeed * framelag;
    }
    if ( key_held( &conf->up ) )
    {
      ctrl->pitch += TurnAccell * MaxTurnSpeed * framelag;
    }
    if ( mouse_dy != 0.0F )
    {
      ctrl->pitch += TurnAccell * MaxTurnSpeed * pitch_sign * mouse_dy ;
    }
  }

  if ( key_held( &conf->move_left ) )
  {
    ctrl->right -= MoveAccell * MaxMoveSpeed * framelag;
  }
  if ( key_held( &conf->move_right ) )
  {
    ctrl->right += MoveAccell * MaxMoveSpeed * framelag;
  }
  
  if ( key_held( &conf->move_down ) )
  {
    ctrl->up -= MoveAccell * MaxMoveSpeed * framelag;
  }
  if ( key_held( &conf->move_up ) )
  {
    ctrl->up += MoveAccell * MaxMoveSpeed * framelag;
  }
  
  if ( key_held( &conf->roll_left ) )
  {
    ctrl->roll += RollAccell * MaxRollSpeed * framelag;
  }
  if ( key_held( &conf->roll_right ) )
  {
    ctrl->roll -= RollAccell * MaxRollSpeed * framelag;
  }

  if( NitroFuel && ( key_pressed ( &conf->turbo ) ) )
  {
    PlaySfx( SFX_NitroStart, 0.66F );
  }

  ctrl->turbo = key_held( &conf->turbo );
  if ( ctrl->turbo )
  {
    if ( NitroFuel > 0.0F )
    {
      ctrl->forward += TurboAccell * MaxTurboSpeed * framelag;
    }
    else
    {
      ctrl->forward += MoveAccell * MaxMoveSpeed * framelag;
    }
  }
  else if ( key_held( &conf->move_forward ) )
  {
    ctrl->forward += MoveAccell * MaxMoveSpeed * framelag;
  }
  if ( key_held( &conf->move_backward ) )
  {
    ctrl->forward -= MoveAccell * MaxMoveSpeed * framelag;
  }

  if ( key_pressed( &conf->cruise_faster ) )
    ctrl->cruise_control++;
  if ( key_pressed( &conf->cruise_slower ) )
    ctrl->cruise_control--;

  ctrl->fire_primary      = key_held( &conf->fire_primary );
  ctrl->fire_secondary    = key_held( &conf->fire_secondary );
  ctrl->fire_mine       = key_pressed( &conf->fire_mine );

  ctrl->select_next_primary = key_pressed( &conf->select_next_primary );
  ctrl->select_prev_primary = key_pressed( &conf->select_prev_primary );
  
  ctrl->select_next_secondary = key_pressed( &conf->select_next_secondary );
  ctrl->select_prev_secondary = key_pressed( &conf->select_prev_secondary );
  
  ctrl->drop_primary      = key_pressed( &conf->drop_primary );
  ctrl->drop_secondary    = key_pressed( &conf->drop_secondary );
  ctrl->drop_shield     = key_pressed( &conf->drop_shield );
  ctrl->drop_ammo       = key_pressed( &conf->drop_ammo );

  ctrl->select_primary = 0;
  for ( j = 0; j < MAX_PRIMARY_WEAPONS; j++ )
  {
    if ( key_pressed( &conf->select_primary[ j ] ) )
    {
      ctrl->select_primary = j + 1;
    }
  }
  ctrl->select_secondary = 0;
  for ( j = 0; j < MAX_SECONDARY_WEAPONS; j++ )
  {
    if ( key_pressed( &conf->select_secondary[ j ] ) )
    {
      ctrl->select_secondary = j + 1;
    }
  }

  if ( ( SDL_GetModState() & KMOD_CTRL ) && key_pressed( &conf->send_msg ) && MyGameStatus == STATUS_Normal )
  {
    MenuRestart( &MENU_QuickTextSendWhisper );
  }
  else if ( ( key_pressed( &conf->send_msg ) ) && MyGameStatus == STATUS_Normal )
  {
    MenuRestart( &MENU_QuickTextSend );
  }

#ifdef PLAYER_SPEECH_TAUNTS
  if( key_pressed( &conf->send_speech )  )
  {
    PlaySpecificBikerSpeech( SFX_BIKER_TN, Ships[ WhoIAm ].Object.Group, &Ships[WhoIAm].Object.Pos, 0.0F, player_config->bike, -1, false ); // don't update
    if( MyGameStatus == STATUS_Normal )
    {
		SendBikerTaunt(); // (Sfx.c)
      //SendGameMessage(MSG_TEXTMSG, 0, 0, TEXTMSGTYPE_SpeechTaunt, 0);
    }
  }
#endif
  
	if ( JoystickInput )
	{
		for (joystick = 0; joystick < Num_Joysticks; joystick++)
		{
			if (JoystickInfo[joystick].connected && JoystickInfo[joystick].assigned)
				ReadJoystickInput(ctrl, joystick);
		}
	}

#ifdef LUA_BOT
	ProcessBot1();
#endif

  MaxMove = MoveAccell * MaxMoveSpeed * framelag;
  MaxTurbo = TurboAccell * MaxTurboSpeed * framelag;
  MaxTurn = TurnAccell * MaxTurnSpeed * framelag;
  MaxRoll = RollAccell * MaxRollSpeed * framelag;
  MaxBank = BankAccell * MaxBankAngle * framelag;

  CLAMP( ctrl->pitch, MaxTurn );
  CLAMP( ctrl->yaw, MaxTurn );
  CLAMP( ctrl->roll, MaxRoll );
  CLAMP( ctrl->bank, MaxBank );
  CLAMP( ctrl->right, MaxMove );
  CLAMP( ctrl->up, MaxMove );

  if ( ctrl->turbo && NitroFuel > 0.0F )
  {
    if ( ctrl->forward > MaxTurbo )
      ctrl->forward = MaxTurbo;
    else if ( ctrl->forward < -MaxMove )
      ctrl->forward = -MaxMove;
  }
  else
  {
    CLAMP( ctrl->forward, MaxMove );
  }
}