summaryrefslogtreecommitdiffstats
path: root/src/studio.cpp (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Hooks: central vtable install with restore supportsalmonik36 hours1-22/+22
| | | | | | | | | Move vtable patching into hooks.cpp: one call clones the table, validates every slot, records the originals and installs the clone. Installs happen from the setup, game and paint threads, so the bookkeeping is mutex-protected. Client, CInput, IVModelRender, IStudioRender and ISurface all use it, and hooks_restore_all() can now put every interface back (previously impossible).
* Chams: leave engine-forced material passes alonesalmonik36 hours1-1/+23
| | | | | | | | | | | Shadow-depth and reflection passes call DrawModelExecute with a material already forced via IVModelRender::ForcedMaterialOverride. Chams could not tell that apart from a free draw, substituted its own material (putting chams into the shadow map) and then cleared the override to null, which broke the shadow material for every model drawn afterwards. Hook slot 1 as a tracker so the current forced material is known, and skip the chams substitution whenever one is active.
* Fix audit findings: crash safety, correctness, rendering, performancesalmonik36 hours1-15/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Crash/UB: - gate every hook behind an init-stage flag until config/surface/input are ready - publish module maps as immutable atomic snapshots instead of reallocating shared vectors under unlocked readers - validate the %ebp walk in the RandomSeed/RandomFloat hooks against the stack - bounds-check every RecvTable/RecvProp/string dereference with module_range() - preserve the Itanium vtable header when cloning (client, CInput, model render, studio render) - reject negative usercmd sequence numbers; guard config_load against a null section target; cap the bone parent walk; check mprotect; drop PROT_EXEC on the GOT patch; absorb server.so .bss tail Correctness: - filter dormant entities across ESP, aimbot, triggerbot, melee, items and projectiles (slot self-tested against the local player) - reset the server-health latch per map and only latch on valid model indices - bone cache sized for the 128-target scan; set valid=false on every failure; head_position keeps searching past an invalid bone - vischeck steps past glass by probing until clear, and ignores entities owned by the target (held weapons, bone followers) - aimbot: maxs no longer disables it, AABB-aware FOV prefilter, lock hysteresis, lead point re-checked for FOV and visibility - spread: seed hook arms on the no-spread toggle alone; engine toggle only controls the RandomFloat zeroing - resolve m_hOwnerEntity/m_hOwner; NPC lead velocity from the server entity - vector_angles pitch range, point_ground normal test, underwater jump+duck no longer skips combat, semi-auto press/release edge for synthetic fire - item/projectile markers and blast rings refresh origin per frame while discovery stays at 10 Hz; trajectory uses the real m_DmgRadius and honours the blast-radius toggle Rendering/GUI: - one overlay draw per engine frame (FRAME_RENDER_START boundary), fixing alpha stacking and the speed-graph flicker - clipped lines/outlines and ellipsised text instead of drawing past the content pane or shifting over neighbours - dropdown dismissal consumes the click; hover ignores hidden controls - chams: reset AlphaModulate, reference shared materials once, restore prop tint colour; fonts created once per handle - projection uses Source's 4:3 aspect scaling and roll; screen size refreshed each frame; FOV circle gated on the aim toggles, not the bind Performance: - TTL caches for NPC relation, friendly/neutral and damage class - model names memoised per model index - entity pointer -> index cache for the triggerbot (was a 4096-slot walk/tick) Build: - real Makefile with -MMD dependency tracking, debug/release objects and an always-relink rule; build.sh kept as a thin wrapper
* Chams: working alpha via RenderView blend and a custom VMTsalmonik3 days1-8/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | Testing on :99 showed the material $alpha path is a dead end: UnlitGeneric takes translucency from the base texture/vertex alpha, and the debug materials have neither. Follow Amalgam: apply alpha with IVRenderView::SetBlend (VEngineRenderView014 slot 4) around the model draw, saving/restoring it. To have something translucent to blend, write a tiny UnlitGeneric VMT with $model 1 + $translucent 1 + a white base texture to <game>/<mod>/materials/hl2hake/translucent.vmt (plus a custom/ copy). It is written by a preload constructor so it exists before the material system scans its search paths, then loaded once with FindMaterial. Styles 0/3/4/6 use it when the colour alpha is below 255. Also: - Visible wireframe + through-wall: fill the visible silhouette first so the through-wall pass cannot show in the wireframe gaps, then draw a brightened contour. Style 6 is now "Solid + contour" (recolour + visible edges). - find_modules builds local snapshots and publishes them under a mutex; the setup thread and the server retry could reset the shared vectors live and crash at startup. Verified on :99: Solid + alpha 64 renders a see-through viewmodel, Solid + contour shows a blue fill with bright blue contours, Additive is a translucent coloured glow and Fullbright is a white additive glow.
* Chams: real additive material, addref cached materialssalmonik3 days1-33/+13
| | | | | | | | | | | | | | | Testing on :99 showed ADDITIVE on debugtranslucentsinglecolor did nothing and alpha lost the colour, because that VMT has no $translucent and the engine bound an unreferenced material. Use debug/debugtranslucentmodelhulls (VMT has $additive 1 + $color) for Additive/Fullbright, and addref every preloaded material so the engine stops warning "bad reference count 0" and applies $color/ColorModulate. Verified: Solid is flat blue, Additive is a translucent coloured glow, Fullbright is a white additive glow, White is opaque white. Also drop the viewmodel additive base (the solid material is opaque, so it made an opaque blob) and never call FindMaterial inside DrawModelExecute. Document that the alpha control is stored but has no effect until a custom $translucent model VMT is added.
* Chams: make Fullbright a white-hot additive glowsalmonik3 days1-11/+1
| | | | | | | | Fullbright was additive with the chosen colour lifted only 25% toward white, which on a dark scene looked almost identical to Solid/Flat. Force white for the Fullbright colour so the additive pass reads as a distinctly brighter, white-hot glow; the faint translucent base still gives it a silhouette on bright backgrounds.
* Chams: per-colour alpha and a softer viewmodel additive basesalmonik3 days1-9/+26
| | | | | | | | | | | - Colour picker gains an optional alpha bar (checkerboard preview, #RRGGBBAA readout); add_color_alpha is used for the chams colours. Chams colours are now r,g,b,a and chams_apply sets $alpha plus MATERIAL_VAR_TRANSLUCENT when alpha < 255. Config stores vis_a / inv_a / vm a. - The additive viewmodel base is now a faint translucent tint (alpha/8) instead of an opaque fill, so additive/Fullbright stay see-through and the viewmodel no longer becomes a solid blob. Fullbright whitening reduced to 25% so blue stays blue instead of turning lavender.
* Chams: keep additive viewmodel visible on bright backgroundssalmonik3 days1-0/+12
| | | | | | | | Viewmodels are collated as RENDER_GROUP_VIEW_MODEL_OPAQUE, so an additive forced material can vanish against a bright sky/wall (additive adds nothing to an already-bright surface). Draw a dim opaque solid base before the additive viewmodel pass so the first-person model always has a visible silhouette; the additive layer still provides the glow.
* Chams: use the model solid shader for flat, drop vgui/whitesalmonik3 days1-12/+2
| | | | | | | vgui/white is an UnlitGeneric with $vertexcolor/$vertexalpha, no basetexture and no $model, so it renders nothing on model vertices; Flat was invisible on the viewmodel and would be invisible on NPCs too. Flat now uses the solid model shader with the FLAT flag. Remove the vgui/white probe.
* Chams: fix the flat viewmodel, glow outline and fullbright stylessalmonik3 days1-9/+29
| | | | | | | | | - Flat uses the solid model shader with the FLAT flag on the viewmodel; vgui/white does not draw skinned models and made the hands vanish. - Glow outline draws its wireframe contour with ZNEARER and a brightened colour, so the solid base no longer hides the contour. - Fullbright is now additive + self-illuminated with the colour lifted toward white, so it reads differently from Solid and Additive glow.
* Chams: per-relationship, visible/invisible styles and viewmodelsalmonik3 days1-37/+57
| | | | | | | | | | | | - Hostile/neutral/friendly each have independent visible and through-wall settings: enable, style and colour. Viewmodel has its own enable/style/colour. - Styles: Flat, Wireframe, Additive, Solid, White, Fullbright, Glow outline. Additive uses the model solid material + ADDITIVE flag (the VGUI additive was invisible on NPCs). White/fullbright are solid-based, so the viewmodel no longer disappears/checkerboards. Glow outline adds a wireframe contour pass for depth. - Config: [chams] active/bind, [chams_hostile|neutral|friendly] vis/inv settings, [chams_vm]. GUI sections for each group.
* Chams: apply model-safe styles to the viewmodelsalmonik3 days1-5/+11
| | | | | | | The viewmodel was always solid. Use the selected style material for the model-debug styles (wireframe/solid/white/fullbright); Flat and Additive use the solid model shader with the same flags because their VGUI materials do not draw skinned models.
* Chams: use the loaded VGUI whites for flat and additivesalmonik3 days1-2/+2
| | | | | | | models/debug/debugwhite is EP2-only and additivevertexcolorvertexalpha is not loadable in the base game. Preload vgui/white for Flat and vgui/white_additive for Additive; the other debug styles were already found. The viewmodel keeps the solid model shader.
* Chams: preload style materials outside the model drawsalmonik3 days1-15/+50
| | | | | | | | | FindMaterial inside DrawModelExecute did not load the style VMTs, so every style fell back to the solid material. Preload the six style materials from outer_draw (throttled) and have the render hook use the cached pointers only. world_find_material now returns only the exact requested material; the caller falls back to the solid style. Add a vgui/white probe and per-style preload logs.
* Chams: style flags on the resident debug materialsalmonik3 days1-19/+34
| | | | | | | | The base game only has debug/debugtranslucentsinglecolor resident, so the other debug VMTs silently fell back to it and every style looked flat. Use that material for every style and apply material flags instead: FLAT, WIREFRAME, ADDITIVE, and FLAT|SELFILLUM for fullbright; white forces the colour. Flags are cleared after the draw.
* Chams: model-safe styles and a dedicated viewmodel materialsalmonik3 days1-6/+16
| | | | | | | | | VGUI/white materials do not draw skinned models, so every viewmodel style except the model debug one made the hands/weapon disappear. Use model debug materials for all styles: wireframe, additive vertex colour, translucent single colour, translucent vertex colour, MRM fullbright. The viewmodel always uses debug/debugtranslucentsinglecolor. A missing style now falls back to that material instead of vgui/white.
* Chams: material styles and viewmodel supportsalmonik3 days1-20/+38
| | | | | | | | | - Material selector 0..4: debugwhite, debug wireframe (ignorez), vgui white_additive, debugtranslucentsinglecolor, vgui/white; cached per index with a debugwhite fallback. - Add "Viewmodel (hands/weapon)" toggle; viewmodel entities (class contains viewmodel or model path /v_...) get a normal-depth chams pass. - [chams] gains viewmodel= and material=.
* Chams: quiet material lookup, accept any fallback by namesalmonik3 days1-4/+2
| | | | | | FindMaterial diagnostics are no longer logged per attempt; the chosen material is logged once. Accept any candidate name returned by FindMaterial, not just debugwhite.
* Chams: tint through $color/$color2 and log the chosen materialsalmonik3 days1-6/+19
| | | | | | ColorModulate alone left the forced material white. Also set the shader's $color and $color2 vars (IMaterialVar SetVecValue 3-float) and restore them to white after the draw. Log which fallback material was selected.
* Add chamssalmonik3 days1-0/+98
| | | | | | | | | | | | - Hook IVModelRender::DrawModelExecute (VEngineModel016 slot 19) and force models/debug/debugwhite for NPC models, identified by ModelRenderInfo_t::entity_index. - Two passes: MATERIAL_VAR_IGNOREZ through walls, then normal depth, with IMaterial::ColorModulate for the configured colour; restore the shared material's flag/colour afterwards. - Material lookup via the IMaterialSystem list, FindMaterial fallback. - New Chams feature/card with Through walls and colour; [chams] config. - Remove the temporary ammo/projectile/fuse diagnostics.
* Studio: drop the prop draw diagnosticsalmonik4 days1-7/+0
| | | | | Props render correctly with all seven DrawModel arguments forwarded; the per-draw model/client/origin log is no longer needed.
* Props: forward DrawModel's modelOrigin argumentsalmonik4 days1-3/+16
| | | | | | | | | | | | DrawModel takes (this, results, info, boneToWorld, flexWeights, flexDelayedWeights, const Vector &modelOrigin, flags). The hook dropped modelOrigin, so flags landed in its slot and the real flags were read from caller stack garbage. studiorender.so 0x83ad0 reads 0x20(%ebp) as the modelOrigin pointer and 0x24(%ebp) as the flags; passing both restores the engine's normal draw. This is the cause of the intermittent (~50%) checkerboard/error-material props: the draw was being issued with a garbage flag word.
* Props: remove studio diagnostics; document the prop tint pathsalmonik4 days1-20/+0
| | | | | | | Drop the temporary DrawModel/SetColor logs now that the prop tint works, and document the IStudioRender hook layout, the short model-name format used for prop detection, the SetColor-before-DrawModel ordering, and why prop materials cannot be tinted directly.
* Props: force colour inside prop DrawModel; no prop material tintsalmonik4 days1-1/+5
| | | | | | | The engine calls SetColorModulation(1,1,1) immediately before DrawModel, so the in-draw flag never sees it. Set the prop colour at the start of the prop DrawModel hook instead (colour only, not alpha), and stop applying ColorModulate to prop materials so only one mechanism touches props.
* Props: only substitute colour during studio draws (no forced set)salmonik4 days1-19/+11
| | | | | | | | | The forced SetColorModulation/SetAlphaModulation calls before DrawModel are what turned matched props into the error material and destabilised the material system. Mirror Amalgam instead: set a "drawing a prop" flag around the original draw and only substitute the colour when the engine itself calls SetColorModulation during that draw. Log those calls for the first few draws to see whether the engine applies modulation inside DrawModel at all.
* Props: disable StudioRender hooks, fix m_clrRender offsetsalmonik4 days1-0/+4
| | | | | | | | | | | | Hooking IStudioRender's draw/setter slots made matched props render the error material and then crashed the material system ("debug/modelstats has bad reference count 0 when being bound"). Keep the hook code for reference but do not install it. Fix the m_clrRender netvar resolution: the walk picked an embedded table entry at offset 0, so the earlier entity writes stomped entity vtables. Only accept offsets inside C_BaseEntity (0x20..0x2000), then write the prop colour there for models/props entities. Restore white when disabled.
* Props: match the studio model name formatsalmonik4 days1-1/+12
| | | | | | | | studiohdr_t::name is not "models/props/...". In this build it is the short model name with Windows separators, e.g. "props_junk\wood_crate002a.mdl" (the models/ prefix is stripped). Normalise the prefix/separators and match props/, props\ and props_ (excluding the distant props_skybox set), so the studio hooks actually recognise prop draws.
* Diagnose prop tinting: log prop materials and studio draw model namessalmonik4 days1-3/+10
| | | | | | | Log the first crate materials the tint pass modifies and the first DrawModel/ DrawModelArray calls with their model names, to see whether the crates are brush materials that were never reached, materials loaded after the tint was applied, or a studio draw path that is still missed.
* Props: tint through DrawModel/DrawModelArray; drop m_clrRender writessalmonik4 days1-9/+51
| | | | | | | | | | | m_clrRender resolved to offset 0 in this build; writing it stomped entity vtables instead of tinting anything. Remove that path. The static-prop logging showed DrawModelStaticProp is never called for these props, so hook the other studio draw entries as well: DrawModel (29) for entity models and DrawModelArray (46, the instanced static-prop path). Both read the model name from DrawModelInfo_t::m_pStudioHdr and force the prop colour for models/props* draws.
* World tint: include props/ materials; log static studio drawssalmonik4 days1-1/+13
| | | | | | | | | Static props commonly use brush-style props/... materials (props/woodcrate001a is LightmappedGeneric), so the models/props-only filter missed them. Include the props/ prefix. Also log the first static prop studio draws and a 500-draw summary so we can see whether the engine draws props through DrawModelStaticProp at all.
* World tint: tint map-static props through IStudioRendersalmonik4 days1-0/+178
Most of the crates are prop_static, which have no client entity, so writing m_clrRender only reached the three dynamic ones. Hook the StudioRender interface (VStudioRender025) on the interface object's vtable: substitute the prop colour in SetColorModulation/SetAlphaModulation while DrawModelStaticProp is drawing a models/props model, and set the modulation explicitly before the original draw in case the engine sets it just before the call. Vtable indices verified by disassembling CStudioRenderContext: 27 = three float stores from the argument pointer, 28 = one float, 30 = the DrawModelInfo_t-drawing entry with three arguments (the 2013 SDK header lists these slots five positions earlier in this build).