From fa458178a4a1d307977ee8b1fc1d659470444229 Mon Sep 17 00:00:00 2001 From: John Ratliff Date: Sat, 17 Sep 2022 17:39:22 -0400 Subject: [PATCH] fix virtual calls from constructors --- source/model/gbggrawcode.cc | 15 ++++----------- source/model/genesisrawcode.cc | 6 ++---- source/model/nesrawcode.cc | 15 ++++----------- source/model/snesrawcode.cc | 6 ++---- 4 files changed, 12 insertions(+), 30 deletions(-) diff --git a/source/model/gbggrawcode.cc b/source/model/gbggrawcode.cc index 21f4055..a9d801f 100644 --- a/source/model/gbggrawcode.cc +++ b/source/model/gbggrawcode.cc @@ -24,18 +24,11 @@ using namespace ggencoder; -GBGGRawCode::GBGGRawCode(int address, int value, int compare) { - setAddress(address); - setValue(value); - setCompare(compare); -} - -GBGGRawCode::GBGGRawCode(int address, int value) { - setAddress(address); - setValue(value); +GBGGRawCode::GBGGRawCode(int address, int value, int compare) + : RawCode{address & 0xFFFF, value & 0xFF}, CompareRawCode{compare} {} - compare = -1; -} +GBGGRawCode::GBGGRawCode(int address, int value) + : RawCode{address & 0xFFFF, value & 0xFF}, CompareRawCode{-1} {} void GBGGRawCode::setAddress(int address) { this->address = (address & 0xFFFF); diff --git a/source/model/genesisrawcode.cc b/source/model/genesisrawcode.cc index c2ede45..f7a514a 100644 --- a/source/model/genesisrawcode.cc +++ b/source/model/genesisrawcode.cc @@ -24,10 +24,8 @@ using namespace ggencoder; -GenesisRawCode::GenesisRawCode(int address, int value) { - setAddress(address); - setValue(value); -} +GenesisRawCode::GenesisRawCode(int address, int value) + : RawCode{address & 0xFFFFFF, value & 0xFFFF} {} void GenesisRawCode::setAddress(int address) { this->address = (address & 0xFFFFFF); diff --git a/source/model/nesrawcode.cc b/source/model/nesrawcode.cc index e504bf0..0cafd36 100644 --- a/source/model/nesrawcode.cc +++ b/source/model/nesrawcode.cc @@ -24,18 +24,11 @@ using namespace ggencoder; -NESRawCode::NESRawCode(int address, int value, int compare) { - setAddress(address); - setValue(value); - setCompare(compare); -} - -NESRawCode::NESRawCode(int address, int value) { - setAddress(address); - setValue(value); +NESRawCode::NESRawCode(int address, int value, int compare) + : RawCode{address & 0xFFFF, value & 0xFF}, CompareRawCode{compare} {} - compare = -1; -} +NESRawCode::NESRawCode(int address, int value) + : RawCode{address & 0xFFFF, value & 0xFF}, CompareRawCode{-1} {} void NESRawCode::setAddress(int address) { this->address = (address & 0xFFFF); diff --git a/source/model/snesrawcode.cc b/source/model/snesrawcode.cc index 104f6a2..1168fcd 100644 --- a/source/model/snesrawcode.cc +++ b/source/model/snesrawcode.cc @@ -24,10 +24,8 @@ using namespace ggencoder; -SNESRawCode::SNESRawCode(int address, int value) { - setAddress(address); - setValue(value); -} +SNESRawCode::SNESRawCode(int address, int value) + : RawCode{address & 0xFFFFFF, value & 0xFF} {} void SNESRawCode::setAddress(int address) { this->address = (address & 0xFFFFFF);