|
25 | 25 | using SWBF2Admin.Utility;
|
26 | 26 | using SWBF2Admin.Structures;
|
27 | 27 | using SWBF2Admin.Runtime.Rcon.Packets;
|
| 28 | +using System.Collections.Generic; |
28 | 29 |
|
29 | 30 | namespace SWBF2Admin.Runtime.Rcon
|
30 | 31 | {
|
@@ -266,6 +267,48 @@ public void IngameLua(string lua)
|
266 | 267 | SendCommand("lua", lua);
|
267 | 268 | }
|
268 | 269 |
|
| 270 | + public bool UpdateServerSettings(List<ServerSettings.ServerSetting> settings) |
| 271 | + { |
| 272 | + Logger.Log(LogLevel.Verbose, "Updating {0} setting(s)", settings.Count.ToString()); |
| 273 | + foreach (var setting in settings) |
| 274 | + { |
| 275 | + SendPacket(new UpdateSettingPacket(setting)); |
| 276 | + } |
| 277 | + return false; |
| 278 | + } |
| 279 | + |
| 280 | + public void UpdateMapList(List<string> newMapList) |
| 281 | + { |
| 282 | + var mp = new MapListPacket(); |
| 283 | + SendPacket(mp); |
| 284 | + if (!mp.PacketOk) |
| 285 | + { |
| 286 | + Logger.Log(LogLevel.Error, "Map update failed - invalid /maps response"); |
| 287 | + return; |
| 288 | + } |
| 289 | + |
| 290 | + int added = 0; |
| 291 | + int dropped = 0; |
| 292 | + foreach (var s in mp.MapList) |
| 293 | + { |
| 294 | + if (!newMapList.Contains(s)) |
| 295 | + { |
| 296 | + SendCommand("dropmap", s); |
| 297 | + dropped++; |
| 298 | + } |
| 299 | + } |
| 300 | + |
| 301 | + foreach (var s in newMapList) |
| 302 | + { |
| 303 | + if (!mp.MapList.Contains(s)) |
| 304 | + { |
| 305 | + SendCommand("addmap", s); |
| 306 | + added++; |
| 307 | + } |
| 308 | + } |
| 309 | + Logger.Log(LogLevel.Verbose, "Added {0} maps, dropped {1} maps", added.ToString(), dropped.ToString()); |
| 310 | + } |
| 311 | + |
269 | 312 | /// <summary>
|
270 | 313 | /// Sends a command to the server but does not retrieve the response
|
271 | 314 | /// <note>
|
@@ -349,7 +392,7 @@ private void WorkThread_Run()
|
349 | 392 |
|
350 | 393 | bytesRead = 0;
|
351 | 394 | }
|
352 |
| - // Logger.Log(LogLevel.Verbose, "Read rcon message: {0} bytes", message.Length.ToString()); |
| 395 | + // Logger.Log(LogLevel.Verbose, "Read rcon message: {0} bytes", message.Length.ToString()); |
353 | 396 | ProcessMessage(message);
|
354 | 397 |
|
355 | 398 | bytesRead = 0;
|
|
0 commit comments