2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

128 Zeilen
2.7 KiB

  1. #include <stdio.h>
  2. #include "minIni.h"
  3. #include "../common/IZ_common.h"
  4. #include "../stdinc/IZ_string.h"
  5. #if defined IZ_WINDOWS
  6. #include <windows.h>
  7. #endif
  8. i32 IZ_ReadAsset(const char* current_dir, const char* ini_filename) {
  9. WIN32_FIND_DATA fd_file;
  10. char current_path[2048];
  11. sprintf(current_path, "%s\\*.*", current_dir);
  12. HANDLE h_find = FindFirstFile(current_path, &fd_file);
  13. if (h_find == INVALID_HANDLE_VALUE) {
  14. return -1;
  15. }
  16. do {
  17. if (strcmp(fd_file.cFileName, ".") == 0) {
  18. continue;
  19. }
  20. if (strcmp(fd_file.cFileName, "..") == 0) {
  21. continue;
  22. }
  23. sprintf(current_path, "%s\\%s", current_dir, fd_file.cFileName);
  24. if (fd_file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
  25. fprintf(stderr, "Invalid asset component: %s\n", current_path);
  26. continue;
  27. }
  28. char final_current_dir[2048];
  29. IZ_memcpy(final_current_dir, 2048, current_dir, 2048);
  30. u16 i = 0;
  31. char c = current_dir[i];
  32. while (c != '\0') {
  33. final_current_dir[i] = c == '\\' ? '/' : c;
  34. i += 1;
  35. c = current_dir[i];
  36. }
  37. ini_putl(final_current_dir, fd_file.cFileName, fd_file.nFileSizeLow, ini_filename);
  38. } while(FindNextFile(h_find, &fd_file));
  39. FindClose(h_find);
  40. return 0;
  41. }
  42. i32 IZ_ReadAssetPack(const char* current_dir, const char* ini_filename) {
  43. WIN32_FIND_DATA fd_file;
  44. char current_path[2048];
  45. sprintf(current_path, "%s\\*.*", current_dir);
  46. HANDLE h_find = FindFirstFile(current_path, &fd_file);
  47. if (h_find == INVALID_HANDLE_VALUE) {
  48. return -1;
  49. }
  50. do {
  51. if (strcmp(fd_file.cFileName, ".") == 0) {
  52. continue;
  53. }
  54. if (strcmp(fd_file.cFileName, "..") == 0) {
  55. continue;
  56. }
  57. sprintf(current_path, "%s\\%s", current_dir, fd_file.cFileName);
  58. if (fd_file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
  59. IZ_ReadAsset(current_path, ini_filename);
  60. continue;
  61. }
  62. fprintf(stderr, "Invalid asset: %s\n", current_path);
  63. } while(FindNextFile(h_find, &fd_file));
  64. FindClose(h_find);
  65. return 0;
  66. }
  67. i32 IZ_ReadAllAssetPacks(const char* current_dir, const char* ini_filename) {
  68. ini_remove(ini_filename);
  69. WIN32_FIND_DATA fd_file;
  70. char current_path[2048];
  71. sprintf(current_path, "%s\\*.*", current_dir);
  72. HANDLE h_find = FindFirstFile(current_path, &fd_file);
  73. if (h_find == INVALID_HANDLE_VALUE) {
  74. return -1;
  75. }
  76. do {
  77. if (strcmp(fd_file.cFileName, ".") == 0) {
  78. continue;
  79. }
  80. if (strcmp(fd_file.cFileName, "..") == 0) {
  81. continue;
  82. }
  83. sprintf(current_path, "%s\\%s", current_dir, fd_file.cFileName);
  84. if (fd_file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
  85. IZ_ReadAssetPack(current_path, ini_filename);
  86. continue;
  87. }
  88. fprintf(stderr, "Invalid asset pack: %s\n", current_path);
  89. } while(FindNextFile(h_find, &fd_file));
  90. FindClose(h_find);
  91. return 0;
  92. }
  93. i32 main(void) {
  94. return IZ_ReadAllAssetPacks("assets\\internal", "assets.ini");
  95. }