Change FindMap to take a const char* for searching instead of char*.#396
Change FindMap to take a const char* for searching instead of char*.#396KyleSanderson merged 1 commit intomasterfrom
Conversation
3785980 to
62f5703
Compare
|
drive-by: New API looks a lot better. Also, there is no risk of this integer truncation blowing up on 64-bit. SourcePawn integers are 32-bit, so int -> size_t -> int is harmless in this context. Plus, it's a relatively safe assumption that no one is going to use the C++ API to create a 2GB string buffer to hold a map name. That said, the const_cast is gross - probably better to create a local buffer of size PATH_MAX instead. |
62f5703 to
9a5bd2e
Compare
|
🚢 |
|
@powerlord ke::SafeStrcpy was a replacement for strncopy which still does exist in SM 1.7 so it can be backported |
|
@powerlord can you confirm this doesn't regress anything for you? |
|
@WildCard65 I'm well aware of what it was a replacement for. Except that's not how AlliedModders usually backports things... usually it's done by cherry-picking commits from master into 1.7-dev (for example). @KyleSanderson I'm not sure exactly what you want me to test. I can tell you right now that any code I have that uses FindMap is going to break as you've changed the SourcePawn syntax for it. |
|
While we're on the subject of testing, you really should update plugins/testsuite/findmap.sp In fact, that should have tossed an error in the Travis and AppVeyor tests. Why didn't it? Are we not actually building the testsuite plugins during our testing process? |
Indeed. it will be broken at compile-time, but the already compiled plugins should work at runtime as-is.
We are not. Only a subset of the test plugins are meant to test for compile-time issues. It's still not necessarily a bad idea to have an opt-in switch in the ambuild script to compile them, just making sure that we don't ship them. |
|
@psychonic Well, to not ship them, we just have to not copy them to the package directory, correct? As for checking for regressions, I haven't compiled this branch (or even looked which branch it is) to do testing on it. |
|
I can't currently test this as both this and SM master crash on Linux TF2 server start. I'll file a bug against master in Bugzilla about it. |
|
@powerlord this is now resolved, sorry for the inconvenience. |
|
@KyleSanderson Might want to merge master and/or cherry-pick that commit into this branch to update it as well. I mean, I know I can get around it by switching branches without updating submodules afterwards, but it's still a good idea. |
939d73a to
f59df24
Compare
|
Old commands that use FindMap appear to still work. It looks like Valve fixed the return types of its internal FindMap in the TF2 PASS time update as well.
I have not tried the new 3-argument version yet. Then again, the sooner this gets merged into master, the sooner I can fix PR #354 to use it. On a side note, when you merge commits on an already pushed branch, it does a very messy merge for the person who had pulled a previous version. Not only did it prompt me for a commit message, but this is what the merge looked like on the command line: The only file that actually changed since my last pull was the public/amtl change. |
Change FindMap to take a const char* for searching instead of char*.
|
@powerlord That is normal for git to list what changes were merged in like that, but for prompting a commit message, that usually means there was a merge conflict |
|
@WildCard65 The "conflict" was because someone rewrote history
|
I dislike the FindMap API we have greatly because we're asking users to create a new buffer, fill it, and then pass it to FindMap to determine if the user input is valid. We don't have any other APIs like this, and it turns into a whole thing everytime this native is to be used. Internally we have the exact same pattern and we throw away the result...
The alternative I'm proposing is the top, bottom being present.
native FindMapResult FindMap(const char[] map, char[] foundmap, int maxlen);native FindMapResult FindMap(char[] map, int maxlen);This is only compile tested.