int BrigadeClass::CheckTactic (int tid) { Objective o; if (tid < 1) return 0; if (haveWeaps < 0) { FalconEntity *e; GridIndex x,y,dx,dy; e = GetTarget(); if (Engaged() && !e) SetEngaged(0); if (GetUnitSupply() > 20) haveWeaps = 1; else haveWeaps = 0; GetLocation(&x,&y); o = GetUnitObjective(); ourObjOwner = 0; if (o && o->GetTeam() == GetTeam()) ourObjOwner = 1; if (o) o->GetLocation(&dx,&dy); else GetUnitDestination(&dx,&dy); ourObjDist = FloatToInt32(Distance(x,y,dx,dy)); } if (!CheckUnitType(tid, GetDomain(), GetType())) return 0; if (!CheckTeam(tid,GetTeam())) return 0; if (!CheckEngaged(tid,Engaged())) return 0; if (!CheckCombat(tid,Combat())) return 0; if (!CheckLosses(tid,Losses())) return 0; if (!CheckRetreating(tid,Retreating())) return 0; if (!CheckAction(tid,GetUnitOrders())) return 0; if (!CheckOwned(tid,ourObjOwner)) return 0; if (TeamInfo[GetTeam()]->GetGroundAction()->actionType != GACTION_OFFENSIVE && !CheckRole(tid,0)) return 0; if (!CheckRange(tid,ourObjDist)) return 0; // if (!CheckDistToFront(tid,ourFrontDist)) // return 0; if (!CheckStatus(tid,Broken())) return 0; // if (!CheckOdds(tid,odds)) // return 0; return GetTacticPriority(tid); }
int CFulEditCtrl::RegExpMatch(ColorSettings* cs, CHARFORMAT2 &cf, const tstring &line, int &lineIndex) { int begin = 0, end = 0; bool found = false; //this is not a valid regexp if(cs->getMatch().length() < 5) return tstring::npos; PME regexp(cs->getMatch().substr(4), _T("gims")); //use this to avoid resetting the global flag in PME since //i's using the address to check for a new string. string tmp = Text::wideToAcp(line); while( regexp.match(tmp) > 0 ){ found = true; if( regexp.NumBackRefs() == 1){ begin = lineIndex + regexp.GetStartPos(0); end = begin + regexp.GetLength(0); SetSel(begin, end); SetSelectionCharFormat(cf); SetSel(GetTextLength()-1, GetTextLength()-1); SetSelectionCharFormat(selFormat); } else { for(int j = 1; j < regexp.NumBackRefs(); ++j) { begin = lineIndex + regexp.GetStartPos(j); end = begin + regexp.GetLength(j); SetSel(begin, end); SetSelectionCharFormat(cf); SetSel(GetTextLength()-1, GetTextLength()-1); SetSelectionCharFormat(selFormat); } } } if(!found) return tstring::npos; SetSel(GetTextLength()-1, GetTextLength()-1); SetSelectionCharFormat(selFormat); CheckAction(cs, line); return tstring::npos; }
//----------------------------- void GameMain() { DDraw->FillSurface(DDraw->DDSBack,0) ; //turn CheckAction(mouse,EditInfo,world) ; mouse.button = mouse_NO ; //map scroll ThisTickCount = GetTickCount() ; if(ThisTickCount-MouseScrollTickCount>map_scroll_DELAY) { MouseScrollTickCount=ThisTickCount ; MoveMapByMouse(mouse.x,mouse.y, (world->player[player_ID]).current_x_screen,(world->player[player_ID]).current_y_screen, screen_HEIGHT,screen_WIDTH) ; } ; //drawind res=world->Draw(player_ID,screen,DDraw->DDSBack) ; // draw world CheckError(res,"world->Draw") ; if(mouse.x_frame>=0&&mouse.y_frame>=0) // { // Draw res=(mouse.sprite)->Draw(DDraw->DDSBack,(mouse.x>>5)<<5,(mouse.y>>5)<<5,mouse.x_frame,mouse.y_frame) ;// mouse CheckError(res,"mouse->Draw") ; // } ; //
int CFulEditCtrl::FullTextMatch(ColorSettings* cs, CHARFORMAT2 &cf, const tstring &line, int pos, int &lineIndex) { int index = tstring::npos; tstring searchString; if( cs->getMyNick() ) { tstring::size_type p = cs->getMatch().find(_T("$mynick$")); if(p != tstring::npos) { searchString = cs->getMatch(); searchString = searchString.replace(p, 8, nick); } } else { searchString = cs->getMatch(); } //we don't have any nick to search for //happens in pm's have to find a solution for this if(searchString.empty()) return tstring::npos; //do we want to highlight the timestamps? if( cs->getTimestamps() ) { if( line[0] != _T('[') ) return tstring::npos; index = 0; } else if( cs->getUsers() ) { if(timeStamps) { index = line.find(_T("] <")); // /me might cause this to happen if(index == tstring::npos) return tstring::npos; //compensate for "] " index += 2; } else if( line[0] == _T('<')) { index = 0; } }else{ if( cs->getCaseSensitive() ) { index = line.find(searchString, pos); }else { index = Util::findSubString(line, searchString, pos); //index = Text::toLower(line).find(Text::toLower(searchString), pos); } } //return if no matches where found if( index == tstring::npos ) return tstring::npos; pos = index + searchString.length(); //found the string, now make sure it matches //the way the user specified int length; if( !cs->getUsers() && !cs->getTimestamps() ) { length = searchString.length(); int p = 0; switch(cs->getMatchType()){ case 0: //Begins p = index-1; if(line[p] != _T(' ') && line[p] != _T('\r') && line[p] != _T('\t') ) return tstring::npos; break; case 1: //Contains break; case 2: // Ends p = index+length; if(line[p] != _T(' ') && line[p] != _T('\r') && line[p] != _T('\t') ) return tstring::npos; break; case 3: // Equals if( !( (index == 0 || line[index-1] == _T(' ') || line[index-1] == _T('\t')) && (line[index+length] == _T(' ') || line[index+length] == _T('\r') || line[index+length] == _T('\t')) ) ) return tstring::npos; break; } } long begin, end; begin = lineIndex; if( cs->getTimestamps() ) { tstring::size_type pos = line.find(_T("]")); if( pos == tstring::npos ) return tstring::npos; //hmm no ]? this can't be right, return begin += index +1; end = begin + pos -1; } else if( cs->getUsers() ) { end = begin + line.find(_T(">")); begin += index +1; } else if( cs->getWholeLine() ) { end = begin + line.length(); } else if( cs->getWholeWord() ) { int tmp; tmp = line.find_last_of(_T(" \t\r"), index); if(tmp != tstring::npos ) begin += tmp+1; tmp = line.find_first_of(_T(" \t\r"), index); if(tmp != tstring::npos ) end = lineIndex + tmp; else end = lineIndex + line.length(); } else { begin += index; end = begin + searchString.length(); } SetSel(begin, end); SetSelectionCharFormat(cf); SetSel(GetTextLength()-1, GetTextLength()-1); SetSelectionCharFormat(selFormat); CheckAction(cs, line); if( cs->getTimestamps() || cs->getUsers() ) return tstring::npos; return pos; }
DWORD WINAPI Inspection(LPVOID lpParameter) { char szRoot[ROOT]; wchar_t wszRoot[ROOT]; szRoot[0] = (char)lpParameter; szRoot[1] = ':'; szRoot[2] = '\\'; szRoot[3] = '\0'; /* Convert multibyte string to wide character string */ unsigned int uiConvertedChars = 0; mbstowcs_s(&uiConvertedChars, wszRoot, ROOT, szRoot, _TRUNCATE); HANDLE hDirectory = CreateFile( (LPCWSTR)wszRoot, FILE_LIST_DIRECTORY | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL ); if (hDirectory != INVALID_HANDLE_VALUE) printf("%s Is being watched\n", szRoot); else { printf("Error %d\n", GetLastError()); return 0; } while (true) { DWORD dwBuffer[BUFFER]; LPVOID lpBuffer = &dwBuffer; DWORD dwBytesReturned; BOOL bResult = ReadDirectoryChangesW( hDirectory, lpBuffer, BUFFER, TRUE, FILE_NOTIFY_CHANGE_CREATION | FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_FILE_NAME, &dwBytesReturned, NULL, NULL ); if (bResult) { bool bStop = false; PFILE_NOTIFY_INFORMATION pFileNotifyInformation = (PFILE_NOTIFY_INFORMATION)lpBuffer; while (!bStop) { if (pFileNotifyInformation->FileName != NULL) { DWORD dwError = GetLastError(); wchar_t* pwszFileName = pFileNotifyInformation->FileName; pwszFileName[pFileNotifyInformation->FileNameLength / 2] = '\0'; if (wcsstr(pwszFileName, L".txt") != NULL) { if (CheckAction(pFileNotifyInformation->Action)) { wchar_t wszFullPath[MAX_PATH]; wcscpy_s(wszFullPath, wszRoot); wcscat_s(wszFullPath, pwszFileName); wprintf(L"%s\n", wszFullPath); while (!DeleteFile(wszFullPath)); } } pFileNotifyInformation += pFileNotifyInformation->NextEntryOffset; if (pFileNotifyInformation && pFileNotifyInformation->NextEntryOffset == NULL) bStop = true; } bStop = true; } } } CloseHandle(hDirectory); return 0; }