2021-10-24 04:09:34 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
2021-12-26 23:54:17 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2021-10-24 04:09:34 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 23:54:17 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2021-10-24 04:09:34 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-06-28 22:21:04 +00:00
|
|
|
#include "chewy/globals.h"
|
|
|
|
#include "chewy/cursor.h"
|
2021-10-24 04:09:34 +00:00
|
|
|
#include "chewy/types.h"
|
2022-02-28 23:17:25 +00:00
|
|
|
#include "chewy/detail.h"
|
2021-12-11 04:20:40 +00:00
|
|
|
#include "common/algorithm.h"
|
2021-10-24 04:09:34 +00:00
|
|
|
|
|
|
|
namespace Chewy {
|
|
|
|
|
2022-03-20 10:38:41 +00:00
|
|
|
void GameFlags::clear() {
|
2021-11-15 00:35:08 +00:00
|
|
|
// TODO: Not sure how to do this any better
|
2022-03-20 10:38:41 +00:00
|
|
|
Common::fill((byte *)this, (byte *)this + sizeof(GameFlags), 0);
|
2021-11-15 00:35:08 +00:00
|
|
|
}
|
|
|
|
|
2022-03-20 10:38:41 +00:00
|
|
|
void GameState::clear() {
|
|
|
|
*this = GameState();
|
2021-11-15 00:35:08 +00:00
|
|
|
_flags = this;
|
|
|
|
_flags->clear();
|
|
|
|
}
|
|
|
|
|
2021-10-24 04:09:34 +00:00
|
|
|
static void syncArray(Common::Serializer &s, uint8 *arr, size_t count) {
|
|
|
|
for (size_t i = 0; i < count; ++i)
|
|
|
|
s.syncAsByte(arr[i]);
|
|
|
|
}
|
2022-07-03 13:14:06 +00:00
|
|
|
|
2021-10-24 04:09:34 +00:00
|
|
|
static void syncArray(Common::Serializer &s, int16 *arr, size_t count) {
|
|
|
|
for (size_t i = 0; i < count; ++i)
|
|
|
|
s.syncAsSint16LE(arr[i]);
|
|
|
|
}
|
|
|
|
|
2021-10-24 17:49:17 +00:00
|
|
|
#define SPIELER_FLAGS_SIZE 38
|
|
|
|
|
2022-03-20 10:38:41 +00:00
|
|
|
bool GameState::synchronize(Common::Serializer &s) {
|
|
|
|
if (sizeof(GameFlags) != SPIELER_FLAGS_SIZE)
|
2021-10-24 17:49:17 +00:00
|
|
|
error("Invalid flags structure size");
|
|
|
|
|
2022-03-20 11:58:05 +00:00
|
|
|
byte dummy = 0;
|
2022-06-28 22:21:04 +00:00
|
|
|
int16 dummy16 = 0;
|
2022-07-03 13:14:06 +00:00
|
|
|
uint8 InvUseDef[40 * 3] = {0}; // dummy
|
2022-06-29 13:23:33 +00:00
|
|
|
int inventoryCursor = _G(cur)->getInventoryCursor();
|
2022-03-20 11:58:05 +00:00
|
|
|
|
2021-10-24 04:09:34 +00:00
|
|
|
// Sync the structure's bitflags
|
2021-10-24 17:49:17 +00:00
|
|
|
s.syncBytes((byte *)_flags, SPIELER_FLAGS_SIZE);
|
2021-10-24 04:09:34 +00:00
|
|
|
|
2022-07-03 13:14:06 +00:00
|
|
|
_G(txt)->syncHotspotStrings(s);
|
|
|
|
_G(txt)->syncInventoryStrings(s);
|
|
|
|
_G(txt)->syncInventoryUseStrings(s);
|
2021-10-24 04:09:34 +00:00
|
|
|
syncArray(s, InvUseDef, 40 * 3);
|
|
|
|
|
|
|
|
s.syncAsSint16LE(MainMenuY);
|
|
|
|
s.syncAsSint16LE(InvDisp);
|
|
|
|
s.syncAsSint16LE(DispZx);
|
|
|
|
s.syncAsSint16LE(DispZy);
|
|
|
|
s.syncAsSint16LE(DispFlag);
|
|
|
|
s.syncAsSint16LE(InventY);
|
|
|
|
syncArray(s, InventSlot, MAX_MOV_OBJ);
|
|
|
|
|
2022-06-29 13:23:33 +00:00
|
|
|
s.syncAsSint16LE(inventoryCursor);
|
|
|
|
s.syncAsByte(dummy); // obsolete inventoryCursor flag
|
2022-06-28 22:21:04 +00:00
|
|
|
s.syncAsSint16LE(dummy16); // curWidth
|
|
|
|
s.syncAsSint16LE(dummy16); // curHeight
|
2021-10-24 04:09:34 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < MAX_MOV_OBJ; ++i)
|
|
|
|
room_m_obj[i].synchronize(s);
|
|
|
|
for (int i = 0; i < MAX_FEST_OBJ; ++i)
|
|
|
|
room_s_obj[i].synchronize(s);
|
|
|
|
for (int i = 0; i < MAX_EXIT; ++i)
|
|
|
|
room_e_obj[i].synchronize(s);
|
|
|
|
|
|
|
|
syncArray(s, X, MAX_PERSON);
|
|
|
|
syncArray(s, Y, MAX_PERSON);
|
|
|
|
syncArray(s, Phase, MAX_PERSON);
|
2022-03-02 22:42:15 +00:00
|
|
|
syncArray(s, _personHide, MAX_PERSON);
|
|
|
|
syncArray(s, _personRoomNr, MAX_PERSON);
|
2021-10-24 04:09:34 +00:00
|
|
|
syncArray(s, &ZoomXy[0][0], MAX_PERSON * 2);
|
|
|
|
s.syncAsSint16LE(ChewyAni);
|
|
|
|
syncArray(s, PersonGlobalDia, MAX_PERSON);
|
|
|
|
syncArray(s, PersonDia, MAX_PERSON);
|
|
|
|
syncArray(s, PersonDiaRoom, MAX_PERSON);
|
|
|
|
syncArray(s, PersonDiaTmpRoom, MAX_PERSON);
|
|
|
|
|
|
|
|
s.syncAsSint16LE(DiaAMov);
|
|
|
|
s.syncAsSint16LE(scrollx);
|
|
|
|
s.syncAsSint16LE(scrolly);
|
|
|
|
s.syncAsSint16LE(ScrollxStep);
|
|
|
|
s.syncAsSint16LE(ScrollyStep);
|
2022-02-21 00:02:27 +00:00
|
|
|
int16 mouseSpeed = 6;
|
|
|
|
s.syncAsSint16LE(mouseSpeed);
|
2021-10-24 04:09:34 +00:00
|
|
|
s.syncAsSint16LE(DelaySpeed);
|
|
|
|
s.syncAsSint16LE(AadDelay);
|
|
|
|
s.syncAsSint16LE(AadSilent);
|
|
|
|
s.syncAsByte(R0FueterLab);
|
|
|
|
s.syncAsByte(R6RaumBetreten);
|
|
|
|
s.syncAsByte(R6BolaJoke);
|
|
|
|
s.syncAsByte(R7BellCount);
|
|
|
|
s.syncAsByte(R11IdCardNr);
|
|
|
|
s.syncAsByte(R12BorkCount);
|
|
|
|
s.syncAsByte(R13MonitorStatus);
|
|
|
|
s.syncAsByte(R17Location);
|
2022-07-10 14:04:44 +00:00
|
|
|
s.syncAsSint16LE(R23GliderExit);
|
|
|
|
syncArray(s, R24Lever, 3);
|
2021-10-24 04:09:34 +00:00
|
|
|
syncArray(s, R24HebelDir, 3);
|
|
|
|
syncArray(s, R24KristallLast, 3);
|
|
|
|
s.syncAsByte(R25SurimyGo);
|
|
|
|
s.syncAsByte(R27HowardGed);
|
|
|
|
s.syncAsByte(R28PumpTxt1);
|
|
|
|
s.syncAsByte(R28PumpTxt);
|
|
|
|
s.syncAsByte(R31SurimyGo);
|
|
|
|
s.syncAsByte(R33SurimyGo);
|
2022-01-27 22:11:29 +00:00
|
|
|
syncArray(s, R33Munter, 4);
|
2021-10-24 04:09:34 +00:00
|
|
|
s.syncAsSint16LE(R39TvKanal);
|
|
|
|
s.syncAsByte(R39TvRecord);
|
|
|
|
s.syncAsByte(R39ClintNews);
|
|
|
|
s.syncAsByte(R40PoliceAniStatus);
|
|
|
|
s.syncAsByte(R41TrainCount);
|
2022-01-27 22:11:29 +00:00
|
|
|
syncArray(s, R47Schloss, 3);
|
2021-10-24 04:09:34 +00:00
|
|
|
syncArray(s, R48TaxiPerson, MAX_PERSON);
|
2022-01-27 22:11:29 +00:00
|
|
|
syncArray(s, R48Auswahl, 5);
|
2021-10-24 04:09:34 +00:00
|
|
|
s.syncAsByte(R49BoyAniCount);
|
|
|
|
s.syncAsByte(R51DoorCount);
|
|
|
|
s.syncAsByte(R54LiftCount);
|
|
|
|
s.syncAsByte(R54HowardVorne);
|
|
|
|
s.syncAsUint16LE(R55ExitDia);
|
|
|
|
s.syncAsSint16LE(R58TmpRoom);
|
|
|
|
s.syncAsSint16LE(R58TmpRoom1);
|
|
|
|
s.syncAsSint16LE(R58TmpSx);
|
|
|
|
s.syncAsSint16LE(R58TmpSy);
|
|
|
|
s.syncAsSint16LE(R58TmpX);
|
|
|
|
s.syncAsSint16LE(R58TmpY);
|
|
|
|
s.syncAsSint16LE(R64Moni1Ani);
|
|
|
|
s.syncAsSint16LE(R64Moni2Ani);
|
2022-01-27 22:11:29 +00:00
|
|
|
syncArray(s, mi, 8);
|
2021-10-24 04:09:34 +00:00
|
|
|
s.syncAsSint16LE(SVal1);
|
|
|
|
s.syncAsSint16LE(SVal2);
|
|
|
|
s.syncAsSint16LE(SVal3);
|
|
|
|
s.syncAsSint16LE(SVal4);
|
2022-07-07 09:08:43 +00:00
|
|
|
s.syncAsSint16LE(dummy16); // sound loop mode
|
2022-03-20 11:58:05 +00:00
|
|
|
s.syncAsByte(dummy); // sound switch
|
2022-06-20 09:45:19 +00:00
|
|
|
s.syncAsByte(dummy); // sound volume
|
2022-03-20 11:58:05 +00:00
|
|
|
s.syncAsByte(dummy); // music switch
|
2022-06-20 09:45:19 +00:00
|
|
|
s.syncAsByte(dummy); // music volume
|
2022-03-20 11:58:05 +00:00
|
|
|
s.syncAsByte(dummy); // speech switch
|
2021-10-24 04:09:34 +00:00
|
|
|
s.syncAsByte(FramesPerSecond);
|
2022-03-20 11:58:05 +00:00
|
|
|
s.syncAsByte(dummy); // subtitles switch
|
2021-10-24 04:09:34 +00:00
|
|
|
|
2022-06-29 13:23:33 +00:00
|
|
|
_G(cur)->setInventoryCursor(inventoryCursor);
|
2022-06-28 22:21:04 +00:00
|
|
|
|
2021-10-24 04:09:34 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-12-11 04:20:40 +00:00
|
|
|
void *MALLOC(size_t size) {
|
|
|
|
void *ret = malloc(size);
|
|
|
|
Common::fill((byte *)ret, (byte *)ret + size, 0);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-10-24 04:09:34 +00:00
|
|
|
} // namespace Chewy
|