| 89 | } |
| 90 | |
| 91 | bool IntsToStr(const int *pInts, size_t NumInts, char *pStr, size_t StrSize) |
| 92 | { |
| 93 | dbg_assert(NumInts > 0, "IntsToStr: NumInts invalid"); |
| 94 | dbg_assert(StrSize >= NumInts * sizeof(int), "IntsToStr: StrSize invalid"); |
| 95 | |
| 96 | // Unpack string without validation |
| 97 | size_t StrIndex = 0; |
| 98 | for(size_t IntIndex = 0; IntIndex < NumInts; IntIndex++) |
| 99 | { |
| 100 | const int CurrentInt = pInts[IntIndex]; |
| 101 | pStr[StrIndex] = ((CurrentInt >> 24) & 0xff) - 128; |
| 102 | StrIndex++; |
| 103 | pStr[StrIndex] = ((CurrentInt >> 16) & 0xff) - 128; |
| 104 | StrIndex++; |
| 105 | pStr[StrIndex] = ((CurrentInt >> 8) & 0xff) - 128; |
| 106 | StrIndex++; |
| 107 | pStr[StrIndex] = (CurrentInt & 0xff) - 128; |
| 108 | StrIndex++; |
| 109 | } |
| 110 | // Ensure null-termination |
| 111 | pStr[StrIndex - 1] = '\0'; |
| 112 | |
| 113 | // Ensure valid UTF-8 |
| 114 | if(str_utf8_check(pStr)) |
| 115 | { |
| 116 | return true; |
| 117 | } |
| 118 | pStr[0] = '\0'; |
| 119 | return false; |
| 120 | } |
| 121 | |
| 122 | float VelocityRamp(float Value, float Start, float Range, float Curvature) |
| 123 | { |