Quake3服务器客户端架构参考

 

 
  
1 这是我早前的分析资料,基本上函数的命名解释比较清晰了
2
3   // -----------------------------------------------
4   简单吧
5 WinMain
6 Com_Frame
7
8
9 // -----------------------------------------------
10 服务端
11
12 SV_ExecuteClientMessage
13 SV_ClientCommand
14 SV_UserMove( cl, msg, qtrue )
15 SV_ClientThink (cl, & cmds[ i ])
16 ClientThink( arg0 ); // VM_Call
17 ClientThink_real( ent );
18
19
20 SV_Frame( msec );
21
22 BotAIStartFrame( time )
23 G_RunFrame( int levelTime )
24 G_RunMissile( ent );
25 G_RunItem( ent );
26 G_RunMover( ent );
27 G_RunClient( ent );
28 G_RunThink( ent );
29 ClientEndFrame( ent );
30
31 Pmove
32 PmoveSingle
33 PM_WaterJumpMove();
34 PM_WaterMove();
35 PM_WalkMove();
36 PM_AirMove
37 PM_NoclipMove ()
38 PM_Weapon();
39 PM_TorsoAnimation();
40 PM_Footsteps
41 PM_StepSlideMove( qfalse )
42
43
44 SV_SendClientMessages
45 SV_SendClientSnapshot( c )
46 SV_BuildClientSnapshot
47 SV_SendMessageToClient
48 SV_WriteSnapshotToClient( client_t * client, msg_t * msg )
49 MSG_WriteDeltaPlayerstate( msg, & oldframe -> ps, & frame -> ps )
50 SV_EmitPacketEntities (oldframe, frame, msg);
51
52
53
54 ClientBegin( int clientNum )
55 ClientSpawn( ent );
56
57
58 // ----------------------------------------------------------
59 客户端
60 CL_PacketEvent
61 CL_ParseServerMessage( msg );
62 CL_ParseSnapshot( msg );
63
64
65 CL_Frame
66 CL_SendCmd();
67 CL_SetCGameTime();
68 SCR_UpdateScreen();
69 SCR_DrawScreenField
70 re.BeginFrame( stereoFrame );
71 CL_CGameRendering
72 cg.clientFrame ++ ;
73 cg.refdef.time = cg.time;
74 CG_PredictPlayerState
75 CG_AddPacketEntities();
76 CG_DrawActive( stereoView );
77 trap_R_RenderScene( & cg.refdef ); // draw 3D view
78 re.EndFrame(...)
79 R_IssueRenderCommands( qtrue );
80
81
82
83
84
85 // --------------------------------------------------------
86 Bot模块
87
88 BotAIStartFrame( int time)
89 BotUpdateInfoConfigStrings();
90
91 trap_BotLibStartFrame(( float ) time / 1000 );
92 trap_BotLibUpdateEntity(...);
93 BotAIRegularUpdate();
94
95 trap_AAS_Initialized()
96 BotAI(i, ( float ) thinktime / 1000 );
97 BotAI_GetClientState( client, & bs -> cur_ps );
98 BotDeathmatchAI(bs, thinktime); // the real AI
99 BotTeamAI(bs); // if not in the intermission and not in observer mode
100 BotAI_BotInitialChat(bs, " whoisteamleader " , NULL); // if asked for a team leader and no response
101 BotAI_BotInitialChat(bs, " iamteamleader " , NULL); // if become teamleader
102
103 bs -> ainode(bs) // execute AI nodes
104
105
106 trap_EA_SelectWeapon(bs -> client, bs -> weaponnum);
107
108
109
110 BotUpdateInput(botstates[i], time, elapsed_time);
111 trap_BotUserCommand(botstates[i] -> client, & botstates[i] -> lastucmd);
112
113
114
115
116
117 // ---------------------------------------------------------
118 UI模块
119
120 UI_MainMenu
121 Main_MenuDraw
122 refdef.x = x;
123 refdef.y = y;
124 refdef.width = w;
125 refdef.height = h;
126 refdef.time = uis.realtime;
127 trap_R_ClearScene();
128 trap_R_AddRefEntityToScene( & ent );
129 trap_R_RenderScene( & refdef );
130 Menu_Draw( & s_main.menu );
131 UI_DrawString(...)
132
133 UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t * pi, int time )
134 refdef_t refdef;
135 refEntity_t legs;
136 refEntity_t torso;
137 refEntity_t head;
138 refEntity_t gun;
139 refEntity_t barrel;
140 refEntity_t flash;
141 vec3_t origin;
142 int renderfx;
143 vec3_t mins = { - 16 , - 16 , - 24 };
144 vec3_t maxs = { 16 , 16 , 32 };
145
146 refdef.x = x;
147 refdef.y = y;
148 refdef.width = w;
149 refdef.height = h;
150
151 refdef.time = dp_realtime;
152 trap_R_ClearScene();
153 ...
154 trap_R_AddLightToScene
155 ...
156 trap_R_RenderScene( & refdef );
157
158
159
160
161 // ---------------------------------------------------------------
162 渲染模块:
163
164 RE_RenderScene
165 R_RenderView( & parms );
166 R_GenerateDrawSurfs()
167 R_AddWorldSurfaces ();
168 R_MarkLeaves ();
169 R_RecursiveWorldNode( tr.world -> nodes, 15 , ( 1 << tr.refdef.num_dlights ) - 1 );
170 R_AddEntitySurfaces ();
171 R_AddMD3Surfaces( ent );
172 R_AddAnimSurfaces( ent );
173 R_AddBrushModelSurfaces( ent );
174
175
176
177 R_SyncRenderThread
178 R_IssueRenderCommands
179 RB_ExecuteRenderCommands
180 RB_DrawSurfs
181 RB_RenderDrawSurfList
182
183
184 RB_RenderThread
185 RB_ExecuteRenderCommands
186 RB_DrawSurfs
187 RB_RenderDrawSurfList( drawSurf_t * drawSurfs, int numDrawSurfs )
188 RB_BeginDrawingView
189 qglClear( clearBits );
190
191
192
193
194 // ----------------------------------------------------------------
195 光照图数据lightFloats
196
197 VL_LightWorld
198 VL_Radiosity
199 RunThreadsOnIndividual( numDrawSurfaces, qtrue, VL_SurfaceRadiosity )
200 VL_SurfaceRadiosity( int num )
201
202
203 VL_LightWorld
204 RunThreadsOnIndividual( numvlights, qtrue, VL_FloodLightThread )
205 VL_FloodLight(vlight_t * light)
206 VL_R_CastLightAtSurface(vlight_t * light, lightvolume_t * volume)
207 VL_LightSurfaceWithVolume( int surfaceNum, int facetNum, vlight_t * light, lightvolume_t * volume )
208
209
210
211
212 // ----------------------------------------------------------------
213 动画过程:
214
215 SV_Frame( int msec )
216 G_RunFrame( int levelTime )
217 G_RunClient( gentity_t * ent )
218 ClientThink_real( ent );
219 Pmove ( & pm);
220 PmoveSingle( pmove );
221 PM_DropTimers();
222 { ... pm -> ps -> legsTimer -= pml.msec ... }
223

 

转载于:https://www.cnblogs.com/Perit/articles/1765857.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值