object.c 594 B

123456789101112131415161718192021222324252627
  1. //
  2. // Created by 李建 on 2023/12/6.
  3. //
  4. #include "object.h"
  5. #include <string.h>
  6. #define MAX_OBJECTS 16
  7. static sparrow_object sparrow_object_list[MAX_OBJECTS];
  8. static int object_index = 0;
  9. void register_sparrow_object(sparrow_object obj) {
  10. if (object_index > MAX_OBJECTS - 1) return;
  11. sparrow_object_list[object_index++] = obj;
  12. }
  13. sparrow_object * find_sparrow_object(char * name) {
  14. for(int i = 0; i < object_index; i++)
  15. {
  16. if( strcmp(sparrow_object_list[i].name, name) == 0)
  17. {
  18. return &sparrow_object_list[i];
  19. }
  20. }
  21. return NULL;
  22. }