src/game/Strategic/Strategic_Town_Loyalty.cc
static void UpdateTownLoyaltyRating(INT8 bTownId)
{
	// check gain value and update loyaty
	UINT8 ubOldLoyaltyRating = 0;
	INT16 sRatingChange = 0;
	UINT8 ubMaxLoyalty = 0;


	Assert( ( bTownId >= FIRST_TOWN ) && ( bTownId < NUM_TOWNS ) );

	// remember previous loyalty value
	ubOldLoyaltyRating = gTownLoyalty[ bTownId ].ubRating;

	sRatingChange = gTownLoyalty[ bTownId ].sChange / GAIN_PTS_PER_LOYALTY_PT;

	// if loyalty is ready to increase
	if( sRatingChange > 0 )
	{
		// if the town is Omerta, and the rebels are/will become hostile
		if ((bTownId == OMERTA) && (gTacticalStatus.fCivGroupHostile[ REBEL_CIV_GROUP ] != CIV_GROUP_NEUTRAL))
		{
			// maximum loyalty is much less than normal
			ubMaxLoyalty = HOSTILE_OMERTA_LOYALTY_RATING;
		}
		else
		{
			ubMaxLoyalty = MAX_LOYALTY_VALUE;
		}

		// check if we'd be going over the max
		if( (gTownLoyalty[ bTownId ].ubRating + sRatingChange ) >= ubMaxLoyalty )
		{
			// set to max and null out gain pts
			gTownLoyalty[ bTownId ].ubRating = ubMaxLoyalty;
			gTownLoyalty[ bTownId ].sChange = 0;
		}
		else
		{
			// increment loyalty rating, reduce sChange
			gTownLoyalty[ bTownId ].ubRating += sRatingChange;
			gTownLoyalty[ bTownId ].sChange %= GAIN_PTS_PER_LOYALTY_PT;
		}
	}
	else
	// if loyalty is ready to decrease
	if( sRatingChange < 0 )
	{
		// check if we'd be going below zero
		if( ( gTownLoyalty[ bTownId ].ubRating + sRatingChange ) < 0 )
		{
			// set to zero and null out gain pts
			gTownLoyalty[ bTownId ].ubRating = 0;
			gTownLoyalty[ bTownId ].sChange = 0;
		}
		else
		{
			// decrement loyalty rating, reduce sChange
			gTownLoyalty[ bTownId ].ubRating += sRatingChange;
			gTownLoyalty[ bTownId ].sChange %= GAIN_PTS_PER_LOYALTY_PT;
		}
	}


	// check old aginst new, if diff, dirty map panel
	if( ubOldLoyaltyRating != gTownLoyalty[ bTownId ].ubRating )
	{
		fMapPanelDirty = TRUE;
	}
}
// update town loyalty rating based on gain values
update town loyalty rating based on gain values
update town loyalty rating based on gain values
static void UpdateTownLoyaltyRating(INT8 bTownId)
{
	UINT8 ubOldLoyaltyRating = 0;
	INT16 sRatingChange = 0;
	UINT8 ubMaxLoyalty = 0;
	Assert( ( bTownId >= FIRST_TOWN ) && ( bTownId < NUM_TOWNS ) );
	ubOldLoyaltyRating = gTownLoyalty[ bTownId ].ubRating;
	sRatingChange = gTownLoyalty[ bTownId ].sChange / GAIN_PTS_PER_LOYALTY_PT;
	if( sRatingChange > 0 )
	{
		if ((bTownId == OMERTA) && (gTacticalStatus.fCivGroupHostile[ REBEL_CIV_GROUP ] != CIV_GROUP_NEUTRAL))
		{
			ubMaxLoyalty = HOSTILE_OMERTA_LOYALTY_RATING;
		}
		else
		{
			ubMaxLoyalty = MAX_LOYALTY_VALUE;
		}
		if( (gTownLoyalty[ bTownId ].ubRating + sRatingChange ) >= ubMaxLoyalty )
		{
			gTownLoyalty[ bTownId ].ubRating = ubMaxLoyalty;
			gTownLoyalty[ bTownId ].sChange = 0;
		}
		else
		{
			gTownLoyalty[ bTownId ].ubRating += sRatingChange;
			gTownLoyalty[ bTownId ].sChange %= GAIN_PTS_PER_LOYALTY_PT;
		}
	}
	else
	if( sRatingChange < 0 )
	{
		if( ( gTownLoyalty[ bTownId ].ubRating + sRatingChange ) < 0 )
		{
			gTownLoyalty[ bTownId ].ubRating = 0;
			gTownLoyalty[ bTownId ].sChange = 0;
		}
		else
		{
			gTownLoyalty[ bTownId ].ubRating += sRatingChange;
			gTownLoyalty[ bTownId ].sChange %= GAIN_PTS_PER_LOYALTY_PT;
		}
	}
	if( ubOldLoyaltyRating != gTownLoyalty[ bTownId ].ubRating )
	{
		fMapPanelDirty = TRUE;
	}
}
static void UpdateTownLoyaltyRating ( INT8 bTownId ) { UINT8 ubOldLoyaltyRating = 0 ; INT16 sRatingChange = 0 ; UINT8 ubMaxLoyalty = 0 ; Assert ( ( bTownId >= FIRST_TOWN ) && ( bTownId < NUM_TOWNS ) ) ; ubOldLoyaltyRating = gTownLoyalty [ bTownId ] . ubRating ; sRatingChange = gTownLoyalty [ bTownId ] . sChange / GAIN_PTS_PER_LOYALTY_PT ; if ( sRatingChange > 0 ) { if ( ( bTownId == OMERTA ) && ( gTacticalStatus . fCivGroupHostile [ REBEL_CIV_GROUP ] != CIV_GROUP_NEUTRAL ) ) { ubMaxLoyalty = HOSTILE_OMERTA_LOYALTY_RATING ; } else { ubMaxLoyalty = MAX_LOYALTY_VALUE ; } if ( ( gTownLoyalty [ bTownId ] . ubRating + sRatingChange ) >= ubMaxLoyalty ) { gTownLoyalty [ bTownId ] . ubRating = ubMaxLoyalty ; gTownLoyalty [ bTownId ] . sChange = 0 ; } else { gTownLoyalty [ bTownId ] . ubRating += sRatingChange ; gTownLoyalty [ bTownId ] . sChange %= GAIN_PTS_PER_LOYALTY_PT ; } } else if ( sRatingChange < 0 ) { if ( ( gTownLoyalty [ bTownId ] . ubRating + sRatingChange ) < 0 ) { gTownLoyalty [ bTownId ] . ubRating = 0 ; gTownLoyalty [ bTownId ] . sChange = 0 ; } else { gTownLoyalty [ bTownId ] . ubRating += sRatingChange ; gTownLoyalty [ bTownId ] . sChange %= GAIN_PTS_PER_LOYALTY_PT ; } } if ( ubOldLoyaltyRating != gTownLoyalty [ bTownId ] . ubRating ) { fMapPanelDirty = TRUE ; } }
update town loyalty rating based on gain values
update town loyalty rating based on gain values
// check gain value and update loyaty // remember previous loyalty value // if loyalty is ready to increase // if the town is Omerta, and the rebels are/will become hostile // maximum loyalty is much less than normal // check if we'd be going over the max // set to max and null out gain pts // increment loyalty rating, reduce sChange // if loyalty is ready to decrease // check if we'd be going below zero // set to zero and null out gain pts // decrement loyalty rating, reduce sChange // check old aginst new, if diff, dirty map panel