mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-20 19:59:15 +12:00
Add BBCODE to Horse Descriptions, Player Descriptions and Ranch Descriptions.
This commit is contained in:
parent
bdebe4d84a
commit
72bc81d900
14 changed files with 142 additions and 40 deletions
|
@ -348,7 +348,7 @@ namespace HISP.Game.Chat
|
|||
foreach(Correction correct in CorrectedWords)
|
||||
message = message.Replace(correct.FilteredWord, correct.ReplacedWord);
|
||||
|
||||
return message;
|
||||
return message.Trim();
|
||||
}
|
||||
public static string EscapeMessage(string message)
|
||||
{
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace HISP.Game.Horse
|
|||
}
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
name = value.Trim();
|
||||
Database.SetHorseName(this.RandomId, name);
|
||||
}
|
||||
}
|
||||
|
@ -110,8 +110,8 @@ namespace HISP.Game.Horse
|
|||
}
|
||||
set
|
||||
{
|
||||
description = value;
|
||||
Database.SetHorseDescription(this.RandomId, value);
|
||||
description = value.Trim();
|
||||
Database.SetHorseDescription(this.RandomId, description);
|
||||
}
|
||||
}
|
||||
public string Sex;
|
||||
|
|
|
@ -61,11 +61,6 @@ namespace HISP.Game.Items
|
|||
foreach (DroppedItem droppedItem in items)
|
||||
droppedItemsList.Add(droppedItem);
|
||||
}
|
||||
public static void Update()
|
||||
{
|
||||
DespawnItems();
|
||||
GenerateItems(false);
|
||||
}
|
||||
public static void RemoveDroppedItem(DroppedItem item)
|
||||
{
|
||||
int randomId = item.Instance.RandomId;
|
||||
|
@ -110,12 +105,12 @@ namespace HISP.Game.Items
|
|||
{
|
||||
Database.DecrementDroppedItemDespawnTimer();
|
||||
|
||||
for(int i = 0; i < droppedItemsList.Count; i++)
|
||||
for (int i = 0; i < droppedItemsList.Count; i++)
|
||||
{
|
||||
if (droppedItemsList[i] == null) // Item removed in another thread.
|
||||
continue;
|
||||
|
||||
droppedItemsList[i].DespawnTimer--;
|
||||
droppedItemsList[i].DespawnTimer-=5;
|
||||
if(droppedItemsList[i].DespawnTimer <= 0)
|
||||
{
|
||||
if (GameServer.GetUsersAt(droppedItemsList[i].X, droppedItemsList[i].Y, true, true).Length > 0) // Dont despawn items players are standing on
|
||||
|
|
|
@ -32,7 +32,9 @@ namespace HISP.Game
|
|||
{
|
||||
int pos = ((x * Height) + y);
|
||||
|
||||
if (pos >= oMapData.Length && overlay)
|
||||
if ((pos <= 0 || pos >= oMapData.Length) && overlay)
|
||||
return 1;
|
||||
else if ((pos <= 0 || pos >= MapData.Length) && !overlay)
|
||||
return 1;
|
||||
else if (overlay && Treasure.IsTileBuiredTreasure(x, y))
|
||||
return 193; // Burried Treasure tile.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using HISP.Server;
|
||||
using HISP.Security;
|
||||
using HISP.Server;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
|
@ -70,7 +71,8 @@ namespace HISP.Game
|
|||
|
||||
public static string RanchTrainAllAttempt;
|
||||
public static string RanchTrainSuccessFormat;
|
||||
public static string RanchTrainCantTrain;
|
||||
public static string RanchTrainBadMoodFormat;
|
||||
public static string RanchTrainCantTrainFormat;
|
||||
public static string RanchHorsesFullyRested;
|
||||
public static string RanchWagonDroppedYouOff;
|
||||
|
||||
|
@ -756,7 +758,11 @@ namespace HISP.Game
|
|||
|
||||
public static string FormatRanchTrainFail(string horseName, int timeout)
|
||||
{
|
||||
return RanchTrainCantTrain.Replace("%HORSENAME%", horseName).Replace("%TIME%", timeout.ToString());
|
||||
return RanchTrainCantTrainFormat.Replace("%HORSENAME%", horseName).Replace("%TIME%", timeout.ToString());
|
||||
}
|
||||
public static string FormatRanchTrainBadMood(string horseName)
|
||||
{
|
||||
return RanchTrainBadMoodFormat.Replace("%HORSENAME%", horseName);
|
||||
}
|
||||
public static string FormatRanchTrain(string horseName, int speed, int strength, int conformation, int agility, int endurance, int exp)
|
||||
{
|
||||
|
@ -764,7 +770,7 @@ namespace HISP.Game
|
|||
}
|
||||
public static string FormatRanchDescOthers(string description)
|
||||
{
|
||||
return RanchDescriptionOthersFormat.Replace("%DESCRIPTION%", description);
|
||||
return RanchDescriptionOthersFormat.Replace("%DESCRIPTION%", BBCode.EncodeBBCodeToMeta(description));
|
||||
}
|
||||
public static string FormatRanchSoldMessage(int price)
|
||||
{
|
||||
|
@ -792,7 +798,7 @@ namespace HISP.Game
|
|||
}
|
||||
public static string FormatRanchYoursDescription(string description)
|
||||
{
|
||||
return RanchYourDescriptionFormat.Replace("%DESCRIPTION%", description);
|
||||
return RanchYourDescriptionFormat.Replace("%DESCRIPTION%", BBCode.EncodeBBCodeToMeta(description));
|
||||
}
|
||||
public static string FormatBuildingEntry(string name, int price, int buildingId)
|
||||
{
|
||||
|
@ -848,7 +854,7 @@ namespace HISP.Game
|
|||
}
|
||||
public static string FormatCantTrain(string horseName)
|
||||
{
|
||||
return RanchTrainCantTrain.Replace("%HORSENAME%", horseName);
|
||||
return RanchTrainCantTrainFormat.Replace("%HORSENAME%", horseName);
|
||||
}
|
||||
public static string FormatRiddlerRiddle(string riddle)
|
||||
{
|
||||
|
@ -1160,7 +1166,7 @@ namespace HISP.Game
|
|||
}
|
||||
public static string FormatHorseDescription(string Description)
|
||||
{
|
||||
return HorseDescriptionFormat.Replace("%DESCRIPTION%", Description);
|
||||
return HorseDescriptionFormat.Replace("%DESCRIPTION%", BBCode.EncodeBBCodeToMeta(Description));
|
||||
}
|
||||
public static string FormatHorseHandsHigh(string color, string breed,string sex, double handsHigh)
|
||||
{
|
||||
|
@ -1515,7 +1521,7 @@ namespace HISP.Game
|
|||
}
|
||||
public static string FormatPlayerDescriptionForStatsMenu(string description)
|
||||
{
|
||||
return StatsDescriptionFormat.Replace("%PLAYERDESC%", description);
|
||||
return StatsDescriptionFormat.Replace("%PLAYERDESC%", BBCode.EncodeBBCodeToMeta(description));
|
||||
}
|
||||
|
||||
public static string FormatExperience(int expPoints)
|
||||
|
|
|
@ -646,6 +646,10 @@ namespace HISP.Game
|
|||
message += Messages.RanchTrainAllAttempt;
|
||||
foreach(HorseInstance horse in user.HorseInventory.HorseList)
|
||||
{
|
||||
if(horse.BasicStats.Mood < 200)
|
||||
{
|
||||
message += Messages.FormatRanchTrainBadMood(horse.Name);
|
||||
}
|
||||
if(horse.TrainTimer == 0)
|
||||
{
|
||||
horse.AdvancedStats.Speed += 1;
|
||||
|
|
|
@ -192,8 +192,8 @@ namespace HISP.Game
|
|||
}
|
||||
set
|
||||
{
|
||||
title = value;
|
||||
Database.SetRanchTitle(Id, value);
|
||||
title = value.Trim();
|
||||
Database.SetRanchTitle(Id, title);
|
||||
}
|
||||
}
|
||||
public string Description
|
||||
|
@ -204,7 +204,7 @@ namespace HISP.Game
|
|||
}
|
||||
set
|
||||
{
|
||||
description = value;
|
||||
description = value.Trim();
|
||||
Database.SetRanchDescription(Id, value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -217,8 +217,9 @@ namespace HISP.Player
|
|||
set
|
||||
{
|
||||
|
||||
Database.SetPlayerNotes(Id, value);
|
||||
privateNotes = value;
|
||||
privateNotes = value.Trim();
|
||||
Database.SetPlayerNotes(Id, privateNotes);
|
||||
|
||||
}
|
||||
}
|
||||
public string ProfilePage {
|
||||
|
@ -227,10 +228,9 @@ namespace HISP.Player
|
|||
return profilePage;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
Database.SetPlayerProfile(value, Id);
|
||||
profilePage = value;
|
||||
{
|
||||
profilePage = value.TrimEnd();
|
||||
Database.SetPlayerProfile(profilePage, Id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
35
Horse Isle Server/HorseIsleServer/Security/BBCode.cs
Normal file
35
Horse Isle Server/HorseIsleServer/Security/BBCode.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Security
|
||||
{
|
||||
public class BBCode
|
||||
{
|
||||
public BBCode(string tag, string meta)
|
||||
{
|
||||
this.Tag = tag;
|
||||
this.MetaTranslation = meta;
|
||||
bbcodeTranslations.Add(this);
|
||||
}
|
||||
private static List<BBCode> bbcodeTranslations = new List<BBCode>();
|
||||
public string Tag;
|
||||
public string MetaTranslation;
|
||||
|
||||
public static string EncodeMetaToBBCode(string message)
|
||||
{
|
||||
foreach (BBCode code in bbcodeTranslations)
|
||||
{
|
||||
message = message.Replace(code.MetaTranslation, code.Tag);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
public static string EncodeBBCodeToMeta(string message)
|
||||
{
|
||||
foreach(BBCode code in bbcodeTranslations)
|
||||
{
|
||||
message = message.Replace(code.Tag, code.MetaTranslation);
|
||||
message = message.Replace(code.Tag.ToUpper(), code.MetaTranslation);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,11 +9,6 @@ namespace HISP.Server
|
|||
private static int getHexVal(char hex)
|
||||
{
|
||||
int val = (int)hex;
|
||||
//For uppercase A-F letters:
|
||||
//return val - (val < 58 ? 48 : 55);
|
||||
//For lowercase a-f letters:
|
||||
//return val - (val < 58 ? 48 : 87);
|
||||
//Or the two combined, but a bit slower:
|
||||
return val - (val < 58 ? 48 : (val < 97 ? 55 : 87));
|
||||
}
|
||||
public static byte[] StringToByteArray(string hex)
|
||||
|
@ -31,6 +26,8 @@ namespace HISP.Server
|
|||
return arr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Double PointsToDistance(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2));
|
||||
|
|
|
@ -3753,7 +3753,7 @@ namespace HISP.Server
|
|||
|
||||
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "UPDATE DroppedItems SET DespawnTimer=DespawnTimer-1";
|
||||
sqlCommand.CommandText = "UPDATE DroppedItems SET DespawnTimer=DespawnTimer-5";
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ using HISP.Game.SwfModules;
|
|||
using HISP.Game.Horse;
|
||||
using HISP.Game.Items;
|
||||
using System.Globalization;
|
||||
using HISP.Security;
|
||||
|
||||
namespace HISP.Server
|
||||
{
|
||||
|
@ -687,6 +688,16 @@ namespace HISP.Server
|
|||
|
||||
}
|
||||
|
||||
// Register BBCODE
|
||||
int totalBBocdes = gameData.bbcode.Count;
|
||||
for(int i = 0; i < totalBBocdes; i++)
|
||||
{
|
||||
string tag = gameData.bbcode[i].tag;
|
||||
string meta = gameData.bbcode[i].meta;
|
||||
BBCode code = new BBCode(tag, meta);
|
||||
Logger.DebugPrint("Registered BBCODE: " + code.Tag + " to " + code.MetaTranslation);
|
||||
}
|
||||
|
||||
HorseInfo.HorseNames = gameData.horses.names.ToObject<string[]>();
|
||||
|
||||
Item.Present = gameData.item.special.present;
|
||||
|
@ -769,7 +780,8 @@ namespace HISP.Server
|
|||
|
||||
Messages.RanchTrainAllAttempt = gameData.messages.meta.ranch.special.train_all;
|
||||
Messages.RanchTrainSuccessFormat = gameData.messages.meta.ranch.special.train_success;
|
||||
Messages.RanchTrainCantTrain = gameData.messages.meta.ranch.special.train_cant_train;
|
||||
Messages.RanchTrainCantTrainFormat = gameData.messages.meta.ranch.special.train_cant_train;
|
||||
Messages.RanchTrainBadMoodFormat = gameData.messages.meta.ranch.special.train_bad_mood;
|
||||
Messages.RanchHorsesFullyRested = gameData.messages.meta.ranch.special.fully_rested;
|
||||
Messages.RanchWagonDroppedYouOff = gameData.messages.meta.ranch.special.wagon_used;
|
||||
|
||||
|
|
|
@ -89,7 +89,14 @@ namespace HISP.Server
|
|||
|
||||
Treasure.AddValue();
|
||||
Database.IncPlayerTirednessForOfflineUsers();
|
||||
DroppedItems.Update();
|
||||
|
||||
|
||||
if (totalMinutesElapsed % 5 == 0)
|
||||
{
|
||||
DroppedItems.DespawnItems();
|
||||
DroppedItems.GenerateItems(false);
|
||||
}
|
||||
|
||||
WildHorse.Update();
|
||||
Npc.WanderNpcs();
|
||||
minuteTimer.Change(oneMinute, oneMinute);
|
||||
|
@ -2581,8 +2588,6 @@ namespace HISP.Server
|
|||
|
||||
string profilePage = packetStr.Split('|')[1];
|
||||
profilePage = profilePage.Substring(0, profilePage.Length - 2);
|
||||
profilePage = profilePage.Replace("[", "<");
|
||||
profilePage = profilePage.Replace("]", ">");
|
||||
sender.LoggedinUser.CharacterId = characterId;
|
||||
sender.LoggedinUser.ProfilePage = profilePage;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue