Skip to content

Commit 105fe40

Browse files
committed
Refactored bad coding for DrawWidthFactor and DrawHeightFactor
1 parent e14ec22 commit 105fe40

File tree

3 files changed

+49
-37
lines changed

3 files changed

+49
-37
lines changed

Core/GameEngineDevice/Include/W3DDevice/GameClient/WorldHeightMap.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,8 @@ class WorldHeightMap : public RefCountClass,
233233
Int getDrawOrgX(void) {return m_drawOriginX;}
234234
Int getDrawOrgY(void) {return m_drawOriginY;}
235235

236-
//Int getDrawWidth(void) {return REAL_TO_INT(m_drawWidthX*TheGlobalData->m_drawWidthFactor);}
237-
//Int getDrawHeight(void) {return REAL_TO_INT(m_drawHeightY*TheGlobalData->m_drawHeightFactor);}
238-
Int getDrawWidth(void);
239-
Int getDrawHeight(void);
236+
Int getDrawWidth(void) {return m_drawWidthX;}
237+
Int getDrawHeight(void) {return m_drawHeightY;}
240238
void setDrawWidth(Int width) {m_drawWidthX = width; if (m_drawWidthX>m_width) m_drawWidthX = m_width;}
241239
void setDrawHeight(Int height) {m_drawHeightY = height; if (m_drawHeightY>m_height) m_drawHeightY = m_height;}
242240
virtual Int getBorderSize(void) {return m_borderSize;}

Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,26 @@ WorldHeightMap::WorldHeightMap(ChunkInputStream *pStrm, Bool logicalDataOnly):
531531
}
532532
}
533533
}
534-
if (TheGlobalData && TheGlobalData->m_drawEntireTerrain) {
535-
m_drawWidthX=m_width;
536-
m_drawHeightY=m_height;
534+
if (TheGlobalData) {
535+
if( TheGlobalData->m_drawEntireTerrain ){
536+
m_drawWidthX=m_width;
537+
m_drawHeightY=m_height;
538+
} else {
539+
if(TheGlobalData->m_drawWidthFactor != 1.0f)
540+
{
541+
if(m_drawWidthX*TheGlobalData->m_drawWidthFactor >= m_width)
542+
m_drawWidthX=m_width;
543+
else
544+
m_drawWidthX=REAL_TO_INT_FLOOR(m_drawWidthX*TheGlobalData->m_drawWidthFactor);
545+
}
546+
if(TheGlobalData->m_drawHeightFactor != 1.0f)
547+
{
548+
if(m_drawHeightY*TheGlobalData->m_drawHeightFactor >= m_height)
549+
m_drawHeightY=m_height;
550+
else
551+
m_drawHeightY=REAL_TO_INT_FLOOR(m_drawHeightY*TheGlobalData->m_drawHeightFactor);
552+
}
553+
}
537554
}
538555
if (m_drawWidthX > m_width) {
539556
m_drawWidthX = m_width;
@@ -2239,9 +2256,26 @@ Bool WorldHeightMap::setDrawOrg(Int xOrg, Int yOrg)
22392256
newWidth=STRETCH_DRAW_WIDTH;
22402257
newHeight=STRETCH_DRAW_HEIGHT;
22412258
}
2242-
if (TheGlobalData && TheGlobalData->m_drawEntireTerrain) {
2243-
newWidth=m_width;
2244-
newHeight=m_height;
2259+
if (TheGlobalData) {
2260+
if( TheGlobalData->m_drawEntireTerrain ){
2261+
newWidth=m_width;
2262+
newHeight=m_height;
2263+
} else {
2264+
if(TheGlobalData->m_drawWidthFactor != 1.0f)
2265+
{
2266+
if(newWidth*TheGlobalData->m_drawWidthFactor >= m_width)
2267+
newWidth=m_width;
2268+
else
2269+
newWidth=REAL_TO_INT_FLOOR(newWidth*TheGlobalData->m_drawWidthFactor);
2270+
}
2271+
if(TheGlobalData->m_drawHeightFactor != 1.0f)
2272+
{
2273+
if(newHeight*TheGlobalData->m_drawHeightFactor >= m_height)
2274+
newHeight=m_height;
2275+
else
2276+
newHeight=REAL_TO_INT_FLOOR(newHeight*TheGlobalData->m_drawHeightFactor);
2277+
}
2278+
}
22452279
}
22462280
if (newWidth > m_width) newWidth = m_width;
22472281
if (newHeight > m_height) newHeight = m_height;
@@ -2557,25 +2591,3 @@ Bool WorldHeightMap::getRawTileData(Short tileNdx, Int width,
25572591
}
25582592
return(false);
25592593
}
2560-
2561-
Int WorldHeightMap::getDrawWidth(void)
2562-
{
2563-
if(TheGlobalData->m_drawEntireTerrain)
2564-
return m_drawWidthX;
2565-
2566-
if(m_drawWidthX*TheGlobalData->m_drawWidthFactor >= m_width || m_drawWidthX >= m_width )
2567-
return m_width;
2568-
else
2569-
return REAL_TO_INT(m_drawWidthX*TheGlobalData->m_drawWidthFactor);
2570-
}
2571-
2572-
Int WorldHeightMap::getDrawHeight(void)
2573-
{
2574-
if(TheGlobalData->m_drawEntireTerrain)
2575-
return m_drawHeightY;
2576-
2577-
if(m_drawHeightY*TheGlobalData->m_drawHeightFactor >= m_height || m_drawHeightY >= m_height )
2578-
return m_height;
2579-
else
2580-
return REAL_TO_INT(m_drawHeightY*TheGlobalData->m_drawHeightFactor);
2581-
}

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,8 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate
14621462
return 0;
14631463
}
14641464
}
1465+
1466+
const ThingTemplate *projectileTemplate = getProjectileTemplate();
14651467

14661468
// New feature, similar to Black Hole Armor.
14671469
Object* retarget = NULL;
@@ -1471,7 +1473,7 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate
14711473
{
14721474
ProtectionTypeFlags ShieldedType = victimObj->getShieldByTargetType();
14731475
Bool hasProtection = false;
1474-
if(getProjectileTemplate())
1476+
if(projectileTemplate)
14751477
hasProtection = !isProjectileDetonation && getProtectionTypeFlag(ShieldedType, PROTECTION_PROJECTILES);
14761478
else
14771479
hasProtection = firingWeapon->isLaser() ? getProtectionTypeFlag(ShieldedType, PROTECTION_LASER) : getProtectionTypeFlag(ShieldedType, PROTECTION_BULLETS);
@@ -1558,7 +1560,7 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate
15581560

15591561
dz = 0.0f;
15601562
}
1561-
else if(getProjectileTemplate() != NULL)
1563+
else if(projectileTemplate != NULL)
15621564
{
15631565
if(isStructure)
15641566
{
@@ -1596,7 +1598,7 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate
15961598
else
15971599
{
15981600
Real targetHeight = curTarget->getGeometryInfo().getMaxHeightAbovePosition();
1599-
if(getProjectileTemplate() == NULL && !firingWeapon->isLaser() && !sourceObj->isKindOf(KINDOF_INFANTRY) && distSqr > 0)
1601+
if(projectileTemplate == NULL && !firingWeapon->isLaser() && !sourceObj->isKindOf(KINDOF_INFANTRY) && distSqr > 0)
16001602
{
16011603
Real adjustedHeight = targetHeight;
16021604
if(!sourceObj->isAboveTerrain() && distSqr < 4 * targetHeight * targetHeight)
@@ -1803,7 +1805,7 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate
18031805
}
18041806
}
18051807

1806-
if (getProjectileTemplate() == NULL || isProjectileDetonation)
1808+
if (projectileTemplate == NULL || isProjectileDetonation)
18071809
{
18081810
// see if we need to be called back at a later point to deal the damage.
18091811
Coord3D v;
@@ -1933,7 +1935,7 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate
19331935
else // must be a projectile
19341936
{
19351937
Player *owningPlayer = sourceObj->getControllingPlayer(); //Need to know so missiles don't collide with firer
1936-
Object *projectile = TheThingFactory->newObject( getProjectileTemplate(), owningPlayer->getDefaultTeam() );
1938+
Object *projectile = TheThingFactory->newObject( projectileTemplate, owningPlayer->getDefaultTeam() );
19371939
projectile->setProducer(sourceObj);
19381940

19391941
//If the player has battle plans (America Strategy Center), then apply those bonuses

0 commit comments

Comments
 (0)