projects/guix·blob python-team · refs

582 lines · 29.8 KiB

1diff --git a/SamTFE/Sources/Engine/Base/Stream.cpp b/SamTFE/Sources/Engine/Base/Stream.cpp
2index f30213a..8f2aa82 100644
3--- a/SamTFE/Sources/Engine/Base/Stream.cpp
4+++ b/SamTFE/Sources/Engine/Base/Stream.cpp
5@@ -78,7 +78,9 @@ ULONG _ulVirtuallyAllocatedSpaceTotal = 0;
6 // global string with application path (utf-8)
7 CTFileName _fnmApplicationPath;
8 CTFileName _fnmApplicationPathTMP; // home dir or application path
9-
10+#ifdef PLATFORM_UNIX
11+CTFileName _fnmAdditionalDirPath; // additional search path
12+#endif
13 // global string with filename of the started application
14 CTFileName _fnmApplicationExe;
15 // global string with user-specific writable directory.
16@@ -220,6 +222,17 @@ void InitStreams(void)
17 }
18 delete files;
19
20+#ifdef PLATFORM_UNIX
21+ // additional search path
22+ files = _pFileSystem->FindFiles(_fnmAdditionalDirPath, "*.gro");
23+ max = files->Count();
24+ for (i = 0; i < max; i++) {
25+ UNZIPAddArchive( _fnmAdditionalDirPath + ((*files)[i]) );
26+ }
27+ UNZIPAddArchive( _fnmApplicationPath + "share/serioussam/SE1_10b.gro");
28+ delete files;
29+#endif
30+
31 // if there is a mod active
32 if (_fnmMod!="") {
33 // for each group file in mod directory
34@@ -1655,19 +1668,20 @@ INDEX ExpandFilePath(ULONG ulType, const CTFileName &fnmFile, CTFileName &fnmExp
35
36 int _savegame = strncmp((const char *)fnmFile, (const char *) "SaveGame", (size_t) 8 );
37 int _usercontrols = strncmp((const char *)fnmFile, (const char *) "Controls", (size_t) 8 );
38- int _persistentsym = strncmp((const char *)fnmFile, (const char *) "Scripts/PersistentSymbols.ini", (size_t) 29 );
39- int _gamesgms = strncmp((const char *)fnmFile, (const char *) "Data/SeriousSam.gms", (size_t) 19 );
40- int _comsolehistory = strncmp((const char *)fnmFile, (const char *) "Temp/ConsoleHistory.txt", (size_t) 23 );
41- int _userdemos = strncmp((const char *)fnmFile, (const char *) "Demos/Demo", (size_t) 10 );
42+ int _persistentsym = strncmp((const char *)fnmFile, (const char *) "Scripts", (size_t) 7 );
43+ int _gamesgms = strncmp((const char *)fnmFile, (const char *) "Data", (size_t) 4 );
44+ int _comsolehistory = strncmp((const char *)fnmFile, (const char *) "Temp", (size_t) 4 );
45+ int _userdemos = strncmp((const char *)fnmFile, (const char *) "Demo", (size_t) 4 );
46 int _playersplr = strncmp((const char *)fnmFile, (const char *) "Players", (size_t) 7 );
47 int _screenshots = strncmp((const char *)fnmFile, (const char *) "ScreenShots", (size_t) 11 );
48 int _levelsvis = strncmp((const char *)fnmFile, (const char *) "Levels", (size_t) 6 );
49-
50- //CPrintF("ExpandFilePath: %s\n",(const char *) fnmFile);
51+ int _help = strncmp((const char *)fnmFile, (const char *) "Help", (size_t) 4 );
52
53 if(( _savegame == 0 || _persistentsym == 0 || _gamesgms == 0 ||
54 _comsolehistory == 0 || _userdemos == 0 || _playersplr == 0 || _screenshots == 0) && ( _bPortableVersion == FALSE)) {
55 _fnmApplicationPathTMP = _fnmUserDir;
56+ } else if (_help == 0) {
57+ _fnmApplicationPathTMP = _fnmAdditionalDirPath;
58 } else {
59 _fnmApplicationPathTMP = _fnmApplicationPath;
60 }
61@@ -1675,6 +1689,8 @@ INDEX ExpandFilePath(ULONG ulType, const CTFileName &fnmFile, CTFileName &fnmExp
62 if( _levelsvis == 0 && _bPortableVersion == FALSE) {
63 if (fnmFileAbsolute.FileExt()==".vis") {
64 _fnmApplicationPathTMP = _fnmUserDir;
65+ } else {
66+ _fnmApplicationPathTMP = _fnmAdditionalDirPath;
67 }
68 }
69
70diff --git a/SamTFE/Sources/Engine/Base/Stream.h b/SamTFE/Sources/Engine/Base/Stream.h
71index 8ff3de6..1e5aeae 100644
72--- a/SamTFE/Sources/Engine/Base/Stream.h
73+++ b/SamTFE/Sources/Engine/Base/Stream.h
74@@ -391,6 +391,10 @@ ENGINE_API void MakeDirList(
75
76 // global string with application path
77 ENGINE_API extern CTFileName _fnmApplicationPath;
78+#ifdef PLATFORM_UNIX
79+// global string with additional search path
80+ENGINE_API extern CTFileName _fnmAdditionalDirPath;
81+#endif
82 // global string with user-specific writable directory.
83 ENGINE_API extern CTFileName _fnmUserDir;
84 // global string with current MOD path
85diff --git a/SamTFE/Sources/Engine/Engine.cpp b/SamTFE/Sources/Engine/Engine.cpp
86index e6f7c4f..2b6cda5 100644
87--- a/SamTFE/Sources/Engine/Engine.cpp
88+++ b/SamTFE/Sources/Engine/Engine.cpp
89@@ -115,6 +115,7 @@ static CTString sys_strModExt = "";
90 // Path vars
91 static INDEX sys_iGameBits = 0;
92 ENGINE_API INDEX sys_iSysPath = 0;
93+ENGINE_API INDEX sys_iGameDataNotFound = 0;
94
95 // Entities Adjesters
96 ENGINE_API FLOAT _fPlayerFOVAdjuster = 1.0f;
97@@ -676,10 +677,12 @@ ENGINE_API void SE_InitEngine(CTString strGameID)
98 _fnmApplicationPath = CTString(strDirPath);
99 _fnmApplicationExe = CTString(strExePath);
100 #ifdef PLATFORM_UNIX
101+ //_fnmAdditionalDirPath = "/usr/share/" + strGameID + "/";
102 // rcg01012002 calculate user dir.
103 char buf[MAX_PATH];
104 _pFileSystem->GetUserDirectory(buf, sizeof (buf));
105 _fnmUserDir = CTString(buf);
106+ _fnmAdditionalDirPath = _fnmUserDir + "/gamedata/";
107 #endif
108 try {
109 _fnmApplicationExe.RemoveApplicationPath_t();
110@@ -742,147 +745,17 @@ ENGINE_API void SE_InitEngine(CTString strGameID)
111 CPrintF(TRANSV("Running %d-bit version\n"), sys_iGameBits);
112
113 #ifdef PLATFORM_UNIX
114-#if defined(__OpenBSD__) || defined(__FreeBSD__)
115- int _isystempath = strncmp((const char *)strExePath, (const char *) "/usr/local/bin/", (size_t) 15 );
116-#elif defined(__NetBSD__)
117- int _isystempath = strncmp((const char *)strExePath, (const char *) "/usr/pkg/bin/", (size_t) 13 );
118-#else
119- int _isystempath = strncmp((const char *)strExePath, (const char *) "/usr/bin/", (size_t) 9 );
120-#endif
121- if( _isystempath == 0 ) {
122- sys_iSysPath = 1; // using system path
123- } else {
124- sys_iSysPath = 0; // using standarted path
125- }
126-
127- // get library path for mods
128- _fnmModLibPath = "";
129-#if defined(__OpenBSD__) || defined(__FreeBSD__)
130- if( sys_iSysPath == 1 ) {
131- _fnmModLibPath = "/usr/local/lib/" + strGameID + "/";
132-#elif defined(__NetBSD__)
133- if( sys_iSysPath == 1 ) {
134- _fnmModLibPath = "/usr/pkg/lib/" + strGameID + "/";
135-#else
136- if( sys_iSysPath == 1 && sys_iGameBits == 64 && _pFileSystem->IsDirectory((const char *) "/usr/lib/aarch64-linux-gnu/" + strGameID)) {
137- _fnmModLibPath = "/usr/lib/aarch64-linux-gnu/" + strGameID + "/";
138- } else if( sys_iSysPath == 1 && sys_iGameBits == 32 && _pFileSystem->IsDirectory((const char *) "/usr/lib/arm-linux-gnueabihf/" + strGameID)) {
139- _fnmModLibPath = "/usr/lib/arm-linux-gnueabihf/" + strGameID + "/";
140- } else if( sys_iSysPath == 1 && sys_iGameBits == 64 && _pFileSystem->IsDirectory((const char *) "/usr/lib/riscv64-linux-gnu/" + strGameID)) {
141- _fnmModLibPath = "/usr/lib/riscv64-linux-gnu/" + strGameID + "/";
142- } else if( sys_iSysPath == 1 && sys_iGameBits == 64 && _pFileSystem->IsDirectory((const char *) "/usr/lib/s390x-linux-gnu/" + strGameID)) {
143- _fnmModLibPath = "/usr/lib/s390x-linux-gnu/" + strGameID + "/";
144- } else if( sys_iSysPath == 1 && sys_iGameBits == 64 && _pFileSystem->IsDirectory((const char *) "/usr/lib/powerpc64-linux-gnu/" + strGameID)) {
145- _fnmModLibPath = "/usr/lib/powerpc64-linux-gnu/" + strGameID + "/";
146- } else if( sys_iSysPath == 1 && sys_iGameBits == 64 && _pFileSystem->IsDirectory((const char *) "/usr/lib/x86_64-linux-gnu/" + strGameID)) {
147- _fnmModLibPath = "/usr/lib/x86_64-linux-gnu/" + strGameID + "/";
148- } else if( sys_iSysPath == 1 && sys_iGameBits == 32 && _pFileSystem->IsDirectory((const char *) "/usr/lib/i386-linux-gnu/" + strGameID)) {
149- _fnmModLibPath = "/usr/lib/i386-linux-gnu/" + strGameID + "/";
150- } else if( sys_iSysPath == 1 && sys_iGameBits == 64 && _pFileSystem->IsDirectory((const char *) "/usr/lib64/" + strGameID)) {
151- _fnmModLibPath = "/usr/lib64/" + strGameID + "/";
152- } else if( sys_iSysPath == 1 && sys_iGameBits == 32 && _pFileSystem->IsDirectory((const char *) "/usr/lib//" + strGameID)) {
153- _fnmModLibPath = "/usr/lib/" + strGameID + "/";
154-#endif
155- } else if( sys_iSysPath == 0 ) {
156- _fnmModLibPath = _fnmApplicationPath;
157- } else {
158- CPrintF(TRANSV("ERROR: Game libraries not ound!\n"));
159- FatalError(TRANSV("Failed to search game libraries installed!\nPlease reinstall the game.\nSee the log for more details.\nGame log is here: ~/.local/share/Serious-Engine/%s/SeriousSam.log"),(const char *) strGameID);
160- }
161
162- if( sys_iSysPath == 1 ) { // search game data
163- CTFileName _fnm_usr_TestFile, _fnm_local_TestFile, _fnm_home_TestFile;
164- CTString _fnmUserDataPath, _fnm_TestFile;
165- int _fd;
166-
167- if( access((const char *) _fnmUserDir+_strLogFile+".cfg", F_OK) == 0 ) {
168- _fd = open((const char *) _fnmUserDir+_strLogFile+".cfg", O_RDONLY,S_IRUSR);
169- size_t x = read(_fd, _path, 2048);
170- _fnmUserDataPath = (CTString)_path + "/";
171- close(_fd);
172- CPrintF(TRANSV("Testing home path: %s\n"), (const char *) _fnmUserDataPath);
173- } else {
174- _fnmUserDataPath = "";
175- }
176-
177- // set testing files
178- if( strGameID == "serioussamse") {
179- _fnm_TestFile = "SE1_00_Levels.gro";
180- } else {
181- _fnm_TestFile = "1_00_music.gro";
182- }
183- CPrintF(TRANSV("Testing file: %s\n"), (const char *) _fnm_TestFile);
184-#if defined(__OpenBSD__) || defined(__FreeBSD__)
185- _fnm_usr_TestFile = "/usr/local/share/" + strGameID + "/" + _fnm_TestFile; // data in usr
186-#elif defined(__NetBSD__)
187- _fnm_usr_TestFile = "/usr/pkg/share/" + strGameID + "/" + _fnm_TestFile; // data in usr
188-#else
189- _fnm_usr_TestFile = "/usr/share/" + strGameID + "/" + _fnm_TestFile; // data in usr
190-#endif
191- _fnm_local_TestFile = _fnmUserDir + _fnm_TestFile; // data in home .local
192- _fnm_home_TestFile = (const char *)_fnmUserDataPath + _fnm_TestFile;
193- // test
194- if( access((const char *) _fnm_home_TestFile, F_OK) != 0 ) {
195- CPrintF(TRANSV("Testing system path: %s\n"), (const char *) _fnm_usr_TestFile);
196- CPrintF(TRANSV("Testing local path: %s\n"), (const char *) _fnm_local_TestFile);
197- if( access((const char *) _fnm_usr_TestFile, F_OK) == 0 ) {
198-#if defined(__OpenBSD__) || defined(__FreeBSD__)
199- _fnmApplicationPath = "/usr/local/share/" + strGameID + "/"; // all game data
200-#elif defined(__NetBSD__)
201- _fnmApplicationPath = "/usr/pkg/share/" + strGameID + "/"; // all game data
202-#else
203- _fnmApplicationPath = "/usr/share/" + strGameID + "/"; // all game data
204-#endif
205- CPrintF(TRANSV("Found usr path: %s\n"), (const char *) _fnmUserDataPath);
206- } else if( access((const char *) _fnm_local_TestFile, F_OK) == 0 ) {
207- _fnmApplicationPath = _fnmUserDir; // all game data
208- CPrintF(TRANSV("Found local path: %s\n"), (const char *) _fnmUserDataPath);
209- } else {
210- // search in home dir
211- // BOOL YesNoMessage(const char *strFormat, ...)
212-#if defined(__OpenBSD__) || defined(__FreeBSD__)
213- InfoMessage(TRANS("No game files were found in /usr/local/share/%s/\n or %s\nThe home directory will be searched."),(const char *) strGameID,(const char *) _fnmUserDir);
214-#elif defined(__NetBSD__)
215- InfoMessage(TRANS("No game files were found in /usr/pkg/share/%s/\n or %s\nThe home directory will be searched."),(const char *) strGameID,(const char *) _fnmUserDir);
216-#else
217- InfoMessage(TRANS("No game files were found in /usr/share/%s/\n or %s\nThe home directory will be searched."),(const char *) strGameID,(const char *) _fnmUserDir);
218-#endif
219- struct passwd *pw = getpwuid(getuid());
220- const char *_homedir = pw->pw_dir;
221- _testfiledone = 0;
222- _list_dir(_homedir, 0, strGameID);
223- CTString _PATH;
224- _PATH = (CTString)_path;
225- _fnmApplicationPath = (CTFileName) _PATH + "/";
226- _fnm_home_TestFile = (CTFileName) _PATH + "/" + _fnm_TestFile;
227- if( access((const char *) _fnm_home_TestFile, F_OK) == 0 ) {
228- //_fnmApplicationPath = (CTFileName) _PATH + "/";
229- CPrintF(TRANSV("Found home path: %s\n"), (const char *) _fnm_home_TestFile);
230- _fd = open((const char *) _fnmUserDir+_strLogFile+".cfg", O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
231- size_t x = write(_fd, _path, 2048);
232- close(_fd);
233- } else {
234- CPrintF(TRANSV("ERROR: Game data not ound!\n"));
235- _fnmUserDataPath = "";
236-#if defined(__OpenBSD__) || defined(__FreeBSD__)
237- FatalError(TRANSV("Failed to search game data!\nPlease put the game data in the paths:\n/usr/local/share/%s/\n or %s\n or somewhere in your home directory\nSee the log for more details.\nGame log is here: ~/.local/share/Serious-Engine/%s/SeriousSam.log"),(const char *) strGameID,(const char *) _fnmUserDir,(const char *) strGameID);
238-#elif defined(__NetBSD__)
239- FatalError(TRANSV("Failed to search game data!\nPlease put the game data in the paths:\n/usr/pkg/share/%s/\n or %s\n or somewhere in your home directory\nSee the log for more details.\nGame log is here: ~/.local/share/Serious-Engine/%s/SeriousSam.log"),(const char *) strGameID,(const char *) _fnmUserDir,(const char *) strGameID);
240-#else
241- FatalError(TRANSV("Failed to search game data!\nPlease put the game data in the paths:\n/usr/share/%s/\n or %s\n or somewhere in your home directory\nSee the log for more details.\nGame log is here: ~/.local/share/Serious-Engine/%s/SeriousSam.log"),(const char *) strGameID,(const char *) _fnmUserDir,(const char *) strGameID);
242-#endif
243- }
244- }
245- } else {
246- CPrintF(TRANSV("Found path: %s\n"), (const char *) _fnmUserDataPath);
247- _fnmApplicationPath = _fnmUserDataPath; // all game data
248- }
249- }
250+ // using system path
251+ sys_iSysPath = 1;
252+ // library path for mods
253+ _fnmModLibPath = _fnmApplicationPath + "lib/" + strGameID + "/";
254
255 // print info on the started application
256 CPrintF(TRANSV("Executable: %s\n"), (const char *) strExePath);
257 CPrintF(TRANSV("Assumed engine data directory: %s\n"), (const char *) _fnmApplicationPath);
258 CPrintF(TRANSV("Assumed mods library directory: %s\n"), (const char *) _fnmModLibPath);
259+ CPrintF(TRANSV("Assumed additional data directory: %s\n"), (const char *) _fnmAdditionalDirPath);
260 #endif
261
262 CPrintF("\n");
263diff --git a/SamTFE/Sources/Engine/Engine.h b/SamTFE/Sources/Engine/Engine.h
264index 8307f70..6ba88a4 100644
265--- a/SamTFE/Sources/Engine/Engine.h
266+++ b/SamTFE/Sources/Engine/Engine.h
267@@ -207,6 +207,7 @@ extern ENGINE_API BOOL _bWorldEditorApp; // is this world edtior app
268 extern ENGINE_API CTString _strLogFile;
269 extern ENGINE_API CTFileName _fnmModLibPath;
270 extern ENGINE_API INDEX sys_iSysPath;
271+extern ENGINE_API INDEX sys_iGameDataNotFound;
272 #ifdef PLATFORM_WIN32
273 //
274 extern ENGINE_API FLOAT _fPlayerFOVAdjuster;
275diff --git a/SamTSE/Sources/Engine/Base/Stream.cpp b/SamTSE/Sources/Engine/Base/Stream.cpp
276index f30213a..9a2ffaf 100644
277--- a/SamTSE/Sources/Engine/Base/Stream.cpp
278+++ b/SamTSE/Sources/Engine/Base/Stream.cpp
279@@ -78,7 +78,9 @@ ULONG _ulVirtuallyAllocatedSpaceTotal = 0;
280 // global string with application path (utf-8)
281 CTFileName _fnmApplicationPath;
282 CTFileName _fnmApplicationPathTMP; // home dir or application path
283-
284+#ifdef PLATFORM_UNIX
285+CTFileName _fnmAdditionalDirPath; // additional search path
286+#endif
287 // global string with filename of the started application
288 CTFileName _fnmApplicationExe;
289 // global string with user-specific writable directory.
290@@ -194,15 +196,16 @@ void InitStreams(void)
291 }
292 }
293 // find eventual extension for the mod's dlls
294- _strModExt = "";
295+ _strModExt = "MP";
296 // DG: apparently both ModEXT.txt and ModExt.txt exist in the wild.
297+/*
298 CTFileName tmp;
299 if(ExpandFilePath(EFP_READ, CTString("ModEXT.txt"), tmp) != EFP_NONE) {
300 LoadStringVar(CTString("ModEXT.txt"), _strModExt);
301 } else {
302 LoadStringVar(CTString("ModExt.txt"), _strModExt);
303 }
304-
305+*/
306
307 CPrintF(TRANSV("Loading group files...\n"));
308
309@@ -220,6 +223,17 @@ void InitStreams(void)
310 }
311 delete files;
312
313+#ifdef PLATFORM_UNIX
314+ // additional search path
315+ files = _pFileSystem->FindFiles(_fnmAdditionalDirPath, "*.gro");
316+ max = files->Count();
317+ for (i = 0; i < max; i++) {
318+ UNZIPAddArchive( _fnmAdditionalDirPath + ((*files)[i]) );
319+ }
320+ UNZIPAddArchive( _fnmApplicationPath + "share/serioussamse/SE1_10b.gro");
321+ delete files;
322+#endif
323+
324 // if there is a mod active
325 if (_fnmMod!="") {
326 // for each group file in mod directory
327@@ -1655,19 +1669,20 @@ INDEX ExpandFilePath(ULONG ulType, const CTFileName &fnmFile, CTFileName &fnmExp
328
329 int _savegame = strncmp((const char *)fnmFile, (const char *) "SaveGame", (size_t) 8 );
330 int _usercontrols = strncmp((const char *)fnmFile, (const char *) "Controls", (size_t) 8 );
331- int _persistentsym = strncmp((const char *)fnmFile, (const char *) "Scripts/PersistentSymbols.ini", (size_t) 29 );
332- int _gamesgms = strncmp((const char *)fnmFile, (const char *) "Data/SeriousSam.gms", (size_t) 19 );
333- int _comsolehistory = strncmp((const char *)fnmFile, (const char *) "Temp/ConsoleHistory.txt", (size_t) 23 );
334- int _userdemos = strncmp((const char *)fnmFile, (const char *) "Demos/Demo", (size_t) 10 );
335+ int _persistentsym = strncmp((const char *)fnmFile, (const char *) "Scripts", (size_t) 7 );
336+ int _gamesgms = strncmp((const char *)fnmFile, (const char *) "Data", (size_t) 4 );
337+ int _comsolehistory = strncmp((const char *)fnmFile, (const char *) "Temp", (size_t) 4 );
338+ int _userdemos = strncmp((const char *)fnmFile, (const char *) "Demo", (size_t) 4 );
339 int _playersplr = strncmp((const char *)fnmFile, (const char *) "Players", (size_t) 7 );
340 int _screenshots = strncmp((const char *)fnmFile, (const char *) "ScreenShots", (size_t) 11 );
341 int _levelsvis = strncmp((const char *)fnmFile, (const char *) "Levels", (size_t) 6 );
342-
343- //CPrintF("ExpandFilePath: %s\n",(const char *) fnmFile);
344+ int _help = strncmp((const char *)fnmFile, (const char *) "Help", (size_t) 4 );
345
346 if(( _savegame == 0 || _persistentsym == 0 || _gamesgms == 0 ||
347 _comsolehistory == 0 || _userdemos == 0 || _playersplr == 0 || _screenshots == 0) && ( _bPortableVersion == FALSE)) {
348 _fnmApplicationPathTMP = _fnmUserDir;
349+ } else if (_help == 0) {
350+ _fnmApplicationPathTMP = _fnmAdditionalDirPath;
351 } else {
352 _fnmApplicationPathTMP = _fnmApplicationPath;
353 }
354@@ -1675,6 +1690,8 @@ INDEX ExpandFilePath(ULONG ulType, const CTFileName &fnmFile, CTFileName &fnmExp
355 if( _levelsvis == 0 && _bPortableVersion == FALSE) {
356 if (fnmFileAbsolute.FileExt()==".vis") {
357 _fnmApplicationPathTMP = _fnmUserDir;
358+ } else {
359+ _fnmApplicationPathTMP = _fnmAdditionalDirPath;
360 }
361 }
362
363diff --git a/SamTSE/Sources/Engine/Base/Stream.h b/SamTSE/Sources/Engine/Base/Stream.h
364index 8ff3de6..1e5aeae 100644
365--- a/SamTSE/Sources/Engine/Base/Stream.h
366+++ b/SamTSE/Sources/Engine/Base/Stream.h
367@@ -391,6 +391,10 @@ ENGINE_API void MakeDirList(
368
369 // global string with application path
370 ENGINE_API extern CTFileName _fnmApplicationPath;
371+#ifdef PLATFORM_UNIX
372+// global string with additional search path
373+ENGINE_API extern CTFileName _fnmAdditionalDirPath;
374+#endif
375 // global string with user-specific writable directory.
376 ENGINE_API extern CTFileName _fnmUserDir;
377 // global string with current MOD path
378diff --git a/SamTSE/Sources/Engine/Engine.cpp b/SamTSE/Sources/Engine/Engine.cpp
379index e6f7c4f..97baa59 100644
380--- a/SamTSE/Sources/Engine/Engine.cpp
381+++ b/SamTSE/Sources/Engine/Engine.cpp
382@@ -110,11 +110,12 @@ static INDEX sys_iHDDMisc = 0;
383
384 // MOD info
385 static CTString sys_strModName = "";
386-static CTString sys_strModExt = "";
387+static CTString sys_strModExt = "MP";
388
389 // Path vars
390 static INDEX sys_iGameBits = 0;
391 ENGINE_API INDEX sys_iSysPath = 0;
392+ENGINE_API INDEX sys_iGameDataNotFound = 0;
393
394 // Entities Adjesters
395 ENGINE_API FLOAT _fPlayerFOVAdjuster = 1.0f;
396@@ -676,10 +677,12 @@ ENGINE_API void SE_InitEngine(CTString strGameID)
397 _fnmApplicationPath = CTString(strDirPath);
398 _fnmApplicationExe = CTString(strExePath);
399 #ifdef PLATFORM_UNIX
400+ //_fnmAdditionalDirPath = "/usr/share/" + strGameID + "/";
401 // rcg01012002 calculate user dir.
402 char buf[MAX_PATH];
403 _pFileSystem->GetUserDirectory(buf, sizeof (buf));
404 _fnmUserDir = CTString(buf);
405+ _fnmAdditionalDirPath = _fnmUserDir + "/gamedata/";
406 #endif
407 try {
408 _fnmApplicationExe.RemoveApplicationPath_t();
409@@ -742,147 +745,16 @@ ENGINE_API void SE_InitEngine(CTString strGameID)
410 CPrintF(TRANSV("Running %d-bit version\n"), sys_iGameBits);
411
412 #ifdef PLATFORM_UNIX
413-#if defined(__OpenBSD__) || defined(__FreeBSD__)
414- int _isystempath = strncmp((const char *)strExePath, (const char *) "/usr/local/bin/", (size_t) 15 );
415-#elif defined(__NetBSD__)
416- int _isystempath = strncmp((const char *)strExePath, (const char *) "/usr/pkg/bin/", (size_t) 13 );
417-#else
418- int _isystempath = strncmp((const char *)strExePath, (const char *) "/usr/bin/", (size_t) 9 );
419-#endif
420- if( _isystempath == 0 ) {
421- sys_iSysPath = 1; // using system path
422- } else {
423- sys_iSysPath = 0; // using standarted path
424- }
425-
426- // get library path for mods
427- _fnmModLibPath = "";
428-#if defined(__OpenBSD__) || defined(__FreeBSD__)
429- if( sys_iSysPath == 1 ) {
430- _fnmModLibPath = "/usr/local/lib/" + strGameID + "/";
431-#elif defined(__NetBSD__)
432- if( sys_iSysPath == 1 ) {
433- _fnmModLibPath = "/usr/pkg/lib/" + strGameID + "/";
434-#else
435- if( sys_iSysPath == 1 && sys_iGameBits == 64 && _pFileSystem->IsDirectory((const char *) "/usr/lib/aarch64-linux-gnu/" + strGameID)) {
436- _fnmModLibPath = "/usr/lib/aarch64-linux-gnu/" + strGameID + "/";
437- } else if( sys_iSysPath == 1 && sys_iGameBits == 32 && _pFileSystem->IsDirectory((const char *) "/usr/lib/arm-linux-gnueabihf/" + strGameID)) {
438- _fnmModLibPath = "/usr/lib/arm-linux-gnueabihf/" + strGameID + "/";
439- } else if( sys_iSysPath == 1 && sys_iGameBits == 64 && _pFileSystem->IsDirectory((const char *) "/usr/lib/riscv64-linux-gnu/" + strGameID)) {
440- _fnmModLibPath = "/usr/lib/riscv64-linux-gnu/" + strGameID + "/";
441- } else if( sys_iSysPath == 1 && sys_iGameBits == 64 && _pFileSystem->IsDirectory((const char *) "/usr/lib/s390x-linux-gnu/" + strGameID)) {
442- _fnmModLibPath = "/usr/lib/s390x-linux-gnu/" + strGameID + "/";
443- } else if( sys_iSysPath == 1 && sys_iGameBits == 64 && _pFileSystem->IsDirectory((const char *) "/usr/lib/powerpc64-linux-gnu/" + strGameID)) {
444- _fnmModLibPath = "/usr/lib/powerpc64-linux-gnu/" + strGameID + "/";
445- } else if( sys_iSysPath == 1 && sys_iGameBits == 64 && _pFileSystem->IsDirectory((const char *) "/usr/lib/x86_64-linux-gnu/" + strGameID)) {
446- _fnmModLibPath = "/usr/lib/x86_64-linux-gnu/" + strGameID + "/";
447- } else if( sys_iSysPath == 1 && sys_iGameBits == 32 && _pFileSystem->IsDirectory((const char *) "/usr/lib/i386-linux-gnu/" + strGameID)) {
448- _fnmModLibPath = "/usr/lib/i386-linux-gnu/" + strGameID + "/";
449- } else if( sys_iSysPath == 1 && sys_iGameBits == 64 && _pFileSystem->IsDirectory((const char *) "/usr/lib64/" + strGameID)) {
450- _fnmModLibPath = "/usr/lib64/" + strGameID + "/";
451- } else if( sys_iSysPath == 1 && sys_iGameBits == 32 && _pFileSystem->IsDirectory((const char *) "/usr/lib//" + strGameID)) {
452- _fnmModLibPath = "/usr/lib/" + strGameID + "/";
453-#endif
454- } else if( sys_iSysPath == 0 ) {
455- _fnmModLibPath = _fnmApplicationPath;
456- } else {
457- CPrintF(TRANSV("ERROR: Game libraries not ound!\n"));
458- FatalError(TRANSV("Failed to search game libraries installed!\nPlease reinstall the game.\nSee the log for more details.\nGame log is here: ~/.local/share/Serious-Engine/%s/SeriousSam.log"),(const char *) strGameID);
459- }
460-
461- if( sys_iSysPath == 1 ) { // search game data
462- CTFileName _fnm_usr_TestFile, _fnm_local_TestFile, _fnm_home_TestFile;
463- CTString _fnmUserDataPath, _fnm_TestFile;
464- int _fd;
465-
466- if( access((const char *) _fnmUserDir+_strLogFile+".cfg", F_OK) == 0 ) {
467- _fd = open((const char *) _fnmUserDir+_strLogFile+".cfg", O_RDONLY,S_IRUSR);
468- size_t x = read(_fd, _path, 2048);
469- _fnmUserDataPath = (CTString)_path + "/";
470- close(_fd);
471- CPrintF(TRANSV("Testing home path: %s\n"), (const char *) _fnmUserDataPath);
472- } else {
473- _fnmUserDataPath = "";
474- }
475-
476- // set testing files
477- if( strGameID == "serioussamse") {
478- _fnm_TestFile = "SE1_00_Levels.gro";
479- } else {
480- _fnm_TestFile = "1_00_music.gro";
481- }
482- CPrintF(TRANSV("Testing file: %s\n"), (const char *) _fnm_TestFile);
483-#if defined(__OpenBSD__) || defined(__FreeBSD__)
484- _fnm_usr_TestFile = "/usr/local/share/" + strGameID + "/" + _fnm_TestFile; // data in usr
485-#elif defined(__NetBSD__)
486- _fnm_usr_TestFile = "/usr/pkg/share/" + strGameID + "/" + _fnm_TestFile; // data in usr
487-#else
488- _fnm_usr_TestFile = "/usr/share/" + strGameID + "/" + _fnm_TestFile; // data in usr
489-#endif
490- _fnm_local_TestFile = _fnmUserDir + _fnm_TestFile; // data in home .local
491- _fnm_home_TestFile = (const char *)_fnmUserDataPath + _fnm_TestFile;
492- // test
493- if( access((const char *) _fnm_home_TestFile, F_OK) != 0 ) {
494- CPrintF(TRANSV("Testing system path: %s\n"), (const char *) _fnm_usr_TestFile);
495- CPrintF(TRANSV("Testing local path: %s\n"), (const char *) _fnm_local_TestFile);
496- if( access((const char *) _fnm_usr_TestFile, F_OK) == 0 ) {
497-#if defined(__OpenBSD__) || defined(__FreeBSD__)
498- _fnmApplicationPath = "/usr/local/share/" + strGameID + "/"; // all game data
499-#elif defined(__NetBSD__)
500- _fnmApplicationPath = "/usr/pkg/share/" + strGameID + "/"; // all game data
501-#else
502- _fnmApplicationPath = "/usr/share/" + strGameID + "/"; // all game data
503-#endif
504- CPrintF(TRANSV("Found usr path: %s\n"), (const char *) _fnmUserDataPath);
505- } else if( access((const char *) _fnm_local_TestFile, F_OK) == 0 ) {
506- _fnmApplicationPath = _fnmUserDir; // all game data
507- CPrintF(TRANSV("Found local path: %s\n"), (const char *) _fnmUserDataPath);
508- } else {
509- // search in home dir
510- // BOOL YesNoMessage(const char *strFormat, ...)
511-#if defined(__OpenBSD__) || defined(__FreeBSD__)
512- InfoMessage(TRANS("No game files were found in /usr/local/share/%s/\n or %s\nThe home directory will be searched."),(const char *) strGameID,(const char *) _fnmUserDir);
513-#elif defined(__NetBSD__)
514- InfoMessage(TRANS("No game files were found in /usr/pkg/share/%s/\n or %s\nThe home directory will be searched."),(const char *) strGameID,(const char *) _fnmUserDir);
515-#else
516- InfoMessage(TRANS("No game files were found in /usr/share/%s/\n or %s\nThe home directory will be searched."),(const char *) strGameID,(const char *) _fnmUserDir);
517-#endif
518- struct passwd *pw = getpwuid(getuid());
519- const char *_homedir = pw->pw_dir;
520- _testfiledone = 0;
521- _list_dir(_homedir, 0, strGameID);
522- CTString _PATH;
523- _PATH = (CTString)_path;
524- _fnmApplicationPath = (CTFileName) _PATH + "/";
525- _fnm_home_TestFile = (CTFileName) _PATH + "/" + _fnm_TestFile;
526- if( access((const char *) _fnm_home_TestFile, F_OK) == 0 ) {
527- //_fnmApplicationPath = (CTFileName) _PATH + "/";
528- CPrintF(TRANSV("Found home path: %s\n"), (const char *) _fnm_home_TestFile);
529- _fd = open((const char *) _fnmUserDir+_strLogFile+".cfg", O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
530- size_t x = write(_fd, _path, 2048);
531- close(_fd);
532- } else {
533- CPrintF(TRANSV("ERROR: Game data not ound!\n"));
534- _fnmUserDataPath = "";
535-#if defined(__OpenBSD__) || defined(__FreeBSD__)
536- FatalError(TRANSV("Failed to search game data!\nPlease put the game data in the paths:\n/usr/local/share/%s/\n or %s\n or somewhere in your home directory\nSee the log for more details.\nGame log is here: ~/.local/share/Serious-Engine/%s/SeriousSam.log"),(const char *) strGameID,(const char *) _fnmUserDir,(const char *) strGameID);
537-#elif defined(__NetBSD__)
538- FatalError(TRANSV("Failed to search game data!\nPlease put the game data in the paths:\n/usr/pkg/share/%s/\n or %s\n or somewhere in your home directory\nSee the log for more details.\nGame log is here: ~/.local/share/Serious-Engine/%s/SeriousSam.log"),(const char *) strGameID,(const char *) _fnmUserDir,(const char *) strGameID);
539-#else
540- FatalError(TRANSV("Failed to search game data!\nPlease put the game data in the paths:\n/usr/share/%s/\n or %s\n or somewhere in your home directory\nSee the log for more details.\nGame log is here: ~/.local/share/Serious-Engine/%s/SeriousSam.log"),(const char *) strGameID,(const char *) _fnmUserDir,(const char *) strGameID);
541-#endif
542- }
543- }
544- } else {
545- CPrintF(TRANSV("Found path: %s\n"), (const char *) _fnmUserDataPath);
546- _fnmApplicationPath = _fnmUserDataPath; // all game data
547- }
548- }
549
550+ // using system path
551+ sys_iSysPath = 1;
552+ // library path for mods
553+ _fnmModLibPath = _fnmApplicationPath + "lib/" + strGameID + "/";
554 // print info on the started application
555 CPrintF(TRANSV("Executable: %s\n"), (const char *) strExePath);
556 CPrintF(TRANSV("Assumed engine data directory: %s\n"), (const char *) _fnmApplicationPath);
557 CPrintF(TRANSV("Assumed mods library directory: %s\n"), (const char *) _fnmModLibPath);
558+ CPrintF(TRANSV("Assumed additional data directory: %s\n"), (const char *) _fnmAdditionalDirPath);
559 #endif
560
561 CPrintF("\n");
562@@ -969,7 +841,7 @@ ENGINE_API void SE_InitEngine(CTString strGameID)
563 InitStreams();
564 // keep mod name in sys cvar
565 sys_strModName = _strModName;
566- sys_strModExt = _strModExt;
567+ sys_strModExt = "MP";
568
569 // checking of crc
570 #if 0
571diff --git a/SamTSE/Sources/Engine/Engine.h b/SamTSE/Sources/Engine/Engine.h
572index 8307f70..6ba88a4 100644
573--- a/SamTSE/Sources/Engine/Engine.h
574+++ b/SamTSE/Sources/Engine/Engine.h
575@@ -207,6 +207,7 @@ extern ENGINE_API BOOL _bWorldEditorApp; // is this world edtior app
576 extern ENGINE_API CTString _strLogFile;
577 extern ENGINE_API CTFileName _fnmModLibPath;
578 extern ENGINE_API INDEX sys_iSysPath;
579+extern ENGINE_API INDEX sys_iGameDataNotFound;
580 #ifdef PLATFORM_WIN32
581 //
582 extern ENGINE_API FLOAT _fPlayerFOVAdjuster;