simplify and unify var lookup code

the codepaths are now shared between have a srcmod and not having one