random_name.c 977 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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(
  36. name, max_name_size, "%s_%s", prefix[prefix_i], suffix[suffix_i]);
  37. // Set first symbol to upper case
  38. name[0] = name[0] - 0x20;
  39. }