Skip to content

Commit 66a75ca

Browse files
committed
Merge remote-tracking branch 'origin/end_return_refactor' into end_return_refactor
2 parents 9aee65b + 97be026 commit 66a75ca

File tree

103 files changed

+383
-375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+383
-375
lines changed

Core/GameEngine/Source/Common/System/Debug.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ void DebugInit(int flags)
381381
*(pEnd + 1) = 0;
382382
}
383383

384+
static_assert(ARRAY_SIZE(theLogFileNamePrev) >= ARRAY_SIZE(dirbuf), "Incorrect array size");
384385
strcpy(theLogFileNamePrev, dirbuf);
385386
strlcat(theLogFileNamePrev, gAppPrefix, ARRAY_SIZE(theLogFileNamePrev));
386387
strlcat(theLogFileNamePrev, DEBUG_FILE_NAME_PREV, ARRAY_SIZE(theLogFileNamePrev));
@@ -391,6 +392,7 @@ void DebugInit(int flags)
391392
}
392393
strlcat(theLogFileNamePrev, ".txt", ARRAY_SIZE(theLogFileNamePrev));
393394

395+
static_assert(ARRAY_SIZE(theLogFileName) >= ARRAY_SIZE(dirbuf), "Incorrect array size");
394396
strcpy(theLogFileName, dirbuf);
395397
strlcat(theLogFileName, gAppPrefix, ARRAY_SIZE(theLogFileNamePrev));
396398
strlcat(theLogFileName, DEBUG_FILE_NAME, ARRAY_SIZE(theLogFileNamePrev));
@@ -730,9 +732,9 @@ void ReleaseCrash(const char *reason)
730732
return; // We are shutting down, and TheGlobalData has been freed. jba. [4/15/2003]
731733
}
732734

733-
strcpy(prevbuf, TheGlobalData->getPath_UserData().str());
735+
strlcpy(prevbuf, TheGlobalData->getPath_UserData().str(), ARRAY_SIZE(prevbuf));
734736
strlcat(prevbuf, RELEASECRASH_FILE_NAME_PREV, ARRAY_SIZE(prevbuf));
735-
strcpy(curbuf, TheGlobalData->getPath_UserData().str());
737+
strlcpy(curbuf, TheGlobalData->getPath_UserData().str(), ARRAY_SIZE(curbuf));
736738
strlcat(curbuf, RELEASECRASH_FILE_NAME, ARRAY_SIZE(curbuf));
737739

738740
remove(prevbuf);
@@ -819,9 +821,9 @@ void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m)
819821
char prevbuf[ _MAX_PATH ];
820822
char curbuf[ _MAX_PATH ];
821823

822-
strcpy(prevbuf, TheGlobalData->getPath_UserData().str());
824+
strlcpy(prevbuf, TheGlobalData->getPath_UserData().str(), ARRAY_SIZE(prevbuf));
823825
strlcat(prevbuf, RELEASECRASH_FILE_NAME_PREV, ARRAY_SIZE(prevbuf));
824-
strcpy(curbuf, TheGlobalData->getPath_UserData().str());
826+
strlcpy(curbuf, TheGlobalData->getPath_UserData().str(), ARRAY_SIZE(curbuf));
825827
strlcat(curbuf, RELEASECRASH_FILE_NAME, ARRAY_SIZE(curbuf));
826828

827829
remove(prevbuf);

Core/GameEngine/Source/Common/System/GameMemory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2975,7 +2975,7 @@ void MemoryPoolFactory::memoryPoolUsageReport( const char* filename, FILE *appen
29752975
if( !appendToFileInstead )
29762976
{
29772977
char tmp[256];
2978-
strcpy(tmp,filename);
2978+
strlcpy(tmp, filename, ARRAY_SIZE(tmp));
29792979
strlcat(tmp, ".csv", ARRAY_SIZE(tmp));
29802980
perfStatsFile = fopen(tmp, "w");
29812981
}

Core/GameEngineDevice/Source/StdDevice/Common/StdLocalFileSystem.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ Bool StdLocalFileSystem::doesFileExist(const Char *filename) const
211211
void StdLocalFileSystem::getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList & filenameList, Bool searchSubdirectories) const
212212
{
213213

214-
char search[_MAX_PATH];
215214
AsciiString asciisearch;
216215
asciisearch = originalDirectory;
217216
asciisearch.concat(currentDirectory);
@@ -227,17 +226,15 @@ void StdLocalFileSystem::getFileListInDirectory(const AsciiString& currentDirect
227226
std::replace(fixedDirectory.begin(), fixedDirectory.end(), '\\', '/');
228227
#endif
229228

230-
strcpy(search, fixedDirectory.c_str());
231-
232229
Bool done = FALSE;
233230
std::error_code ec;
234231

235-
auto iter = std::filesystem::directory_iterator(search, ec);
232+
auto iter = std::filesystem::directory_iterator(fixedDirectory.c_str(), ec);
236233
// The default iterator constructor creates an end iterator
237234
done = iter == std::filesystem::directory_iterator();
238235

239236
if (ec) {
240-
DEBUG_LOG(("StdLocalFileSystem::getFileListInDirectory - Error opening directory %s", search));
237+
DEBUG_LOG(("StdLocalFileSystem::getFileListInDirectory - Error opening directory %s", fixedDirectory.c_str()));
241238
return;
242239
}
243240

Core/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,14 @@ void Win32LocalFileSystem::getFileListInDirectory(const AsciiString& currentDire
127127
HANDLE fileHandle = NULL;
128128
WIN32_FIND_DATA findData;
129129

130-
char search[_MAX_PATH];
131130
AsciiString asciisearch;
132131
asciisearch = originalDirectory;
133132
asciisearch.concat(currentDirectory);
134133
asciisearch.concat(searchName);
135-
strcpy(search, asciisearch.str());
136134

137135
Bool done = FALSE;
138136

139-
fileHandle = FindFirstFile(search, &findData);
137+
fileHandle = FindFirstFile(asciisearch.str(), &findData);
140138
done = (fileHandle == INVALID_HANDLE_VALUE);
141139

142140
while (!done) {

Core/Libraries/Source/WWVegas/WW3D2/collect.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,8 @@ WW3DErrorType CollectionDefClass::Load(ChunkLoadClass & cload)
10151015
if (cload.Read(&header,sizeof(header)) != sizeof(header)) goto Error;
10161016
if (!cload.Close_Chunk()) goto Error;
10171017

1018-
strlcpy(Name,header.Name,W3D_NAME_LEN);
1018+
static_assert(ARRAY_SIZE(Name) >= ARRAY_SIZE(header.Name), "Incorrect array size");
1019+
strcpy(Name,header.Name);
10191020
ObjectNames.Resize(header.RenderObjectCount);
10201021

10211022
while (cload.Open_Chunk()) {

Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,17 @@ int HCompressedAnimClass::Load_W3D(ChunkLoadClass & cload)
255255

256256
cload.Close_Chunk();
257257

258-
strcpy(Name,aheader.HierarchyName);
258+
static_assert(ARRAY_SIZE(Name) >= ARRAY_SIZE(aheader.HierarchyName), "Incorrect array size");
259+
strcpy(Name, aheader.HierarchyName);
259260
strlcat(Name, ".", ARRAY_SIZE(Name));
260261
strlcat(Name, aheader.Name, ARRAY_SIZE(Name));
261262

262263
// TSS chasing crash bug 05/26/99
263264
WWASSERT(HierarchyName != NULL);
264265
WWASSERT(aheader.HierarchyName != NULL);
265266
WWASSERT(sizeof(HierarchyName) >= W3D_NAME_LEN);
266-
strlcpy(HierarchyName,aheader.HierarchyName,W3D_NAME_LEN);
267+
static_assert(ARRAY_SIZE(HierarchyName) >= ARRAY_SIZE(aheader.HierarchyName), "Incorrect array size");
268+
strcpy(HierarchyName, aheader.HierarchyName);
267269

268270
HTreeClass * base_pose = WW3DAssetManager::Get_Instance()->Get_HTree(HierarchyName);
269271
if (base_pose == NULL) {

Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,12 @@ int HModelDefClass::Load_W3D(ChunkLoadClass & cload)
148148
/*
149149
** process the header info
150150
*/
151-
strlcpy(ModelName,header.Name,W3D_NAME_LEN);
152-
strlcpy(BasePoseName,header.HierarchyName,W3D_NAME_LEN);
153-
strcpy(Name,ModelName);
151+
static_assert(ARRAY_SIZE(ModelName) >= ARRAY_SIZE(header.Name), "Incorrect array size");
152+
static_assert(ARRAY_SIZE(BasePoseName) >= ARRAY_SIZE(header.HierarchyName), "Incorrect array size");
153+
static_assert(ARRAY_SIZE(Name) >= ARRAY_SIZE(ModelName), "Incorrect array size");
154+
strcpy(ModelName, header.Name);
155+
strcpy(BasePoseName, header.HierarchyName);
156+
strcpy(Name, ModelName);
154157

155158
/*
156159
** Just allocate a node for the number of sub objects we're expecting
@@ -232,7 +235,8 @@ bool HModelDefClass::read_connection(ChunkLoadClass & cload,HmdlNodeDefStruct *
232235
return false;
233236
}
234237

235-
strcpy(node->RenderObjName,ModelName);
238+
static_assert(ARRAY_SIZE(node->RenderObjName) >= ARRAY_SIZE(ModelName), "Incorrect array size");
239+
strcpy(node->RenderObjName, ModelName);
236240
strlcat(node->RenderObjName, ".", ARRAY_SIZE(node->RenderObjName));
237241
strlcat(node->RenderObjName, con.RenderObjName, ARRAY_SIZE(node->RenderObjName));
238242

Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,8 @@ Render2DSentenceClass::Build_Sentence (const WCHAR *text, int *hkX, int *hkY)
11481148
return ;
11491149
}
11501150

1151+
if (Font == NULL)
1152+
return;
11511153

11521154
if(Centered && (WrapWidth > 0 || wcschr(text,L'\n')))
11531155
Build_Sentence_Centered(text, hkX, hkY);
@@ -1473,7 +1475,7 @@ FontCharsClass::Update_Current_Buffer (int char_width)
14731475
// Create_GDI_Font
14741476
//
14751477
////////////////////////////////////////////////////////////////////////////////////
1476-
void
1478+
bool
14771479
FontCharsClass::Create_GDI_Font (const char *font_name)
14781480
{
14791481
HDC screen_dc = ::GetDC ((HWND)WW3D::Get_Window());
@@ -1567,6 +1569,8 @@ FontCharsClass::Create_GDI_Font (const char *font_name)
15671569
if (doingGenerals) {
15681570
CharOverhang = 0;
15691571
}
1572+
1573+
return GDIFont != NULL && GDIBitmap != NULL;
15701574
}
15711575

15721576

@@ -1613,7 +1617,7 @@ FontCharsClass::Free_GDI_Font (void)
16131617
// Initialize_GDI_Font
16141618
//
16151619
////////////////////////////////////////////////////////////////////////////////////
1616-
void
1620+
bool
16171621
FontCharsClass::Initialize_GDI_Font (const char *font_name, int point_size, bool is_bold)
16181622
{
16191623
//
@@ -1631,8 +1635,8 @@ FontCharsClass::Initialize_GDI_Font (const char *font_name, int point_size, bool
16311635
//
16321636
// Create the actual font object
16331637
//
1634-
Create_GDI_Font (font_name);
1635-
}
1638+
return Create_GDI_Font (font_name);
1639+
}
16361640

16371641

16381642
////////////////////////////////////////////////////////////////////////////////////

Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class FontCharsClass : public W3DMPO, public RefCountClass
8282
FontCharsClass *AlternateUnicodeFont;
8383

8484

85-
void Initialize_GDI_Font( const char *font_name, int point_size, bool is_bold );
85+
bool Initialize_GDI_Font( const char *font_name, int point_size, bool is_bold );
8686
bool Is_Font( const char *font_name, int point_size, bool is_bold );
8787
const char * Get_Name( void ) { return Name; }
8888

@@ -99,7 +99,7 @@ class FontCharsClass : public W3DMPO, public RefCountClass
9999
//
100100
// Private methods
101101
//
102-
void Create_GDI_Font( const char *font_name );
102+
bool Create_GDI_Font( const char *font_name );
103103
void Free_GDI_Font( void );
104104
const FontCharsClassCharDataStruct * Store_GDI_Char( WCHAR ch );
105105
void Update_Current_Buffer( int char_width );

Core/Libraries/Source/WWVegas/WW3D2/ringobj.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ RingPrototypeClass::RingPrototypeClass (void)
11991199
RingPrototypeClass::RingPrototypeClass(RingRenderObjClass *ring)
12001200
{
12011201
::memset (&Definition, 0, sizeof (Definition));
1202-
::strcpy (Definition.Name, ring->Get_Name ());
1202+
strlcpy(Definition.Name, ring->Get_Name(), ARRAY_SIZE(Definition.Name));
12031203

12041204
Definition.AnimDuration = ring->AnimDuration;
12051205
Definition.Attributes = ring->Get_Flags ();
@@ -1230,7 +1230,7 @@ RingPrototypeClass::RingPrototypeClass(RingRenderObjClass *ring)
12301230
filename = name;
12311231
}
12321232

1233-
::strcpy (Definition.TextureName, filename);
1233+
strlcpy(Definition.TextureName, filename, ARRAY_SIZE(Definition.TextureName));
12341234
}
12351235

12361236
//

0 commit comments

Comments
 (0)