int main() { Terminal* term = new Terminal(); term->run(); delete term; return 0; }
void Switch::toggleTarget() { switch (targetType) { case T_DOOR: { Door* t = (Door*)target; t->isOpen = !t->isOpen; break; } case T_TERMINAL: { Terminal* t = (Terminal*)target; t->toggle(); break; } case T_LEVEL_END: { levelNum++; curr_level = getLevelString(levelNum); loading = true; // TEMP songNum++; changeSong = true; } } }
void CampTerminalMenuComponent::fillObjectMenuResponse(SceneObject* sceneObject, ObjectMenuResponse* menuResponse, CreatureObject* player) const { if (!sceneObject->isTerminal()) return; Terminal* terminal = cast<Terminal*>(sceneObject); if(terminal == NULL) { error("Terminal is null in fillObjectMenuResponse"); return; } StructureObject* camp = cast<StructureObject*>(terminal->getControlledObject()); if(camp == NULL) { error("Camp is null in fillObjectMenuResponse"); return; } TangibleObjectMenuComponent::fillObjectMenuResponse(sceneObject, menuResponse, player); /// Get Ghost Reference<PlayerObject*> ghost = player->getSlottedObject("ghost").castTo<PlayerObject*>(); if (ghost == NULL) { error("PlayerCreature has no ghost: " + String::valueOf(player->getObjectID())); return; } if (!player->isInRange(terminal, 16)) { return; } menuResponse->addRadialMenuItem(68, 3, "@camp:mnu_status"); /// Make sure player doesn't already have a camp setup somewhere else for (int i = 0; i < ghost->getTotalOwnedStructureCount(); ++i) { uint64 oid = ghost->getOwnedStructure(i); ManagedReference<StructureObject*> structure = ghost->getZoneServer()->getObject(oid).castTo<StructureObject*>(); if (structure == camp) { menuResponse->addRadialMenuItem(182, 3, "@camp:mnu_disband"); return; } } SortedVector<ManagedReference<ActiveArea*> >* areas = camp->getActiveAreas(); ManagedReference<ActiveArea*> area = NULL; for (int i = 0; i < areas->size(); ++i) { area = areas->get(i); if (area->isCampArea()) { break; } area == NULL; } if (area != NULL && area->isCampArea() && (area.castTo<CampSiteActiveArea*>())->isAbandoned()) { menuResponse->addRadialMenuItem(183, 3, "@camp:mnu_assume_ownership"); } }
void PrintHelp() { static const char * const help[] = { // Assume TTY has 72 columns. Let's try to keep everything to 70 max. // 1 2 3 4 5 6 7 // 1234567890123456789012345678901234567890123456789012345678901234567890 "Enter a move using file letter, rank number for source and target.", "For example, White moving king pawn forward two squares: e2e4.", "To castle, just move the king two squares. Example: e1g1.", "", "You may also enter any of the following commands:", "board Print the board now (see 'hide', 'show').", "help Print this help text.", "hide Print the board only when asked (see 'board', 'show').", "new Start a new game.", "quit Exit the game.", "show Print the board every time it is your turn.", "swap Swap sides with the computer.", "time Adjust computer's think time (difficulty).", NULL }; TheTerminal.printline(); for (int i=0; help[i]; ++i) { TheTerminal.printline(help[i]); } TheTerminal.printline(); }
virtual void Resign(ChessSide iGiveUp, QuitGameReason reason) { switch (reason) { case qgr_resign: switch (iGiveUp) { case SIDE_WHITE: TheTerminal.printline("White resigns."); break; case SIDE_BLACK: TheTerminal.printline("Black resigns."); break; } break; case qgr_lostConnection: TheTerminal.printline("Lost connection."); break; case qgr_startNewGame: TheTerminal.printline("Starting new game."); break; } }
virtual ChessPlayer *CreatePlayer(ChessSide side) { while (humanSide == SIDE_NEITHER) { TheTerminal.print("Which side do you want to play (w, b, quit)? "); std::string choice = TheTerminal.readline(); if (choice == "w") { humanSide = SIDE_WHITE; } else if (choice == "b") { humanSide = SIDE_BLACK; } else if (choice == "quit") { throw "Chess program exited."; } } if (side == humanSide) { human = new HumanChessPlayer(*this); return human; } else { computer = new ComputerChessPlayer(*this); computer->SetTimeLimit(ComputerThinkTime); computer->SetSearchBias(1); computer->setResignFlag(false); return computer; } }
/**Function******************************************************************** Synopsis [Returns the minimum Hamming distance between f and minterm.] Description [Returns the minimum Hamming distance between the minterms of a function f and a reference minterm. The function is given as a BDD; the minterm is given as an array of integers, one for each variable in the manager. Returns the minimum distance if it is less than the upper bound; the upper bound if the minimum distance is at least as large; CUDD_OUT_OF_MEM in case of failure.] SideEffects [None] SeeAlso [Cudd_addHamming] ******************************************************************************/ int Cudd_MinHammingDist( DdManager *dd /* DD manager */, DdNode *f /* function to examine */, int *minterm /* reference minterm */, int upperBound /* distance above which an approximate answer is OK */) { DdHashTable *table; CUDD_VALUE_TYPE epsilon; int res; table = cuddHashTableInit(dd,1,2); if (table == NULL) { return(CUDD_OUT_OF_MEM); } epsilon = Cudd_ReadEpsilon(dd); Terminal zero; zero.set(0.0); Cudd_SetEpsilon(dd,&zero); //Cudd_SetEpsilon(dd,(CUDD_VALUE_TYPE)0.0); res = cuddMinHammingDistRecur(f,minterm,table,upperBound); cuddHashTableQuit(table); Cudd_SetEpsilon(dd,epsilon); return(res); } /* end of Cudd_MinHammingDist */
int main(){ cout << "Starting GUI..." << endl; string systemdrive = get_env("SYSTEMDRIVE"); GDSPath = systemdrive + GDSPath; WMPath = systemdrive + WMPath; ShellPath = systemdrive + ShellPath; Process proc = Process::Spawn(GDSPath, {WMPath, ShellPath}); proc.Wait(); Terminal term; term.SetPointerVisibility(false); term.SetPointerAutohide(true); cout << "Ending remaining GUI processes..."; cout.flush(); bool found = true; while(found){ found = false; ifstream procinfostream(ProcInfoPath); table procs = parsecsv(procinfostream); for(auto row: procs.rows){ if(strtoul(row["parent"].c_str(), NULL, 0) == bt_getpid()){ bt_kill(strtoul(row["PID"].c_str(), NULL, 0)); found = true; } } } cout << "Done." << endl; }
Terminal* Grammar::getNamedNode ( Terminal & node, const string & name ) { // This function only operates on the parent chain. // We only want to output non-source-position dependent constructors for SgLocatedNodes. Test for this. Terminal* parentNode = node.getBaseClass(); #if 0 string parentNodeName; if (parentNode != NULL) { parentNodeName = parentNode->getName(); // printf ("parentNodeName = %s \n",parentNodeName.c_str()); } // printf ("In Grammar::getNamedNode(): name = %s \n",name.c_str()); #endif while ( parentNode != NULL && string(parentNode->getName()) != name ) // while ( (parentNode != NULL) && (parentNodeName != name) ) { // printf ("node %s parent node: %s \n",name.c_str(),parentNode->getName().c_str()); parentNode = parentNode->getBaseClass(); } if (parentNode != NULL) { // printf ("Found node %s parent node: %s \n",name.c_str(),parentNode->getName().c_str()); } return parentNode; }
void Grammar::buildConstructorWithoutSourcePositionInformationSupport( Terminal & node, StringUtility::FileWithLineNumbers & outputFile ) { StringUtility::FileWithLineNumbers editString = buildConstructorWithoutSourcePositionInformation(node); editString = StringUtility::copyEdit (editString,"$CLASSNAME",node.getName()); editString = StringUtility::copyEdit (editString,"$GRAMMAR_NAME",getGrammarName()); // grammarName string defined in Grammar class // Set these to NULL strings if they are still present within the string editString = StringUtility::copyEdit (editString,"$CLASSTAG",node.getTagName()); #if 1 // Also output strings to single file outputFile += editString; #endif // printf ("node.name = %s (# of subtrees/leaves = %" PRIuPTR ") \n",node.getName(),node.nodeList.size()); #if 1 // Call this function recursively on the children of this node in the tree vector<Terminal *>::const_iterator treeNodeIterator; for( treeNodeIterator = node.subclasses.begin(); treeNodeIterator != node.subclasses.end(); treeNodeIterator++ ) { ROSE_ASSERT ((*treeNodeIterator) != NULL); ROSE_ASSERT ((*treeNodeIterator)->getBaseClass() != NULL); buildConstructorWithoutSourcePositionInformationSupport(**treeNodeIterator,outputFile); } #endif }
int main (int argc, char** argv) { Terminal t; t.func(); BoldDecorator bd(t); bd.func(); BarEndlineDecorator(bd).func(); }
void CampTerminalMenuComponent::disbandCamp(SceneObject* sceneObject, CreatureObject* player) const { Terminal* terminal = cast<Terminal*>(sceneObject); if(terminal == NULL) { error("Terminal is null in disbandCamp"); return; } if (!player->isInRange(terminal, 16)) { return; } StructureObject* camp = cast<StructureObject*>(terminal->getControlledObject()); if(camp == NULL) { error("Camp is null in disbandCamp"); return; } if (camp->getZone() == NULL) return; PlayerObject* ghost = player->getPlayerObject(); if (ghost == NULL) { return; } if (!ghost->isOwnedStructure(camp)) { return; } if(player->isSitting()) { player->setPosture(CreaturePosture::UPRIGHT, true); } // Find Camp Area SortedVector<ManagedReference<ActiveArea* > >* areas = camp->getActiveAreas(); ManagedReference<ActiveArea*> area = NULL; for(int i = 0; i < areas->size(); ++i) { area = areas->get(i); if(area->isCampArea()) { break; } area == NULL; } CampSiteActiveArea* campArea = cast<CampSiteActiveArea*>(area.get()); if(campArea != NULL && campArea->despawnCamp()) return; StructureManager::instance()->destroyStructure(camp); if(campArea != NULL) { campArea->destroyObjectFromWorld(true); campArea->destroyObjectFromDatabase(true); } }
/* * Opens a terminal based on your DE. */ void WMHelper::openTerminal(const QString& dirName) { QFileInfo f(dirName); if (f.exists()) { Terminal *term = new Terminal(0, SettingsManager::getTerminal()); term->openTerminal(dirName); } }
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); Terminal tm; tm.run(); return a.exec(); }
void Key::Execute(void *arg) { syslog(LOG_DEBUG, "%s ENTRY",__func__); Terminal term; while(1) { char ch = term.getch(); syslog(LOG_DEBUG,"new key pressed :%d ",ch); write(getKeyFd[1],&ch,1); } }
/* * Player opened a mission terminal or pressed refresh */ void MissionManager::listRequest(PlayerObject* player, uint64 terminal_id,uint8 refresh_count) { Terminal* terminal = dynamic_cast<Terminal*> (gWorldManager->getObjectById(terminal_id)); //uint32 terminal_type = terminal->getTerminalType(); int8 terminal_name[255]; strcpy(terminal_name,terminal->getName().getAnsi()); gLogger->logMsgF("Terminal id %"PRIu64" is type '%s'", MSG_NORMAL, terminal_id, terminal_name); int count = 0; int len = strlen(terminal_name); MissionBag* mission_bag = dynamic_cast<MissionBag*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_MissionBag)); MissionList::iterator it = mission_bag->getMissions()->begin(); while(it != mission_bag->getMissions()->end()) { MissionObject* mission = dynamic_cast<MissionObject*>(*it); mission->clear(); mission->setIssuingTerminal(terminal); mission->setRefreshCount(refresh_count); switch(len) { case 16: //terminal_mission count < 5 ? generateDestroyMission(mission,terminal_id) : generateDeliverMission(mission); break; case 22: //terminal_mission_scout if (count < 5) { mission->setRefreshCount(0); } else { generateReconMission(mission); } break; case 24: //terminal_mission_artisan count < 5 ? generateCraftingMission(mission) : generateSurveyMission(mission); break; case 28: //terminal_mission_entertainer generateEntertainerMission(mission,count); break; default: gLogger->logMsgF("Terminal id %"PRIu64" is type '%s'", MSG_NORMAL, terminal_id, terminal_name); mission->setRefreshCount(0); } gMessageLib->sendMISO_Delta(mission, player); count++; ++it; } }
int main(int argc, char *argv[]){ QGuiApplication app(argc, argv); app.setApplicationName("Nutron"); app.setApplicationVersion("1.0"); QQmlApplicationEngine engine; QQmlContext *ctx = engine.rootContext(); Terminal console; Authenticate validate(console.get_userList()); ctx->setContextProperty("_console",&console); ctx->setContextProperty("_authenticate",&validate); engine.load(QUrl(QStringLiteral("qrc:/gui/main.qml"))); return app.exec(); }
int main (int argc, char** argv) { Terminal t; t.func(); auto bd = decor<BoldDecorator>(t); // smart way bd.func(); BoldDecorator<Terminal>(t).func(); // ugly way decor<BarEndlineDecorator>(bd).func(); // smart way BarEndlineDecorator< BoldDecorator<Terminal> >(bd).func(); // ugly way }
void Screen::draw(Terminal &terminal) { terminal.clear(); for(uint16_t y = 0; y < m_height; y++) { for(uint16_t x = 0; x < m_width; x++) { terminal.pushColor(m_color[y*m_width + x]); std::cout << m_data[y*m_width + x]; terminal.popColor(); } std::cout << "\n"; } std::cout << std::flush; }
void CampTerminalMenuComponent::assumeCampOwnership(SceneObject* sceneObject, CreatureObject* player) const { Terminal* terminal = cast<Terminal*>(sceneObject); if(terminal == NULL) { error("Terminal is null in assumeCampOwnership"); return; } if (!player->isInRange(terminal, 16)) { return; } StructureObject* camp = cast<StructureObject*>(terminal->getControlledObject()); if(camp == NULL) { error("Camp is null in assumeCampOwnership"); return; } // Find Camp Area SortedVector<ManagedReference<ActiveArea* > >* areas = camp->getActiveAreas(); ManagedReference<ActiveArea*> area = NULL; for(int i = 0; i < areas->size(); ++i) { area = areas->get(i); if(area->isCampArea()) { break; } area = NULL; } ManagedReference<CampSiteActiveArea*> campArea = cast<CampSiteActiveArea*>(area.get()); if (campArea != NULL) { if(!campArea->isAbandoned()) return; ManagedReference<CreatureObject*> play = player; Core::getTaskManager()->executeTask([=] () { Locker locker(campArea); campArea->assumeOwnership(play); }, "AssumeOwnershipLambda"); } }
void kernel_main() { initDescriptorTables(); Terminal term; term.clear(); initializePaging(); term.writeColoredString("$7Hello $FMaster$7, $4welcome $7home!\n"); asm volatile("sti"); initTimer(100); term.writeDec(*(uint32_t*)0xABADF00D); for (;;); }
// NOTE: The following is called only when there is a // checkmate, stalemate, or draw by attrition. // The function is NOT called if a player resigns. virtual void ReportEndOfGame(ChessSide winner) { switch (winner) { case SIDE_WHITE: TheTerminal.printline("White wins."); break; case SIDE_BLACK: TheTerminal.printline("Black wins."); break; case SIDE_NEITHER: TheTerminal.printline("Draw game."); break; } }
int main(int argc, char *argv[]) { anvil_name_reg("/dev/tty", 1, 0); Aw::App app("Terminal"); app.setCallback(msg_callback); Terminal terminal; termbox = terminal.getTermBox(); app.setKeyWidget(termbox); app.Run(terminal); return 0; }
void CallThread::run() { cout << "starting call thread\n"; try { _terminal->connect(_hostAddress.c_str(), _remotePort); } catch(...) { cerr << "EXCEPTION[callThread]: unable to perform connection!\n"; // TODO } cout << "finishing call thread\n"; }
int main(int argc, const char *argv[]) { int rc = 1; try { LoadIniFile("ttychess.ini"); TheTerminal.printline(); TheTerminal.printline(std::string("Teletype chess program (") + ConvertDateToVersion(__DATE__) + ") by Don Cross."); TheTerminal.printline("http://cosinekitty.com/chenard"); while (true) { ChessBoard board; ChessUI_TTY ui; ChessGame game(board, ui); ui.SetGame(&game); game.Play(); ui.SetGame(NULL); } rc = 0; } catch (const char *message) { TheTerminal.print(message); TheTerminal.printline(); } TheTerminal.close(); return rc; }
void ZoneImplementation::addSceneObject(SceneObject* object) { objectMap->put(object->getObjectID(), object); //Civic and commercial structures map registration will be handled by their city if (object->isStructureObject()) { StructureObject* structure = cast<StructureObject*>(object); if (structure->isCivicStructure() || structure->isCommercialStructure()) { return; } //Same thing for player city bank/mission terminals } else if (object->isTerminal()) { Terminal* terminal = cast<Terminal*>(object); ManagedReference<SceneObject*> controlledObject = terminal->getControlledObject(); if (controlledObject != NULL && controlledObject->isStructureObject()) { StructureObject* structure = controlledObject.castTo<StructureObject*>(); if (structure->isCivicStructure()) return; } } registerObjectWithPlanetaryMap(object); }
string // Grammar::outputClassesAndFields ( GrammarTreeNode & node, fstream & outputFile ) Grammar::outputClassesAndFields ( Terminal & node ) { string className = node.getName(); string dataFields = node.outputClassesAndFields(); string returnString = className + "\n" + dataFields; // printf ("returnString = \n%s\n",returnString.c_str()); #if 1 // Call this function recursively on the children of this node in the tree vector<Terminal *>::iterator treeNodeIterator; for( treeNodeIterator = node.subclasses.begin(); treeNodeIterator != node.subclasses.end(); treeNodeIterator++ ) { ROSE_ASSERT ((*treeNodeIterator) != NULL); ROSE_ASSERT ((*treeNodeIterator)->getBaseClass() != NULL); // outputClassesAndFields(**treeNodeIterator,outputFile); returnString += outputClassesAndFields(**treeNodeIterator); } #endif // returnString = GrammarString::copyEdit(returnString.c_str(),"$CLASSNAME",node.getName()); const string target = "$CLASSNAME"; const string name = node.getName(); // returnString = GrammarString::copyEdit(returnString,target,name); // returnString = GrammarString::copyEdit(string(returnString),"$CLASSNAME",string(node.getName())); // returnString = GrammarString::copyEdit(string(returnString),target,name); // returnString = GrammarString::copyEdit(returnString,target,name); string copy = returnString; returnString = GrammarString::copyEdit(copy,target,name); return returnString; }
//-------------------------------------------------------------- // Called whenever a player needs to be asked which // piece a pawn should be promoted to. // Must return one of the following values: // Q_INDEX, R_INDEX, B_INDEX, N_INDEX //-------------------------------------------------------------- virtual SQUARE PromotePawn(int pawnDest, ChessSide side) { while (true) { TheTerminal.print("Promote pawn to Q, R, N, B? "); std::string answer = TheTerminal.readline(); if (answer == "q") { return Q_INDEX; } else if (answer == "r") { return R_INDEX; } else if (answer == "n") { return N_INDEX; } else if (answer == "b") { return B_INDEX; } } }
/* JH (11/24/2005): This method generates the code produced for every IR node * for its static data by the method above! */ std::string Grammar::buildStaticDataMemberListDeleteStaticDataSource(Terminal & node) { std::string classMembers = node.buildStaticDataMemberListDeleteStaticData(); string temp = classMembers; classMembers = GrammarString::copyEdit(temp, "$CLASSNAME", node.name); vector<Terminal *>::const_iterator treeListIterator; for( treeListIterator = node.subclasses.begin(); treeListIterator != node.subclasses.end(); treeListIterator++ ) { ROSE_ASSERT ((*treeListIterator) != NULL); ROSE_ASSERT ((*treeListIterator)->getBaseClass() != NULL); classMembers += buildStaticDataMemberListDeleteStaticDataSource(**treeListIterator); } return classMembers; }
// Returns true if the identifier has the same sequence of // characters as `str`. inline bool operator==(Terminal const& t, char const* str) { return !std::strncmp(t.first, str, t.size()); }