fix: фикс краша серверов через настольные игры (#389)

This commit is contained in:
Remuchi
2024-06-28 16:19:47 +07:00
committed by GitHub
parent c28f5648d0
commit ca62beb91f
4 changed files with 29 additions and 0 deletions

View File

@@ -37,5 +37,19 @@ namespace Content.Server.Tabletop.Components
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
public TabletopSession? Session { get; set; } = null; public TabletopSession? Session { get; set; } = null;
// Skyedra Fix start
/// <summary>
/// How many holograms have been spawned onto this board.
/// </summary>
[ViewVariables]
public int HologramsSpawned { get; set; } = 0;
/// <summary>
/// How many holograms are allowed to be spawned total by players.
/// </summary>
[ViewVariables]
public int MaximumHologramsAllowed { get; set; } = 10;
// Skyedra Fix end
} }
} }

View File

@@ -68,6 +68,9 @@ namespace Content.Server.Tabletop
// Find the entity, remove it from the session and set it's position to the tabletop // Find the entity, remove it from the session and set it's position to the tabletop
session.Entities.TryGetValue(entity, out var result); session.Entities.TryGetValue(entity, out var result);
session.Entities.Remove(result); session.Entities.Remove(result);
tabletop.HologramsSpawned--; // White Dream fix
QueueDel(result); QueueDel(result);
} }
@@ -90,6 +93,16 @@ namespace Content.Server.Tabletop
if (!TryComp<ItemComponent>(handEnt, out var item)) if (!TryComp<ItemComponent>(handEnt, out var item))
return; return;
// Skye hotfix to prevent people from infinitely spawning mice on the board games and crashing server.
if (component.HologramsSpawned >= component.MaximumHologramsAllowed)
{
_popupSystem.PopupEntity(Loc.GetString("tabletop-max-entities"), uid, args.User);
return;
}
component.HologramsSpawned++;
// Skye hotfix end
var meta = MetaData(handEnt); var meta = MetaData(handEnt);
var protoId = meta.EntityPrototype?.ID; var protoId = meta.EntityPrototype?.ID;

View File

@@ -4,6 +4,7 @@ tabletop-verb-dump-pieces = Dump Pieces
tabletop-default-board-name = Board Game tabletop-default-board-name = Board Game
tabletop-error-remove-non-hologram = You cant remove a built in piece! tabletop-error-remove-non-hologram = You cant remove a built in piece!
tabletop-added-piece = The board shimmers brightly! tabletop-added-piece = The board shimmers brightly!
tabletop-max-entities = Maximum number of holograms placed.
## Chess ## Chess
tabletop-chess-board-name = Chess tabletop-chess-board-name = Chess

View File

@@ -5,6 +5,7 @@ tabletop-verb-dump-pieces = Сбросить куски
tabletop-default-board-name = Настольная игра tabletop-default-board-name = Настольная игра
tabletop-error-remove-non-hologram = Вы не можете удалить встроенный элемент! tabletop-error-remove-non-hologram = Вы не можете удалить встроенный элемент!
tabletop-added-piece = Доска ярко переливается! tabletop-added-piece = Доска ярко переливается!
tabletop-max-entities = Максимальное количество голограмм уже поставлено.
## Chess ## Chess