| 2907 | } |
| 2908 | |
| 2909 | int CServer::LoadMap(const char *pMapName) |
| 2910 | { |
| 2911 | m_MapReload = false; |
| 2912 | m_SameMapReload = false; |
| 2913 | |
| 2914 | char aBuf[IO_MAX_PATH_LENGTH]; |
| 2915 | str_format(aBuf, sizeof(aBuf), "maps/%s.map", pMapName); |
| 2916 | if(!str_valid_filename(fs_filename(aBuf))) |
| 2917 | { |
| 2918 | log_error("server", "The name '%s' cannot be used for maps because not all platforms support it", aBuf); |
| 2919 | return 0; |
| 2920 | } |
| 2921 | if(!GameServer()->OnMapChange(aBuf, sizeof(aBuf))) |
| 2922 | { |
| 2923 | return 0; |
| 2924 | } |
| 2925 | if(!GameServer()->Map()->Load(pMapName, Storage(), aBuf, IStorage::TYPE_ALL)) |
| 2926 | { |
| 2927 | return 0; |
| 2928 | } |
| 2929 | |
| 2930 | // reinit snapshot ids |
| 2931 | m_IdPool.TimeoutIds(); |
| 2932 | |
| 2933 | // get the crc of the map |
| 2934 | m_aCurrentMapSha256[MAP_TYPE_SIX] = GameServer()->Map()->Sha256(); |
| 2935 | m_aCurrentMapCrc[MAP_TYPE_SIX] = GameServer()->Map()->Crc(); |
| 2936 | char aBufMsg[256]; |
| 2937 | char aSha256[SHA256_MAXSTRSIZE]; |
| 2938 | sha256_str(m_aCurrentMapSha256[MAP_TYPE_SIX], aSha256, sizeof(aSha256)); |
| 2939 | str_format(aBufMsg, sizeof(aBufMsg), "%s sha256 is %s", aBuf, aSha256); |
| 2940 | Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBufMsg); |
| 2941 | |
| 2942 | // load complete map into memory for download |
| 2943 | { |
| 2944 | free(m_apCurrentMapData[MAP_TYPE_SIX]); |
| 2945 | void *pData; |
| 2946 | Storage()->ReadFile(aBuf, IStorage::TYPE_ALL, &pData, &m_aCurrentMapSize[MAP_TYPE_SIX]); |
| 2947 | m_apCurrentMapData[MAP_TYPE_SIX] = (unsigned char *)pData; |
| 2948 | } |
| 2949 | |
| 2950 | if(Config()->m_SvMapsBaseUrl[0]) |
| 2951 | { |
| 2952 | char aEscaped[256]; |
| 2953 | str_format(aBuf, sizeof(aBuf), "%s_%s.map", pMapName, aSha256); |
| 2954 | EscapeUrl(aEscaped, aBuf); |
| 2955 | str_format(m_aMapDownloadUrl, sizeof(m_aMapDownloadUrl), "%s%s", Config()->m_SvMapsBaseUrl, aEscaped); |
| 2956 | } |
| 2957 | else |
| 2958 | { |
| 2959 | m_aMapDownloadUrl[0] = '\0'; |
| 2960 | } |
| 2961 | |
| 2962 | // load sixup version of the map |
| 2963 | if(Config()->m_SvSixup) |
| 2964 | { |
| 2965 | str_format(aBuf, sizeof(aBuf), "maps7/%s.map", pMapName); |
| 2966 | void *pData; |
nothing calls this directly
no test coverage detected