random_name.c 968 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "random_name.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <stdbool.h>
  5. #include <furi.h>
  6. void set_random_name(char* name, uint8_t max_name_size) {
  7. static bool rand_generator_inited = false;
  8. if(!rand_generator_inited) {
  9. srand(DWT->CYCCNT);
  10. rand_generator_inited = true;
  11. }
  12. const char* prefix[] = {
  13. "ancient",
  14. "hollow",
  15. "strange",
  16. "disappeared",
  17. "unknown",
  18. "unthinkable",
  19. "unnamable",
  20. "nameless",
  21. "my",
  22. };
  23. const char* suffix[] = {
  24. "door",
  25. "entrance",
  26. "doorway",
  27. "entry",
  28. "portal",
  29. "entree",
  30. "opening",
  31. "crack",
  32. };
  33. uint8_t prefix_i = rand() % SIZEOF_ARRAY(prefix);
  34. uint8_t suffix_i = rand() % SIZEOF_ARRAY(suffix);
  35. sniprintf(name, max_name_size, "%s_%s", prefix[prefix_i], suffix[suffix_i]);
  36. // Set first symbol to upper case
  37. name[0] = name[0] - 0x20;
  38. }