1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 09:00:34 +00:00

index_pointer now produces better sequences of chars

This commit is contained in:
Zeno Rogue 2021-08-04 18:25:52 +02:00
parent b544461dc7
commit 7c9c599e4c

View File

@ -48,10 +48,13 @@ EX map<void*, int> pointer_indices;
EX string index_pointer(void *v) { EX string index_pointer(void *v) {
if(v == nullptr) return "0"; if(v == nullptr) return "0";
if(!pointer_indices.count(v)) pointer_indices[v] = isize(pointer_indices); if(!pointer_indices.count(v)) {
int s = isize(pointer_indices);
pointer_indices[v] = s;
}
int i = pointer_indices[v];
string res; string res;
int i = pointer_indices[v] + 1; while(true) { res += ('A' + (i % 26)); i /= 26; if(!i) break; i--; }
while(i) { res += ('A' + (i % 26)); i /= 26; }
return res; return res;
} }