@ -6,33 +6,28 @@
using namespace mwmp ;
unsigned int FactionFunctions : : GetFactionChangesSize ( unsigned short pid ) noexcept
void FactionFunctions : : InitializeFactionChanges ( unsigned short pid ) noexcept
{
Player * player ;
GET_PLAYER ( pid , player , 0 ) ;
GET_PLAYER ( pid , player , ) ;
return player - > factionChanges . count ;
player - > factionChanges . factions. clear ( ) ;
}
unsigned char FactionFunctions : : GetFactionChangesAction ( unsigned short pid ) noexcept
unsigned int FactionFunctions : : GetFactionChangesSize ( unsigned short pid ) noexcept
{
Player * player ;
GET_PLAYER ( pid , player , 0 ) ;
return player - > factionChanges . a cti on;
return player - > factionChanges . cou nt ;
}
void FactionFunctions : : AddFaction ( unsigned short pid , const char * factionId , unsigned int rank , bool isExpelle d) noexcept
unsigned char FactionFunctions : : GetFactionChangesAction ( unsigned short pi d) noexcept
{
Player * player ;
GET_PLAYER ( pid , player , ) ;
mwmp : : Faction faction ;
faction . factionId = factionId ;
faction . rank = rank ;
faction . isExpelled = isExpelled ;
GET_PLAYER ( pid , player , 0 ) ;
player - > factionChanges Buffer . f actions. push_back ( faction ) ;
return player - > factionChanges . action ;
}
const char * FactionFunctions : : GetFactionId ( unsigned short pid , unsigned int i ) noexcept
@ -62,16 +57,32 @@ bool FactionFunctions::GetFactionExpelledState(unsigned short pid, unsigned int
return player - > factionChanges . factions . at ( i ) . isExpelled ;
}
void FactionFunctions : : Se ndFactionChanges ( unsigned short pid ) noexcept
void FactionFunctions : : Se tFactionChangesAction ( unsigned short pid , unsigned char action ) noexcept
{
Player * player ;
GET_PLAYER ( pid , player , ) ;
player - > factionChangesBuffer . action = mwmp : : FactionChanges : : BOTH ;
player - > factionChanges . action = action ;
}
void FactionFunctions : : AddFaction ( unsigned short pid , const char * factionId , unsigned int rank , bool isExpelled ) noexcept
{
Player * player ;
GET_PLAYER ( pid , player , ) ;
mwmp : : Faction faction ;
faction . factionId = factionId ;
faction . rank = rank ;
faction . isExpelled = isExpelled ;
player - > factionChanges . factions . push_back ( faction ) ;
}
void FactionFunctions : : SendFactionChanges ( unsigned short pid , bool toOthers ) noexcept
{
Player * player ;
GET_PLAYER ( pid , player , ) ;
std : : swap ( player - > factionChanges , player - > factionChangesBuffer ) ;
mwmp : : Networking : : get ( ) . getPlayerPacketController ( ) - > GetPacket ( ID_PLAYER_FACTION ) - > setPlayer ( player ) ;
mwmp : : Networking : : get ( ) . getPlayerPacketController ( ) - > GetPacket ( ID_PLAYER_FACTION ) - > Send ( false ) ;
player - > factionChanges = std : : move ( player - > factionChangesBuffer ) ;
player - > factionChangesBuffer . factions . clear ( ) ;
mwmp : : Networking : : get ( ) . getPlayerPacketController ( ) - > GetPacket ( ID_PLAYER_FACTION ) - > Send ( toOthers ) ;
}