MCPcopy Create free account
hub / github.com/demoth/jake2 / ParsePacketEntities

Method ParsePacketEntities

client/src/main/java/jake2/client/CL_ents.java:119–209  ·  view source on GitHub ↗
(frame_t oldframe, frame_t newframe, PacketEntitiesMessage m)

Source from the content-addressed store, hash-verified

117 * data stream. ==================
118 */
119 public static void ParsePacketEntities(frame_t oldframe, frame_t newframe, PacketEntitiesMessage m) {
120 newframe.parse_entities = ClientGlobals.cl.parse_entities;
121 newframe.num_entities = 0;
122
123 // delta from the entities present in oldframe
124 int oldindex = 0;
125 int oldnum;
126 entity_state_t oldstate = null;
127 if (oldframe == null)
128 oldnum = 99999;
129 else {
130 // oldindex == 0. hoz
131 // if (oldindex >= oldframe.num_entities)
132 // oldnum = 99999;
133 // else {
134 oldstate = ClientGlobals.cl_parse_entities[(oldframe.parse_entities + oldindex) & (Defines.MAX_PARSE_ENTITIES - 1)];
135 oldnum = oldstate.number;
136 // }
137 }
138
139
140 for (EntityUpdate update: m.updates) {
141 while (oldnum < update.header.number) {
142 // one or more entities from the old packet are unchanged,
143 // copy them to the new frame
144 DeltaEntity(newframe, oldnum, oldstate, null);
145
146 oldindex++;
147
148 if (oldindex >= oldframe.num_entities)
149 oldnum = 99999;
150 else {
151 oldstate = ClientGlobals.cl_parse_entities[(oldframe.parse_entities + oldindex) & (Defines.MAX_PARSE_ENTITIES - 1)];
152 oldnum = oldstate.number;
153 }
154 }
155
156 // oldnum is either 99999 or has reached newnum value
157
158 if ((update.header.flags & Defines.U_REMOVE) != 0) {
159 // the entity present in oldframe is not in the current frame
160 // fixme: assert oldnum == u.header.number
161 // otherwise we are removing (=not including it in the new frame) an entity that wasn't there O_o
162
163 oldindex++;
164
165 if (oldindex >= oldframe.num_entities)
166 oldnum = 99999;
167 else {
168 oldstate = ClientGlobals.cl_parse_entities[(oldframe.parse_entities + oldindex) & (Defines.MAX_PARSE_ENTITIES - 1)];
169 oldnum = oldstate.number;
170 }
171 continue;
172 }
173
174 if (oldnum == update.header.number) {
175 // delta from previous state
176 DeltaEntity(newframe, update.header.number, oldstate, update);

Callers 1

parsePacketEntitiesMethod · 0.95

Calls 1

DeltaEntityMethod · 0.95

Tested by

no test coverage detected