日期:2014-05-17  浏览次数:21047 次

tremulous移植到windows
这里整理一个完整版的tremulous移植到windows下面的步骤.
linux下面直接make就搞定了,但在是linux虚拟机里运行只有5fps...
所以还是得移到windows下面编译


step 1
下载mingw 
http://ncu.dl.sourceforge.net/project/mingw/Installer/mingw-get-inst/mingw-get-inst-20120426/mingw-get-inst-20120426.exe


安装的时候要把c++编译开发包什么的装上,要不然装完运行不了make就尴尬了,如果不清楚就全勾上吧


step 2
下载tremulous源代码
http://nchc.dl.sourceforge.net/project/tremulous/tremulous/1.1/tremulous-1.1.0.zip


解压代码包(源代码在压缩包的tremulous-1.1.0-src.tar.gz里面,解winrar即可解压)


step 3
修改 \src\tools\asm\makefile:16 去掉 -Werror 这个编译选项


step 4
win_local.h:37  dinput dsound.h 这两个文件会提示找不到,这个需要修改一下
#include <C:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/PlatformSDK/Include/dinput.h>
#include <C:/Program Files/Microsoft Visual Studio .NET 2003/Vc7/PlatformSDK/Include/dsound.h>


这个路径是笔者机器上的,请读者按自己机器的实际路径指定(其实也可以通过改makefile来弄,但笔者比较挫,没弄成功)


step 5
win_windproc.c:59 - 76 这两行注释掉,没什么用


运行mingw的shell.进入cross-make-mingw.sh这个文件所在的目录


运行这个脚本
./cross-make-mingw.sh


step 6
这样,基本上就可以编译 出三个动态库:
在 build\release-mingw32-x86\base 目录下面
cgamex86.dll
gamex86.dll
uix86.dll


以及主程序:
build\release-mingw32-x86\tremulous.x86.exe


把 cgamex86.dll gamex86.dll uix86.dll 这三个动态库拷到 tremulous-1.1.0.zip 解压后的 base目录下面
tremulous.x86.exe 拷到 tremulous-1.1.0.zip 解压后的根目录下面


完成这六步,基本就要以在win下面运行游戏了,但注意,此时并没有执行  cgamex86.dll gamex86.dll uix86.dll
这三个动态库里的代码,而是在执行预先打包好的vms-1.1.0.pk3里面的字节码(游戏内置了quake编译器,会把字节码编译成本地码执行)


ps:笔者编译最后,会卡在生成qvm的环节,但这不影响了,因为动态库均已生成,qvm做的事情,是编译三个动态库的字节码版本.不生成也没关系


step 7
为了能方便地修改游戏,加入调式信息,我们需要让tremulous.x86.exe去执行cgamex86.dll gamex86.dll uix86.dll 这三个动态库


修改 vm.c 的 VM_Create 函数


vm_t *VM_Create( const char *module, intptr_t (*systemCalls)(intptr_t *), 
vmInterpret_t interpret ) {
vm_t *vm;
vmHeader_t *header;
int i, remaining;


    interpret = VMI_NATIVE; // ---- 添加这一行,就可以不调用qvm,而是调用.dll
    
修改后,运行的时候会报错


再改这个文件 sv_client.c 的 SV_VerifyPaks_f 函数,大约在945行,加上一句:


cl->gotCP = qtrue;
        bGood = qtrue; // ---- 添加这一行,绕过,就可以正常运行游戏了


if (bGood) {
cl->pureAuthentic = 1;

else {
cl->pureAuthentic = 0;
cl->nextSnapshotTime = -1;
cl->state = CS_ACTIVE;
SV_SendClientSnapshot( cl );
SV_DropClient( cl, "Unpure client detected. Invalid .PK3 files referenced!" );
}


这样,就完全地把tremulous移植到windows,并且可以任意地增加调试信息了.