mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
feat(console): add ConsoleGetAllCommands
Returns every console command and console variable as ConsoleCommandInfo tables, backed by the registry FUN_CONSOLE_COMMAND_REGISTER fills. The walk mirrors the `help` handler (FUN_0063FDC0), the only other thing that enumerates it: step with next = *(uint32_t *)(node + LINK_OFFSET + 4), stop on null or a low-bit-tagged sentinel. Commands and CVars are ONE list, not two. The CVar registrar's last act is FUN_CONSOLE_COMMAND_REGISTER(cvar->name, 0x0063DDE0, categoryId, help) -- which is what makes `/console <cvar> <value>` work -- so the command list already holds every CVar, and walking the CVar list that `cvarlist` and the config saver use would report each one twice. That shared handler address is also an exact commandType test: a node pointing at it is a Cvar, anything else a Command. A pointer comparison against a value the registrar itself writes, not a name or category heuristic. Named as a global, not a C_Console member. The wiki files it under C_Console.GetAllCommands, but on a live 12.1.0 client C_Console is nil and ConsoleGetAllCommands is the real name -- the page is stale about the namespace. The field names come from Blizzard's own generated API docs and were then confirmed against a live entry: command, help, category, commandType, scriptContents, scriptParameters, with the two script fields empty strings rather than nil there too. Enum.ConsoleCategory and Enum.ConsoleCommandType are stated in full rather than derived from the engine's nine categories. Deriving works -- reading VAR_CONSOLE_CATEGORY_TABLE and capitalizing "debug" to "Debug" was verified in-game -- but it makes the enum track the wrong thing. It is a Blizzard contract, not a description of the local console, and it carries values this client cannot produce: Reveal 9 and None 10 have no category here, Macro 2 and Script 3 no registration path. A client that renamed its `gm` category would silently register Enum.ConsoleCategory.Master and turn Enum.ConsoleCategory.Gm into nil, breaking a constant meant to be fixed everywhere. Offsets.h keeps the verification: ids 0..8 are debug, graphics, console, combat, game, default, net, sound, gm in that order, so a category read off a node lands inside the enum without translation. scriptContents and scriptParameters describe console macros and scripts, which have no registration path here, so both are always "". Verified in-game: 538 entries, 487 of them CVars. `help` -> Command / Console with its description, `realmList` -> Cvar / Default, and our own `ExportDBCFiles` -> Command / Debug, which also proves the walk sees runtime registrations rather than only boot-time ones. C_Console is absent, both enums resolve including the values this client cannot return, and every field has its declared type.
This commit is contained in:
+37
@@ -60,6 +60,7 @@ build instructions.
|
||||
- [`StopAttack()`](#stopattack)
|
||||
|
||||
- [Console](#console)
|
||||
- [`ConsoleGetAllCommands()`](#consolegetallcommands)
|
||||
- [`ExportInterfaceFiles art|code` (console command)](#exportinterfacefiles-artcode-console-command)
|
||||
- [`ExportDBCFiles` (console command)](#exportdbcfiles-console-command)
|
||||
|
||||
@@ -1588,6 +1589,42 @@ Stops your melee auto-attack. If you are not attacking, the call does nothing.
|
||||
|
||||
## Console
|
||||
|
||||
### `ConsoleGetAllCommands()`
|
||||
|
||||
Returns a list of every console command and console variable the client has,
|
||||
each as a table:
|
||||
|
||||
| Field | Type | Meaning |
|
||||
|-------|------|---------|
|
||||
| `command` | string | the name you type in the console |
|
||||
| `help` | string | the description, or `""` when it has none |
|
||||
| `category` | number | an `Enum.ConsoleCategory` value |
|
||||
| `commandType` | number | an `Enum.ConsoleCommandType` value |
|
||||
| `scriptContents` | string | always `""` |
|
||||
| `scriptParameters` | string | always `""` |
|
||||
|
||||
```lua
|
||||
for _, info in ipairs(ConsoleGetAllCommands()) do
|
||||
if info.commandType == Enum.ConsoleCommandType.Cvar then
|
||||
print(info.command, GetCVar(info.command))
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
Console variables are included, and most of them carry no description, so
|
||||
`help` is often `""` for them. Console macros and scripts do not exist on this
|
||||
client, so `commandType` is only ever `Cvar` or `Command`, and the two script
|
||||
fields are always empty.
|
||||
|
||||
`Enum.ConsoleCategory` holds `Debug` 0, `Graphics` 1, `Console` 2, `Combat` 3,
|
||||
`Game` 4, `Default` 5, `Net` 6, `Sound` 7, `Gm` 8, `Reveal` 9 and `None` 10.
|
||||
Every command reports one of `Debug` through `Gm`.
|
||||
`Enum.ConsoleCommandType` holds `Cvar` 0, `Command` 1, `Macro` 2 and
|
||||
`Script` 3.
|
||||
|
||||
The list is live: a command added while the game runs, such as one of the export
|
||||
commands below, appears in the next call.
|
||||
|
||||
### `ExportInterfaceFiles art|code` (console command)
|
||||
|
||||
A **developer-console command** (not a Lua function) — type it into the
|
||||
|
||||
Reference in New Issue
Block a user