Beispiel #1
0
void CGameTeams::SetForceCharacterTeam(int ClientID, int Team)
{
	m_TeeFinished[ClientID] = false;
	if(m_Core.Team(ClientID) != TEAM_FLOCK 
		&& m_Core.Team(ClientID) != TEAM_SUPER 
		&& m_TeamState[m_Core.Team(ClientID)] != TEAMSTATE_EMPTY)
	{
		bool NoOneInOldTeam = true;
		for(int i = 0; i < MAX_CLIENTS; ++i)
			if(i != ClientID && m_Core.Team(ClientID) == m_Core.Team(i))
			{
				NoOneInOldTeam = false;//all good exists someone in old team
				break;
			} 
		if(NoOneInOldTeam)
			m_TeamState[m_Core.Team(ClientID)] = TEAMSTATE_EMPTY;
	}
	if(Count(m_Core.Team(ClientID)) > 0) m_MembersCount[m_Core.Team(ClientID)]--;
	m_Core.Team(ClientID, Team);
	if(m_Core.Team(ClientID) != TEAM_SUPER) m_MembersCount[m_Core.Team(ClientID)]++;
	if(Team != TEAM_SUPER && m_TeamState[Team] == TEAMSTATE_EMPTY)
		ChangeTeamState(Team, TEAMSTATE_OPEN);
	
	for (int LoopClientID = 0; LoopClientID < MAX_CLIENTS; ++LoopClientID)
	{
		if(Character(LoopClientID) && Character(LoopClientID)->GetPlayer()->m_IsUsingDDRaceClient)
			SendTeamsState(LoopClientID);
	}
}
Beispiel #2
0
bool CGameTeams::SetCharacterTeam(int ClientID, int Team)
{
	//Check on wrong parameters. +1 for TEAM_SUPER
	if(ClientID < 0 || ClientID >= MAX_CLIENTS || Team < 0 || Team >= MAX_CLIENTS + 1)
		return false;
	//You can join to TEAM_SUPER at any time, but any other group you cannot if it started
	if(Team != TEAM_SUPER && m_TeamState[Team] >= TEAMSTATE_CLOSED)
		return false;
	//No need to switch team if you there
	if(m_Core.Team(ClientID) == Team)
		return false;
	//You cannot be in TEAM_SUPER if you not super
	if(Team == TEAM_SUPER && !Character(ClientID)->m_Super) return false;
	//if you begin race
	if(Character(ClientID)->m_DDRaceState != DDRACE_NONE)
	{
		//you will be killed if you try to join FLOCK
		if(Team == TEAM_FLOCK && m_Core.Team(ClientID) != TEAM_FLOCK)
			Character(ClientID)->GetPlayer()->KillCharacter(WEAPON_GAME);
		else if(Team != TEAM_SUPER)
			return false;
	}
	SetForceCharacterTeam(ClientID, Team);
	
	
	//GameServer()->CreatePlayerSpawn(Character(id)->m_Core.m_Pos, TeamMask());
	return true;
}
Beispiel #3
0
void CGameTeams::OnCharacterFinish(int ClientID)
{
	if(m_Core.Team(ClientID) == TEAM_FLOCK || m_Core.Team(ClientID) == TEAM_SUPER)
	{
		Character(ClientID)->OnFinish();
	}
	else
	{
		m_TeeFinished[ClientID] = true;
		if(TeamFinished(m_Core.Team(ClientID)))
		{
			//ChangeTeamState(m_Core.Team(id), TEAMSTATE_FINISHED);//TODO: Make it better
			ChangeTeamState(m_Core.Team(ClientID), TEAMSTATE_OPEN);
			for(int i = 0; i < MAX_CLIENTS; ++i)
			{
				if(m_Core.Team(ClientID) == m_Core.Team(i))
				{
					CCharacter * pChar = Character(i);
					if(pChar != 0)
					{
						pChar->OnFinish();
						m_TeeFinished[i] = false;
					}
				}
			}
			
		}
	}
}
Beispiel #4
0
bool CWeapon_GenericGun07::OnFire(vec2 Direction)
{
	if(m_ReloadTimer > 0)
		return false;
		
	// check for ammo
	if(!m_Ammo)
	{
		// 125ms is a magical limit of how fast a human can click
		m_ReloadTimer = 125 * Server()->TickSpeed() / 1000;
		if(m_LastNoAmmoSound+Server()->TickSpeed() <= Server()->Tick())
		{
			CEvent_Sound(GameServer()).World(WorldID())
				.Send(Character()->GetPos(), SOUND_WEAPON_NOAMMO);
		
			m_LastNoAmmoSound = Server()->Tick();
		}
		return false;
	}
	
	vec2 ProjStartPos = Character()->GetPos() + Direction * Character()->GetProximityRadius()*0.75f;
	
	CreateProjectile(ProjStartPos, Direction);
	
	m_Ammo--;
	
	m_ReloadTimer = g_pData->m_Weapons.m_aId[m_TW07ID].m_Firedelay * Server()->TickSpeed() / 1000;
	
	return true;
}
Beispiel #5
0
int64_t CGameTeams::TeamMask(int Team, int ExceptID, int Asker)
{
	int64_t Mask = 0;

	for (int i = 0; i < MAX_CLIENTS; ++i)
	{
		if (i == ExceptID)
			continue; // Explicitly excluded
		if (!GetPlayer(i))
			continue; // Player doesn't exist

		if (!(GetPlayer(i)->GetTeam() == -1 || GetPlayer(i)->m_Paused))
		{ // Not spectator
			if (i != Asker)
			{ // Actions of other players
				if (!Character(i))
					continue; // Player is currently dead
				if (!GetPlayer(i)->m_ShowOthers)
				{
					if (m_Core.GetSolo(Asker))
						continue; // When in solo part don't show others
					if (m_Core.GetSolo(i))
						continue; // When in solo part don't show others
					if (m_Core.Team(i) != Team && m_Core.Team(i) != TEAM_SUPER)
						continue; // In different teams
				} // ShowOthers
			} // See everything of yourself
		}
		else if (GetPlayer(i)->m_SpectatorID != SPEC_FREEVIEW)
		{ // Spectating specific player
			if (GetPlayer(i)->m_SpectatorID != Asker)
			{ // Actions of other players
				if (!Character(GetPlayer(i)->m_SpectatorID))
					continue; // Player is currently dead
				if (!GetPlayer(i)->m_ShowOthers)
				{
					if (m_Core.GetSolo(Asker))
						continue; // When in solo part don't show others
					if (m_Core.GetSolo(GetPlayer(i)->m_SpectatorID))
						continue; // When in solo part don't show others
					if (m_Core.Team(GetPlayer(i)->m_SpectatorID) != Team && m_Core.Team(GetPlayer(i)->m_SpectatorID) != TEAM_SUPER)
						continue; // In different teams
				} // ShowOthers
			} // See everything of player you're spectating
		}
		else
		{ // Freeview
			if (GetPlayer(i)->m_SpecTeam)
			{ // Show only players in own team when spectating
				if (m_Core.Team(i) != Team && m_Core.Team(i) != TEAM_SUPER)
					continue; // in different teams
			}
		}

		Mask |= 1LL << i;
	}
	return Mask;
}
Beispiel #6
0
void MainWindow::on_testAchieve_clicked()
{
    action = TESTACHIEVE;
    ArmoryCharacter::insert(Character("Giganteus", "Thrall"));
    ArmoryCharacter::insert(Character("Gigahuf", "Thrall"));
    ArmoryCharacter::insert(Character("Sauerbruch", "Thrall"));
    ArmoryCharacter::insert(Character("Giganteus", "Antonidas"));
    db->updatePlayers();
}
static int __cdecl common_refill_and_read_nolock(__crt_stdio_stream const stream) throw()
{
    typedef __acrt_stdio_char_traits<Character> stdio_traits;

    _VALIDATE_RETURN(stream.valid(), EINVAL, stdio_traits::eof);

    if (!stream.is_in_use() || stream.is_string_backed())
        return stdio_traits::eof;

    if (stream.has_all_of(_IOWRITE))
    {
        stream.set_flags(_IOERROR);
        return stdio_traits::eof;
    }

    stream.set_flags(_IOREAD);

    // Get a buffer, if necessary:
    if (!stream.has_any_buffer())
        __acrt_stdio_allocate_buffer_nolock(stream.public_stream());

    auto const context = get_context_nolock(stream, Character());

    stream->_ptr = stream->_base;
    stream->_cnt = _read(_fileno(stream.public_stream()), stream->_base, stream->_bufsiz);

    if (!is_buffer_valid_nolock(stream, Character()))
    {
        stream.set_flags(stream->_cnt != 0 ? _IOERROR : _IOEOF);
        stream->_cnt = 0;
        return stdio_traits::eof;
    }

    if (!stream.has_any_of(_IOWRITE | _IOUPDATE) &&
        ((_osfile_safe(_fileno(stream.public_stream())) & (FTEXT | FEOFLAG)) == (FTEXT | FEOFLAG)))
    {
        stream.set_flags(_IOCTRLZ);
    }

    // Check for small _bufsiz (_SMALL_BUFSIZ). If it is small and if it is our
    // buffer, then this must be the first call to this function after an fseek
    // on a read-access-only stream. Restore _bufsiz to its larger value
    // (_INTERNAL_BUFSIZ) so that the next call to this function, if one is made,
    // will fill the whole buffer.
    if (stream->_bufsiz == _SMALL_BUFSIZ &&
        stream.has_crt_buffer() &&
        !stream.has_all_of(_IOBUFFER_SETVBUF))
    {
        stream->_bufsiz = _INTERNAL_BUFSIZ;
    }

    return read_character_nolock(stream, context, Character());
}
void PlayerController::Tick(sf::Window *window) {
  b2Body *body = Character()->Body();
  b2Vec2 chrPos = body->GetPosition();
  b2Vec2 base = Character()->ClosestPlanet()->Position();
  float angle_r = RadiansOf(chrPos - base);
  if (chrPos.x < base.x)
    angle_r = -angle_r;
  Character()->Body()->SetTransform(chrPos, angle_r);
  if (left_down_) {
    b2Vec2 mouseVec(mouse_x_ - window->getSize().x / 2.0f,
                    mouse_y_ - window->getSize().y / 2.0f);
    b2Vec2 rotated = RotatedVector(mouseVec, angle_r);
    body->ApplyLinearImpulse(rotated, body->GetPosition());
  }
}
Beispiel #9
0
void MWState::CharacterManager::createCharacter(const std::string& name)
{
    std::ostringstream stream;

    // The character name is user-supplied, so we need to escape the path
    for (std::string::const_iterator it = name.begin(); it != name.end(); ++it)
    {
        if (std::isalnum(*it)) // Ignores multibyte characters and non alphanumeric characters
            stream << *it;
        else
            stream << "_";
    }

    boost::filesystem::path path = mPath / stream.str();

    // Append an index if necessary to ensure a unique directory
    int i=0;
    while (boost::filesystem::exists(path))
    {
           std::ostringstream test;
           test << stream.str();
           test << " - " << ++i;
           path = mPath / test.str();
    }

    mCharacters.push_back (Character (path, mGame));

    mCurrent = &mCharacters.back();
}
Beispiel #10
0
int main()
{
	Character cube = Character("Cube", 5, 25, 123);
	Environment earth = Environment(137, "Earth", EARTH_GRAVITY);
	PhysicsController controller = PhysicsController();

	float maxJumpHeightOnEarth = controller.getMaxJumpHeightInMeters(earth, cube);
	float timeInAirOnEarth = controller.getJumpDurationInSeconds(earth, cube);
	float bookHeight = 0.05;
	bool canJumpOverBookOnEarth = controller.canJumpOverObstacle(earth, cube, bookHeight);
	std::cout << "EARTH:" << std::endl <<
		"--max jump height: " << maxJumpHeightOnEarth << " meters" << std::endl <<
		"--time in air: " << timeInAirOnEarth << " seconds" << std::endl <<
		"--can jump over book: " << (canJumpOverBookOnEarth ? "Yes" : "No") << std::endl;
	std::cout << std::endl;

	Environment moon = Environment(321, "Moon", MOON_GRAVITY);
	float maxJumpHeightOnTheMoon = controller.getMaxJumpHeightInMeters(moon, cube);
	float timeInAirOnTheMoon = controller.getJumpDurationInSeconds(moon, cube);
	bool canJumpOverBookOnTheMoon = controller.canJumpOverObstacle(moon, cube, bookHeight);
	std::cout << "MOON:" << std::endl <<
		"--max jump height: " << maxJumpHeightOnTheMoon << " meters" << std::endl <<
		"--time in air: " << timeInAirOnTheMoon << " seconds" << std::endl <<
		"--can jump over book: " << (canJumpOverBookOnTheMoon ? "Yes" : "No") << std::endl;

	return 0;
}
Beispiel #11
0
int main() {
    
    Character character = Character();
    character.prompt();
    
    return 0;
}
Beispiel #12
0
Lexer::Lexer(char* filename)
    :
    scanner(),
    token(Character(NULL, NULL, NULL, NULL, NULL), &scanner, NULL)
{
    scanner.OpenFile(filename);
}
Beispiel #13
0
void CMod_Weapon_Laser::CreateProjectile(vec2 Pos, vec2 Direction)
{
	new CLaser(GameWorld(), Pos, Direction, GameServer()->Tuning()->m_LaserReach, Player()->GetCID());
	
	CModAPI_WorldEvent_Sound(GameServer(), WorldID())
		.Send(Character()->GetPos(), SOUND_LASER_FIRE);
}
Beispiel #14
0
HumanChar::HumanChar(Gtk * graphic, HumanBox* hb)
{
  this->letter = Character();
  this->clicked = false;
  this->graphic = graphic;
  this->parent = hb;

}
Beispiel #15
0
Font::Character Font::get_character(CharType p_char) const {

	if (!char_map.has(p_char)) {
		ERR_FAIL_V(Character());
	};

	return char_map[p_char];
};
static void __cdecl uninitialize_environment_internal(Character**& environment) throw()
{
    if (environment == get_initial_environment(Character()))
    {
        return;
    }

    free_environment(environment);
}
void CGUIDialogKeyboardGeneric::OnClickButton(int iButtonControl)
{
  if (iButtonControl == CTL_BUTTON_BACKSPACE)
  {
    Backspace();
  }
  else
    Character(GetCharacter(iButtonControl));
}
Beispiel #18
0
Character TextCharCodec::decode( Byte byte ) const
{
    // QTextCodecs "use this codepoint when input data cannot be represented in Unicode." (Qt docs)
    static const QChar replacementChar = QChar( QChar::ReplacementCharacter );
    const QString string =
        mDecoder->toUnicode( reinterpret_cast<const char*>(&byte), 1 );
    const QChar qchar = string.at( 0 );
    const bool isDecoded = (qchar != replacementChar);
    return Character( qchar, ! isDecoded );
}
Beispiel #19
0
int main()
{
	Weapon sword  = Weapon("Steel Sword", 35,100,10,0,"sword",1);
	Item * sPtr = &sword;
	Inventory inv = Inventory(sPtr);
	Inventory * invPtr = &inv;
	Character chris  = Character("Chris", "Thief", "Human", 23,invPtr);
	chris.getInventory()->addItem(sword);
	chris.printStats();
}
Beispiel #20
0
static Character* __cdecl get_tmpfile_buffer_nolock(buffer_id const id) throw()
{
    Character*& buffer_pointer = get_tmpfile_buffer_pointer_nolock(id, Character());
    if (!buffer_pointer)
    {
        buffer_pointer = _calloc_crt_t(Character, L_tmpnam).detach();
    }

    return buffer_pointer;
}
Beispiel #21
0
int StringToInteger(String S)
{
   int n,i;

   n = 0;
   for (i = 1; i <= StringLength(S); i++)
      n = n * 10 + (int) (Character(S,i)) - 48; 

   return(n);
}
static Character** __cdecl common_get_initial_environment() throw()
{
    Character**& initial_environment = get_initial_environment(Character());
    if (!initial_environment)
    {
        initial_environment = common_get_or_create_environment_nolock<Character>();
    }
    
    return initial_environment;
}
Beispiel #23
0
int CGameTeams::TeamMask(int Team, int ExceptID)
{
	if(Team == TEAM_SUPER) return -1;
	int Mask = 0;
	for(int i = 0; i < MAX_CLIENTS; ++i)
		if(i != ExceptID)
			if((Character(i) && (m_Core.Team(i) == Team || m_Core.Team(i) == TEAM_SUPER))
				|| (GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() == -1))
				Mask |= 1 << i;
	return Mask;
}
void CGUIDialogKeyboardGeneric::OnClickButton(int iButtonControl)
{
    if (iButtonControl == CTL_BUTTON_BACKSPACE)
    {
        Backspace();
    }
    else if (iButtonControl == CTL_BUTTON_SPACE)
    {
        Character(" ");
    }
    else
    {
        const CGUIControl* pButton = GetControl(iButtonControl);
        if (pButton)
        {
            Character(pButton->GetDescription());
            // reset the shift keys
            if (m_bShift) OnShift();
        }
    }
}
Beispiel #25
0
/// <summary>
/// Builder of the Enemy class with 3 param
/// </summary>
/// <param> EnemyToCopy: The enemy to copy, what did you expect? </param>
Enemy::Enemy(const Enemy &EnemyToCopy) : Fighter( Character(*(EnemyToCopy.m_name), EnemyToCopy.m_imagePath.at(0), EnemyToCopy.m_imagePath.at(1), 
															EnemyToCopy.getSprite().getPosition().x, EnemyToCopy.getSprite().getPosition().y,
															EnemyToCopy.m_maxSpeed, EnemyToCopy.m_walkSpeed, EnemyToCopy.m_runSpeed, EnemyToCopy.m_jumpSpeed),
												EnemyToCopy.m_healthPoints, EnemyToCopy.m_maxHealthPoints, EnemyToCopy.m_experiencePoints)
										, m_level(EnemyToCopy.m_level), m_isActive(EnemyToCopy.m_isActive)
{
	m_enemyUpVision = new sf::FloatRect(*(EnemyToCopy.m_enemyUpVision));
	m_enemyGroundVision = new sf::FloatRect(*(EnemyToCopy.m_enemyGroundVision));

	m_enemyleftVision = new sf::FloatRect(*(EnemyToCopy.m_enemyleftVision));
	m_enemyRightVision = new sf::FloatRect(*(EnemyToCopy.m_enemyRightVision));
}
Beispiel #26
0
void	snakeclass::movesnake() {
  int	tmp = getch();

  switch(tmp) {
  case KEY_LEFT:
    if (direction != 'r')
      direction = 'l';
    break ;
  case KEY_UP:
    if (direction != 'd')
      direction = 'u';
    break ;
  case KEY_DOWN:
    if (direction != 'u')
      direction = 'd';
    break ;
  case KEY_RIGHT:
    if (direction != 'l')
      direction = 'r';
    break ;
  case KEY_BACKSPACE:
    direction = 'q';
    break ;
  }
  if (!get) {
    Map.map[snake[snake.size() - 1].x][snake[snake.size() - 1].y] = '.'; //attention
    snake.pop_back();
  }
  if (direction == 'l')
    snake.insert(snake.begin(), Character(snake[0].x, snake[0].y - 1));
  else if (direction == 'r')
    snake.insert(snake.begin(), Character(snake[0].x, snake[0].y + 1));
  else if (direction == 'u')
    snake.insert(snake.begin(), Character(snake[0].x - 1, snake[0].y));
  else if (direction == 'd')
    snake.insert(snake.begin(), Character(snake[0].x + 1, snake[0].y));
  Map.map[snake[0].x][snake[0].y] = 'X'; //attention
}
Beispiel #27
0
Player::Player(TextureHolder *textures,  sf::Font *gameFont, int playerNumber):
    reachedPortal(false),
    reachedPortalFirst(false),
    human(false),
    reachPortalMode(false)
{
    number = playerNumber;

    frozenLeft = 0;
    done = false;

    active = false;
    this->textures = textures;
    characters.push_back(Character (this->textures, playerNumber));

    this->pos = playerNumber;

    food = 0;
    cash = 0;
    energy = 0;
    faith = 0;

    txtCash.setFont(*gameFont);
    txtCash.setCharacterSize(20);

    txtFood.setFont(*gameFont);
    txtEnergy.setFont(*gameFont);
    txtFaith.setFont(*gameFont);

    txtNextRound.setFont(*gameFont);
    txtNextRound.setString("End Turn");
    txtNextRound.setCharacterSize(12);
    txtNextRound.setPosition(40,(playerNumber*100)+10);


    int posX1 = 82;
    int posX2 = 962;
    int posY1 = 22;
    int posY2 = 720;
    std::array<std::array<int,2>,4> textPos = {{{
        {posX1,posY1}}, {{posX2,posY1}},{{posX1,posY2}}, {{posX2, posY2}
    }}};

    txtCash.setPosition(textPos[playerNumber][0],textPos[playerNumber][1] );
    buttons.insert({"end_turn",rectangle});

    setSpriteAI();

}
static int __cdecl common_initialize_environment_nolock() throw()
{
    typedef __crt_char_traits<Character> traits;

    // We only initialize the environment once.  Once the environment has been
    // initialized, all updates and modifications go through the other functions
    // that manipulate the environment.
    if (get_environment_nolock(Character()))
        return 0;

    pre_initialize(Character());

    __crt_unique_heap_ptr<Character> const os_environment(traits::get_environment_from_os());
    if (!os_environment)
        return -1;

    __crt_unique_heap_ptr<Character*> crt_environment(create_environment(os_environment.get()));
    if (!crt_environment)
        return -1;

    get_initial_environment(Character()) = crt_environment.get();
    get_dual_state_environment_nolock(Character()).initialize(crt_environment.detach());
    return 0;
}
static Character** __cdecl common_get_or_create_environment_nolock() throw()
{
    typedef __crt_char_traits<Character> traits;
    typedef typename traits::other_char_type other_char_type;

    // Check to see if the required environment already exists:
    Character** const existing_environment = get_environment_nolock(Character());
    if (existing_environment)
        return existing_environment;

    // Check to see if the other environment exists.  We will only initialize
    // the environment here if the other environment was already initialized.
    other_char_type** const other_environment = get_environment_nolock(other_char_type());
    if (!other_environment)
        return nullptr;

    if (common_initialize_environment_nolock<Character>() != 0)
        return nullptr;

    if (initialize_environment_by_cloning_nolock<Character>() != 0)
        return nullptr;

    return get_environment_nolock(Character());
}
Beispiel #30
0
    void SoundManager::Load()
    {
		//this->mClientTransmissionManager.GetClientSessionManager().RegisterAudioEventListener(this);

		this->mAudioDevice = this->mAudioDeviceFactory.CreateDevice();

		if(this->mAudioDevice!=NULL)
		{    
			this->mAudioDevice->Init(this->margc,this->margv);

			this->mAudioDevice->Load();

			//set default listener.
			this->UpdateListenerValues(Character());
		}
    }