-
Notifications
You must be signed in to change notification settings - Fork 62
[GEN] Backports redundant call reductions from ZH #750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,12 +83,13 @@ CreateObjectDie::~CreateObjectDie( void ) | |
//------------------------------------------------------------------------------------------------- | ||
void CreateObjectDie::onDie( const DamageInfo * damageInfo ) | ||
{ | ||
const CreateObjectDieModuleData *data = getCreateObjectDieModuleData(); | ||
if (!isDieApplicable(damageInfo)) | ||
return; | ||
|
||
Object *damageDealer = TheGameLogic->findObjectByID( damageInfo->in.m_sourceID ); | ||
|
||
ObjectCreationList::create(getCreateObjectDieModuleData()->m_ocl, getObject(), damageDealer); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a good change. I suggest to sync Generals to Zero Hour. |
||
ObjectCreationList::create( data->m_ocl, getObject(), damageDealer ); | ||
} // end onDie | ||
|
||
// ------------------------------------------------------------------------------------------------ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,9 +52,10 @@ DestroyDie::~DestroyDie( void ) | |
//------------------------------------------------------------------------------------------------- | ||
void DestroyDie::onDie( const DamageInfo *damageInfo ) | ||
{ | ||
Object *obj = getObject(); | ||
if (!isDieApplicable(damageInfo)) | ||
return; | ||
TheGameLogic->destroyObject(getObject()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a good change. I suggest to sync Generals to Zero Hour. |
||
TheGameLogic->destroyObject( obj ); | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------------ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,7 @@ Int FiringTracker::getNumConsecutiveShotsAtVictim( const Object *victim ) const | |
void FiringTracker::shotFired(const Weapon* weaponFired, ObjectID victimID) | ||
{ | ||
UnsignedInt now = TheGameLogic->getFrame(); | ||
Object *me = getObject(); | ||
|
||
if( victimID == m_victimID ) | ||
{ | ||
|
@@ -117,15 +118,15 @@ void FiringTracker::shotFired(const Weapon* weaponFired, ObjectID victimID) | |
Int shotsNeededOne = weaponFired->getContinuousFireOneShotsNeeded(); | ||
Int shotsNeededTwo = weaponFired->getContinuousFireTwoShotsNeeded(); | ||
|
||
if( getObject()->testWeaponBonusCondition( WEAPONBONUSCONDITION_CONTINUOUS_FIRE_MEAN ) ) | ||
if( me->testWeaponBonusCondition( WEAPONBONUSCONDITION_CONTINUOUS_FIRE_MEAN ) ) | ||
{ | ||
// Can either go up or down from here. | ||
if( m_consecutiveShots < shotsNeededOne ) | ||
coolDown(); | ||
else if( m_consecutiveShots > shotsNeededTwo ) | ||
speedUp(); | ||
} | ||
else if( getObject()->testWeaponBonusCondition( WEAPONBONUSCONDITION_CONTINUOUS_FIRE_FAST ) ) | ||
else if( me->testWeaponBonusCondition( WEAPONBONUSCONDITION_CONTINUOUS_FIRE_FAST ) ) | ||
{ | ||
// Only place I can go here from here is all the way down | ||
if( m_consecutiveShots < shotsNeededTwo ) | ||
|
@@ -161,7 +162,7 @@ void FiringTracker::shotFired(const Weapon* weaponFired, ObjectID victimID) | |
} | ||
|
||
|
||
setWakeFrame(getObject(), calcTimeToSleep()); | ||
setWakeFrame(me, calcTimeToSleep()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just note: The Zero Hour developer forgot replacing a few |
||
} | ||
|
||
//------------------------------------------------------------------------------------------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3945,12 +3945,14 @@ void AIUpdateInterface::privateHackInternet( CommandSourceType cmdSource ) | |
/// if we are attacking "fromID", stop that and attack "toID" instead | ||
void AIUpdateInterface::transferAttack(ObjectID fromID, ObjectID toID) | ||
{ | ||
Object *newTarget = TheGameLogic->findObjectByID( toID ); | ||
|
||
if (m_currentVictimID == fromID) | ||
m_currentVictimID = toID; | ||
|
||
Object* goalObj = getStateMachine()->getGoalObject(); | ||
if (goalObj && goalObj->getID() == fromID) | ||
getStateMachine()->setGoalObject(TheGameLogic->findObjectByID(toID)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a good change. I suggest to sync Generals to Zero Hour. |
||
getStateMachine()->setGoalObject( newTarget ); | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,6 +116,7 @@ void AutoDepositUpdate::awardInitialCaptureBonus( Player *player ) | |
//------------------------------------------------------------------------------------------------- | ||
UpdateSleepTime AutoDepositUpdate::update( void ) | ||
{ | ||
const AutoDepositUpdateModuleData *modData = getAutoDepositUpdateModuleData(); | ||
/// @todo srj use SLEEPY_UPDATE here | ||
if( TheGameLogic->getFrame() >= m_depositOnFrame) | ||
{ | ||
|
@@ -125,23 +126,25 @@ UpdateSleepTime AutoDepositUpdate::update( void ) | |
m_awardInitialCaptureBonus = TRUE; | ||
m_initialized = TRUE; | ||
} | ||
m_depositOnFrame = TheGameLogic->getFrame() + getAutoDepositUpdateModuleData()->m_depositFrame; | ||
m_depositOnFrame = TheGameLogic->getFrame() + modData->m_depositFrame; | ||
|
||
if(getObject()->isNeutralControlled() || getAutoDepositUpdateModuleData()->m_depositAmount <= 0 ) | ||
if(getObject()->isNeutralControlled() || modData->m_depositAmount <= 0 ) | ||
return UPDATE_SLEEP_NONE; | ||
|
||
// makes sure that buildings under construction do not get a bonus CCB | ||
if( getObject()->getConstructionPercent() != CONSTRUCTION_COMPLETE ) | ||
return UPDATE_SLEEP_NONE; | ||
|
||
getObject()->getControllingPlayer()->getMoney()->deposit( getAutoDepositUpdateModuleData()->m_depositAmount); | ||
getObject()->getControllingPlayer()->getScoreKeeper()->addMoneyEarned( getAutoDepositUpdateModuleData()->m_depositAmount); | ||
|
||
int moneyAmount = modData->m_depositAmount; | ||
|
||
getObject()->getControllingPlayer()->getMoney()->deposit( moneyAmount ); | ||
getObject()->getControllingPlayer()->getScoreKeeper()->addMoneyEarned( modData->m_depositAmount); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just note: Here the Zero Hour developer forgot refactor. |
||
|
||
//Display cash income floating over the blacklotus | ||
if(getAutoDepositUpdateModuleData()->m_depositAmount > 0) | ||
if(moneyAmount > 0) | ||
{ | ||
UnicodeString moneyString; | ||
moneyString.format( TheGameText->fetch( "GUI:AddCash" ), getAutoDepositUpdateModuleData()->m_depositAmount ); | ||
moneyString.format( TheGameText->fetch( "GUI:AddCash" ), moneyAmount ); | ||
Coord3D pos; | ||
pos.set( getObject()->getPosition() ); | ||
pos.z += 10.0f; //add a little z to make it show up above the unit. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -491,7 +491,8 @@ Coord3D DockUpdate::computeApproachPosition( Int positionIndex, Object *forWhom | |
// ------------------------------------------------------------------------------------------------ | ||
void DockUpdate::loadDockPositions() | ||
{ | ||
Drawable *myDrawable = getObject()->getDrawable(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary change. I suggest copy Generals to Zero Hour. |
||
Object *obj = getObject(); | ||
Drawable *myDrawable = obj->getDrawable(); | ||
|
||
if (myDrawable) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a good change. I suggest to sync Generals to Zero Hour.