summaryrefslogtreecommitdiffstats
path: root/src/world.cpp (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Fix audit findings: crash safety, correctness, rendering, performancesalmonik36 hours1-3/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: preload style materials outside the model drawsalmonik3 days1-14/+1
| | | | | | | | | 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: model-safe styles and a dedicated viewmodel materialsalmonik3 days1-1/+2
| | | | | | | | | 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: exact material styles, GUI dropdown, viewmodel hookupsalmonik3 days1-32/+41
| | | | | | | | | | - world_find_material now tries the exact requested style first (resident, then FindMaterial) before falling back to debugwhite/vgui white. The old candidate scan returned vgui/white for every style, so all materials looked flat. - Add a real CK_DROPDOWN control (overlay list, outside-click close, config save) and use it for the Chams material selector. - Chams viewmodel toggle included in config/UI.
* Chams: quiet material lookup, accept any fallback by namesalmonik3 days1-7/+9
| | | | | | 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-1/+3
| | | | | | 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.
* Chams: material fallbacks and FindMaterial diagnosticssalmonik3 days1-10/+31
| | | | | | | models/debug/debugwhite is not resident and FindMaterial did not return it. Log each FindMaterial attempt and fall back to debugwhite2/3, vgui/white, debug/debugtranslucentsinglecolor and the ignorez debug wireframe material so chams can still render.
* Add chamssalmonik3 days1-0/+47
| | | | | | | | | | | | - 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.
* Props: force colour inside prop DrawModel; no prop material tintsalmonik4 days1-7/+6
| | | | | | | 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.
* Diagnose prop tinting: log prop materials and studio draw model namessalmonik4 days1-0/+5
| | | | | | | 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.
* World tint: include props/ materials; log static studio drawssalmonik4 days1-1/+5
| | | | | | | | | 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.
* Skybox image: swap red/blue in the uploaded texturesalmonik4 days1-0/+9
| | | | | | The procedural texture reaches the sky sampler with the red and blue channels exchanged (blue sky rendered orange/yellow), while the game's own textures are correct. Swap R/B in the decoded buffer so the sampled colours match the PNG.
* Skybox image: apply HDR colour compensation where materials existsalmonik4 days1-27/+32
| | | | | | | | | | Move the HDR decision from texture load to apply_sky_texture, after the sky materials have definitely been enumerated: compensate the pixel buffer (sRGB -> linear, alpha = 1/8) and re-download the procedural texture before assigning it. The earlier load-time check ran before the materials were visible and silently chose the LDR path, so the 8x HDR decode stayed. Also log the compensation explicitly so the chosen path is visible.
* Skybox image: recognise Sky_HDR_DX9 as the HDR sky shadersalmonik4 days1-1/+5
| | | | | | The material reports shader "Sky_HDR_DX9", not "sky", so the linear/alpha compensation was never applied and the raw sRGB image was scaled by the HDR decode's 8x. Match the Sky_HDR prefix so the compensation path is used.
* Skybox image: match HDR sky colour decodesalmonik4 days1-5/+61
| | | | | | | | | | | | | The HDR "sky" shader samples the compressed texture as rgb *= alpha, multiplies by 8, then converts linear->sRGB for display. Feeding it the raw sRGB image produced the blown-out / oversaturated sky. When the map uses the HDR sky shader, pre-convert the image to linear and set alpha to 1/8 so the 8x scale cancels and the final linear->sRGB conversion restores the original colours. For LDR (UnlitGeneric) materials, create the texture with TEXTUREFLAGS_SRGB so the normal sRGB sampling is used. The first sky material's shader name is logged for confirmation.
* Skybox image: drop Refresh/SetUndefined (crash after apply)salmonik4 days1-22/+11
| | | | | | | | | | | | | | | The last crash happened after "applied", in materialsystem while the renderer walked a shader-parameter list that contained a null vtable entry. That points at the Refresh()/SetUndefined experiment: undefining $hdrcompressedtexture while the sky shader's static combo still expected it (and rebuilding state mid-level) left a broken material. Set the texture on $basetexture/$hdrbasetexture/$hdrcompressedtexture (and the 0/1/2 variants) and do neither SetUndefined nor Refresh: the visible-path material binds its base texture dynamically, which is what made the earlier black sky (empty 798x798 VTF) appear black at all. Log the first sky material's shader name so we know whether this map uses the LDR (UnlitGeneric) or HDR (sky) path.
* Skybox image: power-of-two resize; upload at FRAME_RENDER_STARTsalmonik4 days1-0/+58
| | | | | | | | | | | | | - The material system rejects textures whose dimensions are not multiples of 4 ("Image dimensions must be multiple of 4!"), so scale the decoded image to the next power of two (bilinear). 798x798 -> 1024x1024. The invalid VTF also crashed the renderer after the apply. - Move skybox_update() out of the VGUI paint hook into the FRAME_RENDER_START FrameStageNotify stage. ITexture::Download only regenerates bits when the material system considers the frame render-safe; during paint it returned early, the regenerator never ran (no pixels), and a later upload of the empty VTF crashed. - Log the regenerator entry so the log shows whether the upload path ran.
* Skybox image: fix HDR sky binding; clip checkbox/arrow drawingsalmonik4 days1-8/+35
| | | | | | | | | | | | | | The HDR sky materials use the "sky" shader with $hdrcompressedtexture (DXT5). Assigning an RGBA8 procedural texture there sampled as compressed data and rendered black. Point $hdrbasetexture at the image, undefine $hdrcompressedtexture (and its 0/1/2 variants) so the shader falls back, and call IMaterial::Refresh (37) because the sky shader binds textures in SHADER_INIT, which is otherwise cached. GUI: draw_checkbox and the card expand chevron ignored the content clip, so cards scrolled out of view leaked header widgets outside the window. Log the first regenerator call (size/pitch/first pixel) for diagnosis.
* Skybox image: decode PNG ourselves to avoid symbol interpositionsalmonik4 days1-41/+194
| | | | | | | | | | | | client.so, engine.so and vguimatsurface.so all export their own png_create_read_struct. Loading the system libpng16 made its internal calls bind to the game's older libpng, whose png_struct layout differs, so png_safe_warning read a NULL error_ptr and crashed. Replace libpng with a small PNG reader: zlib's uncompress (dlopen'ed) plus the five PNG row filters, supporting 8-bit non-interlaced RGB/RGBA/gray/palette images with tRNS alpha for palettes. Output verified byte-identical to libpng for the skybox.png in use.
* Skybox image: upload via procedural texture, not CreateTextureFromBitssalmonik4 days1-6/+60
| | | | | | | | | | | The crash was CreateTextureFromBits: this build's IMaterialSystem interface stops at GetDisplayDeviceName, and the slots after it are CMaterialSystem's own virtuals, so index 134 was an unrelated function. Use CreateProceduralTexture (81, verified by disassembling the interface vtable) together with an ITextureRegenerator (SetTextureRegenerator 12, Download 13) that fills mip 0 via IVTFTexture::ImageData (39; IVTFTexture has a two-slot virtual destructor, so Width=15, Height=16, RowSizeInBytes=19).
* World: replace skybox changer with a PNG skybox imagesalmonik4 days1-99/+243
| | | | | | | | | | | | | | | | | sv_skyname did not take effect at runtime in this build, so the Skybox card now replaces the skybox materials' textures with <config dir>/skybox.png. The PNG is decoded through libpng16's simplified API (dlopen'ed, so no new link dependency) and uploaded with IMaterialSystem::CreateTextureFromBits as an RGBA8888 texture. IMaterialVar::SetTextureValue assigns it to $basetexture and the HDR variants for every material in the SkyBox textures group (all six faces get the same image). Original textures are recorded per material/var (texture pointer plus string fallback) and restored when the feature is off. Records survive level changes so a reused sky material is still restorable; the override is re-applied to a new map automatically. The card shows the image path and has a Reload image button; a missing/unreadable PNG raises an error toast.
* World: add skybox changersalmonik4 days1-0/+152
| | | | | | | | | | | | | | New Visuals -> Skybox card with a runtime sv_skyname override using the same mechanism as the stock skybox_swapper entity. The choice list is the HL2 skybox set extracted from the game VPKs. The map's own sky is captured from loaded materials (SkyBox group, parsing skybox/<name>... face names) before the first override, so turning the feature off or picking "Map default" restores it; a level change restores it implicitly. Sky changes invalidate the world tint so new sky materials are tinted as well. GUI: add a CK_CHOICE control (value box with < / > zones).
* World: add prop tint and fog overridesalmonik4 days1-13/+107
| | | | | | | | | | - World tint now also colours prop materials (models/props*) with their own colour, covering static props and prop_physics while leaving NPC, player and weapon materials untouched. - New Fog card: fog_override colour/start/end via ClientCmd, optional skybox fog, and a Remove fog mode. Restores the map fog (fog_override 0) when disabled and re-applies after level changes. - Config sections [worldtint] prop/colour keys and [fog].
* World: add world/sky material colour modulationsalmonik4 days1-0/+248
Port Amalgam's modulation approach: obtain IMaterialSystem from the already loaded materialsystem.so (VMaterialSystem080) and walk materials with FirstMaterial/NextMaterial/GetMaterial. ColorModulate the "World textures" group (sky names excluded) and the "SkyBox textures"/sky-named group. The walk runs only when the enabled groups or colours change, restores white when disabled, and re-applies after level changes. Before touching materials, GetNumMaterials() and the first material's name/group are sanity-checked so a wrong vtable slot logs and aborts instead of walking garbage. GUI: "World tint" card with world/sky toggles and RGB sliders; config section [worldtint].