int AgiEngine::runGame() { int ec = errOK; // Execute the game do { debugC(2, kDebugLevelMain, "game loop"); debugC(2, kDebugLevelMain, "game version = 0x%x", getVersion()); if (agiInit() != errOK) break; if (_restartGame) { setflag(fRestartGame, true); _game.lastController = 0; setvar(vTimeDelay, 2); // "normal" speed _restartGame = false; } // Set computer type (v20 i.e. vComputer) and sound type switch (getPlatform()) { case Common::kPlatformAtariST: setvar(vComputer, kAgiComputerAtariST); setvar(vSoundgen, kAgiSoundPC); break; case Common::kPlatformAmiga: if (getFeatures() & GF_OLDAMIGAV20) setvar(vComputer, kAgiComputerAmigaOld); else setvar(vComputer, kAgiComputerAmiga); setvar(vSoundgen, kAgiSoundTandy); break; case Common::kPlatformApple2GS: setvar(vComputer, kAgiComputerApple2GS); if (getFeatures() & GF_2GSOLDSOUND) setvar(vSoundgen, kAgiSound2GSOld); else setvar(vSoundgen, kAgiSoundTandy); break; case Common::kPlatformPC: default: setvar(vComputer, kAgiComputerPC); setvar(vSoundgen, kAgiSoundPC); break; } // Set monitor type (v26 i.e. vMonitor) switch (_renderMode) { case Common::kRenderCGA: setvar(vMonitor, kAgiMonitorCga); break; case Common::kRenderHercG: case Common::kRenderHercA: setvar(vMonitor, kAgiMonitorHercules); break; // Don't know if Amiga AGI games use a different value than kAgiMonitorEga // for vMonitor so I just use kAgiMonitorEga for them (As was done before too). case Common::kRenderAmiga: case Common::kRenderDefault: case Common::kRenderEGA: default: setvar(vMonitor, kAgiMonitorEga); break; } setvar(vFreePages, 180); // Set amount of free memory to realistic value setvar(vMaxInputChars, 38); _game.inputMode = INPUT_NONE; _game.inputEnabled = false; _game.hasPrompt = 0; _game.state = STATE_RUNNING; ec = playGame(); _game.state = STATE_LOADED; agiDeinit(); } while (_restartGame); delete _menu; _menu = NULL; releaseImageStack(); return ec; }
bool AGOSEngine_PN::ifObjectHere(uint16 a) { if (getFeatures() & GF_DEMO) return false; return _variableArray[39] == getptr(_quickptr[11] + a * _quickshort[4] + 2); }
void QgsVectorDataProvider::fillMinMaxCache() { if ( !mCacheMinMaxDirty ) return; const QgsFields& flds = fields(); for ( int i = 0; i < flds.count(); ++i ) { if ( flds[i].type() == QVariant::Int ) { mCacheMinValues[i] = QVariant( INT_MAX ); mCacheMaxValues[i] = QVariant( INT_MIN ); } else if ( flds[i].type() == QVariant::LongLong ) { mCacheMinValues[i] = QVariant( std::numeric_limits<qlonglong>::max() ); mCacheMaxValues[i] = QVariant( std::numeric_limits<qlonglong>::min() ); } else if ( flds[i].type() == QVariant::Double ) { mCacheMinValues[i] = QVariant( DBL_MAX ); mCacheMaxValues[i] = QVariant( -DBL_MAX ); } else { mCacheMinValues[i] = QVariant(); mCacheMaxValues[i] = QVariant(); } } QgsFeature f; QgsAttributeList keys = mCacheMinValues.keys(); QgsFeatureIterator fi = getFeatures( QgsFeatureRequest().setSubsetOfAttributes( keys ) ); while ( fi.nextFeature( f ) ) { QgsAttributes attrs = f.attributes(); for ( QgsAttributeList::const_iterator it = keys.begin(); it != keys.end(); ++it ) { const QVariant& varValue = attrs.at( *it ); if ( varValue.isNull() ) continue; if ( flds[*it].type() == QVariant::Int ) { int value = varValue.toInt(); if ( value < mCacheMinValues[*it].toInt() ) mCacheMinValues[*it] = value; if ( value > mCacheMaxValues[*it].toInt() ) mCacheMaxValues[*it] = value; } else if ( flds[*it].type() == QVariant::LongLong ) { qlonglong value = varValue.toLongLong(); if ( value < mCacheMinValues[*it].toLongLong() ) mCacheMinValues[*it] = value; if ( value > mCacheMaxValues[*it].toLongLong() ) mCacheMaxValues[*it] = value; } else if ( flds[*it].type() == QVariant::Double ) { double value = varValue.toDouble(); if ( value < mCacheMinValues[*it].toDouble() ) mCacheMinValues[*it] = value; if ( value > mCacheMaxValues[*it].toDouble() ) mCacheMaxValues[*it] = value; } else { QString value = varValue.toString(); if ( mCacheMinValues[*it].isNull() || value < mCacheMinValues[*it].toString() ) { mCacheMinValues[*it] = value; } if ( mCacheMaxValues[*it].isNull() || value > mCacheMaxValues[*it].toString() ) { mCacheMaxValues[*it] = value; } } } } mCacheMinMaxDirty = false; }
void CineEngine::initialize() { _globalVars.reinit(NUM_MAX_VAR + 1); // Initialize all savegames' descriptions to empty strings memset(currentSaveName, 0, sizeof(currentSaveName)); // Resize object table to its correct size and reset all its elements g_cine->_objectTable.resize(NUM_MAX_OBJECT); resetObjectTable(); // Resize animation data table to its correct size and reset all its elements g_cine->_animDataTable.resize(NUM_MAX_ANIMDATA); freeAnimDataTable(); // Resize zone data table to its correct size and reset all its elements g_cine->_zoneData.resize(NUM_MAX_ZONE); Common::set_to(g_cine->_zoneData.begin(), g_cine->_zoneData.end(), 0); // Resize zone query table to its correct size and reset all its elements g_cine->_zoneQuery.resize(NUM_MAX_ZONE); Common::set_to(g_cine->_zoneQuery.begin(), g_cine->_zoneQuery.end(), 0); _timerDelayMultiplier = 12; // Set default speed setupOpcodes(); initLanguage(getLanguage()); if (getGameType() == Cine::GType_OS) { renderer = new OSRenderer; } else { renderer = new FWRenderer; } renderer->initialize(); collisionPage = new byte[320 * 200]; memset(collisionPage, 0, 320 * 200); // Clear part buffer as there's nothing loaded into it yet. // Its size will change when loading data into it with the loadPart function. g_cine->_partBuffer.clear(); if (getGameType() == Cine::GType_OS) { readVolCnf(); } loadTextData("texte.dat"); if (getGameType() == Cine::GType_OS && !(getFeatures() & GF_DEMO)) { loadPoldatDat("poldat.dat"); loadErrmessDat("errmess.dat"); } // in case ScummVM engines can be restarted in the future g_cine->_scriptTable.clear(); g_cine->_relTable.clear(); g_cine->_objectScripts.clear(); g_cine->_globalScripts.clear(); g_cine->_bgIncrustList.clear(); freeAnimDataTable(); g_cine->_overlayList.clear(); g_cine->_messageTable.clear(); resetObjectTable(); var8 = 0; var2 = var3 = var4 = var5 = 0; musicIsPlaying = 0; currentDatName[0] = 0; _preLoad = false; if (ConfMan.hasKey("save_slot") && !_restartRequested) { char saveNameBuffer[256]; sprintf(saveNameBuffer, "%s.%1d", _targetName.c_str(), ConfMan.getInt("save_slot")); bool res = makeLoad(saveNameBuffer); if (res) _preLoad = true; } if (!_preLoad) { loadPrc(BOOT_PRC_NAME); strcpy(currentPrcName, BOOT_PRC_NAME); setMouseCursor(MOUSE_CURSOR_NORMAL); } }
void AGOSEngine_Simon2::os2_screenTextPObj() { // 177: inventory descriptions uint vgaSpriteId = getVarOrByte(); uint color = getVarOrByte(); SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); if (getFeatures() & GF_TALKIE) { if (subObject != NULL && subObject->objectFlags & kOFVoice) { uint speechId = subObject->objectFlagValue[getOffsetOfChild2Param(subObject, kOFVoice)]; if (subObject->objectFlags & kOFNumber) { uint speechIdOffs = subObject->objectFlagValue[getOffsetOfChild2Param(subObject, kOFNumber)]; if (speechId == 116) speechId = speechIdOffs + 115; if (speechId == 92) speechId = speechIdOffs + 98; if (speechId == 99) speechId = 9; if (speechId == 97) { switch (speechIdOffs) { case 12: speechId = 109; break; case 14: speechId = 108; break; case 18: speechId = 107; break; case 20: speechId = 106; break; case 22: speechId = 105; break; case 28: speechId = 104; break; case 90: speechId = 103; break; case 92: speechId = 102; break; case 100: speechId = 51; break; default: error("os2_screenTextPObj: invalid case %d", speechIdOffs); } } } if (_speech) playSpeech(speechId, vgaSpriteId); } } if (subObject != NULL && subObject->objectFlags & kOFText && _subtitles) { const char *stringPtr = (const char *)getStringPtrByID(subObject->objectFlagValue[0]); TextLocation *tl = getTextLocation(vgaSpriteId); char buf[256]; int j, k; if (subObject->objectFlags & kOFNumber) { if (_language == Common::HE_ISR) { j = subObject->objectFlagValue[getOffsetOfChild2Param(subObject, kOFNumber)]; k = (j % 10) * 10; k += j / 10; if (!(j % 10)) sprintf(buf,"0%d%s", k, stringPtr); else sprintf(buf,"%d%s", k, stringPtr); } else { sprintf(buf,"%d%s", subObject->objectFlagValue[getOffsetOfChild2Param(subObject, kOFNumber)], stringPtr); } stringPtr = buf; } if (stringPtr != NULL) printScreenText(vgaSpriteId, color, stringPtr, tl->x, tl->y, tl->width); } }
void SimonEngine::printScreenText(uint vgaSpriteId, uint color, const char *string, int16 x, int16 y, int16 width) { char convertedString[320]; char *convertedString2 = convertedString; const char *string2 = string; int16 height, talkDelay; int stringLength = strlen(string); int padding, lettersPerRow, lettersPerRowJustified; const int textHeight = (getGameType() == GType_FF) ? 15: 10; height = textHeight; lettersPerRow = width / 6; lettersPerRowJustified = stringLength / (stringLength / lettersPerRow + 1) + 1; talkDelay = (stringLength + 3) / 3; if ((getGameType() == GType_SIMON1) && (getFeatures() & GF_TALKIE)) { if (_variableArray[141] == 0) _variableArray[141] = 9; _variableArray[85] = _variableArray[141] * talkDelay; } else { if (_variableArray[86] == 0) talkDelay /= 2; if (_variableArray[86] == 2) talkDelay *= 2; _variableArray[85] = talkDelay * 5; } assert(stringLength > 0); if (getGameType() == GType_FF) { uint16 b, pixels, spaces; uint16 curWdth = width; while (1) { string2 = getPixelLength(string, curWdth, pixels); if (*string2 == 0) { spaces = (width - pixels) / 12; if (spaces != 0) spaces--; while (spaces) { *convertedString2++=' '; spaces--; } strcpy(convertedString2, string); break; } while (*string2 != ' ') { byte chr = *string2; pixels -= charWidth[chr]; string2--; } spaces = (width - pixels) / 12; if (spaces != 0) spaces--; while (spaces) { *convertedString2++ = ' '; spaces--; } b = string2 - string; strncpy(convertedString2, string, b); convertedString2 += b; *convertedString2++ = '\n'; height += textHeight; y -= textHeight; if (y < 2) y = 2; curWdth = pixels; string = string2; } } else { while (stringLength > 0) { int pos = 0; if (stringLength > lettersPerRow) { int removeLastWord = 0; if (lettersPerRow > lettersPerRowJustified) { pos = lettersPerRowJustified; while (string[pos] != ' ') pos++; if (pos > lettersPerRow) removeLastWord = 1; } if (lettersPerRow <= lettersPerRowJustified || removeLastWord) { pos = lettersPerRow; while (string[pos] != ' ' && pos > 0) pos--; } height += textHeight; y -= textHeight; } else pos = stringLength; padding = (lettersPerRow - pos) % 2 ? (lettersPerRow - pos) / 2 + 1 : (lettersPerRow - pos) / 2; while (padding--) *convertedString2++ = ' '; stringLength -= pos; while (pos--) *convertedString2++ = *string++; *convertedString2++ = '\n'; string++; // skip space stringLength--; // skip space } *(convertedString2 - 1) = '\0'; } if (getGameType() == GType_SIMON1) stopAnimateSimon1(vgaSpriteId + 199); else stopAnimateSimon2(2, vgaSpriteId); if (getGameType() == GType_FF) { renderString(1, color, width, height, convertedString); } else { color = color * 3 + 192; if (getPlatform() == Common::kPlatformAmiga) renderStringAmiga(vgaSpriteId, color, width, height, convertedString); else renderString(vgaSpriteId, color, width, height, convertedString); } int b = 4; if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) { if (!getBitFlag(133)) b = 3; x /= 8; if (y < 2) y = 2; } if (getGameType() == GType_SIMON1) loadSprite(b, 2, vgaSpriteId + 199, x, y, 12); else loadSprite(b, 2, vgaSpriteId, x, y, 12); }
bool CineEngine::loadTempSaveOS(Common::SeekableReadStream &in) { char musicName[13]; char bgNames[8][13]; // First check the temporary Operation Stealth savegame format header. ChunkHeader hdr; loadChunkHeader(in, hdr); if (hdr.id != TEMP_OS_FORMAT_ID) { warning("loadTempSaveOS: File has incorrect identifier. Not loading savegame"); return false; } else if (hdr.version > CURRENT_OS_SAVE_VER) { warning("loadTempSaveOS: Detected newer format version. Not loading savegame"); return false; } else if ((int)hdr.version < (int)CURRENT_OS_SAVE_VER) { warning("loadTempSaveOS: Detected older format version. Trying to load nonetheless. Things may break"); } else { // hdr.id == TEMP_OS_FORMAT_ID && hdr.version == CURRENT_OS_SAVE_VER debug(3, "loadTempSaveOS: Found correct header (Both the identifier and version number match)."); } // There shouldn't be any data in the header's chunk currently so it's an error if there is. if (hdr.size > 0) { warning("loadTempSaveOS: Format header's chunk seems to contain data so format is incorrect. Not loading savegame"); return false; } // Ok, so we've got a correct header for a temporary Operation Stealth savegame. // Let's start loading the plain savegame data then. currentDisk = in.readUint16BE(); in.read(currentPartName, 13); in.read(currentPrcName, 13); in.read(currentRelName, 13); in.read(currentMsgName, 13); // Load the 8 background names. for (uint i = 0; i < 8; i++) { in.read(bgNames[i], 13); } in.read(currentCtName, 13); // Moved the loading of current procedure, relation, // backgrounds and Ct here because if they were at the // end of this function then the global scripts loading // made an array out of bounds access. In the original // game's disassembly these aren't here but at the end. // The difference is probably in how we handle loading // the global scripts and some other things (i.e. the // loading routines aren't exactly the same and subtle // semantic differences result in having to do things // in a different order). { // Not sure if this is needed with Operation Stealth... checkDataDisk(currentDisk); if (strlen(currentPrcName)) { loadPrc(currentPrcName); } if (strlen(currentRelName)) { loadRel(currentRelName); } // Reset background music in CD version of Future Wars if (getGameType() == GType_FW && (getFeatures() & GF_CD)) { if (strlen(bgNames[0])) { char buffer[20]; removeExtention(buffer, bgNames[0]); g_sound->setBgMusic(atoi(buffer + 1)); } } // Load first background (Uses loadBg) if (strlen(bgNames[0])) { loadBg(bgNames[0]); } // Add backgrounds 1-7 (Uses addBackground) for (int i = 1; i < 8; i++) { if (strlen(bgNames[i])) { addBackground(bgNames[i], i); } } if (strlen(currentCtName)) { loadCtOS(currentCtName); } } loadObjectTable(in); renderer->restorePalette(in, hdr.version); g_cine->_globalVars.load(in, NUM_MAX_VAR); loadZoneData(in); loadCommandVariables(in); char tempCommandBuffer[kMaxCommandBufferSize]; in.read(tempCommandBuffer, kMaxCommandBufferSize); g_cine->_commandBuffer = tempCommandBuffer; renderer->setCommand(g_cine->_commandBuffer); loadZoneQuery(in); // TODO: Use the loaded string (Current music name (String, 13 bytes)). in.read(musicName, 13); // TODO: Use the loaded value (Is music loaded? (Uint16BE, Boolean)). in.readUint16BE(); // TODO: Use the loaded value (Is music playing? (Uint16BE, Boolean)). in.readUint16BE(); renderer->_cmdY = in.readUint16BE(); in.readUint16BE(); // Some unknown variable that seems to always be zero allowPlayerInput = in.readUint16BE(); playerCommand = in.readUint16BE(); commandVar1 = in.readUint16BE(); isDrawCommandEnabled = in.readUint16BE(); var5 = in.readUint16BE(); var4 = in.readUint16BE(); var3 = in.readUint16BE(); var2 = in.readUint16BE(); commandVar2 = in.readUint16BE(); renderer->_messageBg = in.readUint16BE(); // TODO: Use the loaded value (adBgVar1 (Uint16BE)). in.readUint16BE(); currentAdditionalBgIdx = in.readSint16BE(); currentAdditionalBgIdx2 = in.readSint16BE(); // TODO: Check whether the scroll value really gets used correctly after this. // Note that the backgrounds are loaded only later than this value is set. renderer->setScroll(in.readUint16BE()); // TODO: Use the loaded value (adBgVar0 (Uint16BE). Maybe this means bgVar0?). in.readUint16BE(); disableSystemMenu = in.readUint16BE(); // TODO: adBgVar1 = 1 here // Load the animDataTable entries in.readUint16BE(); // Entry count (255 in the PC version of Operation Stealth). in.readUint16BE(); // Entry size (36 in the PC version of Operation Stealth). loadResourcesFromSave(in, ANIMSIZE_30_PTRS_INTACT); loadScreenParams(in); loadGlobalScripts(in); loadObjectScripts(in); loadSeqList(in); loadOverlayList(in); loadBgIncrustFromSave(in); // Left this here instead of moving it earlier in this function with // the other current value loadings (e.g. loading of current procedure, // current backgrounds etc). Mostly emulating the way we've handled // Future Wars savegames and hoping that things work out. if (strlen(currentMsgName)) { loadMsg(currentMsgName); } // TODO: Add current music loading and playing here // TODO: Palette handling? if (in.pos() == in.size()) { debug(3, "loadTempSaveOS: Loaded the whole savefile."); } else { warning("loadTempSaveOS: Loaded the savefile but didn't exhaust it completely. Something was left over"); } return !(in.eos() || in.err()); }
bool AgiEngine::handleController(uint16 key) { ScreenObjEntry *screenObjEgo = &_game.screenObjTable[SCREENOBJECTS_EGO_ENTRY]; if (key == 0) // nothing pressed return false; // This previously skipped processing, when ESC was pressed and called menu directly. // This original approach was bad, because games check different flags before actually allowing the // user to enter the menu. We checked a few common flags, like for example the availability of the prompt. // But this stopped the user being able to enter the menu, when the original interpreter actually allowed it. // We now instead implement this feature using another way for those platforms. if (key == AGI_KEY_ESCAPE) { // Escape pressed, user probably wants to trigger the menu // For PC, just passing ASCII code for ESC will normally trigger a controller // and the scripts will then trigger the menu switch (getPlatform()) { case Common::kPlatformAmiga: case Common::kPlatformApple2GS: case Common::kPlatformAtariST: // For these platforms, the button ESC normally triggered "pause" // But users could at the same time trigger the menu by clicking on the status line // We check, if menu is currently available and supposed to be accessible. // If yes, we do a delayed trigger now, otherwise we continue processing the key just like normal. // // This is probably the solution with the highest compatibility. // Several games also look for special keys see AGI_MENU_TRIGGER_* // And then there's also Mixed Up Mother Goose, which actually hooks the ESC key for the regular menu // // We risk in here of course, that we let the user access the menu, when it shouldn't be possible. // I'm not 100% sure if those other interpreters really only check VM_FLAG_MENUS_ACCESSIBLE // Needs further investigation. if (getFlag(VM_FLAG_MENUS_ACCESSIBLE) && _menu->isAvailable()) { // menu is supposed to be accessible and is also available _menu->delayedExecuteViaKeyboard(); return true; } default: break; } // Otherwise go on and look for the ESC controller } // AGI 3.149 games, The Black Cauldron and King's Quest 4 need KEY_ESCAPE to use menus // Games with the GF_ESCPAUSE flag need KEY_ESCAPE to pause the game // (key == KEY_ESCAPE && getVersion() != 0x3149 && getGameID() != GID_BC && getGameID() != GID_KQ4 && !(getFeatures() & GF_ESCPAUSE)) ) // return false; if ((getGameID() == GID_MH1 || getGameID() == GID_MH2) && (key == AGI_KEY_ENTER) && (!_text->promptIsEnabled())) { key = 0x20; // Set Enter key to Space in Manhunter when prompt is disabled } debugC(3, kDebugLevelInput, "key = %04x", key); for (uint16 curMapping = 0; curMapping < MAX_CONTROLLER_KEYMAPPINGS; curMapping++) { if (_game.controllerKeyMapping[curMapping].keycode == key) { debugC(3, kDebugLevelInput, "event %d: key press", _game.controllerKeyMapping[curMapping].controllerSlot); _game.controllerOccured[_game.controllerKeyMapping[curMapping].controllerSlot] = true; return true; } } int16 newDirection = 0; switch (key) { case AGI_KEY_UP: newDirection = 1; break; case AGI_KEY_DOWN: newDirection = 5; break; case AGI_KEY_LEFT: newDirection = 7; break; case AGI_KEY_RIGHT: newDirection = 3; break; case AGI_KEY_UP_RIGHT: newDirection = 2; break; case AGI_KEY_DOWN_RIGHT: newDirection = 4; break; case AGI_KEY_UP_LEFT: newDirection = 8; break; case AGI_KEY_DOWN_LEFT: newDirection = 6; break; default: break; } if (_game.playerControl) { if (!(getFeatures() & GF_AGIMOUSE)) { // Handle mouse button events if (!_game.mouseHidden) { if (key == AGI_MOUSE_BUTTON_LEFT) { if (getGameID() == GID_PQ1 && getVar(VM_VAR_CURRENT_ROOM) == 116) { // WORKAROUND: Special handling for mouse clicks in the newspaper // screen of PQ1. Fixes bug #3018770. newDirection = 3; // fake a right arrow key (next page) } else { // Click-to-walk mouse interface //v->flags |= fAdjEgoXY; // setting fAdjEgoXY here will at least break "climbing the log" in SQ2 // in case you walked to the log by using the mouse, so don't!!! int16 egoDestinationX = _mouse.pos.x; int16 egoDestinationY = _mouse.pos.y; _gfx->translateDisplayPosToGameScreen(egoDestinationX, egoDestinationY); screenObjEgo->motionType = kMotionEgo; if (egoDestinationX < (screenObjEgo->xSize / 2)) { screenObjEgo->move_x = -1; } else { screenObjEgo->move_x = egoDestinationX - (screenObjEgo->xSize / 2); } screenObjEgo->move_y = egoDestinationY; screenObjEgo->move_stepSize = screenObjEgo->stepSize; return true; } } } } } if (newDirection || key == AGI_KEY_STATIONARY) { // TODO: not sure, what original AGI did with AdjEgoXY screenObjEgo->flags &= ~fAdjEgoXY; if (screenObjEgo->direction == newDirection) { setVar(VM_VAR_EGO_DIRECTION, 0); } else { setVar(VM_VAR_EGO_DIRECTION, newDirection); } if (_game.playerControl) { screenObjEgo->motionType = kMotionNormal; } return true; } return false; }
Common::Error MohawkEngine_Riven::run() { MohawkEngine::run(); // Let's try to open the installer file (it holds extras.mhk) // Though, we set a low priority to prefer the extracted version if (_installerArchive.open("arcriven.z")) SearchMan.add("arcriven.z", &_installerArchive, 0, false); _gfx = new RivenGraphics(this); _video = new RivenVideoManager(this); _sound = new RivenSoundManager(this); _console = new RivenConsole(this); _saveLoad = new RivenSaveLoad(this, _saveFileMan); _optionsDialog = new RivenOptionsDialog(this); _scriptMan = new RivenScriptManager(this); _inventory = new RivenInventory(this); _rnd = new Common::RandomSource("riven"); // Create the cursor manager if (Common::File::exists("rivendmo.exe")) _cursor = new PECursorManager("rivendmo.exe"); else if (Common::File::exists("riven.exe")) _cursor = new PECursorManager("riven.exe"); else // last resort: try the Mac executable _cursor = new MacCursorManager("Riven"); initVars(); // Check the user has copied all the required datafiles if (!checkDatafiles()) { return Common::kNoGameDataFoundError; } // We need to have a cursor source, or the game won't work if (!_cursor->hasSource()) { Common::String message = _("You're missing a Riven executable. The Windows executable is 'riven.exe' or 'rivendmo.exe'. "); message += _("Using the 'arcriven.z' installer file also works. In addition, you can use the Mac 'Riven' executable."); GUIErrorMessage(message); warning("%s", message.c_str()); return Common::kNoGameDataFoundError; } // Open extras.mhk for common images _extrasFile = new MohawkArchive(); // We need extras.mhk for inventory images, marble images, and credits images if (!_extrasFile->openFile("extras.mhk")) { Common::String message = _("You're missing 'extras.mhk'. Using the 'arcriven.z' installer file also works."); GUIErrorMessage(message); warning("%s", message.c_str()); return Common::kNoGameDataFoundError; } // Set the transition speed _gfx->setTransitionMode((RivenTransitionMode) _vars["transitionmode"]); // Start at main cursor _cursor->setCursor(kRivenMainCursor); _cursor->showCursor(); // Let's begin, shall we? if (getFeatures() & GF_DEMO) { // Start the demo off with the videos changeToStack(kStackAspit); changeToCard(6); } else if (ConfMan.hasKey("save_slot")) { // Load game from launcher/command line if requested int gameToLoad = ConfMan.getInt("save_slot"); // Attempt to load the game. Common::Error loadError = _saveLoad->loadGame(gameToLoad); if (loadError.getCode() != Common::kNoError) { return loadError; } } else { // Otherwise, start us off at aspit's card 1 (the main menu) changeToStack(kStackAspit); changeToCard(1); } while (!hasGameEnded()) doFrame(); return Common::kNoError; }
void MohawkEngine_Riven::handleEvents() { // Update background running things checkTimer(); bool needsUpdate = _gfx->runScheduledWaterEffects(); needsUpdate |= _video->updateMovies(); Common::Event event; while (_eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_MOUSEMOVE: checkHotspotChange(); if (!(getFeatures() & GF_DEMO)) { // Check to show the inventory, but it is always "showing" in the demo if (_eventMan->getMousePos().y >= 392) _gfx->showInventory(); else _gfx->hideInventory(); } needsUpdate = true; break; case Common::EVENT_LBUTTONDOWN: if (_curHotspot >= 0) { checkSunnerAlertClick(); runHotspotScript(_curHotspot, kMouseDownScript); } break; case Common::EVENT_LBUTTONUP: // See RivenScript::switchCard() for more information on why we sometimes // disable the next up event. if (!_ignoreNextMouseUp) { if (_curHotspot >= 0) runHotspotScript(_curHotspot, kMouseUpScript); else checkInventoryClick(); } _ignoreNextMouseUp = false; break; case Common::EVENT_KEYDOWN: switch (event.kbd.keycode) { case Common::KEYCODE_d: if (event.kbd.flags & Common::KBD_CTRL) { _console->attach(); _console->onFrame(); } break; case Common::KEYCODE_SPACE: pauseGame(); break; case Common::KEYCODE_F4: _showHotspots = !_showHotspots; if (_showHotspots) { for (uint16 i = 0; i < _hotspotCount; i++) _gfx->drawRect(_hotspots[i].rect, _hotspots[i].enabled); needsUpdate = true; } else refreshCard(); break; case Common::KEYCODE_F5: runDialog(*_optionsDialog); updateZipMode(); break; case Common::KEYCODE_r: // Return to the main menu in the demo on ctrl+r if (event.kbd.flags & Common::KBD_CTRL && getFeatures() & GF_DEMO) { if (_curStack != kStackAspit) changeToStack(kStackAspit); changeToCard(1); } break; case Common::KEYCODE_p: // Play the intro videos in the demo on ctrl+p if (event.kbd.flags & Common::KBD_CTRL && getFeatures() & GF_DEMO) { if (_curStack != kStackAspit) changeToStack(kStackAspit); changeToCard(6); } break; default: break; } break; default: break; } } if (_curHotspot >= 0) runHotspotScript(_curHotspot, kMouseInsideScript); // Update the screen if we need to if (needsUpdate) _system->updateScreen(); // Cut down on CPU usage _system->delayMillis(10); }
void MohawkEngine_Riven::checkInventoryClick() { Common::Point mousePos = _eventMan->getMousePos(); // Don't even bother. We're not in the inventory portion of the screen. if (mousePos.y < 392) return; // In the demo, check if we've clicked the exit button if (getFeatures() & GF_DEMO) { if (g_demoExitRect->contains(mousePos)) { if (_curStack == kStackAspit && _curCard == 1) { // From the main menu, go to the "quit" screen changeToCard(12); } else if (_curStack == kStackAspit && _curCard == 12) { // From the "quit" screen, just quit _gameOver = true; } else { // Otherwise, return to the main menu if (_curStack != kStackAspit) changeToStack(kStackAspit); changeToCard(1); } } return; } // No inventory shown on aspit if (_curStack == kStackAspit) return; // Set the return stack/card id's. _vars["returnstackid"] = _curStack; _vars["returncardid"] = _curCard; // See RivenGraphics::showInventory() for an explanation // of the variables' meanings. bool hasCathBook = _vars["acathbook"] != 0; bool hasTrapBook = _vars["atrapbook"] != 0; // Go to the book if a hotspot contains the mouse if (!hasCathBook) { if (g_atrusJournalRect1->contains(mousePos)) { _gfx->hideInventory(); changeToStack(kStackAspit); changeToCard(5); } } else if (!hasTrapBook) { if (g_atrusJournalRect2->contains(mousePos)) { _gfx->hideInventory(); changeToStack(kStackAspit); changeToCard(5); } else if (g_cathJournalRect2->contains(mousePos)) { _gfx->hideInventory(); changeToStack(kStackAspit); changeToCard(6); } } else { if (g_atrusJournalRect3->contains(mousePos)) { _gfx->hideInventory(); changeToStack(kStackAspit); changeToCard(5); } else if (g_cathJournalRect3->contains(mousePos)) { _gfx->hideInventory(); changeToStack(kStackAspit); changeToCard(6); } else if (g_trapBookRect3->contains(mousePos)) { _gfx->hideInventory(); changeToStack(kStackAspit); changeToCard(7); } } }
Common::Error MohawkEngine_Riven::run() { MohawkEngine::run(); // Let's try to open the installer file (it holds extras.mhk) // Though, we set a low priority to prefer the extracted version if (_installerArchive.open("arcriven.z")) SearchMan.add("arcriven.z", &_installerArchive, 0, false); _gfx = new RivenGraphics(this); _console = new RivenConsole(this); _saveLoad = new RivenSaveLoad(this, _saveFileMan); _externalScriptHandler = new RivenExternal(this); _optionsDialog = new RivenOptionsDialog(this); _scriptMan = new RivenScriptManager(this); _rnd = new Common::RandomSource("riven"); // Create the cursor manager if (Common::File::exists("rivendmo.exe")) _cursor = new PECursorManager("rivendmo.exe"); else if (Common::File::exists("riven.exe")) _cursor = new PECursorManager("riven.exe"); else // last resort: try the Mac executable _cursor = new MacCursorManager("Riven"); initVars(); // We need to have a cursor source, or the game won't work if (!_cursor->hasSource()) { Common::String message = "You're missing a Riven executable. The Windows executable is 'riven.exe' or 'rivendmo.exe'. "; message += "Using the 'arcriven.z' installer file also works. In addition, you can use the Mac 'Riven' executable."; GUIErrorMessage(message); warning("%s", message.c_str()); return Common::kNoGameDataFoundError; } // Open extras.mhk for common images _extrasFile = new MohawkArchive(); // We need extras.mhk for inventory images, marble images, and credits images if (!_extrasFile->openFile("extras.mhk")) { Common::String message = "You're missing 'extras.mhk'. Using the 'arcriven.z' installer file also works."; GUIErrorMessage(message); warning("%s", message.c_str()); return Common::kNoGameDataFoundError; } // Set the transition speed _gfx->setTransitionSpeed(_vars["transitionmode"]); // Start at main cursor _cursor->setCursor(kRivenMainCursor); _cursor->showCursor(); _system->updateScreen(); // Let's begin, shall we? if (getFeatures() & GF_DEMO) { // Start the demo off with the videos changeToStack(kStackAspit); changeToCard(6); } else if (ConfMan.hasKey("save_slot")) { // Load game from launcher/command line if requested uint32 gameToLoad = ConfMan.getInt("save_slot"); Common::StringArray savedGamesList = _saveLoad->generateSaveGameList(); if (gameToLoad > savedGamesList.size()) error ("Could not find saved game"); // Attempt to load the game. On failure, just send us to the main menu. if (_saveLoad->loadGame(savedGamesList[gameToLoad]).getCode() != Common::kNoError) { changeToStack(kStackAspit); changeToCard(1); } } else { // Otherwise, start us off at aspit's card 1 (the main menu) changeToStack(kStackAspit); changeToCard(1); } while (!_gameOver && !shouldQuit()) handleEvents(); return Common::kNoError; }
void AGOSEngine::printScreenText(uint vgaSpriteId, uint color, const char *string, int16 x, int16 y, int16 width) { char convertedString[320]; char *convertedString2 = convertedString; int16 height, talkDelay; int stringLength = strlen(string); int padding, lettersPerRow, lettersPerRowJustified; const int textHeight = 10; height = textHeight; lettersPerRow = width / 6; lettersPerRowJustified = stringLength / (stringLength / lettersPerRow + 1) + 1; talkDelay = (stringLength + 3) / 3; if (getGameType() == GType_SIMON1 && (getFeatures() & GF_TALKIE)) { if (_variableArray[141] == 0) _variableArray[141] = 9; _variableArray[85] = _variableArray[141] * talkDelay; } else { if (_variableArray[86] == 0) talkDelay /= 2; if (_variableArray[86] == 2) talkDelay *= 2; _variableArray[85] = talkDelay * 5; } assert(stringLength > 0); while (stringLength > 0) { int pos = 0; if (stringLength > lettersPerRow) { int removeLastWord = 0; if (lettersPerRow > lettersPerRowJustified) { pos = lettersPerRowJustified; while (string[pos] != ' ') pos++; if (pos > lettersPerRow) removeLastWord = 1; } if (lettersPerRow <= lettersPerRowJustified || removeLastWord) { pos = lettersPerRow; while (string[pos] != ' ' && pos > 0) pos--; } height += textHeight; y -= textHeight; } else pos = stringLength; padding = ((lettersPerRow - pos) % 2) ? (lettersPerRow - pos) / 2 + 1 : (lettersPerRow - pos) / 2; while (padding--) *convertedString2++ = ' '; stringLength -= pos; while (pos--) *convertedString2++ = *string++; *convertedString2++ = '\n'; string++; // skip space stringLength--; // skip space } *(convertedString2 - 1) = '\0'; if (getGameType() == GType_SIMON1) stopAnimate(vgaSpriteId + 199); else stopAnimateSimon2(2, vgaSpriteId); if (getPlatform() == Common::kPlatformAmiga) { color = color * 3 + 1; renderStringAmiga(vgaSpriteId, color, width, height, convertedString); } else { color = color * 3 + 192; renderString(vgaSpriteId, color, width, height, convertedString); } uint16 windowNum = (!getBitFlag(133)) ? 3 : 4; if (getGameType() == GType_SIMON1 && (getFeatures() & GF_DEMO)) windowNum = 4; x /= 8; if (y < 2) y = 2; if (getGameType() == GType_SIMON1) { uint16 id = 199 + vgaSpriteId; animate(windowNum, id / 100, id, x, y, 12); } else { animate(windowNum, 2, vgaSpriteId, x, y, 12); } }
double* featuresExtract(const BYTE* imageArr, LONG width, LONG height) { int *left, *right, *up, *down; //double features[FEATURES_CNT] = { 0 }; double* features = (double*)calloc(FEATURES_CNT, sizeof(double)); int i, j, count8; int innerPointCnt1, innerPointCnt2; left = (int*)malloc(sizeof(int)*height); right = (int*)malloc(sizeof(int)*height); up = (int*)malloc(sizeof(int)*width); down = (int*)malloc(sizeof(int)*width); // 提取左侧面像素点 for (i = 0; i<height; ++i) { left[i] = -1; for (j = 0; j<width; ++j) { if (imageArr[i*width + j]> 0) { left[i] = j; break; } } } // 提取右侧面边像素点 for (i = 0; i<height; ++i) { right[i] = -1; for (j = width - 1; j >= 0; --j) { if (imageArr[i*width + j]> 0) { right[i] = j; break; } } } // 提取上侧面像素点 for (i = 0; i<width; ++i) { up[i] = -1; for (j = 0; j<height; ++j) { if (imageArr[j*width + i]> 0) { up[i] = j; break; } } } // 提取下侧面像素点 for (i = 0; i<width; ++i) { down[i] = -1; for (j = height - 1; j >= 0; --j) { if (imageArr[j*width + i]> 0) { down[i] = j; break; } } } getFeatures(left, height, features, 0); getFeatures(right, height, features, 1); getFeatures(up, width, features, 2); getFeatures(down, width, features, 3); // 提取内部像素点 innerPointCnt1 = 0; for (i = 5; i<height - 3; ++i) { //down[i] = -1; for (j = 5; j<width - 7; ++j) { if (imageArr[i*width + j]> 0) { ++innerPointCnt1; } } } features[FEATURES_CNT - 2] = innerPointCnt1; // 提取内部像素点 innerPointCnt2 = 0; for (i = 3; i<10; ++i) { //down[i] = -1; for (j = 0; j<width; ++j) { if (imageArr[i*width + j]> 0) { ++innerPointCnt2; } } } features[FEATURES_CNT - 1] = innerPointCnt2; return features; }
Common::Error Parallaction_ns::init() { _screenWidth = 320; _screenHeight = 200; if (getPlatform() == Common::kPlatformPC) { _disk = new DosDisk_ns(this); } else { if (getFeatures() & GF_DEMO) { strcpy(_location._name, "fognedemo"); } _disk = new AmigaDisk_ns(this); } _disk->init(); if (getPlatform() == Common::kPlatformPC) { _soundManI = new DosSoundMan_ns(this); _soundManI->setMusicVolume(ConfMan.getInt("music_volume")); } else { _soundManI = new AmigaSoundMan_ns(this); } _soundMan = new SoundMan(_soundManI); initResources(); initFonts(); _locationParser = new LocationParser_ns(this); _locationParser->init(); _programParser = new ProgramParser_ns(this); _programParser->init(); _cmdExec = new CommandExec_ns(this); _programExec = new ProgramExec_ns(this); _walker = new PathWalker_NS(this); _sarcophagusDeltaX = 0; _movingSarcophagus = false; _freeSarcophagusSlotX = INITIAL_FREE_SARCOPHAGUS_SLOT_X; num_foglie = 0; _intro = false; _inTestResult = false; _location._animations.push_front(_char._ani); _saveLoad = new SaveLoad_ns(this, _saveFileMan); initInventory(); setupBalloonManager(); _score = 1; _testResultLabels[0] = 0; _testResultLabels[1] = 0; Parallaction::init(); return Common::kNoError; }
void MohawkEngine_Riven::doFrame() { // Update background running things _sound->updateSLST(); _video->updateMovies(); if (!_scriptMan->hasQueuedScripts()) { _stack->keyResetAction(); } Common::Event event; while (_eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_MOUSEMOVE: _stack->onMouseMove(event.mouse); break; case Common::EVENT_LBUTTONDOWN: _stack->onMouseDown(_eventMan->getMousePos()); break; case Common::EVENT_LBUTTONUP: _stack->onMouseUp(_eventMan->getMousePos()); _inventory->checkClick(_eventMan->getMousePos()); break; case Common::EVENT_KEYUP: _stack->keyResetAction(); break; case Common::EVENT_KEYDOWN: switch (event.kbd.keycode) { case Common::KEYCODE_d: if (event.kbd.flags & Common::KBD_CTRL) { _console->attach(); _console->onFrame(); } break; case Common::KEYCODE_SPACE: pauseGame(); break; case Common::KEYCODE_F5: runDialog(*_optionsDialog); if (_optionsDialog->getLoadSlot() >= 0) loadGameStateAndDisplayError(_optionsDialog->getLoadSlot()); _gfx->setTransitionMode((RivenTransitionMode) _vars["transitionmode"]); _card->initializeZipMode(); break; case Common::KEYCODE_r: // Return to the main menu in the demo on ctrl+r if (event.kbd.flags & Common::KBD_CTRL && getFeatures() & GF_DEMO) { if (_stack->getId() != kStackAspit) changeToStack(kStackAspit); changeToCard(1); } break; case Common::KEYCODE_p: // Play the intro videos in the demo on ctrl+p if (event.kbd.flags & Common::KBD_CTRL && getFeatures() & GF_DEMO) { if (_stack->getId() != kStackAspit) changeToStack(kStackAspit); changeToCard(6); } break; default: if (event.kbdRepeat) { continue; } _stack->onKeyPressed(event.kbd); break; } break; default: break; } } _stack->onFrame(); if (!_scriptMan->runningQueuedScripts()) { // Don't run queued scripts if we are calling from a queued script // otherwise infinite looping will happen. _scriptMan->runQueuedScripts(); } _inventory->onFrame(); // Update the screen once per frame _system->updateScreen(); // Cut down on CPU usage _system->delayMillis(10); }
ColorId SagaEngine::KnownColor2ColorId(KnownColor knownColor) { ColorId colorId = kITEColorTransBlack; if (getGameId() == GID_ITE) { switch (knownColor) { case(kKnownColorTransparent): colorId = kITEColorTransBlack; break; case (kKnownColorBrightWhite): colorId = kITEColorBrightWhite; break; case (kKnownColorWhite): colorId = kITEColorWhite; break; case (kKnownColorBlack): colorId = kITEColorBlack; break; case (kKnownColorSubtitleTextColor): colorId = (ColorId)255; break; case (kKnownColorVerbText): colorId = kITEColorBlue; break; case (kKnownColorVerbTextShadow): colorId = kITEColorBlack; break; case (kKnownColorVerbTextActive): colorId = (ColorId)96; break; default: error("SagaEngine::KnownColor2ColorId unknown color %i", knownColor); } #ifdef ENABLE_IHNM } else if (getGameId() == GID_IHNM) { // The default colors in the Spanish, version of IHNM are shifted by one // Fixes bug #1848016 - "IHNM: Wrong Subtitles Color (Spanish)". This // also applies to the German and French versions (bug #7064 - "IHNM: // text mistake in german version"). int offset = (getFeatures() & GF_IHNM_COLOR_FIX) ? 1 : 0; switch (knownColor) { case(kKnownColorTransparent): colorId = (ColorId)(249 - offset); break; case (kKnownColorBrightWhite): colorId = (ColorId)(251 - offset); break; case (kKnownColorWhite): colorId = (ColorId)(251 - offset); break; case (kKnownColorBlack): colorId = (ColorId)(249 - offset); break; case (kKnownColorVerbText): colorId = (ColorId)(253 - offset); break; case (kKnownColorVerbTextShadow): colorId = (ColorId)(15 - offset); break; case (kKnownColorVerbTextActive): colorId = (ColorId)(252 - offset); break; default: error("SagaEngine::KnownColor2ColorId unknown color %i", knownColor); } #endif } return colorId; }
void AGOSEngine_Simon1::drawMaskedImage(VC10_state *state) { if (getGameType() == GType_SIMON1 && (_windowNum == 3 || _windowNum == 4 || _windowNum >= 10)) { state->surf2_addr += _videoWindows[17] * 320; } if (getFeatures() & GF_32COLOR) { const byte *mask = state->srcPtr + (state->width * state->y_skip * 16) + (state->x_skip * 8); byte *src = state->surf2_addr; byte *dst = state->surf_addr; state->draw_width *= 2; uint h = state->draw_height; do { for (uint i = 0; i != state->draw_width; i++) { if (getGameType() == GType_SIMON1 && getBitFlag(88)) { /* transparency */ if (mask[i] && (dst[i] & 16)) dst[i] = src[i]; } else { /* no transparency */ if (mask[i]) dst[i] = src[i]; } } dst += state->surf_pitch; src += state->surf2_pitch; mask += state->width * 16; } while (--h); } else if (state->flags & kDFCompressed) { byte *mask, *src, *dst; byte h; uint w; state->x_skip *= 4; state->dl = state->width; state->dh = state->height; vc10_skip_cols(state); w = 0; do { mask = vc10_depackColumn(state); /* esi */ src = state->surf2_addr + w * 2; /* ebx */ dst = state->surf_addr + w * 2; /* edi */ h = state->draw_height; do { if (getGameType() == GType_SIMON1 && getBitFlag(88)) { /* transparency */ if ((mask[0] & 0xF0) && (dst[0] & 0x0F0) == 0x20) dst[0] = src[0]; if ((mask[0] & 0x0F) && (dst[1] & 0x0F0) == 0x20) dst[1] = src[1]; } else { /* no transparency */ if (mask[0] & 0xF0) dst[0] = src[0]; if (mask[0] & 0x0F) dst[1] = src[1]; } mask++; dst += state->surf_pitch; src += state->surf2_pitch; } while (--h); } while (++w != state->draw_width); } else { const byte *src, *mask; byte *dst; uint count; mask = state->srcPtr + (state->width * state->y_skip) * 8; src = state->surf2_addr; dst = state->surf_addr; state->x_skip *= 4; do { for (count = 0; count != state->draw_width; count++) { if (getGameType() == GType_SIMON1 && getBitFlag(88)) { /* transparency */ if (mask[count + state->x_skip] & 0xF0) if ((dst[count * 2] & 0xF0) == 0x20) dst[count * 2] = src[count * 2]; if (mask[count + state->x_skip] & 0x0F) if ((dst[count * 2 + 1] & 0x0F) == 0x20) dst[count * 2 + 1] = src[count * 2 + 1]; } else { /* no transparency */ if (mask[count + state->x_skip] & 0xF0) dst[count * 2] = src[count * 2]; if (mask[count + state->x_skip] & 0x0F) dst[count * 2 + 1] = src[count * 2 + 1]; } } src += state->surf2_pitch; dst += state->surf_pitch; mask += state->width * 8; } while (--state->draw_height); } }
uint SimonEngine::loadTextFile(const char *filename, byte *dst) { if (getFeatures() & GF_OLD_BUNDLE) return loadTextFile_simon1(filename, dst); else return loadTextFile_gme(filename, dst); }
int main(int argc, const char *argv[]) { if (argc != 7) { std::cerr << "Expected 6 arguments" << std::endl; std::cerr << "Usage: boostGivenOrder targetStudent givenOrderFile targetDir sourceDir maxNumBoosts numTargetInstances" << std::endl; return 1; } std::string targetStudent = argv[1]; std::string givenOrderFile = argv[2]; std::string targetDir = argv[3]; std::string sourceDir = argv[4]; unsigned int maxNumBoosts = boost::lexical_cast<unsigned int>(argv[5]); int numTargetInstances = 4 * boost::lexical_cast<int>(argv[6]); std::vector<std::string> orderedStudents; std::vector<double> orderedEvals; std::ifstream in(givenOrderFile.c_str()); assert(in.good()); while (in.good()) { std::string str; float val; in >> val; if (in.eof()) break; in >> str; if (str.size() == 0) break; orderedEvals.push_back(val); orderedStudents.push_back(str); if (orderedStudents.size() >= maxNumBoosts) break; } in.close(); for (unsigned int i = 0; i < orderedStudents.size(); i++) { std::cout << orderedEvals[i] << " " << orderedStudents[i] << std::endl; } Json::Value baseLearnerOptions; baseLearnerOptions["type"] = "weka"; baseLearnerOptions["caching"] = false; baseLearnerOptions["options"] = "weka.classifiers.trees.REPTree"; ClassifierPtr (*baseLearner)(const std::vector<Feature>&,const Json::Value&) = &createClassifier; std::vector<Feature> features = getFeatures(); std::cout << "Creating classifier" << std::endl << std::flush; TwoStageTrAdaBoost classifier(features,false,baseLearner,baseLearnerOptions,10,2,-1); std::cout << "done creating classifier" << std::endl << std::flush; readAndAddArff(getArffName(targetStudent,targetDir),classifier,false,false,1.0,numTargetInstances); std::cout << "HERE" << std::endl; std::vector<float> studentWeights; BOOST_FOREACH(std::string &student, orderedStudents) { readAndAddArff(getArffName(student,sourceDir),classifier,true,false); classifier.train(); std::cout << "done training classifier" << std::endl << std::flush; //std::cout << classifier << std::endl; classifier.clearSourceData(); float sourceInstanceWeight = classifier.getBestSourceInstanceWeight(); studentWeights.push_back(sourceInstanceWeight); std::cout << "STUDENT WEIGHT: " << sourceInstanceWeight << " " << student << std::endl; if (sourceInstanceWeight > 1e-10) { readAndAddArff(getArffName(student,sourceDir),classifier,true,true,sourceInstanceWeight); } }
Common::Error AGOSEngine::init() { if (getGameId() == GID_DIMP) { _screenWidth = 496; _screenHeight = 400; } else if (getGameType() == GType_FF || getGameType() == GType_PP) { _screenWidth = 640; _screenHeight = 480; } else { _screenWidth = 320; _screenHeight = 200; } initGraphics(_screenWidth, _screenHeight, getGameType() == GType_FF || getGameType() == GType_PP); if ((getGameType() == GType_SIMON2 && getPlatform() == Common::kPlatformWindows) || (getGameType() == GType_SIMON1 && getPlatform() == Common::kPlatformWindows) || ((getFeatures() & GF_TALKIE) && getPlatform() == Common::kPlatformAcorn) || (getPlatform() == Common::kPlatformPC)) { int ret = _midi.open(getGameType()); if (ret) warning("MIDI Player init failed: \"%s\"", MidiDriver::getErrorName(ret)); _midi.setVolume(ConfMan.getInt("music_volume"), ConfMan.getInt("sfx_volume")); _midiEnabled = true; } // Setup mixer syncSoundSettings(); // allocate buffers _backGroundBuf = new Graphics::Surface(); _backGroundBuf->create(_screenWidth, _screenHeight, 1); if (getGameType() == GType_FF || getGameType() == GType_PP) { _backBuf = new Graphics::Surface(); _backBuf->create(_screenWidth, _screenHeight, 1); _scaleBuf = new Graphics::Surface(); _scaleBuf->create(_screenWidth, _screenHeight, 1); } if (getGameType() == GType_SIMON2) { _window4BackScn = new Graphics::Surface(); _window4BackScn->create(_screenWidth, _screenHeight, 1); } else if (getGameType() == GType_SIMON1) { _window4BackScn = new Graphics::Surface(); _window4BackScn->create(_screenWidth, 134, 1); } else if (getGameType() == GType_WW || getGameType() == GType_ELVIRA2) { _window4BackScn = new Graphics::Surface(); _window4BackScn->create(224, 127, 1); } else if (getGameType() == GType_ELVIRA1) { _window4BackScn = new Graphics::Surface(); if (getPlatform() == Common::kPlatformAmiga && (getFeatures() & GF_DEMO)) { _window4BackScn->create(224, 196, 1); } else { _window4BackScn->create(224, 144, 1); } _window6BackScn = new Graphics::Surface(); _window6BackScn->create(48, 80, 1); } setupGame(); _debugger = new Debugger(this); _sound = new Sound(this, gss, _mixer); if (ConfMan.hasKey("music_mute") && ConfMan.getBool("music_mute") == 1) { _musicPaused = true; if (_midiEnabled) { _midi.pause(_musicPaused); } _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, 0); } if (ConfMan.hasKey("sfx_mute") && ConfMan.getBool("sfx_mute") == 1) { if (getGameId() == GID_SIMON1DOS) _midi._enable_sfx = !_midi._enable_sfx; else { _effectsPaused = !_effectsPaused; _sound->effectsPause(_effectsPaused); } } _copyProtection = ConfMan.getBool("copy_protection"); _language = Common::parseLanguage(ConfMan.get("language")); if (getGameType() == GType_PP) { _speech = true; _subtitles = false; } else if (getFeatures() & GF_TALKIE) { _speech = !ConfMan.getBool("speech_mute"); _subtitles = ConfMan.getBool("subtitles"); if (getGameType() == GType_SIMON1) { // English and German versions don't have full subtitles if (_language == Common::EN_ANY || _language == Common::DE_DEU) _subtitles = false; // Other versions require speech to be enabled else _speech = true; } // Default to speech only, if both speech and subtitles disabled if (!_speech && !_subtitles) _speech = true; } else { _speech = false; _subtitles = true; } // TODO: Use special debug levels instead of the following hack. _debugMode = (gDebugLevel >= 0); if (gDebugLevel == 2) _dumpOpcodes = true; if (gDebugLevel == 3) _dumpVgaOpcodes = true; if (gDebugLevel == 4) _dumpScripts = true; if (gDebugLevel == 5) _dumpVgaScripts = true; return Common::kNoError; }
void AGOSEngine::dumpBitmap(const char *filename, const byte *offs, uint16 w, uint16 h, int flags, const byte *palette, byte base) { byte *imageBuffer = (byte *)malloc(w * h); assert(imageBuffer); VC10_state state; state.depack_cont = -0x80; state.srcPtr = offs; state.dh = h; state.height = h; state.width = w / 16; if (getFeatures() & GF_PLANAR) { state.srcPtr = convertImage(&state, (getGameType() == GType_PN || (flags & 0x80) != 0)); flags &= ~0x80; } const byte *src = state.srcPtr; byte *dst = imageBuffer; int i, j; if (w > _screenWidth) { for (i = 0; i < w; i += 8) { decodeColumn(dst, src + readUint32Wrapper(src), h, w); dst += 8; src += 4; } } else if (h > _screenHeight) { for (i = 0; i < h; i += 8) { decodeRow(dst, src + readUint32Wrapper(src), w, w); dst += 8 * w; src += 4; } } else if (getGameType() == GType_FF || getGameType() == GType_PP) { if ((flags & 0x80)) { for (i = 0; i != w; i++) { byte *c = vc10_depackColumn(&state); for (j = 0; j != h; j++) { dst[j * w + i] = c[j]; } } } else { for (j = 0; j != h; j++) { for (i = 0; i != w; i++) { dst[i] = src[i]; } } dst += w; src += w; } } else if ((getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) && w == 320 && (h == 134 || h == 200)) { for (j = 0; j != h; j++) { uint16 count = w / 8; byte *dstPtr = dst; do { uint32 bits = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | (src[3]); dstPtr[0] = (byte)((bits >> (32 - 5)) & 31); dstPtr[1] = (byte)((bits >> (32 - 10)) & 31); dstPtr[2] = (byte)((bits >> (32 - 15)) & 31); dstPtr[3] = (byte)((bits >> (32 - 20)) & 31); dstPtr[4] = (byte)((bits >> (32 - 25)) & 31); dstPtr[5] = (byte)((bits >> (32 - 30)) & 31); bits = (bits << 8) | src[4]; dstPtr[6] = (byte)((bits >> (40 - 35)) & 31); dstPtr[7] = (byte)((bits) & 31); dstPtr += 8; src += 5; } while (--count); dst += w; } } else if (flags & 0x80) {
void Parallaction_br::changeLocation() { if (_newLocationName.empty()) { return; } if (_nextPart != -1) { cleanupGame(); // more cleanup needed for part changes (see also saveload) _globalFlags = 0; cleanInventory(true); strcpy(_characterName1, "null"); _part = _nextPart; if (getFeatures() & GF_DEMO) { assert(_part == 1); } else { assert(_part >= 0 && _part <= 4); } _disk->selectArchive(_partNames[_part]); memset(_counters, 0, ARRAYSIZE(_counters)); _globalFlagsNames = _disk->loadTable("global"); _objectsNames = _disk->loadTable("objects"); _countersNames = _disk->loadTable("counters"); // TODO: maybe handle this into Disk delete _objects; if (getPlatform() == Common::kPlatformPC) { _objects = _disk->loadObjects("icone.ico"); } else { _objects = _disk->loadObjects("icons.ico", _part); } parseLocation("common.slf"); } freeLocation(false); // load new location strcpy(_location._name, _newLocationName.c_str()); parseLocation(_location._name); if (_location._startPosition.x != -1000) { _char._ani->setFoot(_location._startPosition); _char._ani->setF(_location._startFrame); } // re-link the follower animation setFollower(_followerName); if (_follower) { Common::Point p = _location._followerStartPosition; if (p.x == -1000) { _char._ani->getFoot(p); } _follower->setFoot(p); _follower->setF(_location._followerStartFrame); } _location._startPosition.x = -1000; _location._startPosition.y = -1000; _location._followerStartPosition.x = -1000; _location._followerStartPosition.y = -1000; _gfx->setScrollPosX(0); _gfx->setScrollPosY(0); if (_char._ani->gfxobj) { Common::Point foot; _char._ani->getFoot(foot); if (foot.x > 550) _gfx->setScrollPosX(320); if (foot.y > 350) _gfx->setScrollPosY(foot.y - 350); } // kFlagsRemove is cleared because the character is visible by default. // Commands can hide the character, anyway. _char._ani->_flags &= ~kFlagsRemove; _cmdExec->run(_location._commands); doLocationEnterTransition(); _cmdExec->run(_location._aCommands); // NOTE: music should not started here! // TODO: implement the music commands which control music execution _soundMan->execute(SC_PLAYMUSIC); _engineFlags &= ~kEngineChangeLocation; _newLocationName.clear(); _nextPart = -1; }
void AGOSEngine::loadGamePcFile() { Common::File in; int fileSize; if (getFileName(GAME_BASEFILE) != NULL) { /* Read main gamexx file */ in.open(getFileName(GAME_BASEFILE)); if (in.isOpen() == false) { error("loadGamePcFile: Can't load gamexx file '%s'", getFileName(GAME_BASEFILE)); } if (getFeatures() & GF_CRUNCHED_GAMEPC) { uint srcSize = in.size(); byte *srcBuf = (byte *)malloc(srcSize); in.read(srcBuf, srcSize); uint dstSize = READ_BE_UINT32(srcBuf + srcSize - 4); byte *dstBuf = (byte *)malloc(dstSize); decrunchFile(srcBuf, dstBuf, srcSize); free(srcBuf); Common::MemoryReadStream stream(dstBuf, dstSize); readGamePcFile(&stream); free(dstBuf); } else { readGamePcFile(&in); } in.close(); } if (getFileName(GAME_TBLFILE) != NULL) { /* Read list of TABLE resources */ in.open(getFileName(GAME_TBLFILE)); if (in.isOpen() == false) { error("loadGamePcFile: Can't load table resources file '%s'", getFileName(GAME_TBLFILE)); } fileSize = in.size(); _tblList = (byte *)malloc(fileSize); if (_tblList == NULL) error("loadGamePcFile: Out of memory for strip table list"); in.read(_tblList, fileSize); in.close(); /* Remember the current state */ _subroutineListOrg = _subroutineList; _tablesHeapPtrOrg = _tablesHeapPtr; _tablesHeapCurPosOrg = _tablesHeapCurPos; } if (getFileName(GAME_STRFILE) != NULL) { /* Read list of TEXT resources */ in.open(getFileName(GAME_STRFILE)); if (in.isOpen() == false) error("loadGamePcFile: Can't load text resources file '%s'", getFileName(GAME_STRFILE)); fileSize = in.size(); _strippedTxtMem = (byte *)malloc(fileSize); if (_strippedTxtMem == NULL) error("loadGamePcFile: Out of memory for strip text list"); in.read(_strippedTxtMem, fileSize); in.close(); } if (getFileName(GAME_STATFILE) != NULL) { /* Read list of ROOM STATE resources */ in.open(getFileName(GAME_STATFILE)); if (in.isOpen() == false) { error("loadGamePcFile: Can't load state resources file '%s'", getFileName(GAME_STATFILE)); } _numRoomStates = in.size() / 8; _roomStates = (RoomState *)calloc(_numRoomStates, sizeof(RoomState)); if (_roomStates == NULL) error("loadGamePcFile: Out of memory for room state list"); for (uint s = 0; s < _numRoomStates; s++) { uint16 num = in.readUint16BE() - (_itemArrayInited - 2); _roomStates[num].state = in.readUint16BE(); _roomStates[num].classFlags = in.readUint16BE(); _roomStates[num].roomExitStates = in.readUint16BE(); } in.close(); } if (getFileName(GAME_RMSLFILE) != NULL) { /* Read list of ROOM ITEMS resources */ in.open(getFileName(GAME_RMSLFILE)); if (in.isOpen() == false) { error("loadGamePcFile: Can't load room resources file '%s'", getFileName(GAME_RMSLFILE)); } fileSize = in.size(); _roomsList = (byte *)malloc(fileSize); if (_roomsList == NULL) error("loadGamePcFile: Out of memory for room items list"); in.read(_roomsList, fileSize); in.close(); } if (getFileName(GAME_XTBLFILE) != NULL) { /* Read list of XTABLE resources */ in.open(getFileName(GAME_XTBLFILE)); if (in.isOpen() == false) { error("loadGamePcFile: Can't load xtable resources file '%s'", getFileName(GAME_XTBLFILE)); } fileSize = in.size(); _xtblList = (byte *)malloc(fileSize); if (_xtblList == NULL) error("loadGamePcFile: Out of memory for strip xtable list"); in.read(_xtblList, fileSize); in.close(); /* Remember the current state */ _xsubroutineListOrg = _subroutineList; _xtablesHeapPtrOrg = _tablesHeapPtr; _xtablesHeapCurPosOrg = _tablesHeapCurPos; } }
int AgiEngine::agiInit() { int ec, i; debug(2, "initializing"); debug(2, "game version = 0x%x", getVersion()); // initialize with adj.ego.move.to.x.y(0, 0) so to speak _game.adjMouseX = _game.adjMouseY = 0; // reset all flags to false and all variables to 0 for (i = 0; i < MAX_FLAGS; i++) _game.flags[i] = 0; for (i = 0; i < MAX_VARS; i++) _game.vars[i] = 0; // clear all resources and events for (i = 0; i < MAX_DIRS; i++) { memset(&_game.views[i], 0, sizeof(struct AgiView)); memset(&_game.pictures[i], 0, sizeof(struct AgiPicture)); memset(&_game.logics[i], 0, sizeof(struct AgiLogic)); memset(&_game.sounds[i], 0, sizeof(class AgiSound *)); // _game.sounds contains pointers now memset(&_game.dirView[i], 0, sizeof(struct AgiDir)); memset(&_game.dirPic[i], 0, sizeof(struct AgiDir)); memset(&_game.dirLogic[i], 0, sizeof(struct AgiDir)); memset(&_game.dirSound[i], 0, sizeof(struct AgiDir)); } // clear view table for (i = 0; i < MAX_VIEWTABLE; i++) memset(&_game.viewTable[i], 0, sizeof(struct VtEntry)); initWords(); if (!_menu) _menu = new Menu(this, _gfx, _picture); initPriTable(); // Clear the string buffer on startup, but not when the game restarts, as // some scripts expect that the game strings remain unaffected after a // restart. An example is script 98 in SQ2, which is not invoked on restart // to ask Ego's name again. The name is supposed to be maintained in string 1. // Fixes bug #3292784. if (!_restartGame) { for (i = 0; i < MAX_STRINGS; i++) _game.strings[i][0] = 0; } // setup emulation switch (getVersion() >> 12) { case 2: debug("Emulating Sierra AGI v%x.%03x", (int)(getVersion() >> 12) & 0xF, (int)(getVersion()) & 0xFFF); break; case 3: debug("Emulating Sierra AGI v%x.002.%03x", (int)(getVersion() >> 12) & 0xF, (int)(getVersion()) & 0xFFF); break; } if (getPlatform() == Common::kPlatformAmiga) _game.gameFlags |= ID_AMIGA; if (getFeatures() & GF_AGDS) _game.gameFlags |= ID_AGDS; // Make the 256 color AGI screen the default AGI screen when AGI256 or AGI256-2 is used if (getFeatures() & (GF_AGI256 | GF_AGI256_2)) _game.sbuf = _game.sbuf256c; if (_game.gameFlags & ID_AMIGA) debug(1, "Amiga padded game detected."); if (_game.gameFlags & ID_AGDS) debug(1, "AGDS mode enabled."); ec = _loader->init(); // load vol files, etc if (ec == errOK) ec = _loader->loadObjects(OBJECTS); // note: demogs has no words.tok if (ec == errOK) ec = _loader->loadWords(WORDS); // FIXME: load IIgs instruments and samples // load_instruments("kq.sys16"); // Load logic 0 into memory if (ec == errOK) ec = _loader->loadResource(rLOGIC, 0); #ifdef __DS__ // Normally, the engine loads the predictive text dictionary when the predictive dialog // is shown. On the DS version, the word completion feature needs the dictionary too. // FIXME - loadDict() no long exists in AGI as this has been moved to within the // GUI Predictive Dialog, but DS Word Completion is probably broken due to this... #endif _egoHoldKey = false; _game.mouseFence.setWidth(0); // Reset return ec; }
void AgiBase::initRenderMode() { Common::Platform platform = Common::parsePlatform(ConfMan.get("platform")); Common::RenderMode configRenderMode = Common::parseRenderMode(ConfMan.get("render_mode").c_str()); // Default to EGA PC rendering _renderMode = Common::kRenderEGA; switch (platform) { case Common::kPlatformDOS: switch (configRenderMode) { case Common::kRenderCGA: _renderMode = Common::kRenderCGA; break; // Hercules is not supported atm //case Common::kRenderHercA: //case Common::kRenderHercG: // _renderMode = Common::kRenderHercG; // break; default: break; } break; case Common::kPlatformAmiga: _renderMode = Common::kRenderAmiga; break; case Common::kPlatformApple2GS: _renderMode = Common::kRenderApple2GS; break; case Common::kPlatformAtariST: _renderMode = Common::kRenderAtariST; break; case Common::kPlatformMacintosh: _renderMode = Common::kRenderMacintosh; break; default: break; } // If render mode is explicitly set, force rendermode switch (configRenderMode) { case Common::kRenderCGA: _renderMode = Common::kRenderCGA; break; case Common::kRenderEGA: _renderMode = Common::kRenderEGA; break; case Common::kRenderVGA: _renderMode = Common::kRenderVGA; break; case Common::kRenderAmiga: _renderMode = Common::kRenderAmiga; break; case Common::kRenderApple2GS: _renderMode = Common::kRenderApple2GS; break; case Common::kRenderAtariST: _renderMode = Common::kRenderAtariST; break; case Common::kRenderMacintosh: _renderMode = Common::kRenderMacintosh; break; default: break; } if (getFeatures() & (GF_AGI256 | GF_AGI256_2)) { // If current game is AGI256, switch (force) to VGA render mode _renderMode = Common::kRenderVGA; } }
bool AGOSEngine_PN::ifObjectAt(uint16 a, uint16 b) { if (getFeatures() & GF_DEMO) return false; return b == getptr(_quickptr[11] + a * _quickshort[4] + 2); }
int AgiEngine::agiInit() { int ec, i; debug(2, "initializing"); debug(2, "game version = 0x%x", getVersion()); // initialize with adj.ego.move.to.x.y(0, 0) so to speak _game.adjMouseX = _game.adjMouseY = 0; // reset all flags to false and all variables to 0 memset(_game.flags, 0, sizeof(_game.flags)); memset(_game.vars, 0, sizeof(_game.vars)); // clear all resources and events for (i = 0; i < MAX_DIRECTORY_ENTRIES; i++) { memset(&_game.views[i], 0, sizeof(struct AgiView)); memset(&_game.pictures[i], 0, sizeof(struct AgiPicture)); memset(&_game.logics[i], 0, sizeof(struct AgiLogic)); memset(&_game.sounds[i], 0, sizeof(class AgiSound *)); // _game.sounds contains pointers now memset(&_game.dirView[i], 0, sizeof(struct AgiDir)); memset(&_game.dirPic[i], 0, sizeof(struct AgiDir)); memset(&_game.dirLogic[i], 0, sizeof(struct AgiDir)); memset(&_game.dirSound[i], 0, sizeof(struct AgiDir)); } // clear view table for (i = 0; i < SCREENOBJECTS_MAX; i++) memset(&_game.screenObjTable[i], 0, sizeof(struct ScreenObjEntry)); memset(&_game.addToPicView, 0, sizeof(struct ScreenObjEntry)); _words->clearEgoWords(); if (!_menu) _menu = new GfxMenu(this, _gfx, _picture, _text); _gfx->initPriorityTable(); // Clear the string buffer on startup, but not when the game restarts, as // some scripts expect that the game strings remain unaffected after a // restart. An example is script 98 in SQ2, which is not invoked on restart // to ask Ego's name again. The name is supposed to be maintained in string 1. // Fixes bug #3292784. if (!_restartGame) { for (i = 0; i < MAX_STRINGS; i++) _game.strings[i][0] = 0; } // setup emulation switch (getVersion() >> 12) { case 2: debug("Emulating Sierra AGI v%x.%03x", (int)(getVersion() >> 12) & 0xF, (int)(getVersion()) & 0xFFF); break; case 3: debug("Emulating Sierra AGI v%x.002.%03x", (int)(getVersion() >> 12) & 0xF, (int)(getVersion()) & 0xFFF); break; } if (getPlatform() == Common::kPlatformAmiga) _game.gameFlags |= ID_AMIGA; if (getFeatures() & GF_AGDS) _game.gameFlags |= ID_AGDS; if (_game.gameFlags & ID_AMIGA) debug(1, "Amiga padded game detected."); if (_game.gameFlags & ID_AGDS) debug(1, "AGDS mode enabled."); ec = _loader->init(); // load vol files, etc if (ec == errOK) ec = _loader->loadObjects(OBJECTS); // note: demogs has no words.tok if (ec == errOK) ec = _loader->loadWords(WORDS); // Load logic 0 into memory if (ec == errOK) ec = _loader->loadResource(RESOURCETYPE_LOGIC, 0); #ifdef __DS__ // Normally, the engine loads the predictive text dictionary when the predictive dialog // is shown. On the DS version, the word completion feature needs the dictionary too. // FIXME - loadDict() no long exists in AGI as this has been moved to within the // GUI Predictive Dialog, but DS Word Completion is probably broken due to this... #endif _keyHoldMode = false; _game.mouseFence.setWidth(0); // Reset // Reset in-game timer inGameTimerReset(); // Sync volume settings from ScummVM system settings setVolumeViaSystemSetting(); return ec; }
void QgsDelimitedTextProvider::rescanFile() { mRescanRequired = false; resetIndexes(); bool buildSpatialIndex = mSpatialIndex != 0; bool buildSubsetIndex = mBuildSubsetIndex && ( mSubsetExpression || mGeomRep != GeomNone ); // In case file has been rewritten check that it is still valid mValid = mLayerValid && mFile->isValid(); if ( ! mValid ) return; // Open the file and get number of rows, etc. We assume that the // file has a header row and process accordingly. Caller should make // sure that the delimited file is properly formed. QStringList messages; if ( mGeomRep == GeomAsWkt ) { mWktFieldIndex = mFile->fieldIndex( mWktFieldName ); if ( mWktFieldIndex < 0 ) { messages.append( tr( "%0 field %1 is not defined in delimited text file" ).arg( "Wkt", mWktFieldName ) ); } } else if ( mGeomRep == GeomAsXy ) { mXFieldIndex = mFile->fieldIndex( mXFieldName ); mYFieldIndex = mFile->fieldIndex( mYFieldName ); if ( mXFieldIndex < 0 ) { messages.append( tr( "%0 field %1 is not defined in delimited text file" ).arg( "X", mWktFieldName ) ); } if ( mYFieldIndex < 0 ) { messages.append( tr( "%0 field %1 is not defined in delimited text file" ).arg( "Y", mWktFieldName ) ); } } if ( messages.size() > 0 ) { reportErrors( messages ); QgsDebugMsg( "Delimited text source invalid on rescan - missing geometry fields" ); mValid = false; return; } // Reset the field columns for ( int i = 0; i < attributeFields.size(); i++ ) { attributeColumns[i] = mFile->fieldIndex( attributeFields.at( i ).name() ); } // Scan through the features in the file mSubsetIndex.clear(); mUseSubsetIndex = false; QgsFeatureIterator fi = getFeatures( QgsFeatureRequest() ); mNumberFeatures = 0; mExtent = QgsRectangle(); QgsFeature f; while ( fi.nextFeature( f ) ) { if ( mGeometryType != QGis::NoGeometry ) { if ( mNumberFeatures == 0 ) { mExtent = f.constGeometry()->boundingBox(); } else { QgsRectangle bbox( f.constGeometry()->boundingBox() ); mExtent.combineExtentWith( &bbox ); } if ( buildSpatialIndex ) mSpatialIndex->insertFeature( f ); } if ( buildSubsetIndex ) mSubsetIndex.append(( quintptr ) f.id() ); mNumberFeatures++; } if ( buildSubsetIndex ) { long recordCount = mFile->recordCount(); recordCount -= recordCount / SUBSET_ID_THRESHOLD_FACTOR; mUseSubsetIndex = recordCount < mSubsetIndex.size(); if ( ! mUseSubsetIndex ) mSubsetIndex.clear(); } mUseSpatialIndex = buildSpatialIndex; }
int AgiEngine::playGame() { int ec = errOK; debugC(2, kDebugLevelMain, "initializing..."); debugC(2, kDebugLevelMain, "game version = 0x%x", getVersion()); _sound->stopSound(); _gfx->clearScreen(0); _game.horizon = HORIZON; _game.playerControl = false; setflag(fLogicZeroFirsttime, true); // not in 2.917 setflag(fNewRoomExec, true); // needed for MUMG and SQ2! setflag(fSoundOn, true); // enable sound setvar(vTimeDelay, 2); // "normal" speed _game.gfxMode = true; _game.clockEnabled = true; _game.lineUserInput = 22; // We run AGIMOUSE always as a side effect if (getFeatures() & GF_AGIMOUSE || true) debug(1, "Using AGI Mouse 1.0 protocol"); if (getFeatures() & GF_AGIPAL) debug(1, "Running AGIPAL game"); debug(0, "Running AGI script.\n"); setflag(fEnteredCli, false); setflag(fSaidAcceptedInput, false); _game.vars[vWordNotFound] = 0; _game.vars[vKey] = 0; debugC(2, kDebugLevelMain, "Entering main loop"); bool firstLoop = !getflag(fRestartGame); // Do not restore on game restart do { if (!mainCycle()) continue; if (getvar(vTimeDelay) == 0 || (1 + _clockCount) % getvar(vTimeDelay) == 0) { if (!_game.hasPrompt && _game.inputMode == INPUT_NORMAL) { writePrompt(); _game.hasPrompt = 1; } else if (_game.hasPrompt && _game.inputMode == INPUT_NONE) { writePrompt(); _game.hasPrompt = 0; } interpretCycle(); // Check if the user has asked to load a game from the command line // or the launcher if (firstLoop) { checkQuickLoad(); firstLoop = false; } setflag(fEnteredCli, false); setflag(fSaidAcceptedInput, false); _game.vars[vWordNotFound] = 0; _game.vars[vKey] = 0; } if (shouldPerformAutoSave(_lastSaveTime)) { saveGame(getSavegameFilename(0), "Autosave"); } } while (!(shouldQuit() || _restartGame)); _sound->stopSound(); return ec; }