コード例 #1
0
//PM
void PlayerManager::ChatSendChannel(long GameID, char * Channel, char * Message)
{
    if (Message && Channel)
    {
        // Find sender's name
        Player * s = GetPlayer(GameID);
		Player * p = (0);

		char FName[40];

		GetPostFix(s, FName, 40);

        if (s)
        {
			m_Mutex.Lock();
			while (GetNextPlayerOnList(p, m_GlobalPlayerList))
			{
				if (p->Active())
				{
					p->SendClientChatEvent(0x03, 0x00, FName, FName, Channel, Message);
				}
			}
			m_Mutex.Unlock();
        }
    }
}
コード例 #2
0
ファイル: p5.cpp プロジェクト: juliekirwin/Bug-Game
//*********************************************************
SetType SetSquad(ifstream & fin, VecPlayerType & pVec,int num, MapSquadType & squadMap){
  char type;
  string pName= "";
  int pRow;
  int pCol;
  char direction;
  SetType squad;
  Player * p;
  BoardClass * bd= BoardClass::GetBd();
  
  fin>> type;
  while(type != 'q' && fin){
    fin>> pName;
    fin>> pRow;
    fin>> pCol;
    fin>> direction;
    p= CreaterPlayer(pName, type);
    bd->BoardClass::PlacePlayer(p, pRow, pCol);
    p->Active();
    p->ResetMomentum();
    p->DropWeapon();
    p->SetDir(direction);
    pVec.push_back(p);
    squad.insert(pName);
    squadMap.insert(make_pair(p->Name(), SquadType(num)));
    fin>> type;
  }
  return squad;
}
コード例 #3
0
void StaticMap::SendSoundBroadcast(long rcount)
{
    Player *p = (0);
    u32 * sector_list = m_ObjectMgr->GetSectorList();

    if (BroadcastID() == 0)
    {
        return;
    }

    ObjectEffect StationBroadcast;
	StationBroadcast.Bitmask = 0x04;
    StationBroadcast.GameID = GameID();
	StationBroadcast.EffectDescID = (short)BroadcastID();
	StationBroadcast.EffectID = BroadcastID();
	StationBroadcast.Duration = 8000;
	
    while (g_PlayerMgr->GetNextPlayerOnList(p, sector_list))
	{
        if (p && p->Active() && (p->GameID()%128 == rcount) && RangeFrom(p->Position()) < 40000.0f) 
        {
            LogDebug("Broadcasting for station %s\n", Name());
            p->SendObjectEffect(&StationBroadcast);
        }
	}
}
コード例 #4
0
//PM
void PlayerManager::ChatSendChannel(long GameID, char * Channel, char * Message)
{
    if (Message && Channel)
    {
        // Find sender's name
        Player * s = GetPlayer(GameID);
		Player * p = (0);

		char FName[40];

		GetPostFix(s, FName, 40);
		long channel_id = GetChannelFromName(Channel);

        if (s)
        {
			while (GetNextPlayerOnList(p, m_GlobalPlayerList))   
			{			
				if (p->Active() && p->IsSubscribed(channel_id))
				{
					p->SendClientChatEvent(0x03, 0x00, FName, FName, Channel, Message);
				}
			}
        }
    }
}
コード例 #5
0
bool PlayerManager::CheckAccountInUse(char *username)
{
	Player * p = (0);
    
	while (GetNextPlayerOnList(p, m_GlobalPlayerList))    
	{
		if (strncmp(p->AccountUsername(), username, 50) == 0)
		{
			if (p->Active())
			{			
				//this player's account is already active 
				//p->ForceLogout();
				//check time of last received update, if older than 30 seconds, kill the account.
				if ((p->LastAccessTime() + 30000) < GetNet7TickCount())
				{
					LogMessage("Account user %s seems to have died. Remove so they can log in again\n", username);
					DropPlayerFromGalaxy(p);
				}
				else
				{
					LogMessage("Account user %s already active, don't allow second account\n", p->AccountUsername());
					return true;
				}
			}
			else
			{
				LogMessage("Account user %s has dead player on server, remove\n", username);
				DropPlayerFromGalaxy(p);
			}
		}
    }
	return false;
}
コード例 #6
0
bool PlayerManager::CheckAccountInUse(char *username)
{
	Player * p = (0);

	while (GetNextPlayerOnList(p, m_GlobalPlayerList))
	{
		if (strncmp(p->AccountUsername(), username, 50) == 0)
		{
			if (p->Active())
			{
				//this player's account is already active
				//p->ForceLogout();
				LogMessage("Account user %s already active, don't allow second account\n", p->AccountUsername());
				return true;
			}
			else
			{
				LogMessage("Account user %s has dead player on server, remove\n", username);
				DropPlayerFromGalaxy(p);
			}
		}
    }
	return false;
}
コード例 #7
0
//PM - start at startup
void PlayerManager::RunMovementThread()
{
    Player * p = (0);
	unsigned long current_tick;
	long sleep_time;

	LogMessage("Begin move thread cycle\n");

    do
    {
		current_tick = GetNet7TickCount();

        // Run through all players sequentially and update each in turn
        m_Mutex.Lock();

		p = (0);

		while (GetNextPlayerOnList(p, m_GlobalPlayerList))
		{
            current_tick = GetNet7TickCount();
            //Handle player removal here
			if (p)
			{
				if (p->GetLoginStage() == 2)
				{
					p->SendPacketCache();
					p->HandleLoginStage2();
				}
				else if (p->IsToBeRemoved())
				{
					m_GlobMemMgr->ReleasePlayerNode(p);
					p->SetActive(false);
					LogMessage("Player %s Removed from Galaxy.\n", p->Name());
					UnSetIndex(p->GameID(), m_GlobalPlayerList);
				}
				else if ((p->LastAccessTime() + 2*60000) < current_tick )
				{
					DropPlayerFromGalaxy(p);
				}
				else if (p->Active())
				{
					if (p->InSpace())
					{
						if (p->MovementID() % 5 == 0)
						{
							p->CalcNewPosition(current_tick); //update the positions

							if (!p->DebugPlayer() && (!IS_PLAYER(p->MVASIndex()) || p->WarpDrive() || p->Following() || p->PlayerUpdateSet()) )
							{
								p->SendLocationAndSpeed(true);
							}
							else if (IS_PLAYER(p->MVASIndex()))
							{
								p->SendLocationAndSpeed(false);
							}

							if (p->ObjectIsMoving())
							{
								p->UpdateVerbs();
							}

							if (p->MovementID() % 50)
							{
								Object *obj = p->NearestNav();
								p->SetNearestNav(obj);
							}

							p->CheckObjectRanges();
							p->UpdatePlayerVisibilityList();
							p->ResetAttacksThisTick();
						}
						p->IncrementMovementID(1);
					}
					p->SendPacketCache();
					p->CheckEventTimes(current_tick);
				}
				else if (p->DebugPlayer())
				{
					if (p->MovementID() % 5 == 0)
					{
						p->SendLocationAndSpeed(false);
						p->UpdatePlayerVisibilityList();
					}
					p->IncrementMovementID(1);
				}
				else
				{
					p->SendPacketCache();
				}
			}
		}

		m_Mutex.Unlock();

		sleep_time = current_tick - GetNet7TickCount() + 100;
		if (sleep_time < 0) sleep_time = 0;
		Sleep(sleep_time);

    } while (!g_ServerShutdown);

	m_Movement_thread_running = false;
	LogMessage("Shutting down movement thread");
}
コード例 #8
0
//PM - start at startup
void PlayerManager::RunMovementThread()
{
	Player * p = (0);
	unsigned long current_tick = GetNet7TickCount();

	// Run through all players sequentially and update each in turn
	m_Mutex.Lock();

	while (GetNextPlayerOnList(p, m_GlobalPlayerList))    
	{
		//Handle player removal here 
		if (p)
		{
			if (p->GetLoginStage() == 1)
			{
				p->SetLoginStage(2);
				p->SendPacketCache();
				p->HandleLoginStage2();
			}
			else if (p->IsToBeRemoved() || (p->LastAccessTime() + 2*60000) < current_tick)
			{
				DropPlayerFromGalaxy(p);
			}
			else if (p->Active())
			{
				if (p->InSpace())
				{
					if (p->MovementID() % 5 == 0)
					{
						p->CalcNewPosition(current_tick); //update the positions

						if (!p->DebugPlayer() && (!IS_PLAYER(p->MVASIndex()) || p->WarpDrive() || p->Following() || p->PlayerUpdateSet()) ) 
						{
							p->SendLocationAndSpeed(true);
						}
						else if (IS_PLAYER(p->MVASIndex()))
						{
							p->SendLocationAndSpeed(false);
						}

						if (p->ObjectIsMoving())
						{
							p->UpdateVerbs();
						}

						if (p->MovementID() % 50)
						{
							Object *obj = p->NearestNav();
							p->SetNearestNav(obj);
						}

						p->CheckObjectRanges();
						p->UpdatePlayerVisibilityList();
						p->ResetAttacksThisTick();
					}
					p->IncrementMovementID(1);
				}
				p->SendPacketCache();
				p->CheckEventTimes(current_tick);
			}
			else if (p->DebugPlayer())
			{
				if (p->MovementID() % 5 == 0)
				{
					p->SendLocationAndSpeed(false);
					p->UpdatePlayerVisibilityList();
				}
				p->IncrementMovementID(1);
			}
			else
			{
				p->SendPacketCache();
			}
		}
	}

	m_Mutex.Unlock();
}