2007-05-30 21:56:52 +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.
|
2003-07-28 01:44:38 +00:00
|
|
|
*
|
2007-05-31 20:28:29 +00:00
|
|
|
* Additional copyright for this file:
|
|
|
|
* Copyright (C) 1994-1998 Revolution Software Ltd.
|
|
|
|
*
|
2003-07-28 01:44:38 +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 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-07-28 01:44:38 +00:00
|
|
|
*/
|
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/textconsole.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
|
2003-10-28 19:51:30 +00:00
|
|
|
#include "sword2/sword2.h"
|
|
|
|
#include "sword2/defs.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
#include "sword2/header.h"
|
2004-02-05 14:19:07 +00:00
|
|
|
#include "sword2/logic.h"
|
|
|
|
#include "sword2/resman.h"
|
2004-11-14 15:00:01 +00:00
|
|
|
#include "sword2/router.h"
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
#include "sword2/sound.h"
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-19 18:40:53 +00:00
|
|
|
namespace Sword2 {
|
|
|
|
|
2004-11-14 15:00:01 +00:00
|
|
|
Logic::Logic(Sword2Engine *vm) :
|
2008-11-09 13:20:43 +00:00
|
|
|
_vm(vm), _kills(0), _currentRunList(0), _moviePlayer(0),
|
|
|
|
_smackerLeadIn(0), _smackerLeadOut(0), _sequenceTextLines(0),
|
|
|
|
_speechTime(0), _animId(0), _speechAnimType(0), _leftClickDelay(0),
|
|
|
|
_rightClickDelay(0), _officialTextNumber(0), _speechTextBlocNo(0) {
|
2005-04-10 16:22:06 +00:00
|
|
|
|
2004-11-14 15:00:01 +00:00
|
|
|
_scriptVars = NULL;
|
|
|
|
memset(_eventList, 0, sizeof(_eventList));
|
|
|
|
memset(_syncList, 0, sizeof(_syncList));
|
|
|
|
_router = new Router(_vm);
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2009-10-20 19:51:32 +00:00
|
|
|
_cycleSkip = false;
|
|
|
|
_speechRunning = false;
|
|
|
|
|
2006-09-09 10:29:14 +00:00
|
|
|
setupOpcodes();
|
2004-11-14 15:00:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Logic::~Logic() {
|
|
|
|
delete _router;
|
|
|
|
}
|
|
|
|
|
2003-10-22 06:51:57 +00:00
|
|
|
/**
|
|
|
|
* Do one cycle of the current session.
|
|
|
|
*/
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-22 07:37:50 +00:00
|
|
|
int Logic::processSession() {
|
2003-09-17 17:34:04 +00:00
|
|
|
// might change during the session, so take a copy here
|
2004-04-07 14:18:27 +00:00
|
|
|
uint32 run_list = _currentRunList;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
_pc = 0; // first object in list
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 17:34:04 +00:00
|
|
|
// by minusing the pc we can cause an immediate cessation of logic
|
|
|
|
// processing on the current list
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-30 06:40:01 +00:00
|
|
|
while (_pc != 0xffffffff) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
byte *game_object_list, *head, *raw_script_ad, *raw_data_ad;
|
|
|
|
uint32 level, ret, script, id;
|
2003-09-17 17:34:04 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
game_object_list = _vm->_resman->openResource(run_list) + ResHeader::size();
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
assert(_vm->_resman->fetchType(run_list) == RUN_LIST);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 17:34:04 +00:00
|
|
|
// read the next id
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
id = READ_LE_UINT32(game_object_list + 4 * _pc);
|
|
|
|
_pc++;
|
|
|
|
|
|
|
|
writeVar(ID, id);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-16 14:18:29 +00:00
|
|
|
_vm->_resman->closeResource(run_list);
|
2003-09-17 17:34:04 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (!id) {
|
2004-04-07 14:18:27 +00:00
|
|
|
// End of list - end the session naturally
|
2003-09-17 17:34:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
assert(_vm->_resman->fetchType(id) == GAME_OBJECT);
|
|
|
|
|
|
|
|
head = _vm->_resman->openResource(id);
|
|
|
|
_curObjectHub.setAddress(head + ResHeader::size());
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
level = _curObjectHub.getLogicLevel();
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
debug(5, "Level %d id(%d) pc(%d)",
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
level,
|
|
|
|
_curObjectHub.getScriptId(level),
|
|
|
|
_curObjectHub.getScriptPc(level));
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
// Do the logic for this object. We keep going until a function
|
|
|
|
// says to stop - remember, system operations are run via
|
|
|
|
// function calls to drivers now.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 17:34:04 +00:00
|
|
|
do {
|
2004-04-07 14:18:27 +00:00
|
|
|
// There is a distinction between running one of our
|
|
|
|
// own scripts and that of another object.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
level = _curObjectHub.getLogicLevel();
|
|
|
|
script = _curObjectHub.getScriptId(level);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (script / SIZE == readVar(ID)) {
|
2004-04-07 14:18:27 +00:00
|
|
|
// It's our own script
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
debug(5, "Run script %d pc=%d",
|
2003-09-27 11:02:58 +00:00
|
|
|
script / SIZE,
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_curObjectHub.getScriptPc(level));
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
// This is the script data. Script and data
|
|
|
|
// object are the same.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
raw_script_ad = head;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
ret = runScript2(raw_script_ad, raw_script_ad, _curObjectHub.getScriptPcPtr(level));
|
2003-09-17 17:34:04 +00:00
|
|
|
} else {
|
2004-04-07 14:18:27 +00:00
|
|
|
// We're running the script of another game
|
|
|
|
// object - get our data object address.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
uint8 type = _vm->_resman->fetchType(script / SIZE);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
assert(type == GAME_OBJECT || type == SCREEN_MANAGER);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
raw_script_ad = _vm->_resman->openResource(script / SIZE);
|
|
|
|
raw_data_ad = head;
|
|
|
|
|
|
|
|
ret = runScript2(raw_script_ad, raw_data_ad, _curObjectHub.getScriptPcPtr(level));
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-16 14:18:29 +00:00
|
|
|
_vm->_resman->closeResource(script / SIZE);
|
2003-09-17 17:34:04 +00:00
|
|
|
|
|
|
|
// reset to us for service script
|
|
|
|
raw_script_ad = raw_data_ad;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-17 17:34:04 +00:00
|
|
|
if (ret == 1) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
level = _curObjectHub.getLogicLevel();
|
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
// The script finished - drop down a level
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (level) {
|
|
|
|
_curObjectHub.setLogicLevel(level - 1);
|
|
|
|
} else {
|
2003-09-17 17:34:04 +00:00
|
|
|
// Hmmm, level 0 terminated :-| Let's
|
|
|
|
// be different this time and simply
|
|
|
|
// let it restart next go :-)
|
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
// Note that this really does happen a
|
|
|
|
// lot, so don't make it a warning.
|
2003-09-17 17:34:04 +00:00
|
|
|
|
2006-04-04 22:04:51 +00:00
|
|
|
debug(5, "object %d script 0 terminated", id);
|
2003-09-17 17:34:04 +00:00
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
// reset to rerun, drop out for a cycle
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_curObjectHub.setScriptPc(level, _curObjectHub.getScriptId(level) & 0xffff);
|
2003-09-17 17:34:04 +00:00
|
|
|
ret = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-17 17:34:04 +00:00
|
|
|
} else if (ret > 2) {
|
2003-10-26 15:42:49 +00:00
|
|
|
error("processSession: illegal script return type %d", ret);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-17 17:34:04 +00:00
|
|
|
// if ret == 2 then we simply go around again - a new
|
|
|
|
// script or subroutine will kick in and run
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 17:34:04 +00:00
|
|
|
// keep processing scripts until 0 for quit is returned
|
2003-09-20 12:24:53 +00:00
|
|
|
} while (ret);
|
2003-09-17 17:34:04 +00:00
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
// Any post logic system requests to go here
|
2003-09-17 17:34:04 +00:00
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
// Clear any syncs that were waiting for this character - it
|
2003-09-17 17:34:04 +00:00
|
|
|
// has used them or now looses them
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
clearSyncs(readVar(ID));
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-30 06:40:01 +00:00
|
|
|
if (_pc != 0xffffffff) {
|
2004-04-07 14:18:27 +00:00
|
|
|
// The session is still valid so run the graphics/mouse
|
|
|
|
// service script
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
runScript(raw_script_ad, raw_script_ad, 0);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-17 17:34:04 +00:00
|
|
|
// and that's it so close the object resource
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_vm->_resman->closeResource(readVar(ID));
|
2003-09-17 17:34:04 +00:00
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
// Leaving a room so remove all ids that must reboot correctly. Then
|
|
|
|
// restart the loop.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
for (uint32 i = 0; i < _kills; i++)
|
|
|
|
_vm->_resman->remove(_objectKillList[i]);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
resetKillList();
|
2003-09-17 17:34:04 +00:00
|
|
|
return 1;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-10-22 06:51:57 +00:00
|
|
|
/**
|
|
|
|
* Bring an immediate halt to the session and cause a new one to start without
|
|
|
|
* a screen update.
|
|
|
|
*/
|
2003-09-17 17:34:04 +00:00
|
|
|
|
2003-10-22 06:51:57 +00:00
|
|
|
void Logic::expressChangeSession(uint32 sesh_id) {
|
2004-04-07 14:18:27 +00:00
|
|
|
// Set new session and force the old one to quit.
|
2003-09-30 06:40:01 +00:00
|
|
|
_currentRunList = sesh_id;
|
|
|
|
_pc = 0xffffffff;
|
2003-09-17 17:34:04 +00:00
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
// Reset now in case we double-clicked an exit prior to changing screen
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
writeVar(EXIT_FADING, 0);
|
2003-09-17 17:34:04 +00:00
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
// We're trashing the list - presumably to change room. In theory,
|
|
|
|
// sync waiting in the list could be left behind and never removed -
|
|
|
|
// so we trash the lot
|
2003-11-08 15:47:51 +00:00
|
|
|
memset(_syncList, 0, sizeof(_syncList));
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
// Various clean-ups
|
2003-11-08 15:47:51 +00:00
|
|
|
_router->clearWalkGridList();
|
2007-01-26 18:21:41 +00:00
|
|
|
_vm->_sound->clearFxQueue(false);
|
2003-11-08 15:47:51 +00:00
|
|
|
_router->freeAllRouteMem();
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-10-22 06:51:57 +00:00
|
|
|
/**
|
|
|
|
* @return The private _currentRunList variable.
|
|
|
|
*/
|
|
|
|
|
2005-02-22 07:37:50 +00:00
|
|
|
uint32 Logic::getRunList() {
|
2003-09-30 06:40:01 +00:00
|
|
|
return _currentRunList;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-10-22 06:51:57 +00:00
|
|
|
/**
|
|
|
|
* Move the current object up a level. Called by fnGosub command. Remember:
|
|
|
|
* only the logic object has access to _curObjectHub.
|
|
|
|
*/
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-22 06:51:57 +00:00
|
|
|
void Logic::logicUp(uint32 new_script) {
|
2003-09-27 11:02:58 +00:00
|
|
|
debug(5, "new pc = %d", new_script & 0xffff);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 14:18:27 +00:00
|
|
|
// going up a level - and we'll keep going this cycle
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_curObjectHub.setLogicLevel(_curObjectHub.getLogicLevel() + 1);
|
2004-04-07 14:18:27 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
assert(_curObjectHub.getLogicLevel() < 3); // Can be 0, 1, 2
|
2004-04-07 14:18:27 +00:00
|
|
|
logicReplace(new_script);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-10-22 06:51:57 +00:00
|
|
|
/**
|
|
|
|
* Force the level to one.
|
|
|
|
*/
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-22 06:51:57 +00:00
|
|
|
void Logic::logicOne(uint32 new_script) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_curObjectHub.setLogicLevel(1);
|
2004-04-07 14:18:27 +00:00
|
|
|
logicReplace(new_script);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-10-22 06:51:57 +00:00
|
|
|
/**
|
|
|
|
* Change current logic. Script must quit with a TERMINATE directive, which
|
|
|
|
* does not write to &pc
|
|
|
|
*/
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-22 06:51:57 +00:00
|
|
|
void Logic::logicReplace(uint32 new_script) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
uint32 level = _curObjectHub.getLogicLevel();
|
|
|
|
|
|
|
|
_curObjectHub.setScriptId(level, new_script);
|
|
|
|
_curObjectHub.setScriptPc(level, new_script & 0xffff);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2005-02-22 07:37:50 +00:00
|
|
|
void Logic::resetKillList() {
|
2003-10-22 06:51:57 +00:00
|
|
|
_kills = 0;
|
2003-09-17 17:34:04 +00:00
|
|
|
}
|
2003-10-04 00:52:27 +00:00
|
|
|
|
2009-04-07 19:52:46 +00:00
|
|
|
/**
|
|
|
|
* Read current location number from script vars
|
|
|
|
*/
|
|
|
|
|
|
|
|
uint32 Logic::getLocationNum() {
|
|
|
|
return readVar(LOCATION);
|
|
|
|
}
|
|
|
|
|
2003-10-04 00:52:27 +00:00
|
|
|
} // End of namespace Sword2
|