@ -90,7 +90,7 @@ void CFameContainer::serial(NLMISC::IStream &f)
{
{
uint32 size = _FactionInfos . size ( ) ;
uint32 size = _FactionInfos . size ( ) ;
f . serial ( size ) ;
f . serial ( size ) ;
std : : map < uint32 , TFameContainerEntry > : : iterator first ( _FactionInfos . begin ( ) ) , last ( _FactionInfos . end ( ) ) ;
std : : map < uint32 , TFameContainerEntry > : : iterator first ( _FactionInfos . begin ( ) ) , last ( _FactionInfos . end ( ) ) ;
for ( ; first ! = last ; + + first )
for ( ; first ! = last ; + + first )
{
{
@ -105,7 +105,7 @@ void CFameContainer::serial(NLMISC::IStream &f)
}
}
}
}
else
else
{
{
// serial old fame save
// serial old fame save
vector < sint32 > fames ;
vector < sint32 > fames ;
vector < sint32 > memories ;
vector < sint32 > memories ;
@ -154,9 +154,9 @@ CFameManager::CFameManager()
//array of callback items
//array of callback items
NLNET : : TUnifiedCallbackItem _cbArray [ ] =
NLNET : : TUnifiedCallbackItem _cbArray [ ] =
{
{
{ " FAME_DELTA " , cbFameDelta } ,
{ " FAME_DELTA " , cbFameDelta } ,
} ;
} ;
// register call back for fame manager
// register call back for fame manager
CUnifiedNetwork : : getInstance ( ) - > addCallbackArray ( _cbArray , sizeof ( _cbArray ) / sizeof ( _cbArray [ 0 ] ) ) ;
CUnifiedNetwork : : getInstance ( ) - > addCallbackArray ( _cbArray , sizeof ( _cbArray ) / sizeof ( _cbArray [ 0 ] ) ) ;
@ -234,7 +234,7 @@ void CFameManager::mirrorIsReady()
const static std : : string fameMemory ( " FameMemory " ) ;
const static std : : string fameMemory ( " FameMemory " ) ;
const static std : : string firstFame ( " Fame_0 " ) ;
const static std : : string firstFame ( " Fame_0 " ) ;
// Mirror.declareEntityTypeOwner( RYZOMID::guild, 5000 ); // max number of guild
// Mirror.declareEntityTypeOwner( RYZOMID::guild, 5000 ); // max number of guild
// Mirror.declareEntityTypeOwner( RYZOMID::civilisation, 10 ); // max number of civilisation
// Mirror.declareEntityTypeOwner( RYZOMID::civilisation, 10 ); // max number of civilisation
@ -245,7 +245,7 @@ void CFameManager::mirrorIsReady()
TheFameDataset . declareProperty ( civilisation , PSOReadWrite ) ;
TheFameDataset . declareProperty ( civilisation , PSOReadWrite ) ;
TheFameDataset . declareProperty ( guild , PSOReadWrite ) ;
TheFameDataset . declareProperty ( guild , PSOReadWrite ) ;
TheFameDataset . declareProperty ( fameMemory , PSOReadWrite ) ;
TheFameDataset . declareProperty ( fameMemory , PSOReadWrite ) ;
for ( uint i = 0 ; i < MAX_FACTION ; + + i )
for ( uint i = 0 ; i < MAX_FACTION ; + + i )
{
{
string propName = toString ( " Fame_%u " , i ) ;
string propName = toString ( " Fame_%u " , i ) ;
@ -305,7 +305,7 @@ void CFameManager::addPlayer(const CEntityId &playerId, const EGSPD::CFameContai
TFameOwnerWrite * fow = new TFameOwnerWrite ( TheFameDataset , entityIndex ) ;
TFameOwnerWrite * fow = new TFameOwnerWrite ( TheFameDataset , entityIndex ) ;
_FamesOwners . insert ( make_pair ( entityIndex , fow ) ) ;
_FamesOwners . insert ( make_pair ( entityIndex , fow ) ) ;
fow - > FameMemory = memoryIndex ;
fow - > FameMemory = memoryIndex ;
// restore the fame value
// restore the fame value
for ( map < CSheetId , EGSPD : : CFameContainerEntryPD > : : const_iterator it = fameContainer . getEntriesBegin ( ) ; it ! = fameContainer . getEntriesEnd ( ) ; + + it )
for ( map < CSheetId , EGSPD : : CFameContainerEntryPD > : : const_iterator it = fameContainer . getEntriesBegin ( ) ; it ! = fameContainer . getEntriesEnd ( ) ; + + it )
{
{
@ -331,7 +331,7 @@ void CFameManager::addPlayer(const CEntityId &playerId, const EGSPD::CFameContai
// fow->Fames[faction] = CStaticFames::getInstance().getStaticFameIndexed(PVP_CLAN::getFactionIndex(playerRace), faction);
// fow->Fames[faction] = CStaticFames::getInstance().getStaticFameIndexed(PVP_CLAN::getFactionIndex(playerRace), faction);
}
}
}
}
fow - > LastGuildStatusChange = fameContainer . getLastGuildStatusChange ( ) ;
fow - > LastGuildStatusChange = fameContainer . getLastGuildStatusChange ( ) ;
/// update the guild memory
/// update the guild memory
updatePlayerFame ( entityIndex ) ;
updatePlayerFame ( entityIndex ) ;
@ -393,7 +393,7 @@ void CFameManager::savePlayerFame(const NLMISC::CEntityId &playerId, EGSPD::CFam
EGS_PD_AST ( entry ) ;
EGS_PD_AST ( entry ) ;
entry - > setFameMemory ( it - > second - > Fames [ i ] ) ;
entry - > setFameMemory ( it - > second - > Fames [ i ] ) ;
}
}
// fameContainer._FamesMemory.resize(MAX_FACTION);
// fameContainer._FamesMemory.resize(MAX_FACTION);
// for (uint i=0; i<MAX_FACTION; ++i)
// for (uint i=0; i<MAX_FACTION; ++i)
// fameContainer._FamesMemory[i] = it->second->Fames[i];
// fameContainer._FamesMemory[i] = it->second->Fames[i];
@ -412,6 +412,7 @@ void CFameManager::savePlayerFame(const NLMISC::CEntityId &playerId, EGSPD::CFam
if ( entry = = NULL )
if ( entry = = NULL )
entry = fameContainer . addToEntries ( id ) ;
entry = fameContainer . addToEntries ( id ) ;
EGS_PD_AST ( entry ) ;
EGS_PD_AST ( entry ) ;
nlinfo ( " %d : %d " , it - > second - > Fames [ i ] ) ;
entry - > setFame ( it - > second - > Fames [ i ] ) ;
entry - > setFame ( it - > second - > Fames [ i ] ) ;
entry - > setLastFameChangeTrend ( fow - > LastFameChangeTrends [ i ] ) ;
entry - > setLastFameChangeTrend ( fow - > LastFameChangeTrends [ i ] ) ;
}
}
@ -578,7 +579,7 @@ void CFameManager::saveGuildFame(const NLMISC::CEntityId &guildId, EGSPD::CFameC
entry - > setLastFameChangeTrend ( it - > second - > LastFameChangeTrends [ i ] ) ;
entry - > setLastFameChangeTrend ( it - > second - > LastFameChangeTrends [ i ] ) ;
}
}
}
}
// fameContainer._Fames.resize(MAX_FACTION);
// fameContainer._Fames.resize(MAX_FACTION);
// fameContainer._Fames[i] = it->second->Fames[i];
// fameContainer._Fames[i] = it->second->Fames[i];
}
}
@ -629,7 +630,7 @@ void CFameManager::removeGuild(const CEntityId &guildId)
void CFameManager : : setGuildCivilisation ( const NLMISC : : CEntityId & guildId , EGSPD : : CPeople : : TPeople civilisation )
void CFameManager : : setGuildCivilisation ( const NLMISC : : CEntityId & guildId , EGSPD : : CPeople : : TPeople civilisation )
{
{
TDataSetRow guildIndex = TheFameDataset . getDataSetRow ( guildId ) ;
TDataSetRow guildIndex = TheFameDataset . getDataSetRow ( guildId ) ;
// check if the civ exists
// check if the civ exists
uint8 id = EGSPD : : getCivilisationId ( civilisation ) ;
uint8 id = EGSPD : : getCivilisationId ( civilisation ) ;
if ( id = = 0xFF )
if ( id = = 0xFF )
@ -639,14 +640,14 @@ void CFameManager::setGuildCivilisation( const NLMISC::CEntityId & guildId, EGSP
}
}
CEntityId civId ( RYZOMID : : civilisation , id ) ;
CEntityId civId ( RYZOMID : : civilisation , id ) ;
TDataSetRow civIndex = TheFameDataset . getDataSetRow ( civId ) ;
TDataSetRow civIndex = TheFameDataset . getDataSetRow ( civId ) ;
TFameContainer : : iterator it = _FamesOwners . find ( civIndex ) ;
TFameContainer : : iterator it = _FamesOwners . find ( civIndex ) ;
if ( it = = _FamesOwners . end ( ) )
if ( it = = _FamesOwners . end ( ) )
{
{
nlwarning ( " FAME:setPlayerCivilisation-> unknown civ eId %s " , civId . toString ( ) . c_str ( ) , id ) ;
nlwarning ( " FAME:setPlayerCivilisation-> unknown civ eId %s " , civId . toString ( ) . c_str ( ) , id ) ;
return ;
return ;
}
}
// check if the player exists
// check if the player exists
it = _FamesOwners . find ( guildIndex ) ;
it = _FamesOwners . find ( guildIndex ) ;
if ( it = = _FamesOwners . end ( ) )
if ( it = = _FamesOwners . end ( ) )
@ -675,7 +676,7 @@ void CFameManager::setPlayerCivilisation( const NLMISC::CEntityId & playerId, EG
}
}
CEntityId civId ( RYZOMID : : civilisation , id ) ;
CEntityId civId ( RYZOMID : : civilisation , id ) ;
TDataSetRow civIndex = TheFameDataset . getDataSetRow ( civId ) ;
TDataSetRow civIndex = TheFameDataset . getDataSetRow ( civId ) ;
TFameContainer : : iterator it = _FamesOwners . find ( civIndex ) ;
TFameContainer : : iterator it = _FamesOwners . find ( civIndex ) ;
if ( it = = _FamesOwners . end ( ) )
if ( it = = _FamesOwners . end ( ) )
{
{
@ -795,7 +796,7 @@ void CFameManager::cbFameDelta( NLNET::CMessage& msgin, const std::string &servi
msgin . serial ( propagate ) ;
msgin . serial ( propagate ) ;
getInstance ( ) . addFameIndexed ( entityId , faction , deltaFame , serviceName , propagate ) ;
getInstance ( ) . addFameIndexed ( entityId , faction , deltaFame , serviceName , propagate ) ;
// We don't inform the client right now, the timer will take care of this
// We don't inform the client right now, the timer will take care of this
//character->sendEventForMissionAvailabilityCheck();
//character->sendEventForMissionAvailabilityCheck();
}
}
@ -841,7 +842,7 @@ void CFameManager::addFameIndexed(const CEntityId &entityId, uint32 faction, sin
CCharacter * character = PlayerManager . getChar ( entityId ) ;
CCharacter * character = PlayerManager . getChar ( entityId ) ;
bool isMarauder = ( character & & character - > getOrganization ( ) = = 5 ) ;
bool isMarauder = ( character & & character - > getOrganization ( ) = = 5 ) ;
if ( fame = = NO_FAME )
if ( fame = = NO_FAME )
{
{
if ( character )
if ( character )
@ -872,10 +873,10 @@ void CFameManager::addFameIndexed(const CEntityId &entityId, uint32 faction, sin
if ( realDeltaFame > 3 * 6000 )
if ( realDeltaFame > 3 * 6000 )
realDeltaFame = 3 * 6000 ;
realDeltaFame = 3 * 6000 ;
if ( realDeltaFame < - 3 * 6000 )
if ( realDeltaFame < - 3 * 6000 )
realDeltaFame = - 3 * 6000 ;
realDeltaFame = - 3 * 6000 ;
if ( ! isMarauder & & realDeltaFame < 0 )
if ( ! isMarauder & & realDeltaFame < 0 )
realDeltaFame / = 10 ;
realDeltaFame / = 10 ;
@ -895,13 +896,13 @@ void CFameManager::addFameIndexed(const CEntityId &entityId, uint32 faction, sin
entityId . toString ( ) . c_str ( ) ,
entityId . toString ( ) . c_str ( ) ,
sint32 ( fame ) ) ;
sint32 ( fame ) ) ;
// just update one player DB
// just update one player DB
// retreive the char info
// retreive the char info
CCharacter * c = PlayerManager . getChar ( entityId ) ;
CCharacter * c = PlayerManager . getChar ( entityId ) ;
// See if still qualify to have declaration
// See if still qualify to have declaration
if ( c )
if ( c )
{
{
// Bound the fame based on current allegiance.
// Bound the fame based on current allegiance.
sint32 maxFame = getMaxFameByFactionIndex ( c - > getAllegiance ( ) , faction) ;
sint32 maxFame = getMaxFameByFactionIndex ( c - > getAllegiance ( ) , c- > getOrganization ( ) , faction) ;
clamp ( fame , FameAbsoluteMin , maxFame ) ;
clamp ( fame , FameAbsoluteMin , maxFame ) ;
// Check to make sure player still qualifies to be in declared allegiances.
// Check to make sure player still qualifies to be in declared allegiances.
c - > verifyClanAllegiance ( PVP_CLAN : : getClanFromIndex ( faction ) , sint32 ( fame ) ) ;
c - > verifyClanAllegiance ( PVP_CLAN : : getClanFromIndex ( faction ) , sint32 ( fame ) ) ;
@ -932,7 +933,7 @@ void CFameManager::addFameIndexed(const CEntityId &entityId, uint32 faction, sin
if ( g )
if ( g )
{
{
// Bound the fame based on current allegiance.
// Bound the fame based on current allegiance.
sint32 maxFame = getMaxFameByFactionIndex ( g - > getAllegiance ( ) , faction ) ;
sint32 maxFame = getMaxFameByFactionIndex ( g - > getAllegiance ( ) , 0 , faction ) ;
clamp ( fame , FameAbsoluteMin , maxFame ) ;
clamp ( fame , FameAbsoluteMin , maxFame ) ;
g - > verifyClanAllegiance ( PVP_CLAN : : getClanFromIndex ( faction ) , sint32 ( fame ) ) ;
g - > verifyClanAllegiance ( PVP_CLAN : : getClanFromIndex ( faction ) , sint32 ( fame ) ) ;
g - > setFameValueGuild ( faction , sint32 ( fame ) , maxFame , fow . LastFameChangeTrends [ faction ] ) ;
g - > setFameValueGuild ( faction , sint32 ( fame ) , maxFame , fow . LastFameChangeTrends [ faction ] ) ;
@ -957,7 +958,7 @@ void CFameManager::addFameIndexed(const CEntityId &entityId, uint32 faction, sin
{
{
gf = fi . getFameIndexed ( TheFameDataset . getEntityId ( fow - > Guild ( ) ) , faction , false , true ) ;
gf = fi . getFameIndexed ( TheFameDataset . getEntityId ( fow - > Guild ( ) ) , faction , false , true ) ;
}
}
nldebug ( " FAME: Updating guild fame for entityId %s as G:%d " ,
nldebug ( " FAME: Updating guild fame for entityId %s as G:%d " ,
entityId . toString ( ) . c_str ( ) ,
entityId . toString ( ) . c_str ( ) ,
sint32 ( fame ) ) ;
sint32 ( fame ) ) ;
@ -1088,7 +1089,7 @@ sint32 CFameManager::getFameIndexed(const CEntityId &entityId, uint32 factionInd
else
else
fame = 0 ;
fame = 0 ;
}
}
// clamp fame upper bound to neutral max if entity is declared as "None"
// clamp fame upper bound to neutral max if entity is declared as "None"
if ( character )
if ( character )
{
{
@ -1238,7 +1239,7 @@ void CFameManager::setEntityFame(const NLMISC::CEntityId & entityId, uint32 fact
{
{
nldebug ( " FAME: set fame for character %s as P:%d " , entityId . toString ( ) . c_str ( ) , fame ) ;
nldebug ( " FAME: set fame for character %s as P:%d " , entityId . toString ( ) . c_str ( ) , fame ) ;
sint32 maxFame = getMaxFameByFactionIndex ( ch - > getAllegiance ( ) , faction) ;
sint32 maxFame = getMaxFameByFactionIndex ( ch - > getAllegiance ( ) , ch- > getOrganization ( ) , faction) ;
ch - > setFameValuePlayer ( faction , fame , maxFame , fow . LastFameChangeTrends [ faction ] ) ;
ch - > setFameValuePlayer ( faction , fame , maxFame , fow . LastFameChangeTrends [ faction ] ) ;
/*
/*
@ -1252,10 +1253,10 @@ void CFameManager::setEntityFame(const NLMISC::CEntityId & entityId, uint32 fact
else
else
CCharacter : : sendDynamicSystemMessage ( ch - > getEntityRowId ( ) , " FAME_LOST_CHAR " , params ) ;
CCharacter : : sendDynamicSystemMessage ( ch - > getEntityRowId ( ) , " FAME_LOST_CHAR " , params ) ;
*/
*/
}
}
else if ( gu )
else if ( gu )
{
{
sint32 maxFame = getMaxFameByFactionIndex ( gu - > getAllegiance ( ) , faction ) ;
sint32 maxFame = getMaxFameByFactionIndex ( gu - > getAllegiance ( ) , 0 , faction ) ;
gu - > setFameValueGuild ( faction , fame , maxFame , fow . LastFameChangeTrends [ faction ] ) ;
gu - > setFameValueGuild ( faction , fame , maxFame , fow . LastFameChangeTrends [ faction ] ) ;
}
}
else
else
@ -1279,8 +1280,20 @@ sint32 CFameManager::getStartFame(PVP_CLAN::TPVPClan playerClan, PVP_CLAN::TPVPC
}
}
// - getMaxFameByClan: playerClan must be Neutral or the same type (Cult or Clan) as targetClan, targetClan must be any non-neutral clan.
// - getMaxFameByClan: playerClan must be Neutral or the same type (Cult or Clan) as targetClan, targetClan must be any non-neutral clan.
sint32 CFameManager : : getMaxFameByClan ( std : : pair < PVP_CLAN : : TPVPClan , PVP_CLAN : : TPVPClan > playerClans , PVP_CLAN: : TPVPClan targetClan )
sint32 CFameManager : : getMaxFameByClan ( std : : pair < PVP_CLAN : : TPVPClan , PVP_CLAN : : TPVPClan > playerClans , uint32 organization , PVP_CLAN: : TPVPClan targetClan )
{
{
if ( targetClan = = PVP_CLAN : : Marauder )
{
if ( organization = = 5 )
return 100 * kFameMultipler ;
return 30 * kFameMultipler ;
}
if ( organization = = 5 ) // marauder
{
return - 30 * kFameMultipler ;
}
// Local variables for the lookup values.
// Local variables for the lookup values.
int playerLookup , targetLookup ;
int playerLookup , targetLookup ;
@ -1337,25 +1350,26 @@ sint32 CFameManager::getMaxFameByClan(std::pair<PVP_CLAN::TPVPClan, PVP_CLAN::TP
}
}
}
}
// Wasn't caught above, probably a tribe. Return a default value.
// Wasn't caught above, probably a tribe. Return a default value.
return FameMaxDefault ;
return FameMaxDefault ;
}
}
sint32 CFameManager : : getMaxFameByFactionIndex ( std : : pair < PVP_CLAN : : TPVPClan , PVP_CLAN : : TPVPClan > allegiance , uint32 factionIndex)
sint32 CFameManager : : getMaxFameByFactionIndex ( std : : pair < PVP_CLAN : : TPVPClan , PVP_CLAN : : TPVPClan > allegiance , uint32 organization, uint32 factionIndex)
{
{
PVP_CLAN : : TPVPClan pvpClan ;
PVP_CLAN : : TPVPClan pvpClan ;
// try first with a clan
// try first with a clan
pvpClan = PVP_CLAN : : getClanFromIndex ( factionIndex ) ;
pvpClan = PVP_CLAN : : getClanFromIndex ( factionIndex ) ;
if ( pvpClan ! = PVP_CLAN : : Unknown )
if ( pvpClan ! = PVP_CLAN : : Unknown )
return getMaxFameByClan ( allegiance , pvpClan) ;
return getMaxFameByClan ( allegiance , organization, pvpClan) ;
// search for tribe
// search for tribe
else
else
{
{
// No allegiance? => Max
// No allegiance? => Max
if ( allegiance . first = = PVP_CLAN : : None | | allegiance . second = = PVP_CLAN : : None )
if ( allegiance . first = = PVP_CLAN : : None | | allegiance . second = = PVP_CLAN : : None )
return FameAbsoluteMax ;
return FameAbsoluteMax ;
// look up in the tribe threshold clamp array
// look up in the tribe threshold clamp array
const vector < CStaticFames : : CTribeCultThresholdPerCiv > & tribeThres = CStaticFames : : getInstance ( ) . getTribeThresholdVector ( ) ;
const vector < CStaticFames : : CTribeCultThresholdPerCiv > & tribeThres = CStaticFames : : getInstance ( ) . getTribeThresholdVector ( ) ;
if ( tribeThres . empty ( ) )
if ( tribeThres . empty ( ) )
@ -1370,45 +1384,54 @@ sint32 CFameManager::getMaxFameByFactionIndex(std::pair<PVP_CLAN::TPVPClan, PVP_
if ( ttIndex > = tribeThres . size ( ) )
if ( ttIndex > = tribeThres . size ( ) )
return FameMaxDefault ;
return FameMaxDefault ;
// get the
// get the
const CStaticFames : : CTribeCultThreshold * tc = 0 ;
const CStaticFames : : CTribeCultThreshold * tc = 0 ;
switch( allegiance . second )
if ( organization = = 5 ) // marauder
{
{
case PVP_CLAN : : Matis :
tc = & tribeThres [ ttIndex ] . Marauder ;
tc = & tribeThres [ ttIndex ] . Matis ;
return tc - > getMarauder ( ) ;
break ;
case PVP_CLAN : : Fyros :
tc = & tribeThres [ ttIndex ] . Fyros ;
break ;
case PVP_CLAN : : Tryker :
tc = & tribeThres [ ttIndex ] . Tryker ;
break ;
case PVP_CLAN : : Zorai :
tc = & tribeThres [ ttIndex ] . Zorai ;
break ;
case PVP_CLAN : : Neutral :
tc = & tribeThres [ ttIndex ] . Neutral ;
break ;
default :
//nlwarning("Character %s have bad civilization allegiance...'%d/%s' !", entityId.toString().c_str(), allegiance.second, PVP_CLAN::toString(allegiance.second).c_str());
return FameMaxDefault ;
}
}
else
switch ( allegiance . first )
{
{
case PVP_CLAN : : Kami :
return tc - > getKami ( ) ;
switch ( allegiance . second )
break ;
{
case PVP_CLAN : : Karavan :
case PVP_CLAN : : Matis :
return tc - > getKaravan ( ) ;
tc = & tribeThres [ ttIndex ] . Matis ;
break ;
break ;
case PVP_CLAN : : Neutral :
case PVP_CLAN : : Fyros :
return tc - > getNeutral ( ) ;
tc = & tribeThres [ ttIndex ] . Fyros ;
break ;
break ;
default :
case PVP_CLAN : : Tryker :
//nlwarning("Character %s have bad cult allegiance...'%d/%s' !", entityId.toString().c_str(), allegiance.first, PVP_CLAN::toString(allegiance.first).c_str());
tc = & tribeThres [ ttIndex ] . Tryker ;
return FameMaxDefault ;
break ;
case PVP_CLAN : : Zorai :
tc = & tribeThres [ ttIndex ] . Zorai ;
break ;
case PVP_CLAN : : Neutral :
tc = & tribeThres [ ttIndex ] . Neutral ;
break ;
default :
//nlwarning("Character %s have bad civilization allegiance...'%d/%s' !", entityId.toString().c_str(), allegiance.second, PVP_CLAN::toString(allegiance.second).c_str());
return FameMaxDefault ;
}
switch ( allegiance . first )
{
case PVP_CLAN : : Kami :
return tc - > getKami ( ) ;
break ;
case PVP_CLAN : : Karavan :
return tc - > getKaravan ( ) ;
break ;
case PVP_CLAN : : Neutral :
return tc - > getNeutral ( ) ;
break ;
default :
//nlwarning("Character %s have bad cult allegiance...'%d/%s' !", entityId.toString().c_str(), allegiance.first, PVP_CLAN::toString(allegiance.first).c_str());
return FameMaxDefault ;
}
}
}
}
}
}
}
@ -1433,7 +1456,7 @@ void CFameManager::doInitTribeThresholdIndex()
}
}
void CFameManager : : enforceFameCaps ( const NLMISC : : CEntityId & entityId , std: : pair < PVP_CLAN : : TPVPClan , PVP_CLAN : : TPVPClan > allegiance )
void CFameManager : : enforceFameCaps ( const NLMISC : : CEntityId & entityId , uint32 organization , std: : pair < PVP_CLAN : : TPVPClan , PVP_CLAN : : TPVPClan > allegiance )
{
{
const TDataSetRow rowId = TheFameDataset . getDataSetRow ( entityId ) ;
const TDataSetRow rowId = TheFameDataset . getDataSetRow ( entityId ) ;
TFameContainer : : iterator it = _FamesOwners . find ( rowId ) ;
TFameContainer : : iterator it = _FamesOwners . find ( rowId ) ;
@ -1464,6 +1487,51 @@ void CFameManager::enforceFameCaps(const NLMISC::CEntityId &entityId, std::pair<
sint32 fame ;
sint32 fame ;
sint32 maxFame ;
sint32 maxFame ;
if ( organization = = 5 ) // marauder
{
for ( int looper = PVP_CLAN : : BeginCults ; looper < = PVP_CLAN : : EndCults ; looper + + )
{
theFactionIndex = PVP_CLAN : : getFactionIndex ( ( PVP_CLAN : : TPVPClan ) looper ) ;
fame = fow . Fames [ theFactionIndex ] ;
maxFame = - 30 * kFameMultipler ;
if ( fame ! = NO_FAME )
{
clamp ( fame , FameAbsoluteMin , maxFame ) ;
fow . Fames [ theFactionIndex ] = fame ;
}
if ( ch )
{
ch - > setFameValuePlayer ( theFactionIndex , fame , maxFame , fow . LastFameChangeTrends [ theFactionIndex ] ) ;
}
if ( gu )
{
gu - > setFameValueGuild ( theFactionIndex , fame , maxFame , fow . LastFameChangeTrends [ theFactionIndex ] ) ;
}
}
for ( int looper = PVP_CLAN : : BeginCivs ; looper < = PVP_CLAN : : EndCivs ; looper + + )
{
theFactionIndex = PVP_CLAN : : getFactionIndex ( ( PVP_CLAN : : TPVPClan ) looper ) ;
fame = fow . Fames [ theFactionIndex ] ;
maxFame = - 30 * kFameMultipler ;
if ( fame ! = NO_FAME )
{
clamp ( fame , FameAbsoluteMin , maxFame ) ;
fow . Fames [ theFactionIndex ] = fame ;
}
if ( ch )
{
ch - > setFameValuePlayer ( theFactionIndex , fame , maxFame , fow . LastFameChangeTrends [ theFactionIndex ] ) ;
}
if ( gu )
{
gu - > setFameValueGuild ( theFactionIndex , fame , maxFame , fow . LastFameChangeTrends [ theFactionIndex ] ) ;
}
}
return ;
}
// Check cults, first member of allegiance
// Check cults, first member of allegiance
PVP_CLAN : : TPVPClan theCult = allegiance . first ;
PVP_CLAN : : TPVPClan theCult = allegiance . first ;
if ( theCult ! = PVP_CLAN : : None )
if ( theCult ! = PVP_CLAN : : None )
@ -1472,7 +1540,7 @@ void CFameManager::enforceFameCaps(const NLMISC::CEntityId &entityId, std::pair<
{
{
theFactionIndex = PVP_CLAN : : getFactionIndex ( ( PVP_CLAN : : TPVPClan ) looper ) ;
theFactionIndex = PVP_CLAN : : getFactionIndex ( ( PVP_CLAN : : TPVPClan ) looper ) ;
fame = fow . Fames [ theFactionIndex ] ;
fame = fow . Fames [ theFactionIndex ] ;
maxFame = getMaxFameByClan ( allegiance , ( PVP_CLAN : : TPVPClan ) looper ) ;
maxFame = getMaxFameByClan ( allegiance , organization , ( PVP_CLAN : : TPVPClan ) looper ) ;
if ( fame ! = NO_FAME )
if ( fame ! = NO_FAME )
{
{
clamp ( fame , FameAbsoluteMin , maxFame ) ;
clamp ( fame , FameAbsoluteMin , maxFame ) ;
@ -1496,12 +1564,12 @@ void CFameManager::enforceFameCaps(const NLMISC::CEntityId &entityId, std::pair<
{
{
theFactionIndex = PVP_CLAN : : getFactionIndex ( ( PVP_CLAN : : TPVPClan ) looper ) ;
theFactionIndex = PVP_CLAN : : getFactionIndex ( ( PVP_CLAN : : TPVPClan ) looper ) ;
fame = fow . Fames [ theFactionIndex ] ;
fame = fow . Fames [ theFactionIndex ] ;
maxFame = getMaxFameByClan ( allegiance , ( PVP_CLAN : : TPVPClan ) looper ) ;
maxFame = getMaxFameByClan ( allegiance , organization , ( PVP_CLAN : : TPVPClan ) looper ) ;
if ( fame ! = NO_FAME )
if ( fame ! = NO_FAME )
{
{
clamp ( fame , FameAbsoluteMin , maxFame ) ;
clamp ( fame , FameAbsoluteMin , maxFame ) ;
fow . Fames [ theFactionIndex ] = fame ;
fow . Fames [ theFactionIndex ] = fame ;
}
}
if ( ch )
if ( ch )
{
{
ch - > setFameValuePlayer ( theFactionIndex , fame , maxFame , fow . LastFameChangeTrends [ theFactionIndex ] ) ;
ch - > setFameValuePlayer ( theFactionIndex , fame , maxFame , fow . LastFameChangeTrends [ theFactionIndex ] ) ;
@ -1514,7 +1582,7 @@ void CFameManager::enforceFameCaps(const NLMISC::CEntityId &entityId, std::pair<
}
}
}
}
void CFameManager : : setAndEnforceTribeFameCap ( const NLMISC : : CEntityId & entityId , std: : pair < PVP_CLAN : : TPVPClan , PVP_CLAN : : TPVPClan > allegiance )
void CFameManager : : setAndEnforceTribeFameCap ( const NLMISC : : CEntityId & entityId , uint32 organization , std: : pair < PVP_CLAN : : TPVPClan , PVP_CLAN : : TPVPClan > allegiance )
{
{
const TDataSetRow rowId = TheFameDataset . getDataSetRow ( entityId ) ;
const TDataSetRow rowId = TheFameDataset . getDataSetRow ( entityId ) ;
TFameContainer : : iterator it = _FamesOwners . find ( rowId ) ;
TFameContainer : : iterator it = _FamesOwners . find ( rowId ) ;
@ -1550,45 +1618,53 @@ void CFameManager::setAndEnforceTribeFameCap(const NLMISC::CEntityId &entityId,
for ( vector < CStaticFames : : CTribeCultThresholdPerCiv > : : const_iterator it = CStaticFames : : getInstance ( ) . getTribeThresholdVector ( ) . begin ( ) ; it ! = CStaticFames : : getInstance ( ) . getTribeThresholdVector ( ) . end ( ) ; + + it )
for ( vector < CStaticFames : : CTribeCultThresholdPerCiv > : : const_iterator it = CStaticFames : : getInstance ( ) . getTribeThresholdVector ( ) . begin ( ) ; it ! = CStaticFames : : getInstance ( ) . getTribeThresholdVector ( ) . end ( ) ; + + it )
{
{
theFactionIndex = ( * it ) . FameIndex ;
theFactionIndex = ( * it ) . FameIndex ;
switch( allegiance . second )
if ( organization = = 5 ) // marauder
{
{
case PVP_CLAN : : Matis :
tc = & ( * it ) . Marauder ;
tc = & ( * it ) . Matis ;
threshold = tc - > getMarauder ( ) ;
break ;
case PVP_CLAN : : Fyros :
tc = & ( * it ) . Fyros ;
break ;
case PVP_CLAN : : Tryker :
tc = & ( * it ) . Tryker ;
break ;
case PVP_CLAN : : Zorai :
tc = & ( * it ) . Zorai ;
break ;
case PVP_CLAN : : Neutral :
tc = & ( * it ) . Neutral ;
break ;
default :
nlwarning ( " Character %s have bad civilization allegiance...'%d/%s' ! " , entityId . toString ( ) . c_str ( ) , allegiance . second , PVP_CLAN : : toString ( allegiance . second ) . c_str ( ) ) ;
return ;
}
}
else
switch ( allegiance . first )
{
{
case PVP_CLAN : : Kami :
switch ( allegiance . second )
threshold = tc - > getKami ( ) ;
{
break ;
case PVP_CLAN : : Matis :
case PVP_CLAN : : Karavan :
tc = & ( * it ) . Matis ;
threshold = tc - > getKaravan ( ) ;
break ;
break ;
case PVP_CLAN : : Fyros :
case PVP_CLAN : : Neutral :
tc = & ( * it ) . Fyros ;
threshold = tc - > getNeutral ( ) ;
break ;
break ;
case PVP_CLAN : : Tryker :
default :
tc = & ( * it ) . Tryker ;
nlwarning ( " Character %s have bad cult allegiance...'%d/%s' ! " , entityId . toString ( ) . c_str ( ) , allegiance . first , PVP_CLAN : : toString ( allegiance . first ) . c_str ( ) ) ;
break ;
return ;
case PVP_CLAN : : Zorai :
tc = & ( * it ) . Zorai ;
break ;
case PVP_CLAN : : Neutral :
tc = & ( * it ) . Neutral ;
break ;
default :
nlwarning ( " Character %s have bad civilization allegiance...'%d/%s' ! " , entityId . toString ( ) . c_str ( ) , allegiance . second , PVP_CLAN : : toString ( allegiance . second ) . c_str ( ) ) ;
return ;
}
switch ( allegiance . first )
{
case PVP_CLAN : : Kami :
threshold = tc - > getKami ( ) ;
break ;
case PVP_CLAN : : Karavan :
threshold = tc - > getKaravan ( ) ;
break ;
case PVP_CLAN : : Neutral :
threshold = tc - > getNeutral ( ) ;
break ;
default :
nlwarning ( " Character %s have bad cult allegiance...'%d/%s' ! " , entityId . toString ( ) . c_str ( ) , allegiance . first , PVP_CLAN : : toString ( allegiance . first ) . c_str ( ) ) ;
return ;
}
}
}
fame = fow . Fames [ theFactionIndex ] ;
fame = fow . Fames [ theFactionIndex ] ;
if ( fame ! = NO_FAME )
if ( fame ! = NO_FAME )
{
{
@ -1618,10 +1694,10 @@ void CFameManager::thresholdChanged(NLMISC::IVariable &var)
// TDataSetRow index;
// TDataSetRow index;
// if ( Mirror.mirrorIsReady() )
// if ( Mirror.mirrorIsReady() )
// index = TheFameDataset.getDataSetRow(eId);
// index = TheFameDataset.getDataSetRow(eId);
//
//
// std::string name;
// std::string name;
// uint32 value;
// uint32 value;
//
//
// f.xmlPush("fames");
// f.xmlPush("fames");
//
//
// if ( f.isReading() )
// if ( f.isReading() )
@ -1644,13 +1720,13 @@ void CFameManager::thresholdChanged(NLMISC::IVariable &var)
// }
// }
// else
// else
// {
// {
// const std::vector<NLMISC::TStringId> & fameIds = CStaticFames::getInstance().getFactionNames();
// const std::vector<NLMISC::TStringId> & fameIds = CStaticFames::getInstance().getFactionNames();
// uint32 size = fameIds.size();
// uint32 size = fameIds.size();
//
//
// f.xmlPush("size");
// f.xmlPush("size");
// f.serial(size);
// f.serial(size);
// f.xmlPop();
// f.xmlPop();
//
//
// for (uint i = 0; i < size; i++ )
// for (uint i = 0; i < size; i++ )
// {
// {
// std::string name = CStringMapper::unmap( fameIds[i] );
// std::string name = CStringMapper::unmap( fameIds[i] );
@ -1777,8 +1853,8 @@ void CFameManager::updateFameTrend(const TDataSetRow &entityIndex)
CCharacter * character = PlayerManager . getChar ( eid ) ;
CCharacter * character = PlayerManager . getChar ( eid ) ;
if ( character = = NULL )
if ( character = = NULL )
{
{
nlwarning ( " Can't find character '%s' (from fame row index %u) in player manager ! " ,
nlwarning ( " Can't find character '%s' (from fame row index %u) in player manager ! " ,
eid . toString ( ) . c_str ( ) ,
eid . toString ( ) . c_str ( ) ,
entityIndex . toString ( ) . c_str ( ) ) ;
entityIndex . toString ( ) . c_str ( ) ) ;
return ;
return ;
}
}
@ -1788,8 +1864,8 @@ void CFameManager::updateFameTrend(const TDataSetRow &entityIndex)
CGuild * guild = CGuildManager : : getInstance ( ) - > getGuildFromId ( ( uint32 ) ( eid . getShortId ( ) ) ) ;
CGuild * guild = CGuildManager : : getInstance ( ) - > getGuildFromId ( ( uint32 ) ( eid . getShortId ( ) ) ) ;
if ( guild = = NULL )
if ( guild = = NULL )
{
{
nlwarning ( " Can't find guild '%s' (from fame row index %u) in guild manager ! " ,
nlwarning ( " Can't find guild '%s' (from fame row index %u) in guild manager ! " ,
eid . toString ( ) . c_str ( ) ,
eid . toString ( ) . c_str ( ) ,
entityIndex . toString ( ) . c_str ( ) ) ;
entityIndex . toString ( ) . c_str ( ) ) ;
return ;
return ;
}
}
@ -1803,7 +1879,7 @@ void CFameManager::updatePlayerFame(const TDataSetRow &playerIndex)
CCharacter * character = NULL ;
CCharacter * character = NULL ;
TFameContainer : : iterator it ( _FamesOwners . find ( playerIndex ) ) ;
TFameContainer : : iterator it ( _FamesOwners . find ( playerIndex ) ) ;
double alpha = 1.0f ;
double alpha = 1.0f ;
if ( it = = _FamesOwners . end ( ) )
if ( it = = _FamesOwners . end ( ) )
{
{
@ -1843,7 +1919,7 @@ void CFameManager::updatePlayerFame(const TDataSetRow &playerIndex)
TheFameDataset . getEntityId ( playerIndex ) . toString ( ) . c_str ( ) ) ;
TheFameDataset . getEntityId ( playerIndex ) . toString ( ) . c_str ( ) ) ;
return ;
return ;
}
}
TFameOwnerWrite * guildFame = it - > second ;
TFameOwnerWrite * guildFame = it - > second ;
if ( now - fow - > LastGuildStatusChange > FameMemoryInterpolation )
if ( now - fow - > LastGuildStatusChange > FameMemoryInterpolation )
@ -1865,7 +1941,7 @@ void CFameManager::updatePlayerFame(const TDataSetRow &playerIndex)
for ( uint i = 0 ; i < MAX_FACTION ; + + i )
for ( uint i = 0 ; i < MAX_FACTION ; + + i )
{
{
sint32 gf = guildFame - > Fames [ i ] ;
sint32 gf = guildFame - > Fames [ i ] ;
sint32 hf = fow - > LastGuildFame [ i ] ;
sint32 hf = fow - > LastGuildFame [ i ] ;
if ( gf = = NO_FAME & & hf = = NO_FAME )
if ( gf = = NO_FAME & & hf = = NO_FAME )
@ -2022,7 +2098,7 @@ NLMISC_COMMAND (declareCharacterCult, "Make character declare a specific cult.",
// Second argument is a clan.
// Second argument is a clan.
PVP_CLAN : : TPVPClan theClan = PVP_CLAN : : fromString ( args [ 1 ] ) ;
PVP_CLAN : : TPVPClan theClan = PVP_CLAN : : fromString ( args [ 1 ] ) ;
if ( theClan = = PVP_CLAN : : Unknown )
if ( theClan = = PVP_CLAN : : Unknown )
{
{
log . displayNL ( " Invalid clan name specified. " ) ;
log . displayNL ( " Invalid clan name specified. " ) ;
@ -2059,7 +2135,7 @@ NLMISC_COMMAND (declareCharacterCiv, "Make character declare a specific civiliza
// Second argument is a clan.
// Second argument is a clan.
PVP_CLAN : : TPVPClan theClan = PVP_CLAN : : fromString ( args [ 1 ] ) ;
PVP_CLAN : : TPVPClan theClan = PVP_CLAN : : fromString ( args [ 1 ] ) ;
if ( theClan = = PVP_CLAN : : Unknown )
if ( theClan = = PVP_CLAN : : Unknown )
{
{
log . displayNL ( " Invalid clan name specified. " ) ;
log . displayNL ( " Invalid clan name specified. " ) ;
@ -2089,7 +2165,7 @@ NLMISC_COMMAND (adjustCharacterFame, "For a character, adjust a specific clan by
// Second argument is a clan.
// Second argument is a clan.
PVP_CLAN : : TPVPClan theClan = PVP_CLAN : : fromString ( args [ 1 ] ) ;
PVP_CLAN : : TPVPClan theClan = PVP_CLAN : : fromString ( args [ 1 ] ) ;
uint32 factionIndex ;
uint32 factionIndex ;
if ( theClan = = PVP_CLAN : : Unknown )
if ( theClan = = PVP_CLAN : : Unknown )
@ -2143,7 +2219,7 @@ NLMISC_COMMAND (declareGuildCult, "Make guild declare a specific cult", "<Guild
// Second argument is a clan.
// Second argument is a clan.
PVP_CLAN : : TPVPClan theClan = PVP_CLAN : : fromString ( args [ 1 ] ) ;
PVP_CLAN : : TPVPClan theClan = PVP_CLAN : : fromString ( args [ 1 ] ) ;
if ( theClan = = PVP_CLAN : : Unknown )
if ( theClan = = PVP_CLAN : : Unknown )
{
{
log . displayNL ( " Invalid clan name specified. " ) ;
log . displayNL ( " Invalid clan name specified. " ) ;
@ -2179,7 +2255,7 @@ NLMISC_COMMAND (declareGuildCiv, "Make guild declare a specific civilization", "
// Second argument is a clan.
// Second argument is a clan.
PVP_CLAN : : TPVPClan theClan = PVP_CLAN : : fromString ( args [ 1 ] ) ;
PVP_CLAN : : TPVPClan theClan = PVP_CLAN : : fromString ( args [ 1 ] ) ;
if ( theClan = = PVP_CLAN : : Unknown )
if ( theClan = = PVP_CLAN : : Unknown )
{
{
log . displayNL ( " Invalid clan name specified. " ) ;
log . displayNL ( " Invalid clan name specified. " ) ;
@ -2216,7 +2292,7 @@ NLMISC_COMMAND (adjustGuildFame, "For a guild, adjust a specific clan by indicat
// Second argument is a clan.
// Second argument is a clan.
PVP_CLAN : : TPVPClan theClan = PVP_CLAN : : fromString ( args [ 1 ] ) ;
PVP_CLAN : : TPVPClan theClan = PVP_CLAN : : fromString ( args [ 1 ] ) ;
if ( theClan = = PVP_CLAN : : Unknown )
if ( theClan = = PVP_CLAN : : Unknown )
{
{
log . displayNL ( " Invalid clan name specified. " ) ;
log . displayNL ( " Invalid clan name specified. " ) ;
@ -2251,7 +2327,7 @@ NLMISC_COMMAND (testit, "testit", "")
}
}
//int retval = CFameManager::getInstance().getStartFame(pCiv,tClan);
//int retval = CFameManager::getInstance().getStartFame(pCiv,tClan);
int retval = CFameManager : : getInstance ( ) . getMaxFameByClan ( std : : make_pair ( pCult , pCiv ) , tClan ) ;
int retval = CFameManager : : getInstance ( ) . getMaxFameByClan ( std : : make_pair ( pCult , pCiv ) , 0 , tClan ) ;
log . displayNL ( " Fame value = %d. " , retval ) ;
log . displayNL ( " Fame value = %d. " , retval ) ;
return true ;
return true ;