Savestates: Fixed issue with BaseControlDevice::StreamState
This commit is contained in:
parent
4b3edac310
commit
3348c3d96a
5 changed files with 36 additions and 27 deletions
|
@ -31,7 +31,7 @@ void BaseControlDevice::InternalSetStateFromInput()
|
|||
|
||||
void BaseControlDevice::StreamState(bool saving)
|
||||
{
|
||||
ArrayInfo<uint8_t> state{ _state.State.data(), (uint32_t)_state.State.size() };
|
||||
VectorInfo<uint8_t> state{ &_state.State };
|
||||
Stream(_strobe, state);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,13 +17,7 @@ protected:
|
|||
{
|
||||
BaseControlDevice::StreamState(saving);
|
||||
|
||||
uint32_t dataSize = (uint32_t)_data.size();
|
||||
Stream(dataSize);
|
||||
if(!saving) {
|
||||
_data.resize(dataSize);
|
||||
}
|
||||
|
||||
ArrayInfo<uint8_t> data{ _data.data(), dataSize };
|
||||
VectorInfo<uint8_t> data{ &_data };
|
||||
Stream(_insertCycle, _newBarcode, _newBarcodeDigitCount, data);
|
||||
}
|
||||
|
||||
|
|
15
Core/FDS.cpp
15
Core/FDS.cpp
|
@ -449,19 +449,14 @@ void FDS::StreamState(bool saving)
|
|||
|
||||
if(saving) {
|
||||
vector<uint8_t> ipsData = CreateIpsPatch();
|
||||
uint32_t size = (uint32_t)ipsData.size();
|
||||
Stream(size);
|
||||
|
||||
ArrayInfo<uint8_t> data{ ipsData.data(), (uint32_t)ipsData.size() };
|
||||
VectorInfo<uint8_t> data{ &ipsData };
|
||||
Stream(data);
|
||||
} else {
|
||||
uint32_t size = 0;
|
||||
Stream(size);
|
||||
if(size > 0) {
|
||||
vector<uint8_t> ipsData(size, 0);
|
||||
ArrayInfo<uint8_t> data{ ipsData.data(), (uint32_t)ipsData.size() };
|
||||
Stream(data);
|
||||
vector<uint8_t> ipsData;
|
||||
VectorInfo<uint8_t> data{ &ipsData };
|
||||
Stream(data);
|
||||
|
||||
if(ipsData.size() > 0) {
|
||||
LoadDiskData(ipsData);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,15 +22,8 @@ protected:
|
|||
{
|
||||
BaseControlDevice::StreamState(saving);
|
||||
|
||||
uint32_t dataSize = _data.size();
|
||||
Stream(_enabled, _isPlaying, _cycle, dataSize);
|
||||
|
||||
if(!saving) {
|
||||
_data.resize(dataSize);
|
||||
}
|
||||
|
||||
ArrayInfo<uint8_t> data{ _data.data(), _data.size() };
|
||||
Stream(data);
|
||||
VectorInfo<uint8_t> data{ &_data };
|
||||
Stream(_enabled, _isPlaying, _cycle, data);
|
||||
|
||||
if(!saving && _isRecording) {
|
||||
StopRecording();
|
||||
|
|
|
@ -11,6 +11,12 @@ struct ArrayInfo
|
|||
uint32_t ElementCount;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct VectorInfo
|
||||
{
|
||||
vector<T>* Vector;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct ValueInfo
|
||||
{
|
||||
|
@ -109,6 +115,27 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void InternalStream(VectorInfo<T> &info)
|
||||
{
|
||||
vector<T> *vector = info.Vector;
|
||||
|
||||
uint32_t count = (uint32_t)vector->size();
|
||||
StreamElement<uint32_t>(count);
|
||||
|
||||
if(!_saving) {
|
||||
vector->resize(count);
|
||||
memset(vector->data(), 0, sizeof(T)*count);
|
||||
}
|
||||
|
||||
//Load the number of elements requested
|
||||
T* pointer = vector->data();
|
||||
for(uint32_t i = 0; i < count; i++) {
|
||||
StreamElement<T>(*pointer);
|
||||
pointer++;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void InternalStream(ValueInfo<T> &info)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue