diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index a11fe2a7aa..e2d433907e 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -11,6 +11,7 @@ add_files( endian_func.hpp endian_type.hpp enum_type.hpp + hash_func.hpp geometry_func.cpp geometry_func.hpp geometry_type.hpp diff --git a/src/core/hash_func.hpp b/src/core/hash_func.hpp new file mode 100644 index 0000000000..af526a45b8 --- /dev/null +++ b/src/core/hash_func.hpp @@ -0,0 +1,28 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + */ + +/** @file hash_func.hpp Functions related to hashing operations. */ + +#ifndef HASH_FUNC_HPP +#define HASH_FUNC_HPP + +/** + * Simple 32 bit to 32 bit hash + * From MurmurHash3 + */ +inline uint32 SimpleHash32(uint32 h) +{ + h ^= h >> 16; + h *= 0x85ebca6b; + h ^= h >> 13; + h *= 0xc2b2ae35; + h ^= h >> 16; + + return h; +} + +#endif /* HASH_FUNC_HPP */