Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Generals/Code/Tools/WorldBuilder/include/StdAfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT


#include <Utility/stdio_adapter.h>


//{{AFX_INSERT_LOCATION}}
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/Tools/WorldBuilder/src/BaseBuildProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ BOOL BaseBuildProps::OnInitDialog()
// add health
CWnd* pHealth = GetDlgItem(IDC_MAPOBJECT_StartingHealthEdit);
static char buff[12];
sprintf(buff, "%d", m_health);
snprintf(buff, ARRAY_SIZE(buff), "%d", m_health);
pHealth->SetWindowText(buff);

CButton* pItem;
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/Tools/WorldBuilder/src/BlendMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void BlendMaterial::addTerrain(const char *pPath, Int terrainNdx, HTREEITEM pare
// Int percent = (WorldHeightMapEdit::getTexClassNumTiles(terrainNdx)*100 + availableTiles/2) / availableTiles;

char label[_MAX_PATH];
sprintf(label, "%s", buffer);
snprintf(label, ARRAY_SIZE(label), "%s", buffer);


if( doAdd )
Expand Down
12 changes: 6 additions & 6 deletions Generals/Code/Tools/WorldBuilder/src/BuildList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,16 +449,16 @@ void BuildList::OnSelchangeBuildList()
PointerTool::clearSelection(); // unselect other stuff.
if (pBuildInfo) {
CWnd *edit;
static char buff[12];
static char buff[32];
pBuildInfo->setSelected(true);

m_angle = pBuildInfo->getAngle() * 180/PI;
sprintf(buff, "%0.2f", m_angle);
snprintf(buff, ARRAY_SIZE(buff), "%0.2f", m_angle);
edit = GetDlgItem(IDC_MAPOBJECT_Angle);
edit->SetWindowText(buff);

m_height = pBuildInfo->getLocation()->z;
sprintf(buff, "%0.2f", m_height);
snprintf(buff, ARRAY_SIZE(buff), "%0.2f", m_height);
edit = GetDlgItem(IDC_MAPOBJECT_ZOffset);
edit->SetWindowText(buff);

Expand Down Expand Up @@ -638,19 +638,19 @@ void BuildList::PopSliderChanged(const long sliderID, long theVal)
{
// CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc();
CWnd* edit;
static char buff[12];
static char buff[32];
switch (sliderID) {
case IDC_HEIGHT_POPUP:
m_height = theVal;
sprintf(buff, "%0.2f", m_height);
snprintf(buff, ARRAY_SIZE(buff), "%0.2f", m_height);
edit = GetDlgItem(IDC_MAPOBJECT_ZOffset);
edit->SetWindowText(buff);
OnChangeZOffset();
break;

case IDC_ANGLE_POPUP:
m_angle = theVal;
sprintf(buff, "%0.2f", m_angle);
snprintf(buff, ARRAY_SIZE(buff), "%0.2f", m_angle);
edit = GetDlgItem(IDC_MAPOBJECT_Angle);
edit->SetWindowText(buff);
break;
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/Tools/WorldBuilder/src/EditParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ void EditParameter::readFontFile( const char *filename )
{
char buffer[ 1024 ];

sprintf( buffer, "Warning: The font '%s' Size: '%d' Bold: '%d', specified in the config file could not be loaded. Does that font exist?",
snprintf( buffer, ARRAY_SIZE(buffer), "Warning: The font '%s' Size: '%d' Bold: '%d', specified in the config file could not be loaded. Does that font exist?",
fontBuffer, size, bold );
//MessageBox( m_appHWnd, buffer, "Cannot Load Font", MB_OK );

Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/Tools/WorldBuilder/src/FeatherOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void FeatherOptions::OnChangeSizeEdit()
if (1==sscanf(buffer, "%d", &width)) {
m_currentFeather = width;
FeatherTool::setFeather(m_currentFeather);
sprintf(buffer, "%.1f FEET.", m_currentFeather*MAP_XY_FACTOR);
snprintf(buffer, ARRAY_SIZE(buffer), "%.1f FEET.", m_currentFeather*MAP_XY_FACTOR);
pEdit = m_staticThis->GetDlgItem(IDC_WIDTH_LABEL);
if (pEdit) pEdit->SetWindowText(buffer);
}
Expand Down
14 changes: 7 additions & 7 deletions Generals/Code/Tools/WorldBuilder/src/GroveOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,35 +266,35 @@ void GroveOptions::_setDefaultRatios(void)
CWnd* pWnd = GetDlgItem(IDC_Grove_Per1);
if (pWnd) {
defaultRatio = AfxGetApp()->GetProfileInt("GroveOptions", "DefaultRatio1", 0);
sprintf(buff, "%d", defaultRatio);
snprintf(buff, ARRAY_SIZE(buff), "%d", defaultRatio);
pWnd->SetWindowText(buff);
}

pWnd = GetDlgItem(IDC_Grove_Per2);
if (pWnd) {
defaultRatio = AfxGetApp()->GetProfileInt("GroveOptions", "DefaultRatio2", 0);
sprintf(buff, "%d", defaultRatio);
snprintf(buff, ARRAY_SIZE(buff), "%d", defaultRatio);
pWnd->SetWindowText(buff);
}

pWnd = GetDlgItem(IDC_Grove_Per3);
if (pWnd) {
defaultRatio = AfxGetApp()->GetProfileInt("GroveOptions", "DefaultRatio3", 0);
sprintf(buff, "%d", defaultRatio);
snprintf(buff, ARRAY_SIZE(buff), "%d", defaultRatio);
pWnd->SetWindowText(buff);
}

pWnd = GetDlgItem(IDC_Grove_Per4);
if (pWnd) {
defaultRatio = AfxGetApp()->GetProfileInt("GroveOptions", "DefaultRatio4", 0);
sprintf(buff, "%d", defaultRatio);
snprintf(buff, ARRAY_SIZE(buff), "%d", defaultRatio);
pWnd->SetWindowText(buff);
}

pWnd = GetDlgItem(IDC_Grove_Per5);
if (pWnd) {
defaultRatio = AfxGetApp()->GetProfileInt("GroveOptions", "DefaultRatio5", 0);
sprintf(buff, "%d", defaultRatio);
snprintf(buff, ARRAY_SIZE(buff), "%d", defaultRatio);
pWnd->SetWindowText(buff);
}
}
Expand All @@ -308,7 +308,7 @@ void GroveOptions::_setDefaultNumTrees(void)

int defaultNumTrees = AfxGetApp()->GetProfileInt("GroveOptions", "NumberofTrees", 10);
static char buff[ARBITRARY_BUFF_SIZE];
sprintf(buff, "%d", defaultNumTrees);
snprintf(buff, ARRAY_SIZE(buff), "%d", defaultNumTrees);

pWnd->SetWindowText(buff);
}
Expand Down Expand Up @@ -379,7 +379,7 @@ void GroveOptions::_updateTreeWeights(void)

pWnd = GetDlgItem(IDC_Grove_PerTotal);
if (pWnd) {
sprintf(buff, "%d", val);
snprintf(buff, ARRAY_SIZE(buff), "%d", val);
pWnd->SetWindowText(buff);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/Tools/WorldBuilder/src/LayersList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ void LayersList::OnNewLayer()
}

static char buffer[1024];
sprintf(buffer, "%s %d", TheDefaultNewLayerName.c_str(), newLayerNum);
snprintf(buffer, ARRAY_SIZE(buffer), "%s %d", TheDefaultNewLayerName.c_str(), newLayerNum);
addLayerNamed(buffer);

HTREEITEM newItem = pTree->InsertItem(buffer, 0, 0);
Expand Down
12 changes: 6 additions & 6 deletions Generals/Code/Tools/WorldBuilder/src/MeshMoldOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ BOOL MeshMoldOptions::OnInitDialog()

void MeshMoldOptions::setHeight(Real height)
{
char buffer[50];
sprintf(buffer, "%.2f", height);
char buffer[32];
snprintf(buffer, ARRAY_SIZE(buffer), "%.2f", height);
m_currentHeight = height;
if (m_staticThis && !m_staticThis->m_updating) {
CWnd *pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT);
Expand All @@ -154,8 +154,8 @@ void MeshMoldOptions::setHeight(Real height)

void MeshMoldOptions::setScale(Real scale)
{
char buffer[50];
sprintf(buffer, "%d", (int)floor(scale*100));
char buffer[12];
snprintf(buffer, ARRAY_SIZE(buffer), "%d", (int)floor(scale*100));
m_currentScale = scale;
if (m_staticThis && !m_staticThis->m_updating) {
CWnd *pEdit = m_staticThis->GetDlgItem(IDC_SCALE_EDIT);
Expand All @@ -166,8 +166,8 @@ void MeshMoldOptions::setScale(Real scale)

void MeshMoldOptions::setAngle(Int angle)
{
char buffer[50];
sprintf(buffer, "%d", angle);
char buffer[12];
snprintf(buffer, ARRAY_SIZE(buffer), "%d", angle);
m_currentAngle = angle;
if (m_staticThis && !m_staticThis->m_updating) {
CWnd *pEdit = m_staticThis->GetDlgItem(IDC_ANGLE_EDIT);
Expand Down
10 changes: 5 additions & 5 deletions Generals/Code/Tools/WorldBuilder/src/MoundOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ void MoundOptions::setWidth(Int width)

void MoundOptions::setHeight(Int height)
{
char buffer[50];
sprintf(buffer, "%d", height);
char buffer[12];
snprintf(buffer, ARRAY_SIZE(buffer), "%d", height);
m_currentHeight = height;
if (m_staticThis && !m_staticThis->m_updating) {
CWnd *pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT);
Expand Down Expand Up @@ -129,7 +129,7 @@ void MoundOptions::OnChangeFeatherEdit()
if (1==sscanf(buffer, "%d", &feather)) {
m_currentFeather = feather;
MoundTool::setFeather(m_currentFeather);
sprintf(buffer, "%.1f FEET.", m_currentFeather*MAP_XY_FACTOR);
snprintf(buffer, ARRAY_SIZE(buffer), "%.1f FEET.", m_currentFeather*MAP_XY_FACTOR);
pEdit = m_staticThis->GetDlgItem(IDC_FEATHER_LABEL);
if (pEdit) pEdit->SetWindowText(buffer);
}
Expand All @@ -152,7 +152,7 @@ void MoundOptions::OnChangeSizeEdit()
if (1==sscanf(buffer, "%d", &width)) {
m_currentWidth = width;
MoundTool::setWidth(m_currentWidth);
sprintf(buffer, "%.1f FEET.", m_currentWidth*MAP_XY_FACTOR);
snprintf(buffer, ARRAY_SIZE(buffer), "%.1f FEET.", m_currentWidth*MAP_XY_FACTOR);
pEdit = m_staticThis->GetDlgItem(IDC_WIDTH_LABEL);
if (pEdit) pEdit->SetWindowText(buffer);
}
Expand All @@ -175,7 +175,7 @@ void MoundOptions::OnChangeHeightEdit()
if (1==sscanf(buffer, "%d", &height)) {
m_currentHeight = height;
MoundTool::setMoundHeight(m_currentHeight);
sprintf(buffer, "%.1f FEET.", m_currentHeight*MAP_HEIGHT_SCALE);
snprintf(buffer, ARRAY_SIZE(buffer), "%.1f FEET.", m_currentHeight*MAP_HEIGHT_SCALE);
pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_LABEL);
if (pEdit) pEdit->SetWindowText(buffer);
}
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/Tools/WorldBuilder/src/SaveMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void SaveMap::populateMapListbox( Bool systemMaps )
if (systemMaps)
strcpy(dirBuf, ".\\Maps\\");
else
sprintf(dirBuf, "%sMaps\\", TheGlobalData->getPath_UserData().str());
snprintf(dirBuf, ARRAY_SIZE(dirBuf), "%sMaps\\", TheGlobalData->getPath_UserData().str());
int len = strlen(dirBuf);

if (len > 0 && dirBuf[len - 1] != '\\') {
Expand Down
4 changes: 2 additions & 2 deletions Generals/Code/Tools/WorldBuilder/src/TerrainMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ void TerrainMaterial::addTerrain(char *pPath, Int terrainNdx, HTREEITEM parent)
Int percent = (WorldHeightMapEdit::getTexClassNumTiles(terrainNdx)*100 + availableTiles/2) / availableTiles;

char label[_MAX_PATH];
sprintf(label, "%d%% %s", percent, buffer);
snprintf(label, ARRAY_SIZE(label), "%d%% %s", percent, buffer);


if( doAdd )
Expand Down Expand Up @@ -405,7 +405,7 @@ void TerrainMaterial::OnChangeSizeEdit()
if (1==sscanf(buffer, "%d", &width)) {
m_currentWidth = width;
BigTileTool::setWidth(m_currentWidth);
sprintf(buffer, "%.1f FEET.", m_currentWidth*MAP_XY_FACTOR);
snprintf(buffer, ARRAY_SIZE(buffer), "%.1f FEET.", m_currentWidth*MAP_XY_FACTOR);
pEdit = m_staticThis->GetDlgItem(IDC_WIDTH_LABEL);
if (pEdit) pEdit->SetWindowText(buffer);
}
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ void WorldHeightMapEdit::loadImagesFromTerrainType( TerrainType *terrain )
char buffer[ _MAX_PATH ];

// build path to texture file
sprintf( buffer, "%s%s", TERRAIN_TGA_DIR_PATH, terrain->getTexture().str() );
snprintf( buffer, ARRAY_SIZE(buffer), "%s%s", TERRAIN_TGA_DIR_PATH, terrain->getTexture().str() );

// create ascii string for texture path
AsciiString texturePath( buffer );
Expand Down
12 changes: 6 additions & 6 deletions Generals/Code/Tools/WorldBuilder/src/WaterOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ void WaterOptions::DoDataExchange(CDataExchange* pDX)

void WaterOptions::setHeight(Int height)
{
char buffer[50];
sprintf(buffer, "%d", height);
char buffer[12];
snprintf(buffer, ARRAY_SIZE(buffer), "%d", height);
m_waterHeight = height;
if (m_staticThis && !m_staticThis->m_updating) {
CWnd *pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT);
Expand Down Expand Up @@ -91,9 +91,9 @@ void WaterOptions::updateTheUI(void)
pButton->EnableWindow(theTrigger!=NULL);

pWnd = m_staticThis->GetDlgItem(IDC_SPACING);
char buffer[_MAX_PATH];
char buffer[12];
if (pWnd) {
sprintf(buffer, "%d", m_waterPointSpacing);
snprintf(buffer, ARRAY_SIZE(buffer), "%d", m_waterPointSpacing);
pWnd->SetWindowText(buffer);
}
}
Expand Down Expand Up @@ -492,15 +492,15 @@ void WaterOptions::OnChangeSpacingEdit()
{
if (m_updating) return;
CWnd *pEdit = m_staticThis->GetDlgItem(IDC_SPACING);
char buffer[_MAX_PATH];
char buffer[12];
if (pEdit) {
pEdit->GetWindowText(buffer, sizeof(buffer));
Int height;
m_updating = true;
if (1==sscanf(buffer, "%d", &height)) {
m_waterPointSpacing = height;
} else {
sprintf(buffer, "%d", m_waterPointSpacing);
snprintf(buffer, ARRAY_SIZE(buffer), "%d", m_waterPointSpacing);
pEdit->SetWindowText(buffer);
}
m_updating = false;
Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/Tools/WorldBuilder/src/WorldBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ BOOL CWorldBuilderApp::InitInstance()
strcpy((char*)m_pszProfileName, buf);

// ensure the user maps dir exists
sprintf(buf, "%sMaps\\", TheGlobalData->getPath_UserData().str());
snprintf(buf, ARRAY_SIZE(buf), "%sMaps\\", TheGlobalData->getPath_UserData().str());
CreateDirectory(buf, NULL);

// read the water settings from INI (must do prior to initing GameClient, apparently)
Expand Down
10 changes: 5 additions & 5 deletions Generals/Code/Tools/WorldBuilder/src/brushoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ void BrushOptions::setWidth(Int width)

void BrushOptions::setHeight(Int height)
{
char buffer[50];
sprintf(buffer, "%d", height);
char buffer[12];
snprintf(buffer, ARRAY_SIZE(buffer), "%d", height);
m_currentHeight = height;
if (m_staticThis && !m_staticThis->m_updating) {
CWnd *pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT);
Expand Down Expand Up @@ -129,7 +129,7 @@ void BrushOptions::OnChangeFeatherEdit()
if (1==sscanf(buffer, "%d", &feather)) {
m_currentFeather = feather;
BrushTool::setFeather(m_currentFeather);
sprintf(buffer, "%.1f FEET.", m_currentFeather*MAP_XY_FACTOR);
snprintf(buffer, ARRAY_SIZE(buffer), "%.1f FEET.", m_currentFeather*MAP_XY_FACTOR);
pEdit = m_staticThis->GetDlgItem(IDC_FEATHER_LABEL);
if (pEdit) pEdit->SetWindowText(buffer);
}
Expand All @@ -152,7 +152,7 @@ void BrushOptions::OnChangeSizeEdit()
if (1==sscanf(buffer, "%d", &width)) {
m_currentWidth = width;
BrushTool::setWidth(m_currentWidth);
sprintf(buffer, "%.1f FEET.", m_currentWidth*MAP_XY_FACTOR);
snprintf(buffer, ARRAY_SIZE(buffer), "%.1f FEET.", m_currentWidth*MAP_XY_FACTOR);
pEdit = m_staticThis->GetDlgItem(IDC_WIDTH_LABEL);
if (pEdit) pEdit->SetWindowText(buffer);
}
Expand All @@ -175,7 +175,7 @@ void BrushOptions::OnChangeHeightEdit()
if (1==sscanf(buffer, "%d", &height)) {
m_currentHeight = height;
BrushTool::setHeight(m_currentHeight);
sprintf(buffer, "%.1f FEET.", m_currentHeight*MAP_HEIGHT_SCALE);
snprintf(buffer, ARRAY_SIZE(buffer), "%.1f FEET.", m_currentHeight*MAP_HEIGHT_SCALE);
pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_LABEL);
if (pEdit) pEdit->SetWindowText(buffer);
}
Expand Down
Loading
Loading