JobsV - Crash Fix
version 1.1 (community fix)
===========================

A runtime patch for TylerEspo's JobsV [.NET] mod. The original 0.1.4 release
(last updated August 2016, abandoned for 10 years) has a crash where the
script never instantiates if any keybinding in JobsV.config can't be parsed
by Enum.Parse<Keys>.

Symptom from the gta5-mods comment thread (Fractal420, dated stack trace):

    [ERROR] Failed to instantiate script JobsV.Main because constructor
    threw an exception: System.ArgumentException: Nie można znaleźć
    żądanej wartości '*' (Polish locale: "Cannot find requested value '*'")

If you tried to install JobsV and pressing J / E / K / F11 in-game does
nothing, this is almost certainly your bug. Check ScriptHookVDotNet.log for
the same exception text in any language.

This package does NOT replace the original JobsV mod. It runs alongside the
original JobsV.dll and hot-patches the broken keybinding parser at script
load time using Harmony.


Root cause
----------
JobsV.Config has four Keys property getters (InteractKey, HUDKey, SaveDataKey,
LoadKey) that read a line from JobsV.config and call:

    Enum.Parse(typeof(Keys), GetLine(N), ignoreCase: true)

with no try/catch. If the user typed:
  - an asterisk or wildcard ("*", "?")
  - a gamepad button name that isn't in the Keys enum
  - a typo ("Entr" instead of "Enter")
  - any other unparseable string

Enum.Parse throws ArgumentException. The crash happens inside the JobsV.Main
constructor on line 50 where it calls `config.LoadKey.ToString()` and
`config.SaveDataKey.ToString()`. SHVDN aborts the script entirely. From the
player's perspective, JobsV is silently dead.


What is fixed in v1.1
---------------------
Harmony Finalizer patches on all four Keys getters in JobsV.Config:

  InteractKey   -> falls back to Keys.E    on parse failure
  HUDKey        -> falls back to Keys.J    on parse failure
  SaveDataKey   -> falls back to Keys.K    on parse failure
  LoadKey       -> falls back to Keys.F11  on parse failure

Defaults match the JobsV.config sample comments so a default install just
works. Belt-and-suspenders: also a Finalizer on the JobsV.Main constructor
that swallows any other ctor exception with a clear notification, so the
script always loads instead of dying silently.


Contents
--------
JobsV_CrashFix.dll    Runtime patcher (5 KB). Drop in /scripts.
0Harmony.dll          Harmony 2.3.3 runtime (~2.1 MB).
                       Required by JobsV_CrashFix.dll. Drop in /scripts.
                       If you already have a newer 0Harmony.dll from another
                       mod (LSlife, Simple Zombies, $PlayerCompanion), keep
                       the newer one.
README.txt            This file.
CHANGELOG.txt         Per version notes.


Requirements
------------
- The ORIGINAL JobsV [.NET] mod by TylerEspo must be installed first. This
  Crash Fix is purely a runtime patcher and does nothing on its own.
  Source: https://www.gta5-mods.com/scripts/jobsv
- ScriptHookV
- ScriptHookVDotNet 2 or 3
- C++ Redistributable (per original TylerEspo install notes)


Installation
------------
1. Install the original JobsV first, following TylerEspo's instructions.
2. Drop BOTH files from this package into
   ...\Grand Theft Auto V\scripts\:
       JobsV_CrashFix.dll
       0Harmony.dll
3. Launch the game. You should see a brief green ticker:
       "JobsV Crash Fix v1.1 loaded."
   That confirms the runtime patches are applied.
4. Press J to toggle the JobsV HUD. Press E at job blips to interact.


Recommended ini hygiene
-----------------------
Open scripts\JobsV.config and verify the key lines (lines 6, 10, 12, 14) are
valid Keys enum names (E, J, K, F11, etc.) — not gamepad buttons, asterisks,
or anything else. Even with the Crash Fix swallowing bad parses, you'll get
a better experience with valid values in there.


Troubleshooting
---------------
"JobsV Crash Fix failed to apply: ..."
   The patcher couldn't find the target methods. Most likely the original
   JobsV.dll isn't loaded. Check ScriptHookVDotNet.log for any [ERROR] line
   mentioning JobsV.

No ticker on game start.
   Either JobsV_CrashFix.dll isn't in /scripts, or SHVDN didn't load it.
   Check ScriptHookVDotNet.log for any [ERROR] line mentioning JobsV_CrashFix.

JobsV HUD still doesn't appear.
   Verify the original JobsV.dll is in /scripts and the JobsV folder exists
   too (TylerEspo's install puts a folder + a dll). Press J in-game; the
   default HUD key falls back to J even if your config has a bad value.


Credits
-------
Original mod:        JobsV [.NET] by TylerEspo
                     https://www.gta5-mods.com/scripts/jobsv
Crash fix:           chris22622
Runtime patching:    Harmony by Andreas Pardeike (MIT)
                     https://github.com/pardeike/Harmony

Bug surfaced by:
- Fractal420 (gta5-mods comment, dated logs):
  "[ERROR] Failed to instantiate script JobsV.Main because constructor
   threw an exception: System.ArgumentException: Nie można znaleźć
   żądanej wartości '*'"
