Added GetKey() / SetKey() in con_set's Entry, so ScriptVariable can override it and set the key appropriately

This commit is contained in:
smallmodel 2023-11-28 19:28:19 +01:00
parent 2ac2800ecb
commit b10ce9a426
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
6 changed files with 105 additions and 62 deletions

View file

@ -279,7 +279,6 @@ void con_set<key, value>::Archive(Archiver& arc)
Entry *e;
int hash;
int i;
int total;
arc.ArchiveUnsigned(&tableLength);
arc.ArchiveUnsigned(&threshold);
@ -296,12 +295,15 @@ void con_set<key, value>::Archive(Archiver& arc)
e = new Entry;
e->Archive(arc);
hash = HashCode<key>(e->key) % tableLength;
hash = HashCode<key>(e->GetKey()) % tableLength;
e->next = table[hash];
table[hash] = e;
}
} else {
#ifndef NDEBUG
int total;
total = 0;
for (i = 0; i < tableLength; i++) {
@ -310,7 +312,15 @@ void con_set<key, value>::Archive(Archiver& arc)
total++;
}
}
// it must match the number of elements
assert(total == count);
#else
for (i = 0; i < tableLength; i++) {
for (e = table[i]; e != NULL; e = e->next) {
e->Archive(arc);
}
}
#endif
}
}

View file

@ -1199,7 +1199,7 @@ void ScriptMaster::PrintThread(int iThreadNum)
int i = 0;
for (entry = en.NextElement(); entry != NULL; entry = en.NextElement()) {
str& name = Director.GetString(entry->key);
str& name = Director.GetString(entry->GetKey());
if (i > 0) {
status += ", ";