Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
раздавите меня камазом
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh1ntra committed Jul 3, 2024
1 parent 54c68c0 commit ca65ef3
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ private void SendEntityWhisper(
_chatManager.ChatMessageToOne(ChatChannel.Whisper, understand ? msg.OriginalMessage : msg.Message, understand ? wrappedMessage : wrappedLanguageMessage, source, false, session.Channel);
//If listener is too far, they only hear fragments of the message
else if (_examineSystem.InRangeUnOccluded(source, listener, WhisperMuffledRange))
_chatManager.ChatMessageToOne(ChatChannel.Whisper, obfuscatedMessage, wrappedobfuscatedMessage, source, false, session.Channel);
_chatManager.ChatMessageToOne(ChatChannel.Whisper, obfuscatedMessage, wrappedObfuscatedMessage, source, false, session.Channel);
//If listener is too far and has no line of sight, they can't identify the whisperer's identity
else
_chatManager.ChatMessageToOne(ChatChannel.Whisper, understand ? obfuscatedMessage : obfuscatedLanguageMessage, understand ? wrappedUnknownMessage : wrappedUnknownLanguageMessage, source, false, session.Channel);
Expand Down
24 changes: 24 additions & 0 deletions Content.Server/Construction/Components/WelderRefinableComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Content.Shared.Tools;
using Robust.Shared.Prototypes;

namespace Content.Server.Construction.Components;

/// <summary>
/// Used for something that can be refined by welder.
/// For example, glass shard can be refined to glass sheet.
/// </summary>
[RegisterComponent]
public sealed partial class WelderRefinableComponent : Component
{
[DataField]
public HashSet<EntProtoId>? RefineResult = new();

[DataField]
public float RefineTime = 2f;

[DataField]
public float RefineFuel;

[DataField]
public ProtoId<ToolQualityPrototype> QualityNeeded = "Welding";
}
50 changes: 50 additions & 0 deletions Content.Server/Construction/RefiningSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Content.Server.Construction.Components;
using Content.Server.Stack;
using Content.Shared.Construction;
using Content.Shared.Interaction;
using Content.Shared.Stacks;
using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem;

namespace Content.Server.Construction
{
public sealed class RefiningSystem : EntitySystem
{
[Dependency] private readonly SharedToolSystem _toolSystem = default!;
[Dependency] private readonly StackSystem _stackSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<WelderRefinableComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<WelderRefinableComponent, WelderRefineDoAfterEvent>(OnDoAfter);
}

private void OnInteractUsing(EntityUid uid, WelderRefinableComponent component, InteractUsingEvent args)
{
if (args.Handled)
return;

args.Handled = _toolSystem.UseTool(args.Used, args.User, uid, component.RefineTime, component.QualityNeeded, new WelderRefineDoAfterEvent(), fuel: component.RefineFuel);
}

private void OnDoAfter(EntityUid uid, WelderRefinableComponent component, WelderRefineDoAfterEvent args)
{
if (args.Cancelled)
return;

// get last owner coordinates and delete it
var resultPosition = Transform(uid).Coordinates;
EntityManager.DeleteEntity(uid);

// spawn each result after refine
foreach (var result in component.RefineResult!)
{
var droppedEnt = Spawn(result, resultPosition);

// TODO: If something has a stack... Just use a prototype with a single thing in the stack.
// This is not a good way to do it.
if (TryComp<StackComponent>(droppedEnt, out var stack))
_stackSystem.SetCount(droppedEnt, 1, stack);
}
}
}
}
38 changes: 6 additions & 32 deletions Content.Server/Preferences/Managers/ServerPreferencesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading;
using System.Threading.Tasks;
using Content.Corvax.Interfaces.Server;
using Content.Corvax.Interfaces.Shared;
using Content.Server.Administration.Logs;
using Content.Server.Database;
using Content.Shared.CCVar;
Expand Down Expand Up @@ -32,6 +33,7 @@ public sealed class ServerPreferencesManager : IServerPreferencesManager, IPostI
[Dependency] private readonly IPrototypeManager _protos = default!;
[Dependency] private readonly ILogManager _log = default!;
[Dependency] private readonly UserDbDataManager _userDb = default!;
private ISharedSponsorsManager? _sponsors;

// Cache player prefs on the server so we don't need as much async hell related to them.
private readonly Dictionary<NetUserId, PlayerPrefData> _cachedPlayerPrefs =
Expand Down Expand Up @@ -102,41 +104,13 @@ public async Task SetProfile(NetUserId userId, int slot, ICharacterProfile profi
return;
}

if (slot < 0 || slot >= GetMaxUserCharacterSlots(userId)) // Corvax-Sponsors
{
if (slot < 0 || slot >= MaxCharacterSlots)
return;
}

var curPrefs = prefsData.Prefs!;
var session = _playerManager.GetSessionById(userId);

if (profile is HumanoidCharacterProfile humanoid)
if (curPrefs.Characters.TryGetValue(slot, out var storedProfile) && storedProfile is HumanoidCharacterProfile storedHumanoid)
{
if (humanoid.BankBalance != storedHumanoid.BankBalance)
{
_log.Add(LogType.UpdateCharacter, LogImpact.High,
$"Character update with wrong balance from {message.MsgChannel.UserName}, current balance: {storedHumanoid.BankBalance}, tried to set: {humanoid.BankBalance}");

return;
}
}
else if (humanoid.BankBalance != HumanoidCharacterProfile.DefaultBalance)
{
_log.Add(LogType.UpdateCharacter, LogImpact.High,
$"Character creation with wrong balance from {message.MsgChannel.UserName}, default balance: {HumanoidCharacterProfile.DefaultBalance}, tried to set: {humanoid.BankBalance}");

return;
}

_log.Add(LogType.UpdateCharacter, LogImpact.Low, $"Successful character update from {message.MsgChannel.UserName}");

// Corvax-Sponsors-Start: Ensure removing sponsor markings if client somehow bypassed client filtering
// WARN! It's not removing markings from DB!
var sponsorPrototypes = _sponsors != null && _sponsors.TryGetPrototypes(message.MsgChannel.UserId, out var prototypes)
? prototypes.ToArray()
: [];
var sponsorPrototypes = _sponsors != null && _sponsors.TryGetServerPrototypes(session.UserId, out var prototypes) ? prototypes.ToArray() : []; // Corvax-Sponsors
profile.EnsureValid(session, _dependencies, sponsorPrototypes);
// Corvax-Sponsors-End

var profiles = new Dictionary<int, ICharacterProfile>(curPrefs.Characters)
{
Expand Down Expand Up @@ -267,7 +241,7 @@ public bool HavePreferencesLoaded(ICommonSession session)
private int GetMaxUserCharacterSlots(NetUserId userId)
{
var maxSlots = _cfg.GetCVar(CCVars.GameMaxCharacterSlots);
var extraSlots = _sponsors?.GetExtraCharSlots(userId) ?? 0;
var extraSlots = _sponsors?.GetServerExtraCharSlots(userId) ?? 0;
return maxSlots + extraSlots;
}
// Corvax-Sponsors-End
Expand Down
2 changes: 2 additions & 0 deletions Content.Server/Silicons/Borgs/BorgSystem.Modules.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using System.Linq;
using Content.Shared.Hands.Components;
using Content.Shared.Interaction.Components;
Expand Down Expand Up @@ -61,6 +62,7 @@ private void OnSelectableInstalled(EntityUid uid, SelectableBorgModuleComponent
if (_actions.AddAction(chassis, ref component.ModuleSwapActionEntity, out var action, component.ModuleSwapActionId, uid))
{
action.EntityIcon = uid;

Dirty(component.ModuleSwapActionEntity.Value, action);
}

Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Weapons/Ranged/Systems/GunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected override bool ShootDirect(EntityUid gunUid, GunComponent gun, EntityUi
{
if (!Deleted(hitEntity))
{
if (dmg.Any())
if (dmg.AnyPositive()) //Corvax
{
_color.RaiseEffect(Color.Red, new List<EntityUid>() { hitEntity }, Filter.Pvs(hitEntity, entityManager: EntityManager));
}
Expand Down
1 change: 1 addition & 0 deletions Content.Server/_NF/Bank/BankSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Robust.Shared.Network;
using Content.Server.Cargo.Components;
using Content.Shared._NF.Bank.Events;
using Content.Shared.Database;
using Robust.Server.Player;
using Content.Shared.Preferences.Loadouts;
using Robust.Shared.Prototypes;
Expand Down
6 changes: 4 additions & 2 deletions Content.Shared/Actions/BaseActionComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace Content.Shared.Actions;

// TODO add access attribute. Need to figure out what to do with decal & mapping actions.

//[EntityCategory("Actions")]//Corvax-Frontier change after upstream 020724
[Access(typeof(SharedActionsSystem))] //Before upstream 020724
[EntityCategory("Actions")]
//[Access(typeof(SharedActionsSystem))] //Before upstream 020724
public abstract partial class BaseActionComponent : Component
{
public abstract BaseActionEvent? BaseEvent { get; }
Expand Down Expand Up @@ -102,6 +102,8 @@ public abstract partial class BaseActionComponent : Component
/// Entity to use for the action icon. If no entity is provided and the <see cref="Container"/> differs from
/// <see cref="AttachedEntity"/>, then it will default to using <see cref="Container"/>
/// </summary>

[ViewVariables(VVAccess.ReadWrite)]
public EntityUid? EntityIcon
{
get
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public sealed partial class SpeciesPrototype : IPrototype
/// </summary>
[DataField(required: true)]
public bool RoundStart { get; private set; } = false;

// Corvax-Sponsors-Start
/// <summary>
/// Whether the species is available only for sponsors
Expand Down
5 changes: 4 additions & 1 deletion Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.IO;
using System.Linq;
using Content.Corvax.Interfaces.Shared;
using Content.Shared.CCVar;
using Content.Shared.Decals;
using Content.Shared.Examine;
Expand Down Expand Up @@ -36,6 +37,7 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly ISerializationManager _serManager = default!;
[Dependency] private readonly MarkingManager _markingManager = default!;
private ISharedSponsorsManager? _sponsors;

[ValidatePrototypeId<SpeciesPrototype>]
public const string DefaultSpecies = "Human";
Expand Down Expand Up @@ -75,7 +77,8 @@ public HumanoidCharacterProfile FromStream(Stream stream, ICommonSession session

var profile = export.Profile;
var collection = IoCManager.Instance;
profile.EnsureValid(session, collection!);
var sponsorPrototypes = _sponsors != null && _sponsors.TryGetServerPrototypes(session.UserId, out var prototypes) ? prototypes.ToArray() : []; // Corvax-Sponsors
profile.EnsureValid(session, collection!, sponsorPrototypes);
return profile;
}

Expand Down
11 changes: 9 additions & 2 deletions Content.Shared/Preferences/HumanoidCharacterProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public sealed partial class HumanoidCharacterProfile : ICharacterProfile

[DataField]
public Gender Gender { get; private set; } = Gender.Male;

[DataField] // Frontier: Bank balance
public int BankBalance { get; private set; } = DefaultBalance; // Frontier: Bank balance

Expand Down Expand Up @@ -491,7 +491,7 @@ public void EnsureValid(ICommonSession session, IDependencyCollection collection
}

// Corvax-Sponsors-Start: Reset to human if player not sponsor
if (speciesPrototype.SponsorOnly && !sponsorPrototypes.Contains(Species))
if (speciesPrototype.SponsorOnly && !sponsorPrototypes.Contains(Species.Id))
{
Species = SharedHumanoidAppearanceSystem.DefaultSpecies;
speciesPrototype = prototypeManager.Index<SpeciesPrototype>(Species);
Expand Down Expand Up @@ -640,6 +640,13 @@ public void EnsureValid(ICommonSession session, IDependencyCollection collection
_traitPreferences.Clear();
_traitPreferences.UnionWith(traits);


// // Corvax-TTS-Start
// prototypeManager.TryIndex<TTSVoicePrototype>(Voice, out var voice);
// if (voice is null || !CanHaveVoice(voice, Sex))
// Voice = SharedHumanoidAppearanceSystem.DefaultSexVoice[sex];
// // Corvax-TTS-End

// Checks prototypes exist for all loadouts and dump / set to default if not.
var toRemove = new ValueList<string>();

Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private void OnShootRequest(RequestShootEvent msg, EntitySessionEventArgs args)

gun.ShootCoordinates = GetCoordinates(msg.Coordinates);
gun.Target = GetEntity(msg.Target);
AttemptShoot(user.Value, ent, gun);
AttemptShoot(user.Value, gun);
}

private void OnStopShootRequest(RequestStopShootEvent ev, EntitySessionEventArgs args)
Expand Down

0 comments on commit ca65ef3

Please sign in to comment.