diff options
author | yexo <yexo@openttd.org> | 2012-08-13 18:49:38 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2012-08-13 18:49:38 +0000 |
commit | 483d878d5fbe549b2e8196c8e8176ad560734343 (patch) | |
tree | bd3b8f146f76dcb094c51a5204245675c7fa7d47 /src/network/core | |
parent | 93a135bc6a7b973d2fd6971fffd76962ff419a97 (diff) | |
download | openttd-483d878d5fbe549b2e8196c8e8176ad560734343.tar.xz |
(svn r24466) -Codechange [FS#5236]: add general function for ContentType -> Subdirectory conversion (LordAro)
Diffstat (limited to 'src/network/core')
-rw-r--r-- | src/network/core/tcp_content.cpp | 26 | ||||
-rw-r--r-- | src/network/core/tcp_content.h | 2 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/network/core/tcp_content.cpp b/src/network/core/tcp_content.cpp index 30284f2e7..131501a5c 100644 --- a/src/network/core/tcp_content.cpp +++ b/src/network/core/tcp_content.cpp @@ -163,4 +163,30 @@ bool NetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p) { return this-> bool NetworkContentSocketHandler::Receive_CLIENT_CONTENT(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CONTENT_CLIENT_CONTENT); } bool NetworkContentSocketHandler::Receive_SERVER_CONTENT(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CONTENT_SERVER_CONTENT); } +/** + * Helper to get the subdirectory a #ContentInfo is located in. + * @param type The type of content. + * @return The subdirectory the content is located in. + */ +Subdirectory GetContentInfoSubDir(ContentType type) +{ + switch (type) { + default: return NO_DIRECTORY; + case CONTENT_TYPE_AI: return AI_DIR; + case CONTENT_TYPE_AI_LIBRARY: return AI_LIBRARY_DIR; + case CONTENT_TYPE_GAME: return GAME_DIR; + case CONTENT_TYPE_GAME_LIBRARY: return GAME_LIBRARY_DIR; + case CONTENT_TYPE_NEWGRF: return NEWGRF_DIR; + + case CONTENT_TYPE_BASE_GRAPHICS: + case CONTENT_TYPE_BASE_SOUNDS: + case CONTENT_TYPE_BASE_MUSIC: + return BASESET_DIR; + + case CONTENT_TYPE_SCENARIO: + case CONTENT_TYPE_HEIGHTMAP: + return SCENARIO_DIR; + } +} + #endif /* ENABLE_NETWORK */ diff --git a/src/network/core/tcp_content.h b/src/network/core/tcp_content.h index 12996a02d..8e06bedb0 100644 --- a/src/network/core/tcp_content.h +++ b/src/network/core/tcp_content.h @@ -206,6 +206,8 @@ public: void ReceivePackets(); }; +Subdirectory GetContentInfoSubDir(ContentType type); + #endif /* ENABLE_NETWORK */ #endif /* NETWORK_CORE_TCP_CONTENT_H */ |