summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/progs/duke3d/Game/src/menues.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/sdl/progs/duke3d/Game/src/menues.c')
-rw-r--r--apps/plugins/sdl/progs/duke3d/Game/src/menues.c132
1 files changed, 26 insertions, 106 deletions
diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/menues.c b/apps/plugins/sdl/progs/duke3d/Game/src/menues.c
index 3585600f43..66ce4123bf 100644
--- a/apps/plugins/sdl/progs/duke3d/Game/src/menues.c
+++ b/apps/plugins/sdl/progs/duke3d/Game/src/menues.c
@@ -1245,83 +1245,10 @@ void dispnames(void)
1245 1245
1246} 1246}
1247 1247
1248
1249// This is the same thing as was in build.c ...
1250// We DO have a _dos_findfirst implementation now...maybe use that instead?
1251// --ryan.
1252#if ORIGINAL_DUKE3D_GETFILENAMES
1253int getfilenames(uint8_t kind[6])
1254{
1255 short type;
1256 struct find_t fileinfo;
1257
1258 if (strcmp(kind,"SUBD") == 0)
1259 {
1260 strcpy(kind,"*.*");
1261 if (_dos_findfirst(kind,_A_SUBDIR,&fileinfo) != 0)
1262 return(-1);
1263 type = 1;
1264 }
1265 else
1266 {
1267 if (_dos_findfirst(kind,_A_NORMAL,&fileinfo) != 0)
1268 return(-1);
1269 type = 0;
1270 }
1271 do
1272 {
1273 if ((type == 0) || ((fileinfo.attrib&16) > 0))
1274 if ((fileinfo.name[0] != '.') || (fileinfo.name[1] != 0))
1275 {
1276 strcpy(menuname[menunamecnt],fileinfo.name);
1277 menuname[menunamecnt][16] = type;
1278 menunamecnt++;
1279 }
1280 }
1281 while (_dos_findnext(&fileinfo) == 0);
1282
1283 return(0);
1284}
1285
1286#else
1287
1288int getfilenames(char kind[6]) 1248int getfilenames(char kind[6])
1289{ 1249{
1290/* !!! FIXME: Visual C? */
1291#if (defined __WATCOMC__)
1292 short type;
1293 struct find_t fileinfo;
1294
1295 if (strcmp(kind,"SUBD") == 0)
1296 {
1297 strcpy(kind,"*.*");
1298 if (_dos_findfirst(kind,_A_SUBDIR,&fileinfo) != 0)
1299 return(-1);
1300 type = 1;
1301 }
1302 else
1303 {
1304 if (_dos_findfirst(kind,_A_NORMAL,&fileinfo) != 0)
1305 return(-1);
1306 type = 0;
1307 }
1308 do
1309 {
1310 if ((type == 0) || ((fileinfo.attrib&16) > 0))
1311 if ((fileinfo.name[0] != '.') || (fileinfo.name[1] != 0))
1312 {
1313 strcpy(menuname[menunamecnt],fileinfo.name);
1314 menuname[menunamecnt][16] = type;
1315 menunamecnt++;
1316 }
1317 }
1318 while (_dos_findnext(&fileinfo) == 0);
1319
1320#elif (defined PLATFORM_UNIX)
1321
1322 DIR *dir; 1250 DIR *dir;
1323 struct dirent *dent; 1251 struct dirent *dent;
1324 struct stat statbuf;
1325 int add_this; 1252 int add_this;
1326 uint8_t *ptr = NULL; 1253 uint8_t *ptr = NULL;
1327 int len = 0; 1254 int len = 0;
@@ -1330,7 +1257,7 @@ int getfilenames(char kind[6])
1330 if (strcmp(kind,"SUBD") == 0) 1257 if (strcmp(kind,"SUBD") == 0)
1331 subdirs = 1; 1258 subdirs = 1;
1332 1259
1333 dir = opendir(getGamedir()); 1260 dir = opendir(getGameDir());
1334 if (dir == NULL) 1261 if (dir == NULL)
1335 return(-1); 1262 return(-1);
1336 1263
@@ -1340,46 +1267,39 @@ int getfilenames(char kind[6])
1340 dent = readdir(dir); 1267 dent = readdir(dir);
1341 if (dent != NULL) 1268 if (dent != NULL)
1342 { 1269 {
1343 if (stat(dent->d_name, &statbuf) == 0) 1270 if (subdirs)
1344 { 1271 {
1345 if (subdirs) 1272 if (rb->dir_exists(dent->d_name))
1346 { 1273 add_this = 1;
1347 if (S_ISDIR(statbuf.st_mode)) 1274 } /* if */
1348 add_this = 1; 1275 else
1349 } /* if */ 1276 {
1350 else 1277 /* need to expand support if this assertion ever fails. */
1351 { 1278 assert(stricmp(kind, "*.MAP") == 0);
1352 /* need to expand support if this assertion ever fails. */ 1279 len = strlen(dent->d_name);
1353 assert(stricmp(kind, "*.MAP") == 0); 1280 if (len >= 5)
1354 len = strlen(dent->d_name); 1281 {
1355 if (len >= 5) 1282 ptr = ((uint8_t *) dent->d_name) + len;
1356 { 1283 ptr += strlen(ptr) - 4;
1357 ptr = ((uint8_t *) dent->d_name) + len; 1284 if (stricmp(ptr, ".MAP") == 0)
1358 ptr += strlen(ptr) - 4; 1285 add_this = 1;
1359 if (stricmp(ptr, ".MAP") == 0) 1286 } /* if */
1360 add_this = 1; 1287 } /* else */
1361 } /* if */ 1288
1362 } /* else */ 1289 if (add_this)
1363 1290 {
1364 if (add_this) 1291 strcpy(menuname[menunamecnt],dent->d_name);
1365 { 1292 menuname[menunamecnt][16] = subdirs;
1366 strcpy(menuname[menunamecnt],dent->d_name); 1293 menunamecnt++;
1367 menuname[menunamecnt][16] = subdirs; 1294 } /* if */
1368 menunamecnt++;
1369 } /* if */
1370 } /* if */
1371 } /* if */ 1295 } /* if */
1372 } while (dent != NULL); 1296 } while (dent != NULL);
1373 1297
1374 closedir(dir); 1298 closedir(dir);
1375 1299
1376#endif
1377 return(0); 1300 return(0);
1378} 1301}
1379 1302
1380#endif
1381
1382
1383void sortfilenames() 1303void sortfilenames()
1384{ 1304{
1385 uint8_t sortbuffer[17]; 1305 uint8_t sortbuffer[17];