diff --git a/src/ProxyCommands.cc b/src/ProxyCommands.cc index 8cd3b45e..199252a5 100644 --- a/src/ProxyCommands.cc +++ b/src/ProxyCommands.cc @@ -1783,7 +1783,8 @@ static HandlerResult C_V123_A0_A1(shared_ptr ses, ui } // Indexed as [command][version][is_from_client] -static on_command_t handlers[0x100][14][2] = { +static_assert(NUM_VERSIONS == 14, "Don\'t forget to update the ProxyCommands handlers table"); +static on_command_t handlers[0x100][NUM_VERSIONS][2] = { // clang-format off // CMD S_PC_PATCH C S_BB_PATCH C S_DC_NTE C S_DC_V1_12_2000_PROTO C S_DC_V1 C S_DC_V2 C S_PC_NTE C S_PC_V2 C S_GC_NTE C S_GC_V3 C S_GC_EP3_NTE C S_GC_EP3 C S_XB_V3 C S_BB_V4 C /* 00 */ {{S_invalid, nullptr}, {S_invalid, nullptr}, {nullptr, nullptr}, {S_invalid, nullptr}, {S_invalid, nullptr}, {S_invalid, nullptr}, {S_invalid, nullptr}, {S_invalid, nullptr}, {S_invalid, nullptr}, {S_invalid, nullptr}, {S_invalid, nullptr}, {S_invalid, nullptr}, {S_invalid, nullptr}, {S_invalid, nullptr}}, diff --git a/src/QuestScript.cc b/src/QuestScript.cc index 0f446117..439aba17 100644 --- a/src/QuestScript.cc +++ b/src/QuestScript.cc @@ -189,6 +189,8 @@ constexpr uint16_t v_flag(Version v) { using Arg = QuestScriptOpcodeDefinition::Argument; +static_assert(NUM_VERSIONS == 14, "Don\'t forget to update the QuestScript flags and opcode definitions table"); + static constexpr uint16_t F_PASS = 0x0001; // Version::PC_PATCH (unused for quests) static constexpr uint16_t F_ARGS = 0x0002; // Version::BB_PATCH (unused for quests) static constexpr uint16_t F_DC_NTE = 0x0004; // Version::DC_NTE diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index b80eb186..cc04b22f 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -5216,9 +5216,10 @@ typedef void (*on_command_t)(shared_ptr c, uint16_t command, uint32_t fl // Command handler table, indexed by command number and game version. Null // entries in this table cause on_unimplemented_command to be called, which // disconnects the client. -static on_command_t handlers[0x100][14] = { +static_assert(NUM_VERSIONS == 14, "Don\'t forget to update the ReceiveCommands handler table"); +static on_command_t handlers[0x100][NUM_VERSIONS] = { // clang-format off -// PC_PATCH BB_PATCH DC_NTE DC_PROTO DCV1 DCV2 PC-NTE PC GCNTE GC EP3TE EP3 XB BB +// PC_PATCH BB_PATCH DC_NTE DC_112000 DCV1 DCV2 PC_NTE PC GCNTE GC EP3TE EP3 XB BB /* 00 */ {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 01 */ {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 02 */ {on_02_P, on_02_P, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, diff --git a/src/Version.hh b/src/Version.hh index 20e9c4b0..301b1697 100644 --- a/src/Version.hh +++ b/src/Version.hh @@ -24,6 +24,10 @@ enum class Version { UNKNOWN = 15, }; +constexpr size_t NUM_VERSIONS = static_cast(Version::BB_V4) + 1; +constexpr size_t NUM_PATCH_VERSIONS = static_cast(Version::BB_PATCH) + 1; +constexpr size_t NUM_NON_PATCH_VERSIONS = NUM_VERSIONS - NUM_PATCH_VERSIONS; + template <> const char* name_for_enum(Version v); template <> diff --git a/src/WordSelectTable.cc b/src/WordSelectTable.cc index 0067379d..4cf76c12 100644 --- a/src/WordSelectTable.cc +++ b/src/WordSelectTable.cc @@ -205,7 +205,8 @@ WordSelectTable::WordSelectTable( this->name_to_token.emplace(token->canonical_name, token); } - array ws_sets = { + static_assert(NUM_NON_PATCH_VERSIONS == 12, "Don\'t forget to update the WordSelectTable constructor"); + array ws_sets = { &dc_nte_ws, &dc_112000_ws, &dc_v1_ws, &dc_v2_ws, &pc_nte_ws, &pc_v2_ws, &gc_nte_ws, &gc_v3_ws, &gc_ep3_nte_ws, &gc_ep3_ws, &xb_v3_ws, &bb_v4_ws};