bool loadSettings(char* pFile) { CStringList settings; if (!settings.load(pFile)) return false; for (int i = 0; i < settingList.count(); i++) { delete (SettingKey *)settingList[i]; i--; } settingList.clear(); for (int i = 0; i < settings.count(); i++) { if (settings[i][0] == '#' || settings[i][0] == '\'') continue; SettingKey *key = new SettingKey(); key->name = settings[i].copy(0, settings[i].find('=')).trim(); key->value = settings[i].copy(settings[i].find('=') + 1).trim(); } /* ARRAY Server-Options */ globalGuildList.load(findKey("allowedglobalguilds"), ","); cheatwindows.load(findKey("cheatwindows"), ","); jailLevels.load(findKey("jaillevels"), ","); mapNames.load(findKey("maps"), ","); profileList.load(findKey("profilevars", "Kills:=playerkills,Deaths:=playerdeaths,Maxpower:=playerfullhearts,Rating:=playerrating,Alignment:=playerap,Gralat:=playerrupees,Swordpower:=playerswordpower,Spin Attack:=canspin"), ","); staffGuilds.load(findKey("staffguilds", "Server,Manager,Owner,Admin,FAQ,LAT,NAT,GAT,GP,GP Chief,Bugs Admin,NPC Admin,Gani Team,GFX Admin,Events Team,Events Admin,Guild Admin"), ","); staffList.load(findKey("staff"), ","); statusList.load(findKey("playerlisticons", "Online,Away,DND"), ","); /* BOOL Server-Options */ apSystem = CHECK_BOOL(findKey("apsystem", "true")); baddyDropItems = CHECK_BOOL(findKey("baddyitems", "false")); bushesDrop = CHECK_BOOL(findKey("bushitems", "true")); cheatwindowsban = CHECK_BOOL(findKey("cheatwindowsban", "false")); clientsidePushPull = CHECK_BOOL(findKey("clientsidepushpull", "true")); defaultweapons = CHECK_BOOL(findKey("defaultweapons", "true")); detailedconsole = CHECK_BOOL(findKey("detailedconsole", "false")); dontaddserverflags = CHECK_BOOL(findKey("dontaddserverflags", "false")); dontchangekills = CHECK_BOOL(findKey("dontchangekills", "false")); dropItemsDead = CHECK_BOOL(findKey("dropitemsdead", "true")); globalGuilds = CHECK_BOOL(findKey("globalguilds", "true")); healswords = CHECK_BOOL(findKey("healswords", "false")); idleDisconnect = CHECK_BOOL(findKey("disconnectifnotmoved", "true")); noExplosions = CHECK_BOOL(findKey("noexplosions", "false")); noFoldersConfig = CHECK_BOOL(findKey("nofoldersconfig", "false")); putnpcenabled = CHECK_BOOL(findKey("putnpcenabled", "true")); adminCanChangeGralat = CHECK_BOOL(findKey("normaladminscanchangegralats", "true")); setbodyallowed = CHECK_BOOL(findKey("setbodyallowed", "true")); setheadallowed = CHECK_BOOL(findKey("setheadallowed", "true")); setswordallowed = CHECK_BOOL(findKey("setswordallowed", "true")); setshieldallowed = CHECK_BOOL(findKey("setshieldallowed", "true")); showConsolePackets = CHECK_BOOL(findKey("showconsolepackets", "false")); staffOnly = CHECK_BOOL(findKey("onlystaff", "false")); underconstruction = CHECK_BOOL(findKey("underconstruction", "false")); vasesDrop = CHECK_BOOL(findKey("vasesdrop", "true")); warptoforall = CHECK_BOOL(findKey("warptoforall", "false")); /* INT Server-Options */ aptime[0] = atoi(findKey("aptime0", "30")); aptime[1] = atoi(findKey("aptime1", "90")); aptime[2] = atoi(findKey("aptime2", "300")); aptime[3] = atoi(findKey("aptime3", "600")); aptime[4] = atoi(findKey("aptime4", "1200")); baddyRespawn = atoi(findKey("baddyrespawntime")); cheatwindowstime = atoi(findKey("cheatwindowstime", "60")); heartLimit = atoi(findKey("heartlimit", "20")); horseLife = atoi(findKey("horselifetime")); listServerFields[3] = toString(GSERVER_BUILD); listServerPort = atoi(findKey("listport", "14900")); maxNoMovement = atoi(findKey("maxnomovement", "1200")); maxPlayers = atoi(findKey("maxplayers", "128")); mindeathgralats = atoi(findKey("mindeathgralats","1")); maxdeathgralats = atoi(findKey("maxdeathgralats","50")); serverPort = atoi(findKey("serverport", "14802")); shieldLimit = atoi(findKey("shieldlimit", "3")); swordLimit = CLIP(atoi(findKey("swordlimit", "4")), -25, 25); tiledroprate = CLIP(atoi(findKey("tiledroprate", "50")), 0, 100); tileRespawn = atoi(findKey("respawntime")); unstickmeX = (float)atof(findKey("unstickmex", "30")); unstickmeY = (float)atof(findKey("unstickmey", "30.5")); /* TEXT Server-Options */ unstickmeLevel = findKey("unstickmelevel", "onlinestartlocal.nw"); listServerIp = findKey("listip", "listserver.graal.in"); listServerFields[0] = findKey("name", "My Server"); listServerFields[1] = findKey("description", "My Server"); listServerFields[2] = findKey("language", "English"); listServerFields[4] = findKey("url", "http://www.graal.in"); listServerFields[5] = findKey("myip", "AUTO"); shareFolder = findKey("sharefolder"); staffHead = findKey("staffhead", "head25.png"); worldName = findKey("worldname", "main"); // If the server is flagged as under construction, prepend the // Under Construction value to the name. if ( underconstruction && !listServerFields[0].match( "U *" ) ) listServerFields[0] = CBuffer() << "U " << listServerFields[0]; /* Load Maps */ for(int i = 0; i < CMap::mapList.count(); i++) delete((CMap*)CMap::mapList[i]); CMap::mapList.clear(); for(int i = 0; i < mapNames.count(); i++) CMap::openMap(mapNames[i].trim()); // Now fix all the levels. for ( int i = 0; i < levelList.count(); ++i ) { CLevel* level = (CLevel*)levelList[i]; //Find our map id level->map = 0; for ( int j = 0; j < CMap::mapList.count(); ++j ) { CMap* m = (CMap*)CMap::mapList[j]; if ( (level->levelIndex = m->getLevelpos(level->fileName)) >= 0 ) { level->map = m; break; } } } return true; }
//tag should be lowercase BOOL CSimpleSAH::GetNextTags(CStringList& astrTagNames) { int i, j, k; BOOL found = FALSE; CString tagp; long len = strHTML.GetLength(); try{ while(!found) { if(!strCurTagBuf.IsEmpty()) { if(m_bUpdate) file.WriteString(strCurTagBuf); } i = strHTML.Find('<', nStartPoint); if(i<0) { //end of file if(m_bUpdate) { file.Write(strHTML.GetBuffer(8) + nStartPoint, len - nStartPoint); strHTML.ReleaseBuffer(); } return FALSE; } else { if(m_bUpdate) { file.Write(strHTML.GetBuffer(8) + nStartPoint, i - nStartPoint); strHTML.ReleaseBuffer(); } } if(strHTML.Mid(i+1, 2) == "!-") //is comment { j = strHTML.Find("-->", i); if(j<0) { //not a real comment, just some text if(m_bUpdate) { file.Write(strHTML.GetBuffer(8) + i, 3); strHTML.ReleaseBuffer(); } nStartPoint = i + 3; } else { //is comment, output it if(m_bUpdate) { file.Write(strHTML.GetBuffer(8) + i, j - i+3); strHTML.ReleaseBuffer(); } nStartPoint = j + 3; } strCurTagBuf.Empty(); } else { j = strHTML.Find('>', i); k = strHTML.Find('<', i); if(j<0) { //end of file if(m_bUpdate) { file.Write(strHTML.GetBuffer(8) + i, len - i); strHTML.ReleaseBuffer(); } return FALSE; } if(j>k) { //output if(m_bUpdate) { file.Write(strHTML.GetBuffer(8) + i, k-i); strHTML.ReleaseBuffer(); } i = k; } strCurTagBuf = strHTML.Mid(i, j-i+1); nStartPoint = j+1; //if is the needed tag k=strCurTagBuf.FindOneOf(" >\r\n"); if(k>0) tagp = strCurTagBuf.Mid(1, k-1); else tagp = strCurTagBuf.Mid(1, strCurTagBuf.GetLength()-2); tagp.MakeLower(); if(astrTagNames.Find(tagp)) { //find the tag; found = TRUE; } } } }catch(...) { } return found; }
//************************************************************************************************* BOOL CBCGPMousePage::OnInitDialog() { ASSERT (g_pMouseManager != NULL); CPropertyPage::OnInitDialog(); CStringList listOfViewNames; g_pMouseManager->GetViewNames (listOfViewNames); //------------------- // Create image list: //------------------- if (!m_ViewsImages.Create ( globalData.m_sizeSmallIcon.cx, globalData.m_sizeSmallIcon.cy, ILC_COLOR | ILC_MASK, (int) listOfViewNames.GetCount (), 1)) { ASSERT (FALSE); } m_wndListOfViews.SetImageList (&m_ViewsImages, LVSIL_SMALL); POSITION pos; //----------------- // Fill views list: //----------------- CRect rect; m_wndListOfViews.GetClientRect (&rect); m_wndListOfViews.InsertColumn (0, _T(""), LVCFMT_LEFT, rect.Width () - 1); ASSERT (!listOfViewNames.IsEmpty ()); int iMaxWidth = 0; for (pos = listOfViewNames.GetHeadPosition (); pos != NULL;) { CString strViewName = listOfViewNames.GetNext (pos); int iImageIndex = -1; //--------------- // Add view icon: //--------------- UINT uiViewIconId = g_pMouseManager->GetViewIconId ( g_pMouseManager->GetViewIdByName (strViewName)); HICON hViewIcon; if (uiViewIconId != 0 && (hViewIcon = AfxGetApp ()->LoadIcon (uiViewIconId)) != NULL) { iImageIndex = m_ViewsImages.Add (hViewIcon); ::DestroyIcon (hViewIcon); } int iIndex = m_wndListOfViews.GetItemCount (); for (int i = 0; i < m_wndListOfViews.GetItemCount (); i ++) { CString strText = m_wndListOfViews.GetItemText (i, 0); if (strText > strViewName) { iIndex = i; break; } } m_wndListOfViews.InsertItem (iIndex, strViewName, iImageIndex); m_wndListOfViews.SetItemData (iIndex, (DWORD) g_pMouseManager->GetViewIdByName (strViewName)); int iStrWidth = m_wndListOfViews.GetStringWidth (strViewName); iMaxWidth = max (iStrWidth, iMaxWidth); } //---------------------------------- // Add icon width pluse some pixels: //---------------------------------- IMAGEINFO info; m_ViewsImages.GetImageInfo (0, &info); CRect rectImage = info.rcImage; iMaxWidth += rectImage.Width () + 10; m_wndListOfViews.SetColumnWidth (0, iMaxWidth); //-------------------- // Fill commands list: //-------------------- CBCGPToolbarCustomize* pWndParent = DYNAMIC_DOWNCAST (CBCGPToolbarCustomize, GetParent ()); ASSERT (pWndParent != NULL); pWndParent->FillAllCommandsList (m_wndListOfCommands); //----------------------- // Select the first view: //----------------------- m_wndListOfViews.SetItemState (0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); m_wndListOfViews.EnsureVisible (0, FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL CBCGPODBCGridCtrl::GetTableList (CStringList& lstTable) { lstTable.RemoveAll (); if (m_pDataBase == NULL) { ASSERT (FALSE); return FALSE; } ASSERT_VALID (m_pDataBase); try { if (!m_pDataBase->IsOpen ()) { ASSERT (FALSE); return FALSE; } HSTMT hStmt; SQLRETURN rc = ::SQLAllocStmt(m_pDataBase->m_hdbc, &hStmt); if (!m_pDataBase->Check (rc)) { return FALSE; } #if _MSC_VER >= 1300 #ifdef UNICODE #define __BCGP_SQLCHAR SQLWCHAR #else #define __BCGP_SQLCHAR SQLCHAR #endif #else #define __BCGP_SQLCHAR SQLCHAR #endif rc = ::SQLTables (hStmt, NULL,SQL_NTS, NULL,SQL_NTS, NULL,SQL_NTS, (__BCGP_SQLCHAR*) _T("'TABLE'"), SQL_NTS); if (!m_pDataBase->Check (rc)) { AfxThrowDBException (rc, m_pDataBase, hStmt); } while ((rc = ::SQLFetch (hStmt)) != SQL_NO_DATA_FOUND) { if (!m_pDataBase->Check (rc)) { AfxThrowDBException (rc, m_pDataBase, hStmt); } UCHAR szName [256]; #if _MSC_VER < 1300 SDWORD cbName; #else SQLLEN cbName; #endif rc = ::SQLGetData (hStmt, 3, SQL_C_CHAR, szName, 256, &cbName); if (!m_pDataBase->Check (rc)) { AfxThrowDBException (rc, m_pDataBase, hStmt); } #ifdef _UNICODE lstTable.AddTail(CString(szName)); #else lstTable.AddTail ((LPCTSTR)szName); #endif } ::SQLFreeStmt (hStmt, SQL_CLOSE); } catch (CDBException* pEx) { OnODBCException (pEx); pEx->Delete (); return FALSE; } return TRUE; }
void ListServer_Main() { static CBuffer packetBuffer; CStringList lines; if ( listServerFields[5] == "localhost" ) return; if (!lsConnected) return; // Read any new data into the socket. if ( listServer.getData() == -1 ) { errorOut( "serverlog.txt", "Disconnected from list server." ); lsConnected = false; return; } // Grab all the data from the socket buffer. packetBuffer << listServer.getBuffer(); listServer.getBuffer().clear(); // Search for a packet. If none is found, break out of the loop. while (packetBuffer.length() != 0) { CPacket line; if (!nextIsRaw) { int lineEnd = packetBuffer.find( '\n' ); if ( lineEnd == -1 ) return; // Copy the packet out and remove the \n line = packetBuffer.copy( 0, lineEnd + 1 ); packetBuffer.remove(0, line.length()); line.remove(line.length() - 1, 1); } else { if (packetBuffer.length() < rawPacketSize) return; line.writeBytes(packetBuffer.readChars(rawPacketSize), rawPacketSize); packetBuffer.remove(0, line.length()); line.remove(line.length() - 1, 1); nextIsRaw = false; } packetBuffer.setRead(0); int messageId = line.readByte1(); switch (messageId) { case GSVOLD: { printf("[%s] SERVER VERSION CHECK - Current: %i, Latest: %i - Old version, please upgrade.\n", getTimeStr(1).text(), GSERVER_BUILD, line.readByte2()); break; } case GSVCURRENT: { printf("[%s] SERVER VERSION CHECK - Current: %i, Latest: %i - You are up to date :)\n", getTimeStr(1).text(), GSERVER_BUILD, GSERVER_BUILD); break; } case GSVACCOUNT: { CString accountName = line.readChars(line.readByte1()); CString errorMsg = line.readString(""); for (int i = 0; i < newPlayers.count(); i++) { CPlayer *player = (CPlayer *)newPlayers[i]; if (player->accountName.comparei(accountName) == 0) { // The serverlist will return case sensitive account names. // This helps case sensitive file systems open/save the correct // acount. player->accountName = accountName; if (errorMsg == "SUCCESS") { player->sendAccount(); } else { player->sendPacket(CPacket() << (char)DISMESSAGE << errorMsg); player->deleteMe = true; } break; } } break; } case GSVGUILD: { int playerId = line.readByte2(); CPlayer *player = (CPlayer *)playerIds[playerId]; if (player != NULL) { CString nick = line.readChars((unsigned char)line.readByte1()); CString guild = nick.copy( nick.findl( '(' ) ).remove( ")" ); if ( globalGuilds == false ) { if ( globalGuildList.find( guild ) != -1 ) player->setNick(nick, false); } else player->setNick(nick, false); } break; } case GSVPROFILE: /* Unsure if this works, temp */ { CPacket profile; CPlayer *player1 = (CPlayer *)playerIds[line.readByte2()]; CPlayer *player2 = findPlayerId(line.readChars(line.readByte1())); if (player1 == NULL || player2 == NULL) return; profile << (char)player2->accountName.length() << player2->accountName << line.readString(""); int time = player2->onlineSecs; CString line2; //Online time line2 << toString((int)time/3600) << " hrs "; line2 << toString((int)(time/60)%60) << " mins "; line2 << toString((int)time%60) << " secs"; profile << (char)line2.length() << line2; for (int i = 0; i < profileList.count(); i++) { CStringList a; a.load(profileList[i].text(), ":="); if (a[0].length() < 1) continue; CString n; if (a[1] == "playerkills") n = toString(player2->kills); else if (a[1] == "playerdeaths") n = toString(player2->deaths); else if (a[1] == "playerfullhearts") { if ( (float)(int)player2->maxPower == (float)player2->maxPower ) n = toString((int)player2->maxPower); else { n = toString(player2->maxPower); n = n.copy( 0, n.length() - 1 ); } } else if (a[1] == "playerrating") n = toString((int)player2->rating) << "/" << toString((int)player2->deviation); else if (a[1] == "playerap") n = toString(player2->ap); else if (a[1] == "playerrupees") n = toString(player2->rubins); else if (a[1] == "playerswordpower") n = toString(player2->swordPower); else if (a[1] == "canspin") n = (player2->status & 64 ? "true" : "false"); else if (a[1] == "playerhearts") { if ( (float)(int)player2->power == (float)player2->power ) n = toString((int)player2->power); else { n = toString(player2->power); n = n.copy( 0, n.length() - 1 ); } } else if (a[1] == "playerdarts") n = toString(player2->darts); else if (a[1] == "playerbombs") n = toString(player2->bombs); else if (a[1] == "playermp") n = toString(player2->magicPoints); else if (a[1] == "playershieldpower") n = toString(player2->shieldPower); else if (a[1] == "playerglovepower") n = toString(player2->glovePower); else { for (int i = 0; i < player2->myFlags.count(); i++) { CStringList b; b.load(player2->myFlags[i].text(), "="); if (b[0] == a[1]) { n = b[1]; break; } } } profile << (char)(a[0].length() + n.length() + 2) << a[0] << ":=" << n; } player1->sendPacket(CPacket() << (char)DPROFILE << profile); break; } case GSVMSG: printf("[%s] %s\n", getTimeStr(1).text(), line.readString("")); break; case GSVFILESTART3: { unsigned char pTy = (unsigned char)line.readByte1(); CString fileData, fileName = CString() << dataDir << "global" << fSep; switch (pTy) { case 0: // head fileName << "heads" << fSep; break; case 1: // body fileName << "bodies" << fSep; break; case 2: // sword fileName << "swords" << fSep; break; case 3: // shield fileName << "shields" << fSep; break; } fileName << line.readChars(line.readByte1()); fileData.save(fileName.text()); break; } case GSVFILEDATA3: { unsigned char pTy = (unsigned char)line.readByte1(); CString fileData, fileName, newData, shortName; shortName = line.readChars(line.readByte1()); fileName = CString() << dataDir << "global" << fSep; switch (pTy) { case 0: // head fileName << "heads" << fSep; break; case 1: // body fileName << "bodies" << fSep; break; case 2: // sword fileName << "swords" << fSep; break; case 3: // shield fileName << "shields" << fSep; break; } fileName << shortName.text(); newData.writeBytes(line.readChars(line.bytesLeft()), line.bytesLeft()); fileData.load(fileName.text()); fileData << newData; fileData.save(fileName.text()); break; } case GSVFILEEND3: { CPlayer *player = (CPlayer *)playerIds[line.readByte2()]; int type = line.readByte1(); char doCompress = line.readByte1(); time_t modTime = line.readByte5(); int fileLength = line.readByte5(); CString shortName = line.readString(""); CString fileName = CString() << dataDir << "global" << fSep; switch (type) { case 0: // head fileName << "heads" << fSep; break; case 1: // body fileName << "bodies" << fSep; break; case 2: // sword fileName << "swords" << fSep; break; case 3: // shield fileName << "shields" << fSep; break; } fileName << shortName.text(); // If the file was sent compressed, we need to uncompress it. if (doCompress == 1) { // Open the file so we can uncompress it. CString fileData; fileData.load(fileName.text()); // Uncompress the file. char* buffer = new char[fileLength]; memset((void*)buffer, 0, fileLength); int cLen = fileLength; int error = uncompress((Bytef*)buffer,(uLongf*)&cLen,(const Bytef*)fileData.text(), fileData.length()); if (error != Z_OK) printf("Failed to decompress file: %s\n", shortName.text()); // Save the file now. fileData.clear(); fileData.writeBytes(buffer, cLen); fileData.save(fileName.text()); delete [] buffer; } // Set the file mod time. if (setFileModTime(fileName.text(), modTime) == false) printf("** [WARNING] Could not set modification time on file %s\n", shortName.text()); if (player) { player->fileList.add(new COutFile(shortName, 0)); switch (type) { case 0: // head player->headImage = shortName; player->updateProp(HEADGIF); break; case 1: // body player->bodyImage = shortName; player->updateProp(BODYIMG); break; case 2: // sword player->swordImage = shortName; player->updateProp(SWORDPOWER); break; case 3: // shield player->shieldImage = shortName; player->updateProp(SHIELDPOWER); break; } } break; } case GSVPING: // Sent every 60 seconds, do nothing. break; case GSVRAWDATA: nextIsRaw = true; rawPacketSize = line.readByte3(); break; default: printf("[%s] Invalid List Server Message: %i\n", getTimeStr(1).text(), messageId); break; } } }
int GroupRunWithinMultirun(const char* groupName, const char* constraintsToApply) { CStringList cNames; bool applyAll = strncmp(constraintsToApply, "applyAll", 8) == 0; if (!applyAll) { char *cons = strdup(constraintsToApply); char *cName = strtok( cons, ":" ); while(cName) { cNames.AddTail( cName ); cName = strtok( NULL, ":" ); } } CDynConstraintSet *set = new CDynConstraintSet(0); set->RemoveAll(); CDynConstraintSetList & setlist = CManager::theInstance->GetConstraintSets(); POSITION sl_pos = setlist.GetHeadPosition(); while (sl_pos) { CDynConstraintSet * setlist_i = setlist.GetNext(sl_pos); CDynConstraintList& list = setlist_i->GetConstraints(); POSITION pos1 = list.GetHeadPosition(); while(pos1) { CDynConstraint *cur = list.GetNext(pos1); const CString& nm = cur->GetName(); if (applyAll || cNames.Find(nm)) { Info("DesertFinit", "Applying Constraint: %s", nm); cur->SetApplied(); set->InsertConstraint(cur); } } } // prune & generate next hierarchy double dspSize; long repSize; long clockTime; try { CManager::theInstance->GetSizeInfo(dspSize, repSize, clockTime, set); CManager::theInstance->GenerateNextHierarchy(); } catch(CDesertException *e) { set->RemoveAll(); delete set; delete CManager::theInstance; CManager::theInstance = NULL; StopLogging(); throw e; } Info("DesertFinit", "Design Space Size Info: %f %d %d", dspSize, repSize, clockTime); set->RemoveAll(); delete set; int numCfgs = 0; try { numCfgs = CManager::theInstance->CalcRealNoOfConfigurations(); Info("DesertFinitMultirun", "For constraint group: %s with constraints:\r\n\t%s\r\n\tDesign Space Size Info: %f %d %d", groupName, constraintsToApply, dspSize, repSize, clockTime); Info("DesertFinitMultirun", "No. of configurations with last set of constraints is %d", numCfgs); } catch(CDesertException *e) { delete CManager::theInstance; CManager::theInstance = NULL; StopLogging(); throw e; } return numCfgs; }
DLL_DECL void DesertFinit_Apply(const char *applyConstraints) { CManager::theInstance->AnalyseConstraints(); CManager::theInstance->GenerateNextHierarchy(); if (CManager::theInstance->HasConstraints()) { if (applyConstraints) { CStringList cNames; bool applyAll = strncmp(applyConstraints, "applyAll", 8) == 0; if (!applyAll) { char *cons = strdup(applyConstraints); char *cName = strtok( cons, ":" ); while(cName) { cNames.AddTail( cName ); cName = strtok( NULL, ":" ); } if(cNames.IsEmpty()) return; } CDynConstraintSet *set = new CDynConstraintSet(0); set->RemoveAll(); CDynConstraintSetList & setlist = CManager::theInstance->GetConstraintSets(); POSITION sl_pos = setlist.GetHeadPosition(); while (sl_pos) { CDynConstraintSet * setlist_i = setlist.GetNext(sl_pos); CDynConstraintList& list = setlist_i->GetConstraints(); POSITION pos1 = list.GetHeadPosition(); while(pos1) { CDynConstraint *cur = list.GetNext(pos1); const CString& nm = cur->GetName(); if (applyAll || cNames.Find(nm)) { Info("DesertFinit", "Applying Constraint: %s", nm); cur->SetApplied(); set->InsertConstraint(cur); } } } // prune & generate next hierarchy double dspSize; long repSize; long clockTime; try{ CManager::theInstance->GetSizeInfo(dspSize, repSize, clockTime, set); }catch(CDesertException *e) { CManager::theInstance->GenerateNextHierarchy(); set->RemoveAll(); delete set; throw e; } // Info("DesertFinit", "Design Space Size Info: %f %d %d", dspSize, repSize, clockTime); CManager::theInstance->GenerateNextHierarchy(); set->RemoveAll(); delete set; } } }
CString WebUpdateOption(CString strInput) { CString strOutput, strItem, strTemp; CStringList strList; POSITION pos1, pos2; WebGetStringList(strInput, 7, strList); strOutput = _T("<OPTION"); #ifndef __GNUC__ for (pos1 = strList.GetHeadPosition(); pos1 != NULL;) #else for (pos1 = strList.begin(); pos1 != strList.end(); ++pos1) #endif { pos2 = pos1; strItem = strList.GetNext(pos1); strTemp = strItem.Left(6); if (!strTemp.CompareNoCase(_T("value="))) { strItem = strItem.Right(strItem.GetLength()-6); strItem = RemoveQuote(strItem); strOutput += _T(" value="); strOutput += strItem; strList.RemoveAt(pos2); } else if (!strItem.CompareNoCase(_T("selected"))) { strList.RemoveAt(pos2); } } #ifndef __GNUC__ for (pos1 = strList.GetHeadPosition(); pos1 != NULL;) #else for (pos1 = strList.begin(); pos1 != strList.end(); ++pos1) #endif { strOutput += _T(' '); strItem = strList.GetNext(pos1); strOutput += strItem; } strOutput += _T('>'); return strOutput; }
void OnWeb2Web(CString strSrcFile, CString strDstFile, BOOL bForce) { CStdioFile in, out; CString strInput, strOutput; CString strItem, strNew; int iBeginPos, iEndPos, iStartIndex; if (!PromptOverwriteFile(strDstFile, bForce)) return; if (!in.Open(strSrcFile, CFile::modeRead)) { #ifndef __GNUC__ wprintf(_T("Can not open source file %s"), strSrcFile); #else printf("Can not open source file %s", strSrcFile.c_str()); #endif return; } if (!out.Open(strDstFile, CFile::modeCreate|CFile::modeWrite|CFile::typeText)) { #ifndef __GNUC__ wprintf(_T("Can not create destination file %s"), strDstFile); #else printf("Can not create destination file %s", strDstFile.c_str()); #endif in.Close(); return; } strInput = _T(""); #ifndef __GNUC__ while (in.ReadString(strItem)) { #else while (!in.eof()) { std::getline(in, strItem); strItem.TrimRight(); #endif strItem.TrimLeft(); strInput += strItem; strInput += _T("\n"); } iStartIndex = 0; strOutput = _T(""); while (iStartIndex < strInput.GetLength()) { iBeginPos = find_char((TCHAR *)(LPCTSTR)strInput, '<', iStartIndex); iEndPos = find_char((TCHAR *)(LPCTSTR)strInput, '>', iStartIndex); if (iBeginPos == -1 || iEndPos == -1) break; if (iEndPos - iBeginPos < 6) { iStartIndex = iEndPos + 1; continue; } strItem = strInput.Mid(iBeginPos, 7); strItem.MakeUpper(); if (!memcmp((LPCTSTR)strItem, "<INPUT", 6)) { strItem = strInput.Mid(iBeginPos, (iEndPos + 1 - iBeginPos)); strNew = WebUpdateInput(strItem); } else if (!strItem.Compare(_T("<SELECT"))) { strItem = strInput.Mid(iBeginPos, (iEndPos + 1 - iBeginPos)); strNew = WebUpdateSelect(strItem); } else if (!strItem.Compare(_T("<OPTION"))) { strItem = strInput.Mid(iBeginPos, (iEndPos + 1 - iBeginPos)); strNew = WebUpdateOption(strItem); } else { iStartIndex = iEndPos + 1; continue; } strOutput += strInput.Left(iBeginPos); strOutput += strNew; strInput = strInput.Right(strInput.GetLength() - iEndPos - 1); iStartIndex = 0; } strOutput += strInput; out.WriteString(strOutput); in.Close(); out.Close(); } void OnWeb2Info(CString strSrcFile, CString strDstFile, BOOL bForce) { CStdioFile in, out; CString strInput, strOutput; CString strItem, strNew; CStringList listOptions; POSITION pos; int iBeginPos, iEndPos, iStartIndex; if (!PromptOverwriteFile(strDstFile, bForce)) return; if (!in.Open(strSrcFile, CFile::modeRead)) { #ifndef __GNUC__ wprintf(_T("Can not open source file %s"), strSrcFile); #else printf("Can not open source file %s", strSrcFile.c_str()); #endif return; } if (!out.Open(strDstFile, CFile::modeCreate|CFile::modeWrite|CFile::typeText)) { #ifndef __GNUC__ wprintf(_T("Can not create destination file %s"), strDstFile); #else printf("Can not create destination file %s", strDstFile.c_str()); #endif in.Close(); return; } strInput = _T(""); #ifndef __GNUC__ while (in.ReadString(strItem)) { #else while (!in.eof()) { std::getline(in, strItem); strItem.TrimRight(); #endif strItem.TrimLeft(); strInput += strItem; strInput += _T("\n"); } iStartIndex = 0; while (iStartIndex < strInput.GetLength()) { iBeginPos = find_char((TCHAR *)(LPCTSTR)strInput, '<', iStartIndex); iEndPos = find_char((TCHAR *)(LPCTSTR)strInput, '>', iStartIndex); if (iBeginPos == -1 || iEndPos == -1) break; if (iEndPos - iBeginPos < 6) { iStartIndex = iEndPos + 1; continue; } strItem = strInput.Mid(iBeginPos, 7); strItem.MakeUpper(); if (!memcmp((LPCTSTR)strItem, "<INPUT", 6)) { strItem = strInput.Mid(iBeginPos, (iEndPos + 1 - iBeginPos)); strNew = WebUpdateInput(strItem); WebGetOptionsList(strNew, listOptions); } else if (!strItem.Compare(_T("<SELECT"))) { strItem = strInput.Mid(iBeginPos, (iEndPos + 1 - iBeginPos)); strNew = WebUpdateSelect(strItem); WebGetOptionsList(strNew, listOptions); } else { iStartIndex = iEndPos + 1; continue; } strInput = strInput.Right(strInput.GetLength() - iEndPos - 1); iStartIndex = 0; } iStartIndex = 0; #ifndef __GNUC__ for (pos = listOptions.GetHeadPosition(); pos != NULL;) #else for (pos = listOptions.begin(); pos != listOptions.end(); ++pos) #endif { strItem = listOptions.GetNext(pos); strItem += _T("="); if (strItem == _cIPtype) { strNew = "OPT_IP_TYPE"; } else if (strItem == _cIPAddress) { strNew = "OPT_IP_ADDRESS"; } else if (strItem == _cSubMask) { strNew = "OPT_SUBNET_MASK"; } else if (strItem == _cRouterIP) { strNew = "OPT_ROUTER_IP"; } else if (strItem == _cDnsType) { strNew = "OPT_DNS_TYPE"; } else if (strItem == _cDnsIP) { strNew = "OPT_DNS_IP"; } else if (strItem == _cDnsIP2) { strNew = "OPT_DNS_IP2"; } else if (strItem == _cLay3Qos) { strNew = "OPT_LAY3_QOS"; } else if (strItem == _cVlanTag) { strNew = "OPT_VLAN_TAG"; } else if (strItem == _cQosPriority) { strNew = "OPT_QOS_PRIORITY"; } else if (strItem == _cVlanTag2) { strNew = "OPT_VLAN_TAG2"; } else if (strItem == _cQosPriority2) { strNew = "OPT_QOS_PRIORITY2"; } else if (strItem == _cVlanTag3) { strNew = "OPT_VLAN_TAG3"; } else if (strItem == _cQosPriority3) { strNew = "OPT_QOS_PRIORITY3"; } else if (strItem == _cPPPoeID) { strNew = "OPT_PPPOE_ID"; } else if (strItem == _cPPPoePIN) { strNew = "OPT_PPPOE_PIN"; } else if (strItem == _cSerialMethod) { strNew = "OPT_SERIAL_METHOD"; } else if (strItem == _cBaudRate) { strNew = "OPT_BAUD_RATE"; } else if (strItem == _cAdminPIN) { strNew = "OPT_ADMIN_PIN"; } else if (strItem == _cAdminUser) { strNew = "OPT_ADMIN_USER"; } else if (strItem == _cVolInput) { strNew = "OPT_VOL_INPUT"; } else if (strItem == _cVolOutput) { strNew = "OPT_VOL_OUTPUT"; } else if (strItem == _cSpeakerVol) { strNew = "OPT_SPEAKER_VOL"; } else if (strItem == _cProvisionServer) { strNew = "OPT_PROVISION_SERVER"; } else if (strItem == _cProvisionTTL) { strNew = "OPT_PROVISION_TTL"; } else if (strItem == _cProvisionFilename) { strNew = "OPT_PROV_FILENAME"; } else if (strItem == _cProvisionPort) { strNew = "OPT_PROVISION_PORT"; } else if (strItem == _cTimeZone) { strNew = "OPT_TIME_ZONE"; } else if (strItem == _cDayLight) { strNew = "OPT_DAY_LIGHT"; } else if (strItem == _cSntpDns) { strNew = "OPT_SNTP_DNS"; } else if (strItem == _cVoiceCoder0) { strNew = "OPT_VOICE_CODER0"; } else if (strItem == _cVoiceCoder1) { strNew = "OPT_VOICE_CODER1"; } else if (strItem == _cVoiceCoder2) { strNew = "OPT_VOICE_CODER2"; } else if (strItem == _cVoiceCoder3) { strNew = "OPT_VOICE_CODER3"; } else if (strItem == _cVoiceCoder4) { strNew = "OPT_VOICE_CODER4"; } else if (strItem == _cVoiceCoder5) { strNew = "OPT_VOICE_CODER5"; } else if (strItem == _cVoiceCoder6) { strNew = "OPT_VOICE_CODER6"; } else if (strItem == _cSpeexRate) { strNew = "OPT_SPEEX_RATE"; } else if (strItem == _cVad) { strNew = "OPT_VAD"; } else if (strItem == _cAgc) { strNew = "OPT_AGC"; } else if (strItem == _cAec) { strNew = "OPT_AEC"; } else if (strItem == _cIlbcFrame) { strNew = "OPT_ILBC_FRAME"; } else if (strItem == _cFrameNumber0) { strNew = "OPT_FRAME_NUMBER0"; } else if (strItem == _cFrameNumber1) { strNew = "OPT_FRAME_NUMBER1"; } else if (strItem == _cFrameNumber2) { strNew = "OPT_FRAME_NUMBER2"; } else if (strItem == _cFrameNumber3) { strNew = "OPT_FRAME_NUMBER3"; } else if (strItem == _cFrameNumber4) { strNew = "OPT_FRAME_NUMBER4"; } else if (strItem == _cFrameNumber5) { strNew = "OPT_FRAME_NUMBER5"; } else if (strItem == _cFrameNumber6) { strNew = "OPT_FRAME_NUMBER6"; } else if (strItem == _cFwdNumber) { strNew = "OPT_FWD_NUMBER"; } else if (strItem == _cFwdAlways) { strNew = "OPT_FWD_ALWAYS"; } else if (strItem == _cFwdBusy) { strNew = "OPT_FWD_BUSY"; } else if (strItem == _cFwdNoAnswer) { strNew = "OPT_FWD_NOANSWER"; } else if (strItem == _cNoAnswerTimeout) { strNew = "OPT_NOANSWER_TIMEOUT"; } else if (strItem == _cCallWaiting) { strNew = "OPT_CALL_WAITING"; } else if (strItem == _cAutoAnswer) { strNew = "OPT_AUTO_ANSWER"; } else if (strItem == _cDialPrefix) { strNew = "OPT_DIAL_PREFIX"; } else if (strItem == _cHotLineNumber) { strNew = "OPT_HOTLINE_NUMBER"; } else if (strItem == _cUseDigitmap) { strNew = "OPT_USE_DIGITMAP"; } else if (strItem == _cDigitmapTimeout) { strNew = "OPT_DIGITMAP_TIMEOUT"; } else if (strItem == _cPoundAsCall) { strNew = "OPT_POUND_AS_CALL"; } else if (strItem == _cRedialTimeout) { strNew = "OPT_REDIAL_TIMEOUT"; } else if (strItem == _cCallLogTimeout) { strNew = "OPT_CALL_LOG_TIMEOUT"; } else if (strItem == _cRinging) { strNew = "OPT_RINGING"; } else if (strItem == _cGradualRinging) { strNew = "OPT_GRADUAL_RINGING"; } else if (strItem == _cGetVoiceMsg) { strNew = "OPT_GET_VOICE_MSG"; } else if (strItem == _cRegister) { strNew = "OPT_REGISTER"; } else if (strItem == _cLocalPort) { strNew = "OPT_LOCAL_PORT"; } else if (strItem == _cAuthID) { strNew = "OPT_AUTH_ID"; } else if (strItem == _cAuthPIN) { strNew = "OPT_AUTH_PIN"; } else if (strItem == _cUserName) { strNew = "OPT_USER_NAME"; } else if (strItem == _cUserNumber) { strNew = "OPT_USER_NUMBER"; } else if (strItem == _cSipProxy) { strNew = "OPT_SIP_PROXY"; } else if (strItem == _cSipPort) { strNew = "OPT_SIP_PORT"; } else if (strItem == _cSipDomain) { strNew = "OPT_SIP_DOMAIN"; } else if (strItem == _cOutBoundProxy) { strNew = "OPT_OUTBOUND_PROXY"; } else if (strItem == _cRtpPort) { strNew = "OPT_RTP_PORT"; } else if (strItem == _cDtmfPayload) { strNew = "OPT_DTMF_PAYLOAD"; } else if (strItem == _cIlbcPayload) { strNew = "OPT_ILBC_PAYLOAD"; } else if (strItem == _cAdpcm32Payload) { strNew = "OPT_ADPCM32_PAYLOAD"; } else if (strItem == _cSpeexPayload) { strNew = "OPT_SPEEX_PAYLOAD"; } else if (strItem == _cDtmfType) { strNew = "OPT_DTMF_TYPE"; } else if (strItem == _cDnsSrv) { strNew = "OPT_DNS_SRV"; } else if (strItem == _cRegisterTTL) { strNew = "OPT_REGISTER_TTL"; } else if (strItem == _cKeepAlive) { strNew = "OPT_KEEP_ALIVE"; } else if (strItem == _cMessageNumber) { strNew = "OPT_MESSAGE_NUMBER"; } else if (strItem == _cPrack) { strNew = "OPT_PRACK"; } else if (strItem == _cSubscribeMWI) { strNew = "OPT_SUBSCRIBE_MWI"; } else if (strItem == _cProxyRequire) { strNew = "OPT_PROXY_REQUIRE"; } else if (strItem == _cNatTraversal) { strNew = "OPT_NAT_TRAVERSAL"; } else if (strItem == _cNatIP) { strNew = "OPT_NAT_IP"; } else if (strItem == _cStunServer) { strNew = "OPT_STUN_SERVER"; } else if (strItem == _cStunPort) { strNew = "OPT_STUN_PORT"; } else if (strItem == _cIax2Server) { strNew = "OPT_IAX2_SERVER"; } else if (strItem == _cIax2Port) { strNew = "OPT_IAX2_PORT"; } else if (strItem == _cDigitDialing) { strNew = "OPT_DIGIT_DIALING"; } /* else if (strItem == _cUdpDebug) { strNew = "OPT_UDP_DEBUG"; } */ else if (strItem == _cSyslogIP) { strNew = "OPT_SYSLOG_IP"; } else if (strItem == _cTimeOut) { strNew = "OPT_TIME_OUT"; } else if (strItem == _cRingVolOutput) { strNew = "OPT_RING_VOL_OUTPUT"; } else { continue; } if (iStartIndex) { strOutput += ", \n"; } strOutput += strNew; iStartIndex ++; } #ifndef __GNUC__ strItem.Format(_T("#define WEB_INFO_NUM %d\n\nconst unsigned short web_info_code[WEB_INFO_NUM] = {\n"), iStartIndex); #else { char buff[511]; sprintf(buff, _T("#define WEB_INFO_NUM %d\n\nconst unsigned short web_info_code[WEB_INFO_NUM] = {\n"), iStartIndex); strItem = buff; } #endif strOutput = strItem + strOutput; strOutput += _T("\n};\n"); out.WriteString(strOutput); in.Close(); out.Close(); }
bool CLevel::loadNW(CString& pFileName) { CStringList levelData; CString version; char* dataFile = getDataFile(pFileName.text()); if(!strlen(dataFile)) return false; if(!levelData.load(dataFile)) return false; if(levelData.count() < 1) return false; version = levelData[0]; modTime = getFileModTime(dataFile); fileName = pFileName; if(version == "GLEVNW01" || version == "GSERVL01") { for(int i = 1; i < levelData.count(); i ++) { CStringList words; words.load(levelData[i].text(), " "); if(words.count() <= 0) continue; if(words[0] == "BOARD") { if(words.count() <= 5) continue; int x = atoi(words[1].text()); int y = atoi(words[2].text()); int w = atoi(words[3].text()); CString& data = words[5]; if(x >= 0 && x <= 64 && y >= 0 && y <= 64 && w > 0 && x + w <= 64) { if(data.length() >= w*2) { for(int ii = x; ii < x + w; ii++) { char left = data.readChar(); char top = data.readChar(); short tile = base64.find(left) << 6; tile += base64.find(top); tiles[ii + y*64] = tile; } } } } else if(words[0] == "LINK") { if(words.count() <= 7) continue; if(strlen(getDataFile(words[1].text()))) { links.add(new CLink(words[1], atoi(words[2].text()), atoi(words[3].text()), atoi(words[4].text()), atoi(words[5].text()), words[6], words[7])); } } else if(words[0] == "CHEST") { if(words.count() <= 4) continue; for(int ii = 0; ii < itemcount; ii++) { if(words[3] == itemNames[ii]) { chests.add(new CChest(atoi(words[1].text()), atoi(words[2].text()), atoi(words[4].text()), ii)); break; } } } else if(words[0] == "NPC") { if(words.count() <= 3) continue; CString image, code, code2; float x, y; if(words[1] != "-") image = words[1]; x = (float)atof(words[2].text()); y = (float)atof(words[3].text()); for(i++; i < levelData.count() && levelData[i] != "NPCEND"; i++) code << levelData[i] << "\xa7"; // Create the new NPC. Do this before parsing the join commands. // The CNpc constructor will remove all comments. CNpc* jnpc = new CNpc( image, code, x, y, this, true ); // Now filter out the join commands. CStringList npcData; npcData.load( jnpc->clientCode.text(), "\xa7" ); for ( int j = 0; j < npcData.count(); ++j ) code2 << processNpcLine( npcData[j] ) << "\xa7"; jnpc->clientCode = code2; // Now, add all the joined files to the code. if ( joinList.count() > 0 ) { CString* file = 0; while ( (file = (CString*)joinList[0]) != 0 ) { // Load the source file into memory. CString dataFile = getDataFile(file->text()); if(dataFile.length()) { // Append to the end of the script. CString retVal; retVal.load(dataFile.text()); retVal.replaceAll("\r\n", "\xa7"); retVal.replaceAll("\n", "\xa7"); jnpc->clientCode << retVal << "\xa7"; } delete (CString*)joinList[0]; joinList.remove(0); } } joinList.clear(); npcs.add( jnpc ); } else if(words[0] == "BADDY") { if(words.count() <= 3) continue; int x = atoi(words[1].text()); int y = atoi(words[2].text()); int type = atoi(words[3].text()); CBaddy* baddy = new CBaddy(x, y, type); int baddyId = createBaddyId(baddy); baddy->id = baddyId; for(i++; i < levelData.count() && levelData[i] != "BADDYEND"; i++) baddy->verses.add(levelData[i].text()); if(baddies.count() < 50) baddies.add(baddy); else delete baddy; } else if(words[0] == "SIGN") { if(words.count() <= 2) continue; CString sign; int x = atoi(words[1].text()); int y = atoi(words[2].text()); sign.writeChar(x+32); sign.writeChar(y+32); for (i++; i < levelData.count() && levelData[i] != "SIGNEND"; i++) sign << getSignCode(CString() << levelData[i] << "\n"); signs.add(sign); } else if(words[0] == "REPLACENPC") { int npcId = atoi(words[1].text()); CNpc* npc = (CNpc*)npcs[npcId]; if(npc == NULL) continue; for(i++; i < levelData.count() && levelData[i] != "REPLACENPCEND"; i++) npc->setProps((CPacket&)levelData[i]); } } } else return false; //Find our map id for(int i = 0; i < CMap::mapList.count(); i++) { CMap* m = (CMap*)CMap::mapList[i]; if((levelIndex = m->getLevelpos(pFileName)) >= 0) { map = m; break; } } return true; }
CString WebUpdateInput(CString strInput) { CString strOutput, strItem, strTemp; CStringList strList; POSITION pos1, pos2; int iType; WebGetStringList(strInput, 6, strList); strOutput = _T("<INPUT"); iType = ITEM_TYPE_TEXT; #ifndef __GNUC__ for (pos1 = strList.GetHeadPosition(); pos1 != NULL;) #else for (pos1 = strList.begin(); pos1 != strList.end(); ++pos1) #endif { pos2 = pos1; strItem = strList.GetNext(pos1); strTemp = strItem.Left(5); if (!strTemp.CompareNoCase(_T("name="))) { strItem = strItem.Right(strItem.GetLength()-5); strItem = RemoveQuote(strItem); strOutput += _T(" name="); strOutput += strItem; strList.RemoveAt(pos2); } else if (!strTemp.CompareNoCase(_T("type="))) { strTemp = strItem.Right(strItem.GetLength()-5); strTemp = RemoveQuote(strTemp); if (!strTemp.CompareNoCase(_T("checkbox"))) { iType = ITEM_TYPE_CHECKBOX; } else if (!strTemp.CompareNoCase(_T("text"))) { iType = ITEM_TYPE_TEXT; } else if (!strTemp.CompareNoCase(_T("password"))) { iType = ITEM_TYPE_PASSWORD; } else if (!strTemp.CompareNoCase(_T("radio"))) { iType = ITEM_TYPE_RADIO; } else { iType = ITEM_TYPE_UNKNOWN; } } else if (!strItem.CompareNoCase(_T("checked"))) { strList.RemoveAt(pos2); } } #ifndef __GNUC__ for (pos1 = strList.GetHeadPosition(); pos1 != NULL;) #else for (pos1 = strList.begin(); pos1 != strList.end(); ++pos1) #endif { pos2 = pos1; strItem = strList.GetNext(pos1); strTemp = strItem.Left(6); if (!strTemp.CompareNoCase(_T("value="))) { if (iType == ITEM_TYPE_CHECKBOX || iType == ITEM_TYPE_TEXT || iType == ITEM_TYPE_PASSWORD) { strList.RemoveAt(pos2); } else if (iType == ITEM_TYPE_RADIO) { strItem = strItem.Right(strItem.GetLength()-6); strItem = RemoveQuote(strItem); strOutput += _T(" value="); strOutput += strItem; strList.RemoveAt(pos2); } } } #ifndef __GNUC__ for (pos1 = strList.GetHeadPosition(); pos1 != NULL;) #else for (pos1 = strList.begin(); pos1 != strList.end(); ++pos1) #endif { strOutput += _T(' '); strItem = strList.GetNext(pos1); strOutput += strItem; } strOutput += _T('>'); return strOutput; }
BOOL CBCGMenuPage::OnInitDialog() { { CBCGLocalResource locaRes; CPropertyPage::OnInitDialog(); } POSITION pos = NULL; //---------------------------------------------------------- // Find application Menu Bar object (assume that only one): //--------------------------------------------------------- for (pos = gAllToolbars.GetHeadPosition (); m_pMenuBar == NULL && pos != NULL;) { CBCGToolBar* pToolBar = (CBCGToolBar*) gAllToolbars.GetNext (pos); ASSERT (pToolBar != NULL); if (CWnd::FromHandlePermanent (pToolBar->m_hWnd) != NULL) { ASSERT_VALID(pToolBar); m_pMenuBar = DYNAMIC_DOWNCAST (CBCGMenuBar, pToolBar); } } if (m_pMenuBar != NULL) { m_pMenuBar->m_pMenuPage = this; int iCurrMenu = -1; //--------------------------- // Save MenuBar current menu: //--------------------------- m_hmenuCurr = m_pMenuBar->GetMenu (); m_pMenuBar->OnChangeHot (-1); g_menuHash.SaveMenuBar (m_hmenuCurr, m_pMenuBar); //------------------------------------------------------------------- // Find all application document templates and fill menues combobox // by document template data: //------------------------------------------------------------------ CDocManager* pDocManager = AfxGetApp ()->m_pDocManager; if (m_bAutoSet && pDocManager != NULL) { //--------------------------------------- // Walk all templates in the application: //--------------------------------------- for (POSITION pos = pDocManager->GetFirstDocTemplatePosition (); pos != NULL;) { CBCGMultiDocTemplate* pTemplate = (CBCGMultiDocTemplate*) pDocManager->GetNextDocTemplate (pos); ASSERT_VALID (pTemplate); ASSERT_KINDOF (CDocTemplate, pTemplate); //----------------------------------------------------- // We are interessing CMultiDocTemplate objects with // the shared menu only.... //----------------------------------------------------- if (!pTemplate->IsKindOf (RUNTIME_CLASS (CMultiDocTemplate)) || pTemplate->m_hMenuShared == NULL) { continue; } //---------------------------------------------------- // Maybe, the template with same ID is already exist? //---------------------------------------------------- BOOL bIsAlreadyExist = FALSE; for (int i = 0; !bIsAlreadyExist && i < m_wndMenuesList.GetCount (); i++) { CBCGMultiDocTemplate* pListTemplate = (CBCGMultiDocTemplate*) m_wndMenuesList.GetItemData (i); bIsAlreadyExist = pListTemplate != NULL && pListTemplate->GetResId () == pTemplate->GetResId (); } if (!bIsAlreadyExist) { CString strName; pTemplate->GetDocString (strName, CDocTemplate::fileNewName); int iIndex = m_wndMenuesList.AddString (strName); m_wndMenuesList.SetItemData (iIndex, (DWORD_PTR) pTemplate); if (pTemplate->m_hMenuShared == m_hmenuCurr) { iCurrMenu = iIndex; } } } } //-------------------------- // Add a default frame menu: //-------------------------- CString strName; { CBCGLocalResource locaRes; strName.LoadString (IDS_BCGBARRES_DEFUALT_MENU); } int iIndex = m_wndMenuesList.AddString (strName); m_wndMenuesList.SetItemData (iIndex, (DWORD) NULL); if (iCurrMenu == -1) { m_bIsDefaultMDIMenu = TRUE; iCurrMenu = iIndex; } m_hmenuSelected = m_hmenuCurr; m_wndMenuesList.SetCurSel (iCurrMenu); UpdateData (FALSE); OnSelchangeMenuList (); } else { //------------------------------------------------- // No menubar found, disable menu selecting engine: //------------------------------------------------- m_wndMenuesList.EnableWindow (FALSE); GetDlgItem(IDC_BCGBARRES_RESET_FRAME_MENU)->EnableWindow(FALSE); CBCGLocalResource locaRes; m_strMenuDescr.LoadString (IDS_BCGBARRES_NO_MENUBAR); UpdateData (FALSE); } //-------------------------- // Initialize context menus: //-------------------------- { CBCGLocalResource locaRes; CString strNoContextMenu; strNoContextMenu.LoadString (IDS_BCGBARRES_NO_CONTEXT); m_wndContextMenus.AddString (strNoContextMenu); m_wndContextMenus.SetCurSel (0); } if (g_pContextMenuManager != NULL) { CStringList listOfNames; g_pContextMenuManager->GetMenuNames (listOfNames); for (pos = listOfNames.GetHeadPosition (); pos != NULL;) { CString strName = listOfNames.GetNext (pos); m_wndContextMenus.AddString (strName); } m_wndContextMenuCaption.EnableWindow (m_wndContextMenus.GetCount () > 1); m_wndContextMenus.EnableWindow (m_wndContextMenus.GetCount () > 1); } else { //------------------------------- // Hide all context menus fields: //------------------------------- m_wndContextMenuCaption.ShowWindow (SW_HIDE); m_wndContextMenus.ShowWindow (SW_HIDE); m_wndContextHint.ShowWindow (SW_HIDE); m_wndContextFrame.ShowWindow (SW_HIDE); m_wndResetMenuButton.ShowWindow (SW_HIDE); } CBCGToolbarCustomize* pWndParent = DYNAMIC_DOWNCAST (CBCGToolbarCustomize, GetParent ()); ASSERT (pWndParent != NULL); if ((pWndParent->GetFlags () & BCGCUSTOMIZE_MENU_SHADOWS) == 0) { m_wndMenuShadows.ShowWindow (SW_HIDE); } if ((pWndParent->GetFlags () & BCGCUSTOMIZE_MENU_ANIMATIONS) == 0) { m_wndMenuAnimationsLabel.ShowWindow (SW_HIDE); m_wndMenuAnimations.ShowWindow (SW_HIDE); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL WebLogic(const char * strParas, char * szReturn, int& nSize) //(CStringList ¶mList, char *szReturn) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); //参数解析: CString strServIp = _T(""), strServPort = _T(""), strUserName = _T(""), strUserPwd = _T(""), strTaskType = _T(""), strTaskParam = _T(""); CString strProxyServ = _T(""), strProxyUser = _T(""); int nServerPort = 21; int nTimeout = 60; BOOL bRet = FALSE; // Check Content Change CStringList paramList; MakeStringListByChar(paramList,strParas); POSITION pos = paramList.GetHeadPosition(); while(pos) { CString strTemp = paramList.GetNext(pos); if(strTemp.Find(__USERNAME__, 0) == 0) { strUserName = strTemp.Right(strTemp.GetLength() - strlen(__USERNAME__)); } else if(strTemp.Find(__PASSWORD__, 0) == 0) { strUserPwd = strTemp.Right(strTemp.GetLength() - strlen(__PASSWORD__)); } else if(strTemp.Find(__TIMEOUT__, 0) == 0) { nTimeout = atoi(strTemp.Right(strTemp.GetLength() - strlen(__TIMEOUT__))); } else if(strTemp.Find(__SERVERIP__, 0) == 0) { strServIp = strTemp.Right(strTemp.GetLength() - strlen(__SERVERIP__)); } else if(strTemp.Find(__SERVERPORT__, 0) == 0) { strServPort = strTemp.Right(strTemp.GetLength() - strlen(__SERVERPORT__)); } else if(strTemp.Find(__TASKTYPE__, 0) == 0) { strTaskType = strTemp.Right(strTemp.GetLength() - strlen(__TASKTYPE__)); } else if(strTemp.Find(__TASKPARAM__, 0) == 0) { strTaskParam = strTemp.Right(strTemp.GetLength() - strlen(__TASKPARAM__)); } else { } } if(strUserName.IsEmpty()) { sprintf(szReturn, "error=%s", FuncGetStringFromIDS("IDS_Poor_UserName"));//"缺少用户姓名!");//<%IDS_Monitor_40%>"缺少FTP服务器地址" return FALSE; } if(strUserPwd.IsEmpty()) { sprintf(szReturn, "error=%s", FuncGetStringFromIDS("IDS_Poor_Password"));//"缺少用户密码!");//<%IDS_Monitor_40%> return FALSE; } if(strServIp.IsEmpty()) { sprintf(szReturn, "error=%s", FuncGetStringFromIDS("IDS_Poor_ServerAddress"));//"缺少服务器地址!");//<%IDS_Monitor_40%>"缺少FTP服务器地址" return FALSE; } if(strServPort.IsEmpty()) { sprintf(szReturn, "error=%s", FuncGetStringFromIDS("IDS_Poor_ServerPort"));//"缺少服务器端口地址!");//<%IDS_Monitor_40%>"缺少FTP服务器地址" return FALSE; } if(strTaskType.IsEmpty()) { sprintf(szReturn, "error=%s", FuncGetStringFromIDS("IDS_Poor_TaskType"));//"缺少任务类型!");//<%IDS_Monitor_40%>"缺少FTP服务器地址" return FALSE; } if(strTaskParam.IsEmpty()) { //为解决大部分Weblogic监视器不能工作问题,修改代码。修改开始 苏合 2007-09-18 //strTaskParam = "null"; strTaskParam = ""; //为解决大部分Weblogic监视器不能工作问题,修改代码。修改结束 苏合 2007-09-18 } if(nTimeout <= 0) { sprintf(szReturn, "error=%s", FuncGetStringFromIDS("IDS_TimeoutParamError"));//"超时参数有错误!");//<%IDS_Monitor_40%>"缺少FTP服务器地址" return FALSE; } //取数据的实现 CString strCustomerPath = _T(""); strCustomerPath.Format("%s\\fcgi-bin", FuncGetInstallRootPath()); //CString strCmdLine = "CMD /C " + strCustomerPath + "\\MonitorManager\\WeblogicMonitor.bat \""; CString strCmdLine = "CMD /C \"" + strCustomerPath + "\\WeblogicMonitor.bat\" "; strCmdLine += strUserName + " "; strCmdLine += strUserPwd + " "; //为解决大部分Weblogic监视器不能工作问题,修改代码。修改开始 苏合 2007-09-18 //strCmdLine += "t3://" + strServIp + ":" + strServPort; //strCmdLine += " " + strTaskType; //strCmdLine += " " + strTaskParam; strCmdLine += strServIp + " "; strCmdLine += strServPort + " "; strCmdLine += strTaskType + " "; strCmdLine += strTaskParam; //为解决大部分Weblogic监视器不能工作问题,修改代码。修改结束 苏合 2007-09-18 SECURITY_ATTRIBUTES sa; sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.bInheritHandle = TRUE; sa.lpSecurityDescriptor = NULL; HANDLE hRead, hWrite; long retval = CreatePipe(&hRead, &hWrite, &sa, 12000) ; if(retval == 0) { return false; } else { STARTUPINFO si; memset(&si, 0, sizeof(STARTUPINFO)); si.cb = sizeof(STARTUPINFO); si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; si.hStdOutput = hWrite; si.hStdError = hWrite; // si.wShowWindow =SW_HIDE; PROCESS_INFORMATION pi; memset(&pi, 0, sizeof(PROCESS_INFORMATION)); puts(strCmdLine); if (CreateProcess(NULL, strCmdLine.GetBuffer(strCmdLine.GetLength()), &sa, &sa, TRUE, CREATE_NEW_CONSOLE/*CREATE_NO_WINDOW*/, NULL, NULL, &si, &pi)) { bRet = TRUE; DWORD dwResult = WaitForSingleObject(pi.hProcess, 6000*1000); if (dwResult == WAIT_OBJECT_0) { DWORD dwExitCode = 0; if (GetExitCodeProcess(pi.hProcess, &dwExitCode)) { //if (dwExitCode == 0) { // CFile* pFile = NULL; int nFileLength = 0; TRY { pFile = new CFile(hRead); nFileLength = pFile->GetLength(); } CATCH(CFileException, pEx) { // Do Nothing. } END_CATCH char * buffer = NULL; buffer = (char*)malloc(nFileLength+1); // pFile->Read(buffer, nFileLength); CString strSource = _T(""); strSource.Format("%s", buffer); //WeblogicMonitor(去掉call setWLSEnv.cmd所生成的输出) int nOrder = strSource.Find("FileSplitFlag"); nOrder += 13; strSource = strSource.Mid(nOrder); // nOrder = strSource.Find("EndSplitFlag"); //nOrder += 13; strSource = strSource.Left(nOrder); strSource.Replace("WaitingForConnectionCurrentCount","WaitConnetCurCount"); strSource.Replace( "Error=","error=" ); //生成正确格式的输出串 strcpy(szReturn, strSource); //sprintf(szReturn, "error=%s",buffer); // free(buffer); if (pFile != NULL) { pFile->Close(); delete pFile; } } //else { } }
////////////////////////////////////////////////////////////////////////// //简要描述 : 设置扩展属性配置文件 //输入参数 : //返 回 值 : // // //修改日志 : ////////////////////////////////////////////////////////////////////////// STDMETHODIMP CDwgWriter::put_XDataXMLConfigFile(BSTR sXMLFile) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); if (sXMLFile == NULL) return S_OK; CString sXml = sXMLFile; if (sXml.IsEmpty()) return S_OK; m_XDataCfgs.RemoveAll(); try { CXMLFile xmlfile; xmlfile.load(sXml); MSXML2::IXMLDOMNodePtr pNode; MSXML2::IXMLDOMNodePtr pExtAttrNode = NULL; xmlfile.GetNode("LAYERS", pNode); if (pNode == NULL) { //AfxMessageBox("XML配置文件不正确,请检查。"); m_dwgWriter.WriteLog("XML配置文件不正确,请检查。"); return S_FALSE; } pNode = pNode->GetfirstChild(); if (pNode == NULL) { //AfxMessageBox("XML配置文件不正确,请检查。"); m_dwgWriter.WriteLog("XML配置文件不正确,请检查。"); return S_FALSE; } CComBSTR bsNodeName; CComBSTR bsExtAttrs; CString sLayerName; CString sRegAppName; CString sExtAttrs; while (pNode != NULL) { //得到图层名 pNode->get_nodeName(&bsNodeName); sLayerName = bsNodeName; //去掉前面的_前缀,解决数字开头的节点问题 CString sSign = ""; sSign = sLayerName.Mid(0, 1); if (sSign.CompareNoCase("_") == 0) { sLayerName = sLayerName.Mid(1); } XDataAttrLists* pExtAttrs = new XDataAttrLists(); //得到图层下的注册应用名 if (pNode->hasChildNodes()) { pExtAttrNode = pNode->GetfirstChild(); while (pExtAttrNode != NULL) { pExtAttrNode->get_nodeName(&bsNodeName); sRegAppName = bsNodeName; //去掉前面的_前缀,解决数字开头的节点问题 sSign = sRegAppName.Mid(0, 1); if (sSign.CompareNoCase("_") == 0) { sRegAppName = sRegAppName.Mid(1); } pExtAttrNode->get_text(&bsExtAttrs); sExtAttrs = bsExtAttrs; CStringList* pAttrLst = new CStringList(); //解析注册应用名下的属性字段名称 CString sAttr; int iPos = sExtAttrs.Find(','); while (iPos > 0) { sAttr = sExtAttrs.Mid(0, iPos); sExtAttrs = sExtAttrs.Mid(iPos + 1); if (!sAttr.IsEmpty()) { pAttrLst->AddTail(sAttr); } iPos = sExtAttrs.Find(','); } if (iPos == -1) { if (!sExtAttrs.IsEmpty()) { pAttrLst->AddTail(sExtAttrs); } } pExtAttrs->SetAt(sRegAppName, pAttrLst); //得到下一个注册应用名的配置 pExtAttrNode = pExtAttrNode->GetnextSibling(); } } m_XDataCfgs.SetAt(sLayerName, pExtAttrs); //得到下一个图层的扩展属性的配置 pNode = pNode->GetnextSibling(); } } catch (...) { m_dwgWriter.WriteLog("解析XML文件出错,请检查。"); return S_FALSE; } return S_OK; }
bool isValidFile(CBuffer& file, int type) { for ( int i = 0; i < folderConfig.count(); ++i ) { folderConfig[i].setRead(0); CString ftype( folderConfig[i].readString( " " ) ); CString fmask = CBuffer() << dataDir << CBuffer(folderConfig[i].readString( "" )).trim().text(); folderConfig[i].setRead(0); switch ( type ) { case 11: // HEADGIF if ( ftype == "head" ) if ( file.match( fmask.text() ) ) return true; break; case 35: // BODYIMG if ( ftype == "body" ) if ( file.match( fmask.text() ) ) return true; break; case 8: // SWORDPOWER if ( ftype == "sword" ) { int j = 0; while ( j < defaultSwordNames.count() && file.find( defaultSwordNames[j].text() ) == -1 ) ++j; if ( j != defaultSwordNames.count() ) return false; if ( file.match( fmask.text() ) ) return true; } break; case 9: // SHIELDPOWER if ( ftype == "shield" ) { int j = 0; while ( j < defaultShieldNames.count() && file.find( defaultShieldNames[j].text() ) == -1 ) ++j; if ( j != defaultShieldNames.count() ) return false; if ( file.match( fmask.text() ) ) return true; } break; case 1: // level if ( ftype == "level" ) if ( file.match( fmask.text() ) ) return true; break; case -1: // Any if ( file.match( fmask.text() ) ) return true; break; default: case 0: // file if ( ftype == "file" ) if ( file.match( fmask.text() ) ) return true; break; } } return false; }
int Ctbg::read_iap(int fhandle, int onlyopen, CStringList &filelist) { char *filedata; char tmpfilename[MAX_PATH]; CString outfilepath, syscommand; int esize, iapfullsize; int fhandle2; int ret; int hasweidu; int maxlen; hasweidu=1; maxlen=filelength(fhandle); if(maxlen<sizeof(iapheader) ) return -1; //short file, invalid item if(read(fhandle,&iapheader,sizeof(iapheader) )!=sizeof(iapheader) ) { return -2; } if(memcmp(iapheader.signature,"IAP",3) ) return -4; // not iap if(iapheader.totallen!=maxlen) return -1; //iap total length is invalid actfilecount=0; iapfullsize=sizeof(iapheader); KillIapFileHeaders(); iapfileheaders=new iap_file_header[iapheader.tbgcount+iapheader.othercount]; if(!iapfileheaders) return -3; iapfilecount=iapheader.tbgcount+iapheader.othercount; esize=iapfilecount*sizeof(iap_file_header); if(read(fhandle,iapfileheaders,esize)!=esize) { return -2; } iapfullsize+=esize; if(onlyopen) { AllocateHeaders(iapheader.tbgcount,iapheader.othercount); } //handle tbg files, iap files for(actfilecount=0;actfilecount<iapfilecount;actfilecount++) { if(iapfileheaders[actfilecount].nameoffset!=iapfullsize) return -2; esize=iapfileheaders[actfilecount].namelength; iapfullsize+=esize; if(iapfullsize>maxlen) return -2; if(esize>=MAX_PATH) return -3; if(read(fhandle,tmpfilename,esize)!=esize) return -2; outfilepath=bgfolder+CString(tmpfilename,esize); if(iapfileheaders[actfilecount].fileoffset!=iapfullsize) return -2; esize=iapfileheaders[actfilecount].filelength; iapfullsize+=esize; if(iapfullsize>maxlen) return -2; if(actfilecount<iapheader.tbgcount) { //tbg file if(onlyopen) { m_tbgnames[actfilecount]=outfilepath; lseek(fhandle,esize,SEEK_CUR); continue; } ret=read_tbg(fhandle,esize); if(ret<0) return ret; if(ret==9) return 0; //handled in read_tbg already ret=ImportFile(); if(ret<0) return ret; continue; } //plain file if(onlyopen) { m_othernames[actfilecount-iapheader.tbgcount]=outfilepath; lseek(fhandle,esize,SEEK_CUR); continue; } filedata=new char[esize+1]; if(!filedata) return -3; filedata[esize]=0; //for using it as a string if(read(fhandle,filedata,esize)!=esize) { delete [] filedata; return -2; } fhandle2=creat(outfilepath,S_IWRITE); if(fhandle2<1) return -2; if(write(fhandle2,filedata,esize)!=esize) ret=-2; else ret=0; close(fhandle2); if(ret<0) { delete [] filedata; return ret; } if((iapfileheaders[actfilecount].launchflag&2) && hasweidu) { delete [] filedata; if(weidupath.IsEmpty()) { MessageBox(0,"Can't import dialog source without WeiDU installed!","Warning",MB_ICONEXCLAMATION|MB_OK); hasweidu=0; continue; } filelist.AddTail(outfilepath); continue; } if((iapfileheaders[actfilecount].launchflag&1) ) { //if(esize>4096) filedata[4096]=0; //MessageBox(0,filedata,"IAP import",MB_OK); CTextView dlg; dlg.m_text=filedata; dlg.m_file=outfilepath; dlg.DoModal(); delete [] filedata; continue; } delete [] filedata; } if(iapfullsize!=maxlen) return -1; return 0; }
int main(int argc, char *argv[]) { #ifdef PSPSDK pspDebugScreenInit(); SetupCallbacks(); #else // Shut down the server if we get a kill signal. signal( SIGINT, (sighandler_t) shutdownServer ); signal( SIGTERM, (sighandler_t) shutdownServer ); #endif /* Setup Data-Directory */ dataDir = CBuffer(argv[0]).replaceAll("\\", "/"); dataDir = dataDir.copy(0, dataDir.findl('/') + 1); programDir = dataDir; dataDir << "world/"; /* Main Initiating */ adminNames.load( __admin, sizeof(__admin) / sizeof(const char*) ); colourNames.load( __colours, sizeof(__colours) / sizeof(const char*) ); clothCommands.load( __cloths, sizeof(__cloths) / sizeof(const char*) ); defaultGaniNames.load( __defaultgani, sizeof(__defaultgani) / sizeof(const char*) ); defaultSwordNames.load( __defaultsword, sizeof(__defaultsword) / sizeof(const char*) ); defaultShieldNames.load( __defaultshield, sizeof(__defaultshield) / sizeof(const char*) ); playerIds.add(0); playerIds.add(0); npcIds.add(0); srand((int)time(NULL)); /* Load Important Files */ updateFile("rchelp.txt"); updateFile("rcmessage.txt"); updateFile("rules.txt"); updateFile("serverflags.txt"); updateFile("servermessage.html"); updateFile("foldersconfig.txt"); /* Load Settings */ if (!loadSettings("serveroptions.txt")) { errorOut("errorlog.txt", "Unable to load server settings.."); return 1; } /* Load Weapons */ if (!loadWeapons("weapons.txt")) { errorOut("errorlog.txt", "Unable to load weapons from weapons.txt.."); return 1; } /* Initialize Sockets */ if (CSocket::sockStart() != 0) return 1; if(!serverSock.listenSock(serverPort, 20)) { errorOut("errorlog.txt", CString() << "SOCK ERROR: Unable to listen on port: " << toString(serverPort)); return 1; } serverSock.setSync(false); /* Server Finished Loading */ printf("GServer 2 by 39ster\nSpecial thanks to Marlon, Agret, Pac300, 39ster and others for porting the \noriginal 1.39 gserver to 2.1\nServer listening on port: %i\nServer version: Build %s\n\n", serverPort, listServerFields[3].text()); errorOut("serverlog.txt", "Server started"); if ( listServerFields[5] == "localhost" ) errorOut("serverlog.txt", "[DEBUG_LOCALHOSTMODE] Localhost mode is activated.\nListserver communication & account authentication are disabled.", true); serverRunning = true; if ( !(listServerFields[5] == "localhost") ) if (!lsConnected) ListServer_Connect(); while (serverRunning) { long long second = time(NULL); while (second == time(NULL)) { acceptNewPlayers(serverSock); for (int i = 0; i < newPlayers.count(); i ++) { CPlayer* player = (CPlayer*)newPlayers[i]; player->main(); if (player->deleteMe) { delete player; i--; } } for(int i = 0; i < playerList.count(); i++) { CPlayer* player = (CPlayer*)playerList[i]; player->main(); if(player->deleteMe) { delete player; i--; } } // Was moved so it can process faster. - Joey ListServer_Main(); wait(100); } doTimer(); gameTime ++; NOLEVEL->reset(); // Every 30 seconds if (gameTime % 30 == 0) { ListServer_Send(CPacket() << (char)SLSPING); } // Every 10 seconds if (gameTime % 10 == 0) { CPacket pPacket; CString file; for (int i = 0; i < playerList.count(); i++) { CPlayer *player = (CPlayer *)playerList[i]; file << player->accountName << "," << player->nickName << "," << player->levelName << "," << toString(player->x) << "," << toString(player->y) << "," << toString(player->ap) << "\n"; } file.save("logs/playerlist.txt"); serverFlags.save("serverflags.txt"); } //Every 5 seconds? int current = getNWTime(); if (nwTime != current) { nwTime = current; for (int i = 0; i < playerList.count(); i++) { CPacket out; out << (char)NEWWORLDTIME; out.writeByte4(current); ((CPlayer*)playerList[i])->sendPacket(out); } } } }
BOOL CSetSavedDataPage::OnInitDialog() { ISettingsPropPage::OnInitDialog(); // find out how many log messages and URLs we've stored int nLogHistWC = 0; INT_PTR nLogHistMsg = 0; int nUrlHistWC = 0; INT_PTR nUrlHistItems = 0; int nLogHistRepo = 0; CRegistryKey regloghist(_T("Software\\TortoiseGit\\History")); CStringList loghistlist; regloghist.getSubKeys(loghistlist); for (POSITION pos = loghistlist.GetHeadPosition(); pos != NULL; ) { CString sHistName = loghistlist.GetNext(pos); if (sHistName.Left(6).CompareNoCase(_T("commit")) == 0 || sHistName.Left(5).CompareNoCase(_T("merge")) == 0) { nLogHistWC++; CRegistryKey regloghistwc(_T("Software\\TortoiseGit\\History\\")+sHistName); CStringList loghistlistwc; regloghistwc.getValues(loghistlistwc); nLogHistMsg += loghistlistwc.GetCount(); } else { // repoURLs CStringList urlhistlistmain; CStringList urlhistlistmainvalues; CRegistryKey regurlhistlist(_T("Software\\TortoiseGit\\History\\repoURLS")); regurlhistlist.getSubKeys(urlhistlistmain); regurlhistlist.getValues(urlhistlistmainvalues); nUrlHistItems += urlhistlistmainvalues.GetCount(); for (POSITION urlpos = urlhistlistmain.GetHeadPosition(); urlpos != NULL; ) { CString sWCUID = urlhistlistmain.GetNext(urlpos); nUrlHistWC++; CStringList urlhistlistwc; CRegistryKey regurlhistlistwc(_T("Software\\TortoiseGit\\History\\repoURLS\\")+sWCUID); regurlhistlistwc.getValues(urlhistlistwc); nUrlHistItems += urlhistlistwc.GetCount(); } } } // find out how many dialog sizes / positions we've stored INT_PTR nResizableDialogs = 0; CRegistryKey regResizable(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState")); CStringList resizablelist; regResizable.getValues(resizablelist); nResizableDialogs += resizablelist.GetCount(); // find out how many auth data we've stored int nSimple = 0; int nSSL = 0; int nUsername = 0; CString sFile; bool bIsDir = false; PWSTR pszPath = nullptr; if (SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_CREATE, nullptr, &pszPath) == S_OK) { CString path = pszPath; CoTaskMemFree(pszPath); path += L"\\Subversion\\auth\\"; CString sSimple = path + L"svn.simple"; CString sSSL = path + L"svn.ssl.server"; CString sUsername = path + L"svn.username"; CDirFileEnum simpleenum(sSimple); while (simpleenum.NextFile(sFile, &bIsDir)) nSimple++; CDirFileEnum sslenum(sSSL); while (sslenum.NextFile(sFile, &bIsDir)) nSSL++; CDirFileEnum userenum(sUsername); while (userenum.NextFile(sFile, &bIsDir)) nUsername++; } CDirFileEnum logenum(CPathUtils::GetAppDataDirectory()+_T("logcache")); while (logenum.NextFile(sFile, &bIsDir)) nLogHistRepo++; // the "Repositories.dat" is not a cache file nLogHistRepo--; BOOL bActionLog = PathFileExists(CPathUtils::GetLocalAppDataDirectory() + _T("logfile.txt")); m_btnLogHistClear.EnableWindow(nLogHistMsg || nLogHistWC); m_btnUrlHistClear.EnableWindow(nUrlHistItems || nUrlHistWC); m_btnResizableHistClear.EnableWindow(nResizableDialogs > 0); m_btnAuthHistClear.EnableWindow(nSimple || nSSL || nUsername); m_btnRepoLogClear.EnableWindow(nLogHistRepo >= 0); m_btnActionLogClear.EnableWindow(bActionLog); m_btnActionLogShow.EnableWindow(bActionLog); EnableToolTips(); CString sTT; sTT.Format(IDS_SETTINGS_SAVEDDATA_LOGHIST_TT, nLogHistMsg, nLogHistWC); m_tooltips.AddTool(IDC_LOGHISTORY, sTT); m_tooltips.AddTool(IDC_LOGHISTCLEAR, sTT); sTT.Format(IDS_SETTINGS_SAVEDDATA_URLHIST_TT, nUrlHistItems, nUrlHistWC); m_tooltips.AddTool(IDC_URLHISTORY, sTT); m_tooltips.AddTool(IDC_URLHISTCLEAR, sTT); sTT.Format(IDS_SETTINGS_SAVEDDATA_RESIZABLE_TT, nResizableDialogs); m_tooltips.AddTool(IDC_RESIZABLEHISTORY, sTT); m_tooltips.AddTool(IDC_RESIZABLEHISTCLEAR, sTT); sTT.Format(IDS_SETTINGS_SAVEDDATA_AUTH_TT, nSimple, nSSL, nUsername); m_tooltips.AddTool(IDC_AUTHHISTORY, sTT); m_tooltips.AddTool(IDC_AUTHHISTCLEAR, sTT); sTT.Format(IDS_SETTINGS_SAVEDDATA_REPOLOGHIST_TT, nLogHistRepo); m_tooltips.AddTool(IDC_REPOLOG, sTT); m_tooltips.AddTool(IDC_REPOLOGCLEAR, sTT); sTT.LoadString(IDS_SETTINGS_SHOWACTIONLOG_TT); m_tooltips.AddTool(IDC_ACTIONLOGSHOW, sTT); sTT.LoadString(IDS_SETTINGS_MAXACTIONLOGLINES_TT); m_tooltips.AddTool(IDC_MAXLINES, sTT); sTT.LoadString(IDS_SETTINGS_CLEARACTIONLOG_TT); m_tooltips.AddTool(IDC_ACTIONLOGCLEAR, sTT); return TRUE; }
DLL_DECL void * DesertFinitNoGui(bool noError,bool noGui,const char *applyConstraints) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); ASSERT_EX( CManager::theInstance, "CoreInit", "CManager::theInstance IS null"); CCSetErrDialog cse_dialog; if(!CManager::theInstance->VerifyConstraints(&cse_dialog)) { delete CManager::theInstance; CManager::theInstance = NULL; throw new CDesertException(cse_dialog.m_strErrCts); } CManager::theInstance->AnalyseConstraints(); CManager::theInstance->GenerateNextHierarchy(); void * retval = NULL; if (noError) { if (CManager::theInstance->HasConstraints()) { if (applyConstraints) { CStringList cNames; bool applyAll = strncmp(applyConstraints, "applyAll", 8) == 0; if (!applyAll) { char *cons = strdup(applyConstraints); char *cName = strtok( cons, ":" ); while(cName) { cNames.AddTail( cName ); cName = strtok( NULL, ":" ); } } CDynConstraintSet *set = new CDynConstraintSet(0); set->RemoveAll(); CDynConstraintSetList & setlist = CManager::theInstance->GetConstraintSets(); POSITION sl_pos = setlist.GetHeadPosition(); while (sl_pos) { CDynConstraintSet * setlist_i = setlist.GetNext(sl_pos); CDynConstraintList& list = setlist_i->GetConstraints(); POSITION pos1 = list.GetHeadPosition(); while(pos1) { CDynConstraint *cur = list.GetNext(pos1); const CString& nm = cur->GetName(); if (applyAll || cNames.Find(nm)) { Info("DesertFinit", "Applying Constraint: %s", nm); cur->SetApplied(); set->InsertConstraint(cur); } } } // prune & generate next hierarchy double dspSize; long repSize; long clockTime; try{ CManager::theInstance->GetSizeInfo(dspSize, repSize, clockTime, set); }catch(CDesertException *e) { CManager::theInstance->GenerateNextHierarchy(); set->RemoveAll(); delete set; delete CManager::theInstance; CManager::theInstance = NULL; StopLogging(); throw e; } CManager::theInstance->GenerateNextHierarchy(); Info("DesertFinit", "Design Space Size Info: %f %d %d", dspSize, repSize, clockTime); set->RemoveAll(); delete set; } } // CManager::theInstance-> //#ifdef DO_STORE_CONFIGURATIONS // dump the configurations CString fname = projectName + ".cfg"; std::string errmsg; try{ retval = CManager::theInstance->StoreConfigurations(fname, errmsg); } catch(CDesertException *e) { delete CManager::theInstance; CManager::theInstance = NULL; StopLogging(); throw e; } //#endif } // delete the manager instance delete CManager::theInstance; CManager::theInstance = NULL; Info("DesertFinit", "Generated Configurations"); // stop logging StopLogging(); return retval; }
void ListServer_Main() { if (!lsConnected) return; CBuffer receiveBuff; if (listServer.receiveBytes(receiveBuff, 65536) < 0) { errorOut("rclog.txt", "Disconnected from list server"); lsConnected = false; return; } CStringList lines; lines.load(receiveBuff.text(), "\n"); for (int i = 0; i < lines.count(); i++) { CPacket line = CPacket() << lines[i]; int messageId = line.readByte1(); switch (messageId) { case GSVOLD: { printf("*** SERVER VERSION CHECK ***\nYou're running an old version of the GServer.\nYou're running GServer Revision %i while GServer Revision %i is the latest.\n*** SERVER VERSION CHECK ***\n", GSERVER_REVISION, line.readByte2()); break; } case GSVCURRENT: { printf("*** SERVER VERSION CHECK ***\nYou're running an up-to-date server. :)\n*** SERVER VERSION CHECK ***\n"); break; } case GSVACCOUNT: { CString accountName = line.readChars(line.readByte1()); CString errorMsg = line.readString(""); for (int i = 0; i < newPlayers.count(); i++) { CPlayer *player = (CPlayer *)newPlayers[i]; if (player->accountName == accountName) { if (errorMsg == "SUCCESS") { player->sendAccount(); } else { player->sendPacket(CPacket() << (char)DISMESSAGE << errorMsg); player->deleteMe = true; } break; } } break; } case GSVGUILD: { int playerId = line.readByte2(); CPlayer *player = (CPlayer *)playerIds[playerId]; if (player != NULL) { CString nick = line.readChars((unsigned char)line.readByte1()); player->setNick(nick, false); } break; } case GSVFILEC: { CString fileData, fileName = CString() << dataDir << "global" << fSep << line.readChars(line.readByte1()); fileData.save(fileName.text()); break; } case GSVFILED: { CString fileName = line.readChars(line.readByte1()); CPlayer *player = (CPlayer *)playerIds[line.readByte2()]; switch (line.readByte1()) { case 0: // head player->headImage = fileName; player->updateProp(HEADGIF); break; case 1: // body player->bodyImage = fileName; player->updateProp(BODYIMG); break; case 2: // sword player->swordImage = fileName; player->updateProp(SWORDPOWER); break; case 3: // shield player->shieldImage = fileName; player->updateProp(SHIELDPOWER); break; } break; } case GSVFILES: { CString fileData, fileName, newData, shortName; shortName = line.readChars(line.readByte1()); int pos = shortName.find("Revision"); if (pos >= 0) { #ifdef WIN32 fileName = CString() << "GServer-NEW.exe"; #else fileName = CString() << "GServer-NEW"; #endif newData = line.readString(""); } else { fileName = CString() << dataDir << "global" << fSep << shortName.text(); newData = line.readString(""); } fileData.load(fileName.text()); fileData << newData.B64_Decode(); fileData.save(fileName.text()); break; } case GSVPROFILE: /* Unsure if this works, temp */ { CPacket profile; CPlayer *player1 = (CPlayer *)playerIds[line.readByte2()]; CPlayer *player2 = findPlayerId(line.readChars(line.readByte1())); if (player1 == NULL || player2 == NULL) return; profile << (char)player2->accountName.length() << player2->accountName << line.readString(""); int time = player2->onlineSecs; CString line; //Online time line << toString((int)time/3600) << " hrs "; line << toString((int)(time/60)%60) << " mins "; line << toString((int)time%60) << " secs"; profile << (char)line.length() << line; for (int i = 0; i < profileList.count(); i++) { CStringList a; a.load(profileList[i].text(), ":="); if (a[0].length() < 1) continue; CString n; if (a[1] == "playerkills") n = toString(player2->kills); else if (a[1] == "playerdeaths") n = toString(player2->deaths); else if (a[1] == "playerfullhearts") n = toString(player2->maxPower); else if (a[1] == "playerrating") n = toString(player2->rating); else if (a[1] == "playerap") n = toString(player2->ap); else if (a[1] == "playerrupees") n = toString(player2->rubins); else if (a[1] == "playerswordpower") n = toString(player2->swordPower); else if (a[1] == "canspin") n = (player2->status & 64 ? "true" : "false"); else if (a[1] == "playerhearts") n = toString(player2->power); else if (a[1] == "playerdarts") n = toString(player2->darts); else if (a[1] == "playerbombs") n = toString(player2->bombs); else if (a[1] == "playermp") n = toString(player2->magicPoints); else if (a[1] == "playershieldpower") n = toString(player2->shieldPower); else if (a[1] == "playerglovepower") n = toString(player2->glovePower); else { for (int i = 0; i < player2->myFlags.count(); i++) { CStringList b; b.load(player2->myFlags[i].text(), "="); if (b[0] == a[1]) { n = b[1]; break; } } } profile << (char)(a[0].length() + n.length() + 2) << a[0] << ":=" << n; } player1->sendPacket(CPacket() << (char)DPROFILE << profile); break; } case GSVMSG: printf("%s\n", line.readString("")); break; default: printf("Invalid List Server Message: %i\n", messageId); break; } } }
void ListServer_Main() { if ( listServerFields[5] == "localhost" ) return; if (!lsConnected) return; CBuffer receiveBuff; if (listServer.receiveBytes(receiveBuff, 65536) < 0) { errorOut("serverlog.txt", "Disconnected from list server."); lsConnected = false; return; } CStringList lines; lines.load(receiveBuff.text(), "\n"); for (int i = 0; i < lines.count(); i++) { CPacket line = CPacket() << lines[i]; int messageId = line.readByte1(); switch (messageId) { case GSVOLD: { printf("[%s] SERVER VERSION CHECK - Current: %i, Latest: %i - Old version, please upgrade.\n", getTimeStr(1).text(), GSERVER_BUILD, line.readByte2()); break; } case GSVCURRENT: { printf("[%s] SERVER VERSION CHECK - Current: %i, Latest: %i - You are up to date :)\n", getTimeStr(1).text(), GSERVER_BUILD, GSERVER_BUILD); break; } case GSVACCOUNT: { CString accountName = line.readChars(line.readByte1()); CString errorMsg = line.readString(""); for (int i = 0; i < newPlayers.count(); i++) { CPlayer *player = (CPlayer *)newPlayers[i]; if (player->accountName == accountName) { if (errorMsg == "SUCCESS") { player->sendAccount(); } else { player->sendPacket(CPacket() << (char)DISMESSAGE << errorMsg); player->deleteMe = true; } break; } } break; } case GSVGUILD: { int playerId = line.readByte2(); CPlayer *player = (CPlayer *)playerIds[playerId]; if (player != NULL) { CString nick = line.readChars((unsigned char)line.readByte1()); CString guild = nick.copy( nick.findl( '(' ) ).remove( ")" ); if ( globalGuilds == false ) { if ( globalGuildList.find( guild ) != -1 ) player->setNick(nick, false); } else player->setNick(nick, false); } break; } case GSVFILEC: { CString fileData, fileName = CString() << dataDir << "global" << fSep << line.readChars(line.readByte1()); fileData.save(fileName.text()); break; } case GSVFILED: { CString fileName = line.readChars(line.readByte1()); CPlayer *player = (CPlayer *)playerIds[line.readByte2()]; switch (line.readByte1()) { case 0: // head player->headImage = fileName; player->updateProp(HEADGIF); break; case 1: // body player->bodyImage = fileName; player->updateProp(BODYIMG); break; case 2: // sword player->swordImage = fileName; player->updateProp(SWORDPOWER); break; case 3: // shield player->shieldImage = fileName; player->updateProp(SHIELDPOWER); break; } break; } case GSVFILES: { CString fileData, fileName, newData, shortName; shortName = line.readChars(line.readByte1()); int pos = shortName.find("Revision"); if (pos >= 0) { #ifdef WIN32 fileName = CString() << "GServer-NEW.exe"; #else fileName = CString() << "GServer-NEW"; #endif newData = line.readString(""); } else { fileName = CString() << dataDir << "global" << fSep << shortName.text(); newData = line.readString(""); } fileData.load(fileName.text()); fileData << newData.B64_Decode(); fileData.save(fileName.text()); break; } case GSVPROFILE: /* Unsure if this works, temp */ { CPacket profile; CPlayer *player1 = (CPlayer *)playerIds[line.readByte2()]; CPlayer *player2 = findPlayerId(line.readChars(line.readByte1())); if (player1 == NULL || player2 == NULL) return; profile << (char)player2->accountName.length() << player2->accountName << line.readString(""); int time = player2->onlineSecs; CString line2; //Online time line2 << toString((int)time/3600) << " hrs "; line2 << toString((int)(time/60)%60) << " mins "; line2 << toString((int)time%60) << " secs"; profile << (char)line2.length() << line2; for (int i = 0; i < profileList.count(); i++) { CStringList a; a.load(profileList[i].text(), ":="); if (a[0].length() < 1) continue; CString n; if (a[1] == "playerkills") n = toString(player2->kills); else if (a[1] == "playerdeaths") n = toString(player2->deaths); else if (a[1] == "playerfullhearts") { if ( (float)(int)player2->maxPower == (float)player2->maxPower ) n = toString((int)player2->maxPower); else { n = toString(player2->maxPower); n = n.copy( 0, n.length() - 1 ); } } else if (a[1] == "playerrating") n = toString((int)player2->rating) << "/" << toString((int)player2->deviation); else if (a[1] == "playerap") n = toString(player2->ap); else if (a[1] == "playerrupees") n = toString(player2->rubins); else if (a[1] == "playerswordpower") n = toString(player2->swordPower); else if (a[1] == "canspin") n = (player2->status & 64 ? "true" : "false"); else if (a[1] == "playerhearts") { if ( (float)(int)player2->power == (float)player2->power ) n = toString((int)player2->power); else { n = toString(player2->power); n = n.copy( 0, n.length() - 1 ); } } else if (a[1] == "playerdarts") n = toString(player2->darts); else if (a[1] == "playerbombs") n = toString(player2->bombs); else if (a[1] == "playermp") n = toString(player2->magicPoints); else if (a[1] == "playershieldpower") n = toString(player2->shieldPower); else if (a[1] == "playerglovepower") n = toString(player2->glovePower); else { for (int i = 0; i < player2->myFlags.count(); i++) { CStringList b; b.load(player2->myFlags[i].text(), "="); if (b[0] == a[1]) { n = b[1]; break; } } } profile << (char)(a[0].length() + n.length() + 2) << a[0] << ":=" << n; } player1->sendPacket(CPacket() << (char)DPROFILE << profile); break; } case GSVMSG: printf("[%s] %s\n", getTimeStr(1).text(), line.readString("")); break; case GSVPING: // Sent every 60 seconds, do nothing. break; default: printf("[%s] Invalid List Server Message: %i\n", getTimeStr(1).text(), messageId); break; } } }
static BOOL CALLBACK addDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { // only one add dialog at a time! static CScreenInfo* info = NULL; switch (message) { case WM_INITDIALOG: { info = (CScreenInfo*)lParam; // set title CString title; if (info->m_screen.empty()) { title = getString(IDS_ADD_SCREEN); } else { title = CStringUtil::format( getString(IDS_EDIT_SCREEN).c_str(), info->m_screen.c_str()); } SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)title.c_str()); // fill in screen name HWND child = getItem(hwnd, IDC_ADD_SCREEN_NAME_EDIT); SendMessage(child, WM_SETTEXT, 0, (LPARAM)info->m_screen.c_str()); // fill in aliases CString aliases; for (CStringList::const_iterator index = info->m_aliases.begin(); index != info->m_aliases.end(); ++index) { if (!aliases.empty()) { aliases += "\r\n"; } aliases += *index; } child = getItem(hwnd, IDC_ADD_ALIASES_EDIT); SendMessage(child, WM_SETTEXT, 0, (LPARAM)aliases.c_str()); // set options CConfig::CScreenOptions::const_iterator index; child = getItem(hwnd, IDC_ADD_HD_CAPS_CHECK); index = info->m_options.find(kOptionHalfDuplexCapsLock); setItemChecked(child, (index != info->m_options.end() && index->second != 0)); child = getItem(hwnd, IDC_ADD_HD_NUM_CHECK); index = info->m_options.find(kOptionHalfDuplexNumLock); setItemChecked(child, (index != info->m_options.end() && index->second != 0)); child = getItem(hwnd, IDC_ADD_HD_SCROLL_CHECK); index = info->m_options.find(kOptionHalfDuplexScrollLock); setItemChecked(child, (index != info->m_options.end() && index->second != 0)); // modifier options for (UInt32 i = 0; i < sizeof(s_modifiers) / sizeof(s_modifiers[0]); ++i) { child = getItem(hwnd, s_modifiers[i].m_ctrlID); // fill in options for (UInt32 j = 0; j < sizeof(s_modifiers) / sizeof(s_modifiers[0]); ++j) { SendMessage(child, CB_ADDSTRING, 0, (LPARAM)s_modifiers[j].m_name); } // choose current value index = info->m_options.find(s_modifiers[i].m_optionID); KeyModifierID id = s_modifiers[i].m_modifierID; if (index != info->m_options.end()) { id = index->second; } SendMessage(child, CB_SETCURSEL, id - baseModifier, 0); } // dead corners UInt32 corners = 0; index = info->m_options.find(kOptionScreenSwitchCorners); if (index != info->m_options.end()) { corners = index->second; } child = getItem(hwnd, IDC_ADD_DC_TOP_LEFT); setItemChecked(child, (corners & kTopLeftMask) != 0); child = getItem(hwnd, IDC_ADD_DC_TOP_RIGHT); setItemChecked(child, (corners & kTopRightMask) != 0); child = getItem(hwnd, IDC_ADD_DC_BOTTOM_LEFT); setItemChecked(child, (corners & kBottomLeftMask) != 0); child = getItem(hwnd, IDC_ADD_DC_BOTTOM_RIGHT); setItemChecked(child, (corners & kBottomRightMask) != 0); index = info->m_options.find(kOptionScreenSwitchCornerSize); SInt32 size = 0; if (index != info->m_options.end()) { size = index->second; } char buffer[20]; sprintf(buffer, "%d", size); child = getItem(hwnd, IDC_ADD_DC_SIZE); SendMessage(child, WM_SETTEXT, 0, (LPARAM)buffer); return TRUE; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: { CString newName; CStringList newAliases; // extract name and aliases HWND child = getItem(hwnd, IDC_ADD_SCREEN_NAME_EDIT); newName = getWindowText(child); child = getItem(hwnd, IDC_ADD_ALIASES_EDIT); tokenize(newAliases, getWindowText(child)); // name must be valid if (!ARG->m_config.isValidScreenName(newName)) { showError(hwnd, CStringUtil::format( getString(IDS_INVALID_SCREEN_NAME).c_str(), newName.c_str())); return TRUE; } // aliases must be valid for (CStringList::const_iterator index = newAliases.begin(); index != newAliases.end(); ++index) { if (!ARG->m_config.isValidScreenName(*index)) { showError(hwnd, CStringUtil::format( getString(IDS_INVALID_SCREEN_NAME).c_str(), index->c_str())); return TRUE; } } // new name may not be in the new alias list if (isNameInList(newAliases, newName)) { showError(hwnd, CStringUtil::format( getString(IDS_SCREEN_NAME_IS_ALIAS).c_str(), newName.c_str())); return TRUE; } // name must not exist in config but allow same name. also // allow name if it exists in the old alias list but not the // new one. if (ARG->m_config.isScreen(newName) && !CStringUtil::CaselessCmp::equal(newName, info->m_screen) && !isNameInList(info->m_aliases, newName)) { showError(hwnd, CStringUtil::format( getString(IDS_DUPLICATE_SCREEN_NAME).c_str(), newName.c_str())); return TRUE; } // aliases must not exist in config but allow same aliases and // allow an alias to be the old name. for (CStringList::const_iterator index = newAliases.begin(); index != newAliases.end(); ++index) { if (ARG->m_config.isScreen(*index) && !CStringUtil::CaselessCmp::equal(*index, info->m_screen) && !isNameInList(info->m_aliases, *index)) { showError(hwnd, CStringUtil::format( getString(IDS_DUPLICATE_SCREEN_NAME).c_str(), index->c_str())); return TRUE; } } // dead corner size must be non-negative child = getItem(hwnd, IDC_ADD_DC_SIZE); CString valueString = getWindowText(child); int cornerSize = atoi(valueString.c_str()); if (cornerSize < 0) { showError(hwnd, CStringUtil::format( getString(IDS_INVALID_CORNER_SIZE).c_str(), valueString.c_str())); SetFocus(child); return TRUE; } // save name data info->m_screen = newName; info->m_aliases = newAliases; // save options child = getItem(hwnd, IDC_ADD_HD_CAPS_CHECK); if (isItemChecked(child)) { info->m_options[kOptionHalfDuplexCapsLock] = 1; } else { info->m_options.erase(kOptionHalfDuplexCapsLock); } child = getItem(hwnd, IDC_ADD_HD_NUM_CHECK); if (isItemChecked(child)) { info->m_options[kOptionHalfDuplexNumLock] = 1; } else { info->m_options.erase(kOptionHalfDuplexNumLock); } child = getItem(hwnd, IDC_ADD_HD_SCROLL_CHECK); if (isItemChecked(child)) { info->m_options[kOptionHalfDuplexScrollLock] = 1; } else { info->m_options.erase(kOptionHalfDuplexScrollLock); } // save modifier options for (UInt32 i = 0; i < sizeof(s_modifiers) / sizeof(s_modifiers[0]); ++i) { child = getItem(hwnd, s_modifiers[i].m_ctrlID); KeyModifierID id = static_cast<KeyModifierID>( SendMessage(child, CB_GETCURSEL, 0, 0) + baseModifier); if (id != s_modifiers[i].m_modifierID) { info->m_options[s_modifiers[i].m_optionID] = id; } else { info->m_options.erase(s_modifiers[i].m_optionID); } } // save dead corner options UInt32 corners = 0; if (isItemChecked(getItem(hwnd, IDC_ADD_DC_TOP_LEFT))) { corners |= kTopLeftMask; } if (isItemChecked(getItem(hwnd, IDC_ADD_DC_TOP_RIGHT))) { corners |= kTopRightMask; } if (isItemChecked(getItem(hwnd, IDC_ADD_DC_BOTTOM_LEFT))) { corners |= kBottomLeftMask; } if (isItemChecked(getItem(hwnd, IDC_ADD_DC_BOTTOM_RIGHT))) { corners |= kBottomRightMask; } info->m_options[kOptionScreenSwitchCorners] = corners; info->m_options[kOptionScreenSwitchCornerSize] = cornerSize; // success EndDialog(hwnd, 1); info = NULL; return TRUE; } case IDCANCEL: EndDialog(hwnd, 0); info = NULL; return TRUE; } default: break; } return FALSE; }
BOOL CBCGPODBCGridCtrl::OpenSQL (LPCTSTR lpszSQL) { ASSERT (lpszSQL != NULL); m_strSQL.Empty (); RemoveAll (); if (!m_bIsSorting) { DeleteAllColumns (); } if (m_pDataBase == NULL) { ASSERT (FALSE); return FALSE; } try { ASSERT_VALID (m_pDataBase); if (!m_pDataBase->IsOpen ()) { ASSERT (FALSE); return FALSE; } if (m_pRecordSet != NULL) { ASSERT_VALID (m_pRecordSet); if (m_pRecordSet->IsOpen ()) { m_pRecordSet->Close (); } delete m_pRecordSet; m_pRecordSet = NULL; } //--------------------------------------------------------- // Create a new record set and open it using SQL statement: //--------------------------------------------------------- m_pRecordSet = new CRecordset (m_pDataBase); if (!m_pRecordSet->Open (CRecordset::dynaset, lpszSQL)) { return FALSE; } int nColumns = 0; if (!m_bIsSorting) { //------------- // Add columns: //------------- CStringList lstField; if (!GetFieldList (lstField)) { return FALSE; } int nColumn = 0; for (POSITION pos = lstField.GetHeadPosition (); pos != NULL; nColumn++) { InsertColumn (nColumn, lstField.GetNext (pos), 50); } nColumns = (int) lstField.GetCount (); } else { nColumns = GetColumnCount (); } if (nColumns == 0) { // No columns AdjustLayout (); return TRUE; } //------------- // Add records: //------------- if (m_pRecordSet->IsEOF () && m_pRecordSet->IsBOF ()) { // The table is empty AdjustLayout (); return TRUE; } if (m_bVirtualMode) { while (!m_pRecordSet->IsEOF ()) { m_pRecordSet->MoveNext (); } SetVirtualRows (max (0, m_pRecordSet->GetRecordCount ())); } else { for (int nRow = 0; !m_pRecordSet->IsEOF (); m_pRecordSet->MoveNext (), nRow++) { CBCGPGridRow* pRow = CreateRow (nColumns); ASSERT_VALID (pRow); for (int nColumn = 0; nColumn < nColumns; nColumn++) { OnAddData (pRow, nColumn, nRow); } if (OnBeforeAddRow (pRow, nRow)) { AddRow (pRow, FALSE); } else { delete pRow; } } } m_strSQL = lpszSQL; AdjustLayout (); if (!m_pRecordSet->CanUpdate ()) { SetReadOnly (); } } catch (CDBException* pEx) { OnODBCException (pEx); pEx->Delete (); return FALSE; } return TRUE; }
BOOL CForceSyncDlg::OnInitDialog() { CDialog::OnInitDialog(); GetWindowRect(&m_InitRect); m_LastRect = m_InitRect; CString filename; CString filenmok; POSITION pos; BOOL bWeird = FALSE; CStringList strlist; for(pos = m_lpCstrListC->GetHeadPosition(); pos != NULL; ) { filename = m_lpCstrListC->GetNext(pos); if (filename.FindOneOf(_T("@#%")) != -1) { StrBuf b; StrBuf f; f << CharFromCString(filename); StrPtr *p = &f; StrOps::WildToStr(*p, b); filenmok = CharToCString(b.Value()); bWeird = TRUE; } m_List.AddString(filename); strlist.AddTail(filenmok); } if (bWeird) { m_lpCstrListC->RemoveAll(); for(pos = strlist.GetHeadPosition(); pos != NULL; ) m_lpCstrListC->AddTail(strlist.GetNext(pos)); } bWeird = FALSE; strlist.RemoveAll(); for(pos = m_lpCstrListD->GetHeadPosition(); pos != NULL; ) { filename = m_lpCstrListD->GetNext(pos); if (filename.FindOneOf(_T("@#%")) != -1) { StrBuf b; StrBuf f; f << CharFromCString(filename); StrPtr *p = &f; StrOps::WildToStr(*p, b); filenmok = CharToCString(b.Value()); bWeird = TRUE; } m_List.AddString(filename); strlist.AddTail(filenmok); } if (bWeird) { m_lpCstrListD->RemoveAll(); for(pos = strlist.GetHeadPosition(); pos != NULL; ) m_lpCstrListD->AddTail(strlist.GetNext(pos)); } ///////////////////////////// // Fill in the change list, if present, and select the suggested // change number if(!m_pChangeList.IsEmpty()) { ASSERT(m_pChangeList.GetCount() > 0); for(pos=m_pChangeList.GetHeadPosition(); pos != NULL; ) { m_ChangeCombo.AddString(m_pChangeList.GetNext(pos)); } } int index; ASSERT(!m_SelChange.IsEmpty()); if( (index=m_ChangeCombo.FindStringExact(-1, m_SelChange))==CB_ERR) { ASSERT(0); //Why wasnt default value in list? index=0; } m_ChangeCombo.SetCurSel(index); m_Delete.ShowWindow(SW_SHOWNOACTIVATE); m_Delete.EnableWindow(FALSE); m_OK.EnableWindow(FALSE); m_ChangeCombo.EnableWindow(FALSE); hWndThis = m_hWnd; RECT rect; m_List.GetWindowRect(&rect); adjX = rect.left; adjY = rect.top; adjX -= m_InitRect.left; adjY -= m_InitRect.top; m_List.SetRightClkCallback((PTRFUNC)OnRightClickList); // Restore window position m_InitDialogDone = TRUE; m_WinPos.RestoreWindowPosition(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }