void FatWalk::walk(int cluster) { FatEntry root; if (cluster == system.rootDirectory) { root = system.rootEntry(); } else { root.cluster = cluster; root.attributes = FAT_ATTRIBUTES_DIR; root.longName = "/"; } set<int> visited; onEntry(root, root, "/"); doWalk(visited, root, "/"); }
int Router::walkToTalkToMega(byte *ob_logic, byte *ob_graph, byte *ob_mega, byte *ob_walkdata, uint32 megaId, uint32 separation) { ObjectMega obMega(ob_mega); int16 target_x = 0; int16 target_y = 0; uint8 target_dir = 0; // If this is the start of the walk, calculate the route. ObjectLogic obLogic(ob_logic); if (obLogic.getLooping() == 0) { assert(_vm->_resman->fetchType(megaId) == GAME_OBJECT); // Call the base script. This is the graphic/mouse service // call, and will set _engineMega to the ObjectMega of mega we // want to route to. _vm->_logic->runResScript(megaId, 3); ObjectMega targetMega(_vm->_logic->getEngineMega()); // Stand exactly beside the mega, ie. at same y-coord target_y = targetMega.getFeetY(); int scale = obMega.calcScale(); int mega_separation = (separation * scale) / 256; debug(4, "Target is at (%d, %d), separation %d", targetMega.getFeetX(), targetMega.getFeetY(), mega_separation); if (targetMega.getFeetX() < obMega.getFeetX()) { // Target is left of us, so aim to stand to their // right. Face down_left target_x = targetMega.getFeetX() + mega_separation; target_dir = 5; } else { // Ok, must be right of us so aim to stand to their // left. Face down_right. target_x = targetMega.getFeetX() - mega_separation; target_dir = 3; } } return doWalk(ob_logic, ob_graph, ob_mega, ob_walkdata, target_x, target_y, target_dir); }
int Router::doFace(byte *ob_logic, byte *ob_graph, byte *ob_mega, byte *ob_walkdata, uint8 target_dir) { int16 target_x = 0; int16 target_y = 0; // If this is the start of the turn, get the mega's current feet // coords + the required direction ObjectLogic obLogic(ob_logic); if (obLogic.getLooping() == 0) { assert(target_dir <= 7); ObjectMega obMega(ob_mega); target_x = obMega.getFeetX(); target_y = obMega.getFeetY(); } return doWalk(ob_logic, ob_graph, ob_mega, ob_walkdata, target_x, target_y, target_dir); }
int Router::walkToAnim(byte *ob_logic, byte *ob_graph, byte *ob_mega, byte *ob_walkdata, uint32 animRes) { int16 target_x = 0; int16 target_y = 0; uint8 target_dir = 0; // Walkdata is needed for earlySlowOut if player clicks elsewhere // during the walk. // If this is the start of the walk, read anim file to get start coords ObjectLogic obLogic(ob_logic); if (obLogic.getLooping() == 0) { byte *anim_file = _vm->_resman->openResource(animRes); AnimHeader anim_head; anim_head.read(_vm->fetchAnimHeader(anim_file)); target_x = anim_head.feetStartX; target_y = anim_head.feetStartY; target_dir = anim_head.feetStartDir; _vm->_resman->closeResource(animRes); // If start coords not yet set in anim header, use the standby // coords (which should be set beforehand in the script). if (target_x == 0 && target_y == 0) { target_x = _standbyX; target_y = _standbyY; target_dir = _standbyDir; } assert(target_dir <= 7); } return doWalk(ob_logic, ob_graph, ob_mega, ob_walkdata, target_x, target_y, target_dir); }
void FatWalk::doWalk(set<int> &visited, FatEntry ¤tEntry, string name) { int cluster = currentEntry.cluster; if (visited.find(cluster) != visited.end()) { return; } visited.insert(cluster); vector<FatEntry> entries = system.getEntries(cluster); vector<FatEntry>::iterator it; for (it=entries.begin(); it!=entries.end(); it++) { FatEntry &entry = *it; if ((!walkErased) && entry.isErased()) { continue; } if (entry.getFilename() != "." && entry.getFilename() != "..") { string subname = name; if (subname != "" && subname != "/") { subname += "/"; } subname += entry.getFilename(); if (entry.isDirectory()) { onDirectory(currentEntry, entry, subname); doWalk(visited, entry, subname); } onEntry(currentEntry, entry, subname); } } }