MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / Version

Method Version

src/strgen/strgen_base.cpp:130–154  ·  view source on GitHub ↗

* Make a hash of the file to get a unique "version number" * @return The version number. */

Source from the content-addressed store, hash-verified

128 * @return The version number.
129 */
130uint32_t StringData::Version() const
131{
132 uint32_t hash = 0;
133
134 for (size_t i = 0; i < this->max_strings; i++) {
135 const LangString *ls = this->strings[i].get();
136
137 if (ls != nullptr) {
138 hash ^= i * 0x717239;
139 hash = (hash & 1 ? hash >> 1 ^ 0xDEADBEEF : hash >> 1);
140 hash = VersionHashStr(hash, ls->name);
141
142 StringConsumer consumer(ls->english);
143 ParsedCommandString cs;
144 while ((cs = ParseCommandString(consumer)).cmd != nullptr) {
145 if (cs.cmd->flags.Test(CmdFlag::DontCount)) continue;
146
147 hash ^= (cs.cmd - _cmd_structs) * 0x1234567;
148 hash = (hash & 1 ? hash >> 1 ^ 0xF00BAA4 : hash >> 1);
149 }
150 }
151 }
152
153 return hash;
154}
155
156/**
157 * Count the number of tab elements that are in use.

Callers 3

CompileMethod · 0.45
WriteLangMethod · 0.45
FinaliseMethod · 0.45

Calls 4

VersionHashStrFunction · 0.85
ParseCommandStringFunction · 0.85
TestMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected