(frame_t frame, int newnum, entity_state_t old, EntityUpdate update)
| 55 | * Parses deltas from the given base and adds the resulting entity to the current frame |
| 56 | */ |
| 57 | public static void DeltaEntity(frame_t frame, int newnum, entity_state_t old, EntityUpdate update) { |
| 58 | |
| 59 | centity_t ent = ClientGlobals.cl_entities[newnum]; |
| 60 | |
| 61 | entity_state_t state = ClientGlobals.cl_parse_entities[ClientGlobals.cl.parse_entities & (Defines.MAX_PARSE_ENTITIES - 1)]; |
| 62 | ClientGlobals.cl.parse_entities++; |
| 63 | frame.num_entities++; |
| 64 | |
| 65 | state.set(old); |
| 66 | state.number = newnum; |
| 67 | state.event = 0; |
| 68 | Math3D.VectorCopy(old.origin, state.old_origin); |
| 69 | |
| 70 | if (update != null) { |
| 71 | state.setByFlags(update.newState, update.header.flags); |
| 72 | } |
| 73 | |
| 74 | // some data changes will force no lerping |
| 75 | if (state.modelindex != ent.current.modelindex |
| 76 | || state.modelindex2 != ent.current.modelindex2 |
| 77 | || state.modelindex3 != ent.current.modelindex3 |
| 78 | || state.modelindex4 != ent.current.modelindex4 |
| 79 | || Math.abs(state.origin[0] - ent.current.origin[0]) > 512 |
| 80 | || Math.abs(state.origin[1] - ent.current.origin[1]) > 512 |
| 81 | || Math.abs(state.origin[2] - ent.current.origin[2]) > 512 |
| 82 | || state.event == Defines.EV_PLAYER_TELEPORT |
| 83 | || state.event == Defines.EV_OTHER_TELEPORT) { |
| 84 | ent.serverframe = -99; |
| 85 | } |
| 86 | |
| 87 | if (ent.serverframe != ClientGlobals.cl.frame.serverframe - 1) { // wasn't in |
| 88 | // last |
| 89 | // update, so |
| 90 | // initialize |
| 91 | // some |
| 92 | // things |
| 93 | ent.trailcount = 1024; // for diminishing rocket / grenade trails |
| 94 | // duplicate the current state so lerping doesn't hurt anything |
| 95 | ent.prev.set(state); |
| 96 | if (state.event == Defines.EV_OTHER_TELEPORT) { |
| 97 | Math3D.VectorCopy(state.origin, ent.prev.origin); |
| 98 | Math3D.VectorCopy(state.origin, ent.lerp_origin); |
| 99 | } else { |
| 100 | Math3D.VectorCopy(state.old_origin, ent.prev.origin); |
| 101 | Math3D.VectorCopy(state.old_origin, ent.lerp_origin); |
| 102 | } |
| 103 | } else { // shuffle the last state to previous |
| 104 | // Copy ! |
| 105 | ent.prev.set(ent.current); |
| 106 | } |
| 107 | |
| 108 | ent.serverframe = ClientGlobals.cl.frame.serverframe; |
| 109 | // Copy ! |
| 110 | ent.current.set(state); |
| 111 | } |
| 112 | |
| 113 | /* |
| 114 | * ================== CL_ParsePacketEntities |
no test coverage detected