SV_WriteIP_f. @param gameExports
(GameExportsImpl gameExports)
| 228 | * @param gameExports |
| 229 | */ |
| 230 | static void SVCmd_WriteIP_f(GameExportsImpl gameExports) { |
| 231 | RandomAccessFile f; |
| 232 | byte b[]; |
| 233 | |
| 234 | int i; |
| 235 | cvar_t game; |
| 236 | |
| 237 | game = gameExports.gameImports.cvar("game", "", 0); |
| 238 | |
| 239 | String name; |
| 240 | if (game.string == null) |
| 241 | name = Defines.GAMEVERSION + "/listip.cfg"; |
| 242 | else |
| 243 | name = game.string + "/listip.cfg"; |
| 244 | |
| 245 | gameExports.gameImports.cprintf(null, Defines.PRINT_HIGH, "Writing " + name + ".\n"); |
| 246 | |
| 247 | f = Lib.fopen(name, "rw"); |
| 248 | if (f == null) { |
| 249 | gameExports.gameImports.cprintf(null, Defines.PRINT_HIGH, "Couldn't open " |
| 250 | + name + "\n"); |
| 251 | return; |
| 252 | } |
| 253 | |
| 254 | try { |
| 255 | f.writeChars("set filterban " + (int) gameExports.gameCvars.filterban.value |
| 256 | + "\n"); |
| 257 | |
| 258 | for (i = 0; i < numipfilters; i++) { |
| 259 | b = Lib.getIntBytes(ipfilters[i].compare); |
| 260 | f.writeChars("sv addip " + (b[0] & 0xff) + "." + (b[1] & 0xff) |
| 261 | + "." + (b[2] & 0xff) + "." + (b[3] & 0xff) + "\n"); |
| 262 | } |
| 263 | |
| 264 | } catch (IOException e) { |
| 265 | gameExports.gameImports.dprintf("IOError in SVCmd_WriteIP_f:" + e); |
| 266 | } |
| 267 | |
| 268 | Lib.fclose(f); |
| 269 | } |
| 270 | |
| 271 | // todo move to game exports |
| 272 | public static void ServerCommand(List<String> args, GameExportsImpl gameExports) { |
no test coverage detected