mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-10 23:25:41 +12:00
Thread Safe more stuff.. hopefully
This is gonna break so much ..
This commit is contained in:
parent
80b1cdea19
commit
0cad1e0fac
24 changed files with 375 additions and 114 deletions
HorseIsleServer/HorseIsleServer
|
@ -42,9 +42,43 @@ namespace HISP.Game.Chat
|
|||
}
|
||||
public static string PrivateMessageSound;
|
||||
|
||||
public static List<Filter> FilteredWords = new List<Filter>();
|
||||
public static List<Correction> CorrectedWords = new List<Correction>();
|
||||
public static List<Reason> Reasons = new List<Reason>();
|
||||
private static List<Filter> filteredWords = new List<Filter>();
|
||||
private static List<Correction> correctedWords = new List<Correction>();
|
||||
private static List<Reason> reasons = new List<Reason>();
|
||||
|
||||
public static void AddFilter(Filter filter)
|
||||
{
|
||||
filteredWords.Add(filter);
|
||||
}
|
||||
public static void AddCorrection(Correction correction)
|
||||
{
|
||||
correctedWords.Add(correction);
|
||||
}
|
||||
public static void AddReason(Reason reason)
|
||||
{
|
||||
reasons.Add(reason);
|
||||
}
|
||||
public static Filter[] FilteredWords
|
||||
{
|
||||
get
|
||||
{
|
||||
return filteredWords.ToArray();
|
||||
}
|
||||
}
|
||||
public static Correction[] CorrectedWords
|
||||
{
|
||||
get
|
||||
{
|
||||
return correctedWords.ToArray();
|
||||
}
|
||||
}
|
||||
public static Reason[] Reasons
|
||||
{
|
||||
get
|
||||
{
|
||||
return reasons.ToArray();
|
||||
}
|
||||
}
|
||||
public static bool ProcessCommand(User user, string message)
|
||||
{
|
||||
if (message.Length < 1)
|
||||
|
|
|
@ -6,13 +6,31 @@ namespace HISP.Game.Chat
|
|||
{
|
||||
public SocialType(string type)
|
||||
{
|
||||
Socials = new List<Social>();
|
||||
socials = new List<Social>();
|
||||
Type = type;
|
||||
SocialTypes.Add(this);
|
||||
socialTypes.Add(this);
|
||||
}
|
||||
public static List<SocialType> SocialTypes = new List<SocialType>();
|
||||
private static List<SocialType> socialTypes = new List<SocialType>();
|
||||
public string Type;
|
||||
public List<Social> Socials;
|
||||
private List<Social> socials;
|
||||
public void AddSocial(Social social)
|
||||
{
|
||||
socials.Add(social);
|
||||
}
|
||||
public static SocialType[] SocialTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return socialTypes.ToArray();
|
||||
}
|
||||
}
|
||||
public Social[] Socials
|
||||
{
|
||||
get
|
||||
{
|
||||
return socials.ToArray();
|
||||
}
|
||||
}
|
||||
public class Social
|
||||
{
|
||||
public SocialType BaseSocialType;
|
||||
|
@ -47,13 +65,13 @@ namespace HISP.Game.Chat
|
|||
if(stype.Type == type)
|
||||
{
|
||||
social.BaseSocialType = stype;
|
||||
stype.Socials.Add(social);
|
||||
stype.AddSocial(social);
|
||||
return;
|
||||
}
|
||||
}
|
||||
SocialType sType = new SocialType(type);
|
||||
social.BaseSocialType = sType;
|
||||
sType.Socials.Add(social);
|
||||
sType.AddSocial(social);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,11 +13,22 @@ namespace HISP.Game.Events
|
|||
public ThrowTracker(User thrower)
|
||||
{
|
||||
Thrower = thrower;
|
||||
ThrownAt = new List<User>();
|
||||
|
||||
thrownAt = new List<User>();
|
||||
}
|
||||
|
||||
public void AddThrownAt(User user)
|
||||
{
|
||||
thrownAt.Add(user);
|
||||
}
|
||||
public User Thrower;
|
||||
public List<User> ThrownAt;
|
||||
private List<User> thrownAt;
|
||||
public User[] ThrownAt
|
||||
{
|
||||
get
|
||||
{
|
||||
return thrownAt.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Active = false;
|
||||
|
@ -139,7 +150,7 @@ namespace HISP.Game.Events
|
|||
thrower.LoggedinClient.SendPacket(youEarned);
|
||||
throwAt.LoggedinClient.SendPacket(otherEarned);
|
||||
|
||||
throwCounter.ThrownAt.Add(throwAt);
|
||||
throwCounter.AddThrownAt(throwAt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace HISP.Game.Events
|
|||
|
||||
while(true)
|
||||
{
|
||||
int hrsIdx = GameServer.RandomNumberGenerator.Next(0, HorseInfo.Breeds.Count);
|
||||
int hrsIdx = GameServer.RandomNumberGenerator.Next(0, HorseInfo.Breeds.Length);
|
||||
HorseInfo.Breed breed = HorseInfo.Breeds[hrsIdx];
|
||||
if (breed.SpawnInArea == "none")
|
||||
continue;
|
||||
|
|
|
@ -12,12 +12,13 @@ namespace HISP.Game.Events
|
|||
{
|
||||
public WaterBalloonGame()
|
||||
{
|
||||
ThrownWaterBalloonMemory = new List<ThrownCounter>();
|
||||
thrownWaterBalloonMemory = new List<ThrownCounter>();
|
||||
Active = false;
|
||||
}
|
||||
|
||||
|
||||
public List<ThrownCounter> ThrownWaterBalloonMemory;
|
||||
private List<ThrownCounter> thrownWaterBalloonMemory;
|
||||
public ThrownCounter[] ThrownWaterBalloonMemory;
|
||||
public bool Active;
|
||||
private Timer gameTimeout;
|
||||
private const int WATER_BALLOON_GAME_TIMEOUT = 5;
|
||||
|
@ -29,7 +30,7 @@ namespace HISP.Game.Events
|
|||
NumThrown = numThrown;
|
||||
baseGame = game;
|
||||
|
||||
game.ThrownWaterBalloonMemory.Add(this);
|
||||
game.thrownWaterBalloonMemory.Add(this);
|
||||
}
|
||||
private WaterBalloonGame baseGame;
|
||||
public User UserHit;
|
||||
|
@ -89,17 +90,16 @@ namespace HISP.Game.Events
|
|||
{
|
||||
gameTimeout.Dispose();
|
||||
gameTimeout = null;
|
||||
ThrownWaterBalloonMemory.Clear();
|
||||
thrownWaterBalloonMemory.Clear();
|
||||
Active = false;
|
||||
}
|
||||
private ThrownCounter[] getWinners()
|
||||
{
|
||||
int maxThrown = 0;
|
||||
ThrownCounter[] thrownWaterBalloonMemory = ThrownWaterBalloonMemory.ToArray();
|
||||
List<ThrownCounter> winningCounter = new List<ThrownCounter>();
|
||||
|
||||
// Find the highest throw count
|
||||
foreach(ThrownCounter throwMemory in thrownWaterBalloonMemory)
|
||||
foreach(ThrownCounter throwMemory in ThrownWaterBalloonMemory)
|
||||
{
|
||||
if(throwMemory.NumThrown >= maxThrown)
|
||||
{
|
||||
|
@ -121,16 +121,16 @@ namespace HISP.Game.Events
|
|||
|
||||
public void LeaveEvent(User userToLeave)
|
||||
{
|
||||
foreach (ThrownCounter thrownMemory in ThrownWaterBalloonMemory.ToArray())
|
||||
foreach (ThrownCounter thrownMemory in ThrownWaterBalloonMemory)
|
||||
{
|
||||
if (thrownMemory.UserHit.Id == userToLeave.Id)
|
||||
ThrownWaterBalloonMemory.Remove(thrownMemory);
|
||||
thrownWaterBalloonMemory.Remove(thrownMemory);
|
||||
}
|
||||
}
|
||||
|
||||
private ThrownCounter getThrownCounter(User userToGet)
|
||||
{
|
||||
foreach(ThrownCounter thrownMemory in ThrownWaterBalloonMemory.ToArray())
|
||||
foreach(ThrownCounter thrownMemory in ThrownWaterBalloonMemory)
|
||||
{
|
||||
if (thrownMemory.UserHit.Id == userToGet.Id)
|
||||
return thrownMemory;
|
||||
|
|
|
@ -573,8 +573,33 @@ namespace HISP.Game.Horse
|
|||
}
|
||||
|
||||
public static string[] HorseNames;
|
||||
public static List<Category> HorseCategories = new List<Category>();
|
||||
public static List<Breed> Breeds = new List<Breed>();
|
||||
private static List<Category> horseCategories = new List<Category>();
|
||||
private static List<Breed> breeds = new List<Breed>();
|
||||
|
||||
public static void AddBreed(Breed breed)
|
||||
{
|
||||
breeds.Add(breed);
|
||||
}
|
||||
|
||||
public static void AddHorseCategory(Category category)
|
||||
{
|
||||
horseCategories.Add(category);
|
||||
}
|
||||
public static Category[] HorseCategories
|
||||
{
|
||||
get
|
||||
{
|
||||
return horseCategories.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static Breed[] Breeds
|
||||
{
|
||||
get
|
||||
{
|
||||
return breeds.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static string GenerateHorseName()
|
||||
{
|
||||
|
|
|
@ -6,7 +6,19 @@ namespace HISP.Game.Horse
|
|||
{
|
||||
public class Leaser
|
||||
{
|
||||
public static List<Leaser> HorseLeasers = new List<Leaser>();
|
||||
private static List<Leaser> horseLeasers = new List<Leaser>();
|
||||
public static void AddHorseLeaser(Leaser leaser)
|
||||
{
|
||||
horseLeasers.Add(leaser);
|
||||
}
|
||||
|
||||
public static Leaser[] HorseLeasers
|
||||
{
|
||||
get
|
||||
{
|
||||
return horseLeasers.ToArray();
|
||||
}
|
||||
}
|
||||
public Leaser(int breedId, int saddle, int saddlePad, int bridle)
|
||||
{
|
||||
Breed = HorseInfo.GetBreedById(breedId);
|
||||
|
|
|
@ -195,7 +195,7 @@ namespace HISP.Game.Horse
|
|||
Logger.InfoPrint("Generating horses.");
|
||||
while(wildHorses.Count < 40)
|
||||
{
|
||||
HorseInfo.Breed horseBreed = HorseInfo.Breeds[GameServer.RandomNumberGenerator.Next(0, HorseInfo.Breeds.Count)];
|
||||
HorseInfo.Breed horseBreed = HorseInfo.Breeds[GameServer.RandomNumberGenerator.Next(0, HorseInfo.Breeds.Length)];
|
||||
if (horseBreed.Swf == "")
|
||||
continue;
|
||||
if (horseBreed.SpawnInArea == "none") // no unipegs >_>
|
||||
|
|
|
@ -59,8 +59,31 @@ namespace HISP.Game.Items
|
|||
public string HitYourselfMessage;
|
||||
}
|
||||
|
||||
public static List<ItemInformation> Items = new List<ItemInformation>();
|
||||
public static List<ThrowableItem> ThrowableItems = new List<ThrowableItem>();
|
||||
private static List<ItemInformation> items = new List<ItemInformation>();
|
||||
private static List<ThrowableItem> throwableItems = new List<ThrowableItem>();
|
||||
public static void AddItemInfo(ItemInformation itm)
|
||||
{
|
||||
items.Add(itm);
|
||||
}
|
||||
public static void AddThrowableItem(ThrowableItem throwableItem)
|
||||
{
|
||||
throwableItems.Add(throwableItem);
|
||||
}
|
||||
public static ItemInformation[] Items
|
||||
{
|
||||
get
|
||||
{
|
||||
return items.ToArray();
|
||||
}
|
||||
}
|
||||
public static ThrowableItem[] ThrowableItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return throwableItems.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int Present;
|
||||
public static int MailMessage;
|
||||
|
|
|
@ -601,14 +601,14 @@ namespace HISP.Game
|
|||
|
||||
|
||||
message += Messages.FormatTradeYourOffering(trade.OtherTrade.Trader.Username);
|
||||
if (trade.MoneyOffered == 0 && trade.ItemsOffered.Count == 0 && trade.HorsesOffered.Count == 0)
|
||||
if (trade.MoneyOffered == 0 && trade.ItemsOffered.Length == 0 && trade.HorsesOffered.Length == 0)
|
||||
message += Messages.TradeOfferingNothing;
|
||||
if (trade.MoneyOffered > 0)
|
||||
message += Messages.FormatTradeMoneyOffer(trade.MoneyOffered);
|
||||
if(trade.HorsesOffered.Count > 0)
|
||||
if(trade.HorsesOffered.Length > 0)
|
||||
foreach(HorseInstance horse in trade.HorsesOffered)
|
||||
message += Messages.FormatTradeHorseOffer(horse.Name, horse.RandomId);
|
||||
if(trade.ItemsOffered.Count > 0)
|
||||
if(trade.ItemsOffered.Length > 0)
|
||||
foreach(ItemInstance[] item in trade.ItemsOffered)
|
||||
{
|
||||
Item.ItemInformation itemInfo = item[0].GetItemInfo();
|
||||
|
@ -623,14 +623,14 @@ namespace HISP.Game
|
|||
message += Messages.TradeAddItems;
|
||||
|
||||
message += Messages.FormatTradeOtherOffering(trade.OtherTrade.Trader.Username);
|
||||
if (trade.OtherTrade.MoneyOffered == 0 && trade.OtherTrade.ItemsOffered.Count == 0 && trade.OtherTrade.HorsesOffered.Count == 0)
|
||||
if (trade.OtherTrade.MoneyOffered == 0 && trade.OtherTrade.ItemsOffered.Length == 0 && trade.OtherTrade.HorsesOffered.Length == 0)
|
||||
message += Messages.TradeOfferingNothing;
|
||||
if (trade.OtherTrade.MoneyOffered > 0)
|
||||
message += Messages.FormatTradeMoneyOffer(trade.OtherTrade.MoneyOffered);
|
||||
if (trade.OtherTrade.HorsesOffered.Count > 0)
|
||||
if (trade.OtherTrade.HorsesOffered.Length > 0)
|
||||
foreach (HorseInstance horse in trade.OtherTrade.HorsesOffered)
|
||||
message += Messages.FormatTradeHorseOffer(horse.Name, horse.RandomId);
|
||||
if (trade.OtherTrade.ItemsOffered.Count > 0)
|
||||
if (trade.OtherTrade.ItemsOffered.Length > 0)
|
||||
foreach (ItemInstance[] item in trade.OtherTrade.ItemsOffered)
|
||||
{
|
||||
Item.ItemInformation itemInfo = item[0].GetItemInfo();
|
||||
|
|
|
@ -227,8 +227,18 @@ namespace HISP.Game
|
|||
public NpcChat[] Chatpoints;
|
||||
}
|
||||
|
||||
public static List<NpcEntry> NpcList = new List<NpcEntry>();
|
||||
|
||||
private static List<NpcEntry> npcList = new List<NpcEntry>();
|
||||
public static void AddNpc(NpcEntry npc)
|
||||
{
|
||||
npcList.Add(npc);
|
||||
}
|
||||
public static NpcEntry[] NpcList
|
||||
{
|
||||
get
|
||||
{
|
||||
return npcList.ToArray();
|
||||
}
|
||||
}
|
||||
public static NpcReply GetNpcReply(NpcEntry npc, int id)
|
||||
{
|
||||
|
||||
|
|
|
@ -63,8 +63,18 @@ namespace HISP.Game
|
|||
public bool Minigame;
|
||||
}
|
||||
|
||||
public static List<QuestEntry> QuestList = new List<QuestEntry>();
|
||||
|
||||
private static List<QuestEntry> questList = new List<QuestEntry>();
|
||||
public static void AddQuestEntry(QuestEntry quest)
|
||||
{
|
||||
questList.Add(quest);
|
||||
}
|
||||
private static QuestEntry[] QuestList
|
||||
{
|
||||
get
|
||||
{
|
||||
return questList.ToArray();
|
||||
}
|
||||
}
|
||||
public static int GetTotalQuestPoints()
|
||||
{
|
||||
int totalQp = 0;
|
||||
|
|
|
@ -6,14 +6,20 @@ namespace HISP.Game.Services
|
|||
public class Groomer
|
||||
{
|
||||
|
||||
public static List<Groomer> Groomers = new List<Groomer>();
|
||||
|
||||
private static List<Groomer> groomers = new List<Groomer>();
|
||||
public static Groomer[] Groomers
|
||||
{
|
||||
get
|
||||
{
|
||||
return groomers.ToArray();
|
||||
}
|
||||
}
|
||||
public Groomer(int id, double price, int max)
|
||||
{
|
||||
Id = id;
|
||||
PriceMultiplier = price;
|
||||
Max = max;
|
||||
Groomers.Add(this);
|
||||
groomers.Add(this);
|
||||
}
|
||||
|
||||
public int Id;
|
||||
|
|
|
@ -14,7 +14,18 @@ namespace HISP.Game.Services
|
|||
BreedId = breedId;
|
||||
BasePrice = basePrice;
|
||||
}
|
||||
public static List<Pawneer> PawneerPriceModels = new List<Pawneer>();
|
||||
private static List<Pawneer> pawneerPriceModels = new List<Pawneer>();
|
||||
private static Pawneer[] PawneerPriceModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return pawneerPriceModels.ToArray();
|
||||
}
|
||||
}
|
||||
public static void AddPawneerPriceModel(Pawneer pawneerPrice)
|
||||
{
|
||||
pawneerPriceModels.Add(pawneerPrice);
|
||||
}
|
||||
public int BreedId;
|
||||
public int BasePrice;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace HISP.Game.Services
|
|||
{
|
||||
public Workshop()
|
||||
{
|
||||
CraftableItems = new List<CraftableItem>();
|
||||
craftableItems = new List<CraftableItem>();
|
||||
}
|
||||
public class RequiredItem
|
||||
{
|
||||
|
@ -21,19 +21,51 @@ namespace HISP.Game.Services
|
|||
{
|
||||
public CraftableItem()
|
||||
{
|
||||
RequiredItems = new List<RequiredItem>();
|
||||
requiredItems = new List<RequiredItem>();
|
||||
}
|
||||
public int Id;
|
||||
public int GiveItemId;
|
||||
public int MoneyCost;
|
||||
public List<RequiredItem> RequiredItems;
|
||||
private List<RequiredItem> requiredItems;
|
||||
|
||||
public void AddRequiredItem(RequiredItem item)
|
||||
{
|
||||
requiredItems.Add(item);
|
||||
}
|
||||
public RequiredItem[] RequiredItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return requiredItems.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
public int X;
|
||||
public int Y;
|
||||
public List<CraftableItem> CraftableItems;
|
||||
|
||||
public static List<Workshop> Workshops = new List<Workshop>();
|
||||
|
||||
private List<CraftableItem> craftableItems;
|
||||
private static List<Workshop> workshops = new List<Workshop>();
|
||||
public void AddCraftableItem(CraftableItem craftItem)
|
||||
{
|
||||
craftableItems.Add(craftItem);
|
||||
}
|
||||
public static void AddWorkshop(Workshop wkShop)
|
||||
{
|
||||
workshops.Add(wkShop);
|
||||
}
|
||||
public CraftableItem[] CraftableItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return craftableItems.ToArray();
|
||||
}
|
||||
}
|
||||
public static Workshop[] Workshops
|
||||
{
|
||||
get
|
||||
{
|
||||
return workshops.ToArray();
|
||||
}
|
||||
}
|
||||
public static Workshop GetWorkshopAt(int x, int y)
|
||||
{
|
||||
foreach(Workshop wkShop in Workshops)
|
||||
|
|
|
@ -79,8 +79,19 @@ namespace HISP.Game.SwfModules
|
|||
|
||||
}
|
||||
|
||||
public static List<PoetryEntry> PoetList = new List<PoetryEntry>();
|
||||
private static List<PoetryEntry> poetList = new List<PoetryEntry>();
|
||||
private static List<PoetryPeice[]> poetryRooms = new List<PoetryPeice[]>();
|
||||
public static void AddPoetEntry(PoetryEntry poetEntry)
|
||||
{
|
||||
poetList.Add(poetEntry);
|
||||
}
|
||||
public static PoetryEntry[] PoetList
|
||||
{
|
||||
get
|
||||
{
|
||||
return poetList.ToArray();
|
||||
}
|
||||
}
|
||||
public static PoetryPeice[][] PoetryRooms
|
||||
{
|
||||
get
|
||||
|
@ -93,7 +104,7 @@ namespace HISP.Game.SwfModules
|
|||
{
|
||||
List<PoetryEntry> entries = new List<PoetryEntry>();
|
||||
|
||||
foreach(PoetryEntry poet in PoetList.ToArray())
|
||||
foreach(PoetryEntry poet in PoetList)
|
||||
{
|
||||
if(poet.Room == roomId)
|
||||
{
|
||||
|
@ -153,10 +164,5 @@ namespace HISP.Game.SwfModules
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,32 +1,42 @@
|
|||
using HISP.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HISP.Game.SwfModules
|
||||
{
|
||||
public class Dressup
|
||||
{
|
||||
|
||||
public static List<DressupRoom> DressupRooms = new List<DressupRoom>();
|
||||
private static List<DressupRoom> dressupRooms = new List<DressupRoom>();
|
||||
public static DressupRoom[] DressupRooms
|
||||
{
|
||||
get
|
||||
{
|
||||
return dressupRooms.ToArray();
|
||||
}
|
||||
}
|
||||
public class DressupRoom
|
||||
{
|
||||
public int RoomId;
|
||||
private List<DressupPeice> dressupPeices;
|
||||
public DressupPeice[] DressupPeices
|
||||
{
|
||||
get
|
||||
{
|
||||
return dressupPeices.ToArray();
|
||||
}
|
||||
}
|
||||
public DressupRoom(int roomId)
|
||||
{
|
||||
RoomId = roomId;
|
||||
DressupPeices = new List<DressupPeice>();
|
||||
dressupPeices = new List<DressupPeice>();
|
||||
|
||||
DressupPeice[] peices = Database.LoadDressupRoom(this);
|
||||
foreach (DressupPeice peice in peices)
|
||||
DressupPeices.Add(peice);
|
||||
dressupPeices.Add(peice);
|
||||
|
||||
DressupRooms.Add(this);
|
||||
dressupRooms.Add(this);
|
||||
}
|
||||
public int RoomId;
|
||||
public List<DressupPeice> DressupPeices;
|
||||
|
||||
|
||||
public DressupPeice GetDressupPeice(int peiceId)
|
||||
{
|
||||
foreach(DressupPeice peice in DressupPeices)
|
||||
|
@ -36,7 +46,7 @@ namespace HISP.Game.SwfModules
|
|||
}
|
||||
// Else create peice
|
||||
DressupPeice dPeice = new DressupPeice(this, peiceId, 0, 0, false, true);
|
||||
DressupPeices.Add(dPeice);
|
||||
dressupPeices.Add(dPeice);
|
||||
return dPeice;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,10 +8,17 @@ namespace HISP.Game
|
|||
{
|
||||
public class TwoPlayer
|
||||
{
|
||||
public static List<TwoPlayer> TwoPlayerGames = new List<TwoPlayer>();
|
||||
private static List<TwoPlayer> twoPlayerGames = new List<TwoPlayer>();
|
||||
public static TwoPlayer[] TwoPlayerGames
|
||||
{
|
||||
get
|
||||
{
|
||||
return twoPlayerGames.ToArray();
|
||||
}
|
||||
}
|
||||
public static void TwoPlayerRemove(User user)
|
||||
{
|
||||
foreach(TwoPlayer twoPlayerGame in TwoPlayerGames.ToArray())
|
||||
foreach(TwoPlayer twoPlayerGame in TwoPlayerGames)
|
||||
{
|
||||
if((twoPlayerGame.Invitee.Id == user.Id))
|
||||
{
|
||||
|
@ -21,7 +28,7 @@ namespace HISP.Game
|
|||
}
|
||||
public static bool IsPlayerInvitingPlayer(User sender, User checkInvites)
|
||||
{
|
||||
foreach (TwoPlayer twoPlayerGame in TwoPlayerGames.ToArray())
|
||||
foreach (TwoPlayer twoPlayerGame in TwoPlayerGames)
|
||||
{
|
||||
if ((twoPlayerGame.Invitee.Id == sender.Id && twoPlayerGame.Inviting.Id == checkInvites.Id) && !twoPlayerGame.Accepted)
|
||||
{
|
||||
|
@ -32,7 +39,7 @@ namespace HISP.Game
|
|||
}
|
||||
public static TwoPlayer GetGameInvitingPlayer(User sender, User checkInvites)
|
||||
{
|
||||
foreach (TwoPlayer twoPlayerGame in TwoPlayerGames.ToArray())
|
||||
foreach (TwoPlayer twoPlayerGame in TwoPlayerGames)
|
||||
{
|
||||
if ((twoPlayerGame.Invitee.Id == sender.Id && twoPlayerGame.Inviting.Id == checkInvites.Id) && !twoPlayerGame.Accepted)
|
||||
{
|
||||
|
@ -44,7 +51,7 @@ namespace HISP.Game
|
|||
|
||||
public static bool IsPlayerInGame(User user)
|
||||
{
|
||||
foreach (TwoPlayer twoPlayerGame in TwoPlayerGames.ToArray())
|
||||
foreach (TwoPlayer twoPlayerGame in TwoPlayerGames)
|
||||
{
|
||||
if ((twoPlayerGame.Invitee.Id == user.Id || twoPlayerGame.Inviting.Id == user.Id) && twoPlayerGame.Accepted)
|
||||
{
|
||||
|
@ -56,7 +63,7 @@ namespace HISP.Game
|
|||
|
||||
public static TwoPlayer GetTwoPlayerGameInProgress(User user)
|
||||
{
|
||||
foreach (TwoPlayer twoPlayerGame in TwoPlayerGames.ToArray())
|
||||
foreach (TwoPlayer twoPlayerGame in TwoPlayerGames)
|
||||
{
|
||||
if ((twoPlayerGame.Invitee.Id == user.Id || twoPlayerGame.Inviting.Id == user.Id) && twoPlayerGame.Accepted)
|
||||
{
|
||||
|
@ -84,7 +91,7 @@ namespace HISP.Game
|
|||
|
||||
deleteTimer = new Timer(new TimerCallback(deleteTwoPlayer), null, 2 * 60 * 1000, 2 * 60 * 1000);
|
||||
|
||||
TwoPlayerGames.Add(this);
|
||||
twoPlayerGames.Add(this);
|
||||
|
||||
update();
|
||||
|
||||
|
@ -105,7 +112,7 @@ namespace HISP.Game
|
|||
|
||||
update();
|
||||
|
||||
TwoPlayerGames.Remove(this);
|
||||
twoPlayerGames.Remove(this);
|
||||
}
|
||||
deleteTimer.Dispose();
|
||||
}
|
||||
|
@ -219,7 +226,7 @@ namespace HISP.Game
|
|||
else
|
||||
updateOthers();
|
||||
|
||||
TwoPlayerGames.Remove(this);
|
||||
twoPlayerGames.Remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,25 +7,41 @@ namespace HISP.Player
|
|||
public class Friends
|
||||
{
|
||||
private User baseUser;
|
||||
public List<int> List;
|
||||
private List<int> list;
|
||||
public int[] List
|
||||
{
|
||||
get
|
||||
{
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return List.Count;
|
||||
return List.Length;
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveFromLocalList(int value)
|
||||
{
|
||||
list.Remove(value);
|
||||
}
|
||||
|
||||
public void AddToLocalList(int value)
|
||||
{
|
||||
list.Remove(value);
|
||||
}
|
||||
public Friends(User user)
|
||||
{
|
||||
baseUser = user;
|
||||
List = new List<int>();
|
||||
list = new List<int>();
|
||||
|
||||
int[] friends = Database.GetBuddyList(user.Id);
|
||||
foreach(int friendId in friends)
|
||||
{
|
||||
List.Add(friendId);
|
||||
list.Add(friendId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -47,13 +63,13 @@ namespace HISP.Player
|
|||
{
|
||||
|
||||
User removeFrom = GameServer.GetUserById(userid);
|
||||
removeFrom.Friends.List.Remove(baseUser.Id);
|
||||
removeFrom.Friends.RemoveFromLocalList(baseUser.Id);
|
||||
|
||||
}
|
||||
catch (KeyNotFoundException) { /* User is offline, remove from database is sufficent */ };
|
||||
|
||||
|
||||
baseUser.Friends.List.Remove(userid);
|
||||
baseUser.Friends.RemoveFromLocalList(userid);
|
||||
}
|
||||
public void AddFriend(User userToFriend)
|
||||
{
|
||||
|
@ -79,8 +95,8 @@ namespace HISP.Player
|
|||
if (userToFriend.PendingBuddyRequestTo == baseUser)
|
||||
{
|
||||
Database.AddBuddy(baseUser.Id, userToFriend.Id);
|
||||
List.Add(userToFriend.Id);
|
||||
userToFriend.Friends.List.Add(baseUser.Id);
|
||||
list.Add(userToFriend.Id);
|
||||
userToFriend.Friends.AddToLocalList(baseUser.Id);
|
||||
|
||||
byte[] nowFriendsMsg = PacketBuilder.CreateChat(Messages.FormatAddBuddyConfirmed(userToFriend.Username), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
byte[] nowFriendsOther = PacketBuilder.CreateChat(Messages.FormatAddBuddyConfirmed(baseUser.Username), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
|
|
|
@ -27,9 +27,39 @@ namespace HISP.Player
|
|||
public string Stage = "OPEN";
|
||||
|
||||
public int MoneyOffered = 0;
|
||||
public List<HorseInstance> HorsesOffered = new List<HorseInstance>();
|
||||
public List<ItemInstance[]> ItemsOffered = new List<ItemInstance[]>();
|
||||
private List<HorseInstance> horsesOffered = new List<HorseInstance>();
|
||||
private List<ItemInstance[]> itemsOffered = new List<ItemInstance[]>();
|
||||
public ItemInstance[][] ItemsOffered
|
||||
{
|
||||
get
|
||||
{
|
||||
return itemsOffered.ToArray();
|
||||
}
|
||||
}
|
||||
public HorseInstance[] HorsesOffered
|
||||
{
|
||||
get
|
||||
{
|
||||
return horsesOffered.ToArray();
|
||||
}
|
||||
}
|
||||
public void RemoveOfferedHorse(HorseInstance horse)
|
||||
{
|
||||
horsesOffered.Remove(horse);
|
||||
}
|
||||
public void OfferHorse(HorseInstance horse)
|
||||
{
|
||||
horsesOffered.Add(horse);
|
||||
}
|
||||
|
||||
public void OfferItems(ItemInstance[] items)
|
||||
{
|
||||
itemsOffered.Add(items);
|
||||
}
|
||||
public void RemoveOfferedItems(ItemInstance[] items)
|
||||
{
|
||||
itemsOffered.Remove(items);
|
||||
}
|
||||
private void endTrade()
|
||||
{
|
||||
Trader.PendingTradeTo = 0;
|
||||
|
@ -70,13 +100,13 @@ namespace HISP.Player
|
|||
Trader.LoggedinClient.SendPacket(tradeNotAllowedWhileBidding);
|
||||
fail = true;
|
||||
}
|
||||
if (OtherTrade.Trader.HorseInventory.HorseList.Length + HorsesOffered.Count > OtherTrade.Trader.MaxHorses)
|
||||
if (OtherTrade.Trader.HorseInventory.HorseList.Length + HorsesOffered.Length > OtherTrade.Trader.MaxHorses)
|
||||
{
|
||||
byte[] tradeYouHaveTooManyHorses = PacketBuilder.CreateChat(Messages.TradeYouCantHandleMoreHorses, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
Trader.LoggedinClient.SendPacket(tradeYouHaveTooManyHorses);
|
||||
fail = true;
|
||||
}
|
||||
if (Trader.HorseInventory.HorseList.Length + OtherTrade.HorsesOffered.Count > Trader.MaxHorses)
|
||||
if (Trader.HorseInventory.HorseList.Length + OtherTrade.HorsesOffered.Length > Trader.MaxHorses)
|
||||
{
|
||||
byte[] tradeYouHaveTooManyHorses = PacketBuilder.CreateChat(Messages.TradeYouCantHandleMoreHorses, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
Trader.LoggedinClient.SendPacket(tradeYouHaveTooManyHorses);
|
||||
|
|
|
@ -1 +1 @@
|
|||
98d0c4bb5e4c2b9300b97ac11b8ba65b05365645
|
||||
80b1cdea1957c5471347f46cf8bb541e2abf1ca1
|
||||
|
|
|
@ -4050,7 +4050,7 @@ namespace HISP.Server
|
|||
sqlCommand.Dispose();
|
||||
}
|
||||
}
|
||||
public static List<ItemInstance> GetShopInventory(int shopId)
|
||||
public static ItemInstance[] GetShopInventory(int shopId)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
|
@ -4068,7 +4068,7 @@ namespace HISP.Server
|
|||
instances.Add(new ItemInstance(reader.GetInt32(0), reader.GetInt32(1)));
|
||||
}
|
||||
sqlCommand.Dispose();
|
||||
return instances;
|
||||
return instances.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4105,7 +4105,7 @@ namespace HISP.Server
|
|||
}
|
||||
}
|
||||
|
||||
public static List<ItemInstance> GetPlayerInventory(int playerId)
|
||||
public static ItemInstance[] GetPlayerInventory(int playerId)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
|
@ -4123,7 +4123,7 @@ namespace HISP.Server
|
|||
instances.Add(new ItemInstance(reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2)));
|
||||
}
|
||||
sqlCommand.Dispose();
|
||||
return instances;
|
||||
return instances.ToArray();
|
||||
}
|
||||
}
|
||||
public static int[] GetModsAndAdmins()
|
||||
|
|
|
@ -136,7 +136,7 @@ namespace HISP.Server
|
|||
Chat.Reason reason = new Chat.Reason();
|
||||
reason.Name = gameData.messages.chat.reason_messages[i].name;
|
||||
reason.Message = gameData.messages.chat.reason_messages[i].message;
|
||||
Chat.Reasons.Add(reason);
|
||||
Chat.AddReason(reason);
|
||||
|
||||
Logger.DebugPrint("Registered Chat Warning Reason: " + reason.Name + " (Message: " + reason.Message + ")");
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ namespace HISP.Server
|
|||
filter.FilteredWord = gameData.messages.chat.filter[i].word;
|
||||
filter.MatchAll = gameData.messages.chat.filter[i].match_all;
|
||||
filter.Reason = Chat.GetReason((string)gameData.messages.chat.filter[i].reason_type);
|
||||
Chat.FilteredWords.Add(filter);
|
||||
Chat.AddFilter(filter);
|
||||
|
||||
Logger.DebugPrint("Registered Filtered Word: " + filter.FilteredWord + " With reason: " + filter.Reason.Name + " (Matching all: " + filter.MatchAll + ")");
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ namespace HISP.Server
|
|||
Chat.Correction correction = new Chat.Correction();
|
||||
correction.FilteredWord = gameData.messages.chat.correct[i].word;
|
||||
correction.ReplacedWord = gameData.messages.chat.correct[i].new_word;
|
||||
Chat.CorrectedWords.Add(correction);
|
||||
Chat.AddCorrection(correction);
|
||||
|
||||
Logger.DebugPrint("Registered Word Correction: " + correction.FilteredWord + " to " + correction.ReplacedWord);
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ namespace HISP.Server
|
|||
item.SpawnParamaters.SpawnNearSpecialTile = gameData.item.item_list[i].spawn_parameters.spawn_near_special_tile;
|
||||
|
||||
Logger.DebugPrint("Registered Item ID: " + item.Id + " Name: " + item.Name + " spawns on: " + item.SpawnParamaters.SpawnOnTileType);
|
||||
Item.Items.Add(item);
|
||||
Item.AddItemInfo(item);
|
||||
}
|
||||
// Register Throwables
|
||||
int totalThrowable = gameData.item.throwable.Count;
|
||||
|
@ -241,7 +241,7 @@ namespace HISP.Server
|
|||
throwableItem.HitMessage = gameData.item.throwable[i].message_hit;
|
||||
throwableItem.ThrowMessage = gameData.item.throwable[i].message_throw;
|
||||
throwableItem.HitYourselfMessage = gameData.item.throwable[i].message_hit_yourself;
|
||||
Item.ThrowableItems.Add(throwableItem);
|
||||
Item.AddThrowableItem(throwableItem);
|
||||
}
|
||||
|
||||
// Register NPCs
|
||||
|
@ -317,7 +317,7 @@ namespace HISP.Server
|
|||
chats.Add(npcChat);
|
||||
}
|
||||
npcEntry.Chatpoints = chats.ToArray();
|
||||
Npc.NpcList.Add(npcEntry);
|
||||
Npc.AddNpc(npcEntry);
|
||||
}
|
||||
|
||||
// Register Quests
|
||||
|
@ -392,7 +392,7 @@ namespace HISP.Server
|
|||
quest.ChainedQuestId = gameData.quest_list[i].chained_questid;
|
||||
quest.Minigame = gameData.quest_list[i].minigame;
|
||||
Logger.DebugPrint("Registered Quest: " + quest.Id + " - " + quest.Title);
|
||||
Quest.QuestList.Add(quest);
|
||||
Quest.AddQuestEntry(quest);
|
||||
}
|
||||
|
||||
int totalShops = gameData.shop_list.Count;
|
||||
|
@ -479,7 +479,7 @@ namespace HISP.Server
|
|||
entry.Id = gameData.poetry[i].id;
|
||||
entry.Word = gameData.poetry[i].word;
|
||||
entry.Room = gameData.poetry[i].room_id;
|
||||
Brickpoet.PoetList.Add(entry);
|
||||
Brickpoet.AddPoetEntry(entry);
|
||||
|
||||
Logger.DebugPrint("Registered poet: " + entry.Id.ToString() + " word: " + entry.Word + " in room " + entry.Room.ToString());
|
||||
}
|
||||
|
@ -512,7 +512,7 @@ namespace HISP.Server
|
|||
horseBreed.Swf = gameData.horses.breeds[i].swf;
|
||||
horseBreed.Type = gameData.horses.breeds[i].type;
|
||||
|
||||
HorseInfo.Breeds.Add(horseBreed);
|
||||
HorseInfo.AddBreed(horseBreed);
|
||||
Logger.DebugPrint("Registered Horse Breed: #" + horseBreed.Id + ": " + horseBreed.Name);
|
||||
}
|
||||
// Register Breed Prices @ Pawneer Order
|
||||
|
@ -522,7 +522,7 @@ namespace HISP.Server
|
|||
int id = gameData.horses.pawneer_base_price[i].breed_id;
|
||||
int price = gameData.horses.pawneer_base_price[i].price;
|
||||
Pawneer pawneerPricing = new Pawneer(id, price);
|
||||
Pawneer.PawneerPriceModels.Add(pawneerPricing);
|
||||
Pawneer.AddPawneerPriceModel(pawneerPricing);
|
||||
Logger.DebugPrint("Registered Pawneer Base Price " + pawneerPricing.BreedId + " for $" + pawneerPricing.BasePrice.ToString("N0", CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
|
@ -533,7 +533,7 @@ namespace HISP.Server
|
|||
category.Name = gameData.horses.categorys[i].name;
|
||||
category.MetaOthers = gameData.horses.categorys[i].message_others;
|
||||
category.Meta = gameData.horses.categorys[i].message;
|
||||
HorseInfo.HorseCategories.Add(category);
|
||||
HorseInfo.AddHorseCategory(category);
|
||||
Logger.DebugPrint("Registered horse category type: " + category.Name);
|
||||
}
|
||||
int totalTrackedItems = gameData.messages.meta.misc_stats.tracked_items.Count;
|
||||
|
@ -626,12 +626,12 @@ namespace HISP.Server
|
|||
Workshop.RequiredItem requiredItem = new Workshop.RequiredItem();
|
||||
requiredItem.RequiredItemId = gameData.workshop[i].craftable_items[ii].required_items[iii].req_item;
|
||||
requiredItem.RequiredItemCount = gameData.workshop[i].craftable_items[ii].required_items[iii].req_quantity;
|
||||
craftableItem.RequiredItems.Add(requiredItem);
|
||||
craftableItem.AddRequiredItem(requiredItem);
|
||||
}
|
||||
wkShop.CraftableItems.Add(craftableItem);
|
||||
wkShop.AddCraftableItem(craftableItem);
|
||||
}
|
||||
|
||||
Workshop.Workshops.Add(wkShop);
|
||||
Workshop.AddWorkshop(wkShop);
|
||||
Logger.DebugPrint("Registered Workshop at X: " + wkShop.X + " Y: " + wkShop.Y);
|
||||
|
||||
}
|
||||
|
@ -793,7 +793,7 @@ namespace HISP.Server
|
|||
leaser.Inteligence = gameData.leaser[i].horse.advanced_stats.inteligence;
|
||||
leaser.Personality = gameData.leaser[i].horse.advanced_stats.personality;
|
||||
|
||||
Leaser.HorseLeasers.Add(leaser);
|
||||
Leaser.AddHorseLeaser(leaser);
|
||||
Logger.DebugPrint("Registered Leaser: " + leaser.LeaseId.ToString() + " For a " + leaser.HorseName);
|
||||
}
|
||||
|
||||
|
|
|
@ -484,7 +484,7 @@ namespace HISP.Server
|
|||
|
||||
HorseInstance horse = sender.LoggedinUser.HorseInventory.GetHorseById(horseRandomId);
|
||||
if(!sender.LoggedinUser.TradingWith.HorsesOffered.Contains(horse))
|
||||
sender.LoggedinUser.TradingWith.HorsesOffered.Add(horse);
|
||||
sender.LoggedinUser.TradingWith.OfferHorse(horse);
|
||||
|
||||
UpdateArea(sender);
|
||||
|
||||
|
@ -2380,7 +2380,7 @@ namespace HISP.Server
|
|||
{
|
||||
if(existingItems[0].ItemId == sender.LoggedinUser.AttemptingToOfferItem)
|
||||
{
|
||||
sender.LoggedinUser.TradingWith.ItemsOffered.Remove(existingItems);
|
||||
sender.LoggedinUser.TradingWith.RemoveOfferedItems(existingItems);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2392,7 +2392,7 @@ namespace HISP.Server
|
|||
{
|
||||
items[i] = item.ItemInstances[i];
|
||||
}
|
||||
sender.LoggedinUser.TradingWith.ItemsOffered.Add(items);
|
||||
sender.LoggedinUser.TradingWith.OfferItems(items);
|
||||
|
||||
UpdateArea(sender);
|
||||
if (sender.LoggedinUser.TradingWith != null)
|
||||
|
@ -4086,7 +4086,7 @@ namespace HISP.Server
|
|||
int roomId = packet[3] - 40;
|
||||
Dressup.DressupRoom room = Dressup.GetDressupRoom(roomId);
|
||||
|
||||
if (room.DressupPeices.Count > 0)
|
||||
if (room.DressupPeices.Length > 0)
|
||||
{
|
||||
byte[] allDressupsResponse = PacketBuilder.CreateDressupRoomPeiceResponse(room.DressupPeices.ToArray());
|
||||
sender.SendPacket(allDressupsResponse);
|
||||
|
|
Loading…
Add table
Reference in a new issue