Merge remote-tracking branch 'refs/remotes/barotrauma/master'
Conflicts: .vs/Subsurface_Solution/v14/.suo Subsurface/Barotrauma.csproj Subsurface/Properties/AssemblyInfo.cs Subsurface/Source/Items/ItemSpawner.cs Subsurface/Source/Networking/GameClient.cs Subsurface/Source/Networking/GameServer.cs Subsurface/Source/Networking/GameServerLogin.cs
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
Binary file not shown.
@@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
<music file="Content/Sounds/Music/Enter the Maze.ogg" type="repair" priorityrange="30,60"/>
|
<music file="Content/Sounds/Music/Enter the Maze.ogg" type="repair" priorityrange="30,60"/>
|
||||||
<music file="Content/Sounds/Music/Static Motion.ogg" type="repair" priorityrange="50,80"/>
|
<music file="Content/Sounds/Music/Static Motion.ogg" type="repair" priorityrange="50,80"/>
|
||||||
|
<music file="Content/Sounds/Music/Phantom From Space.ogg" type="monster" priorityrange="25,60"/>
|
||||||
<music file="Content/Sounds/Music/Unseen Horrors.ogg" type="monster" priorityrange="40,100"/>
|
<music file="Content/Sounds/Music/Unseen Horrors.ogg" type="monster" priorityrange="40,100"/>
|
||||||
|
|
||||||
<music file="Content/Sounds/Music/amb_JD_drone_clattering_machine.ogg" type="deep"/>
|
<music file="Content/Sounds/Music/amb_JD_drone_clattering_machine.ogg" type="deep"/>
|
||||||
|
|||||||
@@ -42,6 +42,8 @@
|
|||||||
<Character file="Content/Characters/TigerThresher/tigerthresher.xml" />
|
<Character file="Content/Characters/TigerThresher/tigerthresher.xml" />
|
||||||
<Character file="Content/Characters/Watcher/watcher.xml" />
|
<Character file="Content/Characters/Watcher/watcher.xml" />
|
||||||
<Structure file="Content/Map/StructurePrefabs.xml" />
|
<Structure file="Content/Map/StructurePrefabs.xml" />
|
||||||
|
<BackgroundCreaturePrefabs file="Content/BackgroundSprites/BackgroundCreaturePrefabs.xml"/>
|
||||||
|
<BackgroundSpritePrefabs file="Content/BackgroundSprites/BackgroundSpritePrefabs.xml" />
|
||||||
<RandomEvents file="Content/randomevents.xml" />
|
<RandomEvents file="Content/randomevents.xml" />
|
||||||
<LocationTypes file="Content/Map/locationTypes.xml" />
|
<LocationTypes file="Content/Map/locationTypes.xml" />
|
||||||
<Missions file="Content/Missions.xml" />
|
<Missions file="Content/Missions.xml" />
|
||||||
|
|||||||
@@ -16,23 +16,37 @@ namespace Barotrauma
|
|||||||
|
|
||||||
float checkActiveTimer;
|
float checkActiveTimer;
|
||||||
|
|
||||||
private List<BackgroundCreaturePrefab> prefabs;
|
private List<BackgroundCreaturePrefab> prefabs = new List<BackgroundCreaturePrefab>();
|
||||||
private List<BackgroundCreature> activeSprites;
|
private List<BackgroundCreature> activeSprites = new List<BackgroundCreature>();
|
||||||
|
|
||||||
public BackgroundCreatureManager(string configPath)
|
public BackgroundCreatureManager(string configPath)
|
||||||
{
|
{
|
||||||
activeSprites = new List<BackgroundCreature>();
|
LoadConfig(configPath);
|
||||||
prefabs = new List<BackgroundCreaturePrefab>();
|
}
|
||||||
|
public BackgroundCreatureManager(List<string> files)
|
||||||
XDocument doc = ToolBox.TryLoadXml(configPath);
|
{
|
||||||
if (doc == null || doc.Root == null) return;
|
foreach(var file in files)
|
||||||
|
|
||||||
foreach (XElement element in doc.Root.Elements())
|
|
||||||
{
|
{
|
||||||
prefabs.Add(new BackgroundCreaturePrefab(element));
|
LoadConfig(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void LoadConfig(string configPath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
XDocument doc = ToolBox.TryLoadXml(configPath);
|
||||||
|
if (doc == null || doc.Root == null) return;
|
||||||
|
|
||||||
|
foreach (XElement element in doc.Root.Elements())
|
||||||
|
{
|
||||||
|
prefabs.Add(new BackgroundCreaturePrefab(element));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError(String.Format("Failed to load BackgroundCreatures from {0}", configPath), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
public void SpawnSprites(int count, Vector2? position = null)
|
public void SpawnSprites(int count, Vector2? position = null)
|
||||||
{
|
{
|
||||||
activeSprites.Clear();
|
activeSprites.Clear();
|
||||||
|
|||||||
@@ -34,25 +34,39 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
const int GridSize = 1000;
|
const int GridSize = 1000;
|
||||||
|
|
||||||
private List<BackgroundSpritePrefab> prefabs;
|
private List<BackgroundSpritePrefab> prefabs = new List<BackgroundSpritePrefab>();
|
||||||
//private List<BackgroundSprite> sprites;
|
|
||||||
|
|
||||||
private List<BackgroundSprite>[,] sprites;
|
private List<BackgroundSprite>[,] sprites;
|
||||||
|
|
||||||
public BackgroundSpriteManager(string configPath)
|
public BackgroundSpriteManager(string configPath)
|
||||||
{
|
{
|
||||||
//sprites = new List<BackgroundSprite>[2,2]();
|
LoadConfig(configPath);
|
||||||
prefabs = new List<BackgroundSpritePrefab>();
|
}
|
||||||
|
public BackgroundSpriteManager(List<string> files)
|
||||||
XDocument doc = ToolBox.TryLoadXml(configPath);
|
{
|
||||||
if (doc == null || doc.Root == null) return;
|
foreach (var file in files)
|
||||||
|
|
||||||
foreach (XElement element in doc.Root.Elements())
|
|
||||||
{
|
{
|
||||||
prefabs.Add(new BackgroundSpritePrefab(element));
|
LoadConfig(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void LoadConfig(string configPath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
XDocument doc = ToolBox.TryLoadXml(configPath);
|
||||||
|
if (doc == null || doc.Root == null) return;
|
||||||
|
|
||||||
|
foreach (XElement element in doc.Root.Elements())
|
||||||
|
{
|
||||||
|
prefabs.Add(new BackgroundSpritePrefab(element));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError(String.Format("Failed to load BackgroundSprites from {0}", configPath), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
public void PlaceSprites(Level level, int amount)
|
public void PlaceSprites(Level level, int amount)
|
||||||
{
|
{
|
||||||
sprites = new List<BackgroundSprite>[
|
sprites = new List<BackgroundSprite>[
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
public enum ContentType
|
public enum ContentType
|
||||||
{
|
{
|
||||||
None, Jobs, Item, Character, Structure, Executable, LocationTypes, RandomEvents, Missions
|
None, Jobs, Item, Character, Structure, Executable, LocationTypes, RandomEvents, Missions, BackgroundCreaturePrefabs, BackgroundSpritePrefabs
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ContentPackage
|
public class ContentPackage
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ namespace Barotrauma
|
|||||||
NewMessage(" ", Color.Cyan);
|
NewMessage(" ", Color.Cyan);
|
||||||
|
|
||||||
NewMessage("spawn [creaturename] [near/inside/outside]: spawn a creature at a random spawnpoint (use the second parameter to only select spawnpoints near/inside/outside the submarine)", Color.Cyan);
|
NewMessage("spawn [creaturename] [near/inside/outside]: spawn a creature at a random spawnpoint (use the second parameter to only select spawnpoints near/inside/outside the submarine)", Color.Cyan);
|
||||||
|
NewMessage("spawnitem [itemname] [cursor/inventory]: spawn an item at the position of the cursor, in the inventory of the controlled character or at a random spawnpoint if the last parameter is omitted", Color.Cyan);
|
||||||
|
|
||||||
NewMessage(" ", Color.Cyan);
|
NewMessage(" ", Color.Cyan);
|
||||||
|
|
||||||
@@ -200,7 +201,7 @@ namespace Barotrauma
|
|||||||
NewMessage("revive: bring the controlled character back from the dead", Color.Cyan);
|
NewMessage("revive: bring the controlled character back from the dead", Color.Cyan);
|
||||||
|
|
||||||
NewMessage(" ", Color.Cyan);
|
NewMessage(" ", Color.Cyan);
|
||||||
|
|
||||||
NewMessage("fixwalls: fixes all the walls", Color.Cyan);
|
NewMessage("fixwalls: fixes all the walls", Color.Cyan);
|
||||||
NewMessage("fixitems: fixes every item/device in the sub", Color.Cyan);
|
NewMessage("fixitems: fixes every item/device in the sub", Color.Cyan);
|
||||||
NewMessage("oxygen: replenishes the oxygen in every room to 100%", Color.Cyan);
|
NewMessage("oxygen: replenishes the oxygen in every room to 100%", Color.Cyan);
|
||||||
@@ -219,6 +220,7 @@ namespace Barotrauma
|
|||||||
UpdaterUtil.SaveFileList("filelist.xml");
|
UpdaterUtil.SaveFileList("filelist.xml");
|
||||||
break;
|
break;
|
||||||
case "spawn":
|
case "spawn":
|
||||||
|
case "spawncharacter":
|
||||||
if (commands.Length == 1) return;
|
if (commands.Length == 1) return;
|
||||||
|
|
||||||
Character spawnedCharacter = null;
|
Character spawnedCharacter = null;
|
||||||
@@ -231,7 +233,7 @@ namespace Barotrauma
|
|||||||
switch (commands[2].ToLowerInvariant())
|
switch (commands[2].ToLowerInvariant())
|
||||||
{
|
{
|
||||||
case "inside":
|
case "inside":
|
||||||
spawnPoint = WayPoint.GetRandom(SpawnType.Human);
|
spawnPoint = WayPoint.GetRandom(SpawnType.Human, null, Submarine.MainSub);
|
||||||
break;
|
break;
|
||||||
case "outside":
|
case "outside":
|
||||||
spawnPoint = WayPoint.GetRandom(SpawnType.Enemy);
|
spawnPoint = WayPoint.GetRandom(SpawnType.Enemy);
|
||||||
@@ -293,6 +295,54 @@ namespace Barotrauma
|
|||||||
spawnedCharacter.SpawnedMidRound = true;
|
spawnedCharacter.SpawnedMidRound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "spawnitem":
|
||||||
|
if (commands.Length < 2) return;
|
||||||
|
|
||||||
|
Vector2? spawnPos = null;
|
||||||
|
Inventory spawnInventory = null;
|
||||||
|
|
||||||
|
int extraParams = 0;
|
||||||
|
switch (commands.Last())
|
||||||
|
{
|
||||||
|
case "cursor":
|
||||||
|
extraParams = 1;
|
||||||
|
spawnPos = GameMain.GameScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||||
|
break;
|
||||||
|
case "inventory":
|
||||||
|
extraParams = 1;
|
||||||
|
spawnInventory = Character.Controlled == null ? null : Character.Controlled.Inventory;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
extraParams = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
string itemName = string.Join(" ", commands.Skip(1).Take(commands.Length - extraParams - 1)).ToLowerInvariant();
|
||||||
|
|
||||||
|
var itemPrefab = MapEntityPrefab.list.Find(ip => ip.Name.ToLowerInvariant() == itemName) as ItemPrefab;
|
||||||
|
if (itemPrefab == null)
|
||||||
|
{
|
||||||
|
ThrowError("Item \""+itemName+"\" not found!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (spawnPos == null && spawnInventory == null)
|
||||||
|
{
|
||||||
|
var wp = WayPoint.GetRandom(SpawnType.Human, null, Submarine.MainSub);
|
||||||
|
spawnPos = wp == null ? Vector2.Zero : wp.WorldPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (spawnPos != null)
|
||||||
|
{
|
||||||
|
Item.Spawner.QueueItem(itemPrefab, (Vector2)spawnPos, false);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (spawnInventory != null)
|
||||||
|
{
|
||||||
|
Item.Spawner.QueueItem(itemPrefab, (Inventory)spawnInventory, false);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "disablecrewai":
|
case "disablecrewai":
|
||||||
HumanAIController.DisableCrewAI = !HumanAIController.DisableCrewAI;
|
HumanAIController.DisableCrewAI = !HumanAIController.DisableCrewAI;
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ namespace Barotrauma
|
|||||||
missionButton.UserData = InfoFrameTab.Mission;
|
missionButton.UserData = InfoFrameTab.Mission;
|
||||||
missionButton.OnClicked = SelectInfoFrameTab;
|
missionButton.OnClicked = SelectInfoFrameTab;
|
||||||
|
|
||||||
if (GameMain.Server != null)
|
if (GameMain.Server != null)
|
||||||
{
|
{
|
||||||
var manageButton = new GUIButton(new Rectangle(200, -30, 130, 20), "Manage players", GUI.Style, infoFrame);
|
var manageButton = new GUIButton(new Rectangle(200, -30, 130, 20), "Manage players", GUI.Style, infoFrame);
|
||||||
manageButton.UserData = InfoFrameTab.ManagePlayers;
|
manageButton.UserData = InfoFrameTab.ManagePlayers;
|
||||||
@@ -269,7 +269,7 @@ namespace Barotrauma
|
|||||||
break;
|
break;
|
||||||
case InfoFrameTab.Mission:
|
case InfoFrameTab.Mission:
|
||||||
CreateMissionInfo(infoFrame);
|
CreateMissionInfo(infoFrame);
|
||||||
break;
|
break;
|
||||||
case InfoFrameTab.ManagePlayers:
|
case InfoFrameTab.ManagePlayers:
|
||||||
GameMain.Server.ManagePlayersFrame(infoFrame);
|
GameMain.Server.ManagePlayersFrame(infoFrame);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -17,20 +17,20 @@ namespace Barotrauma
|
|||||||
spawnQueue = new Queue<Pair<ItemPrefab, object>>();
|
spawnQueue = new Queue<Pair<ItemPrefab, object>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
//public void QueueItem(ItemPrefab itemPrefab, Vector2 position, bool isNetworkMessage = false)
|
public void QueueItem(ItemPrefab itemPrefab, Vector2 worldPosition, bool isNetworkMessage = false)
|
||||||
//{
|
{
|
||||||
// if (!isNetworkMessage && GameMain.Client!=null)
|
if (!isNetworkMessage && GameMain.Client != null)
|
||||||
// {
|
{
|
||||||
// //clients aren't allowed to spawn new items unless the server says so
|
//clients aren't allowed to spawn new items unless the server says so
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// var itemInfo = new Pair<ItemPrefab, object>();
|
var itemInfo = new Pair<ItemPrefab, object>();
|
||||||
// itemInfo.First = itemPrefab;
|
itemInfo.First = itemPrefab;
|
||||||
// itemInfo.Second = position;
|
itemInfo.Second = worldPosition;
|
||||||
|
|
||||||
// spawnQueue.Enqueue(itemInfo);
|
spawnQueue.Enqueue(itemInfo);
|
||||||
//}
|
}
|
||||||
|
|
||||||
public void QueueItem(ItemPrefab itemPrefab, Inventory inventory, bool isNetworkMessage = false)
|
public void QueueItem(ItemPrefab itemPrefab, Inventory inventory, bool isNetworkMessage = false)
|
||||||
{
|
{
|
||||||
@@ -58,17 +58,14 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
var itemInfo = spawnQueue.Dequeue();
|
var itemInfo = spawnQueue.Dequeue();
|
||||||
|
|
||||||
//if (itemInfo.Second is Vector2)
|
if (itemInfo.Second is Vector2)
|
||||||
//{
|
{
|
||||||
// //todo: take multiple subs into account
|
var item = new Item(itemInfo.First, (Vector2)itemInfo.Second, null);
|
||||||
// Vector2 position = (Vector2)itemInfo.Second - Submarine.MainSub.HiddenSubPosition;
|
AddToSpawnedList(item);
|
||||||
|
|
||||||
// items.Add(new Item(itemInfo.First, position, null));
|
items.Add(item);
|
||||||
// inventories.Add(null);
|
}
|
||||||
|
else if (itemInfo.Second is Inventory)
|
||||||
//}
|
|
||||||
//else
|
|
||||||
if (itemInfo.Second is Inventory)
|
|
||||||
{
|
{
|
||||||
var item = new Item(itemInfo.First, Vector2.Zero, null);
|
var item = new Item(itemInfo.First, Vector2.Zero, null);
|
||||||
AddToSpawnedList(item);
|
AddToSpawnedList(item);
|
||||||
@@ -77,7 +74,6 @@ namespace Barotrauma
|
|||||||
inventory.TryPutItem(item, null);
|
inventory.TryPutItem(item, null);
|
||||||
|
|
||||||
items.Add(item);
|
items.Add(item);
|
||||||
//inventories.Add(inventory);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public LevelRenderer(Level level)
|
public LevelRenderer(Level level)
|
||||||
{
|
{
|
||||||
if (shaftTexture == null) shaftTexture = TextureLoader.FromFile("Content/Map/shaft.png");
|
if (shaftTexture == null) shaftTexture = TextureLoader.FromFile("Content/Map/iceWall.png");
|
||||||
|
|
||||||
if (background==null)
|
if (background==null)
|
||||||
{
|
{
|
||||||
@@ -50,7 +50,12 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (backgroundSpriteManager==null)
|
if (backgroundSpriteManager==null)
|
||||||
{
|
{
|
||||||
backgroundSpriteManager = new BackgroundSpriteManager("Content/BackgroundSprites/BackgroundSpritePrefabs.xml");
|
|
||||||
|
var files = GameMain.SelectedPackage.GetFilesOfType(ContentType.BackgroundSpritePrefabs);
|
||||||
|
if (files.Count > 0)
|
||||||
|
backgroundSpriteManager = new BackgroundSpriteManager(files);
|
||||||
|
else
|
||||||
|
backgroundSpriteManager = new BackgroundSpriteManager("Content/BackgroundSprites/BackgroundSpritePrefabs.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.level = level;
|
this.level = level;
|
||||||
@@ -173,22 +178,21 @@ namespace Barotrauma
|
|||||||
|
|
||||||
Vector2 pos = new Vector2(0.0f, -level.Size.Y);// level.EndPosition;
|
Vector2 pos = new Vector2(0.0f, -level.Size.Y);// level.EndPosition;
|
||||||
|
|
||||||
if (GameMain.GameScreen.Cam.WorldView.Y < -pos.Y - 512) return;
|
if (GameMain.GameScreen.Cam.WorldView.Y < -pos.Y - 1024) return;
|
||||||
|
|
||||||
pos.X = GameMain.GameScreen.Cam.WorldView.X -512.0f;
|
pos.X = GameMain.GameScreen.Cam.WorldView.X -1024;
|
||||||
|
|
||||||
int width = (int)(Math.Ceiling(GameMain.GameScreen.Cam.WorldView.Width / 512.0f + 2.0f) * 512.0f);
|
int width = (int)(Math.Ceiling(GameMain.GameScreen.Cam.WorldView.Width / 1024 + 4.0f) * 1024);
|
||||||
|
|
||||||
|
GUI.DrawRectangle(spriteBatch,new Rectangle((int)(MathUtils.Round(pos.X, 1024)), (int)-GameMain.GameScreen.Cam.WorldView.Y, width, (int)(GameMain.GameScreen.Cam.WorldView.Y - level.Size.Y) + 30),Color.Black, true);
|
||||||
spriteBatch.Draw(shaftTexture,
|
spriteBatch.Draw(shaftTexture,
|
||||||
new Rectangle((int)(MathUtils.Round(pos.X, 512.0f)), (int)pos.Y, width, 512),
|
new Rectangle((int)(MathUtils.Round(pos.X, 1024)), (int)pos.Y, width, 1024),
|
||||||
new Rectangle(0, 0, width, 256),
|
new Rectangle(0, 0, width, 1024),
|
||||||
level.BackgroundColor, 0.0f,
|
level.BackgroundColor, 0.0f,
|
||||||
Vector2.Zero,
|
Vector2.Zero,
|
||||||
SpriteEffects.None, 0.0f);
|
SpriteEffects.None, 0.0f);
|
||||||
|
|
||||||
GUI.DrawRectangle(spriteBatch,
|
|
||||||
new Rectangle((int)(MathUtils.Round(pos.X, 512.0f)), (int)-GameMain.GameScreen.Cam.WorldView.Y, width, (int)(GameMain.GameScreen.Cam.WorldView.Y - level.Size.Y)+10),
|
|
||||||
Color.Black, true );
|
|
||||||
|
|
||||||
//background.DrawTiled(spriteBatch,
|
//background.DrawTiled(spriteBatch,
|
||||||
// (backgroundPos.Y < 0) ? new Vector2(0.0f, -backgroundPos.Y) : Vector2.Zero,
|
// (backgroundPos.Y < 0) ? new Vector2(0.0f, -backgroundPos.Y) : Vector2.Zero,
|
||||||
@@ -199,6 +203,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void RenderWalls(GraphicsDevice graphicsDevice, Camera cam)
|
public void RenderWalls(GraphicsDevice graphicsDevice, Camera cam)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (wallVertices == null) return;
|
if (wallVertices == null) return;
|
||||||
|
|
||||||
basicEffect.World = cam.ShaderTransform
|
basicEffect.World = cam.ShaderTransform
|
||||||
|
|||||||
@@ -12,6 +12,20 @@ namespace Barotrauma.Networking
|
|||||||
public string Name;
|
public string Name;
|
||||||
public string IP;
|
public string IP;
|
||||||
|
|
||||||
|
public bool CompareTo(string ipCompare)
|
||||||
|
{
|
||||||
|
int rangeBanIndex = IP.IndexOf(".x");
|
||||||
|
if (rangeBanIndex<=-1)
|
||||||
|
{
|
||||||
|
return ipCompare == IP;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ipCompare.Length < rangeBanIndex) return false;
|
||||||
|
return ipCompare.Substring(0, rangeBanIndex) == IP.Substring(0, rangeBanIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public BannedPlayer(string name, string ip)
|
public BannedPlayer(string name, string ip)
|
||||||
{
|
{
|
||||||
this.Name = name;
|
this.Name = name;
|
||||||
@@ -74,7 +88,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
public bool IsBanned(string IP)
|
public bool IsBanned(string IP)
|
||||||
{
|
{
|
||||||
return bannedPlayers.Any(bp => bp.IP == IP);
|
return bannedPlayers.Any(bp => bp.CompareTo(IP));
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIComponent CreateBanFrame(GUIComponent parent)
|
public GUIComponent CreateBanFrame(GUIComponent parent)
|
||||||
@@ -94,6 +108,12 @@ namespace Barotrauma.Networking
|
|||||||
var removeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Remove", Alignment.Right | Alignment.CenterY, GUI.Style, textBlock);
|
var removeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Remove", Alignment.Right | Alignment.CenterY, GUI.Style, textBlock);
|
||||||
removeButton.UserData = bannedPlayer;
|
removeButton.UserData = bannedPlayer;
|
||||||
removeButton.OnClicked = RemoveBan;
|
removeButton.OnClicked = RemoveBan;
|
||||||
|
if (bannedPlayer.IP.IndexOf(".x") <= -1)
|
||||||
|
{
|
||||||
|
var rangeBanButton = new GUIButton(new Rectangle(-100, 0, 100, 20), "Ban range", Alignment.Right | Alignment.CenterY, GUI.Style, textBlock);
|
||||||
|
rangeBanButton.UserData = bannedPlayer;
|
||||||
|
rangeBanButton.OnClicked = RangeBan;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return banFrame;
|
return banFrame;
|
||||||
@@ -120,6 +140,46 @@ namespace Barotrauma.Networking
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string ToRange(string ip)
|
||||||
|
{
|
||||||
|
for (int i = ip.Length - 1; i > 0; i--)
|
||||||
|
{
|
||||||
|
if (ip[i] == '.')
|
||||||
|
{
|
||||||
|
ip = ip.Substring(0, i) + ".x";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool RangeBan(GUIButton button, object obj)
|
||||||
|
{
|
||||||
|
BannedPlayer banned = obj as BannedPlayer;
|
||||||
|
if (banned == null) return false;
|
||||||
|
|
||||||
|
banned.IP = ToRange(banned.IP);
|
||||||
|
|
||||||
|
BannedPlayer bp;
|
||||||
|
while ((bp = bannedPlayers.Find(x => banned.CompareTo(x.IP)))!=null)
|
||||||
|
{
|
||||||
|
//remove all specific bans that are now covered by the rangeban
|
||||||
|
bannedPlayers.Remove(bp);
|
||||||
|
}
|
||||||
|
|
||||||
|
bannedPlayers.Add(banned);
|
||||||
|
|
||||||
|
Save();
|
||||||
|
|
||||||
|
if (banFrame != null)
|
||||||
|
{
|
||||||
|
banFrame.Parent.RemoveChild(banFrame);
|
||||||
|
CreateBanFrame(banFrame.Parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private bool CloseFrame(GUIButton button, object obj)
|
private bool CloseFrame(GUIButton button, object obj)
|
||||||
{
|
{
|
||||||
banFrame = null;
|
banFrame = null;
|
||||||
|
|||||||
@@ -116,6 +116,12 @@ namespace Barotrauma.Networking
|
|||||||
settingsButton.OnClicked = ToggleSettingsFrame;
|
settingsButton.OnClicked = ToggleSettingsFrame;
|
||||||
settingsButton.UserData = "settingsButton";
|
settingsButton.UserData = "settingsButton";
|
||||||
|
|
||||||
|
whitelist = new WhiteList();
|
||||||
|
|
||||||
|
GUIButton whitelistButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170 - 170 - 170 - 170, 20, 150, 20), "Whitelist", Alignment.TopLeft, GUI.Style, inGameHUD);
|
||||||
|
whitelistButton.OnClicked = ToggleWhiteListFrame;
|
||||||
|
whitelistButton.UserData = "whitelistButton";
|
||||||
|
|
||||||
banList = new BanList();
|
banList = new BanList();
|
||||||
|
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
@@ -284,6 +290,7 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
if (ShowNetStats) netStats.Update(deltaTime);
|
if (ShowNetStats) netStats.Update(deltaTime);
|
||||||
if (settingsFrame != null) settingsFrame.Update(deltaTime);
|
if (settingsFrame != null) settingsFrame.Update(deltaTime);
|
||||||
|
if (whitelist.WhiteListFrame != null) whitelist.WhiteListFrame.Update(deltaTime);
|
||||||
|
|
||||||
if (!started) return;
|
if (!started) return;
|
||||||
|
|
||||||
@@ -895,6 +902,10 @@ namespace Barotrauma.Networking
|
|||||||
log.LogFrame.Update(0.016f);
|
log.LogFrame.Update(0.016f);
|
||||||
log.LogFrame.Draw(spriteBatch);
|
log.LogFrame.Draw(spriteBatch);
|
||||||
}
|
}
|
||||||
|
else if (whitelist.WhiteListFrame != null)
|
||||||
|
{
|
||||||
|
whitelist.WhiteListFrame.Draw(spriteBatch);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ShowNetStats) return;
|
if (!ShowNetStats) return;
|
||||||
|
|
||||||
@@ -1009,6 +1020,10 @@ namespace Barotrauma.Networking
|
|||||||
banButton.UserData = character.Name;
|
banButton.UserData = character.Name;
|
||||||
banButton.OnClicked += GameMain.NetLobbyScreen.BanPlayer;
|
banButton.OnClicked += GameMain.NetLobbyScreen.BanPlayer;
|
||||||
|
|
||||||
|
var rangebanButton = new GUIButton(new Rectangle(0, -25, 100, 20), "Ban range", Alignment.BottomRight, GUI.Style, characterFrame);
|
||||||
|
rangebanButton.UserData = character.Name;
|
||||||
|
rangebanButton.OnClicked += GameMain.NetLobbyScreen.BanPlayerRange;
|
||||||
|
|
||||||
var kickButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Kick", Alignment.BottomLeft, GUI.Style, characterFrame);
|
var kickButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Kick", Alignment.BottomLeft, GUI.Style, characterFrame);
|
||||||
kickButton.UserData = character.Name;
|
kickButton.UserData = character.Name;
|
||||||
kickButton.OnClicked += GameMain.NetLobbyScreen.KickPlayer;
|
kickButton.OnClicked += GameMain.NetLobbyScreen.KickPlayer;
|
||||||
|
|||||||
@@ -156,6 +156,14 @@ namespace Barotrauma.Networking
|
|||||||
unauthenticatedClients.Remove(unauthClient);
|
unauthenticatedClients.Remove(unauthClient);
|
||||||
unauthClient = null;
|
unauthClient = null;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
if (!whitelist.IsWhiteListed(name, inc.SenderConnection.RemoteEndPoint.Address.ToString()))
|
||||||
|
{
|
||||||
|
inc.SenderConnection.Disconnect("You're not in this server's whitelist.");
|
||||||
|
DebugConsole.NewMessage(name + " (" + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ") couldn't join the server (not in whitelist)", Color.Red);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (!Client.IsValidName(name))
|
if (!Client.IsValidName(name))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
private bool registeredToMaster;
|
private bool registeredToMaster;
|
||||||
|
|
||||||
|
private WhiteList whitelist;
|
||||||
private BanList banList;
|
private BanList banList;
|
||||||
|
|
||||||
private string password;
|
private string password;
|
||||||
@@ -253,7 +254,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
private void CreateSettingsFrame()
|
private void CreateSettingsFrame()
|
||||||
{
|
{
|
||||||
settingsFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f);
|
settingsFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f);
|
||||||
|
|
||||||
GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 400, 430), null, Alignment.Center, GUI.Style, settingsFrame);
|
GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 400, 430), null, Alignment.Center, GUI.Style, settingsFrame);
|
||||||
innerFrame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f);
|
innerFrame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f);
|
||||||
@@ -643,6 +644,20 @@ namespace Barotrauma.Networking
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ToggleWhiteListFrame(GUIButton button, object obj)
|
||||||
|
{
|
||||||
|
if (whitelist.WhiteListFrame == null)
|
||||||
|
{
|
||||||
|
whitelist.CreateWhiteListFrame();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
whitelist.CloseFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void ManagePlayersFrame(GUIFrame infoFrame)
|
public void ManagePlayersFrame(GUIFrame infoFrame)
|
||||||
{
|
{
|
||||||
GUIListBox cList = new GUIListBox(new Rectangle(0, 0, 0, 300), Color.White * 0.7f, GUI.Style, infoFrame);
|
GUIListBox cList = new GUIListBox(new Rectangle(0, 0, 0, 300), Color.White * 0.7f, GUI.Style, infoFrame);
|
||||||
@@ -664,13 +679,17 @@ namespace Barotrauma.Networking
|
|||||||
Alignment.Left, Alignment.Left,
|
Alignment.Left, Alignment.Left,
|
||||||
null, frame);
|
null, frame);
|
||||||
|
|
||||||
var banButton = new GUIButton(new Rectangle(-120, 0, 100, 20), "Ban", Alignment.Right | Alignment.CenterY, GUI.Style, frame);
|
var banButton = new GUIButton(new Rectangle(-110, 0, 100, 20), "Ban", Alignment.Right | Alignment.CenterY, GUI.Style, frame);
|
||||||
banButton.UserData = c.name;
|
banButton.UserData = c.name;
|
||||||
banButton.OnClicked += GameMain.NetLobbyScreen.BanPlayer;
|
banButton.OnClicked = GameMain.NetLobbyScreen.BanPlayer;
|
||||||
|
|
||||||
|
var rangebanButton = new GUIButton(new Rectangle(-220, 0, 100, 20), "Ban range", Alignment.Right | Alignment.CenterY, GUI.Style, frame);
|
||||||
|
rangebanButton.UserData = c.name;
|
||||||
|
rangebanButton.OnClicked = GameMain.NetLobbyScreen.BanPlayerRange;
|
||||||
|
|
||||||
var kickButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Kick", Alignment.Right | Alignment.CenterY, GUI.Style, frame);
|
var kickButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Kick", Alignment.Right | Alignment.CenterY, GUI.Style, frame);
|
||||||
kickButton.UserData = c.name;
|
kickButton.UserData = c.name;
|
||||||
kickButton.OnClicked += GameMain.NetLobbyScreen.KickPlayer;
|
kickButton.OnClicked = GameMain.NetLobbyScreen.KickPlayer;
|
||||||
|
|
||||||
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
|
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
public virtual void SendChatMessage(string message, ChatMessageType? type = null) { }
|
public virtual void SendChatMessage(string message, ChatMessageType? type = null) { }
|
||||||
|
|
||||||
public virtual void KickPlayer(string kickedName, bool ban) { }
|
public virtual void KickPlayer(string kickedName, bool ban, bool range = false) { }
|
||||||
|
|
||||||
public virtual void Update(float deltaTime)
|
public virtual void Update(float deltaTime)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,224 @@
|
|||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Barotrauma.Networking
|
||||||
|
{
|
||||||
|
class WhiteListedPlayer
|
||||||
|
{
|
||||||
|
public string Name;
|
||||||
|
public string IP;
|
||||||
|
|
||||||
|
public WhiteListedPlayer(string name,string ip)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
IP = ip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class WhiteList
|
||||||
|
{
|
||||||
|
const string SavePath = "Data/whitelist.txt";
|
||||||
|
|
||||||
|
private List<WhiteListedPlayer> whitelistedPlayers;
|
||||||
|
public List<WhiteListedPlayer> WhiteListedPlayers
|
||||||
|
{
|
||||||
|
get { return whitelistedPlayers; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private GUIComponent whitelistFrame;
|
||||||
|
private GUIComponent innerlistFrame;
|
||||||
|
|
||||||
|
private GUITextBox nameBox;
|
||||||
|
private GUITextBox ipBox;
|
||||||
|
|
||||||
|
public bool enabled;
|
||||||
|
|
||||||
|
public GUIComponent WhiteListFrame
|
||||||
|
{
|
||||||
|
get { return whitelistFrame; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public WhiteList()
|
||||||
|
{
|
||||||
|
enabled = false;
|
||||||
|
whitelistedPlayers = new List<WhiteListedPlayer>();
|
||||||
|
|
||||||
|
if (File.Exists(SavePath))
|
||||||
|
{
|
||||||
|
string[] lines;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lines = File.ReadAllLines(SavePath);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Failed to open whitelist in " + SavePath, e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string line in lines)
|
||||||
|
{
|
||||||
|
if (line[0] == '#')
|
||||||
|
{
|
||||||
|
string lineval = line.Substring(1, line.Length - 1);
|
||||||
|
if (lineval.ToLower()=="true" || Convert.ToInt32(lineval)!=0)
|
||||||
|
{
|
||||||
|
enabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string[] separatedLine = line.Split(',');
|
||||||
|
if (separatedLine.Length < 2) continue;
|
||||||
|
|
||||||
|
string name = String.Join(",", separatedLine.Take(separatedLine.Length - 1));
|
||||||
|
string ip = separatedLine.Last();
|
||||||
|
|
||||||
|
whitelistedPlayers.Add(new WhiteListedPlayer(name, ip));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Save()
|
||||||
|
{
|
||||||
|
GameServer.Log("Saving whitelist", null);
|
||||||
|
|
||||||
|
List<string> lines = new List<string>();
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
lines.Add("#true");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lines.Add("#false");
|
||||||
|
}
|
||||||
|
foreach (WhiteListedPlayer wlp in whitelistedPlayers)
|
||||||
|
{
|
||||||
|
lines.Add(wlp.Name + "," + wlp.IP);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.WriteAllLines(SavePath, lines);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Saving the whitelist to " + SavePath + " failed", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsWhiteListed(string name, string ip)
|
||||||
|
{
|
||||||
|
if (!enabled) return true;
|
||||||
|
WhiteListedPlayer wlp = whitelistedPlayers.Find(p => p.Name == name);
|
||||||
|
if (wlp == null) return false;
|
||||||
|
if (wlp.IP != ip && !string.IsNullOrWhiteSpace(wlp.IP)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GUIComponent CreateWhiteListFrame()
|
||||||
|
{
|
||||||
|
whitelistFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f);
|
||||||
|
|
||||||
|
GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 500, 430), null, Alignment.Center, GUI.Style, whitelistFrame);
|
||||||
|
innerFrame.Padding = new Vector4(20.0f, 50.0f, 20.0f, 100.0f);
|
||||||
|
|
||||||
|
var closeButton = new GUIButton(new Rectangle(0, 85, 100, 20), "Close", Alignment.BottomRight, GUI.Style, innerFrame);
|
||||||
|
closeButton.OnClicked = GameMain.Server.ToggleWhiteListFrame;
|
||||||
|
|
||||||
|
new GUITextBlock(new Rectangle(0, -35, 200, 20), "Whitelist", GUI.Style, innerFrame, GUI.LargeFont);
|
||||||
|
var enabledTick = new GUITickBox(new Rectangle(200, -30, 20, 20), "Enabled", Alignment.Left, innerFrame);
|
||||||
|
enabledTick.Selected = enabled;
|
||||||
|
enabledTick.OnSelected = (GUITickBox box) =>
|
||||||
|
{
|
||||||
|
enabled = !enabled;
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
foreach (Client c in GameMain.Server.ConnectedClients)
|
||||||
|
{
|
||||||
|
if (!IsWhiteListed(c.name,c.Connection.RemoteEndPoint.Address.ToString()))
|
||||||
|
{
|
||||||
|
whitelistedPlayers.Add(new WhiteListedPlayer(c.name, c.Connection.RemoteEndPoint.Address.ToString()));
|
||||||
|
CloseFrame(); CreateWhiteListFrame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Save();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
new GUITextBlock(new Rectangle(0, 35, 90, 25), "Name:", GUI.Style, Alignment.BottomLeft, Alignment.TopLeft, innerFrame, false, GUI.Font);
|
||||||
|
nameBox = new GUITextBox(new Rectangle(100, 30, 170, 25), Alignment.BottomLeft, GUI.Style, innerFrame);
|
||||||
|
nameBox.Font = GUI.Font;
|
||||||
|
|
||||||
|
new GUITextBlock(new Rectangle(0, 65, 90, 25), "IP Address:", GUI.Style, Alignment.BottomLeft, Alignment.TopLeft, innerFrame, false, GUI.Font);
|
||||||
|
ipBox = new GUITextBox(new Rectangle(100, 60, 170, 25), Alignment.BottomLeft, GUI.Style, innerFrame);
|
||||||
|
ipBox.Font = GUI.Font;
|
||||||
|
|
||||||
|
var addnewButton = new GUIButton(new Rectangle(300, 45, 150, 20), "Add to whitelist", Alignment.BottomLeft, GUI.Style, innerFrame);
|
||||||
|
addnewButton.OnClicked = AddToWhiteList;
|
||||||
|
|
||||||
|
innerlistFrame = new GUIListBox(new Rectangle(0, 0, 0, 0), GUI.Style, innerFrame);
|
||||||
|
|
||||||
|
foreach (WhiteListedPlayer wlp in whitelistedPlayers)
|
||||||
|
{
|
||||||
|
string blockText = wlp.Name;
|
||||||
|
if (!string.IsNullOrWhiteSpace(wlp.IP)) blockText += " (" + wlp.IP + ")";
|
||||||
|
GUITextBlock textBlock = new GUITextBlock(
|
||||||
|
new Rectangle(0, 0, 0, 25),
|
||||||
|
blockText,
|
||||||
|
GUI.Style,
|
||||||
|
Alignment.Left, Alignment.Left, innerlistFrame);
|
||||||
|
textBlock.Padding = new Vector4(10.0f, 10.0f, 0.0f, 0.0f);
|
||||||
|
textBlock.UserData = wlp;
|
||||||
|
|
||||||
|
var removeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Remove", Alignment.Right | Alignment.CenterY, GUI.Style, textBlock);
|
||||||
|
removeButton.UserData = wlp;
|
||||||
|
removeButton.OnClicked = RemoveFromWhiteList;
|
||||||
|
}
|
||||||
|
|
||||||
|
return whitelistFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool RemoveFromWhiteList(GUIButton button, object obj)
|
||||||
|
{
|
||||||
|
WhiteListedPlayer wlp = obj as WhiteListedPlayer;
|
||||||
|
if (wlp == null) return false;
|
||||||
|
|
||||||
|
DebugConsole.Log("Removing " + wlp.Name + " from whitelist");
|
||||||
|
GameServer.Log("Removing " + wlp.Name + " from whitelist", null);
|
||||||
|
|
||||||
|
whitelistedPlayers.Remove(wlp);
|
||||||
|
Save();
|
||||||
|
CloseFrame(); CreateWhiteListFrame();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool AddToWhiteList(GUIButton button, object obj)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(nameBox.Text) || whitelistedPlayers.Find(x => x.Name.ToLower() == nameBox.Text.ToLower()) != null) return false;
|
||||||
|
whitelistedPlayers.Add(new WhiteListedPlayer(nameBox.Text,ipBox.Text));
|
||||||
|
Save();
|
||||||
|
CloseFrame(); CreateWhiteListFrame();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CloseFrame(GUIButton button=null, object obj=null)
|
||||||
|
{
|
||||||
|
whitelistFrame = null;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,8 +33,12 @@ namespace Barotrauma
|
|||||||
renderTarget = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
renderTarget = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||||
renderTargetWater = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
renderTargetWater = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||||
renderTargetAir = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
renderTargetAir = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||||
|
|
||||||
BackgroundCreatureManager = new BackgroundCreatureManager("Content/BackgroundSprites/BackgroundCreaturePrefabs.xml");
|
var files = GameMain.SelectedPackage.GetFilesOfType(ContentType.BackgroundCreaturePrefabs);
|
||||||
|
if(files.Count > 0)
|
||||||
|
BackgroundCreatureManager = new BackgroundCreatureManager(files);
|
||||||
|
else
|
||||||
|
BackgroundCreatureManager = new BackgroundCreatureManager("Content/BackgroundSprites/BackgroundCreaturePrefabs.xml");
|
||||||
|
|
||||||
#if LINUX
|
#if LINUX
|
||||||
var blurEffect = content.Load<Effect>("blurshader_opengl");
|
var blurEffect = content.Load<Effect>("blurshader_opengl");
|
||||||
|
|||||||
@@ -413,8 +413,12 @@ namespace Barotrauma
|
|||||||
|
|
||||||
GUIButton settingsButton = new GUIButton(new Rectangle(-100, 0, 80, 30), "Settings", Alignment.BottomRight, GUI.Style, infoFrame);
|
GUIButton settingsButton = new GUIButton(new Rectangle(-100, 0, 80, 30), "Settings", Alignment.BottomRight, GUI.Style, infoFrame);
|
||||||
settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame;
|
settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame;
|
||||||
settingsButton.UserData = "settingsButton";
|
settingsButton.UserData = "settingsButton";
|
||||||
|
|
||||||
|
GUIButton whitelistButton = new GUIButton(new Rectangle(-200, 0, 80, 30), "Whitelist", Alignment.BottomRight, GUI.Style, infoFrame);
|
||||||
|
whitelistButton.OnClicked = GameMain.Server.ToggleWhiteListFrame;
|
||||||
|
whitelistButton.UserData = "whitelistButton";
|
||||||
|
|
||||||
if (subList.Selected == null) subList.Select(Math.Max(0, prevSelectedSub));
|
if (subList.Selected == null) subList.Select(Math.Max(0, prevSelectedSub));
|
||||||
if (shuttleList.Selected == null)
|
if (shuttleList.Selected == null)
|
||||||
{
|
{
|
||||||
@@ -788,7 +792,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
playerFrame = new GUIFrame(new Rectangle(0, 0, 0, 0), Color.Black * 0.3f);
|
playerFrame = new GUIFrame(new Rectangle(0, 0, 0, 0), Color.Black * 0.3f);
|
||||||
|
|
||||||
var playerFrameInner = new GUIFrame(new Rectangle(0, 0, 300, 150), null, Alignment.Center, GUI.Style, playerFrame);
|
var playerFrameInner = new GUIFrame(new Rectangle(0, 0, 300, 250), null, Alignment.Center, GUI.Style, playerFrame);
|
||||||
playerFrameInner.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f);
|
playerFrameInner.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f);
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0,0,200,20), component.UserData.ToString(),
|
new GUITextBlock(new Rectangle(0,0,200,20), component.UserData.ToString(),
|
||||||
@@ -849,7 +853,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (GameMain.Server != null || GameMain.Client.HasPermission(ClientPermissions.Kick))
|
if (GameMain.Server != null || GameMain.Client.HasPermission(ClientPermissions.Kick))
|
||||||
{
|
{
|
||||||
var kickButton = new GUIButton(new Rectangle(0, -30, 100, 20), "Kick", Alignment.BottomLeft, GUI.Style, playerFrameInner);
|
var kickButton = new GUIButton(new Rectangle(0, -50, 100, 20), "Kick", Alignment.BottomLeft, GUI.Style, playerFrameInner);
|
||||||
kickButton.UserData = obj;
|
kickButton.UserData = obj;
|
||||||
kickButton.OnClicked += KickPlayer;
|
kickButton.OnClicked += KickPlayer;
|
||||||
kickButton.OnClicked += ClosePlayerFrame;
|
kickButton.OnClicked += ClosePlayerFrame;
|
||||||
@@ -861,6 +865,11 @@ namespace Barotrauma
|
|||||||
banButton.UserData = obj;
|
banButton.UserData = obj;
|
||||||
banButton.OnClicked += BanPlayer;
|
banButton.OnClicked += BanPlayer;
|
||||||
banButton.OnClicked += ClosePlayerFrame;
|
banButton.OnClicked += ClosePlayerFrame;
|
||||||
|
|
||||||
|
var rangebanButton = new GUIButton(new Rectangle(0, -25, 100, 20), "Ban range", Alignment.BottomLeft, GUI.Style, playerFrameInner);
|
||||||
|
rangebanButton.UserData = obj;
|
||||||
|
rangebanButton.OnClicked += BanPlayerRange;
|
||||||
|
rangebanButton.OnClicked += ClosePlayerFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
var closeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Close", Alignment.BottomRight, GUI.Style, playerFrameInner);
|
var closeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Close", Alignment.BottomRight, GUI.Style, playerFrameInner);
|
||||||
@@ -903,8 +912,24 @@ namespace Barotrauma
|
|||||||
else if (GameMain.Client != null && GameMain.Client.HasPermission(ClientPermissions.Ban))
|
else if (GameMain.Client != null && GameMain.Client.HasPermission(ClientPermissions.Ban))
|
||||||
{
|
{
|
||||||
GameMain.Client.KickPlayer(userData.ToString(), true);
|
GameMain.Client.KickPlayer(userData.ToString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool BanPlayerRange(GUIButton button, object userData)
|
||||||
|
{
|
||||||
|
if (userData == null) return false;
|
||||||
|
|
||||||
|
if (GameMain.Server != null)
|
||||||
|
{
|
||||||
|
GameMain.Server.KickPlayer(userData.ToString(), true, true);
|
||||||
|
}
|
||||||
|
else if (GameMain.Client != null && GameMain.Client.HasPermission(ClientPermissions.Ban))
|
||||||
|
{
|
||||||
|
GameMain.Client.KickPlayer(userData.ToString(), true, true);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
---------------------------------------------------------------------------------------------------------
|
||||||
|
v0.5.1.2
|
||||||
|
---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
- hacked clients can't join a full server or change the name of their character anymore
|
||||||
|
- option to choose which character to control using the "control" command when there are multiple
|
||||||
|
characters/creatures with the same name
|
||||||
|
- a console command for spawning items
|
||||||
|
- the server logs show who sent each chat message
|
||||||
|
|
||||||
---------------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------------
|
||||||
v0.5.1.1
|
v0.5.1.1
|
||||||
---------------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user