From 00753d2ff2ae712af8a668c9ea80f7787d59ee94 Mon Sep 17 00:00:00 2001 From: Zero Fanker Date: Thu, 25 Apr 2024 19:11:06 -0400 Subject: [PATCH] restrict "std" namespace using . --- MissionEditor/Basic.cpp | 2 +- MissionEditor/ComboUInputDlg.h | 2 +- MissionEditor/FinalSun.cpp | 2 +- MissionEditor/FinalSunDlg.cpp | 2 ++ MissionEditor/IniFile.h | 3 ++- MissionEditor/IsoView.cpp | 20 ++++++++++---------- MissionEditor/Loading.cpp | 4 ++-- MissionEditor/MapData.h | 2 +- MissionEditor/MiniMap.cpp | 8 ++++---- MissionEditor/MissionEditor.vcxproj | 4 ++-- MissionEditor/StdAfx.h | 5 ++--- MissionEditor/TextDrawer.cpp | 2 +- MissionEditor/functions.cpp | 4 ++-- MissionEditor/functions.h | 2 ++ MissionEditor/inlines.h | 2 +- MissionEditor/variables.cpp | 2 +- MissionEditor/variables.h | 2 +- 17 files changed, 36 insertions(+), 32 deletions(-) diff --git a/MissionEditor/Basic.cpp b/MissionEditor/Basic.cpp index ceac04e..058b5ed 100644 --- a/MissionEditor/Basic.cpp +++ b/MissionEditor/Basic.cpp @@ -163,7 +163,7 @@ void CBasic::OnChangeName() void CBasic::UpdateData() { // MessageBox("This function ( UpdateData() ) should not be called here... please report to the author."); - errstream << "CBasic::UpdateData() called - should not be called" << endl; + errstream << "CBasic::UpdateData() called - should not be called" << std::endl; errstream.flush(); } diff --git a/MissionEditor/ComboUInputDlg.h b/MissionEditor/ComboUInputDlg.h index be00df2..5b5fa3a 100644 --- a/MissionEditor/ComboUInputDlg.h +++ b/MissionEditor/ComboUInputDlg.h @@ -32,7 +32,7 @@ #include -using namespace std; +using std::vector; #define COMBOUINPUT_HOUSES 0 #define COMBOUINPUT_COUNTRIES 1 diff --git a/MissionEditor/FinalSun.cpp b/MissionEditor/FinalSun.cpp index 48520c5..c507c11 100644 --- a/MissionEditor/FinalSun.cpp +++ b/MissionEditor/FinalSun.cpp @@ -112,7 +112,7 @@ CFinalSunApp::CFinalSunApp() log += "finalalert2log.txt"; #endif m_u8LogFileName = log; - errstream.open(m_u8LogFileName, ios_base::trunc); + errstream.open(m_u8LogFileName, std::ios_base::trunc); errstream << "\uFEFF"; // BOM #ifdef TS_MODE diff --git a/MissionEditor/FinalSunDlg.cpp b/MissionEditor/FinalSunDlg.cpp index 4952b47..e4e4452 100644 --- a/MissionEditor/FinalSunDlg.cpp +++ b/MissionEditor/FinalSunDlg.cpp @@ -69,6 +69,8 @@ static char THIS_FILE[] = __FILE__; #include #include +using std::endl; + extern ACTIONDATA AD; extern BOOL bNoDraw; diff --git a/MissionEditor/IniFile.h b/MissionEditor/IniFile.h index 55807b2..4ad31ba 100644 --- a/MissionEditor/IniFile.h +++ b/MissionEditor/IniFile.h @@ -38,7 +38,8 @@ #include #include "IniHelper.h" -using namespace std; +using std::vector; +using std::map; class CIniFileSection { diff --git a/MissionEditor/IsoView.cpp b/MissionEditor/IsoView.cpp index 7517a85..d2b69d6 100644 --- a/MissionEditor/IsoView.cpp +++ b/MissionEditor/IsoView.cpp @@ -358,8 +358,8 @@ __forceinline void BlitTerrain(void* dst, int x, int y, int dleft, int dtop, int short& left = st.vborder[e].left; short& right = st.vborder[e].right; - auto l = max(left, srcRect.left); - auto r = min(right, static_cast(srcRect.right - 1)); + auto l = std::max(left, srcRect.left); + auto r = std::min(right, static_cast(srcRect.right - 1)); for (i = l; i <= r; i++) { //if (i < srcRect.left || i >= srcRect.right) { @@ -640,7 +640,7 @@ __forceinline void BlitPic(void* dst, int x, int y, int dleft, int dtop, int dpi int l = pLighting[spos]; BYTE* bc = reinterpret_cast(&c); for (int i = 0; i < 4; ++i) - bc[i] = min(255, bc[i] * (200 + l * 300 / 255) / 255); // game seems to overbrighten and have a lot of ambient - if you change this, also change Loading.cpp shp lighting value so that shp light stays at 1.0 + bc[i] = std::min(255, bc[i] * (200 + l * 300 / 255) / 255); // game seems to overbrighten and have a lot of ambient - if you change this, also change Loading.cpp shp lighting value so that shp light stays at 1.0 //bc[i] = min(255, bc[i] * (0 + l * (255 - 0) / 255) / 255); } memcpy(dest, &c, bpp); @@ -3674,7 +3674,7 @@ void CIsoView::DrawTube(const CTube& tube, const DDSURFACEDESC2* lockedDDSD, con const auto col = color ? m_color_converter->GetColor(*color) : (type0 ? m_color_converter->GetColor(255, 0, 0) : m_color_converter->GetColor(0, 0, 255)); ProjectedVec lineOffset = type0 ? ProjectedVec() : ProjectedVec(1, 1); - int lowestHeight = min(Map->GetHeightAt(tube.getStartCoords()), Map->GetHeightAt(tube.getEndCoords())); + int lowestHeight = std::min(Map->GetHeightAt(tube.getStartCoords()), Map->GetHeightAt(tube.getEndCoords())); LineDrawer ld(lockedDDSD->lpSurface, bpp, lockedDDSD->dwWidth, lockedDDSD->dwHeight, lockedDDSD->lPitch); auto startDraw = GetRenderTargetCoordinates(tube.getStartCoords(), lowestHeight); ld.MoveTo(startDraw.x + f_x / 2 + lineOffset.x, startDraw.y + f_y / 2 + lineOffset.y); @@ -4681,7 +4681,7 @@ void CIsoView::OnTimer(UINT_PTR nIDEvent) InvalidateRect(NULL, FALSE); } else { - errstream << "Timer calls InitTMPs()" << endl; + errstream << "Timer calls InitTMPs()" << std::endl; errstream.flush(); theApp.m_loading->InitTMPs(); @@ -5062,10 +5062,10 @@ void CIsoView::DrawMap() auto topRight = GetMapCoordinatesFromClientCoordinates(CPoint(cr.right, 0), false, true); auto bottomLeft = GetMapCoordinatesFromClientCoordinates(CPoint(0, cr.bottom), false, true); auto bottomRight = GetMapCoordinatesFromClientCoordinates(CPoint(cr.right, cr.bottom), false, true); - left = min(topLeft.x, topRight.x); - top = min(topLeft.y, topRight.y); - right = max(bottomLeft.x, bottomRight.x); - bottom = max(bottomLeft.y, bottomRight.y); + left = std::min(topLeft.x, topRight.x); + top = std::min(topLeft.y, topRight.y); + right = std::max(bottomLeft.x, bottomRight.x); + bottom = std::max(bottomLeft.y, bottomRight.y); } // some large buildings may be out of reach: @@ -6029,7 +6029,7 @@ void CIsoView::OnKillFocus(CWnd* pNewWnd) CView::OnKillFocus(pNewWnd); if (rscroll) { - errstream << "Killing scroll" << endl; + errstream << "Killing scroll" << std::endl; errstream.flush(); ReleaseCapture(); diff --git a/MissionEditor/Loading.cpp b/MissionEditor/Loading.cpp index 1b77b1e..cf6339b 100644 --- a/MissionEditor/Loading.cpp +++ b/MissionEditor/Loading.cpp @@ -4562,7 +4562,7 @@ void CLoading::LoadStrings() BYTE* lpData = NULL; DWORD dwSize; if (DoesFileExist((std::string(TSPath) + "\\" + file).c_str())) { - std::ifstream f(std::string(TSPath) + "\\" + file, ios::binary); + std::ifstream f(std::string(TSPath) + "\\" + file, std::ios::binary); if (f.good()) { f.seekg(0, std::ios::end); auto size = f.tellg(); @@ -4582,7 +4582,7 @@ void CLoading::LoadStrings() //HMIXFILE hMix=m_hLanguage; if (hMix) { if (FSunPackLib::XCC_ExtractFile(file, u8AppDataPath + "\\RA2Tmp.csf", hMix)) { - std::ifstream f(u8AppDataPath + "\\RA2Tmp.csf", ios::binary); + std::ifstream f(u8AppDataPath + "\\RA2Tmp.csf", std::ios::binary); if (f.good()) { f.seekg(0, std::ios::end); auto size = f.tellg(); diff --git a/MissionEditor/MapData.h b/MissionEditor/MapData.h index 31aa735..8e8fd29 100644 --- a/MissionEditor/MapData.h +++ b/MissionEditor/MapData.h @@ -34,7 +34,7 @@ extern TILEDATA** tiledata; extern DWORD* tiledata_count; -extern ofstream errstream; +extern std::ofstream errstream; extern map tilesets_start; extern CIniFile* tiles; extern CFinalSunApp theApp; diff --git a/MissionEditor/MiniMap.cpp b/MissionEditor/MiniMap.cpp index 2825009..5e8c74d 100644 --- a/MissionEditor/MiniMap.cpp +++ b/MissionEditor/MiniMap.cpp @@ -97,10 +97,10 @@ void CMiniMap::OnDraw(CDC* pDC) auto topRight = Map->GetMiniMapPos(isoview.GetMapCoordinatesFromClientCoordinates(CPoint(cr.right, 0), false, true)); auto bottomLeft = Map->GetMiniMapPos(isoview.GetMapCoordinatesFromClientCoordinates(CPoint(0, cr.bottom), false, true)); auto bottomRight = Map->GetMiniMapPos(isoview.GetMapCoordinatesFromClientCoordinates(CPoint(cr.right, cr.bottom), false, true)); - auto left = min(topLeft.x, topRight.x); - auto top = min(topLeft.y, topRight.y); - auto right = max(bottomLeft.x, bottomRight.x); - auto bottom = max(bottomLeft.y, bottomRight.y); + auto left = std::min(topLeft.x, topRight.x); + auto top = std::min(topLeft.y, topRight.y); + auto right = std::max(bottomLeft.x, bottomRight.x); + auto bottom = std::max(bottomLeft.y, bottomRight.y); CPoint center(r.right / 2, r.bottom / 2); selRect.left = left * m_scale; diff --git a/MissionEditor/MissionEditor.vcxproj b/MissionEditor/MissionEditor.vcxproj index 79bd618..2f8674e 100644 --- a/MissionEditor/MissionEditor.vcxproj +++ b/MissionEditor/MissionEditor.vcxproj @@ -347,7 +347,7 @@ - RA2_MODE;YR_MODE;%(PreprocessorDefinitions) + NOMINMAX;RA2_MODE;YR_MODE;%(PreprocessorDefinitions) ..\MissionEditorPackLib @@ -419,7 +419,7 @@ - RA2_MODE;YR_MODE;%(PreprocessorDefinitions) + NOMINMAX;RA2_MODE;YR_MODE;%(PreprocessorDefinitions) ..\MissionEditorPackLib diff --git a/MissionEditor/StdAfx.h b/MissionEditor/StdAfx.h index 9433283..0622b6f 100644 --- a/MissionEditor/StdAfx.h +++ b/MissionEditor/StdAfx.h @@ -28,8 +28,7 @@ #pragma once #endif -#define VC_EXTRALEAN -#define NOMINMAX +#define VC_EXTRALEAN #pragma warning(disable: 4503) #pragma warning(disable: 4786) @@ -56,7 +55,7 @@ #include "resource.h" #include "TipDlg.h" - +using std::endl; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ inserts additional declarations exactly above this line. diff --git a/MissionEditor/TextDrawer.cpp b/MissionEditor/TextDrawer.cpp index 05209e7..bbe9ad4 100644 --- a/MissionEditor/TextDrawer.cpp +++ b/MissionEditor/TextDrawer.cpp @@ -164,7 +164,7 @@ ProjectedVec TextDrawer::GetExtent(const std::string& text) const cur.set(0, cur.y + ch + lineOffset); } else if (c >= 32 && c <= 126) { cur.x += cw; - maxpos.set(max(maxpos.x, cur.x), max(maxpos.y, cur.y + ch)); + maxpos.set(std::max(maxpos.x, cur.x), std::max(maxpos.y, cur.y + ch)); } } diff --git a/MissionEditor/functions.cpp b/MissionEditor/functions.cpp index aa5f21f..943a24a 100644 --- a/MissionEditor/functions.cpp +++ b/MissionEditor/functions.cpp @@ -1280,10 +1280,10 @@ CString GetFreeID() "Actions", "AITriggerTypes", }; - if (find(std::begin(typeListSections), std::end(typeListSections), input) != std::end(typeListSections)) { + if (std::find(std::begin(typeListSections), std::end(typeListSections), input) != std::end(typeListSections)) { return true; } - if (find(std::begin(idListSections), std::end(idListSections), input) != std::end(idListSections)) { + if (std::find(std::begin(idListSections), std::end(idListSections), input) != std::end(idListSections)) { return true; } return false; diff --git a/MissionEditor/functions.h b/MissionEditor/functions.h index f4f6156..beadde5 100644 --- a/MissionEditor/functions.h +++ b/MissionEditor/functions.h @@ -25,6 +25,8 @@ #include #include +using std::string; + bool deleteFile(const std::string& u8FilePath); // set the status bar text in the main dialog diff --git a/MissionEditor/inlines.h b/MissionEditor/inlines.h index 07f3c88..91b92d2 100644 --- a/MissionEditor/inlines.h +++ b/MissionEditor/inlines.h @@ -195,7 +195,7 @@ inline CString SetParam(const CString& data, const int param, const CString& val if (param < 0) return data; std::vector params = SplitParams(data); - params.resize(max(param + 1, static_cast(params.size()))); + params.resize(std::max(param + 1, static_cast(params.size()))); params[param] = value; return Join(",", params); } diff --git a/MissionEditor/variables.cpp b/MissionEditor/variables.cpp index 7096691..d3685f5 100644 --- a/MissionEditor/variables.cpp +++ b/MissionEditor/variables.cpp @@ -183,7 +183,7 @@ SMUDGE_INFO smudgeinfo[0x0F00]; #endif /* error output */ -ofstream errstream; +std::ofstream errstream; /* the finalsun app object */ CFinalSunApp theApp; diff --git a/MissionEditor/variables.h b/MissionEditor/variables.h index da8ef19..4bc6295 100644 --- a/MissionEditor/variables.h +++ b/MissionEditor/variables.h @@ -114,7 +114,7 @@ extern SMUDGE_INFO smudgeinfo[0x0F00]; extern CFinalSunApp theApp; /* error output */ -extern ofstream errstream; +extern std::ofstream errstream; // application path extern char AppPath[MAX_PATH + 1];