【C++】如何从源代码编译红色警戒2地图编辑器

【C++】如何从源代码编译红色警戒2地图编辑器

操作视频

视频中的代码不需要下载三方库,已经包含三方库。

https://www.bilibili.com/video/BV1GTwNehEB5/?spm_id_from=333.1387.homepage.video_card.click\&vd_source=0578c14da2b84f0964bbee439d4fd921

一、运行效果:





这个地图就是冰天雪地,哈哈

二、源代码来源及编程语言:

https://github.com/electronicarts/CNC_TS_and_RA2_Mission_Editor

源代码编程语言:C++/C

三、环境搭建:

打建编译环境前这个源代码库的帮助文档也要好好瞅瞅:

安装红警2

这里我是安装的共和国之辉,其他的没有测试过不太清楚是否可以正常试用

安装VS2022

这个直接通过微软安装,其实这里先只需要安装很少部分,当通过VS2022打开下载的源代码时,VS会提醒安装所缺的编译器及相关的东西,好像有1、2个多G要安装。

下载代码,源代码其实不太多,由于源代码是外网的,我fork到gitee了份代码:

https://gitee.com/r77683962/CNC_TS_and_RA2_Mission_Editor

源代码大概1.6M的样子,这里要小心,编译源代码需要的其他三方库比较多

这步很重要,这里好像是要更新三方库的下载索引还是啥的,我在这里吃过亏,如果这里不操作,三方库不下载,编译时会报很多源代码依赖不到。

这里展示了部分已经下载的三方库:

这是用du命令看到的文件列表:

C:\Users\Administrator\AppData\Local\vcpkg

Administrator@MS-NXTARZGVVQFH MINGW64 ~/AppData/Local/vcpkg/downloads

$ du -sh *

1.6M 7z2408-extra.7z

103M PowerShell-7.2.23-win-x64.zip

1.6M boostorg-algorithm-boost-1.86.0.tar.gz

20K boostorg-array-boost-1.86.0.tar.gz

20K boostorg-assert-boost-1.86.0.tar.gz

84K boostorg-bind-boost-1.86.0.tar.gz

788K boostorg-boost-boost-1.86.0.tar.gz

36K boostorg-cmake-boost-1.86.0.tar.gz

56K boostorg-concept_check-boost-1.86.0.tar.gz

380K boostorg-config-boost-1.86.0.tar.gz

64K boostorg-container_hash-boost-1.86.0.tar.gz

16K boostorg-conversion-boost-1.86.0.tar.gz

168K boostorg-core-boost-1.86.0.tar.gz

52K boostorg-crc-boost-1.86.0.tar.gz

44K boostorg-describe-boost-1.86.0.tar.gz

76K boostorg-detail-boost-1.86.0.tar.gz

120K boostorg-exception-boost-1.86.0.tar.gz

48K boostorg-function-boost-1.86.0.tar.gz

76K boostorg-function_types-boost-1.86.0.tar.gz

56K boostorg-functional-boost-1.86.0.tar.gz

704K boostorg-fusion-boost-1.86.0.tar.gz

4.0K boostorg-headers-boost-1.86.0.tar.gz

48K boostorg-integer-boost-1.86.0.tar.gz

20K boostorg-io-boost-1.86.0.tar.gz

1.5M boostorg-iterator-boost-1.86.0.tar.gz

132K boostorg-move-boost-1.86.0.tar.gz

128K boostorg-mp11-boost-1.86.0.tar.gz

1.5M boostorg-mpl-boost-1.86.0.tar.gz

232K boostorg-optional-boost-1.86.0.tar.gz

108K boostorg-predef-boost-1.86.0.tar.gz

848K boostorg-preprocessor-boost-1.86.0.tar.gz

204K boostorg-range-boost-1.86.0.tar.gz

624K boostorg-regex-boost-1.86.0.tar.gz

180K boostorg-smart_ptr-boost-1.86.0.tar.gz

16K boostorg-static_assert-boost-1.86.0.tar.gz

20K boostorg-throw_exception-boost-1.86.0.tar.gz

32K boostorg-tuple-boost-1.86.0.tar.gz

392K boostorg-type_traits-boost-1.86.0.tar.gz

24K boostorg-typeof-boost-1.86.0.tar.gz

3.6M boostorg-unordered-boost-1.86.0.tar.gz

160K boostorg-utility-boost-1.86.0.tar.gz

792K bzip2-1.0.8.tar.gz

41M cmake-3.29.2-windows-i386.zip

588K lzo-2.10.tar.gz

1.5M madler-zlib-v1.3.1.tar.gz

88K msys2-mingw-w64-x86_64-pkgconf-1~2.2.0-1-any.pkg.tar.zst

1.9M msys2-msys2-runtime-3.5.3-3-x86_64.pkg.tar.zst

0 temp

387M tools

这是URL地址列表,其实不需要手动下载,估计是递归依赖下载:

https://github.com/boostorg/algorithm/archive/boost-1.86.0.tar.gz -> boostorg-algorithm-boost-1.86.0.tar.gz...

https://github.com/boostorg/array/archive/boost-1.86.0.tar.gz -> boostorg-array-boost-1.86.0.tar.gz...

https://github.com/boostorg/assert/archive/boost-1.86.0.tar.gz -> boostorg-assert-boost-1.86.0.tar.gz...

https://github.com/boostorg/bind/archive/boost-1.86.0.tar.gz -> boostorg-bind-boost-1.86.0.tar.gz...

https://github.com/boostorg/boost/archive/boost-1.86.0.tar.gz -> boostorg-boost-boost-1.86.0.tar.gz...

https://github.com/boostorg/cmake/archive/boost-1.86.0.tar.gz -> boostorg-cmake-boost-1.86.0.tar.gz...

https://github.com/boostorg/concept_check/archive/boost-1.86.0.tar.gz -> boostorg-concept_check-boost-1.86.0.tar.gz...

https://github.com/boostorg/config/archive/boost-1.86.0.tar.gz -> boostorg-config-boost-1.86.0.tar.gz...

https://github.com/boostorg/container_hash/archive/boost-1.86.0.tar.gz -> boostorg-container_hash-boost-1.86.0.tar.gz...

https://github.com/boostorg/conversion/archive/boost-1.86.0.tar.gz -> boostorg-conversion-boost-1.86.0.tar.gz...

https://github.com/boostorg/core/archive/boost-1.86.0.tar.gz -> boostorg-core-boost-1.86.0.tar.gz...

https://github.com/boostorg/crc/archive/boost-1.86.0.tar.gz -> boostorg-crc-boost-1.86.0.tar.gz...

https://github.com/boostorg/describe/archive/boost-1.86.0.tar.gz -> boostorg-describe-boost-1.86.0.tar.gz...

https://github.com/boostorg/detail/archive/boost-1.86.0.tar.gz -> boostorg-detail-boost-1.86.0.tar.gz...

https://github.com/boostorg/exception/archive/boost-1.86.0.tar.gz -> boostorg-exception-boost-1.86.0.tar.gz...

https://github.com/boostorg/function/archive/boost-1.86.0.tar.gz -> boostorg-function-boost-1.86.0.tar.gz...

https://github.com/boostorg/function_types/archive/boost-1.86.0.tar.gz -> boostorg-function_types-boost-1.86.0.tar.gz...

https://github.com/boostorg/functional/archive/boost-1.86.0.tar.gz -> boostorg-functional-boost-1.86.0.tar.gz...

https://github.com/boostorg/fusion/archive/boost-1.86.0.tar.gz -> boostorg-fusion-boost-1.86.0.tar.gz...

https://github.com/boostorg/headers/archive/boost-1.86.0.tar.gz -> boostorg-headers-boost-1.86.0.tar.gz...

https://github.com/boostorg/integer/archive/boost-1.86.0.tar.gz -> boostorg-integer-boost-1.86.0.tar.gz...

https://github.com/boostorg/io/archive/boost-1.86.0.tar.gz -> boostorg-io-boost-1.86.0.tar.gz...

https://github.com/boostorg/iterator/archive/boost-1.86.0.tar.gz -> boostorg-iterator-boost-1.86.0.tar.gz...

https://github.com/boostorg/move/archive/boost-1.86.0.tar.gz -> boostorg-move-boost-1.86.0.tar.gz...

https://github.com/boostorg/mp11/archive/boost-1.86.0.tar.gz -> boostorg-mp11-boost-1.86.0.tar.gz...

https://github.com/boostorg/mpl/archive/boost-1.86.0.tar.gz -> boostorg-mpl-boost-1.86.0.tar.gz...

https://github.com/boostorg/optional/archive/boost-1.86.0.tar.gz -> boostorg-optional-boost-1.86.0.tar.gz...

https://github.com/boostorg/predef/archive/boost-1.86.0.tar.gz -> boostorg-predef-boost-1.86.0.tar.gz...

https://github.com/boostorg/preprocessor/archive/boost-1.86.0.tar.gz -> boostorg-preprocessor-boost-1.86.0.tar.gz...

https://github.com/boostorg/range/archive/boost-1.86.0.tar.gz -> boostorg-range-boost-1.86.0.tar.gz...

https://github.com/boostorg/regex/archive/boost-1.86.0.tar.gz -> boostorg-regex-boost-1.86.0.tar.gz...

https://github.com/boostorg/smart_ptr/archive/boost-1.86.0.tar.gz -> boostorg-smart_ptr-boost-1.86.0.tar.gz...

https://github.com/boostorg/static_assert/archive/boost-1.86.0.tar.gz -> boostorg-static_assert-boost-1.86.0.tar.gz...

https://github.com/boostorg/throw_exception/archive/boost-1.86.0.tar.gz -> boostorg-throw_exception-boost-1.86.0.tar.gz...

https://github.com/boostorg/tuple/archive/boost-1.86.0.tar.gz -> boostorg-tuple-boost-1.86.0.tar.gz...

https://github.com/boostorg/type_traits/archive/boost-1.86.0.tar.gz -> boostorg-type_traits-boost-1.86.0.tar.gz...

https://github.com/boostorg/typeof/archive/boost-1.86.0.tar.gz -> boostorg-typeof-boost-1.86.0.tar.gz...

https://github.com/boostorg/unordered/archive/boost-1.86.0.tar.gz -> boostorg-unordered-boost-1.86.0.tar.gz...

https://github.com/boostorg/utility/archive/boost-1.86.0.tar.gz -> boostorg-utility-boost-1.86.0.tar.gz...

https://github.com/madler/zlib/archive/v1.3.1.tar.gz -> madler-zlib-v1.3.1.tar.gz...

https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-pkgconf-1\~2.2.0-1-any.pkg.tar.zst

https://mirror.msys2.org/msys/x86_64/msys2-runtime-3.5.3-3-x86_64.pkg.tar.zst

https://mirror.selfnet.de/msys2/mingw/mingw64/mingw-w64-x86_64-pkgconf-1\~2.2.0-1-any.pkg.tar.zst -> msys2-mingw-w64-x86_64-pkgconf-1~2.2.0-1-any.pkg.tar.zst...

https://mirror.selfnet.de/msys2/msys/x86_64/msys2-runtime-3.5.3-3-x86_64.pkg.tar.zst -> msys2-msys2-runtime-3.5.3-3-x86_64.pkg.tar.zst...

https://mirror.yandex.ru/mirrors/msys2/mingw/mingw64/mingw-w64-x86_64-pkgconf-1\~2.2.0-1-any.pkg.tar.zst

https://mirror.yandex.ru/mirrors/msys2/msys/x86_64/msys2-runtime-3.5.3-3-x86_64.pkg.tar.zst

https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/mingw64/mingw-w64-x86_64-pkgconf-1\~2.2.0-1-any.pkg.tar.zst

https://mirrors.tuna.tsinghua.edu.cn/msys2/msys/x86_64/msys2-runtime-3.5.3-3-x86_64.pkg.tar.zst

https://mirrors.ustc.edu.cn/msys2/mingw/mingw64/mingw-w64-x86_64-pkgconf-1\~2.2.0-1-any.pkg.tar.zst

https://mirrors.ustc.edu.cn/msys2/msys/x86_64/msys2-runtime-3.5.3-3-x86_64.pkg.tar.zst

https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-pkgconf-1\~2.2.0-1-any.pkg.tar.zst

https://repo.msys2.org/msys/x86_64/msys2-runtime-3.5.3-3-x86_64.pkg.tar.zst

https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz

https://www.mirrorservice.org/sites/sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz -> bzip2-1.0.8.tar.gz...

四、可能碰到的问题

vs2022编译前需要下载源代码依赖的三方库,可能会报下载载被x-block-origin。

vs2022 downloads are blocked by x-block-origin.

C:\Windows\System32\drivers\etc\hosts里最后添加:

140.82.114.4 github.com

151.101.1.6 github.global.ssl.fastly.net

151.101.65.6 github.global.ssl.fastly.net

151.101.129.6 github.global.ssl.fastly.net

151.101.193.6 github.global.ssl.fastly.net

14.82.114.4 assets-cdn.github.com

五、参考

1.​红警2的地图编辑器居然更新2.0了,还开源了

https://bbs.nga.cn/read.php?tid=39569282\&page=e\&rand=747

2.https://gitee.com/r77683962/CNC_TS_and_RA2_Mission_Editor

红警游戏地图里边有些感觉是类似3D的2D展示,源代码很有学习的价值。

感谢阅读。

相关推荐
不是编程家4 分钟前
C++第十五讲:异常
jvm·c++
知星小度S35 分钟前
今天你学C++了吗?——C++中的STL
开发语言·c++
轻口味3 小时前
【HarmonyOS NAPI 深度探索9】发布到 npm 并管理版本
c++·华为·npm·harmonyos·napi·harmonyos-next
像污秽一样3 小时前
AI刷题-小R的随机播放顺序、不同整数的计数问题
开发语言·c++·算法
胤胤爸3 小时前
Android ndk-jni语法—— 6
android·c++
松桥爸(仁勇)4 小时前
【72课 局部变量与全局变量】课后练习
c++·算法
m0_748234084 小时前
【C++】——精细化哈希表架构:理论与实践的综合分析
c++·架构·散列表
Mr.Wang8095 小时前
C++ QT中Q_Q和Q_D是什么?怎么使用?本质是什么?C++仿写
开发语言·c++
miilue5 小时前
[LeetCode] 链表完整版 — 虚拟头结点 | 基本操作 | 双指针法 | 递归
java·开发语言·数据结构·c++·算法·leetcode·链表