Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.
Open

Zip #745

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

# Game settings files
GameServerApp/Settings/

# User-specific files
*.suo
*.user
Expand Down Expand Up @@ -308,7 +305,6 @@ __pycache__/
OpenCover/

# Custom stuff
GameServer/Settings/GameInfo.json
GameServerConsole/Settings/GameInfo.json
GameServerConsole/Settings/GameServerSettings.json
MigrationBackup/
12 changes: 0 additions & 12 deletions Content/GameMode/LeagueSandbox-Default/GameMode.json

This file was deleted.

2 changes: 1 addition & 1 deletion Content/LeagueSandbox-Default
19 changes: 9 additions & 10 deletions GameServerCore/Content/HashFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class HashFunctions
public static uint HashString(string path)
{
uint hash = 0;
var mask = 0xF0000000;
const uint mask = 0xF0000000;
for (var i = 0; i < path.Length; i++)
{
hash = char.ToLower(path[i]) + 0x10 * hash;
Expand All @@ -18,22 +18,21 @@ public static uint HashString(string path)
return hash;
}

public static uint HashStringSdbm(string section, string name)
public static uint HashStringSdbm(string data)
{
uint hash = 0;
foreach (var c in section)
{
hash = char.ToLower(c) + 65599 * hash;
}

hash = char.ToLower('*') + 65599 * hash;
foreach (var c in name)
foreach (var c in data)
{
hash = char.ToLower(c) + 65599 * hash;
hash = char.ToLowerInvariant(c) + 65599 * hash;
}

return hash;
}

public static uint HashStringSdbm(string section, string name)
{
return HashStringSdbm($"{section}*{name}");
}
}


Expand Down
2 changes: 1 addition & 1 deletion GameServerCore/Domain/GameObjects/IChampion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public interface IChampion : IObjAiBase
ISpell GetSpell(byte slot);
ISpell LevelUpSpell(byte slot);


}
}
2 changes: 1 addition & 1 deletion GameServerCore/Domain/IInventoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public interface IInventoryManager
IItem GetItem(byte slot);
void RemoveItem(byte slot);
byte GetItemSlot(IItem item);
IItem SetExtraItem(byte slot, IItemType item);
IItem SetExtraItem(byte slot, IItemData item);
void SwapItems(byte slot1, byte slot2);
}
}
2 changes: 1 addition & 1 deletion GameServerCore/Domain/IItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public interface IItem
{
byte StackSize { get; }
int TotalPrice { get; }
IItemType ItemType { get; }
IItemData ItemData { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
namespace GameServerCore.Domain
{
public interface IItemType
public interface IItemData
{
int ItemId { get; }
string Name { get; }
int MaxStack { get; }
int Price { get; }
string ItemGroup { get; }
float SellBackModifier { get; }
int RecipeItem1 { get; }
int RecipeItem2 { get; }
int RecipeItem3 { get; }
int RecipeItem4 { get; }
int[] RecipeItems { get; }
int TotalPrice { get; }

}
}
46 changes: 0 additions & 46 deletions GameServerCore/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,52 +95,6 @@ public static double RadianToDegree(double angle)
}
}

public class PairList<TKey, TValue> : List<Pair<TKey, TValue>>
{
public void Add(TKey key, TValue value)
{
Add(new Pair<TKey, TValue>(key, value));
}
public bool ContainsKey(TKey key)
{
foreach (var v in this)
{
if (v.Item1.Equals(key))
{
return true;
}
}

return false;
}

public TValue this[TKey key]
{
get
{
foreach (var v in this)
{
if (v.Item1.Equals(key))
{
return v.Item2;
}
}

return default(TValue);
}
set
{
foreach (var v in this)
{
if (v.Item1.Equals(key))
{
v.Item2 = value;
}
}
}
}
}

public static class CustomConvert
{
public static TeamId ToTeamId(this int i)
Expand Down
5 changes: 1 addition & 4 deletions GameServerCore/GameServerCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<Compile Include="Domain\IBuff.cs" />
<Compile Include="Domain\IInventoryManager.cs" />
<Compile Include="Domain\IItem.cs" />
<Compile Include="Domain\IItemType.cs" />
<Compile Include="Domain\IItemData.cs" />
<Compile Include="Domain\IReplicate.cs" />
<Compile Include="Domain\IReplication.cs" />
<Compile Include="Domain\IRuneCollection.cs" />
Expand Down Expand Up @@ -144,8 +144,5 @@
<Compile Include="Packets\PacketDefinitions\Requests\ViewRequest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
3 changes: 0 additions & 3 deletions GameServerCore/packages.config

This file was deleted.

2 changes: 1 addition & 1 deletion GameServerLib/Chatbox/Commands/ReloadScriptsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public ReloadScriptsCommand(ChatCommandManager chatCommandManager, Game game)

public override void Execute(int userId, bool hasReceivedArguments, string arguments = "")
{
if (Game.LoadScripts())
if (Game.LoadScripts(true))
{
ChatCommandManager.SendDebugMsgFormatted(DebugMsgType.INFO, "Scripts reloaded.");
}
Expand Down
19 changes: 11 additions & 8 deletions GameServerLib/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Numerics;
using System.Text;
using LeagueSandbox.GameServer.Content;
using Newtonsoft.Json.Linq;

Expand Down Expand Up @@ -69,22 +70,24 @@ private void LoadConfig(Game game, string json)
// Read where the content is
ContentPath = (string)gameInfo.SelectToken("CONTENT_PATH");

// Load items
game.ItemManager.AddItems(ItemContentCollection.LoadItemsFrom(
// todo: remove this hardcoded path with content pipeline refactor
$"{ContentPath}/LeagueSandbox-Default/Items"
));

// Read the game configuration
var gameToken = data.SelectToken("game");
GameConfig = new GameConfig(gameToken);

// Read spawns info
ContentManager = ContentManager.LoadGameMode(game, GameConfig.GameMode, ContentPath);
var mapPath = ContentManager.GetMapDataPath(GameConfig.Map);
var mapData = JObject.Parse(File.ReadAllText(mapPath));
var mapPath = ContentManager.GetMapConfigPath(GameConfig.Map);
JObject mapData;
using (var stream = new BinaryReader(ContentManager.Content[mapPath].ReadFile()))
{
mapData = JObject.Parse(Encoding.UTF8.GetString(stream.ReadBytes((int)stream.BaseStream.Length)));
}

var spawns = mapData.SelectToken("spawns");

// Load items
game.ItemManager.LoadItems(ContentManager);

MapSpawns = new MapSpawns();
foreach (JProperty teamSpawn in spawns)
{
Expand Down
19 changes: 13 additions & 6 deletions GameServerLib/Content/CharData.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.IO;
using GameServerCore.Enums;
using IniParser;
using LeagueSandbox.GameServer.Logging;
using log4net;
using LeagueSandbox.GameServer.Exceptions;
using Newtonsoft.Json;

namespace LeagueSandbox.GameServer.Content
Expand Down Expand Up @@ -43,7 +45,7 @@ public CharData(Game game)
public float HpRegenPerLevel { get; private set; }
public float MpRegenPerLevel { get; private set; }
public float AttackSpeedPerLevel { get; private set; }
public bool IsMelee { get; private set; } //Yes or no
public bool IsMelee { get; private set; } //Yes or No
public float PathfindingCollisionRadius { get; private set; } = -1.0f;
public float GameplayCollisionRadius { get; private set; } = 65.0f;
public PrimaryAbilityResourceType ParType { get; private set; } = PrimaryAbilityResourceType.MANA;
Expand Down Expand Up @@ -78,13 +80,17 @@ public void Load(string name)
return;
}

var file = new ContentFile();
ContentFile file;
try
{
var path = _game.Config.ContentManager.GetUnitStatPath(name);
_logger.Debug($"Loading {name}'s Stats from path: {Path.GetFullPath(path)}!");
var text = File.ReadAllText(Path.GetFullPath(path));
file = JsonConvert.DeserializeObject<ContentFile>(text);
var iniParser = new FileIniDataParser();
_logger.Debug($"Loading {name}'s Stats from path: {path}!");
using (var stream = new StreamReader(_game.Config.ContentManager.Content[path].ReadFile()))
{
var iniData = iniParser.ReadData(stream);
file = new ContentFile(ContentManager.ParseIniFile(iniData));
}
}
catch (ContentNotFoundException notfound)
{
Expand All @@ -110,10 +116,11 @@ public void Load(string name)
HpRegenPerLevel = file.GetFloat("Data", "HPRegenPerLevel", HpRegenPerLevel);
MpRegenPerLevel = file.GetFloat("Data", "MPRegenPerLevel", MpRegenPerLevel);
AttackSpeedPerLevel = file.GetFloat("Data", "AttackSpeedPerLevel", AttackSpeedPerLevel);
IsMelee = file.GetString("Data", "IsMelee", IsMelee ? "Yes" : "No").Equals("yes");
IsMelee = file.GetString("Data", "IsMelee", IsMelee ? "Yes" : "No").ToLowerInvariant().Equals("yes");
PathfindingCollisionRadius =
file.GetFloat("Data", "PathfindingCollisionRadius", PathfindingCollisionRadius);
GameplayCollisionRadius = file.GetFloat("Data", "GameplayCollisionRadius", GameplayCollisionRadius);

Enum.TryParse<PrimaryAbilityResourceType>(file.GetString("Data", "PARType", ParType.ToString()),
out var tempPar);
ParType = tempPar;
Expand Down
32 changes: 12 additions & 20 deletions GameServerLib/Content/ContentFile.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
using System.Collections.Generic;
using System.Globalization;
using GameServerCore.Content;
using LeagueSandbox.GameServer.Logging;

namespace LeagueSandbox.GameServer.Content
{
public class ContentFile
{
public Dictionary<string, Dictionary<string, string>> Values { get; set; }
= new Dictionary<string, Dictionary<string, string>>();

public Dictionary<string, object> MetaData { get; set; }
= new Dictionary<string, object>();

private uint Hash(string section, string name)
public ContentFile(Dictionary<string, Dictionary<string, string>> data)
{
uint hash = 0;
foreach (var c in section)
{
hash = char.ToLower(c) + 65599 * hash;
}
hash = char.ToLower('*') + 65599 * hash;
foreach (var c in name)
{
hash = char.ToLower(c) + 65599 * hash;
}
Values = data;
}

return hash;
public ContentFile() : this(new Dictionary<string, Dictionary<string, string>>())
{
}

public string GetObject(string section, string name)
Expand All @@ -41,7 +31,8 @@ public string GetObject(string section, string name)
var hash = HashFunctions.HashStringSdbm(section, name).ToString();
if (Values["UNKNOWN_HASHES"].ContainsKey(hash))
{
//TODO: Log that unkown hash was found!
LoggerProvider.GetLogger().Info($"UNKNOWN HASH {hash} WAS FOUND TO BE {section}*{name}!" +
"PLEASE SHOW THIS LOG TO A DEVELOPER.");
return Values["UNKNOWN_HASHES"][hash];
}
}
Expand Down Expand Up @@ -84,7 +75,7 @@ public float[] GetFloatArray(string section, string name, float[] defaultValue )
var list = obj.Split(' ');
if (defaultValue.Length == list.Length)
{
for (var i = 0; i<defaultValue.Length; i++)
for (var i = 0; i < defaultValue.Length; i++)
{
float.TryParse(list[i], NumberStyles.Any, CultureInfo.InvariantCulture, out defaultValue[i]);
}
Expand All @@ -104,9 +95,10 @@ public int[] GetIntArray(string section, string name, int[] defaultValue)
{
for (var i = 0; i < defaultValue.Length; i++)
{
float value;
if (float.TryParse(list[i], NumberStyles.Any, CultureInfo.InvariantCulture, out value))
if (float.TryParse(list[i], NumberStyles.Any, CultureInfo.InvariantCulture, out var value))
{
defaultValue[i] = (int)value;
}
}
}
}
Expand Down
Loading