Decides which entities are going to be visible to the client, and copies off the playerstat and areabits.
(client_t client)
| 263 | * off the playerstat and areabits. |
| 264 | */ |
| 265 | public void SV_BuildClientFrame(client_t client) { |
| 266 | |
| 267 | edict_t clent = client.edict; |
| 268 | if (clent.getClient() == null) |
| 269 | return; // not in game yet |
| 270 | |
| 271 | // this is the frame we are creating |
| 272 | client_frame_t frame = client.frames[gameImports.sv.framenum & Defines.UPDATE_MASK]; |
| 273 | |
| 274 | frame.senttime = gameImports.realtime; // save it for ping calc later |
| 275 | |
| 276 | // find the client's PVS |
| 277 | int i; |
| 278 | float[] org = {0, 0, 0}; |
| 279 | for (i = 0; i < 3; i++) |
| 280 | org[i] = clent.getClient().getPlayerState().pmove.origin[i] * 0.125f |
| 281 | + clent.getClient().getPlayerState().viewoffset[i]; |
| 282 | |
| 283 | int leafnum = gameImports.cm.CM_PointLeafnum(org); |
| 284 | int clientarea = gameImports.cm.CM_LeafArea(leafnum); |
| 285 | int clientcluster = gameImports.cm.CM_LeafCluster(leafnum); |
| 286 | |
| 287 | // calculate the visible areas |
| 288 | frame.areabytes = gameImports.cm.CM_WriteAreaBits(frame.areabits, clientarea); |
| 289 | |
| 290 | // grab the current player_state_t |
| 291 | frame.ps.set(clent.getClient().getPlayerState()); |
| 292 | |
| 293 | SV_FatPVS(org); |
| 294 | byte[] clientphs = gameImports.cm.CM_ClusterPHS(clientcluster); |
| 295 | |
| 296 | // build up the list of visible entities |
| 297 | frame.num_entities = 0; |
| 298 | frame.first_entity = next_client_entities; |
| 299 | |
| 300 | for (int e = 1; e < gameImports.gameExports.getNumEdicts(); e++) { |
| 301 | edict_t ent = gameImports.gameExports.getEdict(e); |
| 302 | |
| 303 | // ignore ents without visible models |
| 304 | if ((ent.svflags & Defines.SVF_NOCLIENT) != 0) |
| 305 | continue; |
| 306 | |
| 307 | // ignore ents without visible models unless they have an effect |
| 308 | if (0 == ent.s.modelindex && 0 == ent.s.effects && 0 == ent.s.sound |
| 309 | && 0 == ent.s.event) |
| 310 | continue; |
| 311 | |
| 312 | // ignore if not touching a PV leaf |
| 313 | // check area |
| 314 | if (ent != clent) { |
| 315 | if (!gameImports.cm.CM_AreasConnected(clientarea, ent.areanum)) { |
| 316 | // doors can legally straddle two areas, so we may need to check another one |
| 317 | if (0 == ent.areanum2 || !gameImports.cm.CM_AreasConnected(clientarea, ent.areanum2)) |
| 318 | continue; // blocked by a door |
| 319 | } |
| 320 | |
| 321 | // beams just check one point for PHS |
| 322 | int l; |
no test coverage detected