Skip to content

Commit c4433a0

Browse files
author
Bart Roossien
committed
Essentially this is a strcpy now.
1 parent ec72413 commit c4433a0

File tree

2 files changed

+40
-50
lines changed

2 files changed

+40
-50
lines changed

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,18 +1477,16 @@ Shadow* W3DProjectedShadowManager::addDecal(Shadow::ShadowTypeInfo *shadowInfo)
14771477
Real decalSizeY=0.0f;
14781478

14791479
Bool allowSunDirection=FALSE;
1480-
Char texture_name[64];
1481-
Int nameLen;
1480+
Char texture_name[ARRAY_SIZE(shadowInfo->m_ShadowName)];
14821481

14831482
if (!shadowInfo)
14841483
return NULL; //right now we require hardware render-to-texture support
14851484

14861485
//simple decal using the premade texture specified.
14871486
//can be always perpendicular to model's z-axis or projected
14881487
//onto world geometry.
1489-
nameLen=strlen(shadowInfo->m_ShadowName);
1490-
strlcpy(texture_name,shadowInfo->m_ShadowName,nameLen + 1);
1491-
strcpy(texture_name+nameLen,".tga"); //append texture extension
1488+
strcpy(texture_name, shadowInfo->m_ShadowName);
1489+
strlcpy(texture_name, ".tga", ARRAY_SIZE(texture_name));
14921490

14931491
//Check if we previously added a decal using this texture
14941492
st=m_W3DShadowTextureManager->getTexture(texture_name);
@@ -1583,18 +1581,16 @@ Shadow* W3DProjectedShadowManager::addDecal(RenderObjClass *robj, Shadow::Shadow
15831581
Real decalOffsetY=0.0f;
15841582

15851583
Bool allowSunDirection=FALSE;
1586-
Char texture_name[64];
1587-
Int nameLen;
1584+
Char texture_name[ARRAY_SIZE(shadowInfo->m_ShadowName)];
15881585

15891586
if (!robj || !shadowInfo)
15901587
return NULL; //right now we require hardware render-to-texture support
15911588

15921589
//simple decal using the premade texture specified.
15931590
//can be always perpendicular to model's z-axis or projected
15941591
//onto world geometry.
1595-
nameLen=strlen(shadowInfo->m_ShadowName);
1596-
strlcpy(texture_name,shadowInfo->m_ShadowName,nameLen + 1);
1597-
strcpy(texture_name+nameLen,".tga"); //append texture extension
1592+
strcpy(texture_name, shadowInfo->m_ShadowName);
1593+
strlcpy(texture_name, ".tga", ARRAY_SIZE(texture_name));
15981594

15991595
//Check if we previously added a decal using this texture
16001596
st=m_W3DShadowTextureManager->getTexture(texture_name);
@@ -1706,8 +1702,7 @@ W3DProjectedShadow* W3DProjectedShadowManager::addShadow(RenderObjClass *robj, S
17061702
Real decalOffsetY=0.0f;
17071703

17081704
Bool allowSunDirection=FALSE;
1709-
Char texture_name[64];
1710-
Int nameLen;
1705+
Char texture_name[ARRAY_SIZE(shadowInfo->m_ShadowName)];
17111706

17121707

17131708
if (!m_dynamicRenderTarget || !robj || !TheGlobalData->m_useShadowDecals)
@@ -1721,13 +1716,14 @@ W3DProjectedShadow* W3DProjectedShadowManager::addShadow(RenderObjClass *robj, S
17211716
{ //simple decal using the premade texture specified.
17221717
//can be always perpendicular to model's z-axis or projected
17231718
//onto world geometry.
1724-
nameLen=strlen(shadowInfo->m_ShadowName);
1725-
if (nameLen <= 1) //no texture name given, use same as object
1726-
{ strcpy(texture_name,defaultDecalName);
1719+
if (strlen(shadowInfo->m_ShadowName) <= 1) //no texture name given, use same as object
1720+
{
1721+
strcpy(texture_name, defaultDecalName);
17271722
}
17281723
else
1729-
{ strlcpy(texture_name,shadowInfo->m_ShadowName,nameLen + 1);
1730-
strcpy(texture_name+nameLen,".tga"); //append texture extension
1724+
{
1725+
strcpy(texture_name, shadowInfo->m_ShadowName);
1726+
strlcpy(texture_name, ".tga", ARRAY_SIZE(texture_name));
17311727
}
17321728

17331729
st=m_W3DShadowTextureManager->getTexture(texture_name);
@@ -1891,20 +1887,19 @@ W3DProjectedShadow* W3DProjectedShadowManager::createDecalShadow(Shadow::ShadowT
18911887
Real decalOffsetX=0.0f;
18921888
Real decalOffsetY=0.0f;
18931889
const Real defaultWidth = 10.0f;
1894-
1895-
Char texture_name[64];
1896-
Int nameLen;
1890+
Char texture_name[ARRAY_SIZE(shadowInfo->m_ShadowName)];
18971891

18981892
//simple decal using the premade texture specified.
18991893
//can be always perpendicular to model's z-axis or projected
19001894
//onto world geometry.
1901-
nameLen=strlen(shadowInfo->m_ShadowName);
1902-
if (nameLen <= 1) //no texture name given, use same as object
1903-
{ strcpy(texture_name,defaultDecalName);
1895+
if (strlen(shadowInfo->m_ShadowName) <= 1) //no texture name given, use same as object
1896+
{
1897+
strcpy(texture_name,defaultDecalName);
19041898
}
19051899
else
1906-
{ strlcpy(texture_name,shadowInfo->m_ShadowName,nameLen + 1);
1907-
strcpy(texture_name+nameLen,".tga"); //append texture extension
1900+
{
1901+
strcpy(texture_name, shadowInfo->m_ShadowName);
1902+
strlcpy(texture_name, ".tga", ARRAY_SIZE(texture_name));
19081903
}
19091904

19101905
st=m_W3DShadowTextureManager->getTexture(texture_name);

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,18 +1477,16 @@ Shadow* W3DProjectedShadowManager::addDecal(Shadow::ShadowTypeInfo *shadowInfo)
14771477
Real decalSizeY=0.0f;
14781478

14791479
Bool allowSunDirection=FALSE;
1480-
Char texture_name[64];
1481-
Int nameLen;
1480+
Char texture_name[ARRAY_SIZE(shadowInfo->m_ShadowName)];
14821481

14831482
if (!shadowInfo)
14841483
return NULL; //right now we require hardware render-to-texture support
14851484

14861485
//simple decal using the premade texture specified.
14871486
//can be always perpendicular to model's z-axis or projected
14881487
//onto world geometry.
1489-
nameLen=strlen(shadowInfo->m_ShadowName);
1490-
strlcpy(texture_name,shadowInfo->m_ShadowName,nameLen + 1);
1491-
strcpy(texture_name+nameLen,".tga"); //append texture extension
1488+
strcpy(texture_name, shadowInfo->m_ShadowName);
1489+
strlcpy(texture_name, ".tga", ARRAY_SIZE(texture_name));
14921490

14931491
//Check if we previously added a decal using this texture
14941492
st=m_W3DShadowTextureManager->getTexture(texture_name);
@@ -1583,18 +1581,16 @@ Shadow* W3DProjectedShadowManager::addDecal(RenderObjClass *robj, Shadow::Shadow
15831581
Real decalOffsetY=0.0f;
15841582

15851583
Bool allowSunDirection=FALSE;
1586-
Char texture_name[64];
1587-
Int nameLen;
1584+
Char texture_name[ARRAY_SIZE(shadowInfo->m_ShadowName)];
15881585

15891586
if (!robj || !shadowInfo)
15901587
return NULL; //right now we require hardware render-to-texture support
15911588

15921589
//simple decal using the premade texture specified.
15931590
//can be always perpendicular to model's z-axis or projected
15941591
//onto world geometry.
1595-
nameLen=strlen(shadowInfo->m_ShadowName);
1596-
strlcpy(texture_name,shadowInfo->m_ShadowName,nameLen + 1);
1597-
strcpy(texture_name+nameLen,".tga"); //append texture extension
1592+
strcpy(texture_name, shadowInfo->m_ShadowName);
1593+
strlcpy(texture_name, ".tga", ARRAY_SIZE(texture_name));
15981594

15991595
//Check if we previously added a decal using this texture
16001596
st=m_W3DShadowTextureManager->getTexture(texture_name);
@@ -1706,8 +1702,7 @@ W3DProjectedShadow* W3DProjectedShadowManager::addShadow(RenderObjClass *robj, S
17061702
Real decalOffsetY=0.0f;
17071703

17081704
Bool allowSunDirection=FALSE;
1709-
Char texture_name[64];
1710-
Int nameLen;
1705+
Char texture_name[ARRAY_SIZE(shadowInfo->m_ShadowName)];
17111706

17121707

17131708
if (!m_dynamicRenderTarget || !robj || !TheGlobalData->m_useShadowDecals)
@@ -1721,13 +1716,14 @@ W3DProjectedShadow* W3DProjectedShadowManager::addShadow(RenderObjClass *robj, S
17211716
{ //simple decal using the premade texture specified.
17221717
//can be always perpendicular to model's z-axis or projected
17231718
//onto world geometry.
1724-
nameLen=strlen(shadowInfo->m_ShadowName);
1725-
if (nameLen <= 1) //no texture name given, use same as object
1726-
{ strcpy(texture_name,defaultDecalName);
1719+
if (strlen(shadowInfo->m_ShadowName) <= 1) //no texture name given, use same as object
1720+
{
1721+
strcpy(texture_name, defaultDecalName);
17271722
}
17281723
else
1729-
{ strlcpy(texture_name,shadowInfo->m_ShadowName,nameLen + 1);
1730-
strcpy(texture_name+nameLen,".tga"); //append texture extension
1724+
{
1725+
strcpy(texture_name, shadowInfo->m_ShadowName);
1726+
strlcpy(texture_name, ".tga", ARRAY_SIZE(texture_name));
17311727
}
17321728

17331729
st=m_W3DShadowTextureManager->getTexture(texture_name);
@@ -1891,20 +1887,19 @@ W3DProjectedShadow* W3DProjectedShadowManager::createDecalShadow(Shadow::ShadowT
18911887
Real decalOffsetX=0.0f;
18921888
Real decalOffsetY=0.0f;
18931889
const Real defaultWidth = 10.0f;
1894-
1895-
Char texture_name[64];
1896-
Int nameLen;
1890+
Char texture_name[ARRAY_SIZE(shadowInfo->m_ShadowName)];
18971891

18981892
//simple decal using the premade texture specified.
18991893
//can be always perpendicular to model's z-axis or projected
19001894
//onto world geometry.
1901-
nameLen=strlen(shadowInfo->m_ShadowName);
1902-
if (nameLen <= 1) //no texture name given, use same as object
1903-
{ strcpy(texture_name,defaultDecalName);
1895+
if (strlen(shadowInfo->m_ShadowName) <= 1) //no texture name given, use same as object
1896+
{
1897+
strcpy(texture_name, defaultDecalName);
19041898
}
19051899
else
1906-
{ strlcpy(texture_name,shadowInfo->m_ShadowName,nameLen + 1);
1907-
strcpy(texture_name+nameLen,".tga"); //append texture extension
1900+
{
1901+
strcpy(texture_name, shadowInfo->m_ShadowName);
1902+
strlcpy(texture_name, ".tga", ARRAY_SIZE(texture_name));
19081903
}
19091904

19101905
st=m_W3DShadowTextureManager->getTexture(texture_name);

0 commit comments

Comments
 (0)