diff options
author | rubidium <rubidium@openttd.org> | 2009-01-17 16:53:32 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-01-17 16:53:32 +0000 |
commit | 3a13b75e37b5642de3c1e89cf6ab3bf860b76375 (patch) | |
tree | 76215ba6e27bc0b1f49919c01ff2608f276b8e3d /src/gfxinit.cpp | |
parent | 2850bf9e006ebdd40b5562cca5117bca027cfab5 (diff) | |
download | openttd-3a13b75e37b5642de3c1e89cf6ab3bf860b76375.tar.xz |
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
Diffstat (limited to 'src/gfxinit.cpp')
-rw-r--r-- | src/gfxinit.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp index 905bfe2a2..c23f0a816 100644 --- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -543,3 +543,36 @@ char *GetGraphicsSetsList(char *p, const char *last) return p; } + +#if defined(ENABLE_NETWORK) +#include "network/network_content.h" + +/** + * Check whether we have an graphics with the exact characteristics as ci. + * @param ci the characteristics to search on (shortname and md5sum) + * @param md5sum whether to check the MD5 checksum + * @return true iff we have an graphics set matching. + */ +bool HasGraphicsSet(const ContentInfo *ci, bool md5sum) +{ + assert(ci->type == CONTENT_TYPE_BASE_GRAPHICS); + for (const GraphicsSet *g = _available_graphics_sets; g != NULL; g = g->next) { + if (g->found_grfs <= 1) continue; + + if (g->shortname != ci->unique_id) continue; + if (!md5sum) return true; + + byte md5[16]; + memset(md5, 0, sizeof(md5)); + for (uint i = 0; i < MAX_GFT; i++) { + for (uint j = 0; j < sizeof(md5); j++) { + md5[j] ^= g->files[i].hash[j]; + } + } + if (memcmp(md5, ci->md5sum, sizeof(md5)) == 0) return true; + } + + return false; +} + +#endif /* ENABLE_NETWORK */ |