mirror of
https://github.com/roflmuffin/CounterStrikeSharp.git
synced 2025-12-07 08:26:34 -08:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28ce183cdc | ||
|
|
dddf24d0f3 | ||
|
|
fce68cb160 | ||
|
|
a82faeb5c8 | ||
|
|
ce3ff449b9 | ||
|
|
aa40d81a86 | ||
|
|
5644921873 | ||
|
|
3860ca1662 | ||
|
|
b79fd19c85 | ||
|
|
b7ea025b03 | ||
|
|
5ac173df51 | ||
|
|
c82a58f5ab | ||
|
|
1806919559 | ||
|
|
f8451c2818 | ||
|
|
a87bd25b48 | ||
|
|
9c5468e5ba | ||
|
|
f826be664f | ||
|
|
7f5103d9ee | ||
|
|
877b7c5a4a | ||
|
|
24363d6352 | ||
|
|
2eaf7c2d8c | ||
|
|
8b486ecf7e | ||
|
|
54cc93e0f8 | ||
|
|
a695eec4fa | ||
|
|
e207be2fbf | ||
|
|
eea64519a6 |
11
.devcontainer/linux/devcontainer.json
Normal file
11
.devcontainer/linux/devcontainer.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "SteamRT Sniper SDK",
|
||||
"image": "registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest",
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"ms-vscode.cpptools"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,5 +10,5 @@ indent_size = 4
|
||||
max_line_length = 140
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.json]
|
||||
[{*.json,*.yaml,*.yml}]
|
||||
indent_size = 2
|
||||
|
||||
21
.github/workflows/actionlint.yaml
vendored
Normal file
21
.github/workflows/actionlint.yaml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: actionlint
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
branches: ["main"]
|
||||
paths:
|
||||
- ".github/actions/**"
|
||||
- ".github/workflows/**"
|
||||
|
||||
jobs:
|
||||
actionlint:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 3
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: actionlint
|
||||
uses: reviewdog/action-actionlint@v1
|
||||
with:
|
||||
reporter: github-pr-review
|
||||
fail_on_error: true
|
||||
@@ -56,8 +56,6 @@ set(SOURCE_FILES
|
||||
src/core/tick_scheduler.cpp
|
||||
src/scripting/autonative.h
|
||||
src/scripting/natives/natives_engine.cpp
|
||||
src/core/engine_trace.h
|
||||
src/core/engine_trace.cpp
|
||||
src/scripting/natives/natives_callbacks.cpp
|
||||
src/core/managers/player_manager.h
|
||||
src/core/managers/player_manager.cpp
|
||||
|
||||
@@ -79,7 +79,7 @@ public class HelloWorldPlugin : BasePlugin
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
[ConsoleCommand("issue_warning", "Issue warning to player")]
|
||||
[ConsoleCommand("css_issue_warning", "Issue warning to player")]
|
||||
public void OnCommand(CCSPlayerController? player, CommandInfo command)
|
||||
{
|
||||
Logger.LogWarning("Player shouldn't be doing that");
|
||||
|
||||
@@ -4,5 +4,7 @@
|
||||
"FollowCS2ServerGuidelines": true,
|
||||
"PluginHotReloadEnabled": true,
|
||||
"PluginAutoLoadEnabled": true,
|
||||
"ServerLanguage": "en"
|
||||
"ServerLanguage": "en",
|
||||
"UnlockConCommands": true,
|
||||
"UnlockConVars": true
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
"ClientPrint": {
|
||||
"signatures": {
|
||||
"library": "server",
|
||||
"windows": "48 85 C9 0F 84 ? ? ? ? 48 8B C4 48 89 58 18",
|
||||
"windows": "48 85 C9 0F 84 ? ? ? ? 48 89 5C 24 ? 55",
|
||||
"linux": "55 48 89 E5 41 57 49 89 CF 41 56 49 89 D6 41 55 41 89 F5 41 54 4C 8D A5 A0 FE FF FF"
|
||||
}
|
||||
},
|
||||
@@ -35,8 +35,8 @@
|
||||
"CBasePlayerController_SetPawn": {
|
||||
"signatures": {
|
||||
"library": "server",
|
||||
"windows": "44 88 4C 24 ? 55 56 57 41 54 41 56 48 8D 6C 24 ?",
|
||||
"linux": "55 48 89 E5 41 57 41 56 41 89 D6 41 55 49 89 FD 41 54 45 89 C4"
|
||||
"windows": "48 89 74 24 ? 55 41 54 41 55 41 56 41 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 4C 8B F9",
|
||||
"linux": "55 48 89 E5 41 57 41 56 41 55 49 89 FD 41 54 45 89 C4"
|
||||
}
|
||||
},
|
||||
"CCSPlayerPawnBase_PostThink": {
|
||||
@@ -57,7 +57,7 @@
|
||||
"signatures": {
|
||||
"library": "server",
|
||||
"windows": "48 89 5C 24 ? 48 89 74 24 ? 55 57 41 ? 41 ? 41 ? 48 ? ? ? ? 48 ? ? ? ? ? ? 4D ? ? 48",
|
||||
"linux": "55 48 89 E5 41 57 41 56 49 89 D6 41 55 49 89 CD 41 54 49 89 F4 53 48 89 FB 48 8D 3D 33 DA 7B 00"
|
||||
"linux": "55 48 89 E5 41 57 41 56 49 89 D6 41 55 49 89 CD 41 54 49 89 F4 53 48 89 FB 48 8D 3D"
|
||||
}
|
||||
},
|
||||
"UTIL_Remove": {
|
||||
@@ -84,8 +84,8 @@
|
||||
"CCSPlayer_WeaponServices_CanUse": {
|
||||
"signatures": {
|
||||
"library": "server",
|
||||
"windows": "48 89 5C 24 10 48 89 6C 24 18 56 57 41 56 48 83 EC 30 80 B9 A0 00 00 00 00",
|
||||
"linux": "48 85 F6 0F 84 ? ? ? ? 55 31 C9 48 89 E5 41 55 49 89 FD"
|
||||
"windows": "48 89 5C 24 10 48 89 6C 24 18 56 57 41 56 48 83 EC 30 48 8B 01",
|
||||
"linux": "55 48 8D 15 ? ? ? ? 48 89 E5 41 55 49 89 FD 41 54 49 89 F4"
|
||||
}
|
||||
},
|
||||
"CCSPlayer_ItemServices_GiveNamedItem": {
|
||||
@@ -197,7 +197,7 @@
|
||||
"StateChanged": {
|
||||
"signatures": {
|
||||
"library": "server",
|
||||
"windows": "40 55 53 56 41 55 41 57 48 8D 6C 24 B0",
|
||||
"windows": "40 ? 53 56 41 ? 41 ? 48 ? ? ? ? 48 ? ? ? ? ? ? 48 ? ? 45",
|
||||
"linux": "55 48 89 E5 41 57 41 56 41 55 41 54 53 89 D3"
|
||||
}
|
||||
},
|
||||
@@ -237,7 +237,7 @@
|
||||
"CEntityResourceManifest_AddResource": {
|
||||
"offsets": {
|
||||
"windows": 2,
|
||||
"linux": 2
|
||||
"linux": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,320 +0,0 @@
|
||||
ActionType_t
|
||||
AimMatrixBlendMode
|
||||
AmmoFlags_t
|
||||
AmmoPosition_t
|
||||
AnimationProcessingType_t
|
||||
AnimationSnapshotType_t
|
||||
AnimationType_t
|
||||
AnimLoopMode_t
|
||||
AnimNodeNetworkMode
|
||||
AnimParamButton_t
|
||||
AnimParamNetworkSetting
|
||||
AnimParamType_t
|
||||
AnimPoseControl
|
||||
AnimScriptType
|
||||
AnimValueSource
|
||||
AnimVectorSource
|
||||
attributeprovidertypes_t
|
||||
BaseExplosionTypes_t
|
||||
BBoxVolumeType_t
|
||||
BeamClipStyle_t
|
||||
BeamType_t
|
||||
BeginDeathLifeStateTransition_t
|
||||
BinaryNodeChildOption
|
||||
BinaryNodeTiming
|
||||
Blend2DMode
|
||||
BlendKeyType
|
||||
BloomBlendMode_t
|
||||
BlurFilterType_t
|
||||
BoneMaskBlendSpace
|
||||
BoneTransformSpace_t
|
||||
BrushSolidities_e
|
||||
C4LightEffect_t
|
||||
CAnimationGraphVisualizerPrimitiveType
|
||||
CanPlaySequence_t
|
||||
ChatIgnoreType_t
|
||||
ChickenActivity
|
||||
ChoiceBlendMethod
|
||||
ChoiceChangeMethod
|
||||
ChoiceMethod
|
||||
Class_T
|
||||
CLogicBranchList__LogicBranchListenerLastState_t
|
||||
ClosestPointTestType_t
|
||||
CNmBoneMask__WeightInfo_t
|
||||
CommandEntitySpecType_t
|
||||
CommandExecMode_t
|
||||
CompMatPropertyMutatorConditionType_t
|
||||
CompMatPropertyMutatorType_t
|
||||
CompositeMaterialInputContainerSourceType_t
|
||||
CompositeMaterialInputLooseVariableType_t
|
||||
CompositeMaterialInputTextureType_t
|
||||
CompositeMaterialMatchFilterType_t
|
||||
CompositeMaterialVarSystemVar_t
|
||||
CRR_Response__ResponseEnum_t
|
||||
CSPlayerBlockingUseAction_t
|
||||
CSPlayerState
|
||||
CSWeaponCategory
|
||||
CSWeaponMode
|
||||
CSWeaponSilencerType
|
||||
CSWeaponState_t
|
||||
CSWeaponType
|
||||
DamageTypes_t
|
||||
DampingSpeedFunction
|
||||
DebugOverlayBits_t
|
||||
Detail2Combo_t
|
||||
DetailCombo_t
|
||||
DisableShadows_t
|
||||
Disposition_t
|
||||
doorCheck_e
|
||||
DoorState_t
|
||||
EDemoBoneSelectionMode
|
||||
EInButtonState
|
||||
EKillTypes_t
|
||||
ELayoutNodeType
|
||||
EntFinderMethod_t
|
||||
EntityDisolveType_t
|
||||
EntityDormancyType_t
|
||||
EntityIOTargetType_t
|
||||
EntitySubclassScope_t
|
||||
EOverrideBlockLOS_t
|
||||
EStyleNodeType
|
||||
Explosions
|
||||
FacingMode
|
||||
FieldNetworkOption
|
||||
fieldtype_t
|
||||
filter_t
|
||||
FixAngleSet_t
|
||||
FlexOpCode_t
|
||||
FootFallTagFoot_t
|
||||
FootLockSubVisualization
|
||||
FootPinningTimingSource
|
||||
FootstepLandedFootSoundType_t
|
||||
ForcedCrouchState_t
|
||||
FuncDoorSpawnPos_t
|
||||
FuseVariableAccess_t
|
||||
FuseVariableType_t
|
||||
GameAnimEventIndex_t
|
||||
gear_slot_t
|
||||
GrenadeType_t
|
||||
HierarchyType_t
|
||||
HitboxLerpType_t
|
||||
HitGroup_t
|
||||
HorizJustification_e
|
||||
Hull_t
|
||||
IChoreoServices__ChoreoState_t
|
||||
IChoreoServices__ScriptState_t
|
||||
IKChannelMode
|
||||
IkEndEffectorType
|
||||
IKSolverType
|
||||
IKTargetCoordinateSystem
|
||||
IKTargetSource
|
||||
IkTargetType
|
||||
InheritableBoolType_t
|
||||
InputBitMask_t
|
||||
InputLayoutVariation_t
|
||||
ItemFlagTypes_t
|
||||
JiggleBoneSimSpace
|
||||
JointAxis_t
|
||||
JointMotion_t
|
||||
JumpCorrectionMethod
|
||||
LatchDirtyPermission_t
|
||||
LayoutPositionType_e
|
||||
LessonPanelLayoutFileTypes_t
|
||||
LifeState_t
|
||||
loadout_slot_t
|
||||
MaterialProxyType_t
|
||||
Materials
|
||||
MatterialAttributeTagType_t
|
||||
MedalRank_t
|
||||
MeshDrawPrimitiveFlags_t
|
||||
MissingParentInheritBehavior_t
|
||||
ModelBoneFlexComponent_t
|
||||
ModelConfigAttachmentType_t
|
||||
ModelSkeletonData_t__BoneFlags_t
|
||||
ModifyDamageReturn_t
|
||||
MoodType_t
|
||||
MorphBundleType_t
|
||||
MorphFlexControllerRemapType_t
|
||||
MoveCollide_t
|
||||
MoveLinearAuthoredPos_t
|
||||
MovementGait_t
|
||||
MoveMountingAmount_t
|
||||
MoveType_t
|
||||
NavAttributeEnum
|
||||
NavDirType
|
||||
navproperties_t
|
||||
NmFootPhase_t
|
||||
NmFootPhaseCondition_t
|
||||
NmFrameSnapEventMode_t
|
||||
NmTransitionRule_t
|
||||
NmTransitionRuleCondition_t
|
||||
NPCFollowFormation_t
|
||||
NPCLookType_t
|
||||
ObjectTypeFlags_t
|
||||
ObserverInterpState_t
|
||||
ObserverMode_t
|
||||
OnFrame
|
||||
ParticleAlphaReferenceType_t
|
||||
ParticleAttachment_t
|
||||
ParticleAttrBoxFlags_t
|
||||
ParticleCollisionMode_t
|
||||
ParticleColorBlendMode_t
|
||||
ParticleColorBlendType_t
|
||||
ParticleControlPointAxis_t
|
||||
ParticleDepthFeatheringMode_t
|
||||
ParticleDetailLevel_t
|
||||
ParticleDirectionNoiseType_t
|
||||
ParticleEndcapMode_t
|
||||
ParticleFalloffFunction_t
|
||||
ParticleFloatBiasType_t
|
||||
ParticleFloatInputMode_t
|
||||
ParticleFloatMapType_t
|
||||
ParticleFloatRandomMode_t
|
||||
ParticleFloatType_t
|
||||
ParticleFogType_t
|
||||
ParticleHitboxBiasType_t
|
||||
ParticleHitboxDataSelection_t
|
||||
ParticleImpulseType_t
|
||||
ParticleLightBehaviorChoiceList_t
|
||||
ParticleLightFogLightingMode_t
|
||||
ParticleLightingQuality_t
|
||||
ParticleLightnintBranchBehavior_t
|
||||
ParticleLightTypeChoiceList_t
|
||||
ParticleLightUnitChoiceList_t
|
||||
ParticleModelType_t
|
||||
ParticleOmni2LightTypeChoiceList_t
|
||||
ParticleOrientationChoiceList_t
|
||||
ParticleOrientationSetMode_t
|
||||
ParticleOutputBlendMode_t
|
||||
ParticleParentSetMode_t
|
||||
ParticlePinDistance_t
|
||||
ParticlePostProcessPriorityGroup_t
|
||||
ParticleRotationLockType_t
|
||||
ParticleSelection_t
|
||||
ParticleSequenceCropOverride_t
|
||||
ParticleSetMethod_t
|
||||
ParticleSortingChoiceList_t
|
||||
ParticleTextureLayerBlendType_t
|
||||
ParticleTopology_t
|
||||
ParticleTraceMissBehavior_t
|
||||
ParticleTraceSet_t
|
||||
ParticleTransformType_t
|
||||
ParticleVecType_t
|
||||
ParticleVRHandChoiceList_t
|
||||
PerformanceMode_t
|
||||
PermModelInfo_t__FlagEnum
|
||||
PetGroundType_t
|
||||
PFNoiseModifier_t
|
||||
PFNoiseTurbulence_t
|
||||
PFNoiseType_t
|
||||
PFuncVisualizationType_t
|
||||
PlayerAnimEvent_t
|
||||
PlayerConnectedState
|
||||
PointTemplateClientOnlyEntityBehavior_t
|
||||
PointTemplateOwnerSpawnGroupType_t
|
||||
PointWorldTextJustifyHorizontal_t
|
||||
PointWorldTextJustifyVertical_t
|
||||
PointWorldTextReorientMode_t
|
||||
PoseType_t
|
||||
PreviewCharacterMode
|
||||
PreviewEOMCelebration
|
||||
PreviewWeaponState
|
||||
PropDoorRotatingOpenDirection_e
|
||||
PropDoorRotatingSpawnPos_t
|
||||
PulseCursorCancelPriority_t
|
||||
PulseCursorExecResult_t
|
||||
PulseInstructionCode_t
|
||||
PulseMethodCallMode_t
|
||||
PulseTestEnumColor_t
|
||||
PulseTestEnumShape_t
|
||||
PulseValueType_t
|
||||
QuestProgress__Reason
|
||||
RagdollPoseControl
|
||||
RenderBufferFlags_t
|
||||
RenderFx_t
|
||||
RenderMode_t
|
||||
RenderMultisampleType_t
|
||||
RenderPrimitiveType_t
|
||||
RenderSlotType_t
|
||||
ResetCycleOption
|
||||
RumbleEffect_t
|
||||
ScalarExpressionType_t
|
||||
SceneOnPlayerDeath_t
|
||||
ScriptedConflictResponse_t
|
||||
ScriptedMoveTo_t
|
||||
ScriptedMoveType_t
|
||||
ScriptedOnDeath_t
|
||||
SelectorTagBehavior_t
|
||||
SeqCmd_t
|
||||
SeqPoseSetting_t
|
||||
SequenceFinishNotifyState_t
|
||||
ShadowType_t
|
||||
ShakeCommand_t
|
||||
ShardSolid_t
|
||||
ShatterDamageCause
|
||||
ShatterGlassStressType
|
||||
ShatterPanelMode
|
||||
SimpleConstraintSoundProfile__SimpleConstraintsSoundProfileKeypoints_t
|
||||
SnapshotIndexType_t
|
||||
SolidType_t
|
||||
SolveIKChainAnimNodeDebugSetting
|
||||
SosActionSortType_t
|
||||
SosActionStopType_t
|
||||
SosEditItemType_t
|
||||
SosGroupType_t
|
||||
SoundEventStartType_t
|
||||
SoundFlags_t
|
||||
soundlevel_t
|
||||
SpawnDebugOverrideState_t
|
||||
SpawnDebugRestrictionOverrideState_t
|
||||
SpawnPointCoopEnemy__BotDefaultBehavior_t
|
||||
SpriteCardPerParticleScale_t
|
||||
SpriteCardShaderType_t
|
||||
SpriteCardTextureChannel_t
|
||||
SpriteCardTextureType_t
|
||||
StanceOverrideMode
|
||||
StanceType_t
|
||||
StandardLightingAttenuationStyle_t
|
||||
StateActionBehavior
|
||||
StepPhase
|
||||
SubclassVDataChangeType_t
|
||||
SurroundingBoundsType_t
|
||||
TakeDamageFlags_t
|
||||
TextureRepetitionMode_t
|
||||
ThreeState_t
|
||||
TimelineCompression_t
|
||||
TOGGLE_STATE
|
||||
Touch_t
|
||||
TrackOrientationType_t
|
||||
TRAIN_CODE
|
||||
TrainOrientationType_t
|
||||
TrainVelocityType_t
|
||||
ValueRemapperHapticsType_t
|
||||
ValueRemapperInputType_t
|
||||
ValueRemapperMomentumType_t
|
||||
ValueRemapperOutputType_t
|
||||
ValueRemapperRatchetType_t
|
||||
VectorExpressionType_t
|
||||
VectorFloatExpressionType_t
|
||||
VelocityMetricMode
|
||||
VertJustification_e
|
||||
ViewFadeMode_t
|
||||
VMixChannelOperation_t
|
||||
VMixFilterSlope_t
|
||||
VMixFilterType_t
|
||||
VMixLFOShape_t
|
||||
VMixPannerType_t
|
||||
VMixProcessorType_t
|
||||
VMixSubgraphSwitchInterpolationType_t
|
||||
vote_create_failed_t
|
||||
VPhysXAggregateData_t__VPhysXFlagEnum_t
|
||||
VPhysXBodyPart_t__VPhysXFlagEnum_t
|
||||
VPhysXConstraintParams_t__EnumFlags0_t
|
||||
VPhysXJoint_t__Flags_t
|
||||
WaterLevel_t
|
||||
WeaponAttackType_t
|
||||
WeaponSound_t
|
||||
WeaponSwitchReason_t
|
||||
WorldTextPanelHorizontalAlign_t
|
||||
WorldTextPanelOrientation_t
|
||||
WorldTextPanelVerticalAlign_t
|
||||
@@ -28,7 +28,6 @@ receive a ban.
|
||||
> [!NOTE]
|
||||
> Disable this option at your own risk.
|
||||
|
||||
|
||||
## PluginHotReloadEnabled
|
||||
|
||||
When enabled, plugins are automatically reloaded when their .dll file is updated.
|
||||
@@ -39,4 +38,12 @@ When enabled, plugins are automatically loaded from the plugins directory on ser
|
||||
|
||||
## ServerLanguage
|
||||
|
||||
Configures the default language to use for server commands & messages. The format for the culture name based on RFC 4646 is `languagecode2-country`/`regioncode2`, where `languagecode2` is the two-letter language code and `country/regioncode2` is the two-letter subculture code. Examples include `ja-JP` for Japanese (Japan) and `en-US` for English (United States). Defaults to "en".
|
||||
Configures the default language to use for server commands & messages. The format for the culture name based on RFC 4646 is `languagecode2-country`/`regioncode2`, where `languagecode2` is the two-letter language code and `country/regioncode2` is the two-letter subculture code. Examples include `ja-JP` for Japanese (Japan) and `en-US` for English (United States). Defaults to "en".
|
||||
|
||||
## UnlockConCommands
|
||||
|
||||
When enabled, will remove the `FCVAR_HIDDEN`,`FCVAR_DEVELOPMENTONLY`, `FCVAR_MISSING0`, `FCVAR_MISSING1`, `FCVAR_MISSING2`, `FCVAR_MISSING3` flags from all console commands.
|
||||
|
||||
## UnlockConVars
|
||||
|
||||
When enabled, will remove the `FCVAR_HIDDEN`,`FCVAR_DEVELOPMENTONLY`, `FCVAR_MISSING0`, `FCVAR_MISSING1`, `FCVAR_MISSING2`, `FCVAR_MISSING3` flags from all console variables.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Globalization;
|
||||
using System.Globalization;
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes;
|
||||
@@ -22,18 +22,29 @@ public class WithTranslationsPlugin : BasePlugin
|
||||
// A global `Localizer` is provided on the plugin instance.
|
||||
// You can also use dependency injection to inject `IStringLocalizer` in your own services.
|
||||
Logger.LogInformation("This message is in the server language: {Message}", Localizer["test.translation"]);
|
||||
|
||||
|
||||
// IStringLocalizer can accept standard string format arguments.
|
||||
// "This number has 2 decimal places {0:n2}" -> "This number has 2 decimal places 123.55"
|
||||
Logger.LogInformation(Localizer["test.format", 123.551]);
|
||||
|
||||
|
||||
// This message has colour codes
|
||||
Server.PrintToChatAll(Localizer["test.colors"]);
|
||||
|
||||
// This message has colour codes and formatted values
|
||||
Server.PrintToChatAll(Localizer["test.colors.withformat", 123.551]);
|
||||
|
||||
// This prints the message to all players in their respective language
|
||||
PrintToAllPlayersLocalized("test.format", 123.456);
|
||||
}
|
||||
|
||||
|
||||
void PrintToAllPlayersLocalized(string key, params object[] args)
|
||||
{
|
||||
foreach (var player in Utilities.GetPlayers().Where(x => x.IsValid))
|
||||
{
|
||||
player.PrintToChat(Localizer.ForPlayer(player, key, args));
|
||||
}
|
||||
}
|
||||
|
||||
[ConsoleCommand("css_replylanguage", "Test Translations")]
|
||||
public void OnCommandReplyLanguage(CCSPlayerController? player, CommandInfo command)
|
||||
{
|
||||
|
||||
Submodule libraries/hl2sdk-cs2 updated: 739c88fa85...0b862d725a
@@ -156,17 +156,10 @@ namespace CounterStrikeSharp.API.Core
|
||||
break;
|
||||
}
|
||||
|
||||
// If our arugment doesn't end in ".dll" - try and construct a path similar to PluginName/PluginName.dll.
|
||||
// If our argument doesn't end in ".dll" - try and construct a path similar to PluginName/PluginName.dll.
|
||||
// We'll assume we have a full path if we have ".dll".
|
||||
var path = info.GetArg(2);
|
||||
if (!path.EndsWith(".dll"))
|
||||
{
|
||||
path = Path.Combine(_scriptHostConfiguration.RootPath, $"plugins/{path}/{path}.dll");
|
||||
}
|
||||
else
|
||||
{
|
||||
path = Path.Combine(_scriptHostConfiguration.RootPath, path);
|
||||
}
|
||||
path = Path.Combine(_scriptHostConfiguration.RootPath, !path.EndsWith(".dll") ? $"plugins/{path}/{path}.dll" : path);
|
||||
|
||||
var plugin = _pluginContextQueryHandler.FindPluginByModulePath(path);
|
||||
|
||||
@@ -204,7 +197,13 @@ namespace CounterStrikeSharp.API.Core
|
||||
}
|
||||
|
||||
var pluginIdentifier = info.GetArg(2);
|
||||
IPluginContext? plugin = _pluginContextQueryHandler.FindPluginByIdOrName(pluginIdentifier);
|
||||
string path;
|
||||
path = Path.Combine(_scriptHostConfiguration.RootPath,
|
||||
!pluginIdentifier.EndsWith(".dll") ? $"plugins/{pluginIdentifier}/{pluginIdentifier}.dll" : pluginIdentifier);
|
||||
|
||||
var plugin = _pluginContextQueryHandler.FindPluginByIdOrName(pluginIdentifier)
|
||||
?? _pluginContextQueryHandler.FindPluginByModulePath(path);
|
||||
|
||||
if (plugin == null)
|
||||
{
|
||||
info.ReplyToCommand($"Could not unload plugin \"{pluginIdentifier}\"");
|
||||
@@ -249,7 +248,7 @@ namespace CounterStrikeSharp.API.Core
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnLangCommand(CCSPlayerController? player, CommandInfo command)
|
||||
{
|
||||
if (player == null) return;
|
||||
@@ -305,4 +304,4 @@ namespace CounterStrikeSharp.API.Core
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,15 +46,21 @@ namespace CounterStrikeSharp.API.Core
|
||||
|
||||
[JsonPropertyName("FollowCS2ServerGuidelines")]
|
||||
public bool FollowCS2ServerGuidelines { get; set; } = true;
|
||||
|
||||
|
||||
[JsonPropertyName("PluginHotReloadEnabled")]
|
||||
public bool PluginHotReloadEnabled { get; set; } = true;
|
||||
|
||||
|
||||
[JsonPropertyName("PluginAutoLoadEnabled")]
|
||||
public bool PluginAutoLoadEnabled { get; set; } = true;
|
||||
|
||||
|
||||
[JsonPropertyName("ServerLanguage")]
|
||||
public string ServerLanguage { get; set; } = "en";
|
||||
|
||||
[JsonPropertyName("UnlockConCommands")]
|
||||
public bool UnlockConCommands { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("UnlockConVars")]
|
||||
public bool UnlockConVars { get; set; } = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -97,14 +103,18 @@ namespace CounterStrikeSharp.API.Core
|
||||
/// When enabled, plugins are automatically reloaded when their .dll file is updated.
|
||||
/// </summary>
|
||||
public static bool PluginHotReloadEnabled => _coreConfig.PluginHotReloadEnabled;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// When enabled, plugins are automatically loaded from the plugins directory on server start.
|
||||
/// </summary>
|
||||
public static bool PluginAutoLoadEnabled => _coreConfig.PluginAutoLoadEnabled;
|
||||
|
||||
|
||||
public static string ServerLanguage => _coreConfig.ServerLanguage;
|
||||
|
||||
|
||||
public static bool UnlockConCommands => _coreConfig.UnlockConCommands;
|
||||
|
||||
public static bool UnlockConVars => _coreConfig.UnlockConVars;
|
||||
|
||||
}
|
||||
|
||||
public partial class CoreConfig : IStartupService
|
||||
@@ -140,7 +150,7 @@ namespace CounterStrikeSharp.API.Core
|
||||
ReloadCoreConfigCommand));
|
||||
_commandsRegistered = true;
|
||||
}
|
||||
|
||||
|
||||
if (!File.Exists(_coreConfigPath))
|
||||
{
|
||||
_logger.LogWarning(
|
||||
@@ -181,13 +191,13 @@ namespace CounterStrikeSharp.API.Core
|
||||
serverCulture = CultureInfo.InvariantCulture;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CultureInfo.DefaultThreadCurrentUICulture = serverCulture;
|
||||
CultureInfo.DefaultThreadCurrentCulture = serverCulture;
|
||||
CultureInfo.CurrentUICulture = serverCulture;
|
||||
CultureInfo.CurrentCulture = serverCulture;
|
||||
|
||||
|
||||
_logger.LogInformation("Successfully loaded core configuration");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -716,6 +716,86 @@ namespace CounterStrikeSharp.API.Core
|
||||
}
|
||||
}
|
||||
|
||||
[EventName("bullet_damage")]
|
||||
public class EventBulletDamage : GameEvent
|
||||
{
|
||||
public EventBulletDamage(IntPtr pointer) : base(pointer){}
|
||||
public EventBulletDamage(bool force) : base("bullet_damage", force){}
|
||||
|
||||
|
||||
|
||||
// player index who was hurt
|
||||
public CCSPlayerController? Victim
|
||||
{
|
||||
get => GetPlayer("victim");
|
||||
set => SetPlayer("victim", value);
|
||||
}
|
||||
|
||||
|
||||
// player index who attacked
|
||||
public CCSPlayerController? Attacker
|
||||
{
|
||||
get => GetPlayer("attacker");
|
||||
set => SetPlayer("attacker", value);
|
||||
}
|
||||
|
||||
|
||||
// how far the bullet travelled before it hit the player
|
||||
public float Distance
|
||||
{
|
||||
get => Get<float>("distance");
|
||||
set => Set<float>("distance", value);
|
||||
}
|
||||
|
||||
|
||||
// direction vector of the bullet
|
||||
public float DamageDirX
|
||||
{
|
||||
get => Get<float>("damage_dir_x");
|
||||
set => Set<float>("damage_dir_x", value);
|
||||
}
|
||||
|
||||
|
||||
// direction vector of the bullet
|
||||
public float DamageDirY
|
||||
{
|
||||
get => Get<float>("damage_dir_y");
|
||||
set => Set<float>("damage_dir_y", value);
|
||||
}
|
||||
|
||||
|
||||
// direction vector of the bullet
|
||||
public float DamageDirZ
|
||||
{
|
||||
get => Get<float>("damage_dir_z");
|
||||
set => Set<float>("damage_dir_z", value);
|
||||
}
|
||||
|
||||
|
||||
// how many surfaces were penetrated
|
||||
public int NumPenetrations
|
||||
{
|
||||
get => Get<int>("num_penetrations");
|
||||
set => Set<int>("num_penetrations", value);
|
||||
}
|
||||
|
||||
|
||||
// was the shooter noscoped?
|
||||
public bool NoScope
|
||||
{
|
||||
get => Get<bool>("no_scope");
|
||||
set => Set<bool>("no_scope", value);
|
||||
}
|
||||
|
||||
|
||||
// was the shooter jumping?
|
||||
public bool InAir
|
||||
{
|
||||
get => Get<bool>("in_air");
|
||||
set => Set<bool>("in_air", value);
|
||||
}
|
||||
}
|
||||
|
||||
[EventName("bullet_flight_resolution")]
|
||||
public class EventBulletFlightResolution : GameEvent
|
||||
{
|
||||
|
||||
@@ -8,16 +8,19 @@ namespace CounterStrikeSharp.API.Core;
|
||||
public partial class CBaseEntity
|
||||
{
|
||||
/// <exception cref="InvalidOperationException">Entity is not valid</exception>
|
||||
/// <exception cref="ArgumentNullException">No valid argument</exception>
|
||||
public void Teleport(Vector? position = null, QAngle? angles = null, Vector? velocity = null)
|
||||
{
|
||||
Guard.IsValidEntity(this);
|
||||
|
||||
position ??= AbsOrigin!;
|
||||
angles ??= AbsRotation!;
|
||||
velocity ??= AbsVelocity;
|
||||
|
||||
VirtualFunction.CreateVoid<IntPtr, IntPtr, IntPtr, IntPtr>(Handle, GameData.GetOffset("CBaseEntity_Teleport"))(
|
||||
Handle, position.Handle, angles.Handle, velocity.Handle);
|
||||
|
||||
if (position == null && angles == null && velocity == null)
|
||||
throw new ArgumentNullException("No valid argument");
|
||||
|
||||
nint _position = position?.Handle ?? 0;
|
||||
nint _angles = angles?.Handle ?? 0;
|
||||
nint _velocity = velocity?.Handle ?? 0;
|
||||
|
||||
VirtualFunction.CreateVoid<IntPtr, IntPtr, IntPtr, IntPtr>(Handle, GameData.GetOffset("CBaseEntity_Teleport"))(Handle, _position, _angles, _velocity);
|
||||
}
|
||||
|
||||
/// <exception cref="InvalidOperationException">Entity is not valid</exception>
|
||||
@@ -45,4 +48,4 @@ public partial class CBaseEntity
|
||||
|
||||
return (T)Activator.CreateInstance(typeof(T), Marshal.ReadIntPtr(SubclassID.Handle + 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public partial class CBaseAnimGraphController : CSkeletonAnimationController
|
||||
|
||||
// m_flPlaybackRate
|
||||
[SchemaMember("CBaseAnimGraphController", "m_flPlaybackRate")]
|
||||
public float PlaybackRate => Schema.GetDeclaredClass<float>(this.Handle, "CBaseAnimGraphController", "m_flPlaybackRate");
|
||||
public ref float PlaybackRate => ref Schema.GetRef<float>(this.Handle, "CBaseAnimGraphController", "m_flPlaybackRate");
|
||||
|
||||
// m_nNotifyState
|
||||
[SchemaMember("CBaseAnimGraphController", "m_nNotifyState")]
|
||||
|
||||
@@ -94,14 +94,6 @@ public partial class CBasePlayerController : CBaseEntity
|
||||
[SchemaMember("CBasePlayerController", "m_bGamePaused")]
|
||||
public ref bool GamePaused => ref Schema.GetRef<bool>(this.Handle, "CBasePlayerController", "m_bGamePaused");
|
||||
|
||||
// m_nLastRealCommandNumberExecuted
|
||||
[SchemaMember("CBasePlayerController", "m_nLastRealCommandNumberExecuted")]
|
||||
public ref Int32 LastRealCommandNumberExecuted => ref Schema.GetRef<Int32>(this.Handle, "CBasePlayerController", "m_nLastRealCommandNumberExecuted");
|
||||
|
||||
// m_nLastLateCommandExecuted
|
||||
[SchemaMember("CBasePlayerController", "m_nLastLateCommandExecuted")]
|
||||
public ref Int32 LastLateCommandExecuted => ref Schema.GetRef<Int32>(this.Handle, "CBasePlayerController", "m_nLastLateCommandExecuted");
|
||||
|
||||
// m_iIgnoreGlobalChat
|
||||
[SchemaMember("CBasePlayerController", "m_iIgnoreGlobalChat")]
|
||||
public ref ChatIgnoreType_t IgnoreGlobalChat => ref Schema.GetRef<ChatIgnoreType_t>(this.Handle, "CBasePlayerController", "m_iIgnoreGlobalChat");
|
||||
|
||||
@@ -370,10 +370,6 @@ public partial class CCSPlayerPawn : CCSPlayerPawnBase
|
||||
[SchemaMember("CCSPlayerPawn", "m_ignoreLadderJumpTime")]
|
||||
public ref float IgnoreLadderJumpTime => ref Schema.GetRef<float>(this.Handle, "CCSPlayerPawn", "m_ignoreLadderJumpTime");
|
||||
|
||||
// m_NumEnemiesKilledThisRound
|
||||
[SchemaMember("CCSPlayerPawn", "m_NumEnemiesKilledThisRound")]
|
||||
public ref Int32 NumEnemiesKilledThisRound => ref Schema.GetRef<Int32>(this.Handle, "CCSPlayerPawn", "m_NumEnemiesKilledThisRound");
|
||||
|
||||
// m_bKilledByHeadshot
|
||||
[SchemaMember("CCSPlayerPawn", "m_bKilledByHeadshot")]
|
||||
public ref bool KilledByHeadshot => ref Schema.GetRef<bool>(this.Handle, "CCSPlayerPawn", "m_bKilledByHeadshot");
|
||||
|
||||
@@ -94,10 +94,6 @@ public partial class CCSPlayerPawnBase : CBasePlayerPawn
|
||||
[SchemaMember("CCSPlayerPawnBase", "m_angEyeAngles")]
|
||||
public QAngle EyeAngles => Schema.GetDeclaredClass<QAngle>(this.Handle, "CCSPlayerPawnBase", "m_angEyeAngles");
|
||||
|
||||
// m_NumEnemiesAtRoundStart
|
||||
[SchemaMember("CCSPlayerPawnBase", "m_NumEnemiesAtRoundStart")]
|
||||
public ref Int32 NumEnemiesAtRoundStart => ref Schema.GetRef<Int32>(this.Handle, "CCSPlayerPawnBase", "m_NumEnemiesAtRoundStart");
|
||||
|
||||
// m_wasNotKilledNaturally
|
||||
[SchemaMember("CCSPlayerPawnBase", "m_wasNotKilledNaturally")]
|
||||
public ref bool WasNotKilledNaturally => ref Schema.GetRef<bool>(this.Handle, "CCSPlayerPawnBase", "m_wasNotKilledNaturally");
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
// <auto-generated />
|
||||
#nullable enable
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using CounterStrikeSharp;
|
||||
using CounterStrikeSharp.API.Modules.Events;
|
||||
using CounterStrikeSharp.API.Modules.Entities;
|
||||
using CounterStrikeSharp.API.Modules.Memory;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using CounterStrikeSharp.API.Core.Attributes;
|
||||
|
||||
namespace CounterStrikeSharp.API.Core;
|
||||
|
||||
public partial class CCSWeaponBaseVDataAPI : NativeObject
|
||||
{
|
||||
public CCSWeaponBaseVDataAPI (IntPtr pointer) : base(pointer) {}
|
||||
|
||||
}
|
||||
@@ -36,14 +36,14 @@ public partial class CNetworkOriginCellCoordQuantizedVector : NativeObject
|
||||
|
||||
// m_vecX
|
||||
[SchemaMember("CNetworkOriginCellCoordQuantizedVector", "m_vecX")]
|
||||
public float X => Schema.GetDeclaredClass<float>(this.Handle, "CNetworkOriginCellCoordQuantizedVector", "m_vecX");
|
||||
public ref float X => ref Schema.GetRef<float>(this.Handle, "CNetworkOriginCellCoordQuantizedVector", "m_vecX");
|
||||
|
||||
// m_vecY
|
||||
[SchemaMember("CNetworkOriginCellCoordQuantizedVector", "m_vecY")]
|
||||
public float Y => Schema.GetDeclaredClass<float>(this.Handle, "CNetworkOriginCellCoordQuantizedVector", "m_vecY");
|
||||
public ref float Y => ref Schema.GetRef<float>(this.Handle, "CNetworkOriginCellCoordQuantizedVector", "m_vecY");
|
||||
|
||||
// m_vecZ
|
||||
[SchemaMember("CNetworkOriginCellCoordQuantizedVector", "m_vecZ")]
|
||||
public float Z => Schema.GetDeclaredClass<float>(this.Handle, "CNetworkOriginCellCoordQuantizedVector", "m_vecZ");
|
||||
public ref float Z => ref Schema.GetRef<float>(this.Handle, "CNetworkOriginCellCoordQuantizedVector", "m_vecZ");
|
||||
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@ public partial class CNetworkVelocityVector : NativeObject
|
||||
|
||||
// m_vecX
|
||||
[SchemaMember("CNetworkVelocityVector", "m_vecX")]
|
||||
public float X => Schema.GetDeclaredClass<float>(this.Handle, "CNetworkVelocityVector", "m_vecX");
|
||||
public ref float X => ref Schema.GetRef<float>(this.Handle, "CNetworkVelocityVector", "m_vecX");
|
||||
|
||||
// m_vecY
|
||||
[SchemaMember("CNetworkVelocityVector", "m_vecY")]
|
||||
public float Y => Schema.GetDeclaredClass<float>(this.Handle, "CNetworkVelocityVector", "m_vecY");
|
||||
public ref float Y => ref Schema.GetRef<float>(this.Handle, "CNetworkVelocityVector", "m_vecY");
|
||||
|
||||
// m_vecZ
|
||||
[SchemaMember("CNetworkVelocityVector", "m_vecZ")]
|
||||
public float Z => Schema.GetDeclaredClass<float>(this.Handle, "CNetworkVelocityVector", "m_vecZ");
|
||||
public ref float Z => ref Schema.GetRef<float>(this.Handle, "CNetworkVelocityVector", "m_vecZ");
|
||||
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@ public partial class CNetworkViewOffsetVector : NativeObject
|
||||
|
||||
// m_vecX
|
||||
[SchemaMember("CNetworkViewOffsetVector", "m_vecX")]
|
||||
public float X => Schema.GetDeclaredClass<float>(this.Handle, "CNetworkViewOffsetVector", "m_vecX");
|
||||
public ref float X => ref Schema.GetRef<float>(this.Handle, "CNetworkViewOffsetVector", "m_vecX");
|
||||
|
||||
// m_vecY
|
||||
[SchemaMember("CNetworkViewOffsetVector", "m_vecY")]
|
||||
public float Y => Schema.GetDeclaredClass<float>(this.Handle, "CNetworkViewOffsetVector", "m_vecY");
|
||||
public ref float Y => ref Schema.GetRef<float>(this.Handle, "CNetworkViewOffsetVector", "m_vecY");
|
||||
|
||||
// m_vecZ
|
||||
[SchemaMember("CNetworkViewOffsetVector", "m_vecZ")]
|
||||
public float Z => Schema.GetDeclaredClass<float>(this.Handle, "CNetworkViewOffsetVector", "m_vecZ");
|
||||
public ref float Z => ref Schema.GetRef<float>(this.Handle, "CNetworkViewOffsetVector", "m_vecZ");
|
||||
|
||||
}
|
||||
|
||||
@@ -50,4 +50,8 @@ public partial class CSmokeGrenadeProjectile : CBaseCSGrenadeProjectile
|
||||
[SchemaMember("CSmokeGrenadeProjectile", "m_fllastSimulationTime")]
|
||||
public ref float FllastSimulationTime => ref Schema.GetRef<float>(this.Handle, "CSmokeGrenadeProjectile", "m_fllastSimulationTime");
|
||||
|
||||
// m_bExplodeFromInferno
|
||||
[SchemaMember("CSmokeGrenadeProjectile", "m_bExplodeFromInferno")]
|
||||
public ref bool ExplodeFromInferno => ref Schema.GetRef<bool>(this.Handle, "CSmokeGrenadeProjectile", "m_bExplodeFromInferno");
|
||||
|
||||
}
|
||||
|
||||
@@ -12,15 +12,9 @@ public enum BloodType : uint
|
||||
ColorRed = 0x0,
|
||||
ColorYellow = 0x1,
|
||||
ColorGreen = 0x2,
|
||||
ColorBrightGreen = 0x3,
|
||||
EntityMech = 0x4,
|
||||
EntityAntlion = 0x5,
|
||||
EntityZombie = 0x6,
|
||||
EntityBlob = 0x7,
|
||||
EntityBlobFrozen = 0x8,
|
||||
ColorRedLVL2 = 0x9,
|
||||
ColorRedLVL3 = 0xA,
|
||||
ColorRedLVL4 = 0xB,
|
||||
ColorRedLVL5 = 0xC,
|
||||
ColorRedLVL6 = 0xD,
|
||||
ColorRedLVL2 = 0x3,
|
||||
ColorRedLVL3 = 0x4,
|
||||
ColorRedLVL4 = 0x5,
|
||||
ColorRedLVL5 = 0x6,
|
||||
ColorRedLVL6 = 0x7,
|
||||
}
|
||||
|
||||
@@ -17,4 +17,5 @@ public enum PreviewCharacterMode : uint
|
||||
WALKING = 0x6,
|
||||
TEAM_INTRO = 0x7,
|
||||
WINGMAN_INTRO = 0x8,
|
||||
BANNER = 0x9,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace CounterStrikeSharp.API.Core.Translations;
|
||||
|
||||
public static class LocalizerExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a localized string using the locale of the specified player.
|
||||
/// <remarks>Defaults to the server language if the player is invalid.</remarks>
|
||||
/// </summary>
|
||||
public static string ForPlayer(this IStringLocalizer localizer, CCSPlayerController? player, string key)
|
||||
{
|
||||
using WithTemporaryCulture temporaryCulture = new WithTemporaryCulture(player.GetLanguage());
|
||||
return localizer[key];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="ForPlayer(Microsoft.Extensions.Localization.IStringLocalizer,CounterStrikeSharp.API.Core.CCSPlayerController?,string)"/>
|
||||
/// </summary>
|
||||
public static string ForPlayer(this IStringLocalizer localizer, CCSPlayerController? player, string key, params object[] args)
|
||||
{
|
||||
using WithTemporaryCulture temporaryCulture = new WithTemporaryCulture(player.GetLanguage());
|
||||
return localizer[key, args];
|
||||
}
|
||||
}
|
||||
@@ -82,9 +82,9 @@ public static class VirtualFunctions
|
||||
new(GameData.GetSignature("CBasePlayerPawn_RemovePlayerItem"));
|
||||
public static Action<IntPtr, IntPtr> RemovePlayerItemVirtual = RemovePlayerItemFunc.Invoke;
|
||||
|
||||
public static MemoryFunctionVoid<IntPtr, IntPtr, int, short, short> StateChangedFunc =
|
||||
public static MemoryFunctionVoid<IntPtr, IntPtr, int, short, int> StateChangedFunc =
|
||||
new(GameData.GetSignature("StateChanged"));
|
||||
public static Action<IntPtr, IntPtr, int, short, short> StateChanged = StateChangedFunc.Invoke;
|
||||
public static Action<IntPtr, IntPtr, int, short, int> StateChanged = StateChangedFunc.Invoke;
|
||||
|
||||
public static MemoryFunctionVoid<IntPtr, int, long> NetworkStateChangedFunc = new(GameData.GetSignature("NetworkStateChanged"));
|
||||
public static Action<IntPtr, int, long> NetworkStateChanged = NetworkStateChangedFunc.Invoke;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,7 @@ public record SchemaFieldType
|
||||
this.Atomic = Atomic;
|
||||
this.Inner = Inner;
|
||||
|
||||
if (this.Name == "GameTime_t")
|
||||
if (this.Name == "GameTime_t" || this.Name == "CNetworkedQuantizedFloat")
|
||||
{
|
||||
this.Category = SchemaTypeCategory.Builtin;
|
||||
this.Name = "float32";
|
||||
@@ -99,7 +99,8 @@ public record SchemaFieldType
|
||||
{
|
||||
SchemaTypeCategory.Builtin => BuiltinToCsKeyword(Name),
|
||||
SchemaTypeCategory.Ptr => IsString
|
||||
? "string" : $"{Inner!.CsTypeName}?",
|
||||
? "string"
|
||||
: $"{Inner!.CsTypeName}?",
|
||||
SchemaTypeCategory.FixedArray => IsString
|
||||
? "string"
|
||||
: $"{Inner!.CsTypeName}[]",
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
/*
|
||||
* This file is part of CounterStrikeSharp.
|
||||
* CounterStrikeSharp is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* CounterStrikeSharp is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with CounterStrikeSharp. If not, see <https://www.gnu.org/licenses/>. *
|
||||
*/
|
||||
* This file is part of CounterStrikeSharp.
|
||||
* CounterStrikeSharp is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* CounterStrikeSharp is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with CounterStrikeSharp. If not, see <https://www.gnu.org/licenses/>. *
|
||||
*/
|
||||
|
||||
#include "core/coreconfig.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "core/log.h"
|
||||
#include "core/coreconfig.h"
|
||||
|
||||
namespace counterstrikesharp {
|
||||
|
||||
@@ -28,10 +30,12 @@ bool CCoreConfig::Init(char* conf_error, int conf_error_size)
|
||||
{
|
||||
std::ifstream ifs(std::string(m_sPath + ".json"));
|
||||
|
||||
if (!ifs) {
|
||||
if (!ifs)
|
||||
{
|
||||
std::ifstream exampleIfs(std::string(m_sPath + ".example.json"));
|
||||
|
||||
if (!exampleIfs) {
|
||||
if (!exampleIfs)
|
||||
{
|
||||
V_snprintf(conf_error, conf_error_size, "CoreConfig file not found.");
|
||||
return false;
|
||||
}
|
||||
@@ -46,14 +50,19 @@ bool CCoreConfig::Init(char* conf_error, int conf_error_size)
|
||||
|
||||
m_json = json::parse(ifs);
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
PublicChatTrigger = m_json.value("PublicChatTrigger", PublicChatTrigger);
|
||||
SilentChatTrigger = m_json.value("SilentChatTrigger", SilentChatTrigger);
|
||||
FollowCS2ServerGuidelines = m_json.value("FollowCS2ServerGuidelines", FollowCS2ServerGuidelines);
|
||||
PluginHotReloadEnabled = m_json.value("PluginHotReloadEnabled", PluginHotReloadEnabled);
|
||||
PluginAutoLoadEnabled = m_json.value("PluginAutoLoadEnabled", PluginAutoLoadEnabled);
|
||||
ServerLanguage = m_json.value("ServerLanguage", ServerLanguage);
|
||||
} catch (const std::exception& ex) {
|
||||
UnlockConCommands = m_json.value("UnlockConCommands", UnlockConCommands);
|
||||
UnlockConVars = m_json.value("UnlockConVars", UnlockConVars);
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
V_snprintf(conf_error, conf_error_size, "Failed to parse CoreConfig file: %s", ex.what());
|
||||
return false;
|
||||
}
|
||||
@@ -61,10 +70,7 @@ bool CCoreConfig::Init(char* conf_error, int conf_error_size)
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::string CCoreConfig::GetPath() const
|
||||
{
|
||||
return m_sPath;
|
||||
}
|
||||
const std::string CCoreConfig::GetPath() const { return m_sPath; }
|
||||
|
||||
bool CCoreConfig::IsTriggerInternal(std::vector<std::string> triggers, const std::string& message, std::string& prefix) const
|
||||
{
|
||||
@@ -90,4 +96,4 @@ bool CCoreConfig::IsPublicChatTrigger(const std::string& message, std::string& p
|
||||
{
|
||||
return IsTriggerInternal(PublicChatTrigger, message, prefix);
|
||||
}
|
||||
} // namespace counterstrikesharp
|
||||
} // namespace counterstrikesharp
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
/*
|
||||
* This file is part of CounterStrikeSharp.
|
||||
* CounterStrikeSharp is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* CounterStrikeSharp is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with CounterStrikeSharp. If not, see <https://www.gnu.org/licenses/>. *
|
||||
*/
|
||||
* This file is part of CounterStrikeSharp.
|
||||
* CounterStrikeSharp is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* CounterStrikeSharp is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with CounterStrikeSharp. If not, see <https://www.gnu.org/licenses/>. *
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/globals.h"
|
||||
#include <string>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "core/globals.h"
|
||||
|
||||
namespace counterstrikesharp {
|
||||
|
||||
class CCoreConfig
|
||||
@@ -31,6 +33,8 @@ class CCoreConfig
|
||||
bool PluginHotReloadEnabled = true;
|
||||
bool PluginAutoLoadEnabled = true;
|
||||
std::string ServerLanguage = "en";
|
||||
bool UnlockConCommands = true;
|
||||
bool UnlockConVars = true;
|
||||
|
||||
using json = nlohmann::json;
|
||||
CCoreConfig(const std::string& path);
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* This file is part of CounterStrikeSharp.
|
||||
* CounterStrikeSharp is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* CounterStrikeSharp is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with CounterStrikeSharp. If not, see <https://www.gnu.org/licenses/>. *
|
||||
*/
|
||||
|
||||
#include "core/engine_trace.h"
|
||||
|
||||
#include "core/log.h"
|
||||
|
||||
namespace counterstrikesharp {
|
||||
|
||||
CTraceFilterHitAll g_HitAllFilter;
|
||||
|
||||
bool CSimpleTraceFilter::ShouldHitEntity(CEntityInstance *pServerEntity, int contentsMask) {
|
||||
// int index = ExcIndexFromBaseHandle(pServerEntity->GetRefEHandle());
|
||||
// if (index == m_index_to_exclude)
|
||||
// return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
TraceType_t TraceFilterProxy::GetTraceType() const {
|
||||
auto nativeContext = fxNativeContext{};
|
||||
auto scriptContext = ScriptContextRaw(nativeContext);
|
||||
|
||||
m_cb_get_trace_type(&nativeContext);
|
||||
|
||||
return scriptContext.GetResult<TraceType_t>();
|
||||
}
|
||||
|
||||
bool TraceFilterProxy::ShouldHitEntity(CEntityInstance *pServerEntity, int contentsMask) {
|
||||
return true;
|
||||
// auto entity = ExcIndexFromBaseHandle(pServerEntity->GetRefEHandle());
|
||||
// if (entity < 0)
|
||||
// return false;
|
||||
//
|
||||
// auto nativeContext = fxNativeContext{};
|
||||
// auto scriptContext = ScriptContextRaw(nativeContext);
|
||||
//
|
||||
// scriptContext.Push(entity);
|
||||
// scriptContext.Push<int>(0);
|
||||
//
|
||||
// m_cb_should_hit_entity(&nativeContext);
|
||||
//
|
||||
// auto result = scriptContext.GetResult<bool>();
|
||||
//
|
||||
// CSSHARP_CORE_INFO("Received result {0} from `ShouldHitEntity`", result);
|
||||
//
|
||||
// return result;
|
||||
/*return result;
|
||||
return true;*/
|
||||
}
|
||||
|
||||
void TraceFilterProxy::SetShouldHitEntityCallback(CallbackT cb) { m_cb_should_hit_entity = cb; }
|
||||
|
||||
void TraceFilterProxy::SetGetTraceTypeCallback(CallbackT cb) { m_cb_get_trace_type = cb; }
|
||||
|
||||
} // namespace counterstrikesharp
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* This file is part of CounterStrikeSharp.
|
||||
* CounterStrikeSharp is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* CounterStrikeSharp is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with CounterStrikeSharp. If not, see <https://www.gnu.org/licenses/>. *
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <public/engine/IEngineTrace.h>
|
||||
|
||||
#include "scripting/callback_manager.h"
|
||||
|
||||
namespace counterstrikesharp {
|
||||
class TraceFilterProxy : public ITraceFilter {
|
||||
public:
|
||||
TraceFilterProxy() {}
|
||||
bool ShouldHitEntity(CEntityInstance *pServerEntity, int contentsMask);
|
||||
TraceType_t GetTraceType() const;
|
||||
|
||||
void SetShouldHitEntityCallback(CallbackT cb);
|
||||
void SetGetTraceTypeCallback(CallbackT cb);
|
||||
|
||||
private:
|
||||
CallbackT m_cb_should_hit_entity;
|
||||
CallbackT m_cb_get_trace_type;
|
||||
};
|
||||
|
||||
class CSimpleTraceFilter : public ITraceFilter {
|
||||
public:
|
||||
CSimpleTraceFilter(int index)
|
||||
: m_index_to_exclude(index) {}
|
||||
bool ShouldHitEntity(CEntityInstance *pServerEntity, int contentsMask);
|
||||
|
||||
TraceType_t GetTraceType() const { return TRACE_EVERYTHING; }
|
||||
|
||||
private:
|
||||
int m_index_to_exclude = -1;
|
||||
};
|
||||
|
||||
enum RayType { RayType_EndPoint, RayType_Infinite };
|
||||
|
||||
} // namespace counterstrikesharp
|
||||
@@ -35,7 +35,12 @@
|
||||
#include "pch.h"
|
||||
#include "dynohook/core.h"
|
||||
#include "dynohook/manager.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "dynohook/conventions/x64/x64MsFastcall.h"
|
||||
#else
|
||||
#include "dynohook/conventions/x64/x64SystemVcall.h"
|
||||
#endif
|
||||
|
||||
namespace counterstrikesharp {
|
||||
|
||||
@@ -275,8 +280,11 @@ void ValveFunction::AddHook(CallbackT callable, bool post)
|
||||
{
|
||||
dyno::HookManager& manager = dyno::HookManager::Get();
|
||||
dyno::Hook* hook = manager.hook((void*)m_ulAddr, [this] {
|
||||
return new dyno::x64SystemVcall(ConvertArgsToDynoHook(m_Args),
|
||||
static_cast<dyno::DataType>(this->m_eReturnType));
|
||||
#ifdef _WIN32
|
||||
return new dyno::x64MsFastcall(ConvertArgsToDynoHook(m_Args), static_cast<dyno::DataType>(this->m_eReturnType));
|
||||
#else
|
||||
return new dyno::x64SystemVcall(ConvertArgsToDynoHook(m_Args), static_cast<dyno::DataType>(this->m_eReturnType));
|
||||
#endif
|
||||
});
|
||||
g_HookMap[hook] = this;
|
||||
hook->addCallback(dyno::HookType::Post, (dyno::HookHandler*)&HookHandler);
|
||||
@@ -297,8 +305,11 @@ void ValveFunction::AddHook(CallbackT callable, bool post)
|
||||
void ValveFunction::RemoveHook(CallbackT callable, bool post) {
|
||||
dyno::HookManager& manager = dyno::HookManager::Get();
|
||||
dyno::Hook* hook = manager.hook((void*)m_ulAddr, [this] {
|
||||
return new dyno::x64SystemVcall(ConvertArgsToDynoHook(m_Args),
|
||||
static_cast<dyno::DataType>(this->m_eReturnType));
|
||||
#ifdef _WIN32
|
||||
return new dyno::x64MsFastcall(ConvertArgsToDynoHook(m_Args), static_cast<dyno::DataType>(this->m_eReturnType));
|
||||
#else
|
||||
return new dyno::x64SystemVcall(ConvertArgsToDynoHook(m_Args), static_cast<dyno::DataType>(this->m_eReturnType));
|
||||
#endif
|
||||
});
|
||||
g_HookMap[hook] = this;
|
||||
|
||||
@@ -313,4 +324,4 @@ void ValveFunction::RemoveHook(CallbackT callable, bool post) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace counterstrikesharp
|
||||
} // namespace counterstrikesharp
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "core/coreconfig.h"
|
||||
#include "core/log.h"
|
||||
#include "core/memory.h"
|
||||
#include "core/utils.h"
|
||||
@@ -64,7 +65,7 @@ json WriteTypeJson(json obj, CSchemaType* current_type)
|
||||
|
||||
if (atomicTType->m_pAtomicInfo != nullptr)
|
||||
{
|
||||
obj["outer"] = atomicTType->m_pAtomicInfo->m_pszName1;
|
||||
obj["outer"] = atomicTType->m_pAtomicInfo->m_pszName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ json WriteTypeJson(json obj, CSchemaType* current_type)
|
||||
auto fixedArrayType = static_cast<CSchemaType_FixedArray*>(current_type);
|
||||
obj["inner"] = WriteTypeJson(json::object(), fixedArrayType->m_pElementType);
|
||||
}
|
||||
else if (current_type->m_eTypeCategory == SCHEMA_TYPE_PTR)
|
||||
else if (current_type->m_eTypeCategory == SCHEMA_TYPE_POINTER)
|
||||
{
|
||||
auto ptrType = static_cast<CSchemaType_Ptr*>(current_type);
|
||||
obj["inner"] = WriteTypeJson(json::object(), ptrType->m_pObjectType);
|
||||
@@ -94,44 +95,47 @@ json WriteTypeJson(json obj, CSchemaType* current_type)
|
||||
|
||||
CON_COMMAND(dump_schema, "dump schema symbols")
|
||||
{
|
||||
std::vector<std::string> classNames;
|
||||
std::vector<std::string> enumNames;
|
||||
// Reading these from a static file since I cannot seem to get the
|
||||
// CSchemaSystemTypeScope->GetClasses() to return anything on linux.
|
||||
std::ifstream inputClasses(utils::GamedataDirectory() + "/schema_classes.txt");
|
||||
std::ifstream inputEnums(utils::GamedataDirectory() + "/schema_enums.txt");
|
||||
std::ofstream output(utils::GamedataDirectory() + "/schema.json");
|
||||
std::string line;
|
||||
|
||||
while (std::getline(inputClasses, line))
|
||||
{
|
||||
if (!line.empty() && line.back() == '\r')
|
||||
{
|
||||
line.pop_back();
|
||||
}
|
||||
classNames.push_back(line);
|
||||
}
|
||||
|
||||
while (std::getline(inputEnums, line))
|
||||
{
|
||||
if (!line.empty() && line.back() == '\r')
|
||||
{
|
||||
line.pop_back();
|
||||
}
|
||||
enumNames.push_back(line);
|
||||
}
|
||||
|
||||
CSchemaSystemTypeScope* pType = globals::schemaSystem->FindTypeScopeForModule(MODULE_PREFIX "server" MODULE_EXT);
|
||||
|
||||
auto index = pType->m_DeclaredClasses.m_Map.FirstInorder();
|
||||
std::vector<CSchemaClassInfo*> classes;
|
||||
do
|
||||
{
|
||||
classes.push_back(pType->m_DeclaredClasses.m_Map.Element(index)->m_pClassInfo);
|
||||
index = pType->m_DeclaredClasses.m_Map.NextInorder(index);
|
||||
} while (index != pType->m_DeclaredClasses.m_Map.InvalidIndex());
|
||||
|
||||
index = pType->m_DeclaredEnums.m_Map.FirstInorder();
|
||||
std::vector<CSchemaEnumInfo*> enums;
|
||||
do
|
||||
{
|
||||
enums.push_back(pType->m_DeclaredEnums.m_Map.Element(index)->m_pEnumInfo);
|
||||
index = pType->m_DeclaredEnums.m_Map.NextInorder(index);
|
||||
} while (index != pType->m_DeclaredEnums.m_Map.InvalidIndex());
|
||||
|
||||
pType = globals::schemaSystem->GlobalTypeScope();
|
||||
index = pType->m_DeclaredClasses.m_Map.FirstInorder();
|
||||
do
|
||||
{
|
||||
classes.push_back(pType->m_DeclaredClasses.m_Map.Element(index)->m_pClassInfo);
|
||||
index = pType->m_DeclaredClasses.m_Map.NextInorder(index);
|
||||
} while (index != pType->m_DeclaredClasses.m_Map.InvalidIndex());
|
||||
|
||||
index = pType->m_DeclaredEnums.m_Map.FirstInorder();
|
||||
do
|
||||
{
|
||||
enums.push_back(pType->m_DeclaredEnums.m_Map.Element(index)->m_pEnumInfo);
|
||||
index = pType->m_DeclaredEnums.m_Map.NextInorder(index);
|
||||
} while (index != pType->m_DeclaredEnums.m_Map.InvalidIndex());
|
||||
|
||||
json j;
|
||||
j["classes"] = json::object();
|
||||
j["enums"] = json::object();
|
||||
|
||||
for (const auto& line : classNames)
|
||||
for (const auto& pClassInfo : classes)
|
||||
{
|
||||
auto* pClassInfo = pType->FindDeclaredClass(line.c_str()).Get();
|
||||
if (!pClassInfo) continue;
|
||||
|
||||
short fieldsSize = pClassInfo->m_nFieldCount;
|
||||
SchemaClassFieldData_t* pFields = pClassInfo->m_pFields;
|
||||
|
||||
@@ -154,11 +158,8 @@ CON_COMMAND(dump_schema, "dump schema symbols")
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& line : enumNames)
|
||||
for (const auto& pEnumInfo : enums)
|
||||
{
|
||||
auto* pEnumInfo = pType->FindDeclaredEnum(line.c_str()).Get();
|
||||
if (!pEnumInfo) continue;
|
||||
|
||||
j["enums"][pEnumInfo->m_pszName] = json::object();
|
||||
j["enums"][pEnumInfo->m_pszName]["align"] = pEnumInfo->m_nSize;
|
||||
j["enums"][pEnumInfo->m_pszName]["items"] = json::array();
|
||||
@@ -203,6 +204,63 @@ void ConCommandManager::OnAllInitialized()
|
||||
|
||||
m_global_cmd.callback_pre = globals::callbackManager.CreateCallback("OnClientCommandGlobalPre");
|
||||
m_global_cmd.callback_post = globals::callbackManager.CreateCallback("OnClientCommandGlobalPost");
|
||||
|
||||
if (globals::coreConfig->UnlockConCommands)
|
||||
{
|
||||
UnlockConCommands();
|
||||
}
|
||||
|
||||
if (globals::coreConfig->UnlockConVars)
|
||||
{
|
||||
UnlockConVars();
|
||||
}
|
||||
}
|
||||
|
||||
static uint64 flagsToRemove = (FCVAR_HIDDEN | FCVAR_DEVELOPMENTONLY | FCVAR_MISSING0 | FCVAR_MISSING1 | FCVAR_MISSING2 | FCVAR_MISSING3);
|
||||
|
||||
void UnlockConVars()
|
||||
{
|
||||
int unhiddenConVars = 0;
|
||||
|
||||
ConVar* currentCvar = nullptr;
|
||||
ConVarHandle currentCvarHandle;
|
||||
currentCvarHandle.Set(0);
|
||||
|
||||
do
|
||||
{
|
||||
currentCvar = globals::cvars->GetConVar(currentCvarHandle);
|
||||
|
||||
currentCvarHandle.Set(currentCvarHandle.Get() + 1);
|
||||
|
||||
if (!currentCvar) continue;
|
||||
|
||||
if (!(currentCvar->flags & flagsToRemove)) continue;
|
||||
|
||||
currentCvar->flags &= ~flagsToRemove;
|
||||
unhiddenConVars++;
|
||||
} while (currentCvar);
|
||||
}
|
||||
|
||||
void UnlockConCommands()
|
||||
{
|
||||
int unhiddenConCommands = 0;
|
||||
|
||||
ConCommand* currentConCommand = nullptr;
|
||||
ConCommand* invalidConCommand = globals::cvars->GetCommand(ConCommandHandle());
|
||||
ConCommandHandle conCommandHandle;
|
||||
conCommandHandle.Set(0);
|
||||
|
||||
do
|
||||
{
|
||||
currentConCommand = globals::cvars->GetCommand(conCommandHandle);
|
||||
|
||||
conCommandHandle.Set(conCommandHandle.Get() + 1);
|
||||
|
||||
if (!currentConCommand || currentConCommand == invalidConCommand || !(currentConCommand->GetFlags() & flagsToRemove)) continue;
|
||||
|
||||
currentConCommand->RemoveFlags(flagsToRemove);
|
||||
unhiddenConCommands++;
|
||||
} while (currentConCommand && currentConCommand != invalidConCommand);
|
||||
}
|
||||
|
||||
void ConCommandManager::OnShutdown()
|
||||
|
||||
@@ -32,46 +32,52 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "core/globals.h"
|
||||
#include "core/global_listener.h"
|
||||
#include "scripting/script_engine.h"
|
||||
#include <string>
|
||||
#include "core/globals.h"
|
||||
#include "playerslot.h"
|
||||
#include "scripting/script_engine.h"
|
||||
|
||||
struct CaseInsensitiveComparator {
|
||||
bool operator()(const std::string& lhs, const std::string& rhs) const {
|
||||
return std::lexicographical_compare(
|
||||
lhs.begin(), lhs.end(),
|
||||
rhs.begin(), rhs.end(),
|
||||
[](char a, char b) { return std::tolower(a) < std::tolower(b); }
|
||||
);
|
||||
struct CaseInsensitiveComparator
|
||||
{
|
||||
bool operator()(const std::string& lhs, const std::string& rhs) const
|
||||
{
|
||||
return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), [](char a, char b) {
|
||||
return std::tolower(a) < std::tolower(b);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
namespace counterstrikesharp {
|
||||
|
||||
void UnlockConVars();
|
||||
void UnlockConCommands();
|
||||
|
||||
class ScriptCallback;
|
||||
|
||||
enum CommandCallingContext {
|
||||
enum CommandCallingContext
|
||||
{
|
||||
Console = 0,
|
||||
Chat = 1,
|
||||
};
|
||||
|
||||
class ConCommandInfo {
|
||||
class ConCommandInfo
|
||||
{
|
||||
friend class ConCommandManager;
|
||||
|
||||
public:
|
||||
ConCommandInfo();
|
||||
ConCommandInfo(bool bNoCallbacks);
|
||||
public:
|
||||
ConCommandInfo();
|
||||
ConCommandInfo(bool bNoCallbacks);
|
||||
~ConCommandInfo();
|
||||
|
||||
public:
|
||||
public:
|
||||
void HookChange(CallbackT callback, bool post);
|
||||
void UnhookChange(CallbackT callback, bool post);
|
||||
ScriptCallback* GetCallback() { return callback_pre; }
|
||||
|
||||
private:
|
||||
private:
|
||||
ConCommandRefAbstract p_cmd;
|
||||
ConCommand* command;
|
||||
ScriptCallback* callback_pre;
|
||||
@@ -79,10 +85,11 @@ private:
|
||||
bool server_only;
|
||||
};
|
||||
|
||||
class ConCommandManager : public GlobalClass {
|
||||
class ConCommandManager : public GlobalClass
|
||||
{
|
||||
friend class ConCommandInfo;
|
||||
|
||||
public:
|
||||
public:
|
||||
ConCommandManager();
|
||||
~ConCommandManager();
|
||||
void OnAllInitialized() override;
|
||||
@@ -95,15 +102,16 @@ public:
|
||||
bool RemoveValveCommand(const char* name);
|
||||
void Hook_DispatchConCommand(ConCommandHandle cmd, const CCommandContext& ctx, const CCommand& args);
|
||||
void Hook_DispatchConCommand_Post(ConCommandHandle cmd, const CCommandContext& ctx, const CCommand& args);
|
||||
HookResult ExecuteCommandCallbacks(const char* name, const CCommandContext& ctx,
|
||||
const CCommand& args, HookMode mode, CommandCallingContext callingContext);
|
||||
HookResult ExecuteCommandCallbacks(
|
||||
const char* name, const CCommandContext& ctx, const CCommand& args, HookMode mode, CommandCallingContext callingContext);
|
||||
|
||||
CommandCallingContext GetCommandCallingContext(CCommand* args);
|
||||
private:
|
||||
|
||||
private:
|
||||
std::vector<ConCommandInfo*> m_cmd_list;
|
||||
std::map<std::string, ConCommandInfo*, CaseInsensitiveComparator> m_cmd_lookup;
|
||||
std::map<const CCommand*, CommandCallingContext> m_cmd_contexts;
|
||||
ConCommandInfo m_global_cmd = ConCommandInfo(true);
|
||||
};
|
||||
|
||||
} // namespace counterstrikesharp
|
||||
} // namespace counterstrikesharp
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "core/log.h"
|
||||
#include "scripting/callback_manager.h"
|
||||
#include "vprof.h"
|
||||
|
||||
SH_DECL_HOOK2(IGameEventManager2, FireEvent, SH_NOATTRIB, 0, bool, IGameEvent*, bool);
|
||||
|
||||
@@ -211,6 +212,7 @@ bool EventManager::OnFireEvent(IGameEvent* pEvent, bool bDontBroadcast)
|
||||
pCallback->ScriptContext().Push(pEvent);
|
||||
pCallback->ScriptContext().Push(&override);
|
||||
|
||||
VPROF_BUDGET("CS#::OnFireEvent", "CS# Event Hooks");
|
||||
for (auto fnMethodToCall : pCallback->GetFunctions())
|
||||
{
|
||||
if (!fnMethodToCall) continue;
|
||||
@@ -257,6 +259,8 @@ bool EventManager::OnFireEventPost(IGameEvent* pEvent, bool bDontBroadcast)
|
||||
|
||||
if (pCallback)
|
||||
{
|
||||
VPROF_BUDGET("CS#::OnFireEventPost", "CS# Event Hooks");
|
||||
|
||||
auto pEventCopy = m_EventCopies.top();
|
||||
CSSHARP_CORE_TRACE("Pushing event `{}` pointer: {}, dont broadcast: {}, post: {}", pEventCopy->GetName(), (void*)pEventCopy,
|
||||
bDontBroadcast, true);
|
||||
|
||||
@@ -16,22 +16,23 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "core/coreconfig.h"
|
||||
#include "core/game_system.h"
|
||||
#include "core/gameconfig.h"
|
||||
#include "core/global_listener.h"
|
||||
#include "core/log.h"
|
||||
#include "core/coreconfig.h"
|
||||
#include "core/gameconfig.h"
|
||||
#include "core/game_system.h"
|
||||
#include "core/timer_system.h"
|
||||
#include "core/tick_scheduler.h"
|
||||
#include "core/utils.h"
|
||||
#include "core/managers/entity_manager.h"
|
||||
#include "core/tick_scheduler.h"
|
||||
#include "core/timer_system.h"
|
||||
#include "core/utils.h"
|
||||
#include "entity2/entitysystem.h"
|
||||
#include "igameeventsystem.h"
|
||||
#include "interfaces/cs2_interfaces.h"
|
||||
#include "iserver.h"
|
||||
#include "scripting/callback_manager.h"
|
||||
#include "scripting/dotnet_host.h"
|
||||
#include "scripting/script_engine.h"
|
||||
#include "entity2/entitysystem.h"
|
||||
#include "interfaces/cs2_interfaces.h"
|
||||
#include "tier0/vprof.h"
|
||||
|
||||
#define VERSION_STRING "v" BUILD_NUMBER " @ " GITHUB_SHA
|
||||
#define BUILD_TIMESTAMP __DATE__ " " __TIME__
|
||||
@@ -203,6 +204,7 @@ void CounterStrikeSharpMMPlugin::Hook_GameFrame(bool simulating, bool bFirstTick
|
||||
* true | game is ticking
|
||||
* false | game is not ticking
|
||||
*/
|
||||
VPROF_BUDGET("CS#::Hook_GameFrame", "CS# On Frame");
|
||||
globals::timerSystem.OnGameFrame(simulating);
|
||||
|
||||
std::vector<std::function<void()>> out_list(1024);
|
||||
|
||||
@@ -12,65 +12,68 @@
|
||||
* This sample plugin is public domain.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_
|
||||
#define _INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_
|
||||
#define VPROF_LEVEL 1
|
||||
|
||||
#include <ISmmPlugin.h>
|
||||
#include <functional>
|
||||
#include <iserver.h>
|
||||
#include <igameevents.h>
|
||||
#include <iplayerinfo.h>
|
||||
#include <sh_vector.h>
|
||||
#include <vector>
|
||||
#include "entitysystem.h"
|
||||
#include "concurrentqueue.h"
|
||||
#ifndef _INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_
|
||||
#define _INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_
|
||||
|
||||
#include <ISmmPlugin.h>
|
||||
#include <igameevents.h>
|
||||
#include <iplayerinfo.h>
|
||||
#include <iserver.h>
|
||||
#include <sh_vector.h>
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
#include "concurrentqueue.h"
|
||||
#include "entitysystem.h"
|
||||
|
||||
namespace counterstrikesharp {
|
||||
class ScriptCallback;
|
||||
|
||||
class CounterStrikeSharpMMPlugin : public ISmmPlugin, public IMetamodListener {
|
||||
public:
|
||||
bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late) override;
|
||||
bool Unload(char *error, size_t maxlen) override;
|
||||
bool Pause(char *error, size_t maxlen) override;
|
||||
bool Unpause(char *error, size_t maxlen) override;
|
||||
class CounterStrikeSharpMMPlugin : public ISmmPlugin, public IMetamodListener
|
||||
{
|
||||
public:
|
||||
bool Load(PluginId id, ISmmAPI* ismm, char* error, size_t maxlen, bool late) override;
|
||||
bool Unload(char* error, size_t maxlen) override;
|
||||
bool Pause(char* error, size_t maxlen) override;
|
||||
bool Unpause(char* error, size_t maxlen) override;
|
||||
void AllPluginsLoaded() override;
|
||||
|
||||
public: // hooks
|
||||
void OnLevelInit(char const *pMapName,
|
||||
char const *pMapEntities,
|
||||
char const *pOldLevel,
|
||||
char const *pLandmarkName,
|
||||
public: // hooks
|
||||
void OnLevelInit(char const* pMapName,
|
||||
char const* pMapEntities,
|
||||
char const* pOldLevel,
|
||||
char const* pLandmarkName,
|
||||
bool loadGame,
|
||||
bool background) override;
|
||||
void OnLevelShutdown() override;
|
||||
void Hook_GameFrame(bool simulating, bool bFirstTick, bool bLastTick);
|
||||
void Hook_StartupServer(const GameSessionConfiguration_t &config,
|
||||
ISource2WorldSession *,
|
||||
const char *);
|
||||
void AddTaskForNextFrame(std::function<void()> &&task);
|
||||
void Hook_StartupServer(const GameSessionConfiguration_t& config, ISource2WorldSession*, const char*);
|
||||
void AddTaskForNextFrame(std::function<void()>&& task);
|
||||
|
||||
void Hook_RegisterLoopMode(const char* pszLoopModeName, ILoopModeFactory *pLoopModeFactory, void **ppGlobalPointer);
|
||||
void Hook_RegisterLoopMode(const char* pszLoopModeName, ILoopModeFactory* pLoopModeFactory, void** ppGlobalPointer);
|
||||
IEngineService* Hook_FindService(const char* serviceName);
|
||||
|
||||
public:
|
||||
const char *GetAuthor() override;
|
||||
const char *GetName() override;
|
||||
const char *GetDescription() override;
|
||||
const char *GetURL() override;
|
||||
const char *GetLicense() override;
|
||||
const char *GetVersion() override;
|
||||
const char *GetDate() override;
|
||||
const char *GetLogTag() override;
|
||||
public:
|
||||
const char* GetAuthor() override;
|
||||
const char* GetName() override;
|
||||
const char* GetDescription() override;
|
||||
const char* GetURL() override;
|
||||
const char* GetLicense() override;
|
||||
const char* GetVersion() override;
|
||||
const char* GetDate() override;
|
||||
const char* GetLogTag() override;
|
||||
|
||||
private:
|
||||
private:
|
||||
moodycamel::ConcurrentQueue<std::function<void()>> m_nextTasks;
|
||||
};
|
||||
|
||||
static ScriptCallback *on_activate_callback;
|
||||
static ScriptCallback* on_activate_callback;
|
||||
extern CounterStrikeSharpMMPlugin gPlugin;
|
||||
|
||||
PLUGIN_GLOBALVARS();
|
||||
|
||||
#endif //_INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_
|
||||
}
|
||||
#endif //_INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_
|
||||
}
|
||||
|
||||
@@ -15,43 +15,48 @@
|
||||
*/
|
||||
|
||||
#include "scripting/callback_manager.h"
|
||||
#include "core/log.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "core/log.h"
|
||||
#include "vprof.h"
|
||||
|
||||
namespace counterstrikesharp {
|
||||
|
||||
ScriptCallback::ScriptCallback(const char* szName) : m_root_context(fxNativeContext{})
|
||||
{
|
||||
m_script_context_raw = ScriptContextRaw(m_root_context);
|
||||
m_name = std::string(szName);
|
||||
m_profile_name = "ScriptCallback::Execute::" + m_name;
|
||||
}
|
||||
|
||||
ScriptCallback::~ScriptCallback() { m_functions.clear(); }
|
||||
|
||||
void ScriptCallback::AddListener(CallbackT fnPluginFunction)
|
||||
{
|
||||
m_functions.push_back(fnPluginFunction);
|
||||
}
|
||||
void ScriptCallback::AddListener(CallbackT fnPluginFunction) { m_functions.push_back(fnPluginFunction); }
|
||||
|
||||
bool ScriptCallback::RemoveListener(CallbackT fnPluginFunction)
|
||||
{
|
||||
bool bSuccess = true;
|
||||
|
||||
m_functions.erase(std::remove(m_functions.begin(), m_functions.end(), fnPluginFunction),
|
||||
m_functions.end());
|
||||
m_functions.erase(std::remove(m_functions.begin(), m_functions.end(), fnPluginFunction), m_functions.end());
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
void ScriptCallback::Execute(bool bResetContext)
|
||||
{
|
||||
for (auto fnMethodToCall : m_functions) {
|
||||
if (fnMethodToCall) {
|
||||
VPROF_BUDGET(m_profile_name.c_str(), "CS# Script Callbacks");
|
||||
|
||||
for (auto fnMethodToCall : m_functions)
|
||||
{
|
||||
if (fnMethodToCall)
|
||||
{
|
||||
fnMethodToCall(&ScriptContextStruct());
|
||||
}
|
||||
}
|
||||
|
||||
if (bResetContext) {
|
||||
if (bResetContext)
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
@@ -71,8 +76,10 @@ ScriptCallback* CallbackManager::CreateCallback(const char* szName)
|
||||
|
||||
ScriptCallback* CallbackManager::FindCallback(const char* szName)
|
||||
{
|
||||
for (auto* pMarshal : m_managed) {
|
||||
if (strcmp(pMarshal->GetName().c_str(), szName) == 0) {
|
||||
for (auto* pMarshal : m_managed)
|
||||
{
|
||||
if (strcmp(pMarshal->GetName().c_str(), szName) == 0)
|
||||
{
|
||||
return pMarshal;
|
||||
}
|
||||
}
|
||||
@@ -82,18 +89,19 @@ ScriptCallback* CallbackManager::FindCallback(const char* szName)
|
||||
|
||||
void CallbackManager::ReleaseCallback(ScriptCallback* pCallback)
|
||||
{
|
||||
auto I = std::remove_if(m_managed.begin(), m_managed.end(),
|
||||
[pCallback](ScriptCallback* pI) { return pCallback == pI; });
|
||||
auto I = std::remove_if(m_managed.begin(), m_managed.end(), [pCallback](ScriptCallback* pI) {
|
||||
return pCallback == pI;
|
||||
});
|
||||
|
||||
if (I != m_managed.end())
|
||||
m_managed.erase(I, m_managed.end());
|
||||
if (I != m_managed.end()) m_managed.erase(I, m_managed.end());
|
||||
delete pCallback;
|
||||
}
|
||||
|
||||
bool CallbackManager::TryAddFunction(const char* szName, CallbackT fnCallable)
|
||||
{
|
||||
auto* pCallback = FindCallback(szName);
|
||||
if (pCallback) {
|
||||
if (pCallback)
|
||||
{
|
||||
pCallback->AddListener(fnCallable);
|
||||
return true;
|
||||
}
|
||||
@@ -104,7 +112,8 @@ bool CallbackManager::TryAddFunction(const char* szName, CallbackT fnCallable)
|
||||
bool CallbackManager::TryRemoveFunction(const char* szName, CallbackT fnCallable)
|
||||
{
|
||||
auto* pCallback = FindCallback(szName);
|
||||
if (pCallback) {
|
||||
if (pCallback)
|
||||
{
|
||||
return pCallback->RemoveListener(fnCallable);
|
||||
}
|
||||
|
||||
@@ -114,7 +123,8 @@ bool CallbackManager::TryRemoveFunction(const char* szName, CallbackT fnCallable
|
||||
void CallbackManager::PrintCallbackDebug()
|
||||
{
|
||||
CSSHARP_CORE_INFO("----CALLBACKS----");
|
||||
for (auto* pCallback : m_managed) {
|
||||
for (auto* pCallback : m_managed)
|
||||
{
|
||||
CSSHARP_CORE_INFO("{0} ({0})\n", pCallback->GetName().c_str(), 1);
|
||||
}
|
||||
}
|
||||
@@ -126,7 +136,8 @@ CallbackPair::CallbackPair()
|
||||
|
||||
CallbackPair::CallbackPair(bool bNoCallbacks)
|
||||
{
|
||||
if (!bNoCallbacks) {
|
||||
if (!bNoCallbacks)
|
||||
{
|
||||
pre = globals::callbackManager.CreateCallback("");
|
||||
post = globals::callbackManager.CreateCallback("");
|
||||
}
|
||||
@@ -138,4 +149,4 @@ CallbackPair::~CallbackPair()
|
||||
globals::callbackManager.ReleaseCallback(post);
|
||||
}
|
||||
|
||||
} // namespace counterstrikesharp
|
||||
} // namespace counterstrikesharp
|
||||
|
||||
@@ -43,6 +43,7 @@ class ScriptCallback
|
||||
private:
|
||||
std::vector<CallbackT> m_functions;
|
||||
std::string m_name;
|
||||
std::string m_profile_name;
|
||||
ScriptContextRaw m_script_context_raw;
|
||||
fxNativeContext m_root_context;
|
||||
};
|
||||
@@ -69,12 +70,11 @@ class CallbackPair
|
||||
CallbackPair();
|
||||
CallbackPair(bool bNoCallbacks);
|
||||
~CallbackPair();
|
||||
bool HasCallbacks() const
|
||||
{ return pre->GetFunctionCount() > 0 || post->GetFunctionCount() > 0; }
|
||||
bool HasCallbacks() const { return pre->GetFunctionCount() > 0 || post->GetFunctionCount() > 0; }
|
||||
|
||||
public:
|
||||
ScriptCallback* pre;
|
||||
ScriptCallback* post;
|
||||
};
|
||||
|
||||
} // namespace counterstrikesharp
|
||||
} // namespace counterstrikesharp
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
// clang-format off
|
||||
#include "mm_plugin.h"
|
||||
#include "core/engine_trace.h"
|
||||
#include "core/timer_system.h"
|
||||
#include "core/utils.h"
|
||||
#include "scripting/autonative.h"
|
||||
@@ -43,16 +42,12 @@ namespace counterstrikesharp {
|
||||
|
||||
const char* GetMapName(ScriptContext& script_context)
|
||||
{
|
||||
if (globals::getGlobalVars() == nullptr)
|
||||
return nullptr;
|
||||
if (globals::getGlobalVars() == nullptr) return nullptr;
|
||||
|
||||
return globals::getGlobalVars()->mapname.ToCStr();
|
||||
}
|
||||
|
||||
const char* GetGameDirectory(ScriptContext& script_context)
|
||||
{
|
||||
return strdup(Plat_GetGameDirectory());
|
||||
}
|
||||
const char* GetGameDirectory(ScriptContext& script_context) { return strdup(Plat_GetGameDirectory()); }
|
||||
|
||||
bool IsMapValid(ScriptContext& script_context)
|
||||
{
|
||||
@@ -60,26 +55,21 @@ bool IsMapValid(ScriptContext& script_context)
|
||||
return globals::engine->IsMapValid(mapname) != 0;
|
||||
}
|
||||
|
||||
float GetTickInterval(ScriptContext& script_context)
|
||||
{
|
||||
return globals::engine_fixed_tick_interval;
|
||||
}
|
||||
float GetTickInterval(ScriptContext& script_context) { return globals::engine_fixed_tick_interval; }
|
||||
|
||||
float GetCurrentTime(ScriptContext& script_context) { return globals::getGlobalVars()->curtime; }
|
||||
|
||||
int GetTickCount(ScriptContext& script_context) { return globals::getGlobalVars()->tickcount; }
|
||||
|
||||
float GetGameFrameTime(ScriptContext& script_context)
|
||||
{
|
||||
return globals::getGlobalVars()->frametime;
|
||||
}
|
||||
float GetGameFrameTime(ScriptContext& script_context) { return globals::getGlobalVars()->frametime; }
|
||||
|
||||
double GetEngineTime(ScriptContext& script_context) { return Plat_FloatTime(); }
|
||||
|
||||
int GetMaxClients(ScriptContext& script_context)
|
||||
{
|
||||
auto globalVars = globals::getGlobalVars();
|
||||
if (globalVars == nullptr) {
|
||||
if (globalVars == nullptr)
|
||||
{
|
||||
script_context.ThrowNativeError("Global Variables not initialized yet.");
|
||||
return -1;
|
||||
}
|
||||
@@ -144,83 +134,6 @@ float GetSoundDuration(ScriptContext& script_context)
|
||||
// attenuation, 0, flags, pitch, origin, direction);
|
||||
// }
|
||||
|
||||
Ray_t* CreateRay1(ScriptContext& script_context)
|
||||
{
|
||||
auto ray_type = script_context.GetArgument<RayType>(0);
|
||||
auto vec1 = script_context.GetArgument<Vector*>(1);
|
||||
auto vec2 = script_context.GetArgument<Vector*>(2);
|
||||
|
||||
Ray_t* pRay = new Ray_t;
|
||||
|
||||
if (ray_type == RayType_EndPoint) {
|
||||
pRay->Init(*vec1, *vec2);
|
||||
return pRay;
|
||||
} else if (ray_type == RayType_Infinite) {
|
||||
QAngle angles;
|
||||
Vector endVec;
|
||||
angles.Init(vec2->x, vec2->y, vec2->z);
|
||||
AngleVectors(angles, &endVec);
|
||||
|
||||
endVec.NormalizeInPlace();
|
||||
endVec = *vec1 + endVec * MAX_TRACE_LENGTH;
|
||||
|
||||
pRay->Init(*vec1, endVec);
|
||||
return pRay;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Ray_t* CreateRay2(ScriptContext& script_context)
|
||||
{
|
||||
auto vec1 = script_context.GetArgument<Vector*>(0);
|
||||
auto vec2 = script_context.GetArgument<Vector*>(1);
|
||||
auto vec3 = script_context.GetArgument<Vector*>(2);
|
||||
auto vec4 = script_context.GetArgument<Vector*>(3);
|
||||
|
||||
Ray_t* pRay = new Ray_t;
|
||||
pRay->Init(*vec1, *vec2, *vec3, *vec4);
|
||||
return pRay;
|
||||
}
|
||||
|
||||
void TraceRay(ScriptContext& script_context)
|
||||
{
|
||||
auto ray = script_context.GetArgument<Ray_t*>(0);
|
||||
auto pTrace = script_context.GetArgument<CGameTrace*>(1);
|
||||
auto trace_filter = script_context.GetArgument<ITraceFilter*>(2);
|
||||
auto flags = script_context.GetArgument<uint32_t>(3);
|
||||
|
||||
globals::engineTrace->TraceRay(*ray, flags, trace_filter, pTrace);
|
||||
}
|
||||
|
||||
CSimpleTraceFilter* NewSimpleTraceFilter(ScriptContext& script_context)
|
||||
{
|
||||
auto index_to_ignore = script_context.GetArgument<int>(0);
|
||||
|
||||
return new CSimpleTraceFilter(index_to_ignore);
|
||||
}
|
||||
|
||||
TraceFilterProxy* NewTraceFilterProxy(ScriptContext& script_context)
|
||||
{
|
||||
return new TraceFilterProxy();
|
||||
}
|
||||
|
||||
void TraceFilterProxySetTraceTypeCallback(ScriptContext& script_context)
|
||||
{
|
||||
auto trace_filter = script_context.GetArgument<TraceFilterProxy*>(0);
|
||||
auto callback = script_context.GetArgument<CallbackT>(1);
|
||||
|
||||
trace_filter->SetGetTraceTypeCallback(callback);
|
||||
}
|
||||
|
||||
void TraceFilterProxySetShouldHitEntityCallback(ScriptContext& script_context)
|
||||
{
|
||||
auto [trace_filter, callback] = script_context.GetArguments<TraceFilterProxy*, CallbackT>();
|
||||
trace_filter->SetShouldHitEntityCallback(callback);
|
||||
}
|
||||
|
||||
CGameTrace* NewTraceResult(ScriptContext& script_context) { return new CGameTrace(); }
|
||||
|
||||
double GetTickedTime(ScriptContext& script_context) { return globals::timerSystem.GetTickedTime(); }
|
||||
|
||||
void QueueTaskForNextFrame(ScriptContext& script_context)
|
||||
@@ -228,7 +141,9 @@ void QueueTaskForNextFrame(ScriptContext& script_context)
|
||||
auto func = script_context.GetArgument<void*>(0);
|
||||
|
||||
typedef void(voidfunc)(void);
|
||||
globals::mmPlugin->AddTaskForNextFrame([func]() { reinterpret_cast<voidfunc*>(func)(); });
|
||||
globals::mmPlugin->AddTaskForNextFrame([func]() {
|
||||
reinterpret_cast<voidfunc*>(func)();
|
||||
});
|
||||
}
|
||||
|
||||
void QueueTaskForNextWorldUpdate(ScriptContext& script_context)
|
||||
@@ -236,7 +151,9 @@ void QueueTaskForNextWorldUpdate(ScriptContext& script_context)
|
||||
auto func = script_context.GetArgument<void*>(0);
|
||||
|
||||
typedef void(voidfunc)(void);
|
||||
globals::serverManager.AddTaskForNextWorldUpdate([func]() { reinterpret_cast<voidfunc*>(func)(); });
|
||||
globals::serverManager.AddTaskForNextWorldUpdate([func]() {
|
||||
reinterpret_cast<voidfunc*>(func)();
|
||||
});
|
||||
}
|
||||
|
||||
void QueueTaskForFrame(ScriptContext& script_context)
|
||||
@@ -259,15 +176,19 @@ void* GetValveInterface(ScriptContext& scriptContext)
|
||||
auto [interfaceType, interfaceName] = scriptContext.GetArguments<InterfaceType, const char*>();
|
||||
|
||||
CreateInterfaceFn factoryFn;
|
||||
if (interfaceType == Server) {
|
||||
if (interfaceType == Server)
|
||||
{
|
||||
factoryFn = globals::ismm->GetServerFactory();
|
||||
} else if (interfaceType == Engine) {
|
||||
}
|
||||
else if (interfaceType == Engine)
|
||||
{
|
||||
factoryFn = globals::ismm->GetEngineFactory();
|
||||
}
|
||||
|
||||
auto foundInterface = globals::ismm->VInterfaceMatch(factoryFn, interfaceName);
|
||||
|
||||
if (foundInterface == nullptr) {
|
||||
if (foundInterface == nullptr)
|
||||
{
|
||||
scriptContext.ThrowNativeError("Could not find interface");
|
||||
}
|
||||
|
||||
@@ -280,33 +201,29 @@ void GetCommandParamValue(ScriptContext& scriptContext)
|
||||
auto paramType = scriptContext.GetArgument<DataType_t>(1);
|
||||
|
||||
int iContextIndex = 2;
|
||||
switch (paramType) {
|
||||
case DATA_TYPE_STRING:
|
||||
scriptContext.SetResult(CommandLine()->ParmValue(
|
||||
paramName, scriptContext.GetArgument<const char*>(iContextIndex)));
|
||||
return;
|
||||
case DATA_TYPE_INT:
|
||||
scriptContext.SetResult(
|
||||
CommandLine()->ParmValue(paramName, scriptContext.GetArgument<int>(iContextIndex)));
|
||||
return;
|
||||
case DATA_TYPE_FLOAT:
|
||||
scriptContext.SetResult(
|
||||
CommandLine()->ParmValue(paramName, scriptContext.GetArgument<float>(iContextIndex)));
|
||||
return;
|
||||
switch (paramType)
|
||||
{
|
||||
case DATA_TYPE_STRING:
|
||||
scriptContext.SetResult(CommandLine()->ParmValue(paramName, scriptContext.GetArgument<const char*>(iContextIndex)));
|
||||
return;
|
||||
case DATA_TYPE_INT:
|
||||
scriptContext.SetResult(CommandLine()->ParmValue(paramName, scriptContext.GetArgument<int>(iContextIndex)));
|
||||
return;
|
||||
case DATA_TYPE_FLOAT:
|
||||
scriptContext.SetResult(CommandLine()->ParmValue(paramName, scriptContext.GetArgument<float>(iContextIndex)));
|
||||
return;
|
||||
}
|
||||
|
||||
scriptContext.ThrowNativeError("Invalid param type");
|
||||
}
|
||||
|
||||
void PrintToServerConsole(ScriptContext& scriptContext) {
|
||||
void PrintToServerConsole(ScriptContext& scriptContext)
|
||||
{
|
||||
auto message = scriptContext.GetArgument<const char*>(0);
|
||||
|
||||
META_CONPRINT(message);
|
||||
}
|
||||
|
||||
CREATE_GETTER_FUNCTION(Trace, bool, DidHit, CGameTrace*, obj->DidHit());
|
||||
CREATE_GETTER_FUNCTION(TraceResult, CBaseEntity*, Entity, CGameTrace*, obj->m_pEnt);
|
||||
|
||||
REGISTER_NATIVES(engine, {
|
||||
ScriptEngine::RegisterNativeHandler("GET_GAME_DIRECTORY", GetGameDirectory);
|
||||
ScriptEngine::RegisterNativeHandler("GET_MAP_NAME", GetMapName);
|
||||
@@ -324,20 +241,6 @@ REGISTER_NATIVES(engine, {
|
||||
ScriptEngine::RegisterNativeHandler("GET_SOUND_DURATION", GetSoundDuration);
|
||||
// ScriptEngine::RegisterNativeHandler("EMIT_SOUND", EmitSound);
|
||||
|
||||
ScriptEngine::RegisterNativeHandler("NEW_SIMPLE_TRACE_FILTER", NewSimpleTraceFilter);
|
||||
ScriptEngine::RegisterNativeHandler("NEW_TRACE_RESULT", NewTraceResult);
|
||||
ScriptEngine::RegisterNativeHandler("TRACE_DID_HIT", TraceGetDidHit);
|
||||
ScriptEngine::RegisterNativeHandler("TRACE_RESULT_ENTITY", TraceResultGetEntity);
|
||||
|
||||
ScriptEngine::RegisterNativeHandler("NEW_TRACE_FILTER_PROXY", NewTraceFilterProxy);
|
||||
ScriptEngine::RegisterNativeHandler("TRACE_FILTER_PROXY_SET_TRACE_TYPE_CALLBACK",
|
||||
TraceFilterProxySetTraceTypeCallback);
|
||||
ScriptEngine::RegisterNativeHandler("TRACE_FILTER_PROXY_SET_SHOULD_HIT_ENTITY_CALLBACK",
|
||||
TraceFilterProxySetShouldHitEntityCallback);
|
||||
|
||||
ScriptEngine::RegisterNativeHandler("CREATE_RAY_1", CreateRay1);
|
||||
ScriptEngine::RegisterNativeHandler("CREATE_RAY_2", CreateRay2);
|
||||
ScriptEngine::RegisterNativeHandler("TRACE_RAY", TraceRay);
|
||||
ScriptEngine::RegisterNativeHandler("GET_TICKED_TIME", GetTickedTime);
|
||||
ScriptEngine::RegisterNativeHandler("QUEUE_TASK_FOR_NEXT_FRAME", QueueTaskForNextFrame);
|
||||
ScriptEngine::RegisterNativeHandler("QUEUE_TASK_FOR_NEXT_WORLD_UPDATE", QueueTaskForNextWorldUpdate);
|
||||
|
||||
@@ -21,55 +21,62 @@
|
||||
|
||||
namespace counterstrikesharp {
|
||||
|
||||
CREATE_GETTER_FUNCTION(Vector, float, Length, Vector *, obj->Length());
|
||||
CREATE_GETTER_FUNCTION(Vector, float, Length2D, Vector *, obj->Length2D());
|
||||
CREATE_GETTER_FUNCTION(Vector, float, LengthSqr, Vector *, obj->LengthSqr());
|
||||
CREATE_GETTER_FUNCTION(Vector, float, Length2DSqr, Vector *, obj->Length2DSqr());
|
||||
CREATE_GETTER_FUNCTION(Vector, float, IsZero, Vector *, obj->IsZero());
|
||||
CREATE_GETTER_FUNCTION(Vector, float, Length, Vector*, obj->Length());
|
||||
CREATE_GETTER_FUNCTION(Vector, float, Length2D, Vector*, obj->Length2D());
|
||||
CREATE_GETTER_FUNCTION(Vector, float, LengthSqr, Vector*, obj->LengthSqr());
|
||||
CREATE_GETTER_FUNCTION(Vector, float, Length2DSqr, Vector*, obj->Length2DSqr());
|
||||
CREATE_GETTER_FUNCTION(Vector, bool, IsZero, Vector*, obj->IsZero());
|
||||
|
||||
CREATE_GETTER_FUNCTION(Vector, float, X, Vector *, obj->x);
|
||||
CREATE_GETTER_FUNCTION(Vector, float, Y, Vector *, obj->y);
|
||||
CREATE_GETTER_FUNCTION(Vector, float, Z, Vector *, obj->z);
|
||||
CREATE_GETTER_FUNCTION(Vector, float, X, Vector*, obj->x);
|
||||
CREATE_GETTER_FUNCTION(Vector, float, Y, Vector*, obj->y);
|
||||
CREATE_GETTER_FUNCTION(Vector, float, Z, Vector*, obj->z);
|
||||
|
||||
CREATE_SETTER_FUNCTION(Vector, float, X, Vector *, obj->x = value);
|
||||
CREATE_SETTER_FUNCTION(Vector, float, Y, Vector *, obj->y = value);
|
||||
CREATE_SETTER_FUNCTION(Vector, float, Z, Vector *, obj->z = value);
|
||||
CREATE_SETTER_FUNCTION(Vector, float, X, Vector*, obj->x = value);
|
||||
CREATE_SETTER_FUNCTION(Vector, float, Y, Vector*, obj->y = value);
|
||||
CREATE_SETTER_FUNCTION(Vector, float, Z, Vector*, obj->z = value);
|
||||
|
||||
// TODO: These need to be cleared out somehow
|
||||
std::vector<Vector *> managed_vectors;
|
||||
std::vector<Vector*> managed_vectors;
|
||||
|
||||
Vector *VectorNew(ScriptContext &script_context) {
|
||||
Vector* VectorNew(ScriptContext& script_context)
|
||||
{
|
||||
auto vec = new Vector();
|
||||
managed_vectors.push_back(vec);
|
||||
return vec;
|
||||
}
|
||||
|
||||
// TODO: These need to be cleared out somehow
|
||||
std::vector<QAngle *> managed_angles;
|
||||
std::vector<QAngle*> managed_angles;
|
||||
|
||||
QAngle *AngleNew(ScriptContext &script_context) {
|
||||
QAngle* AngleNew(ScriptContext& script_context)
|
||||
{
|
||||
auto ang = new QAngle();
|
||||
managed_angles.push_back(ang);
|
||||
return ang;
|
||||
}
|
||||
|
||||
void NativeVectorAngles(ScriptContext &script_context) {
|
||||
auto vec = script_context.GetArgument<Vector *>(0);
|
||||
auto pseudoUpVector = script_context.GetArgument<Vector *>(1);
|
||||
auto outAngle = script_context.GetArgument<QAngle *>(2);
|
||||
void NativeVectorAngles(ScriptContext& script_context)
|
||||
{
|
||||
auto vec = script_context.GetArgument<Vector*>(0);
|
||||
auto pseudoUpVector = script_context.GetArgument<Vector*>(1);
|
||||
auto outAngle = script_context.GetArgument<QAngle*>(2);
|
||||
|
||||
if (!pseudoUpVector) {
|
||||
if (!pseudoUpVector)
|
||||
{
|
||||
VectorAngles(*vec, *outAngle);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
VectorAngles(*vec, *pseudoUpVector, *outAngle);
|
||||
}
|
||||
}
|
||||
|
||||
void NativeAngleVectors(ScriptContext &script_context) {
|
||||
auto vec = script_context.GetArgument<QAngle *>(0);
|
||||
auto fwd = script_context.GetArgument<Vector *>(1);
|
||||
auto right = script_context.GetArgument<Vector *>(2);
|
||||
auto up = script_context.GetArgument<Vector *>(3);
|
||||
void NativeAngleVectors(ScriptContext& script_context)
|
||||
{
|
||||
auto vec = script_context.GetArgument<QAngle*>(0);
|
||||
auto fwd = script_context.GetArgument<Vector*>(1);
|
||||
auto right = script_context.GetArgument<Vector*>(2);
|
||||
auto up = script_context.GetArgument<Vector*>(3);
|
||||
|
||||
AngleVectors(*vec, fwd, right, up);
|
||||
}
|
||||
@@ -92,6 +99,6 @@ REGISTER_NATIVES(vector, {
|
||||
ScriptEngine::RegisterNativeHandler("VECTOR_LENGTH_2D", VectorGetLength2D);
|
||||
ScriptEngine::RegisterNativeHandler("VECTOR_LENGTH_SQR", VectorGetLengthSqr);
|
||||
ScriptEngine::RegisterNativeHandler("VECTOR_LENGTH_2D_SQR", VectorGetLength2DSqr);
|
||||
ScriptEngine::RegisterNativeHandler("VECTOR_IS_ZERO", VectorGetLengthSqr);
|
||||
ScriptEngine::RegisterNativeHandler("VECTOR_IS_ZERO", VectorGetIsZero);
|
||||
})
|
||||
} // namespace counterstrikesharp
|
||||
} // namespace counterstrikesharp
|
||||
|
||||
Reference in New Issue
Block a user