Skip to content

Commit ca6af67

Browse files
committed
Merge branch 'staging'
2 parents f1e5b63 + c420d6b commit ca6af67

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

CathodeLib/Scripts/CATHODE/CommandsPAK/Helpers/ShortGuidUtils.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,17 @@ public static string FindString(ShortGuid guid)
122122
/* Generate a random unique ShortGuid */
123123
public static ShortGuid GenerateRandom()
124124
{
125-
string str = DateTime.Now.ToString("G");
125+
string str = Guid.NewGuid().ToString();
126126
ShortGuid guid = Generate(str, false);
127-
int i = 0;
128-
int c_i = 0;
127+
int s = 0;
129128
while (_vanilla.cache.ContainsKey(str) || _custom.cache.ContainsKey(str) || _vanilla.cacheReversed.ContainsKey(guid) || _custom.cacheReversed.ContainsKey(guid))
130129
{
131-
str = guid.ToByteString();
132-
if (i > 1000)
133-
{
134-
str += (char)c_i;
135-
c_i++;
136-
i = 0;
137-
}
130+
str = $"{str}_{s++}";
138131
guid = Generate(str, false);
139-
i++;
132+
133+
if (s > 10000) throw new Exception("Failed to generate unique ShortGuid after many attempts.");
140134
}
141-
//Cache(guid, str);
135+
Cache(guid, str);
142136
return guid;
143137
}
144138

0 commit comments

Comments
 (0)