clean up check_size

This commit is contained in:
Martin Michelsen
2023-06-18 22:43:53 -07:00
parent aead8aae71
commit f333a88aaf
9 changed files with 294 additions and 338 deletions
+2 -4
View File
@@ -187,11 +187,9 @@ void BattleRecord::add_chat_message(
bool BattleRecord::is_map_definition_event(const Event& ev) {
if (ev.type == Event::Type::BATTLE_COMMAND) {
auto& header = check_size_t<G_CardBattleCommandHeader>(
ev.data, sizeof(G_CardBattleCommandHeader), 0xFFFF);
auto& header = check_size_t<G_CardBattleCommandHeader>(ev.data, 0xFFFF);
if (header.subcommand == 0xB6) {
auto& header = check_size_t<G_MapSubsubcommand_GC_Ep3_6xB6>(
ev.data, sizeof(G_MapSubsubcommand_GC_Ep3_6xB6), 0xFFFF);
auto& header = check_size_t<G_MapSubsubcommand_GC_Ep3_6xB6>(ev.data, 0xFFFF);
if (header.subsubcommand == 0x41) {
return true;
}
+1 -2
View File
@@ -1532,8 +1532,7 @@ const unordered_map<uint8_t, Server::handler_t> Server::subcommand_handlers({
});
void Server::on_server_data_input(const string& data) {
auto header = check_size_t<G_CardBattleCommandHeader>(
data, sizeof(G_CardBattleCommandHeader), 0xFFFF);
auto header = check_size_t<G_CardBattleCommandHeader>(data, 0xFFFF);
if (header.size * 4 < data.size()) {
throw runtime_error("command is incomplete");
}