コード例 #1
0
ファイル: TeamHandler.cpp プロジェクト: Mocahteam/SpringPP
void CTeamHandler::GameFrame(int frameNum)
{
	if (!(frameNum & (TEAM_SLOWUPDATE_RATE-1))) {
		for (int a = 0; a < ActiveTeams(); ++a) {
			Team(a)->ResetFrameVariables();
		}
		for (int a = 0; a < ActiveTeams(); ++a) {
			Team(a)->SlowUpdate();
		}
	}
}
コード例 #2
0
ファイル: launch_speedup.cpp プロジェクト: DonCN/haiku
status_t
Session::StartWatchingTeam()
{
	if (Team() < B_OK)
		return B_OK;

	status_t status = start_watching_team(Team(), team_gone, this);
	if (status == B_OK)
		fIsWatchingTeam = true;

	return status;
}
コード例 #3
0
TeamHolder::TeamHolder(const QString &name)
{
    m_teams.push_back(Team());
    m_currentTeam = 0;

    this->name() = name;
}
コード例 #4
0
ファイル: TeamDebugger.cpp プロジェクト: looncraz/haiku
status_t
BTeamDebugger::Uninstall()
{
	if (Team() < 0)
		return B_BAD_VALUE;

	remove_team_debugger(Team());

	delete_port(fDebuggerPort);

	BDebugContext::Uninit();

	fDebuggerPort = -1;

	return B_OK;
}
コード例 #5
0
//--------------------------- Render -------------------------------------
//
//------------------------------------------------------------------------
void GoalKeeper::Render()                                         
{
  if (Team()->Color() == SoccerTeam::blue) 
    gdi->BluePen();
  else 
    gdi->RedPen();
  
  m_vecPlayerVBTrans = WorldTransform(m_vecPlayerVB,
                                       Pos(),
                                       m_vLookAt,
                                       m_vLookAt.Perp(),
                                       Scale());

  gdi->ClosedShape(m_vecPlayerVBTrans);
  
  //draw the head
  gdi->BrownBrush();
  gdi->Circle(Pos(), 6);

  //draw the ID
  if (Prm.bIDs)
  {
    gdi->TextColor(0, 170, 0);;
    gdi->TextAtPos(Pos().x-20, Pos().y-20, ttos(ID()));
  }

  //draw the state
  if (Prm.bStates)
  { 
    gdi->TextColor(0, 170, 0); 
    gdi->TransparentText(); 
    gdi->TextAtPos(m_vPosition.x, m_vPosition.y -20, std::string(m_pStateMachine->GetNameOfCurrentState()));
  }
}
コード例 #6
0
void Simulation::setupTeams(json_spirit::Array &teamData)
{
	int teamIndex = 0;
	for (json_spirit::Value &val : teamData)
	{
		teams.push_back(Team(val.get_obj(), teamIndex++));
	}
}
コード例 #7
0
ファイル: input.cpp プロジェクト: PLaGInc/Lab_1-CG-
input::input(QWidget *parent) :
    QDialog(parent),
    NewTeamRow(Team("", 0, 0, 0, 0)),
    ui(new Ui::input)
{
    ui->setupUi(this);
    QDialog::setFixedSize(size());

}
コード例 #8
0
Vector2D GoalKeeper::GetRearInterposeTarget()const
{
  double xPosTarget = Team()->HomeGoal()->Center().x;

  double yPosTarget = Pitch()->PlayingArea()->Center().y - 
                     Prm.GoalWidth*0.5 + (Ball()->Pos().y*Prm.GoalWidth) /
                     Pitch()->PlayingArea()->Height();

  return Vector2D(xPosTarget, yPosTarget); 
}
コード例 #9
0
ファイル: Scoreboard.cpp プロジェクト: ChriPiv/MCServer
cTeam * cScoreboard::RegisterTeam(
	const AString & a_Name, const AString & a_DisplayName,
	const AString & a_Prefix, const AString & a_Suffix
)
{
	cTeam Team(a_Name, a_DisplayName, a_Prefix, a_Suffix);

	std::pair<cTeamMap::iterator, bool> Status = m_Teams.insert(cNamedTeam(a_Name, Team));

	return Status.second ? &Status.first->second : NULL;
}
コード例 #10
0
void TeamHolder::addTeam()
{
    m_teams.push_back(Team());

    if (currentTeam() < count() - 1 && !team(currentTeam()).folder().isEmpty()) {
        m_teams.back().setFolder(team(currentTeam()).folder());
    } else {
        QSettings s;

        m_teams.back().setFolder(s.value("Teams/Folder").toString());
    }
}
コード例 #11
0
int main(int argc, char *argv[])
{
    std::vector<Team> teams;
    teams.push_back(Team(1, "Apple"));
    teams.push_back(Team(2, "Berry"));
    teams.push_back(Team(3, "Clementine"));
    teams.push_back(Team(4, "Dandelion"));
    teams.push_back(Team(5, "Egg"));
    teams.push_back(Team(6, "Fish"));
    teams.push_back(Team(7, "Grape"));
    teams.push_back(Team(8, "Habonero"));
    teams.push_back(Team(9, "Ice cream"));
    teams.push_back(Team(10, "Juice"));
    print_container(teams);
    Division d(teams);

    QApplication a(argc, argv);
    bball w;
    w.show();

    return a.exec();
}
コード例 #12
0
ファイル: Parser.cpp プロジェクト: ninovt9/NINO_SCHEDULE
	void Parser::HandleGroupExp(const std::string &groupName)
	{
		auto condition = [](TokenIndex iter)
		{
			return (iter->GetType() == TokenType::TAB && (iter + 1)->GetType() == TokenType::STRING);
		};

		for (; condition(iter_); SkipIter(2))
		{
			auto teamName = (iter_ + 1)->GetName();
			AddTeam(teamName, Team(teamName));
		}
	}
コード例 #13
0
ファイル: input.cpp プロジェクト: PLaGInc/Lab_1-CG-
void input::on_buttonBox_accepted()
{
    if (!ui->teamEdit->text().isEmpty()
            && ui->winBox->value() >= 0
            && ui->loseBox->value() >= 0
            && ui->totalBox->value() >= 0
            && ui->ratingBox->value() > 0)
    {
            NewTeamRow = Team(ui->teamEdit->text(), ui->winBox->value(),
                           ui->loseBox->value(), ui->totalBox->value(),
                           ui->ratingBox->value());
    }
}
コード例 #14
0
ファイル: match.cpp プロジェクト: Mathsoum/Petanque
Match::Match(const Team &first, const Team &second)
{
  mState = PENDING;

  mMatch.first = first;
  mMatch.second = second;
  mWinner = NONE;

  if( second == Team() ) {
    mState = FINISHED;
    mWinner = FIRST;
  }
}
コード例 #15
0
ファイル: TeamHandler.cpp プロジェクト: Anarchid/spring
unsigned int CTeamHandler::GetNumTeamsInAllyTeam(unsigned int allyTeamNum, bool countDeadTeams) const
{
	unsigned int numTeams = 0;

	for (unsigned int teamNum = 0; teamNum < teamHandler->ActiveTeams(); teamNum++) {
		if (AllyTeam(teamNum) != allyTeamNum)
			continue;
		if (Team(teamNum)->isDead && !countDeadTeams)
			continue;

		numTeams += 1;
	}

	return numTeams;
}
コード例 #16
0
ファイル: Modes.cpp プロジェクト: Kindos7/FDX_Fighter
    //Population control
    void Offline_Survival::add_enemy()//Add enemy
    {
        //Update the counters
        ++now_cur;
        --now_tot;

        //Insert the enemy
        ais.emplace_front(get_rand_cnt(),txture,cfg,Team(player?player->team().get_swapped():Team().get_swapped()));

        //Configure it
        AI_spaceship& new_ai=ais.front();
        new_ai.set_enemy(player);
        new_ai.put_lasers(&al);
        new_ai.put_cannon(can);
        new_ai.put_cannon_lasers(&al);
    }
コード例 #17
0
ファイル: GamePlayerInfo.cpp プロジェクト: jhkl/s25client
/// Deserialisierungskonstruktor
GamePlayerInfo::GamePlayerInfo(const unsigned playerid, Serializer* ser) :
    playerid(playerid),
    ps(PlayerState(ser->PopUnsignedChar())),
    aiInfo(),
    name(ser->PopString()),
    origin_name(ser->PopString()),
    is_host(ser->PopBool()),
    nation(Nation(ser->PopUnsignedChar())),
    team(Team(ser->PopUnsignedChar())),
    color(ser->PopUnsignedChar()),
    ping(ser->PopUnsignedInt()),
    rating(ser->PopUnsignedInt()),
    obj_cnt(0),
    obj_id_cnt(0),
    ready(ser->PopBool())
{
}
コード例 #18
0
ファイル: agent.cpp プロジェクト: TristanBrismontier/Tron
char Agent::stuck()
{
	int x = head().X;
	int y = head().Y;
	string moves;
    if(Team()==1)
        moves="uldr";
    else
        moves="drul";

	for(int i=0;i<3;i++)
    {
		Point nextp; nextp.X=nextX(x,moves[i]); nextp.Y=nextY(y,moves[i]);
		//cout << "distans for stuck " << getdistance(head(),nextp) << endl;
		if(isEmpty(nextp.X,nextp.Y)) //&& getdistance(head(),nextp)>1 )
		{ /*cout << "raft too if!!" << endl;*/  cout << "stuck "<< moves[i] << endl;   return moves[i]; }
		
    }
	return moves[3];
}
コード例 #19
0
/* TODO Old system. Random generation of matches.
 *
 * Should generate next matches on the fly !
 * Even over few next phases
 */
void FourMatchesContest::generateNextMatchList()
{
  QList<Team> teamsList = TeamModel::getInstance()->getRawData();

  Util<Team>::shuffle( &teamsList );
  //qDebug() << "Is teamsList.size() even ? " << (teamsList.size() % 2 == 0);

  if( teamsList.size() % 2 != 0 && mState != NOT_STARTED_YET) {
      QList<Team> mustPlay = getTeamsAlreadyBeenExempt();
//      qDebug() << "Must play :";
//      Q_FOREACH(Team team, mustPlay) {
//          qDebug() << team.getName();
//      }
//      qDebug() << "";

      while( !mustPlay.isEmpty() ) {
        QList<Team> teamsAvailable = teamsAvailableToPlayAgainst( mustPlay.first(), teamsList );
        //qDebug() << "New match " << teamsList.first().getName() << " vs " << teamsAvailable.first().getName();
        addMatchToCurrentPhase( mustPlay.first(), teamsAvailable.first() );
        teamsList.removeOne( mustPlay.first() );
        teamsList.removeOne( teamsAvailable.first() );
        mustPlay.removeFirst();
      }
  }

  while( !teamsList.isEmpty() ) {
    //qDebug() << " >> teamsList.size() == " << teamsList.size();
    if( teamsList.size() > 1 ) {
      QList<Team> teamsAvailable = teamsAvailableToPlayAgainst( teamsList.first(), teamsList );
      //qDebug() << "New match " << teamsList.first().getName() << " vs " << teamsAvailable.first().getName();
      addMatchToCurrentPhase( teamsList.first(), teamsAvailable.first() );
      teamsList.removeFirst();
      teamsList.removeOne( teamsAvailable.first() );
    } else if( teamsList.size() == 1 ) {
        //qDebug() << "Generate last match with " << teamsList.first().getName();
        addMatchToCurrentPhase( teamsList.first(), Team() );
        teamsList.removeFirst();
    }
  }
}
コード例 #20
0
ファイル: TeamHandler.cpp プロジェクト: Anarchid/spring
void CTeamHandler::UpdateTeamUnitLimitsPreSpawn(int liveTeamNum)
{
	CTeam* liveTeam = teams[liveTeamNum];
	CTeam* tempTeam = NULL;

	// will be set to true immediately after we return
	assert(liveTeam->isDead);

	// Gaia team is alone in its allyteam and cannot really spawn
	if (liveTeamNum == gaiaTeamID)
		return;

	// count the number of remaining (non-dead) teams in <liveTeam>'s allyteam, EXCLUDING us
	const unsigned int numRemainingActiveTeams = GetNumTeamsInAllyTeam(AllyTeam(liveTeamNum), false);

	if (numRemainingActiveTeams == 0) {
		// set default since we are the only team in our allyteam now
		liveTeam->SetMaxUnits(std::min(gameSetup->maxUnitsPerTeam, int(MAX_UNITS / teams.size())));
		return;
	}

	// reduce the limit of each team in our allyteam uniformly
	for (unsigned int tempTeamNum = 0; tempTeamNum < teams.size(); tempTeamNum++) {
		if (tempTeamNum == liveTeamNum)
			continue;
		if (AllyTeam(tempTeamNum) != AllyTeam(liveTeamNum))
			continue;
		if (Team(tempTeamNum)->isDead)
			continue;

		tempTeam = teams[tempTeamNum];
		tempTeam->SetMaxUnits((tempTeam->GetMaxUnits() * numRemainingActiveTeams) / (numRemainingActiveTeams + 1));
	}

	assert(tempTeam != NULL);
	liveTeam->SetMaxUnits(tempTeam->GetMaxUnits());
}
コード例 #21
0
ファイル: game.cpp プロジェクト: aaronjohnleonard/sequence
Game::Game(int numTeams, int numPlayers)
{

    board = Board();
    teams = vector<Team>();
    for (int i = 0; i < numTeams; i++){
        teams.push_back(Team());
    }
    players = vector<Player*>();
    for (int i = 0; i < numPlayers; i++){
        players.push_back(new Player_Human());
    }
    deck = deque<Card>();
    this->createDeck();
    discard = vector<Card>();
    currentTurn = 0;
    gameCompleted = false;
    for (unsigned long i = 0; i < players.size(); i++){
        dealHandToPlayer(players[i]);
    }
    for (unsigned long i = 0; i < players.size(); i++){
        players[i]->printHand();
    }
}
コード例 #22
0
void CreatureTextMgr::SendChatPacket(WorldPacket* data, WorldObject* source, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) const
{
    if (!source)
        return;

    float dist = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY);

    switch (msgType)
    {
        case CHAT_MSG_MONSTER_YELL:
            dist = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL);
            break;
        case CHAT_MSG_MONSTER_EMOTE:
        case CHAT_MSG_RAID_BOSS_EMOTE:
            dist = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE);
            break;
        case CHAT_MSG_MONSTER_WHISPER:
        case CHAT_MSG_RAID_BOSS_WHISPER:
        {
            if (range == TEXT_RANGE_NORMAL)//ignores team and gmOnly
            {
                Player* player = ObjectAccessor::FindPlayer(whisperGuid);
                if (!player || !player->GetSession())
                    return;
                player->GetSession()->SendPacket(data);
                return;
            }
            break;
        }
        default:
            break;
    }

    switch (range)
    {
        case TEXT_RANGE_AREA:
        {
            uint32 areaId = source->GetAreaId();
            Map::PlayerList const& pList = source->GetMap()->GetPlayers();
            for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
            {
                if (itr->getSource()->GetAreaId() == areaId && (!team || Team(itr->getSource()->GetTeam()) == team) && (!gmOnly || itr->getSource()->isGameMaster()))
                {
                    if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid
                        data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(itr->getSource()->GetGUID()));
                    (itr->getSource())->GetSession()->SendPacket(data);
                }
            }
            return;
        }
        case TEXT_RANGE_ZONE:
        {
            uint32 zoneId = source->GetZoneId();
            Map::PlayerList const& pList = source->GetMap()->GetPlayers();
            for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
            {
                if (itr->getSource()->GetZoneId() == zoneId && (!team || Team(itr->getSource()->GetTeam()) == team) && (!gmOnly || itr->getSource()->isGameMaster()))
                {
                    if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid
                        data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(itr->getSource()->GetGUID()));
                    (itr->getSource())->GetSession()->SendPacket(data);
                }
            }
            return;
        }
        case TEXT_RANGE_MAP:
        {
            Map::PlayerList const& pList = source->GetMap()->GetPlayers();
            for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
            {
                if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid
                    data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(itr->getSource()->GetGUID()));
                if ((!team || Team(itr->getSource()->GetTeam()) == team) && (!gmOnly || itr->getSource()->isGameMaster()))
                    (itr->getSource())->GetSession()->SendPacket(data);
            }
            return;
        }
        case TEXT_RANGE_WORLD:
        {
            const SessionMap smap = sWorld->GetAllSessions();
            for (SessionMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter)
            {
                if (Player* plr = (*iter).second->GetPlayer())
                {
                    if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid
                        data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(plr->GetGUID()));
                    if (plr->GetSession()  && (!team || Team(plr->GetTeam()) == team) && (!gmOnly || plr->isGameMaster()))
                        plr->GetSession()->SendPacket(data);
                }
            }
            return;
        }
        case TEXT_RANGE_NORMAL:
        default:
            break;
    }
    source->SendMessageToSetInRange(data, dist, true);
}
コード例 #23
0
void BattleGroundIC::EndBattleGround(uint32 winner)
{
    SendMessage2ToAll(LANG_BG_IC_TEAM_WINS,CHAT_MSG_BG_SYSTEM_NEUTRAL,NULL, (winner == ALLIANCE ? LANG_BG_IC_ALLIANCE : LANG_BG_IC_HORDE));

    BattleGround::EndBattleGround(Team(winner));
}
コード例 #24
0
ファイル: Vision.cpp プロジェクト: HaikuArchives/Vision
int32 VisionApp::ThreadStates(void)
{
	thread_id team(Team());
	int32 cookie(0);
	thread_info info;

	BString buffer;
	int32 t_count(0);

	while (get_next_thread_info(team, &cookie, &info) == B_NO_ERROR) {
		// wake up any threads that're snoozing for their next reconnect run
		if (strstr(info.name, "s>") != NULL) {
			switch (info.state) {
			case B_THREAD_ASLEEP:
				suspend_thread(info.thread);
			// fall through
			case B_THREAD_SUSPENDED:
				resume_thread(info.thread);
				break;
			default:
				break;
			}
		}

		if (fDebugShutdown) {
			buffer += "thread: ";
			buffer << info.thread;
			buffer += " name:  ";
			buffer += info.name;
			buffer += " state: ";

			switch ((int32)info.state) {
			case B_THREAD_RUNNING:
				buffer += "running\n";
				break;

			case B_THREAD_READY:
				buffer += "ready\n";
				break;

			case B_THREAD_RECEIVING:
				buffer += "receiving\n";
				break;

			case B_THREAD_ASLEEP:
				buffer += "asleep\n";
				break;

			case B_THREAD_SUSPENDED:
				buffer += "suspended\n";
				break;

			case B_THREAD_WAITING:
				buffer += "waiting\n";
				break;

			default:
				buffer += "???\n";
			}
		}
		++t_count;
	}

	if (fDebugShutdown && buffer.Length()) {
		printf("%s\n", buffer.String());
#if 0
    BAlert *alert (new BAlert (
      "Too many threads",
      buffer.String(),
      t_count > 1 ? "Damn" : "Cool",
      0,
      0,
      B_WIDTH_AS_USUAL,
      t_count > 1 ? B_STOP_ALERT : B_INFO_ALERT));
      alert->Go();
#endif
	}

	return t_count;
}
コード例 #25
0
bool GoalKeeper::BallWithinRangeForIntercept()const
{
  return (Vec2DDistanceSq(Team()->HomeGoal()->Center(), Ball()->Pos()) <=
          Prm.GoalKeeperInterceptRangeSq);
}
コード例 #26
0
void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly) const
{
    switch (msgType)
    {
        case CHAT_MSG_MONSTER_PARTY:
        {
            if (!whisperTarget)
                return;

            if (Player const* whisperPlayer = whisperTarget->ToPlayer())
            {
                if (Group const* group = whisperPlayer->GetGroup())
                    group->BroadcastWorker([data](Player* player) { player->SendDirectMessage(data); });
            }
            return;
        }
        case CHAT_MSG_MONSTER_WHISPER:
        case CHAT_MSG_RAID_BOSS_WHISPER:
        {
            if (range == TEXT_RANGE_NORMAL) // ignores team and gmOnly
            {
                if (!whisperTarget || whisperTarget->GetTypeId() != TYPEID_PLAYER)
                    return;

                whisperTarget->ToPlayer()->SendDirectMessage(data);
                return;
            }
            break;
        }
        default:
            break;
    }

    switch (range)
    {
        case TEXT_RANGE_AREA:
        {
            uint32 areaId = source->GetAreaId();
            Map::PlayerList const& players = source->GetMap()->GetPlayers();
            for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                if (itr->GetSource()->GetAreaId() == areaId && (!team || Team(itr->GetSource()->GetTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
                    itr->GetSource()->SendDirectMessage(data);
            return;
        }
        case TEXT_RANGE_ZONE:
        {
            uint32 zoneId = source->GetZoneId();
            Map::PlayerList const& players = source->GetMap()->GetPlayers();
            for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                if (itr->GetSource()->GetZoneId() == zoneId && (!team || Team(itr->GetSource()->GetTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
                    itr->GetSource()->SendDirectMessage(data);
            return;
        }
        case TEXT_RANGE_MAP:
        {
            Map::PlayerList const& players = source->GetMap()->GetPlayers();
            for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                if ((!team || Team(itr->GetSource()->GetTeam()) == team) && (!gmOnly || itr->GetSource()->IsGameMaster()))
                    itr->GetSource()->SendDirectMessage(data);
            return;
        }
        case TEXT_RANGE_WORLD:
        {
            SessionMap const& smap = sWorld->GetAllSessions();
            for (SessionMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter)
                if (Player* player = iter->second->GetPlayer())
                    if ((!team || Team(player->GetTeam()) == team) && (!gmOnly || player->IsGameMaster()))
                        player->SendDirectMessage(data);
            return;
        }
        case TEXT_RANGE_NORMAL:
        default:
            break;
    }

    float dist = GetRangeForChatType(msgType);
    source->SendMessageToSetInRange(data, dist, true);
}
コード例 #27
0
ファイル: bf4_x86.cpp プロジェクト: davidebeatrici/mumble
static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, float *camera_top, std::string &context, std::wstring &identity) {
	for (int i=0;i<3;i++) {
		avatar_pos[i] = avatar_front[i] = avatar_top[i] = camera_pos[i] = camera_front[i] = camera_top[i] = 0.0f;
	}

	bool ok, state;
	char serverid[37], host[22], team[3];
	BYTE squad, squad_leader, squad_state;

	// Server ID pointers
	procptr_t serverid_base = peekProcPtr(pModule + 0x1D39C64);
	if (!serverid_base) return false;
	procptr_t serverid_offset_0 = peekProcPtr(serverid_base + 0xC);
	if (!serverid_offset_0) return false;
	procptr_t serverid_offset_1 = peekProcPtr(serverid_offset_0 + 0x14);
	if (!serverid_offset_1) return false;
	procptr_t serverid_offset = peekProcPtr(serverid_offset_1 + 0x1D0);
	if (!serverid_offset) return false;

	// Squad pointers
	procptr_t squad_base = peekProcPtr(pModule + 0x1D39D0C);
	if (!squad_base) return false;
	procptr_t squad_offset_0 = peekProcPtr(squad_base + 0x7C);
	if (!squad_offset_0) return false;
	procptr_t squad_offset_1 = peekProcPtr(squad_offset_0 + 0x728);
	if (!squad_offset_1) return false;

	// Peekproc and assign game addresses to our containers, so we can retrieve positional data
	ok = peekProc(pModule + 0x1D23B0E, &state, 1) && // Magical state value: 0 when in-game and 1 when in menu/dead.
	     peekProc(pModule + 0x1CFD3C0, avatar_pos, 12) && // Avatar Position values (X, Y and Z).
	     peekProc(pModule + 0x1D23CB0, camera_pos, 12) && // Camera Position values (X, Y and Z).
	     peekProc(pModule + 0x1D23C90, avatar_top, 12) && // Avatar Top Vector values (X, Y and Z).
	     peekProc(pModule + 0x1D23CA0, avatar_front, 12) && // Avatar Front Vector values (X, Y and Z).
	     peekProc(serverid_offset, serverid) && // Server ID (36 characters).
	     peekProc(pModule + 0x1CF3A68, host) && // Host value: "IP:Port" when in a server, "bot" when loading and empty when it's hidden.
	     peekProc(pModule + 0x1DCF695, team) && // Team value: US (United States); RU (Russia); CH (China).
	     peekProc(squad_offset_1 + 0x15C, squad) && // Squad value: 0 (not in a squad); 1 (Alpha); 2 (Bravo); 3 (Charlie)... 26 (Zulu).
	     peekProc(squad_offset_1 + 0x160, squad_leader) && // Squad leader value: 0 (False); 1 (True).
	     peekProc(squad_offset_1 + 0x161, squad_state); // Squad state value: 0 (Public); 1 (Private).

	// This prevents the plugin from linking to the game in case something goes wrong during values retrieval from memory addresses.
	if (! ok) {
		return false;
	}

	if (state) { // If not in-game
		context.clear(); // Clear context
		identity.clear(); // Clear identity
		// Set vectors values to 0.
		for (int i=0;i<3;i++) {
			avatar_pos[i] = avatar_front[i] = avatar_top[i] = camera_pos[i] =  camera_front[i] = camera_top[i] = 0.0f;
		}

		return true; // This tells Mumble to ignore all vectors.
	}

	escape(serverid, sizeof(serverid));
	std::ostringstream ocontext;
	ocontext << " {\"Server ID\": \"" << serverid << "\"}"; // Set context with server ID
	context = ocontext.str();

	std::wostringstream oidentity;
	oidentity << "{";
	escape(host, sizeof(host));
	// Only include host (IP:port) if it is not empty and does not include the string "bot" (which means it's a local server).
	if (strcmp(host, "") != 0 && strstr(host, "bot") == NULL) {
		oidentity << std::endl << "\"Host\": \"" << host << "\",";
	}

	std::string Team(team);
	if (!Team.empty()) {
		oidentity << std::endl;
		if (Team == "US")
			oidentity << "\"Team\": \"United States\","; // If team value is US, set "United States" as team in identity.
		else if (Team == "CH")
			oidentity << "\"Team\": \"China\","; // If team value is CH, set "China" as team in identity.
		else if (Team == "RU")
			oidentity << "\"Team\": \"Russia\","; // If team value is RU, set "Russia" as team in identity.
	}

	// If squad value is in a value between 1 and 26, set squad name in identity using NATO Phonetic alphabet.
	if (squad > 0 && squad < 27) {
		if (squad == 1)
			oidentity << std::endl << "\"Squad\": \"Alpha\",";
		else if (squad == 2)
			oidentity << std::endl << "\"Squad\": \"Bravo\",";
		else if (squad == 3)
			oidentity << std::endl << "\"Squad\": \"Charlie\",";
		else if (squad == 4)
			oidentity << std::endl << "\"Squad\": \"Delta\",";
		else if (squad == 5)
			oidentity << std::endl << "\"Squad\": \"Echo\",";
		else if (squad == 6)
			oidentity << std::endl << "\"Squad\": \"Foxtrot\",";
		else if (squad == 7)
			oidentity << std::endl << "\"Squad\": \"Golf\",";
		else if (squad == 8)
			oidentity << std::endl << "\"Squad\": \"Hotel\",";
		else if (squad == 9)
			oidentity << std::endl << "\"Squad\": \"India\",";
		else if (squad == 10)
			oidentity << std::endl << "\"Squad\": \"Juliet\",";
		else if (squad == 11)
			oidentity << std::endl << "\"Squad\": \"Kilo\",";
		else if (squad == 12)
			oidentity << std::endl << "\"Squad\": \"Lima\",";
		else if (squad == 13)
			oidentity << std::endl << "\"Squad\": \"Mike\",";
		else if (squad == 14)
			oidentity << std::endl << "\"Squad\": \"November\",";
		else if (squad == 15)
			oidentity << std::endl << "\"Squad\": \"Oscar\",";
		else if (squad == 16)
			oidentity << std::endl << "\"Squad\": \"Papa\",";
		else if (squad == 17)
			oidentity << std::endl << "\"Squad\": \"Quebec\",";
		else if (squad == 18)
			oidentity << std::endl << "\"Squad\": \"Romeo\",";
		else if (squad == 19)
			oidentity << std::endl << "\"Squad\": \"Sierra\",";
		else if (squad == 20)
			oidentity << std::endl << "\"Squad\": \"Tango\",";
		else if (squad == 21)
			oidentity << std::endl << "\"Squad\": \"Uniform\",";
		else if (squad == 22)
			oidentity << std::endl << "\"Squad\": \"Victor\",";
		else if (squad == 23)
			oidentity << std::endl << "\"Squad\": \"Whiskey\",";
		else if (squad == 24)
			oidentity << std::endl << "\"Squad\": \"X-ray\",";
		else if (squad == 25)
			oidentity << std::endl << "\"Squad\": \"Yankee\",";
		else if (squad == 26)
			oidentity << std::endl << "\"Squad\": \"Zulu\",";
		// Squad leader
		if (squad_leader == 1)
			oidentity << std::endl << "\"Squad leader\": true,"; // If squad leader value is true, set squad leader state to "True" in identity.
		else
			oidentity << std::endl << "\"Squad leader\": false,"; // If squad leader value is false, set squad leader state to "False" in identity.
		// Squad state
		if (squad_state == 1)
			oidentity << std::endl << "\"Squad state\": \"Private\""; // If squad state value is true, set squad state to "Private" in identity.
		else
			oidentity << std::endl << "\"Squad state\": \"Public\""; // If squad state value is false, set squad state to "Public" in identity.
		// When not in a squad
	} else {
		oidentity << std::endl << "\"Squad\": null,"; // If squad value isn't between 1 and 26, set squad to "null" in identity.
		oidentity << std::endl << "\"Squad leader\": null,"; // If not in a squad, set squad leader state to "null" in identity.
		oidentity << std::endl << "\"Squad state\": null"; // If not in a squad, set squad state to "null" in identity.
	}

	oidentity << std::endl << "}";
	identity = oidentity.str();

	// Flip the front vector
	for (int i=0;i<3;i++) {
		avatar_front[i] = -avatar_front[i];
	}

	// Convert from right to left handed
	avatar_pos[0] = -avatar_pos[0];
	camera_pos[0] = -camera_pos[0];
	avatar_front[0] = -avatar_front[0];
	avatar_top[0] = -avatar_top[0];

	// Sync camera front and top vectors with avatar ones
	for (int i=0;i<3;i++) {
		camera_front[i] = avatar_front[i];
		camera_top[i] = avatar_top[i];
	}

	return true;
}
コード例 #28
0
TeamHolder::TeamHolder()
{
    m_teams.push_back(Team());
    m_currentTeam = 0;
}
コード例 #29
0
ファイル: CreatureTextMgr.cpp プロジェクト: 3kids/TrinityCore
void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) const
{
    float dist = GetRangeForChatType(msgType);

    switch (msgType)
    {
        case CHAT_MSG_MONSTER_WHISPER:
        case CHAT_MSG_RAID_BOSS_WHISPER:
        {
            if (range == TEXT_RANGE_NORMAL)//ignores team and gmOnly
            {
                Player* player = ObjectAccessor::FindPlayer(whisperGuid);
                if (!player || !player->GetSession())
                    return;
                player->GetSession()->SendPacket(data);
                return;
            }
            break;
        }
        default:
            break;
    }

    switch (range)
    {
        case TEXT_RANGE_AREA:
        {
            uint32 areaId = source->GetAreaId();
            Map::PlayerList const& players = source->GetMap()->GetPlayers();
            for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                if (itr->getSource()->GetAreaId() == areaId && (!team || Team(itr->getSource()->GetTeam()) == team) && (!gmOnly || itr->getSource()->isGameMaster()))
                    itr->getSource()->GetSession()->SendPacket(data);
            return;
        }
        case TEXT_RANGE_ZONE:
        {
            uint32 zoneId = source->GetZoneId();
            Map::PlayerList const& players = source->GetMap()->GetPlayers();
            for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                if (itr->getSource()->GetZoneId() == zoneId && (!team || Team(itr->getSource()->GetTeam()) == team) && (!gmOnly || itr->getSource()->isGameMaster()))
                    itr->getSource()->GetSession()->SendPacket(data);
            return;
        }
        case TEXT_RANGE_MAP:
        {
            Map::PlayerList const& players = source->GetMap()->GetPlayers();
            for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                if ((!team || Team(itr->getSource()->GetTeam()) == team) && (!gmOnly || itr->getSource()->isGameMaster()))
                    itr->getSource()->GetSession()->SendPacket(data);
            return;
        }
        case TEXT_RANGE_WORLD:
        {
            SessionMap const& smap = sWorld->GetAllSessions();
            for (SessionMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter)
                if (Player* player = iter->second->GetPlayer())
                    if (player->GetSession()  && (!team || Team(player->GetTeam()) == team) && (!gmOnly || player->isGameMaster()))
                        player->GetSession()->SendPacket(data);
            return;
        }
        case TEXT_RANGE_NORMAL:
        default:
            break;
    }

    source->SendMessageToSetInRange(data, dist, true);
}
コード例 #30
0
ファイル: TeamHandler.cpp プロジェクト: achoum/spring
void CTeamHandler::LoadFromSetup(const CGameSetup* setup)
{
	const bool useLuaGaia  = CLuaGaia::SetConfigString(setup->luaGaiaStr);

	activeTeams = setup->numTeams;
	activeAllyTeams = setup->numAllyTeams;

	assert(activeTeams <= MAX_TEAMS);
	assert(activeAllyTeams <= MAX_TEAMS);

	for (int i = 0; i < activeTeams; ++i) {
		// TODO: this loop body could use some more refactoring
		CTeam* team = Team(i);
		const CGameSetup::TeamData& teamStartingData = setup->teamStartingData[i];

		team->metal = setup->startMetal;
		team->metalIncome = setup->startMetal; // for the endgame statistics

		team->energy = setup->startEnergy;
		team->energyIncome = setup->startEnergy;

		float3 start(teamStartingData.startPos.x, teamStartingData.startPos.y, teamStartingData.startPos.z);
		team->StartposMessage(start, (setup->startPosType != CGameSetup::StartPos_ChooseInGame));
		std::memcpy(team->color, teamStartingData.color, 4);
		team->handicap = teamStartingData.handicap;
		team->leader = teamStartingData.leader;
		team->side = teamStartingData.side;
		SetAllyTeam(i, teamStartingData.teamAllyteam);

		if (!teamStartingData.aiDll.empty()) {
			if (teamStartingData.aiDll.substr(0, 6) == "LuaAI:") { // its a LuaAI
				team->luaAI = teamStartingData.aiDll.substr(6);
				team->isAI = true;
			}
			else { // no LuaAI
				if (setup->hostDemo) // in demo replay, we don't need AI's to load again
					team->dllAI = "";
				else {
					team->dllAI = teamStartingData.aiDll;
					team->isAI = true;
				}
			}
		}
	}

	for (int allyTeam1 = 0; allyTeam1 < activeAllyTeams; ++allyTeam1)
	{
		for (int allyTeam2 = 0; allyTeam2 < activeAllyTeams; ++allyTeam2)
			allies[allyTeam1][allyTeam2] = setup->allyStartingData[allyTeam1].allies[allyTeam2];
	}

	if (useLuaGaia) {
		// Gaia adjustments
		gaiaTeamID = activeTeams;
		gaiaAllyTeamID = activeAllyTeams;
		activeTeams++;
		activeAllyTeams++;

		// Setup the gaia team
		CTeam* team = Team(gaiaTeamID);
		team->color[0] = 255;
		team->color[1] = 255;
		team->color[2] = 255;
		team->color[3] = 255;
		team->gaia = true;
		team->StartposMessage(float3(0.0, 0.0, 0.0), true);
		//players[setup->numPlayers]->team = gaiaTeamID;
		SetAllyTeam(gaiaTeamID, gaiaAllyTeamID);
	}
}