int Panel::ProcessKey(int Key, unsigned int ControlState) { switch (Key) { case VK_F3: if (ControlState == PKF_SHIFT) { return true; } break; case VK_F4: switch (ControlState) { case 0: DlgShutdown(); return true; case PKF_SHIFT: return true; } break; case VK_F6: switch (ControlState) { case 0: if (DlgConnection()) { psi.Control(this, FCTL_UPDATEPANEL, 0, nullptr); psi.Control(this, FCTL_REDRAWPANEL, 0, nullptr); } return true; case PKF_SHIFT: try { m_conn->Open(nullptr); } catch (WinError &e) { farebox_code(e.code(), e.where().c_str()); } psi.Control(this, FCTL_UPDATEPANEL, 0, nullptr); psi.Control(this, FCTL_REDRAWPANEL, 0, nullptr); return true; } break; case VK_F7: switch (ControlState) { case 0: AutoUTF cmd = L"mstsc.exe"; if (!Empty(m_conn->host())) { cmd += L" /v:"; cmd += m_conn->host(); } ExecCMD(cmd); return true; } break; } if ((ControlState == 0 && (Key == VK_F3 || Key == VK_F5 || Key == VK_F8)) || (ControlState == PKF_SHIFT && (Key == VK_F7 || Key == VK_F8))) { FarPnl pInfo(this, FCTL_GETPANELINFO); WinTS::iterator m_cur; if (pInfo.ItemsNumber() && pInfo.CurrentItem() && (m_cur = std::find(m_ts.begin(), m_ts.end(), pInfo[pInfo.CurrentItem()].FindData.nFileSize)) != m_ts.end()) { if (ControlState == 0 && Key == VK_F3) { AutoUTF tmp(TempFile(TempDir())); HANDLE hfile = ::CreateFileW(tmp.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (hfile != INVALID_HANDLE_VALUE) { FileWrite(hfile, Info(m_cur)); ::CloseHandle(hfile); psi.Viewer(tmp.c_str(), nullptr, 0, 0, -1, -1, VF_DELETEONLYFILEONCLOSE | VF_ENABLE_F6 | VF_DISABLEHISTORY | VF_NONMODAL | VF_IMMEDIATERETURN, CP_AUTODETECT); } return true; } else if (ControlState == 0 && Key == VK_F5) { DlgMessage(m_cur->id()); } else if (ControlState == PKF_SHIFT && Key == VK_F7) { WinTSession::ConnectLocal(m_cur->id()); } else if (ControlState == 0 && Key == VK_F8) { if (farquestion(GetMsg(txtAreYouSure), GetMsg(txtDisconnectSession))) WinTSession::Disconnect(m_cur->id(), m_conn->host()); } else if (ControlState == PKF_SHIFT && Key == VK_F8) { if (farquestion(GetMsg(txtAreYouSure), GetMsg(txtLogoffSession))) WinTSession::LogOff(m_cur->id(), m_conn->host()); } psi.Control(this, FCTL_UPDATEPANEL, 0, nullptr); psi.Control(this, FCTL_REDRAWPANEL, 0, nullptr); return true; } } return false; }
bool ArenaTeam::LoadMembersFromDB(QueryResult* arenaTeamMembersResult) { if (!arenaTeamMembersResult) return false; bool captainPresentInTeam = false; do { Field* fields = arenaTeamMembersResult->Fetch(); // prevent crash if db records are broken, when all members in result are already processed and current team hasn't got any members if (!fields) break; uint32 arenaTeamId = fields[0].GetUInt32(); if (arenaTeamId < m_TeamId) { // there is in table arena_team_member record which doesn't have arenateamid in arena_team table, report error sLog.outErrorDb("ArenaTeam %u does not exist but it has record in arena_team_member table, deleting it!", arenaTeamId); CharacterDatabase.PExecute("DELETE FROM arena_team_member WHERE arenateamid = '%u'", arenaTeamId); continue; } if (arenaTeamId > m_TeamId) // we loaded all members for this arena_team already, break cycle break; ArenaTeamMember newmember; newmember.guid = ObjectGuid(HIGHGUID_PLAYER, fields[1].GetUInt32()); newmember.games_week = fields[2].GetUInt32(); newmember.wins_week = fields[3].GetUInt32(); newmember.games_season = fields[4].GetUInt32(); newmember.wins_season = fields[5].GetUInt32(); newmember.personal_rating = fields[6].GetUInt32(); newmember.name = fields[7].GetCppString(); newmember.Class = fields[8].GetUInt8(); // check if member exists in characters table if (newmember.name.empty()) { sLog.outErrorDb("ArenaTeam %u has member with empty name - probably player %s doesn't exist, deleting him from memberlist!", arenaTeamId, newmember.guid.GetString().c_str()); DelMember(newmember.guid); continue; } // arena team can't be > 2 * arenatype (2 for 2x2, 3 for 3x3, 5 for 5x5) if (GetMembersSize() >= GetMaxMembersSize()) return false; if (newmember.guid == GetCaptainGuid()) captainPresentInTeam = true; m_members.push_back(newmember); } while (arenaTeamMembersResult->NextRow()); if (Empty() || !captainPresentInTeam) { // arena team is empty or captain is not in team, delete from db sLog.outErrorDb("ArenaTeam %u does not have any members or its captain is not in team, disbanding it...", m_TeamId); return false; } return true; }
CmdArg::CmdArg() { mn_MaxLen = 0; ms_Arg = NULL; mb_RestorePath = false; Empty(); }
static AddError() { a_sym *xsym, *sym; a_pro *xpro, *pro; a_state *x, **s, **t, *AddErrState(); a_shift_action *tx, *ty, *trans; a_reduce_action *rx, *ry, *redun; int i; a_word *defined, *conflict, *rset; short int *at; trans = CALLOC( nsym, a_shift_action ); rx = redun = CALLOC( npro + 1, a_reduce_action ); rset = conflict = CALLOC( (npro + 2)*wperset, a_word ); for( i = 0; i <= npro; ++i ) { (rx++)->follow = rset; rset += wperset; } defined = rset; s = CALLOC( nstate, a_state * ); at = CALLOC( nstate, short int ); s = t = CALLOC( nstate + 1, a_state * ); for( x = statelist; x; x = x->next ) { Mark( *x ); *t++ = x; } restart = AddErrState( &errsym->enter, s, t ); for( x = restart; x; x = x->next ) { Clear( defined ); Clear( conflict ); xpro = NULL; for( i = 0; i < x->kersize; ++i ) { at[i] = 0; if( (pro = x->name.state[i]->redun->pro) > xpro ) { xpro = pro; } } redun->pro = errpro; rx = redun + 1; if( x != restart ) while( xpro ) { pro = xpro; xpro = NULL; Clear( rx->follow ); for( i = 0; i < x->kersize; ++i ) { ry = &x->name.state[i]->redun[at[i]]; if( ry->pro == pro ) { Union( rx->follow, ry->follow ); ++(at[i]); ++ry; } if( ry->pro > xpro ) { xpro = ry->pro; } } UnionAnd( conflict, rx->follow, defined ); Union( defined, rx->follow ); rx->pro = pro; ++rx; } xsym = NULL; for( i = 0; i < x->kersize; ++i ) { at[i] = 0; if( (sym = x->name.state[i]->trans->sym) > xsym ) { xsym = sym; } } tx = trans; while( xsym ) { sym = xsym; xsym = NULL; t = s; for( i = 0; i < x->kersize; ++i ) { ty = &x->name.state[i]->trans[at[i]]; if( ty->sym == sym ) { if( !IsMarked( *ty->state ) ) { Mark( *ty->state ); *t++ = ty->state; } ++(at[i]); ++ty; } if( ty->sym > xsym ) { xsym = ty->sym; } } tx->sym = sym; if( sym->pro ) { ++nvtrans; } else { if( IsBitSet( defined, sym->id ) ) { SetBit( conflict, sym->id ); while( --t >= s ) { Unmark( **t ); } continue; } else { SetBit( defined, sym->id ); } } tx->state = AddErrState( &errsym->enter, s, t ); ++tx; } x->trans = CALLOC( tx - trans + 1, a_shift_action ); memcpy( x->trans, trans, ((char *) tx) - ((char *) trans) ); if( Empty( conflict ) ) { redun->pro = NULL; i = 0; } else { i = 1; } while( --rx > redun ) { AndNot( rx->follow, conflict ); if( Empty( rx->follow ) ) { rx->pro = NULL; } else { ++i; } } x->redun = CALLOC( i + 1, a_reduce_action ); if( i ) { rset = CALLOC( i*wperset, a_word ); rx = redun; while( i > 0 ) { if( rx->pro ) { --i; x->redun[i].pro = rx->pro; x->redun[i].follow = rset; Assign( rset, rx->follow ); rset += wperset; } ++rx; } } } free( trans ); free( redun ); free( conflict ); free( s ); free( at ); }
HDM::HDM() { Mnemonic = "HDM"; Empty(); }
VTG::~VTG() { Mnemonic.Empty(); Empty(); }
int peek(Stack* stack) { if (Empty(stack)) return INT_MIN; return stack->array[stack->top]; }
Empty ReturnsEmpty::getEmpty() { return Empty(); }
CFX_ListCtrl::~CFX_ListCtrl() { Empty(); }
ValueType Front(void) { assert(!Empty()); return Element(_context, _current); }
void ResultIterator::CalculateBlobOrder( GenericVector<int> *blob_indices) const { bool context_is_ltr = current_paragraph_is_ltr_ ^ in_minor_direction_; blob_indices->clear(); if (Empty(RIL_WORD)) return; if (context_is_ltr || it_->word()->UnicharsInReadingOrder()) { // Easy! just return the blobs in order; for (int i = 0; i < word_length_; i++) blob_indices->push_back(i); return; } // The blobs are in left-to-right order, but the current reading context // is right-to-left. const int U_LTR = UNICHARSET::U_LEFT_TO_RIGHT; const int U_RTL = UNICHARSET::U_RIGHT_TO_LEFT; const int U_EURO_NUM = UNICHARSET::U_EUROPEAN_NUMBER; const int U_EURO_NUM_SEP = UNICHARSET::U_EUROPEAN_NUMBER_SEPARATOR; const int U_EURO_NUM_TERM = UNICHARSET::U_EUROPEAN_NUMBER_TERMINATOR; const int U_COMMON_NUM_SEP = UNICHARSET::U_COMMON_NUMBER_SEPARATOR; const int U_OTHER_NEUTRAL = UNICHARSET::U_OTHER_NEUTRAL; // Step 1: Scan for and mark European Number sequences // [:ET:]*[:EN:]+(([:ES:]|[:CS:])?[:EN:]+)*[:ET:]* GenericVector<int> letter_types; for (int i = 0; i < word_length_; i++) { letter_types.push_back(it_->word()->SymbolDirection(i)); } // Convert a single separtor sandwiched between two EN's into an EN. for (int i = 0; i + 2 < word_length_; i++) { if (letter_types[i] == U_EURO_NUM && letter_types[i + 2] == U_EURO_NUM && (letter_types[i + 1] == U_EURO_NUM_SEP || letter_types[i + 1] == U_COMMON_NUM_SEP)) { letter_types[i + 1] = U_EURO_NUM; } } // Scan for sequences of European Number Terminators around ENs and convert // them to ENs. for (int i = 0; i < word_length_; i++) { if (letter_types[i] == U_EURO_NUM_TERM) { int j = i + 1; while (j < word_length_ && letter_types[j] == U_EURO_NUM_TERM) { j++; } if (j < word_length_ && letter_types[j] == U_EURO_NUM) { // The sequence [i..j] should be converted to all European Numbers. for (int k = i; k < j; k++) letter_types[k] = U_EURO_NUM; } j = i - 1; while (j > -1 && letter_types[j] == U_EURO_NUM_TERM) { j--; } if (j > -1 && letter_types[j] == U_EURO_NUM) { // The sequence [j..i] should be converted to all European Numbers. for (int k = j; k <= i; k++) letter_types[k] = U_EURO_NUM; } } } // Step 2: Convert all remaining types to either L or R. // Sequences ([:L:]|[:EN:])+ (([:CS:]|[:ON:])+ ([:L:]|[:EN:])+)* -> L. // All other are R. for (int i = 0; i < word_length_;) { int ti = letter_types[i]; if (ti == U_LTR || ti == U_EURO_NUM) { // Left to right sequence; scan to the end of it. int last_good = i; for (int j = i + 1; j < word_length_; j++) { int tj = letter_types[j]; if (tj == U_LTR || tj == U_EURO_NUM) { last_good = j; } else if (tj == U_COMMON_NUM_SEP || tj == U_OTHER_NEUTRAL) { // do nothing. } else { break; } } // [i..last_good] is the L sequence for (int k = i; k <= last_good; k++) letter_types[k] = U_LTR; i = last_good + 1; } else { letter_types[i] = U_RTL; i++; } } // At this point, letter_types is entirely U_LTR or U_RTL. for (int i = word_length_ - 1; i >= 0;) { if (letter_types[i] == U_RTL) { blob_indices->push_back(i); i--; } else { // left to right sequence. scan to the beginning. int j = i - 1; for (; j >= 0 && letter_types[j] != U_RTL; j--) { } // pass // Now (j, i] is LTR for (int k = j + 1; k <= i; k++) blob_indices->push_back(k); i = j; } } ASSERT_HOST(blob_indices->size() == word_length_); }
void Next(void) { assert(!Empty()); ++_current; }
ValueType Front(void) const { assert(!Empty()); return *_pos; }
void Next(void) { assert(!Empty()); ++_pos; }
GraphType::~GraphType() { Empty(); }
SATELLITE_DATA::~SATELLITE_DATA() { Empty(); }
VTG::VTG() { Mnemonic = _T("VTG"); Empty(); }
bool TokenSection::IsOneToken() const { return !Empty() && Begin->next() == End; }
int pop(Stack* stack) { if (Empty(stack)) return INT_MIN; return stack->array[stack->top--]; }
Input::Input() { Empty(); }
CVarDefMap::~CVarDefMap() { Empty(); }
CDoubleZeroString::CDoubleZeroString() : m_buf(NULL) { m_ar.SetSize(0, 16); Empty(); }
CPointerList::~CPointerList() { Empty(); }
CDoubleZeroString::~CDoubleZeroString() { Empty(); }
HDM::~HDM() { Mnemonic.clear(); Empty(); }
const Node& List::front() { if (isEmpty()) throw Empty(); return *head; }
CUPnpNatMappingKey::CUPnpNatMappingKey(void) { Empty(); }
void List::pop_front() { if (isEmpty()) throw Empty(); Node *tmp = head->next; delete head; head = tmp; }
CUT_NNTPArticleList::~CUT_NNTPArticleList() { Empty(); // Clear article list }
PriorityQueue::~PriorityQueue(){ Empty(); }