Skip to content

Commit aed6784

Browse files
committed
Don’t use Base_directory before it’s been set
Before this change, the Base_directory variable would get accessed before we set its value. This seems to be OK. I’m not sure about the details, but it seems like C++ guarantees that Base_directory will be filled with zeros when it’s created. That being said, the code that was modified by this commit used to be misleading. The code would copy the contents of the Base_directory variable into another variable named path. If you read the code, you would think that path would be set to something along the lines of "C:\\Games\\Descent3" or "/home/username/D3-open-source", but in reality, path would be set to "". This change makes it clear that path is guaranteed to be set to "". The main motivation behind this commit is to make it easier to create a future commit. That future commit will replace Base_directory with a new variable named Base_directories. Base_directories will have a different data type that does not get filled with zeros by default. In other words, we need to set the new Base_directories variable before we use it. Unfortunately, neither the current Base_directory variable nor the future Base_directories variable will get set in time. Both of them will be set after path variable gets set. This commit allows me to not worry about that detail when I create the future Base_directories commit.
1 parent 01a28c5 commit aed6784

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Descent3/sdlmain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class oeD3LnxDatabase : public oeLnxAppDatabase {
176176
char *netdir = getenv("D3_DIR");
177177

178178
if (!dir)
179-
strcpy(path, Base_directory);
179+
strcpy(path, "");
180180
else
181181
strcpy(path, dir);
182182

0 commit comments

Comments
 (0)