INT CommandHistory (LPTSTR param) { LPTSTR tmp; INT tmp_int; LPHIST_ENTRY h_tmp; TCHAR szBuffer[2048]; tmp=_tcschr(param,_T('/')); if (tmp) { param=tmp; switch (_totupper(param[1])) { case _T('F'):/*delete history*/ CleanHistory();InitHistory(); break; case _T('R'):/*read history from standard in*/ //hIn=GetStdHandle (STD_INPUT_HANDLE); for(;;) { ConInString(szBuffer,sizeof(szBuffer)/sizeof(TCHAR)); if (*szBuffer!=_T('\0')) History(0,szBuffer); else break; } break; case _T('A'):/*add an antry*/ History(0,param+2); break; case _T('S'):/*set history size*/ if ((tmp_int=_ttoi(param+2))) set_size(tmp_int); break; default: return 1; } } else { for (h_tmp = Top->prev; h_tmp != Bottom; h_tmp = h_tmp->prev) ConErrPuts(h_tmp->string); } return 0; }
CallStack::History CallStack::trace(std::uint32_t size) { poco_assert(0 < size); auto process = GetCurrentProcess(); if (FALSE == SymInitialize(process, nullptr, TRUE)) { return std::move(History()); } std::unique_ptr<void*[]> stack(new void*[size]); auto frames = CaptureStackBackTrace(0, size, stack.get(), nullptr); const int max_name_length = 255; std::unique_ptr<char[]> symbol_buffer(new char[sizeof(SYMBOL_INFO) + ((max_name_length + 1) * sizeof(char))]); auto symbol = reinterpret_cast<SYMBOL_INFO*>(symbol_buffer.get()); symbol->MaxNameLen = max_name_length; symbol->SizeOfStruct = sizeof(SYMBOL_INFO); History ret; for (decltype(frames) i = 0; i < frames; i++) { if (FALSE != SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol)) { ret.insert(std::make_pair(symbol->Name, Poco::NumberFormatter::formatHex(symbol->Address, true))); } } return std::move(ret); }
void Ide::OpenLog() { String p = GetLogPath(); String path = NormalizePath(p); if(!designer && path == editfile) { History(-1); return; } AddHistory(); if(FileExists(p)) EditFile(p); }
FB_Config::~FB_Config() { wxFileInputStream input( EditorPath + "/ide/history.ini" ); wxFileConfig History(input); wxFileOutputStream output( EditorPath + "/ide/history.ini" ); m_FileHistory->Save( History ); History.Save( output ); delete m_FileHistory; SaveConfig( EditorPath + "/ide/prefs.ini" ); }
FB_Config::FB_Config( ) { wxApp * App = wxGetApp(); EditorPath = wxPathOnly(App->argv[0]); wxFileInputStream input( EditorPath + "/ide/history.ini" ); wxFileConfig History(input); m_FileHistory = new wxFileHistory; m_FileHistory->Load( History ); LoadConfig( EditorPath + "/ide/prefs.ini" ); LoadFBTheme( EditorPath + "/ide/" + ThemeFile + ".fbt" ); LoadKWFile( EditorPath + "/ide/" + SyntaxFile ); }
double MathematicaLib::DoTheMath(char const* equation){ commandHistory.insert(commandHistory.end(), equation); // saves each inputted command into a vector try{ if (strcmp("Help", equation) == 0) { Help(); return 0.0; } else if (strcmp("Undo", equation) == 0) { return Undo(); } else if (strcmp("ClearRestart", equation) == 0){ ClearRestart(); return 0.0; } else if (strcmp("History", equation) == 0){ History(commandHistory); return 0.0; } else if (strcmp("Load", equation) == 0){ Load(); return 0.0; } else if (strlen(equation) > 100) { cout << "Input enetered is too big" << endl; return 0.0; } // used to limit input else { return IsThisAnEquation(equation); } } catch (exception e){ cout << "Invalid input" << endl; return 0; } return 0.0; // when an equations was not inputted }// end of DoTheMath
VWallSession::VWallSession(const QString& id, VAccount* account): Conference(account), d_ptr(new VWallSessionPrivate) { Q_D(VWallSession); d->q_ptr = this; d->id = id; d->me = account->getContact(account->uid(),true); d->me->setContactName(account->name()); d->owner = d->account()->getContact(d->id,true); d->historyCount = 10; MessageList list = History().read(this,1); if (list.count()) d->timeStamp = list.first().time().toTime_t(); d->updateTimer.setInterval(5000); connect(&d->updateTimer,SIGNAL(timeout()),d,SLOT(getHistory())); connect(d->owner,SIGNAL(destroyed()),SLOT(deleteLater())); }
GTPResponse GTP::gtp_load_sgf(vecstr args){ if(args.size() == 0) return GTPResponse(true, "load_sgf <filename>"); std::ifstream infile(args[0].c_str()); if(!infile) { return GTPResponse(false, "Error opening file " + args[0] + " for reading"); } SGFParser<Move> sgf(infile); if(sgf.game() != Board::name){ infile.close(); return GTPResponse(false, "File is for the wrong game: " + sgf.game()); } int size = sgf.size(); if(size != hist->get_size()){ if(hist.len() == 0){ hist = History(size); set_board(); time_control.new_game(); }else{ infile.close(); return GTPResponse(false, "File has the wrong boardsize to match the existing game"); } } Side s = Side::P1; while(sgf.next_node()){ Move m = sgf.move(); move(m); // push the game forward s = ~s; } if(sgf.has_children()) agent->load_sgf(sgf); assert(sgf.done_child()); infile.close(); return true; }
VOID History_del_current_entry(LPTSTR str) { LPHIST_ENTRY tmp; if (size == 0) return; if (curr_ptr == Bottom) curr_ptr=Bottom->next; if (curr_ptr == Top) curr_ptr=Top->prev; tmp = curr_ptr; curr_ptr = curr_ptr->prev; del(tmp); History(-1, str); }
static BOOL ReadCommand( PCONSOLE_STATE State, LPSTR str, INT maxlen) { SHORT orgx; /* origin x/y */ SHORT orgy; SHORT curx; /*current x/y cursor position*/ SHORT cury; SHORT tempscreen; INT count; /*used in some for loops*/ INT current = 0; /*the position of the cursor in the string (str)*/ INT charcount = 0;/*chars in the string (str)*/ INPUT_RECORD ir; CHAR ch; BOOL bReturn = FALSE; BOOL bCharInput; #ifdef FEATURE_HISTORY //BOOL bContinue=FALSE;/*is TRUE the second case will not be executed*/ CHAR PreviousChar; #endif CONSOLE_GetCursorXY(&orgx, &orgy); curx = orgx; cury = orgy; memset(str, 0, maxlen * sizeof(CHAR)); CONSOLE_SetCursorType(State->bInsert, TRUE); do { bReturn = FALSE; CONSOLE_ConInKey(&ir); if (ir.Event.KeyEvent.dwControlKeyState & (RIGHT_ALT_PRESSED |LEFT_ALT_PRESSED| RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED) ) { switch (ir.Event.KeyEvent.wVirtualKeyCode) { #ifdef FEATURE_HISTORY case 'K': /*add the current command line to the history*/ if (ir.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED)) { if (str[0]) History(0,str); ClearCommandLine (str, maxlen, orgx, orgy); current = charcount = 0; curx = orgx; cury = orgy; //bContinue=TRUE; break; } case 'D': /*delete current history entry*/ if (ir.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED)) { ClearCommandLine (str, maxlen, orgx, orgy); History_del_current_entry(str); current = charcount = strlen (str); ConOutPrintf("%s", str); GetCursorXY(&curx, &cury); //bContinue=TRUE; break; } #endif /*FEATURE_HISTORY*/ } } bCharInput = FALSE; switch (ir.Event.KeyEvent.wVirtualKeyCode) { case VK_BACK: /* <BACKSPACE> - delete character to left of cursor */ if (current > 0 && charcount > 0) { if (current == charcount) { /* if at end of line */ str[current - 1] = L'\0'; if (CONSOLE_GetCursorX () != 0) { CONSOLE_ConOutPrintf("\b \b"); curx--; } else { CONSOLE_SetCursorXY((SHORT)(State->maxx - 1), (SHORT)(CONSOLE_GetCursorY () - 1)); CONSOLE_ConOutChar(' '); CONSOLE_SetCursorXY((SHORT)(State->maxx - 1), (SHORT)(CONSOLE_GetCursorY () - 1)); cury--; curx = State->maxx - 1; } } else { for (count = current - 1; count < charcount; count++) str[count] = str[count + 1]; if (CONSOLE_GetCursorX () != 0) { CONSOLE_SetCursorXY ((SHORT)(CONSOLE_GetCursorX () - 1), CONSOLE_GetCursorY ()); curx--; } else { CONSOLE_SetCursorXY ((SHORT)(State->maxx - 1), (SHORT)(CONSOLE_GetCursorY () - 1)); cury--; curx = State->maxx - 1; } CONSOLE_GetCursorXY(&curx, &cury); CONSOLE_ConOutPrintf("%s ", &str[current - 1]); CONSOLE_SetCursorXY(curx, cury); } charcount--; current--; } break; case VK_INSERT: /* toggle insert/overstrike mode */ State->bInsert ^= TRUE; CONSOLE_SetCursorType(State->bInsert, TRUE); break; case VK_DELETE: /* delete character under cursor */ if (current != charcount && charcount > 0) { for (count = current; count < charcount; count++) str[count] = str[count + 1]; charcount--; CONSOLE_GetCursorXY(&curx, &cury); CONSOLE_ConOutPrintf("%s ", &str[current]); CONSOLE_SetCursorXY(curx, cury); } break; case VK_HOME: /* goto beginning of string */ if (current != 0) { CONSOLE_SetCursorXY(orgx, orgy); curx = orgx; cury = orgy; current = 0; } break; case VK_END: /* goto end of string */ if (current != charcount) { CONSOLE_SetCursorXY(orgx, orgy); CONSOLE_ConOutPrintf("%s", str); CONSOLE_GetCursorXY(&curx, &cury); current = charcount; } break; case 'M': case 'C': /* ^M does the same as return */ bCharInput = TRUE; if (!(ir.Event.KeyEvent.dwControlKeyState & (RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED))) { break; } case VK_RETURN: /* end input, return to main */ #ifdef FEATURE_HISTORY /* add to the history */ if (str[0]) History (0, str); #endif str[charcount] = '\0'; CONSOLE_ConOutChar('\n'); bReturn = TRUE; break; case VK_ESCAPE: /* clear str Make this callable! */ ClearCommandLine (str, maxlen, orgx, orgy); curx = orgx; cury = orgy; current = charcount = 0; break; #ifdef FEATURE_HISTORY case VK_F3: History_move_to_bottom(); #endif case VK_UP: #ifdef FEATURE_HISTORY /* get previous command from buffer */ ClearCommandLine (str, maxlen, orgx, orgy); History (-1, str); current = charcount = strlen (str); if (((charcount + orgx) / maxx) + orgy > maxy - 1) orgy += maxy - ((charcount + orgx) / maxx + orgy + 1); CONSOLE_ConOutPrintf("%s", str); CONSOLE_GetCursorXY(&curx, &cury); #endif break; case VK_DOWN: #ifdef FEATURE_HISTORY /* get next command from buffer */ ClearCommandLine (str, maxlen, orgx, orgy); History (1, str); current = charcount = strlen (str); if (((charcount + orgx) / maxx) + orgy > maxy - 1) orgy += maxy - ((charcount + orgx) / maxx + orgy + 1); CONSOLE_ConOutPrintf("%s", str); CONSOLE_GetCursorXY(&curx, &cury); #endif break; case VK_LEFT: /* move cursor left */ if (current > 0) { current--; if (CONSOLE_GetCursorX() == 0) { CONSOLE_SetCursorXY((SHORT)(State->maxx - 1), (SHORT)(CONSOLE_GetCursorY () - 1)); curx = State->maxx - 1; cury--; } else { CONSOLE_SetCursorXY((SHORT)(CONSOLE_GetCursorX () - 1), CONSOLE_GetCursorY ()); curx--; } } break; case VK_RIGHT: /* move cursor right */ if (current != charcount) { current++; if (CONSOLE_GetCursorX() == State->maxx - 1) { CONSOLE_SetCursorXY(0, (SHORT)(CONSOLE_GetCursorY () + 1)); curx = 0; cury++; } else { CONSOLE_SetCursorXY((SHORT)(CONSOLE_GetCursorX () + 1), CONSOLE_GetCursorY ()); curx++; } } #ifdef FEATURE_HISTORY else { LPCSTR last = PeekHistory(-1); if (last && charcount < (INT)strlen (last)) { PreviousChar = last[current]; CONSOLE_ConOutChar(PreviousChar); CONSOLE_GetCursorXY(&curx, &cury); str[current++] = PreviousChar; charcount++; } } #endif break; default: /* This input is just a normal char */ bCharInput = TRUE; } ch = ir.Event.KeyEvent.uChar.UnicodeChar; if (ch >= 32 && (charcount != (maxlen - 2)) && bCharInput) { /* insert character into string... */ if (State->bInsert && current != charcount) { /* If this character insertion will cause screen scrolling, * adjust the saved origin of the command prompt. */ tempscreen = strlen(str + current) + curx; if ((tempscreen % State->maxx) == (State->maxx - 1) && (tempscreen / State->maxx) + cury == (State->maxy - 1)) { orgy--; cury--; } for (count = charcount; count > current; count--) str[count] = str[count - 1]; str[current++] = ch; if (curx == State->maxx - 1) curx = 0, cury++; else curx++; CONSOLE_ConOutPrintf("%s", &str[current - 1]); CONSOLE_SetCursorXY(curx, cury); charcount++; } else { if (current == charcount) charcount++; str[current++] = ch; if (CONSOLE_GetCursorX () == State->maxx - 1 && CONSOLE_GetCursorY () == State->maxy - 1) orgy--, cury--; if (CONSOLE_GetCursorX () == State->maxx - 1) curx = 0, cury++; else curx++; CONSOLE_ConOutChar(ch); } } } while (!bReturn); CONSOLE_SetCursorType(State->bInsert, TRUE); return TRUE; }
// Return true if any changes made bool RefineTask::RefineHorizP(MSA* msaIn, unsigned uIters, bool bLockLeft, bool bLockRight) { Q_UNUSED(bLockLeft); Q_UNUSED(bLockRight); MuscleContext *ctx = workpool->ctx; unsigned &g_uRefineHeightSubtree = ctx->refinehoriz.g_uRefineHeightSubtree; unsigned &g_uRefineHeightSubtreeTotal = ctx->refinehoriz.g_uRefineHeightSubtreeTotal; Tree &tree = workpool->GuideTree; workpool->msaIn = msaIn; workpool->uIters = uIters; if (!tree.IsRooted()) Quit("RefineHeight: requires rooted tree"); const unsigned uSeqCount = msaIn->GetSeqCount(); if (uSeqCount < 3) return false; const unsigned uInternalNodeCount = uSeqCount - 1; unsigned *InternalNodeIndexes = new unsigned[uInternalNodeCount]; unsigned *InternalNodeIndexesR = new unsigned[uInternalNodeCount]; GetInternalNodesInHeightOrder(tree, InternalNodeIndexes); ScoreHistory History(uIters, 2*uSeqCount - 1); workpool->History = &History; workpool->uInternalNodeCount = uInternalNodeCount; bool bAnyChangesAnyIter = false; workpool->refineNodeStatuses = new RefineTreeNodeStatus[uInternalNodeCount]; for (unsigned n = 0; n < uInternalNodeCount; ++n) { InternalNodeIndexesR[uInternalNodeCount - 1 - n] = InternalNodeIndexes[n]; workpool->refineNodeStatuses[n] = RefineTreeNodeStatus_Available; } for (unsigned uIter = 0; uIter < uIters && !ctx->isCanceled(); ++uIter) { workpool->uIter = uIter; bool bAnyChangesThisIter = false; IncIter(); SetProgressDesc("Refine biparts"); g_uRefineHeightSubtree = 0; g_uRefineHeightSubtreeTotal = uInternalNodeCount*2 - 1; bool &bReverse = workpool->bReversed = (uIter%2 != 0); if (bReverse) workpool->InternalNodeIndexes = InternalNodeIndexesR; else workpool->InternalNodeIndexes = InternalNodeIndexes; bool bOscillating; workpool->ptrbOscillating = &bOscillating; for (unsigned i = 0; i < 2 && !ctx->isCanceled(); ++i) { bool bAnyChanges = false; bool &bRight = workpool->bRight; switch (i) { case 0: bRight = true; break; case 1: bRight = false; break; default: delete[] InternalNodeIndexes; delete[] InternalNodeIndexesR; Quit("RefineHeight default case"); } workpool->reset(); RefineHeightPartsP(&bAnyChanges); if (bOscillating) { ProgressStepsDone(); goto Osc; } if (bAnyChanges) { bAnyChangesThisIter = true; bAnyChangesAnyIter = true; } } ProgressStepsDone(); if (bOscillating) break; if (!bAnyChangesThisIter) break; } Osc: delete[] InternalNodeIndexes; delete[] InternalNodeIndexesR; delete[] workpool->refineNodeStatuses; return bAnyChangesAnyIter; }
static void DoBuy (RESPONSE_REF R) { COUNT credit; SIZE needed_credit; BYTE slot; DWORD capacity; credit = GetAvailableCredits (); capacity = FUEL_RESERVE; slot = NUM_MODULE_SLOTS - 1; do { if (GLOBAL_SIS (ModuleSlots[slot]) == FUEL_TANK || GLOBAL_SIS (ModuleSlots[slot]) == HIGHEFF_FUELSYS) { COUNT volume; volume = GLOBAL_SIS (ModuleSlots[slot]) == FUEL_TANK ? FUEL_TANK_CAPACITY : HEFUEL_TANK_CAPACITY; capacity += volume; } } while (slot--); // If they're out of credits, educate them on how commerce works. if (credit == 0) { AskedToBuy = TRUE; NPCPhrase (NEED_CREDIT); NatureOfConversation (R); } else if (PLAYER_SAID (R, buy_fuel) || PLAYER_SAID (R, buy_1_fuel) || PLAYER_SAID (R, buy_5_fuel) || PLAYER_SAID (R, buy_10_fuel) || PLAYER_SAID (R, buy_25_fuel) || PLAYER_SAID (R, fill_me_up)) { needed_credit = 0; if (PLAYER_SAID (R, buy_1_fuel)) needed_credit = 1; else if (PLAYER_SAID (R, buy_5_fuel)) needed_credit = 5; else if (PLAYER_SAID (R, buy_10_fuel)) needed_credit = 10; else if (PLAYER_SAID (R, buy_25_fuel)) needed_credit = 25; else if (PLAYER_SAID (R, fill_me_up)) needed_credit = (capacity - GLOBAL_SIS (FuelOnBoard) + FUEL_TANK_SCALE - 1) / FUEL_TANK_SCALE; if (needed_credit == 0) { if (!GET_GAME_STATE (MELNORME_FUEL_PROCEDURE)) { NPCPhrase (BUY_FUEL_INTRO); SET_GAME_STATE (MELNORME_FUEL_PROCEDURE, 1); } } else { if (GLOBAL_SIS (FuelOnBoard) / FUEL_TANK_SCALE + needed_credit > capacity / FUEL_TANK_SCALE) { NPCPhrase (NO_ROOM_FOR_FUEL); goto TryFuelAgain; } if ((int)(needed_credit * (BIO_CREDIT_VALUE / 2)) <= (int)credit) { DWORD f; NPCPhrase (GOT_FUEL); f = (DWORD)needed_credit * FUEL_TANK_SCALE; while (f > 0x3FFFL) { DeltaSISGauges (0, 0x3FFF, 0); f -= 0x3FFF; } DeltaSISGauges (0, (SIZE)f, 0); } needed_credit *= (BIO_CREDIT_VALUE / 2); } if (needed_credit) { DeltaCredit (-needed_credit); if (GLOBAL_SIS (FuelOnBoard) >= capacity) goto BuyBuyBuy; } TryFuelAgain: NPCPhrase (HOW_MUCH_FUEL); Response (buy_1_fuel, DoBuy); Response (buy_5_fuel, DoBuy); Response (buy_10_fuel, DoBuy); Response (buy_25_fuel, DoBuy); Response (fill_me_up, DoBuy); Response (done_buying_fuel, DoBuy); } else if (PLAYER_SAID (R, buy_technology) || PLAYER_SAID (R, buy_new_tech)) { // Note that this code no longer uses the MELNORME_TECH_STACK state // buts, as they're not needed; we can tell what technologies the // player has by using the technology API above. This opens the // possibility of the player acquiring tech from someplace other than // the Melnorme. const TechSaleData* nextTech; // If it's our first time, give an introduction. if (!GET_GAME_STATE (MELNORME_TECH_PROCEDURE)) { NPCPhrase (BUY_NEW_TECH_INTRO); SET_GAME_STATE (MELNORME_TECH_PROCEDURE, 1); } // Did the player just attempt to buy a tech? if (PLAYER_SAID (R, buy_new_tech)) { nextTech = GetNextTechForSale (); if (!nextTech) goto BuyBuyBuy; // No tech left to buy if (!DeltaCredit (-nextTech->price)) goto BuyBuyBuy; // Can't afford it // Make the sale GrantTech (nextTech->techId); NPCPhrase (nextTech->sold_line); } nextTech = GetNextTechForSale (); if (!nextTech) { NPCPhrase (NEW_TECH_ALL_GONE); goto BuyBuyBuy; // No tech left to buy } NPCPhrase (nextTech->sale_line); Response (buy_new_tech, DoBuy); Response (no_buy_new_tech, DoBuy); } else if (PLAYER_SAID (R, buy_info) || PLAYER_SAID (R, buy_current_events) || PLAYER_SAID (R, buy_alien_races) || PLAYER_SAID (R, buy_history)) { if (!GET_GAME_STATE (MELNORME_INFO_PROCEDURE)) { NPCPhrase (BUY_INFO_INTRO); SET_GAME_STATE (MELNORME_INFO_PROCEDURE, 1); } else if (PLAYER_SAID (R, buy_info)) { NPCPhrase (OK_BUY_INFO); } else { #define INFO_COST 75 if (!DeltaCredit (-INFO_COST)) goto BuyBuyBuy; if (PLAYER_SAID (R, buy_current_events)) CurrentEvents (); else if (PLAYER_SAID (R, buy_alien_races)) AlienRaces (); else if (PLAYER_SAID (R, buy_history)) History (); } if (!AnyInfoLeftToSell ()) { NPCPhrase (INFO_ALL_GONE); goto BuyBuyBuy; } if (GET_GAME_STATE (MELNORME_EVENTS_INFO_STACK) < NUM_EVENT_ITEMS) Response (buy_current_events, DoBuy); if (GET_GAME_STATE (MELNORME_ALIEN_INFO_STACK) < NUM_ALIEN_RACE_ITEMS) Response (buy_alien_races, DoBuy); if (GET_GAME_STATE (MELNORME_HISTORY_INFO_STACK) < NUM_HISTORY_ITEMS) Response (buy_history, DoBuy); Response (done_buying_info, DoBuy); } else { if (PLAYER_SAID (R, done_buying_fuel)) NPCPhrase (OK_DONE_BUYING_FUEL); else if (PLAYER_SAID (R, no_buy_new_tech)) NPCPhrase (OK_NO_BUY_NEW_TECH); else if (PLAYER_SAID (R, done_buying_info)) NPCPhrase (OK_DONE_BUYING_INFO); else NPCPhrase (WHAT_TO_BUY); BuyBuyBuy: if (GLOBAL_SIS (FuelOnBoard) < capacity) Response (buy_fuel, DoBuy); if (GetNextTechForSale ()) Response (buy_technology, DoBuy); if (AnyInfoLeftToSell ()) Response (buy_info, DoBuy); Response (done_buying, NatureOfConversation); Response (be_leaving_now, ExitConversation); } }
inline History history() { return History(); }
static void DoBuy (RESPONSE_REF R) { COUNT credit; SIZE needed_credit; BYTE slot; DWORD capacity; credit = MAKE_WORD ( GET_GAME_STATE (MELNORME_CREDIT0), GET_GAME_STATE (MELNORME_CREDIT1) ); capacity = FUEL_RESERVE; slot = NUM_MODULE_SLOTS - 1; do { if (GLOBAL_SIS (ModuleSlots[slot]) == FUEL_TANK || GLOBAL_SIS (ModuleSlots[slot]) == HIGHEFF_FUELSYS) { COUNT volume; volume = GLOBAL_SIS (ModuleSlots[slot]) == FUEL_TANK ? FUEL_TANK_CAPACITY : HEFUEL_TANK_CAPACITY; capacity += volume; } } while (slot--); if (credit == 0) { AskedToBuy = TRUE; NPCPhrase (NEED_CREDIT); NatureOfConversation (R); } else if (PLAYER_SAID (R, buy_fuel) || PLAYER_SAID (R, buy_1_fuel) || PLAYER_SAID (R, buy_5_fuel) || PLAYER_SAID (R, buy_10_fuel) || PLAYER_SAID (R, buy_25_fuel) || PLAYER_SAID (R, fill_me_up)) { needed_credit = 0; if (PLAYER_SAID (R, buy_1_fuel)) needed_credit = 1; else if (PLAYER_SAID (R, buy_5_fuel)) needed_credit = 5; else if (PLAYER_SAID (R, buy_10_fuel)) needed_credit = 10; else if (PLAYER_SAID (R, buy_25_fuel)) needed_credit = 25; else if (PLAYER_SAID (R, fill_me_up)) needed_credit = (capacity - GLOBAL_SIS (FuelOnBoard) + FUEL_TANK_SCALE - 1) / FUEL_TANK_SCALE; if (needed_credit == 0) { if (!GET_GAME_STATE (MELNORME_FUEL_PROCEDURE)) { NPCPhrase (BUY_FUEL_INTRO); SET_GAME_STATE (MELNORME_FUEL_PROCEDURE, 1); } } else { if (GLOBAL_SIS (FuelOnBoard) / FUEL_TANK_SCALE + needed_credit > capacity / FUEL_TANK_SCALE) { NPCPhrase (NO_ROOM_FOR_FUEL); goto TryFuelAgain; } if ((int)(needed_credit * (BIO_CREDIT_VALUE / 2)) <= (int)credit) { DWORD f; NPCPhrase (GOT_FUEL); f = (DWORD)needed_credit * FUEL_TANK_SCALE; LockMutex (GraphicsLock); while (f > 0x3FFFL) { DeltaSISGauges (0, 0x3FFF, 0); f -= 0x3FFF; } DeltaSISGauges (0, (SIZE)f, 0); UnlockMutex (GraphicsLock); } needed_credit *= (BIO_CREDIT_VALUE / 2); } if (needed_credit) { DeltaCredit (-needed_credit); if (GLOBAL_SIS (FuelOnBoard) >= capacity) goto BuyBuyBuy; } TryFuelAgain: NPCPhrase (HOW_MUCH_FUEL); Response (buy_1_fuel, DoBuy); Response (buy_5_fuel, DoBuy); Response (buy_10_fuel, DoBuy); Response (buy_25_fuel, DoBuy); Response (fill_me_up, DoBuy); Response (done_buying_fuel, DoBuy); } else if (PLAYER_SAID (R, buy_technology) || PLAYER_SAID (R, buy_new_tech)) { BYTE stack; needed_credit = 0; if (PLAYER_SAID (R, buy_technology)) { if (!GET_GAME_STATE (MELNORME_TECH_PROCEDURE)) { NPCPhrase (BUY_NEW_TECH_INTRO); SET_GAME_STATE (MELNORME_TECH_PROCEDURE, 1); } stack = 0; } else { RESPONSE_REF pStr; stack = GET_GAME_STATE (MELNORME_TECH_STACK); switch (stack) { case 0: pStr = OK_BUY_NEW_TECH_1; needed_credit = 75 * BIO_CREDIT_VALUE; break; case 1: pStr = OK_BUY_NEW_TECH_2; needed_credit = 75 * BIO_CREDIT_VALUE; break; case 2: pStr = OK_BUY_NEW_TECH_3; needed_credit = 75 * BIO_CREDIT_VALUE; break; case 3: pStr = OK_BUY_NEW_TECH_4; needed_credit = 75 * BIO_CREDIT_VALUE; break; case 4: pStr = OK_BUY_NEW_TECH_5; needed_credit = 75 * BIO_CREDIT_VALUE; break; case 5: pStr = OK_BUY_NEW_TECH_6; needed_credit = 75 * BIO_CREDIT_VALUE; break; case 6: pStr = OK_BUY_NEW_TECH_7; needed_credit = 75 * BIO_CREDIT_VALUE; break; case 7: pStr = OK_BUY_NEW_TECH_8; needed_credit = 75 * BIO_CREDIT_VALUE; break; case 8: pStr = OK_BUY_NEW_TECH_9; needed_credit = 75 * BIO_CREDIT_VALUE; break; case 9: pStr = OK_BUY_NEW_TECH_10; needed_credit = 75 * BIO_CREDIT_VALUE; break; case 10: pStr = OK_BUY_NEW_TECH_11; needed_credit = 75 * BIO_CREDIT_VALUE; break; case 11: pStr = OK_BUY_NEW_TECH_12; needed_credit = 75 * BIO_CREDIT_VALUE; break; case 12: pStr = OK_BUY_NEW_TECH_13; needed_credit = 75 * BIO_CREDIT_VALUE; break; } if ((int)needed_credit > (int)credit) { DeltaCredit (-needed_credit); goto BuyBuyBuy; } else { ++stack; NPCPhrase (pStr); DeltaCredit (-needed_credit); } } switch (stack) { case 0: if (GLOBAL (ModuleCost[BLASTER_WEAPON]) == 0) { NPCPhrase (NEW_TECH_1); break; } ++stack; case 1: GLOBAL (ModuleCost[BLASTER_WEAPON]) = 4000 / MODULE_COST_SCALE; if (!GET_GAME_STATE (IMPROVED_LANDER_SPEED)) { NPCPhrase (NEW_TECH_2); break; } ++stack; case 2: SET_GAME_STATE (IMPROVED_LANDER_SPEED, 1); if (GLOBAL (ModuleCost[ANTIMISSILE_DEFENSE]) == 0) { NPCPhrase (NEW_TECH_3); break; } ++stack; case 3: GLOBAL (ModuleCost[ANTIMISSILE_DEFENSE]) = 4000 / MODULE_COST_SCALE; if (!(GET_GAME_STATE (LANDER_SHIELDS) & (1 << BIOLOGICAL_DISASTER))) { NPCPhrase (NEW_TECH_4); break; } ++stack; case 4: credit = GET_GAME_STATE (LANDER_SHIELDS) | (1 << BIOLOGICAL_DISASTER); SET_GAME_STATE (LANDER_SHIELDS, credit); if (!GET_GAME_STATE (IMPROVED_LANDER_CARGO)) { NPCPhrase (NEW_TECH_5); break; } ++stack; case 5: SET_GAME_STATE (IMPROVED_LANDER_CARGO, 1); if (GLOBAL (ModuleCost[HIGHEFF_FUELSYS]) == 0) { NPCPhrase (NEW_TECH_6); break; } ++stack; case 6: GLOBAL (ModuleCost[HIGHEFF_FUELSYS]) = 1000 / MODULE_COST_SCALE; if (!GET_GAME_STATE (IMPROVED_LANDER_SHOT)) { NPCPhrase (NEW_TECH_7); break; } ++stack; case 7: SET_GAME_STATE (IMPROVED_LANDER_SHOT, 1); if (!(GET_GAME_STATE (LANDER_SHIELDS) & (1 << EARTHQUAKE_DISASTER))) { NPCPhrase (NEW_TECH_8); break; } ++stack; case 8: credit = GET_GAME_STATE (LANDER_SHIELDS) | (1 << EARTHQUAKE_DISASTER); SET_GAME_STATE (LANDER_SHIELDS, credit); if (GLOBAL (ModuleCost[TRACKING_SYSTEM]) == 0) { NPCPhrase (NEW_TECH_9); break; } ++stack; case 9: GLOBAL (ModuleCost[TRACKING_SYSTEM]) = 5000 / MODULE_COST_SCALE; if (!(GET_GAME_STATE (LANDER_SHIELDS) & (1 << LIGHTNING_DISASTER))) { NPCPhrase (NEW_TECH_10); break; } ++stack; case 10: credit = GET_GAME_STATE (LANDER_SHIELDS) | (1 << LIGHTNING_DISASTER); SET_GAME_STATE (LANDER_SHIELDS, credit); if (!(GET_GAME_STATE (LANDER_SHIELDS) & (1 << LAVASPOT_DISASTER))) { NPCPhrase (NEW_TECH_11); break; } ++stack; case 11: credit = GET_GAME_STATE (LANDER_SHIELDS) | (1 << LAVASPOT_DISASTER); SET_GAME_STATE (LANDER_SHIELDS, credit); if (GLOBAL (ModuleCost[CANNON_WEAPON]) == 0) { NPCPhrase (NEW_TECH_12); break; } ++stack; case 12: GLOBAL (ModuleCost[CANNON_WEAPON]) = 6000 / MODULE_COST_SCALE; if (GLOBAL (ModuleCost[SHIVA_FURNACE]) == 0) { NPCPhrase (NEW_TECH_13); break; } ++stack; case 13: GLOBAL (ModuleCost[SHIVA_FURNACE]) = 4000 / MODULE_COST_SCALE; NPCPhrase (NEW_TECH_ALL_GONE); SET_GAME_STATE (MELNORME_TECH_STACK, stack); goto BuyBuyBuy; } SET_GAME_STATE (MELNORME_TECH_STACK, stack); Response (buy_new_tech, DoBuy); Response (no_buy_new_tech, DoBuy); } else if (PLAYER_SAID (R, buy_info) || PLAYER_SAID (R, buy_current_events) || PLAYER_SAID (R, buy_alien_races) || PLAYER_SAID (R, buy_history)) { needed_credit = 0; if (PLAYER_SAID (R, buy_info)) { if (GET_GAME_STATE (MELNORME_INFO_PROCEDURE)) NPCPhrase (OK_BUY_INFO); else { NPCPhrase (BUY_INFO_INTRO); SET_GAME_STATE (MELNORME_INFO_PROCEDURE, 1); } } else { #define INFO_COST 75 needed_credit = INFO_COST; if ((int)credit >= (int)needed_credit) { if (PLAYER_SAID (R, buy_current_events)) CurrentEvents (); else if (PLAYER_SAID (R, buy_alien_races)) AlienRaces (); else /* if (R == buy_history) */ History (); } DeltaCredit (-needed_credit); if (GET_GAME_STATE (MELNORME_EVENTS_INFO_STACK) < NUM_EVENT_ITEMS || GET_GAME_STATE (MELNORME_ALIEN_INFO_STACK) < NUM_ALIEN_RACE_ITEMS || GET_GAME_STATE (MELNORME_HISTORY_INFO_STACK) < NUM_HISTORY_ITEMS) { } else { NPCPhrase (INFO_ALL_GONE); goto BuyBuyBuy; } } if (GET_GAME_STATE (MELNORME_EVENTS_INFO_STACK) < NUM_EVENT_ITEMS) Response (buy_current_events, DoBuy); if (GET_GAME_STATE (MELNORME_ALIEN_INFO_STACK) < NUM_ALIEN_RACE_ITEMS) Response (buy_alien_races, DoBuy); if (GET_GAME_STATE (MELNORME_HISTORY_INFO_STACK) < NUM_HISTORY_ITEMS) Response (buy_history, DoBuy); Response (done_buying_info, DoBuy); } else { if (PLAYER_SAID (R, done_buying_fuel)) NPCPhrase (OK_DONE_BUYING_FUEL); else if (PLAYER_SAID (R, no_buy_new_tech)) NPCPhrase (OK_NO_BUY_NEW_TECH); else if (PLAYER_SAID (R, done_buying_info)) NPCPhrase (OK_DONE_BUYING_INFO); else NPCPhrase (WHAT_TO_BUY); BuyBuyBuy: if (GLOBAL_SIS (FuelOnBoard) < capacity) Response (buy_fuel, DoBuy); if (GET_GAME_STATE (MELNORME_TECH_STACK) < NUM_TECH_ITEMS) Response (buy_technology, DoBuy); if (GET_GAME_STATE (MELNORME_ALIEN_INFO_STACK) < NUM_ALIEN_RACE_ITEMS || GET_GAME_STATE (MELNORME_HISTORY_INFO_STACK) < NUM_HISTORY_ITEMS || GET_GAME_STATE (MELNORME_EVENTS_INFO_STACK) < NUM_EVENT_ITEMS) Response (buy_info, DoBuy); Response (done_buying, NatureOfConversation); Response (be_leaving_now, ExitConversation); } }
void onquit(char *nick) { register aluser *user, **u; register asuser *suser, **s; register avalchan *valchan; #ifdef DEBUG printf("Detected user quit..\n"); #endif u = &Lusers[lu_hash(nick)]; while (*u && strcasecmp(nick, (*u)->nick)) u = &(*u)->next; user = *u; if (user == NULL) { log("ERROR: onquit() can't find user!"); #ifdef HISTORY History(NULL); #endif return; } /* remove from memory */ while ((valchan = user->valchan) != NULL) { #ifdef DEBUG printf("\twas validated on %s\n", valchan->name); #endif valchan->reg->inuse--; user->valchan = valchan->next; TTLALLOCMEM -= strlen(valchan->name) + 1; free(valchan->name); TTLALLOCMEM -= sizeof(avalchan); free(valchan); } while (user->channel != NULL) { #ifdef DEBUG printf("\twas on %s\n", user->channel->N->name); #endif /* onpart() free's the chan structure * we can't do chan=chan->next after the * onpart() call. We must start from the * beginning of the list every time */ onpart(nick, user->channel->N->name); } /* remove user from server's userlist */ s = &user->server->users[su_hash(user->nick)]; while (*s != NULL && strcasecmp((*s)->N->nick, user->nick)) { s = &(*s)->next; } if (*s != NULL) { suser = *s; *s = (*s)->next; TTLALLOCMEM -= sizeof(asuser); free(suser); } else { log("ERROR: onquit() user not found in server's userlist!"); } *u = user->next; #if 0 if (!strcasecmp(user->nick, DEFAULT_NICKNAME)) { ChNick(DEFAULT_NICKNAME); } #endif #ifdef NICKSERV nserv_quit(user); #endif TTLALLOCMEM -= strlen(user->nick) + 1; free(user->nick); TTLALLOCMEM -= strlen(user->username) + 1; free(user->username); TTLALLOCMEM -= strlen(user->site) + 1; free(user->site); TTLALLOCMEM -= sizeof(aluser); free(user); }
/* read in a command line */ BOOL ReadCommand(LPTSTR str, INT maxlen) { CONSOLE_SCREEN_BUFFER_INFO csbi; SHORT orgx; /* origin x/y */ SHORT orgy; SHORT curx; /*current x/y cursor position*/ SHORT cury; SHORT tempscreen; INT count; /*used in some for loops*/ INT current = 0; /*the position of the cursor in the string (str)*/ INT charcount = 0;/*chars in the string (str)*/ INPUT_RECORD ir; #ifdef FEATURE_UNIX_FILENAME_COMPLETION WORD wLastKey = 0; #endif TCHAR ch; BOOL bReturn = FALSE; BOOL bCharInput; #ifdef FEATURE_4NT_FILENAME_COMPLETION TCHAR szPath[MAX_PATH]; #endif #ifdef FEATURE_HISTORY //BOOL bContinue=FALSE;/*is TRUE the second case will not be executed*/ TCHAR PreviousChar; #endif if (!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) { /* No console */ HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); DWORD dwRead; CHAR chr; do { if (!ReadFile(hStdin, &chr, 1, &dwRead, NULL) || !dwRead) return FALSE; #ifdef _UNICODE MultiByteToWideChar(InputCodePage, 0, &chr, 1, &str[charcount++], 1); #endif } while (chr != '\n' && charcount < maxlen); str[charcount] = _T('\0'); return TRUE; } /* get screen size */ maxx = csbi.dwSize.X; maxy = csbi.dwSize.Y; curx = orgx = csbi.dwCursorPosition.X; cury = orgy = csbi.dwCursorPosition.Y; memset (str, 0, maxlen * sizeof (TCHAR)); SetCursorType (bInsert, TRUE); do { bReturn = FALSE; ConInKey (&ir); if (ir.Event.KeyEvent.dwControlKeyState & (RIGHT_ALT_PRESSED |LEFT_ALT_PRESSED| RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED) ) { switch (ir.Event.KeyEvent.wVirtualKeyCode) { #ifdef FEATURE_HISTORY case 'K': /*add the current command line to the history*/ if (ir.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED)) { if (str[0]) History(0,str); ClearCommandLine (str, maxlen, orgx, orgy); current = charcount = 0; curx = orgx; cury = orgy; //bContinue=TRUE; break; } case 'D': /*delete current history entry*/ if (ir.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED)) { ClearCommandLine (str, maxlen, orgx, orgy); History_del_current_entry(str); current = charcount = _tcslen (str); ConOutPrintf (_T("%s"), str); GetCursorXY (&curx, &cury); //bContinue=TRUE; break; } #endif /*FEATURE_HISTORY*/ } } bCharInput = FALSE; switch (ir.Event.KeyEvent.wVirtualKeyCode) { case VK_BACK: /* <BACKSPACE> - delete character to left of cursor */ if (current > 0 && charcount > 0) { if (current == charcount) { /* if at end of line */ str[current - 1] = _T('\0'); if (GetCursorX () != 0) { ConOutPrintf (_T("\b \b")); curx--; } else { SetCursorXY ((SHORT)(maxx - 1), (SHORT)(GetCursorY () - 1)); ConOutChar (_T(' ')); SetCursorXY ((SHORT)(maxx - 1), (SHORT)(GetCursorY () - 1)); cury--; curx = maxx - 1; } } else { for (count = current - 1; count < charcount; count++) str[count] = str[count + 1]; if (GetCursorX () != 0) { SetCursorXY ((SHORT)(GetCursorX () - 1), GetCursorY ()); curx--; } else { SetCursorXY ((SHORT)(maxx - 1), (SHORT)(GetCursorY () - 1)); cury--; curx = maxx - 1; } GetCursorXY (&curx, &cury); ConOutPrintf (_T("%s "), &str[current - 1]); SetCursorXY (curx, cury); } charcount--; current--; } break; case VK_INSERT: /* toggle insert/overstrike mode */ bInsert ^= TRUE; SetCursorType (bInsert, TRUE); break; case VK_DELETE: /* delete character under cursor */ if (current != charcount && charcount > 0) { for (count = current; count < charcount; count++) str[count] = str[count + 1]; charcount--; GetCursorXY (&curx, &cury); ConOutPrintf (_T("%s "), &str[current]); SetCursorXY (curx, cury); } break; case VK_HOME: /* goto beginning of string */ if (current != 0) { SetCursorXY (orgx, orgy); curx = orgx; cury = orgy; current = 0; } break; case VK_END: /* goto end of string */ if (current != charcount) { SetCursorXY (orgx, orgy); ConOutPrintf (_T("%s"), str); GetCursorXY (&curx, &cury); current = charcount; } break; case VK_TAB: #ifdef FEATURE_UNIX_FILENAME_COMPLETION /* expand current file name */ if ((current == charcount) || (current == charcount - 1 && str[current] == _T('"'))) /* only works at end of line*/ { if (wLastKey != VK_TAB) { /* if first TAB, complete filename*/ tempscreen = charcount; CompleteFilename (str, charcount); charcount = _tcslen (str); current = charcount; SetCursorXY (orgx, orgy); ConOutPrintf (_T("%s"), str); if (tempscreen > charcount) { GetCursorXY (&curx, &cury); for (count = tempscreen - charcount; count--; ) ConOutChar (_T(' ')); SetCursorXY (curx, cury); } else { if (((charcount + orgx) / maxx) + orgy > maxy - 1) orgy += maxy - ((charcount + orgx) / maxx + orgy + 1); } /* set cursor position */ SetCursorXY ((orgx + current) % maxx, orgy + (orgx + current) / maxx); GetCursorXY (&curx, &cury); } else { /*if second TAB, list matches*/ if (ShowCompletionMatches (str, charcount)) { PrintPrompt(); GetCursorXY(&orgx, &orgy); ConOutPrintf(_T("%s"), str); /* set cursor position */ SetCursorXY((orgx + current) % maxx, orgy + (orgx + current) / maxx); GetCursorXY(&curx, &cury); } } } else { MessageBeep(-1); } #endif #ifdef FEATURE_4NT_FILENAME_COMPLETION /* used to later see if we went down to the next line */ tempscreen = charcount; szPath[0]=_T('\0'); /* str is the whole things that is on the current line that is and and out. arg 2 is weather it goes back one file or forward one file */ CompleteFilename(str, !(ir.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED), szPath, current); /* Attempt to clear the line */ ClearCommandLine (str, maxlen, orgx, orgy); curx = orgx; cury = orgy; current = charcount = 0; /* Everything is deleted, lets add it back in */ _tcscpy(str,szPath); /* Figure out where cusor is going to be after we print it */ charcount = _tcslen(str); current = charcount; SetCursorXY(orgx, orgy); /* Print out what we have now */ ConOutPrintf(_T("%s"), str); /* Move cursor accordingly */ if (tempscreen > charcount) { GetCursorXY(&curx, &cury); for(count = tempscreen - charcount; count--; ) ConOutChar(_T(' ')); SetCursorXY(curx, cury); } else { if (((charcount + orgx) / maxx) + orgy > maxy - 1) orgy += maxy - ((charcount + orgx) / maxx + orgy + 1); } SetCursorXY((short)(((int)orgx + current) % maxx), (short)((int)orgy + ((int)orgx + current) / maxx)); GetCursorXY(&curx, &cury); #endif break; case _T('M'): case _T('C'): /* ^M does the same as return */ bCharInput = TRUE; if (!(ir.Event.KeyEvent.dwControlKeyState & (RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED))) { break; } case VK_RETURN: /* end input, return to main */ #ifdef FEATURE_HISTORY /* add to the history */ if (str[0]) History (0, str); #endif str[charcount++] = _T('\n'); str[charcount] = _T('\0'); ConOutChar(_T('\n')); bReturn = TRUE; break; case VK_ESCAPE: /* clear str Make this callable! */ ClearCommandLine (str, maxlen, orgx, orgy); curx = orgx; cury = orgy; current = charcount = 0; break; #ifdef FEATURE_HISTORY case VK_F3: History_move_to_bottom(); #endif case VK_UP: #ifdef FEATURE_HISTORY /* get previous command from buffer */ ClearCommandLine (str, maxlen, orgx, orgy); History (-1, str); current = charcount = _tcslen (str); if (((charcount + orgx) / maxx) + orgy > maxy - 1) orgy += maxy - ((charcount + orgx) / maxx + orgy + 1); ConOutPrintf (_T("%s"), str); GetCursorXY (&curx, &cury); #endif break; case VK_DOWN: #ifdef FEATURE_HISTORY /* get next command from buffer */ ClearCommandLine (str, maxlen, orgx, orgy); History (1, str); current = charcount = _tcslen (str); if (((charcount + orgx) / maxx) + orgy > maxy - 1) orgy += maxy - ((charcount + orgx) / maxx + orgy + 1); ConOutPrintf (_T("%s"), str); GetCursorXY (&curx, &cury); #endif break; case VK_LEFT: /* move cursor left */ if (current > 0) { current--; if (GetCursorX () == 0) { SetCursorXY ((SHORT)(maxx - 1), (SHORT)(GetCursorY () - 1)); curx = maxx - 1; cury--; } else { SetCursorXY ((SHORT)(GetCursorX () - 1), GetCursorY ()); curx--; } } else { MessageBeep (-1); } break; case VK_RIGHT: /* move cursor right */ if (current != charcount) { current++; if (GetCursorX () == maxx - 1) { SetCursorXY (0, (SHORT)(GetCursorY () + 1)); curx = 0; cury++; } else { SetCursorXY ((SHORT)(GetCursorX () + 1), GetCursorY ()); curx++; } } #ifdef FEATURE_HISTORY else { LPCTSTR last = PeekHistory(-1); if (last && charcount < (INT)_tcslen (last)) { PreviousChar = last[current]; ConOutChar(PreviousChar); GetCursorXY(&curx, &cury); str[current++] = PreviousChar; charcount++; } } #endif break; default: /* This input is just a normal char */ bCharInput = TRUE; } #ifdef _UNICODE ch = ir.Event.KeyEvent.uChar.UnicodeChar; if (ch >= 32 && (charcount != (maxlen - 2)) && bCharInput) #else ch = ir.Event.KeyEvent.uChar.AsciiChar; if ((UCHAR)ch >= 32 && (charcount != (maxlen - 2)) && bCharInput) #endif /* _UNICODE */ { /* insert character into string... */ if (bInsert && current != charcount) { /* If this character insertion will cause screen scrolling, * adjust the saved origin of the command prompt. */ tempscreen = _tcslen(str + current) + curx; if ((tempscreen % maxx) == (maxx - 1) && (tempscreen / maxx) + cury == (maxy - 1)) { orgy--; cury--; } for (count = charcount; count > current; count--) str[count] = str[count - 1]; str[current++] = ch; if (curx == maxx - 1) curx = 0, cury++; else curx++; ConOutPrintf (_T("%s"), &str[current - 1]); SetCursorXY (curx, cury); charcount++; } else { if (current == charcount) charcount++; str[current++] = ch; if (GetCursorX () == maxx - 1 && GetCursorY () == maxy - 1) orgy--, cury--; if (GetCursorX () == maxx - 1) curx = 0, cury++; else curx++; ConOutChar (ch); } } //wLastKey = ir.Event.KeyEvent.wVirtualKeyCode; } while (!bReturn); SetCursorType (bInsert, TRUE); #ifdef FEATURE_ALIASES /* expand all aliases */ ExpandAlias (str, maxlen); #endif /* FEATURE_ALIAS */ return TRUE; }
void Analyser (Domain *omega, int step, double time) { FILE *fp[2]; int nfields = omega->U->fhead->dim()+1; int i; Element_List **V; char fname[FILENAME_MAX]; double step_length; dparam_set("t", time); V = (Element_List**) malloc(nfields*sizeof(Element_List*)); /* .......... Field Files ......... */ V[0] = omega->U; V[1] = omega->V; V[2] = omega->W; V[3] = omega->P; if(init){ verbose = option("verbose"); iostep = iparam("IOSTEP"); hisstep = option("hisstep"); if(!hisstep) hisstep = iparam("HISSTEP"); nsteps = iparam("NSTEPS"); timeavg = option("timeavg"); if (omega->his_list) hisHeader (omega); init = 0; } /* .......... General Output ......... */ step_length = (clock()-last_time)/(double)CLOCKS_PER_SEC; last_time = clock(); ROOTONLY fprintf(stdout, "Time step = %d, Time = %g Cpu-Time = %g\n", step, time, step_length); fflush(stdout); if (step == 0){ /* Everything else is for step > 0 */ if (omega->his_list) /* Do initial history point */ History (omega, time); return; } if ((step % hisstep) == 0){ if (omega->his_list){ History (omega, time); fflush(omega->his_file); } forces(omega,step,time); if (option ("SurInflow") == 1) { surf_inflow(omega,step,time); } ROOTONLY fflush(omega->fce_file); /* flush stdout at step as well */ ROOTONLY fflush(stdout); if(option("SurForce")||option("SurInflow")){ cnt_srf_elements(omega); } if(verbose){ if(omega->soln) for(i=0;i<nfields;++i) V[i]->Terror(omega->soln[i]); else V[0]->Terror("0.0"); } } if(option("SurForce")||option("SurInflow")){ int a = cnt_srf_elements(omega); } if (step % iostep == 0 && step < nsteps) { if (option ("checkpt")) { DO_PARALLEL{ if(option("SLICES")&&check_number<100){ sprintf (fname, "%s_%d.chk.hdr.%d", omega->name, check_number, pllinfo.procid); fp[0] = fopen(fname,"w"); sprintf (fname, "%s_%d.chk.dat.%d", omega->name, check_number, pllinfo.procid); fp[1] = fopen(fname,"w"); ++check_number; } else{ sprintf (fname, "%s.chk.hdr.%d", omega->name, pllinfo.procid); fp[0] = fopen(fname,"w"); sprintf (fname, "%s.chk.dat.%d", omega->name, pllinfo.procid); fp[1] = fopen(fname,"w"); } Writefld (fp, omega->name, step, time, nfields, V); fclose(fp[0]); fclose(fp[1]); } else{ if(option("SLICES")&&check_number<100){ sprintf (fname, "%s_%d.chk", omega->name,check_number); ++check_number; } else sprintf (fname, "%s.chk", omega->name); fp[1] = fp[0] = fopen(fname,"w"); Writefld (fp, omega->name, step, time, nfields, V); fclose(fp[0]); } }