From c7da2f38c38a8dc7ad3d88149b24d69d0e84a21a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 3 Nov 2019 01:15:44 +0100 Subject: SCUMM HE: MBC: Properly create arrays on receiving. We now can join the game! --- engines/scumm/he/intern_he.h | 2 +- engines/scumm/he/moonbase/net_main.cpp | 6 ++---- engines/scumm/he/script_v72he.cpp | 13 +++++++++---- 3 files changed, 12 insertions(+), 9 deletions(-) (limited to 'engines/scumm/he') diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h index d1487c76fc..90f78f07c1 100644 --- a/engines/scumm/he/intern_he.h +++ b/engines/scumm/he/intern_he.h @@ -306,7 +306,7 @@ protected: virtual void redrawBGAreas(); virtual void checkExecVerbs(); - byte *defineArray(int array, int type, int dim2start, int dim2end, int dim1start, int dim1end); + byte *defineArray(int array, int type, int dim2start, int dim2end, int dim1start, int dim1end, bool newArray = false, int *newid = NULL); virtual int readArray(int array, int idx2, int idx1); virtual void writeArray(int array, int idx2, int idx1, int value); void redimArray(int arrayId, int newDim2start, int newDim2end, diff --git a/engines/scumm/he/moonbase/net_main.cpp b/engines/scumm/he/moonbase/net_main.cpp index d29154be9f..519a8025a9 100644 --- a/engines/scumm/he/moonbase/net_main.cpp +++ b/engines/scumm/he/moonbase/net_main.cpp @@ -566,20 +566,18 @@ bool Net::remoteReceiveData() { case PACKETTYPE_REMOTESENDSCUMMARRAY: { - int newArray; + int newArray = 0; // Assume that the packet data contains a "SCUMM PACKAGE" // and unpack it into an scumm array :-) - newArray = _vm->findFreeArrayId(); - int dim1start = _packetdata->child("data")->child("dim1start")->asIntegerNumber(); int dim1end = _packetdata->child("data")->child("dim1end")->asIntegerNumber(); int dim2start = _packetdata->child("data")->child("dim2start")->asIntegerNumber(); int dim2end = _packetdata->child("data")->child("dim2end")->asIntegerNumber(); int atype = _packetdata->child("data")->child("type")->asIntegerNumber(); - byte *data = _vm->defineArray(newArray, atype, dim2start, dim2end, dim1start, dim1end); + byte *data = _vm->defineArray(0, atype, dim2start, dim2end, dim1start, dim1end, true, &newArray); int32 size = (dim1end - dim1start + 1) * (dim2end - dim2start + 1); diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp index b2af816afe..d86b0cebdf 100644 --- a/engines/scumm/he/script_v72he.cpp +++ b/engines/scumm/he/script_v72he.cpp @@ -102,7 +102,7 @@ void ScummEngine_v72he::setupOpcodes() { static const int arrayDataSizes[] = { 0, 1, 4, 8, 8, 16, 32 }; byte *ScummEngine_v72he::defineArray(int array, int type, int dim2start, int dim2end, - int dim1start, int dim1end) { + int dim1start, int dim1end, bool newArray, int *newid) { int id; int size; ArrayHeader *ah; @@ -115,13 +115,17 @@ byte *ScummEngine_v72he::defineArray(int array, int type, int dim2start, int dim if (type == kBitArray || type == kNibbleArray) type = kByteArray; - nukeArray(array); + if (!newArray) + nukeArray(array); id = findFreeArrayId(); + if (newid != NULL) + *newid = id; + debug(9, "defineArray (array %d, dim2start %d, dim2end %d dim1start %d dim1end %d", id, dim2start, dim2end, dim1start, dim1end); - if (array & 0x80000000) { + if (!newArray && (array & 0x80000000)) { error("Can't define bit variable as array pointer"); } @@ -130,7 +134,8 @@ byte *ScummEngine_v72he::defineArray(int array, int type, int dim2start, int dim if (_game.heversion >= 80) id |= 0x33539000; - writeVar(array, id); + if (!newArray) + writeVar(array, id); if (_game.heversion >= 80) id &= ~0x33539000; -- cgit v1.2.3