2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

127 linhas
2.7 KiB

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