I made did some cleanup to command system in Spearmint, may want to do similar in Unvanquished.
Based on this recent unv/engine-upgrade commit, I think it's all relevant.
-
Have VM commands store a real function (example: CL_GameCommand), instead of hacks for NULL function (the checking if each VM wants to run the command / don't warn if command already exists).
-
Only let VMs run commands they add using trap_AddCommand. (Caused by the above change; offtopic note: stops q3/teamarena ui commands from working because not added using a syscall so I cannot be committed to ioq3. :sadface: )
-
Move forwarding 'unhandled' commands to server into cgame. (cgame adds the commands; so I think it should handle them. Allows engine code to be cleaner.)
-
Auto remove commands added by a VM on VM shutdown (Remove all commands that use the VM's command function, example: CL_GameCommand.) It fixes switching mods/cgame and having non-existing command in tab-completion.
-
Don't let VMs remove commands added by another VM. (Only remove if command uses VM's command function, example: CL_GameCommand.)
Note: My implementation of the last two assumes VMs only use one function for their commands (example: CL_GameCommand). Might want to skip if you plan to have VM give engine a different function address for each command (not possible for QVMs, possible for DLLs, I don't know anything about PNaCl).
My implementation: main commit and a probably irrelevant fix for server's new behavior of printing unknown commands added when removing CL_ForwardCommandToServer.
Feel free to use or ignore this.