quake3研究环境搭建

声明: 原文 http://www.cnblogs.com/vincent2600/archive/2011/09/12/2174056.html


如果不去读quake3代码,作为一个游戏程序员是说不过去的,现在去读还不晚,肯定会碰到很多问题,解决问题的过程就是练级。

hacking之前,首先是建立环境,运行调试环境。quake3是99年推出的,到现在已经十二年了,网上能找到一些关于quake3编译运行的只言片语
但都不可行,自己只有基于这些再加上自己试验,make it works!

 在开始之后,需以下几个文件.
 1.Quake 3 Demo版(我们需要里面的资源相关的东西)
 ftp://ftp.idsoftware.com/idstuff/quake3/win32/Q3ADemo.exe
 2.Quake 3 源代码
 ftp://ftp.idsoftware.com/idstuff/source/quake3-1.32b-source.zip
 3.Quake 3 发行版q3pointrelease_132.exe(单纯照其他网上的步骤,只使用demo资源始终要报错)
 
 进入正题.
 1.打开代码下/code/quake3.sln,直接编译,不出意外会报错:
   ui.def : error LNK2001: unresolved external symbol vmMain
   将solution configuration从Debug Alpha改为Debug,OK!
  
 2.关键这样还不是很好,因为这样直接把生成的quake3.exe拿去运行会有问题:
   打开"quake3"工程中的files.c,注释 第3263,3264,3266三行,如下
 // if ( FS_ReadFile( "default.cfg", NULL ) <= 0 ) {
 //   Com_Error( ERR_FATAL, "Couldn't load default.cfg" );
 //   bk001208 - SafeMode see below, FIXME?
 // }
 然后,将files.c中的tatic void FS_SetRestrictions()函数的全部内容注释,仅剩下如下的空壳函数
 static void FS_SetRestrictions( void ) {
 }
 
 3.安装Quake 3 Demo版的Q3ADemo.exe和Quake 3发行版q3pointrelease_132.exe,到C:盘的根目录,安装后分别为C:\3Ademo与C:\Quake III Arena,
   将C:/Q3Ademo/demoq3目录下的pak0.pk3文件复制到C:/Quake III Arena/baseq3 目录下
  
 4.接下来就是用vs进行跟踪调试的关键步骤:
   change quake3 project property -> Linker -> output file C:\Quake III Arena\quake3.exe
   change quake3 project property -> Debugging -> Command $(TargetPath)
   change quake3 project property -> Debugging -> Command $(TargetDir)   //C:\Quake III Arena
  
 5.现在,前往金银岛的船已经好了,Let's Hack !


///

///

如果没有任何人指引,就只看代码几乎如同瞎子摸象。打开sln可以看到botlib,cgame,game,q3_ui,quake3,renderer,splines,ui 8个project,但是它们各自的功能何如呢?

在gamespy找到一篇帖子稍微靠谱一些:

What's the difference between game and cgame? Most of the functions are very different. What's the role of them?


Game / cgame are the "gamecode", which defines the rules of the game, and the meaning of all "entities" (players, items, weapons, projectiles etc are all represented in the engine side as an entity_t). For example, the gamecode is where logic is that ties an entity that happens to have the model of a rocket into a thing that moves at 800ups in a straight line, and damages the entity it hits. The engine itself doesn't have a concept of a rocket, it just knows about the map, entities, and clients that it must send this data to / render.

CGame stands for Client Game, and is the code that runs on the client side, while "Game" only runs on the server. The server (game) is the thing that decides that the rocket is moving at 800ups in a straight line, and when a collision occurs, is the code that calls the damage function to hurt another entity. The client (cgame) simply knows it has a rocket entity, so it gives it the right model, sets up the right rendering effects, and plays the sounds at the right times.

You'll notice there are a few files in both projects with the prefix bg_* - these files are "both game" projects, because the code in them is shared between both client and server. This is mainly for things like movement, to allow the client to predict the path of the rocket so the client can guess where it is without waiting for the server to tell it, to avoid it feeling laggy.

In the released versions of q3, the game/cgame/ui/q3_ui projects aren't built as DLLs like they are in the VS project, they're built into the platform independent .QVM files by a custom version of the "lcc" compiler - the projects are set up as DLLs as well to make it much easier to debug them.

The q3_ui is I guess the user interface/menus, but there's also a ui project... again what's the role of both of them?


Originally, there was just q3_ui, and that is the userinterface used in Quake 3 itself. However the code they released includes the Team Arena missionpack too, which uses a re-written version of the user interface which you can find in the "ui" project. For game/cgame, the TA versions are actually merged into the project and are built by selecting a different configuration in VS (which just toggles the #define MISSIONPACK), but the UI was a major rewrite.

What are splines?


Funky maths (wikipedia link) for giving nice interpolated curves between points. IIRC the splines project is completely unused in Q3, it's just a hangover from something they were experimenting with.

Finally, what project/function links all this together, ie. whats the first script/header script to get executed when it's you've got the build and are running the release executable?


Well, like every Windows program, the very first place WinMain, which you can find at the bottom of win_main.c in the "quake3" project. That calls the Com_Init() which is the "common init" and will do all the real initialisation, and then sit in a loop calling Com_Frame() every frame, which does all processing for each frame of the game. Com_Frame will work out whether you're running a client, a server, or both, and call the appropriate bits.

posted:
Any info on this, or any resources you can point me to would be appreciated..


I don't know of any resources telling you this stuff - you might find something about the game / cgame split as this is the "mod" code, and so people were learning about it before the engine code was released.



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值