int _tmain(int argc, TCHAR** argv) //this_program.exe working_dir wow_exe { static HINSTANCE hinstDLL; FILE *log; log = fopen("D:\\log\\main.txt","a+"); hinstDLL = LoadLibrary(TEXT("globalhook_dll.dll")); fprintf(log,"Start hooking!!\r\n"); pFunc set = (pFunc)GetProcAddress(hinstDLL,"SetHook"); pFunc un = (pFunc)GetProcAddress(hinstDLL,"UnHook"); set(); char temp = getchar(); un(); FreeLibrary(hinstDLL); fclose(log); return 0; }
void CClient::endGame( bool closeConnection /*= true*/ ) { //suggest interfaces to finish their stuff (AI should interrupt any bg working threads) for(auto i : playerint) i.second->finish(); // Game is ending // Tell the network thread to reach a stable state if(closeConnection) stopConnection(); logNetwork->infoStream() << "Closed connection."; GH.curInt = nullptr; { boost::unique_lock<boost::recursive_mutex> un(*LOCPLINT->pim); logNetwork->infoStream() << "Ending current game!"; if(GH.topInt()) { GH.topInt()->deactivate(); } GH.listInt.clear(); GH.objsToBlit.clear(); GH.statusbar = nullptr; logNetwork->infoStream() << "Removed GUI."; vstd::clear_pointer(const_cast<CGameInfo*>(CGI)->mh); vstd::clear_pointer(gs); logNetwork->infoStream() << "Deleted mapHandler and gameState."; LOCPLINT = nullptr; } playerint.clear(); battleints.clear(); callbacks.clear(); battleCallbacks.clear(); CGObelisk::reset(); logNetwork->infoStream() << "Deleted playerInts."; logNetwork->infoStream() << "Client stopped."; }
void kruskal() { int i; for(i=0;i<n;i++) parents[i] = -1; int e=0; i=0; while(e < (n-1)) { int x = find(edges[i].u); int y = find(edges[i].v); if(x != y) { ans += (long long int)edges[i].w; //printf("%d %d\n",edges[i].u,edges[i].v); un(x,y); e++; } i++; } }
int main(){ int cas; while(~scanf("%d",&cas)){ while(cas--){ int n;scanf("%d",&n); memset(map1,-1,sizeof(map1)); int tsum=0; init(n); for(int i=0;i<n;i++){ int t1,t2,t3;scanf("%d%d%d",&t1,&t2,&t3); a[t1]=t2; for(int i=0;i<t3;i++){ int u;scanf("%d",&u); map1[t1][u]=1; un(t1,u); } tsum+=t2*t3; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(map1[i][j]==1){ map1[i][j]=a[i]+a[j]; } } } int ans=0; for(int i=0;i<n;i++){ if(fa[i]==i){ // printf("%d %d\n",i,num[i]); ans+=prime(i,num[i]); } } // printf("%d %d\n",ans,tsum); printf("%d\n",tsum-ans); } // break; } return 0; }
MyPluralFormsNode* MyPluralFormsParser::logicalAndExpression() { MyPluralFormsNode* p = equalityExpression(); if (p == NULL) return NULL; MyPluralFormsNodePtr ln(p); // left if (token().type() == MyPluralFormsToken::T_LOGICAL_AND) { MyPluralFormsNodePtr un(new MyPluralFormsNode(token())); // up if (!nextToken()) { return NULL; } p = logicalAndExpression(); if (p == 0) { return NULL; } MyPluralFormsNodePtr rn(p); // right if (rn->token().type() == MyPluralFormsToken::T_LOGICAL_AND) { // transform 1 && (2 && 3) -> (1 && 2) && 3 // u r // l r -> u 3 // 2 3 l 2 un->setNode(0, ln.release()); un->setNode(1, rn->releaseNode(0)); rn->setNode(0, un.release()); return rn.release(); } un->setNode(0, ln.release()); un->setNode(1, rn.release()); return un.release(); } return ln.release(); }
void mexFunction (int nlhs, mxArray *out[], int nrhs, const mxArray *in[]) { // Check to see if we have the correct number of input and output // arguments. if (nrhs != 6) mexErrMsgTxt("Incorrect number of input arguments.\n Correct form is (cost, neigbourhood, interior labels, weight of exterior points, cost of models,threshold)."); if (nlhs != 2) mexErrMsgTxt("Incorrect number of output arguments should be of the form [Binary matrix,interior labels]."); int points = mxGetM(in[0]); int hyp =mxGetN(in[0]); int p2 = mxGetN(in[1]); int maxn = mxGetM(in[1]); double lambda=mxGetPr(in[3])[0]; double* hweight=mxGetPr(in[4]); double thresh=mxGetPr(in[5])[0];; mexPrintf("thresh %f\n",thresh); if((lambda>1)||(lambda<0)){ //clog<<"Lambda: "<<lambda<<endl; mexErrMsgTxt("Lambda must be in [0,1]"); } ////clog<<"hyp "<<hyp<<endl; ////clog<<"points "<<points<<endl; ////clog<<"maxn "<<maxn<<endl; if (points!=p2){ //cout<<"points "<<points<<endl; //cout<<"p2 "<<p2<<endl; mexErrMsgTxt("Matrixs 1 and 2 must be of same length."); } if(maxn>=points) mexErrMsgTxt("Matrix 2 has too many neighbours (no neigh must always be less than points)"); if (points != static_cast<int> (mxGetM(in[2]))){ //cout<<"points "<<points<<endl; //cout<<"mxGetM(in[2]) "<<mxGetM(in[2])<<endl; mexErrMsgTxt("Matrix 1, and vector 3 must be of same length."); } if (mxGetN(in[2])!=1) mexErrMsgTxt("Third element must be a vector."); if (mxGetN(in[3])!=1) mexErrMsgTxt("Fourth element must be a scalar."); if (mxGetM(in[3])!=1) mexErrMsgTxt("Fourth element must be a scalar."); if (mxGetN(in[4])!=1) mexErrMsgTxt("Fifth element must be a vector."); if (static_cast<int>(mxGetM(in[4]))!=hyp) mexErrMsgTxt("Fifth element must be a vector of length hyp."); if (mxGetN(in[5])!=1) mexErrMsgTxt("Sixth element must be a scalar."); if (mxGetM(in[5])!=1) mexErrMsgTxt("Sixth element must be a scalar."); for (int i = 0; i !=hyp; ++i) if (hweight[i]<0) mexErrMsgTxt("hweight[i] must be >= 0"); hypothesis H(points,maxn,hyp,lambda,hweight,0); vector<double>un(points*hyp); double* tmp= mxGetPr(in[0]); H.un=&un[0]; for(unsigned int i=0;i!=points*hyp;++i) if(tmp<0){ mexErrMsgTxt("hweight[i] must be >= 0"); } else un[i]=min(thresh,tmp[i]); for (int i = 0; i !=points;++i){ H.label[i]=mxGetPr(in[2])[i]; if (H.label[i]>=hyp){ mexErrMsgTxt("All labels must be less than number of hypothesis"); } if (H.label[i]<0) mexErrMsgTxt("All labels must be greater than or equal to number 0"); } for (int i = 0; i !=points;++i) for (int j = 0; j !=maxn; ++j){ H.neigh_m[i*maxn+j]=mxGetPr(in[1])[i*maxn+j]-1; if (H.neigh_m[i*maxn+j]>=points) mexErrMsgTxt("neighbours must be less or equal to than number of points"); if (H.neigh_m[i*maxn+j]<-1) mexErrMsgTxt("neighbours must be greater than 0"); if(H.neigh_m[i*maxn+j]==i){ mexPrintf("Matrix 2 %d has a self neighbour in position %d\n",i+1,j+1); mexErrMsgTxt("No self neighbours"); } } H.solve(); out[0]=mxCreateDoubleMatrix(points,hyp,mxREAL); H.annotate((double*)mxGetPr(out[0]),thresh); out[1]=mxCreateDoubleMatrix(points,1,mxREAL); for (int i = 0; i !=points; ++i) mxGetPr(out[1])[i]=H.label[i]; return ; }
char* un(char* m1, char* m2, char* m3, char* m4) { return un(m1, m2, m3, m4, ""); }
char* un(char* m1, char* m2, char* m3) { return un(m1, m2, m3, "", ""); }
// Unite char strings char* un(char* m1, char* m2) { return un(m1, m2, "", "", ""); }
KDModule::KDModule(QWidget *parent, const char *name, const QStringList &) : KCModule(KDMFactory::instance(), parent, name) , minshowuid(0) , maxshowuid(0) , updateOK(false) { KAboutData *about = new KAboutData(I18N_NOOP("kcmkdm"), I18N_NOOP("KDE Login Manager Config Module"), 0, 0, KAboutData::License_GPL, I18N_NOOP("(c) 1996 - 2005 The KDM Authors")); about->addAuthor("Thomas Tanghus", I18N_NOOP("Original author"), "*****@*****.**"); about->addAuthor("Steffen Hansen", 0, "*****@*****.**"); about->addAuthor("Oswald Buddenhagen", I18N_NOOP("Current maintainer"), "*****@*****.**"); setQuickHelp( i18n( "<h1>Login Manager</h1> In this module you can configure the " "various aspects of the KDE Login Manager. This includes " "the look and feel as well as the users that can be " "selected for login. Note that you can only make changes " "if you run the module with superuser rights. If you have not started the KDE " "Control Center with superuser rights (which is absolutely the right thing to " "do, by the way), click on the <em>Modify</em> button to acquire " "superuser rights. You will be asked for the superuser password." "<h2>Appearance</h2> On this tab page, you can configure how " "the Login Manager should look, which language it should use, and which " "GUI style it should use. The language settings made here have no influence on " "the user's language settings." "<h2>Font</h2>Here you can choose the fonts that the Login Manager should use " "for various purposes like greetings and user names. " "<h2>Background</h2>If you want to set a special background for the login " "screen, this is where to do it." "<h2>Shutdown</h2> Here you can specify who is allowed to shutdown/reboot the machine " "and whether a boot manager should be used." "<h2>Users</h2>On this tab page, you can select which users the Login Manager " "will offer you for logging in." "<h2>Convenience</h2> Here you can specify a user to be logged in automatically, " "users not needing to provide a password to log in, and other convenience features.<br>" "Note, that these settings are security holes by their nature, so use them very carefully.")); setAboutData( about ); setlocale( LC_COLLATE, "C" ); KGlobal::locale()->insertCatalogue("kcmbackground"); QStringList sl; QMap<gid_t,QStringList> tgmap; QMap<gid_t,QStringList>::Iterator tgmapi; QMap<gid_t,QStringList>::ConstIterator tgmapci; QMap<QString, QPair<int,QStringList> >::Iterator umapi; struct passwd *ps; for (setpwent(); (ps = getpwent()); ) { QString un( QFile::decodeName( ps->pw_name ) ); if (usermap.find( un ) == usermap.end()) { usermap.insert( un, QPair<int,QStringList>( ps->pw_uid, sl ) ); if ((tgmapi = tgmap.find( ps->pw_gid )) != tgmap.end()) (*tgmapi).append( un ); else tgmap[ps->pw_gid] = un; } } endpwent(); struct group *grp; for (setgrent(); (grp = getgrent()); ) { QString gn( QFile::decodeName( grp->gr_name ) ); bool delme = false; if ((tgmapi = tgmap.find( grp->gr_gid )) != tgmap.end()) { if ((*tgmapi).count() == 1 && (*tgmapi).first() == gn) delme = true; else for (QStringList::ConstIterator it = (*tgmapi).begin(); it != (*tgmapi).end(); ++it) usermap[*it].second.append( gn ); tgmap.remove( tgmapi ); } if (!*grp->gr_mem || (delme && !grp->gr_mem[1] && gn == QFile::decodeName( *grp->gr_mem ))) continue; do { QString un( QFile::decodeName( *grp->gr_mem ) ); if ((umapi = usermap.find( un )) != usermap.end()) { if ((*umapi).second.find( gn ) == (*umapi).second.end()) (*umapi).second.append( gn ); } else kdWarning() << "group '" << gn << "' contains unknown user '" << un << "'" << endl; } while (*++grp->gr_mem); } endgrent(); for (tgmapci = tgmap.begin(); tgmapci != tgmap.end(); ++tgmapci) kdWarning() << "user(s) '" << tgmapci.data().join(",") << "' have unknown GID " << tgmapci.key() << endl; config = new KSimpleConfig( QString::fromLatin1( KDE_CONFDIR "/kdm/kdmrc" )); QVBoxLayout *top = new QVBoxLayout(this); tab = new QTabWidget(this); // ***** // _don't_ add a theme configurator until the theming engine is _really_ done!! // ***** appearance = new KDMAppearanceWidget(this); tab->addTab(appearance, i18n("A&ppearance")); connect(appearance, SIGNAL(changed(bool)), SIGNAL( changed(bool))); font = new KDMFontWidget(this); tab->addTab(font, i18n("&Font")); connect(font, SIGNAL(changed(bool)), SIGNAL(changed(bool))); background = new KBackground(this); tab->addTab(background, i18n("&Background")); connect(background, SIGNAL(changed(bool)), SIGNAL(changed(bool))); sessions = new KDMSessionsWidget(this); tab->addTab(sessions, i18n("&Shutdown")); connect(sessions, SIGNAL(changed(bool)), SIGNAL(changed(bool))); users = new KDMUsersWidget(this, 0); tab->addTab(users, i18n("&Users")); connect(users, SIGNAL(changed(bool)), SIGNAL(changed(bool))); connect(users, SIGNAL(setMinMaxUID(int,int)), SLOT(slotMinMaxUID(int,int))); connect(this, SIGNAL(addUsers(const QMap<QString,int> &)), users, SLOT(slotAddUsers(const QMap<QString,int> &))); connect(this, SIGNAL(delUsers(const QMap<QString,int> &)), users, SLOT(slotDelUsers(const QMap<QString,int> &))); connect(this, SIGNAL(clearUsers()), users, SLOT(slotClearUsers())); convenience = new KDMConvenienceWidget(this, 0); tab->addTab(convenience, i18n("Con&venience")); connect(convenience, SIGNAL(changed(bool)), SIGNAL(changed(bool))); connect(this, SIGNAL(addUsers(const QMap<QString,int> &)), convenience, SLOT(slotAddUsers(const QMap<QString,int> &))); connect(this, SIGNAL(delUsers(const QMap<QString,int> &)), convenience, SLOT(slotDelUsers(const QMap<QString,int> &))); connect(this, SIGNAL(clearUsers()), convenience, SLOT(slotClearUsers())); load(); if (getuid() != 0 || !config->checkConfigFilesWritable( true )) { appearance->makeReadOnly(); font->makeReadOnly(); background->makeReadOnly(); users->makeReadOnly(); sessions->makeReadOnly(); convenience->makeReadOnly(); } top->addWidget(tab); }
void CClient::battleStarted(const BattleInfo * info) { for(auto & battleCb : battleCallbacks) { if(vstd::contains_if(info->sides, [&](const SideInBattle& side) {return side.color == battleCb.first; }) || battleCb.first >= PlayerColor::PLAYER_LIMIT) { battleCb.second->setBattle(info); } } // for(ui8 side : info->sides) // if(battleCallbacks.count(side)) // battleCallbacks[side]->setBattle(info); std::shared_ptr<CPlayerInterface> att, def; auto & leftSide = info->sides[0], & rightSide = info->sides[1]; //If quick combat is not, do not prepare interfaces for battleint if(!settings["adventure"]["quickCombat"].Bool()) { if(vstd::contains(playerint, leftSide.color) && playerint[leftSide.color]->human) att = std::dynamic_pointer_cast<CPlayerInterface>(playerint[leftSide.color]); if(vstd::contains(playerint, rightSide.color) && playerint[rightSide.color]->human) def = std::dynamic_pointer_cast<CPlayerInterface>(playerint[rightSide.color]); } if(!settings["session"]["headless"].Bool()) { Rect battleIntRect((screen->w - 800)/2, (screen->h - 600)/2, 800, 600); if(!!att || !!def) { boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim); GH.pushIntT<CBattleInterface>(leftSide.armyObject, rightSide.armyObject, leftSide.hero, rightSide.hero, battleIntRect, att, def); } else if(settings["session"]["spectate"].Bool() && !settings["session"]["spectate-skip-battle"].Bool()) { //TODO: This certainly need improvement auto spectratorInt = std::dynamic_pointer_cast<CPlayerInterface>(playerint[PlayerColor::SPECTATOR]); spectratorInt->cb->setBattle(info); boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim); GH.pushIntT<CBattleInterface>(leftSide.armyObject, rightSide.armyObject, leftSide.hero, rightSide.hero, battleIntRect, att, def, spectratorInt); } } auto callBattleStart = [&](PlayerColor color, ui8 side) { if(vstd::contains(battleints, color)) battleints[color]->battleStart(leftSide.armyObject, rightSide.armyObject, info->tile, leftSide.hero, rightSide.hero, side); }; callBattleStart(leftSide.color, 0); callBattleStart(rightSide.color, 1); callBattleStart(PlayerColor::UNFLAGGABLE, 1); if(settings["session"]["spectate"].Bool() && !settings["session"]["spectate-skip-battle"].Bool()) callBattleStart(PlayerColor::SPECTATOR, 1); if(info->tacticDistance && vstd::contains(battleints, info->sides[info->tacticsSide].color)) { boost::thread(&CClient::commenceTacticPhaseForInt, this, battleints[info->sides[info->tacticsSide].color]); } }
std::string Condition::getName(bool tip, NameFlags::Value flags, int recursion) const { if (!tip) { return (type < scen.pergame->max_condition_types) ? types[type] : "Unknown!"; } else { std::string stype = std::string(""); std::ostringstream convert; switch (type) { case ConditionType::None: // Let this act like a separator convert << " "; stype.append(convert.str()); break; case ConditionType::BringObjectToArea: convert << get_unit_full_name(object) << " " << object; convert << " is" << areaName(); stype.append(convert.str()); break; case ConditionType::BringObjectToObject: convert << get_unit_full_name(object) << " " << object << " is next to unit " << get_unit_full_name(u_loc) << " " << u_loc; stype.append(convert.str()); break; case ConditionType::OwnObjects: case ConditionType::OwnFewerObjects: case ConditionType::ObjectsInArea: { // we define some variables in this block, therefore need scope as we are also in a case if (valid_player()) { convert << playerPronoun(player) << " has "; } switch (type) { case ConditionType::OwnObjects: case ConditionType::ObjectsInArea: if (amount == 0) { convert << "any number of"; } else { convert << "at least " << amount; } break; case ConditionType::OwnFewerObjects: if (amount == 0) { convert << "no"; } else { convert << "at most " << amount; } break; } if (valid_unit_spec()) { std::string un(wstringToString(pUnit->name())); if (amount > 1 && !un.empty() && *un.rbegin() != 's' && !replaced(un, "man", "men")) { convert << " " << un << "s"; } else { convert << " " << un; } } else { if (amount != 1) { convert << " units"; } else { convert << " unit"; } } convert << areaName(); stype.append(convert.str()); } break; case ConditionType::DestroyObject: convert << get_unit_full_name(object) << " is killed"; stype.append(convert.str()); break; case ConditionType::CaptureObject: convert << playerPronoun(player) << " captured " << get_unit_full_name(object); stype.append(convert.str()); break; case ConditionType::AccumulateAttribute: switch (res_type) { case 0: // Food accumulated convert << playerPronoun(player) << " has " << amount << " food"; break; case 1: // Wood accumulated convert << playerPronoun(player) << " has " << amount << " wood"; break; case 2: // Stone accumulated convert << playerPronoun(player) << " has " << amount << " stone"; break; case 3: // Gold accumulated convert << playerPronoun(player) << " has " << amount << " gold"; break; case 20: // Units killed if (amount == 1) { convert << playerPronoun(player) << " kills a unit"; } else { convert << playerPronoun(player) << " has killed " << amount << " units"; } break; case 44: // Kill ratio if (amount == 0) { convert << playerPronoun(player) << " has equal kills and deaths"; } else if (amount == 1) { convert << playerPronoun(player) << " has killed one more than lost"; } else if (amount > 0) { convert << playerPronoun(player) << " has " << amount << " more kills than deaths"; } else if (amount == -1) { convert << playerPronoun(player) << " has lost one more unit than has killed"; } else { convert << playerPronoun(player) << " has " << -amount << " more deaths than kills"; } break; default: //convert << types_short[type]; if (res_type >= 0) { const Link * list = esdata.resources.head(); for (int i=0; list; list = list->next(), i++) { if (i == res_type) { std::wstring resname(list->name()); convert << playerPronoun(player) << "'s "; convert << std::string( resname.begin(), resname.end()); convert << " >= " << amount; break; } } } break; } stype.append(convert.str()); break; case ConditionType::ResearchTehcnology: if (valid_technology_spec()) { convert << playerPronoun(player) << " has tech "; std::wstring techname(pTech->name()); convert << std::string( techname.begin(), techname.end()); convert << " researched"; } else { convert << "INVALID"; } stype.append(convert.str()); break; case ConditionType::ResearchingTechnology: if (pTech && pTech->id()) { convert << playerPronoun(player) << " is researching "; std::wstring techname(pTech->name()); convert << std::string( techname.begin(), techname.end()); } else { convert << "INVALID"; } stype.append(convert.str()); break; case ConditionType::Timer: convert << time_string(timer) << " has passed"; stype.append(convert.str()); break; case ConditionType::ObjectSelected: convert << "selected unit " << object; convert << " (" << get_unit_full_name(object) << ")"; stype.append(convert.str()); break; case ConditionType::AISignal: switch (ai_signal) { case -1034: convert << "singleplayer / cheats enabled"; break; case -1036: convert << "starting resources set to standard"; break; case -1039: convert << "regicide"; break; case -1040: convert << "deathmatch"; break; case -70850: convert << "one-click garrison"; break; default: if (ai_signal >= -518 && ai_signal <= -7) { int signal = ai_signal + 518; int taunt_player = signal / 64; int taunt_set_id = signal % 64; convert << "player " << taunt_player + 1 << " taunted " << taunt_set[taunt_set_id]; } else if (ai_signal >= -774 && ai_signal <= -519) { convert << "AI goal " << ai_signal + 774 << " achieved"; } else { convert << "AI signalled " << ai_signal; } } stype.append(convert.str()); break; case ConditionType::ObjectVisible: convert << "unit " << object; convert << " (" << get_unit_full_name(object) << ") is visible"; stype.append(convert.str()); break; case ConditionType::PlayerDefeated: if (player == 0) { convert << "Gaia"; } else { convert << playerPronoun(player); } convert << " is defeated"; stype.append(convert.str()); break; case ConditionType::ObjectHasTarget: convert << "unit " << object << " (" << get_unit_full_name(object) << ") is targetting"; if (null_location_unit()) { convert << " something"; } else { convert << " " << u_loc << " (" << get_unit_full_name(u_loc) << ")"; } stype.append(convert.str()); break; case ConditionType::UnitsGarrisoned: if (amount == 1) { convert << "unit " << object << " (" << get_unit_full_name(object) << ") has " << amount << " units garrisoned"; } else { convert << "unit " << object << " (" << get_unit_full_name(object) << ") has one unit garrisoned"; } stype.append(convert.str()); break; case ConditionType::DifficultyLevel: convert << "difficulty is "; switch (amount) { case DifficultyLevel::Hardest: convert << "Hardest"; break; case DifficultyLevel::Hard: convert << "Hard"; break; case DifficultyLevel::Moderate: convert << "Moderate"; break; case DifficultyLevel::Standard: convert << "Standard"; break; case DifficultyLevel::Easiest: convert << "Easiest"; break; } stype.append(convert.str()); break; case ConditionType::UnitsQueuedPastPopCap_SWGB: if (valid_player()) { convert << playerPronoun(player) << " has " << amount << " units queued past the pop cap"; } else { convert << "INVALID"; } stype.append(convert.str()); break; case ConditionType::OwnFewerFoundations_SWGB: // Chance_HD: switch (scen.game) { case AOHD: case AOF: case AOHD4: case AOF4: case AOHD6: case AOF6: convert << amount << "% chance "; stype.append(convert.str()); break; case SWGB: case SWGBCC: if (valid_player()) { convert << playerPronoun(player) << " has "; } if (amount == 0) { convert << "no"; } else { convert << "at most " << amount; } if (valid_unit_spec()) { std::string un(wstringToString(pUnit->name())); if (amount > 1 && !un.empty() && *un.rbegin() != 's' && !replaced(un, "man", "men")) { convert << " " << un << " foundations"; } else { convert << " " << un << " foundation"; } } else { if (amount != 1) { convert << " foundations"; } else { convert << " foundation"; } } convert << areaName(); stype.append(convert.str()); break; default: convert << amount << "UNKNOWN CONDITION"; stype.append(convert.str()); } break; default: stype.append((type < scen.pergame->max_condition_types) ? types_short[type] : "Unknown!"); } return flags&NameFlags::LIMITLEN?stype.substr(0,MAX_CHARS):stype; } }
/** * Loaded tables are registered for processing events. * * \param[in] pEd inotify event dispatcher * * \throw InotifyException thrown if base table directory cannot be read */ void load_tables(EventDispatcher* pEd) throw (InotifyException) { // WARNING - this function has not been optimized!!! std::string s; if (!IncronCfg::GetValue("system_table_dir", s)) throw InotifyException("configuration system is corrupted", EINVAL); DIR* d = opendir(s.c_str()); if (d != NULL) { syslog(LOG_NOTICE, "loading system tables"); struct dirent* pDe = NULL; while ((pDe = readdir(d)) != NULL) { std::string un(pDe->d_name); std::string path(IncronCfg::BuildPath(s, pDe->d_name)); bool ok = pDe->d_type == DT_REG; if (pDe->d_type == DT_UNKNOWN) { struct stat st; if (stat(path.c_str(), &st) == 0) ok = S_ISREG(st.st_mode); } if (ok) { syslog(LOG_INFO, "loading table %s", pDe->d_name); UserTable* pUt = new UserTable(pEd, un, true); g_ut.insert(SUT_MAP::value_type(path, pUt)); pUt->Load(); } } closedir(d); } else { syslog(LOG_WARNING, "cannot open system table directory (ignoring)"); } if (!IncronCfg::GetValue("user_table_dir", s)) throw InotifyException("configuration system is corrupted", EINVAL); d = opendir(s.c_str()); if (d == NULL) throw InotifyException("cannot open user table directory", errno); syslog(LOG_NOTICE, "loading user tables"); struct dirent* pDe = NULL; while ((pDe = readdir(d)) != NULL) { std::string un(pDe->d_name); std::string path(IncronCfg::BuildPath(s, pDe->d_name)); bool ok = pDe->d_type == DT_REG; if (pDe->d_type == DT_UNKNOWN) { struct stat st; if (stat(path.c_str(), &st) == 0) ok = S_ISREG(st.st_mode); } if (ok) { if (UserTable::CheckUser(pDe->d_name)) { syslog(LOG_INFO, "loading table for user %s", pDe->d_name); UserTable* pUt = new UserTable(pEd, un, false); g_ut.insert(SUT_MAP::value_type(path, pUt)); pUt->Load(); } else { syslog(LOG_WARNING, "table for invalid user %s found (ignored)", pDe->d_name); } } } closedir(d); }
I rk(I f,A r,A a,A w) { A z=0,*p=0; if(w)ND2 else ND1; { XA; C *pp=0,*ap,*wp; I wt=0,wr=0,wn=0,*wd=0; I n=0,t=0,i,j,k,d[9],rw,ra,ri,ir,iw=0,ia=0,ii=0, e=!w&&f==MP(9),h=QP(f)&&f!=MP(71)&&!e; Q(!QA(r),9); Q(r->t,6); Q(r->n<1||r->n>3,8); ar-=ra=raw(ar,*r->p); if(!w) mv(d,ad,ra),ir=tr(ra,ad),ad+=ra; else { wt=w->t,wr=w->r,wd=w->d; wr-=rw=raw(wr,r->p[r->n>1]),ri=r->n>2?r->p[2]:9; Q(ri<0,9); if(ri>ra)ri=ra; if(ri>rw)ri=rw; mv(d,ad,ra-=ri); ia=tr(ra,ad),mv(d+ra,wd,rw),iw=tr(rw-=ri,wd); Q(cm(ad+=ra,wd+=rw,ri),11); ii=tr(ri,ad),ra+=rw+ri,ir=ia*iw*ii,wn=tr(wr,wd+=ri),ad+=ri; if(h&&ir>iw&&(f==MP(21)||f==MP(25)||f==MP(26)||f==MP(32)||f==MP(33))) h=0; } an=tr(ar,ad); if(h) { g=0; aw_c[0]=a->c; aw_c[1]=w&&w->c; r=(A)fa(f,gC(at,ar,an,ad,a->n?a->p:0),w?gC(wt,wr,wn,wd,w->n?w->p:0):0); aw_c[0]=aw_c[1]=1; if(!r)R 0; r=un(&r); mv(d+ra,r->d,j=r->r); if((j+=ra)>MAXR)R q=13,(I)r; n=r->n;t=r->t; if(ir<2) R mv(r->d,d,r->r=j),r->n*=ir,(I)r; dc(r); if(g==(I (*)())rsh) R rsh(w?w:a,j,d); if(!g){h=0;} else { if(at=atOnExit,w) wt=wtOnExit; if(at!=a->t&&!(a=at?ep_cf(1):ci(1))) R 0; if(w&&wt!=w->t&&!(w=wt?ep_cf(2):ci(2))) R 0; OF(i,ir,n); W(ga(t,j,i,d)); pp=(C*)z->p; } } if(!h) { W(ga(Et,ra,ir,d)); *--Y=zr(z),p=(A*)z->p; } if(!w) { for(ap=(C*)a->p;ir--;ap+=Tt(at,an)) if(h) (*(I(*)(C*,C*,I))g)(pp,ap,an),pp+=Tt(t,n); else a=gc(at,ar,an,ad,(I*)ap),*p++=e?a:(A)fa(f,(I)a,0); } else { for(i=0;i<ia;++i)for(j=0;j<iw;++j) for(k=0;k<ii;++k){ ap=(C*)a->p+Tt(at,(i*ii+k)*an); wp=(C*)w->p+Tt(wt,(j*ii+k)*wn); if(h) { (*(I(*)(C*,C*,C*,I))g)(pp,ap,wp,n),pp+=Tt(t,n); if(q==1)*--Y=(I)z,aplus_err(q,(A)Y[1]),++Y; } else { *p++=(A)fa(f,(I)gc(at,ar,an,ad,(I*)ap),(I)gc(wt,wr,wn,wd,(I*)wp)); } } } if(h)R(I)z; if(!e)z=(A)dis(r=z),dc(r); R ++Y,(I)z; } }
int process(const char* filename,const char* config_file ,int evtNum) { Unpacker2 un(filename,config_file ,evtNum); T->Process("analyze_trb3.C"); TBrowser browser; }