diff options
author | Vencislav Atanasov <user890104@freemyipod.org> | 2019-07-28 23:31:50 +0300 |
---|---|---|
committer | Vencislav Atanasov <user890104@freemyipod.org> | 2019-07-29 01:59:40 +0300 |
commit | 183e45e8d0b4425bbd41fab37f2a4dc143e1e27c (patch) | |
tree | 5e25c211f6a3bd46dc594123451af00c1bf7ef9c /apps/plugins/sdl/progs/duke3d/Game/src/global.c | |
parent | e19857e712ff54cec08d5a6342a32dae2788cb50 (diff) | |
download | rockbox-183e45e8d0b4425bbd41fab37f2a4dc143e1e27c.tar.gz rockbox-183e45e8d0b4425bbd41fab37f2a4dc143e1e27c.zip |
sdl: Remove platform-specific code
Also nuke the Makefiles of Duke Nukem 3D (pun intended).
Change-Id: If2707cf079bfb9299347f9c5f980780134b6ecda
Diffstat (limited to 'apps/plugins/sdl/progs/duke3d/Game/src/global.c')
-rw-r--r-- | apps/plugins/sdl/progs/duke3d/Game/src/global.c | 139 |
1 files changed, 1 insertions, 138 deletions
diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/global.c b/apps/plugins/sdl/progs/duke3d/Game/src/global.c index 57c561edd6..b0f4442d32 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/global.c +++ b/apps/plugins/sdl/progs/duke3d/Game/src/global.c | |||
@@ -76,11 +76,6 @@ int32_t gc,neartaghitdist,lockclock,max_player_health,max_armour_amount,max_ammo | |||
76 | struct weaponhit hittype[MAXSPRITES]; | 76 | struct weaponhit hittype[MAXSPRITES]; |
77 | short spriteq[1024],spriteqloc,spriteqamount=64; | 77 | short spriteq[1024],spriteqloc,spriteqamount=64; |
78 | 78 | ||
79 | // ported build engine has this, too. --ryan. | ||
80 | #if PLATFORM_DOS | ||
81 | short moustat = 0; | ||
82 | #endif | ||
83 | |||
84 | struct animwalltype animwall[MAXANIMWALLS]; | 79 | struct animwalltype animwall[MAXANIMWALLS]; |
85 | short numanimwalls; | 80 | short numanimwalls; |
86 | int32_t *animateptr[MAXANIMATES], animategoal[MAXANIMATES], animatevel[MAXANIMATES], animatecnt; | 81 | int32_t *animateptr[MAXANIMATES], animategoal[MAXANIMATES], animatevel[MAXANIMATES], animatecnt; |
@@ -232,7 +227,6 @@ int32_t *curipos[MAXINTERPOLATIONS]; | |||
232 | 227 | ||
233 | void FixFilePath(char *filename) | 228 | void FixFilePath(char *filename) |
234 | { | 229 | { |
235 | #if PLATFORM_UNIX || PLATFORM_ROCKBOX | ||
236 | uint8_t *ptr; | 230 | uint8_t *ptr; |
237 | uint8_t *lastsep = filename; | 231 | uint8_t *lastsep = filename; |
238 | 232 | ||
@@ -304,74 +298,8 @@ void FixFilePath(char *filename) | |||
304 | return; | 298 | return; |
305 | } | 299 | } |
306 | } | 300 | } |
307 | #endif | ||
308 | } | ||
309 | |||
310 | |||
311 | #if PLATFORM_DOS | ||
312 | /* no-op. */ | ||
313 | |||
314 | #elif PLATFORM_WIN32 | ||
315 | int _dos_findfirst(uint8_t *filename, int x, struct find_t *f) | ||
316 | { | ||
317 | int32_t rc = _findfirst(filename, &f->data); | ||
318 | f->handle = rc; | ||
319 | if (rc != -1) | ||
320 | { | ||
321 | strncpy(f->name, f->data.name, sizeof (f->name) - 1); | ||
322 | f->name[sizeof (f->name) - 1] = '\0'; | ||
323 | return(0); | ||
324 | } | ||
325 | return(1); | ||
326 | } | ||
327 | |||
328 | int _dos_findnext(struct find_t *f) | ||
329 | { | ||
330 | int rc = 0; | ||
331 | if (f->handle == -1) | ||
332 | return(1); /* invalid handle. */ | ||
333 | |||
334 | rc = _findnext(f->handle, &f->data); | ||
335 | if (rc == -1) | ||
336 | { | ||
337 | _findclose(f->handle); | ||
338 | f->handle = -1; | ||
339 | return(1); | ||
340 | } | ||
341 | |||
342 | strncpy(f->name, f->data.name, sizeof (f->name) - 1); | ||
343 | f->name[sizeof (f->name) - 1] = '\0'; | ||
344 | return(0); | ||
345 | } | ||
346 | |||
347 | #elif defined(PLATFORM_UNIX) || defined(PLATFORM_MACOSX) || defined(PLATFORM_ROCKBOX) | ||
348 | int _dos_findfirst(char *filename, int x, struct find_t *f) | ||
349 | { | ||
350 | char *ptr; | ||
351 | |||
352 | if (strlen(filename) >= sizeof (f->pattern)) | ||
353 | return(1); | ||
354 | |||
355 | strcpy(f->pattern, filename); | ||
356 | FixFilePath(f->pattern); | ||
357 | ptr = strrchr(f->pattern, PATH_SEP_CHAR); | ||
358 | |||
359 | if (ptr == NULL) | ||
360 | { | ||
361 | ptr = filename; | ||
362 | f->dir = opendir(CURDIR); | ||
363 | } | ||
364 | else | ||
365 | { | ||
366 | *ptr = '\0'; | ||
367 | f->dir = opendir(f->pattern); | ||
368 | memmove(f->pattern, ptr + 1, strlen(ptr + 1) + 1); | ||
369 | } | ||
370 | |||
371 | return(_dos_findnext(f)); | ||
372 | } | 301 | } |
373 | 302 | ||
374 | |||
375 | static int check_pattern_nocase(const char *x, const char *y) | 303 | static int check_pattern_nocase(const char *x, const char *y) |
376 | { | 304 | { |
377 | if ((x == NULL) || (y == NULL)) | 305 | if ((x == NULL) || (y == NULL)) |
@@ -409,53 +337,6 @@ static int check_pattern_nocase(const char *x, const char *y) | |||
409 | return(*x == *y); /* it's a match (both should be EOS). */ | 337 | return(*x == *y); /* it's a match (both should be EOS). */ |
410 | } | 338 | } |
411 | 339 | ||
412 | int _dos_findnext(struct find_t *f) | ||
413 | { | ||
414 | struct dirent *dent; | ||
415 | |||
416 | if (f->dir == NULL) | ||
417 | return(1); /* no such dir or we're just done searching. */ | ||
418 | |||
419 | while ((dent = readdir(f->dir)) != NULL) | ||
420 | { | ||
421 | if (check_pattern_nocase(f->pattern, dent->d_name)) | ||
422 | { | ||
423 | if (strlen(dent->d_name) < sizeof (f->name)) | ||
424 | { | ||
425 | strcpy(f->name, dent->d_name); | ||
426 | return(0); /* match. */ | ||
427 | } | ||
428 | } | ||
429 | } | ||
430 | |||
431 | closedir(f->dir); | ||
432 | f->dir = NULL; | ||
433 | return(1); /* no match in whole directory. */ | ||
434 | } | ||
435 | #else | ||
436 | #error please define for your platform. | ||
437 | #endif | ||
438 | |||
439 | |||
440 | #if !PLATFORM_DOS | ||
441 | void _dos_getdate(struct dosdate_t *date) | ||
442 | { | ||
443 | time_t curtime = time(NULL); | ||
444 | |||
445 | if (date == NULL) { | ||
446 | return; | ||
447 | } | ||
448 | |||
449 | memset(date, 0, sizeof(struct dosdate_t)); | ||
450 | |||
451 | date->day = 1; | ||
452 | date->month = 1; | ||
453 | date->year = 1970; | ||
454 | date->dayofweek = 4; | ||
455 | } | ||
456 | #endif | ||
457 | |||
458 | |||
459 | int FindDistance2D(int ix, int iy) | 340 | int FindDistance2D(int ix, int iy) |
460 | { | 341 | { |
461 | int t; | 342 | int t; |
@@ -560,11 +441,7 @@ int32 SafeOpenAppend (const char *_filename, int32 filetype) | |||
560 | filename[sizeof (filename) - 1] = '\0'; | 441 | filename[sizeof (filename) - 1] = '\0'; |
561 | FixFilePath(filename); | 442 | FixFilePath(filename); |
562 | 443 | ||
563 | #if (defined PLATFORM_WIN32) | ||
564 | handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_APPEND ); | ||
565 | #else | ||
566 | handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_APPEND , 0666); | 444 | handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_APPEND , 0666); |
567 | #endif | ||
568 | 445 | ||
569 | if (handle == -1) | 446 | if (handle == -1) |
570 | Error (EXIT_FAILURE, "Error opening for append %s: %s",filename,strerror(errno)); | 447 | Error (EXIT_FAILURE, "Error opening for append %s: %s",filename,strerror(errno)); |
@@ -579,11 +456,7 @@ boolean SafeFileExists ( const char * _filename ) | |||
579 | filename[sizeof (filename) - 1] = '\0'; | 456 | filename[sizeof (filename) - 1] = '\0'; |
580 | FixFilePath(filename); | 457 | FixFilePath(filename); |
581 | 458 | ||
582 | #if( defined PLATFORM_WIN32) | 459 | return(rb->file_exists(filename)); |
583 | return(access(filename, 6) == 0); | ||
584 | #else | ||
585 | return(rb->file_exists(filename)); | ||
586 | #endif | ||
587 | } | 460 | } |
588 | 461 | ||
589 | 462 | ||
@@ -595,12 +468,8 @@ int32 SafeOpenWrite (const char *_filename, int32 filetype) | |||
595 | filename[sizeof (filename) - 1] = '\0'; | 468 | filename[sizeof (filename) - 1] = '\0'; |
596 | FixFilePath(filename); | 469 | FixFilePath(filename); |
597 | 470 | ||
598 | #if (defined PLATFORM_WIN32) | ||
599 | handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_TRUNC ); | ||
600 | #else | ||
601 | handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_TRUNC | 471 | handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_TRUNC |
602 | , 0666); | 472 | , 0666); |
603 | #endif | ||
604 | 473 | ||
605 | if (handle == -1) | 474 | if (handle == -1) |
606 | Error (EXIT_FAILURE, "Error opening %s: %s",filename,strerror(errno)); | 475 | Error (EXIT_FAILURE, "Error opening %s: %s",filename,strerror(errno)); |
@@ -783,7 +652,6 @@ void SwapIntelShortArray(short *s, int num) | |||
783 | Stolen for Duke3D, too. | 652 | Stolen for Duke3D, too. |
784 | */ | 653 | */ |
785 | 654 | ||
786 | #if PLATFORM_UNIX | ||
787 | uint8_t *strlwr(uint8_t *s) | 655 | uint8_t *strlwr(uint8_t *s) |
788 | { | 656 | { |
789 | uint8_t *p = s; | 657 | uint8_t *p = s; |
@@ -858,13 +726,11 @@ uint8_t *ultoa(uint32_t value, uint8_t *string, int radix) | |||
858 | 726 | ||
859 | return string; | 727 | return string; |
860 | } | 728 | } |
861 | #endif | ||
862 | 729 | ||
863 | char ApogeePath[256]; | 730 | char ApogeePath[256]; |
864 | 731 | ||
865 | int setup_homedir (void) | 732 | int setup_homedir (void) |
866 | { | 733 | { |
867 | #if PLATFORM_UNIX | ||
868 | int err; | 734 | int err; |
869 | 735 | ||
870 | snprintf (ApogeePath, sizeof (ApogeePath), "%s/.duke3d/", getenv ("HOME")); | 736 | snprintf (ApogeePath, sizeof (ApogeePath), "%s/.duke3d/", getenv ("HOME")); |
@@ -877,9 +743,6 @@ int setup_homedir (void) | |||
877 | strerror (errno)); | 743 | strerror (errno)); |
878 | return -1; | 744 | return -1; |
879 | } | 745 | } |
880 | #else | ||
881 | sprintf(ApogeePath, ".%s", PATH_SEP_STR); | ||
882 | #endif | ||
883 | 746 | ||
884 | return 0; | 747 | return 0; |
885 | } | 748 | } |