* Make a hash of the file to get a unique "version number" * @return The version number. */
| 128 | * @return The version number. |
| 129 | */ |
| 130 | uint32_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. |
no test coverage detected