alliedmodders/sourcemod — pull request #202 by powerlord (2014-11-14 21:37:17+00:00)
Title: Add a data argument to menus

I nearly forgot about this. Basically, this adds a data argument to `CreateMenu`, `CreateMenuEx`, and `CreateDataMenu`. This data argument is passed to MenuHandler and VoteResultCallback.

There was some discussion of whether we wanted to let programmers assign the data variable after the fact, but it is my opinion that it should be created in the Menu constructor / CreateMenu call. Feel free to comment on this if you disagree.

This patch also changes the return type of `CreateMenuEx` and `CreateDataMenu` to `Menu` (it was `Handle`) as this prevents a warning when you try to assign the return value from one of these to a `Menu` variable.

This also adds `CreateDataMenuEx` which combines `CreateMenuEx` and `CreateDataMenu`.

Now, some notes as to the design of this: You'll note that the IPluginContext is saved when a menu is created. This is because most Handle types require the owner identity be passed in when you call FreeHandle on them. You can see this behavior in smn_KillTimer when a Timer has the TIMER_DATA_HNDL_CLOSE flag.

The `userData != NULL` check shouldn't be necessary as we always create a `MenuUserData` struct, but I left it in just in case.