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

Method SV_Baselines_f

server/src/main/java/jake2/server/SV_USER.java:171–216  ·  view source on GitHub ↗
(List<String> args, GameImportsImpl gameImports, client_t client)

Source from the content-addressed store, hash-verified

169 * ================== SV_Baselines_f ==================
170 */
171 private static void SV_Baselines_f(List<String> args, GameImportsImpl gameImports, client_t client) {
172
173 Com.DPrintf("Baselines() from " + client.name + "\n");
174
175 if (client.state != ClientStates.CS_CONNECTED) {
176 Com.Printf("baselines not valid -- already spawned\n");
177 return;
178 }
179
180 // handle the case of a level changing while a client was connecting
181 int spawnCount = args.size() >= 2 ? Lib.atoi(args.get(1)) : 0;
182 if (spawnCount != gameImports.spawncount) {
183 Com.Printf("SV_Baselines_f from different level\n");
184 SV_New_f(args, gameImports, client);
185 return;
186 }
187
188 // todo: validate argument
189 int start = args.size() >= 3 ? Lib.atoi(args.get(2)) : 0;
190
191 //memset (&nullstate, 0, sizeof(nullstate));
192 entity_state_t nullstate = new entity_state_t(null);
193
194 // write a packet full of data
195 int currentReliableSize = client.netchan.reliablePending.stream().mapToInt(NetworkMessage::getSize).sum();
196 while (currentReliableSize < Defines.MAX_MSGLEN / 2 && start < Defines.MAX_EDICTS) {
197 entity_state_t base = gameImports.sv.baselines[start];
198 if (base.modelindex != 0 || base.sound != 0 || base.effects != 0) {
199 final SpawnBaselineMessage spawn = new SpawnBaselineMessage(base);
200 currentReliableSize += spawn.getSize();
201 client.netchan.reliablePending.add(spawn);
202 }
203 start++;
204 }
205
206 // send next command
207 final String nextCmd;
208 if (start == Defines.MAX_EDICTS) {
209 // finished sending baselines
210 nextCmd = String.format("%s %d", StringCmdMessage.PRECACHE,gameImports.spawncount);
211 } else {
212 // continue from where we finished
213 nextCmd = String.format("cmd %s %d %d", StringCmdMessage.BASELINES, gameImports.spawncount, start);
214 }
215 client.netchan.reliablePending.add(new StuffTextMessage(nextCmd));
216 }
217
218 /*
219 * ================== SV_Begin_f ==================

Callers

nothing calls this directly

Calls 8

DPrintfMethod · 0.95
PrintfMethod · 0.95
atoiMethod · 0.95
SV_New_fMethod · 0.95
getSizeMethod · 0.95
sizeMethod · 0.80
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected