aboutsummaryrefslogtreecommitdiff
path: root/sword2/walker.cpp
diff options
context:
space:
mode:
authorTorbjörn Andersson2003-11-16 14:18:29 +0000
committerTorbjörn Andersson2003-11-16 14:18:29 +0000
commitfa2b8ba8de31f5659c675b507553a2b0a1ebd841 (patch)
tree52841e821b3283a0ff9430cf8be0cc273208f6e6 /sword2/walker.cpp
parentab066c41e0a42320137bc6cb79d77720f932af0e (diff)
downloadscummvm-rg350-fa2b8ba8de31f5659c675b507553a2b0a1ebd841.tar.gz
scummvm-rg350-fa2b8ba8de31f5659c675b507553a2b0a1ebd841.tar.bz2
scummvm-rg350-fa2b8ba8de31f5659c675b507553a2b0a1ebd841.zip
More cleanup. I've eliminated all the temporary global variables I've added
over the past few weeks, except for g_sword2. (Of course, this doesn't necessarily make the code any prettier, but we can work on that later.) svn-id: r11309
Diffstat (limited to 'sword2/walker.cpp')
-rw-r--r--sword2/walker.cpp69
1 files changed, 32 insertions, 37 deletions
diff --git a/sword2/walker.cpp b/sword2/walker.cpp
index ca3690a7ff..0fea2a7d24 100644
--- a/sword2/walker.cpp
+++ b/sword2/walker.cpp
@@ -22,15 +22,10 @@
// script functions for moving megas about the place & also for keeping tabs
// on them
-#include "stdafx.h"
+#include "common/stdafx.h"
#include "sword2/sword2.h"
-#include "sword2/console.h"
#include "sword2/defs.h"
#include "sword2/interpreter.h"
-#include "sword2/logic.h"
-#include "sword2/object.h"
-#include "sword2/protocol.h"
-#include "sword2/router.h"
namespace Sword2 {
@@ -60,9 +55,9 @@ int32 Logic::fnWalk(int32 *params) {
// get the parameters
- ob_logic = (Object_logic *) memory->intToPtr(params[0]);
- ob_graph = (Object_graphic *) memory->intToPtr(params[1]);
- ob_mega = (Object_mega *) memory->intToPtr(params[2]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
+ ob_graph = (Object_graphic *) _vm->_memory->intToPtr(params[1]);
+ ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[2]);
target_x = (int16) params[4];
target_y = (int16) params[5];
@@ -88,7 +83,7 @@ int32 Logic::fnWalk(int32 *params) {
if (params[6] < 0 || params[6] > 8)
error("Invalid direction (%d) in fnWalk", params[6]);
- ob_walkdata = (Object_walkdata *) memory->intToPtr(params[3]);
+ ob_walkdata = (Object_walkdata *) _vm->_memory->intToPtr(params[3]);
ob_mega->walk_pc = 0; // always
@@ -131,7 +126,7 @@ int32 Logic::fnWalk(int32 *params) {
// resource
ob_graph->anim_resource = ob_mega->megaset_res;
- } else if (EXIT_FADING && g_graphics->getFadeStatus() == RDFADE_BLACK) {
+ } else if (EXIT_FADING && _vm->_graphics->getFadeStatus() == RDFADE_BLACK) {
// double clicked an exit so quit the walk when screen is black
// ok, thats it - back to script and change screen
@@ -170,7 +165,7 @@ int32 Logic::fnWalk(int32 *params) {
if (checkEventWaiting()) {
if (walkAnim[walk_pc].step == 0 && walkAnim[walk_pc + 1].step == 1) {
// at the beginning of a step
- ob_walkdata = (Object_walkdata *) memory->intToPtr(params[3]);
+ ob_walkdata = (Object_walkdata *) _vm->_memory->intToPtr(params[3]);
_router->earlySlowOut(ob_mega, ob_walkdata);
}
}
@@ -255,11 +250,11 @@ int32 Logic::fnWalkToAnim(int32 *params) {
// if this is the start of the walk, read anim file to get start coords
- ob_logic = (Object_logic *) memory->intToPtr(params[0]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
if (ob_logic->looping == 0) {
// open anim file
- anim_file = res_man->openResource(params[4]);
+ anim_file = _vm->_resman->openResource(params[4]);
// point to animation header
anim_head = _vm->fetchAnimHeader( anim_file );
@@ -269,7 +264,7 @@ int32 Logic::fnWalkToAnim(int32 *params) {
pars[6] = anim_head->feetStartDir; // target_dir
// close anim file
- res_man->closeResource(params[4]);
+ _vm->_resman->closeResource(params[4]);
// if start coords not yet set in anim header, use the standby
// coords (which should be set beforehand in the script)
@@ -320,13 +315,13 @@ int32 Logic::fnTurn(int32 *params) {
// if this is the start of the turn, get the mega's current feet
// coords + the required direction
- ob_logic = (Object_logic *) memory->intToPtr(params[0]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
if (ob_logic->looping == 0) {
if (params[4] < 0 || params[4] > 7)
error("Invalid direction (%d) in fnTurn", params[4]);
- ob_mega = (Object_mega *) memory->intToPtr(params[2]);
+ ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[2]);
pars[4] = ob_mega->feet_x;
pars[5] = ob_mega->feet_y;
@@ -367,8 +362,8 @@ int32 Logic::fnStandAt(int32 *params) {
// set up pointers to the graphic & mega structure
- ob_graph = (Object_graphic *) memory->intToPtr(params[0]);
- ob_mega = (Object_mega *) memory->intToPtr(params[1]);
+ ob_graph = (Object_graphic *) _vm->_memory->intToPtr(params[0]);
+ ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[1]);
// set up the stand frame & set the mega's new direction
@@ -394,7 +389,7 @@ int32 Logic::fnStand(int32 *params) {
// 1 pointer to object's mega structure
// 2 target direction
- Object_mega *ob_mega = (Object_mega *) memory->intToPtr(params[1]);
+ Object_mega *ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[1]);
int32 pars[5];
pars[0] = params[0];
@@ -423,7 +418,7 @@ int32 Logic::fnStandAfterAnim(int32 *params) {
// open the anim file & set up a pointer to the animation header
// open anim file
- anim_file = res_man->openResource(params[2]);
+ anim_file = _vm->_resman->openResource(params[2]);
anim_head = _vm->fetchAnimHeader(anim_file);
// set up the parameter list for fnWalkTo()
@@ -450,7 +445,7 @@ int32 Logic::fnStandAfterAnim(int32 *params) {
error("Invalid direction (%d) in fnStandAfterAnim", pars[4]);
// close the anim file
- res_man->closeResource(params[2]);
+ _vm->_resman->closeResource(params[2]);
// call fnStandAt() with target coords set to anim end position
return fnStandAt(pars);
@@ -470,7 +465,7 @@ int32 Logic::fnStandAtAnim(int32 *params) {
// open the anim file & set up a pointer to the animation header
// open anim file
- anim_file = res_man->openResource(params[2]);
+ anim_file = _vm->_resman->openResource(params[2]);
anim_head = _vm->fetchAnimHeader(anim_file);
// set up the parameter list for fnWalkTo()
@@ -497,7 +492,7 @@ int32 Logic::fnStandAtAnim(int32 *params) {
error("Invalid direction (%d) in fnStandAfterAnim", pars[4]);
// close the anim file
- res_man->closeResource(params[2]);
+ _vm->_resman->closeResource(params[2]);
// call fnStandAt() with target coords set to anim end position
return fnStandAt(pars);
@@ -556,10 +551,10 @@ int32 Logic::fnFaceXY(int32 *params) {
// if this is the start of the turn, get the mega's current feet
// coords + the required direction
- ob_logic = (Object_logic *) memory->intToPtr(params[0]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
if (ob_logic->looping == 0) {
- ob_mega = (Object_mega *) memory->intToPtr(params[2]);
+ ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[2]);
pars[4] = ob_mega->feet_x;
pars[5] = ob_mega->feet_y;
@@ -591,12 +586,12 @@ int32 Logic::fnFaceMega(int32 *params) {
Object_mega *ob_mega;
_standardHeader *head;
- ob_mega = (Object_mega *) memory->intToPtr(params[2]);
- ob_logic = (Object_logic *) memory->intToPtr(params[0]);
+ ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[2]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
if (ob_logic->looping == 0) {
// get targets info
- head = (_standardHeader *) res_man->openResource(params[4]);
+ head = (_standardHeader *) _vm->_resman->openResource(params[4]);
if (head->fileType != GAME_OBJECT)
error("fnFaceMega %d not an object", params[4]);
@@ -606,7 +601,7 @@ int32 Logic::fnFaceMega(int32 *params) {
//call the base script - this is the graphic/mouse service call
runScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man->closeResource(params[4]);
+ _vm->_resman->closeResource(params[4]);
// engineMega is now the Object_mega of mega we want to turn
// to face
@@ -647,8 +642,8 @@ int32 Logic::fnWalkToTalkToMega(int32 *params) {
int mega_separation = params[5];
_standardHeader *head;
- ob_logic = (Object_logic *) memory->intToPtr(params[0]);
- ob_mega = (Object_mega *) memory->intToPtr(params[2]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
+ ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[2]);
pars[0] = params[0]; // standard stuff
pars[1] = params[1];
@@ -658,7 +653,7 @@ int32 Logic::fnWalkToTalkToMega(int32 *params) {
// not been here before so decide where to walk-to
if (!ob_logic->looping) {
// first request the targets info
- head = (_standardHeader *) res_man->openResource(params[4]);
+ head = (_standardHeader *) _vm->_resman->openResource(params[4]);
if (head->fileType != GAME_OBJECT)
error("fnWalkToTalkToMega %d not an object", params[4]);
@@ -669,7 +664,7 @@ int32 Logic::fnWalkToTalkToMega(int32 *params) {
// call
runScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man->closeResource(params[4]);
+ _vm->_resman->closeResource(params[4]);
// engineMega is now the Object_mega of mega we want to
// route to
@@ -737,8 +732,8 @@ int32 Logic::fnAddWalkGrid(int32 *params) {
_router->addWalkGrid(params[0]);
// Touch the grid, getting it into memory.
- res_man->openResource(params[0]);
- res_man->closeResource(params[0]);
+ _vm->_resman->openResource(params[0]);
+ _vm->_resman->closeResource(params[0]);
return IR_CONT;
}
@@ -771,7 +766,7 @@ int32 Logic::fnSetScaling(int32 *params) {
// where s is system scale, which itself is (256 * actual_scale) ie.
// s == 128 is half size
- Object_mega *ob_mega = (Object_mega *) memory->intToPtr(params[0]);
+ Object_mega *ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[0]);
ob_mega->scale_a = params[1];
ob_mega->scale_b = params[2];