Skip to content

Expose FindMap/ResolveFuzzyMapName to plugins.#351

Merged
psychonic merged 4 commits intomasterfrom
expose-findmap
Jun 28, 2015
Merged

Expose FindMap/ResolveFuzzyMapName to plugins.#351
psychonic merged 4 commits intomasterfrom
expose-findmap

Conversation

@psychonic
Copy link
Member

Similar goal as #348 - exposes the fuzzy map matching to plugins.

The biggest difference is that we attempt to expose as much as the FindMap functionality from TF2 (and eventually CS:S, DoD:S, etc.) as we can in other games.

@powerlord Can you give this a look and let me know if you have any concerns with the implementation?

Also, @voided

@psychonic psychonic self-assigned this Jun 27, 2015
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the api docgen understand regular comments?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Most of our newer api (largely methodmaps) have comments in this style, too.

@powerlord
Copy link
Contributor

The only confusing thing I can see here is that auto-completing Workshop maps returns different results in L4D2+ than it does for OrangeBox games.

When TF2 auto-completes a workshop map, it will return eFindMap_NonCanonical or eFindMap_PossiblyAvailable on success depending on whether the map is being tracked and it can get the "real" name ("real" is in quotes because the path doesn't actually exist on disc).

L4D2+ doesn't know if it's dealing with a workshop map or not, so just returns eFindMap_FuzzyMatch any time it does fuzzy matching.

Also, I'm assuming the FileExists is being done to avoid logging IsMapValid errors being logged to the server console.

On a side note, I've been told by Valve's John Schoenick that TF2's

IsMapValid() now requires a proper qualified filename, and no longer blindly wraps input in maps/%s.bsp due to engine changes. In a future SDK update these changes will be restricted to IVEngineServer v23 and requesting v22 will give you a legacy wrapper.

but since we use FindMap these days anyway, I guess this isn't really important.

@psychonic
Copy link
Member Author

When TF2 auto-completes a workshop map, it will return eFindMap_NonCanonical or eFindMap_PossiblyAvailable on success depending on whether the map is being tracked and it can get the "real" name ("real" is in quotes because the path doesn't actually exist on disc).

L4D2+ doesn't know if it's dealing with a workshop map or not, so just returns eFindMap_FuzzyMatch any time it does fuzzy matching.

Intended, for now. That's also documented in the enum. Does TF2 never give FuzzyMatch for workshop maps, even if they're fully downloaded and you use a partial, canonical name, ex. "workshop/"?, rather than a non-canonical name like "workshop/"

Also, I'm assuming the FileExists is being done to avoid logging IsMapValid errors being logged to the server console.

Correct, as noted in the comment above that call.

but since we use FindMap these days anyway, I guess this isn't really important.

Indeed. For that code path (just TF2 right now), we don't even call IsMapValid.

@powerlord
Copy link
Contributor

For workshop/123456789 style for a workshop map you already have

  • If the map is being tracked (via tf_workshop_map_sync or loading the map once), it will copy the workshop/mapnamehere.ugc123456789 style name into the string variable and return eFindMap_NonCanonical
  • If not tracked, but a copy of the map exists on your server, it will not change anything, but return eFindMap_PossiblyAvailable

I haven't tested what it will return for workshop/mapnamehere.ugc123456789 style.

@psychonic
Copy link
Member Author

I see now. For TF2 workshop maps, they're not actually at the path displayed in console, nor even in the maps folder at all. That explains why FuzzyMatch doesn't/won't/can't work for them.

I still don't think that there is anything that we should (or can) do about it in code. I'll see about making the docs clearer.

@psychonic
Copy link
Member Author

It looks like there is also a compile error on Clang that I need to clear up. I only tested on MSVC/Windows.

@powerlord
Copy link
Contributor

I've updated Pull Request #350 to be based on this PR instead of #349.

Of course, that means it has the same Clang compile issue. I'll have to make sure I merge it again after this one is fixed... and then do some testing on it.

@powerlord powerlord mentioned this pull request Jun 27, 2015
@psychonic
Copy link
Member Author

Hokay. Linux compile should be fixed now, and the native doc has been updated according to the findings above.

@powerlord
Copy link
Contributor

Hmm... Apparently TF2 is returning eFindMap_Found when it does non-Workshop fuzzy matching.

I should probably report this to Valve.

@psychonic
Copy link
Member Author

It returned FuzzyMatch for me when trying "cp_dust" and gave back "cp_dustbowl".

@powerlord
Copy link
Contributor

@psychonic Hmm... I was trying "dustbowl" and "dust" and it's executing the FindMap_Found case in my switch block.

(This is in a SourceMod plugin)

@powerlord
Copy link
Contributor

@psychonic Were you testing that on Windows or Linux?

I'm testing this on TF2 Linux with this plugin.

FindMap_NotFound, FindMap_NonCanonical, and FindMap_PossiblyAvailable are all working as expected (for not found, workshop resolved, and workshop unresolved).... I just happen to be getting FindMap_Found for both direct matches and fuzzy matches on TF2.

@psychonic
Copy link
Member Author

You're right, even on Windows. I must have not actually seen what I thought I saw. Using the exact case in Valve's own enum doc for eFindMap_FuzzyMatch, "Ex: cp_dust -> cp_dustbowl"), gives back eFindMap_Found (while still updating the buffer with the exact name).

I'll report it and just add a shim around it for now to return FuzzyMatch if the input doesn't match the output.

@psychonic
Copy link
Member Author

That is fixed now.

@powerlord
Copy link
Contributor

Thanks psychonic. I can confirm this latest change appears to be working properly.

psychonic added a commit that referenced this pull request Jun 28, 2015
Expose FindMap/ResolveFuzzyMapName to plugins.
@psychonic psychonic merged commit f960c64 into master Jun 28, 2015
@psychonic
Copy link
Member Author

I'll report it and just add a shim around it for now to return FuzzyMatch if the input doesn't match the output.

This has been acknowledged and will likely be fixed in a future game update.

psychonic added a commit that referenced this pull request Jul 8, 2015
Expose FindMap/ResolveFuzzyMapName to plugins.
@asherkin asherkin deleted the expose-findmap branch November 3, 2015 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants