| 125 | * ================== SV_Configstrings_f ================== |
| 126 | */ |
| 127 | private static void SV_Configstrings_f(List<String> args, GameImportsImpl gameImports, client_t client) { |
| 128 | |
| 129 | Com.DPrintf("Configstrings() from " + client.name + "\n"); |
| 130 | |
| 131 | if (client.state != ClientStates.CS_CONNECTED) { |
| 132 | Com.Printf("configstrings not valid -- already spawned\n"); |
| 133 | return; |
| 134 | } |
| 135 | |
| 136 | // handle the case of a level changing while a client was connecting |
| 137 | int spawnCount = args.size() >= 2 ? Lib.atoi(args.get(1)) : 0; |
| 138 | if (spawnCount != gameImports.spawncount) { |
| 139 | Com.Printf("SV_Configstrings_f from different level\n"); |
| 140 | SV_New_f(args, gameImports, client); |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | int start = args.size() >= 3 ? Lib.atoi(args.get(2)) : 0; |
| 145 | |
| 146 | // write a packet full of data |
| 147 | int currentReliableSize = client.netchan.reliablePending.stream().mapToInt(NetworkMessage::getSize).sum(); |
| 148 | while (currentReliableSize < Defines.MAX_MSGLEN / 2 && start < Defines.MAX_CONFIGSTRINGS) { |
| 149 | if (gameImports.sv.configstrings[start] != null && gameImports.sv.configstrings[start].length() != 0) { |
| 150 | final ConfigStringMessage config = new ConfigStringMessage(start, gameImports.sv.configstrings[start]); |
| 151 | currentReliableSize += config.getSize(); |
| 152 | client.netchan.reliablePending.add(config); |
| 153 | } |
| 154 | start++; |
| 155 | } |
| 156 | |
| 157 | // send next command |
| 158 | final String nextCmd; |
| 159 | |
| 160 | if (start == Defines.MAX_CONFIGSTRINGS) { |
| 161 | nextCmd = String.format("cmd %s %d 0", StringCmdMessage.BASELINES, gameImports.spawncount); |
| 162 | } else { |
| 163 | nextCmd = String.format("cmd %s %d %d", StringCmdMessage.CONFIG_STRINGS, gameImports.spawncount, start); |
| 164 | } |
| 165 | client.netchan.reliablePending.add(new StuffTextMessage(nextCmd)); |
| 166 | } |
| 167 | |
| 168 | /* |
| 169 | * ================== SV_Baselines_f ================== |