void MainMenu::loadTexturesAndSetSprites() { //Background if(!TBackground.loadFromFile("Ressources/Images/NewBackground.jpg")) std::cout<<"erreur chargement background(MainMenu)"<<std::endl; else SBackground.setTexture(TBackground); //Bouton jouer if(!TPlayButton.loadFromFile("Ressources/Images/PlayButton.png")) std::cout<<"erreur chargement image bouton jouer(MainMenu)"<<std::endl; else SPlayButton.setTexture(TPlayButton); SPlayButton.setPosition(sf::Vector2f(440,295)); //Bouton Options if(!TOptionsButton.loadFromFile("Ressources/Images/OptionsButton.png")) std::cout<<"erreur chargement image bouton options(MainMenu)"<<std::endl; else SOptionsButton.setTexture(TOptionsButton); SOptionsButton.setPosition(sf::Vector2f(440,370)); //Bouton Quitter if(!TQuitButton.loadFromFile("Ressources/Images/QuitButton.png")) std::cout<<"erreur chargement image bouton quitter(MainMenu)"<<std::endl; else SQuitButton.setTexture(TQuitButton); SQuitButton.setPosition(sf::Vector2f(440,445)); //Cache sf::Vector2f cacheSize(120, 50); cache.setFillColor(sf::Color(0, 0, 0, 50)); cache.setSize(cacheSize); }
//////////////////////////////////////////////////// // setCache // adds current packet to specified cache void EQPacketStream::setCache(uint16_t serverArqSeq, EQProtocolPacket& packet) { // check if the entry already exists in the cache EQPacketMap::iterator it = m_cache.find(serverArqSeq); if (it == m_cache.end()) { // entry doesn't exist, so insert an entry into the cache #ifdef PACKET_PROCESS_DIAG seqDebug("SEQ: Insert arq (%04x) stream %d into cache", serverArqSeq, m_streamid); #endif m_cache.insert(EQPacketMap::value_type(serverArqSeq, new EQProtocolPacket(packet, true))); emit cacheSize(m_cache.size(), (int)m_streamid); } else { // replacing an existing entry, make sure the new data is valid #ifdef APPLY_CRC_CHECK if (! packet.hasCRC() || calculateCRC(packet) == packet.crc()) #endif { #ifdef PACKET_PROCESS_DIAG seqDebug("SEQ: Update arq (%04x) stream %d in cache", serverArqSeq, m_streamid); #endif // Free the old packet at this place and replace with the new one. delete it->second; it->second = new EQProtocolPacket(packet, true); } #if defined(PACKET_PROCESS_DIAG) && defined(APPLY_CRC_CHECK) else seqDebug("SEQ: Not Updating arq (%04x) stream %d into cache, CRC error!", serverArqSeq, m_streamid); #endif } #ifdef PACKET_CACHE_DIAG if (m_cache.size() > m_maxCacheCount) m_maxCacheCount = m_cache.size(); #endif // PACKET_CACHE_DIAG }
//////////////////////////////////////////////////// // setCache // adds current packet to specified cache void EQPacketStream::setCache(uint16_t serverArqSeq, EQPacketFormat& packet) { // check if the entry already exists in the cache EQPacketMap::iterator it = m_cache.find(serverArqSeq); if (it == m_cache.end()) { // entry doesn't exist, so insert an entry into the cache #ifdef PACKET_PROCESS_DIAG seqDebug("SEQ: Insert arq (%04x) stream %d into cache", serverArqSeq, m_streamid); #endif m_cache.insert(EQPacketMap::value_type(serverArqSeq, new EQPacketFormat(packet, true))); emit cacheSize(m_cache.size(), (int)m_streamid); } else { // replacing an existing entry, make sure the new data is valid if (packet.isValid()) { #ifdef PACKET_PROCESS_DIAG seqDebug("SEQ: Update arq (%04x) stream %d in cache", serverArqSeq, m_streamid); #endif *it->second = packet; } #ifdef PACKET_PROCESS_DIAG else seqDebug("SEQ: Not Updating arq (%04x) stream %d into cache, CRC error!", serverArqSeq, m_streamid); #endif } #ifdef PACKET_CACHE_DIAG if (m_cache.size() > m_maxCacheCount) m_maxCacheCount = m_cache.size(); #endif // PACKET_CACHE_DIAG }
//////////////////////////////////////////////////// // cache reset void EQPacketStream::resetCache() { // first delete all the entries EQPacketMap::iterator it = m_cache.begin(); EQProtocolPacket* packet; #ifdef PACKET_CACHE_DIAG seqDebug("Clearing Cache[%s]: Count: %d", EQStreamStr[m_streamid], m_cache.size()); #endif while (it != m_cache.end()) { packet = it->second; delete packet; it++; } // now clear the cache #ifdef PACKET_CACHE_DIAG seqDebug("Resetting sequence cache[%s]", EQStreamStr[m_streamid]); #endif m_cache.clear(); emit cacheSize(0, m_streamid); }
//============================================================================= bool CRpgLmu::GetLowerChip(int x, int y, int anime, TextureInfoSet& texInfoSet) { if(x<0 || x >= m_nWidth || y<0 || y>= m_nHeight) return false; if (!m_saLower.GetPtr()) return false; int i, cx = 18, cy = 8, base_cx = 0, base_cy = 0; const uint16_t chip = m_saLower[y][x]; const int nOffset[4][2] = { {0, 0}, // 左上 {8, 0}, // 右上 {0, 8}, // 左下 {8, 8}, // 右下 }; //img.Create(CHIP_SIZE, CHIP_SIZE); //img.CopyPalette(imgChipSet); //if(x==2 && y==6){ // printf("%02X\n", chip); //} kuto::Vector2 size((float)CHIP_SIZE / imgChipSet.getWidth(), (float)CHIP_SIZE / imgChipSet.getHeight()); kuto::Vector2 cacheSize((float)CHIP_SIZE / chipCacheTexture_.getWidth(), (float)CHIP_SIZE / chipCacheTexture_.getHeight()); texInfoSet.size = 0; if(chip<3000){ int cacheIndex = GetChipCacheIndex(chip, anime); if (cacheIndex >= 0) { cx = cacheIndex % (chipCacheTexture_.getWidth() / CHIP_SIZE); cy = cacheIndex / (chipCacheTexture_.getWidth() / CHIP_SIZE); texInfoSet.info[0].texcoord[0].set((float)(cx << 4) / chipCacheTexture_.getWidth(), (float)(cy << 4) / chipCacheTexture_.getHeight()); texInfoSet.info[0].texcoord[1] = texInfoSet.info[0].texcoord[0] + cacheSize; texInfoSet.info[0].texture = &chipCacheTexture_; texInfoSet.size++; return true; } cacheIndex = GetEmptyChipCacheIndex(); int destX = 0, destY = 0; if (cacheIndex >= 0) { destX = cacheIndex % (chipCacheTexture_.getWidth() / CHIP_SIZE) * CHIP_SIZE; destY = cacheIndex / (chipCacheTexture_.getWidth() / CHIP_SIZE) * CHIP_SIZE; } bool ocean_flag[4]; /* 0:浅瀬 1:四隅に深海と境界を持つ浅瀬 2:四隅に浅瀬と境界を持つ深海 3:深海 */ int ocean_type[4]; GetOceanType(chip, ocean_flag); // 海のタイプを調べる // 0〜 if(chip<1000){ // 海岸線A1(普通の陸) base_cx = 0; base_cy = 0; for(i = 0; i < 4; i++){ if(!ocean_flag[i]) ocean_type[i] = 0; else ocean_type[i] = 1; } } // 1000〜 else if(chip<2000){ // 海岸線A2(雪) base_cx = 3; base_cy = 0; for(i = 0; i < 4; i++){ if(!ocean_flag[i]) ocean_type[i] = 0; else ocean_type[i] = 1; } } // 2000〜 else if(chip<3000){ // 海岸線A1(普通の陸) base_cx = 0; base_cy = 0; for(i = 0; i < 4; i++){ if(!ocean_flag[i]) ocean_type[i] = 3; else ocean_type[i] = 2; } } // ベースとなる海をセット for(i = 0; i < 4; i++){ if (cacheIndex >= 0) { int x = ((anime % 3) <<4) + nOffset[i][0]; int y = ((ocean_type[i]+4)<<4) + nOffset[i][1]; for (int j = 0; j < 8; j++) { char* destPtr = chipCacheTexture_.getData() + (destX + nOffset[i][0]) * 4 + ((j + destY + nOffset[i][1]) * chipCacheTexture_.getWidth() * 4); const char* srcPtr = imgChipSet.getData() + x * 4 + ((j + y) * imgChipSet.getWidth() * 4); std::memcpy(destPtr, srcPtr, 8 * 4); } } else { int x = ((anime % 3) <<4) + nOffset[i][0]; int y = ((ocean_type[i]+4)<<4) + nOffset[i][1]; //img.Blt(imgChipSet, nOffset[i][0], nOffset[i][1], x, y, CHIP_SIZE>>1, CHIP_SIZE>>1, false); texInfoSet.info[i].texcoord[0].set((float)(x) / imgChipSet.getWidth(), (float)(y) / imgChipSet.getHeight()); texInfoSet.info[i].texcoord[1] = texInfoSet.info[i].texcoord[0] + size * 0.5f; texInfoSet.info[i].texture = &imgChipSet; texInfoSet.size++; } } /* 00:海・海岸線無し 01:海岸線・左上 02:海岸線・右上 04:海岸線・右下 08:海岸線・左下 10:海岸線・左 11:海岸線・左+右上 12:海岸線・左 +右下 13:海岸線・左+右上+右下 14:海岸線・上 15:海岸線・上+右下 16:海岸線・上 +左下 17:海岸線・上+右下+左下 18:海岸線・右 19:海岸線・右+左下 1A:海岸線・右 +左上 1B:海岸線・右+左下+左上 1C:海岸線・下 1D:海岸線・下+左上 1E:海岸線・下 +右上 1F:海岸線・下+左上+右上 20:海岸線・左+右 21:海岸線・上+下 AB CD 22:海岸線・ABC 23:海岸線・ABC +右下 24:海岸線・AB D 25:海岸線・AB D+左下 26:海岸線・ BCD 27:海岸線・ BCD+左上 28:海岸線・A CD 29:海岸線・A CD+右上 2A:海岸線・CABD 2B:海岸線・BACD 2C:海岸線・ACDB 2D:海岸線・ABDC 2E:海岸線・丸(ABCD) */ int chip2 = chip%50; enum{ A, // 四辺 B, // 上下 C, // 左右 D, // 四隅 OCEAN, // 海岸線なし(下の海チップをそのまま採用) }; int nChip[4] = {OCEAN, OCEAN, OCEAN, OCEAN}; if(chip2<0x10){ bool flag[8]; ByteToBool((unsigned char)chip2, flag); if(flag[0]) nChip[0] = D; // 左上 if(flag[1]) nChip[1] = D; // 右上 if(flag[2]) nChip[3] = D; // 右下 if(flag[3]) nChip[2] = D; // 左下 } // 0x10〜 else if(chip2<0x14){ nChip[0] = nChip[2] = B; if(chip2 & 0x01) nChip[1] = D; if(chip2 & 0x02) nChip[3] = D; } // 0x14〜 else if(chip2<0x18){ nChip[0] = nChip[1] = C; if(chip2 & 0x01) nChip[3] = D; if(chip2 & 0x02) nChip[2] = D; } // 0x18〜 else if(chip2<0x1C){ nChip[1] = nChip[3] = B; if(chip2 & 0x01) nChip[2] = D; if(chip2 & 0x02) nChip[0] = D; } // 0x1C〜 else if(chip2<0x20){ nChip[2] = nChip[3] = C; if(chip2 & 0x01) nChip[0] = D; if(chip2 & 0x02) nChip[1] = D; } else if(chip2==0x20){ nChip[0] = nChip[1] = nChip[2] = nChip[3] = B; } else if(chip2==0x21){ nChip[0] = nChip[1] = nChip[2] = nChip[3] = C; } else if(chip2<=0x23){ nChip[0] = A; nChip[2] = B; nChip[1] = C; if(chip2 & 0x01) nChip[3] = D; } else if(chip2<=0x25){ nChip[1] = A; nChip[3] = B; nChip[0] = C; if(chip2 & 0x01) nChip[2] = D; } else if(chip2<=0x27){ nChip[3] = A; nChip[1] = B; nChip[2] = C; if(chip2 & 0x01) nChip[0] = D; } else if(chip2<=0x29){ nChip[2] = A; nChip[0] = B; nChip[3] = C; if(chip2 & 0x01) nChip[1] = D; } else if(chip2==0x2A){ nChip[0] = nChip[1] = A; nChip[2] = nChip[3] = B; } else if(chip2==0x2B){ nChip[0] = nChip[2] = A; nChip[1] = nChip[3] = C; } else if(chip2==0x2C){ nChip[2] = nChip[3] = A; nChip[0] = nChip[1] = B; } else if(chip2==0x2D){ nChip[1] = nChip[3] = A; nChip[0] = nChip[2] = C; } // else if(chip2==0x2E){ else{ nChip[0] = nChip[1] = nChip[2] = nChip[3] = A; } // 海岸線を描画 for(i = 0; i < 4; i++){ if (cacheIndex >= 0) { if(nChip[i] != OCEAN){ int x = ((base_cx + anime % 3)<<4) + nOffset[i][0]; int y = ((base_cy + nChip[i]) <<4) + nOffset[i][1]; for (int j = 0; j < 8; j++) { char* destPtr = chipCacheTexture_.getData() + (destX + nOffset[i][0]) * 4 + ((j + destY + nOffset[i][1]) * chipCacheTexture_.getWidth() * 4); const char* srcPtr = imgChipSet.getData() + x * 4 + ((j + y) * imgChipSet.getWidth() * 4); std::memcpy(destPtr, srcPtr, 8 * 4); } } } else { if(nChip[i] != OCEAN){ int x = ((base_cx + anime % 3)<<4) + nOffset[i][0]; int y = ((base_cy + nChip[i]) <<4) + nOffset[i][1]; //img.Blt(imgChipSet, nOffset[i][0], nOffset[i][1], x, y, CHIP_SIZE>>1, CHIP_SIZE>>1, false); texInfoSet.info[i+4].texcoord[0].set((float)(x) / imgChipSet.getWidth(), (float)(y) / imgChipSet.getHeight()); texInfoSet.info[i+4].texcoord[1] = texInfoSet.info[i+4].texcoord[0] + size * 0.5f; texInfoSet.info[i+4].texture = &imgChipSet; } else { texInfoSet.info[i+4].texture = NULL; } texInfoSet.size++; } } if (cacheIndex >= 0) { chipCacheTexture_.updateImage(); texInfoSet.info[0].texcoord[0].set((float)(destX) / chipCacheTexture_.getWidth(), (float)(destY) / chipCacheTexture_.getHeight()); texInfoSet.info[0].texcoord[1] = texInfoSet.info[0].texcoord[0] + cacheSize; texInfoSet.info[0].texture = &chipCacheTexture_; texInfoSet.size++; chipCache_[cacheIndex].chipID = chip; chipCache_[cacheIndex].animeCount = anime; return true; } return true; } // 3000〜(3028) else if(chip<3050){ // C1 cx = 3; cy = 4; cy += anime % 4; } // 3050〜(3078) else if(chip<3100){ // C2 cx = 4; cy = 4; cy += anime % 4; } // 3100〜(3128) else if(chip<3150){ // C3 cx = 5; cy = 4; cy += anime % 4; } // 3150〜 else if(chip<3200){ // D1 cx = 0; cy = 8; } // 3200〜 else if(chip<3250){ // D2 cx = 3; cy = 8; } // 3250〜 else if(chip<3300){ // D3 cx = 0; cy = 12; } // 3300〜 else if(chip<3350){ // D4 cx = 3; cy = 12; } // 3350〜 else if(chip<3400){ // D5 cx = 6; cy = 0; } // 3400〜 else if(chip<3450){ // D6 cx = 9; cy = 0; } // 3450〜 else if(chip<3500){ // D7 cx = 6; cy = 4; } // 3500〜 else if(chip<3550){ // D8 cx = 9; cy = 4; } // 3550〜 else if(chip<3600){ // D9 cx = 6; cy = 8; } // 3600〜 else if(chip<3650){ // D10 cx = 9; cy = 8; } // 3650〜 else if(chip<3700){ // D11 cx = 6; cy = 12; } // 3700〜 else if(chip<3750){ // D12 cx = 9; cy = 12; } // 3750〜 else if(chip<4000); // たぶん存在しない // 4000〜 else if(chip<5000){ // 相対位置(ア〜エ→A〜D) enum{ A, B, C, D7, // Dはテンキーと対応 D8, D9, D4, D5, D6, D1, D2, D3, }; // 相対位置→相対座標 static const int nOffset2[12][2] = { {0, 0}, {1, 0}, {2, 0}, {0, 1}, {1, 1}, {2, 1}, {0, 2}, {1, 2}, {2, 2}, {0, 3}, {1, 3}, {2, 3}, }; // 4000〜 if(chip<4050){ // D1 base_cx = 0; base_cy = 8; } // 4050〜 else if(chip<4100){ // D2 base_cx = 3; base_cy = 8; } // 4100〜 else if(chip<4150){ // D3 base_cx = 0; base_cy = 12; } // 4150〜 else if(chip<4200){ // D4 base_cx = 3; base_cy = 12; } // 4200〜 else if(chip<4250){ // D5 base_cx = 6; base_cy = 0; } // 4250〜 else if(chip<4300){ // D6 base_cx = 9; base_cy = 0; } // 4300〜 else if(chip<4350){ // D7 base_cx = 6; base_cy = 4; } // 4350〜 else if(chip<4400){ // D8 base_cx = 9; base_cy = 4; } // 4400〜 else if(chip<4450){ // D9 base_cx = 6; base_cy = 8; } // 4450〜 else if(chip<4500){ // D10 base_cx = 9; base_cy = 8; } // 4500〜 else if(chip<4550){ // D11 base_cx = 6; base_cy = 12; } // 4550〜 else if(chip<4600){ // D12 base_cx = 9; base_cy = 12; } /* 00:中央部 01:四隅・左上 02:四隅・右上 04:四隅・右下 08:四隅・左下 10:集合・左 11:集合・左+右上 12:集合・左 +右下 13:集合・左+右上+右下 14:集合・上 15:集合・上+右下 16:集合・上 +左下 17:集合・上+右下+左下 18:集合・右 19:集合・右+左下 1A:集合・右 +左上 1B:集合・右+左下+左上 1C:集合・下 1D:集合・下+左上 1E:集合・下 +右上 1F:集合・下+左上+右上 20:集合・左+右 21:集合・上+下 // ここから地形チップ独自規格∧||∧ 22:集合・左上 23:集合・左上+四隅・右下 24:集合・右上 25:集合・右上+四隅・左下 26:集合・右下 27:集合・右下+四隅・左上 28:集合・左下 29:集合・左下+四隅・右上 2A:集合(左上+右上) 2B:集合(左上+左下) 2C:集合(左下+右下) 2D:集合(右上+右下) 2E:集合(左上+右上+左下+右下) */ int nChip[4] = {D5, D5, D5, D5}; int chip2 = chip % 50; // 0x00〜 if(chip2<0x10){ //bool flag[8]; //ByteToBool((unsigned char)chip2, flag); //for(i = 0; i < 4; i++){ // if(flag[i]) nChip[i] = C; //} if (chip2 & 0x01) nChip[0] = C; if (chip2 & 0x02) nChip[1] = C; if (chip2 & 0x04) nChip[3] = C; if (chip2 & 0x08) nChip[2] = C; } // 0x10〜 else if(chip2<0x14){ nChip[0] = nChip[2] = D4; if(chip2 & 0x01) nChip[1] = C; if(chip2 & 0x02) nChip[3] = C; } // 0x14〜 else if(chip2<0x18){ nChip[0] = nChip[1] = D8; if(chip2 & 0x01) nChip[3] = C; if(chip2 & 0x02) nChip[2] = C; } // 0x18〜 else if(chip2<0x1C){ nChip[1] = nChip[3] = D6; if(chip2 & 0x01) nChip[2] = C; if(chip2 & 0x02) nChip[0] = C; } // 0x1C〜 else if(chip2<0x20){ nChip[2] = nChip[3] = D2; if(chip2 & 0x01) nChip[0] = C; if(chip2 & 0x02) nChip[1] = C; } else if(chip2==0x20){ nChip[0] = nChip[2] = D4; nChip[1] = nChip[3] = D6; } else if(chip2==0x21){ nChip[0] = nChip[1] = D8; nChip[2] = nChip[3] = D2; } else if(chip2<=0x23){ nChip[0] = nChip[1] = nChip[2] = nChip[3] = D7; if(chip2 & 0x01) nChip[3] = C; } else if(chip2<=0x25){ nChip[0] = nChip[1] = nChip[2] = nChip[3] = D9; if(chip2 & 0x01) nChip[2] = C; } else if(chip2<=0x27){ nChip[0] = nChip[1] = nChip[2] = nChip[3] = D3; if(chip2 & 0x01) nChip[0] = C; } else if(chip2<=0x29){ nChip[0] = nChip[1] = nChip[2] = nChip[3] = D1; if(chip2 & 0x01) nChip[1] = C; } else if(chip2==0x2A){ nChip[0] = nChip[2] = D7; nChip[1] = nChip[3] = D9; } else if(chip2==0x2B){ nChip[0] = nChip[1] = D7; nChip[2] = nChip[3] = D1; } else if(chip2==0x2C){ nChip[0] = nChip[2] = D1; nChip[1] = nChip[3] = D3; } else if(chip2==0x2D){ nChip[0] = nChip[1] = D9; nChip[2] = nChip[3] = D3; } // else if(chip2==0x2E){ else{ nChip[0] = D7; nChip[1] = D9; nChip[2] = D1; nChip[3] = D3; } // チップを描画 int cacheIndex = GetChipCacheIndex(chip, 0); if (cacheIndex >= 0) { cx = cacheIndex % (chipCacheTexture_.getWidth() / CHIP_SIZE); cy = cacheIndex / (chipCacheTexture_.getWidth() / CHIP_SIZE); texInfoSet.info[0].texcoord[0].set((float)(cx << 4) / chipCacheTexture_.getWidth(), (float)(cy << 4) / chipCacheTexture_.getHeight()); texInfoSet.info[0].texcoord[1] = texInfoSet.info[0].texcoord[0] + cacheSize; texInfoSet.info[0].texture = &chipCacheTexture_; texInfoSet.size++; return true; } cacheIndex = GetEmptyChipCacheIndex(); int destX = 0, destY = 0; if (cacheIndex >= 0) { destX = cacheIndex % (chipCacheTexture_.getWidth() / CHIP_SIZE) * CHIP_SIZE; destY = cacheIndex / (chipCacheTexture_.getWidth() / CHIP_SIZE) * CHIP_SIZE; } for(i = 0; i < 4; i++){ if (cacheIndex >= 0) { int x = ( (base_cx+nOffset2[nChip[i]][0])<<4 ) + nOffset[i][0]; int y = ( (base_cy+nOffset2[nChip[i]][1])<<4 ) + nOffset[i][1]; for (int j = 0; j < 8; j++) { char* destPtr = chipCacheTexture_.getData() + (destX + nOffset[i][0]) * 4 + ((j + destY + nOffset[i][1]) * chipCacheTexture_.getWidth() * 4); const char* srcPtr = imgChipSet.getData() + x * 4 + ((j + y) * imgChipSet.getWidth() * 4); std::memcpy(destPtr, srcPtr, 8 * 4); } } else { int x = ( (base_cx+nOffset2[nChip[i]][0])<<4 ) + nOffset[i][0]; int y = ( (base_cy+nOffset2[nChip[i]][1])<<4 ) + nOffset[i][1]; //img.Blt(imgChipSet, nOffset[i][0], nOffset[i][1], x, y, CHIP_SIZE>>1, CHIP_SIZE>>1, false); texInfoSet.info[i].texcoord[0].set((float)(x) / imgChipSet.getWidth(), (float)(y) / imgChipSet.getHeight()); texInfoSet.info[i].texcoord[1] = texInfoSet.info[i].texcoord[0] + size * 0.5f; texInfoSet.info[i].texture = &imgChipSet; texInfoSet.size++; } } if (cacheIndex >= 0) { chipCacheTexture_.updateImage(); texInfoSet.info[0].texcoord[0].set((float)(destX) / chipCacheTexture_.getWidth(), (float)(destY) / chipCacheTexture_.getHeight()); texInfoSet.info[0].texcoord[1] = texInfoSet.info[0].texcoord[0] + cacheSize; texInfoSet.info[0].texture = &chipCacheTexture_; texInfoSet.size++; chipCache_[cacheIndex].chipID = chip; chipCache_[cacheIndex].animeCount = 0; return true; } return true; } // 5000〜 else{ // ブロックE・標準チップ GetChipPos(chip, false, &cx, &cy); } // cx,cyを座標として採用する(4分割しないチップ) //img.Blt(imgChipSet, 0, 0, cx<<4, cy<<4, CHIP_SIZE, CHIP_SIZE, false); texInfoSet.info[0].texcoord[0].set((float)(cx << 4) / imgChipSet.getWidth(), (float)(cy << 4) / imgChipSet.getHeight()); texInfoSet.info[0].texcoord[1] = texInfoSet.info[0].texcoord[0] + size; texInfoSet.info[0].texture = &imgChipSet; texInfoSet.size++; return true; }
//////////////////////////////////////////////////// // Cache processing void EQPacketStream::processCache() { #if defined(PACKET_CACHE_DIAG) seqDebug("SEQ: START checking stream %s cache, arq %04x, cache count %04d", EQStreamStr[m_streamid], m_arqSeqExp, m_cache.size()); #endif EQPacketMap::iterator it; EQPacketMap::iterator eraseIt; EQProtocolPacket* packet; // check if the cache has grown large enough that we should give up // on seeing the current serverArqSeqExp // // If people see this a lot, they either have pathetic network cards, or // are having problems keeping up with packets (slow computer? Too much // net traffic?). Some possible solutions to this are to turn on session // tracking to filter out more PF_PACKET packets from getting passed out of // the kernel and to up the socket receive buffer sizes. See FAQ for // more information. if (m_cache.size() >= m_arqSeqGiveUp) { // ok, if the expected server arq sequence isn't here yet, give up // attempt to find the current expencted arq seq it = m_cache.find(m_arqSeqExp); // keep trying to find a new serverArqSeqExp if we haven't found a good // one yet... while(it == m_cache.end()) { seqWarn("SEQ: Giving up on finding arq %04x in stream %s cache, skipping!", m_arqSeqExp, EQStreamStr[m_streamid]); // incremente the expected arq sequence number m_arqSeqExp++; emit seqExpect(m_arqSeqExp, (int)m_streamid); // attempt to find the new current expencted arq seq it = m_cache.find(m_arqSeqExp); } } else { // haven't given up yet, just try to find the current serverArqSeqExp // attempt to find the current expected ARQ seq it = m_cache.find(m_arqSeqExp); } // iterate over cache until we reach the end or run out of // immediate followers while (it != m_cache.end()) { // get the PacketFormat for the iterator packet = it->second; // make sure this is the expected packet // (we might have incremented to the one after the one returned // by find above). if (packet->arqSeq() != m_arqSeqExp) break; #ifdef PACKET_CACHE_DIAG seqDebug("SEQ: found next arq %04x in stream %s cache, cache count %04d", m_arqSeqExp, EQStreamStr[m_streamid], m_cache.size()); #endif // validate the packet with a crc check. If the packet is for an old // session, we probably shouldn't be using it! #ifdef APPLY_CRC_CHECK if (packet->hasCRC() && packet->crc() != calculateCRC(*packet)) { #if defined (PACKET_CACHE_DIAG) // Something's screwed up seqDebug("SEQ: INVALID PACKET: Bad CRC in packet in stream %s cache with arq %04x! Droping it, but leaving expected seq as %04x", EQStreamStr[m_streamid], packet->arqSeq(), m_arqSeqExp); #endif // Need to drop from the cache eraseIt = it; // increment the current position iterator it++; // erase the packet from the cache m_cache.erase(eraseIt); emit cacheSize(m_cache.size(), (int)m_streamid); #ifdef PACKET_CACHE_DIAG seqDebug("SEQ: REMOVING arq %04x from stream %s cache, cache count %04d", packet->arqSeq(), EQStreamStr[m_streamid], m_cache.size()); #endif // delete the packet delete packet; // No sense looping some more. break; } else #endif /* APPLY_CRC_CHECK */ { #if defined (PACKET_CACHE_DIAG) && (PACKET_CACHE_DIAG > 2) seqDebug("SEQ: Found next arq in stream %s cache, incrementing arq seq, %04x", EQStreamStr[m_streamid], packet->arqSeq()); #endif // Process the packet since it's next in the sequence and was just // received out of order processPacket(*packet, packet->isSubpacket()); // Need to drop from the cache eraseIt = it; // increment the current position iterator it++; // erase the packet from the cache m_cache.erase(eraseIt); emit cacheSize(m_cache.size(), (int)m_streamid); #ifdef PACKET_CACHE_DIAG seqDebug("SEQ: REMOVING arq %04x from stream %s cache, cache count %04d", packet->arqSeq(), EQStreamStr[m_streamid], m_cache.size()); #endif // delete the packet delete packet; if (m_arqSeqExp == 0) it = m_cache.begin(); } } #ifdef PACKET_CACHE_DIAG seqDebug("SEQ: FINISHED checking stream %s cache, arq %04x, cache count %04d", EQStreamStr[m_streamid], m_arqSeqExp, m_cache.size()); #endif }
// ----------------------------------------------------------------------------- // CHttpCacheManager::CreateCacheHandlersL // // ----------------------------------------------------------------------------- // void CHttpCacheManager::CreateCacheHandlersL() { // get our SID. RProcess process; TSecureId secId = process.SecureId(); TUint32 secIdInt = secId; CRepository* repository = CRepository::NewLC(KCRUidCacheManager); CRepository* repositoryDiskLevel = CRepository::NewLC(KCRUidDiskLevel); // Get Cache Postpone Parameters. THttpCachePostponeParameters postpone; TBool newCentrepPresent; GetPostponeParamsL( newCentrepPresent, postpone, repository ); // apply default cache configuration - no cache for anyone, sizes set to default. iCacheEnabled = EFalse; TInt cacheSize( KDefaultCacheSize ); iCacheFolder.Copy( KDefaultCacheDir ); TBool opCacheEnabled( EFalse ); iOperatorCache = 0; TInt opCacheSize = KDefaultOperatorCacheSize; TFileName opCacheFolder( KDefaultOperatorCacheDir ); iVSSCacheEnabled = EFalse; TInt vssCacheSize = KDefaultOperatorCacheSize; TFileName vssCacheFolder( KDefaultVssCacheDir ); if(newCentrepPresent) { // if the new Centrep file is present, we trust it's configured properly. GetHttpCacheConfigL( *repository, iCacheEnabled, cacheSize, iCacheFolder ); GetOperatorCacheConfigL( *repository, opCacheEnabled, opCacheSize, opCacheFolder ); GetVSSCacheConfigL( *repository, iVSSCacheEnabled, vssCacheSize, vssCacheFolder ); } // look for per-process overrides in central repository. Do this before we get drive critical levels so we're on the right // drive. // This has a default string which applies the new per-client default configuration ApplyCacheOverridesL(*repository, secIdInt, iCacheEnabled, cacheSize, opCacheEnabled, iVSSCacheEnabled, iCacheFolder, KDefaultCacheDrive()); TInt criticalLevel = 0; GetCriticalDriveLevelsL( *repositoryDiskLevel, iCacheFolder, criticalLevel ); // Create any caches we should be using. if (iCacheEnabled) { CreateHttpCacheL( secIdInt, cacheSize, criticalLevel, postpone ); if (opCacheEnabled) { CreateOperatorCacheL( *repository, opCacheFolder, opCacheSize, criticalLevel, postpone ); } } //end if( iCacheEnabled ) if ( iVSSCacheEnabled ) { CreateVssCacheL( *repository, vssCacheFolder, vssCacheSize, criticalLevel, postpone ); } CleanupStack::PopAndDestroy(2); // repository, repositoryDiskLevel CrashCheckL( secIdInt ); }
//////////////////////////////////////////////////// // Cache processing void EQPacketStream::processCache() { #if defined(PACKET_CACHE_DIAG) seqDebug("SEQ: START checking stream %s cache, arq %04x, cache count %04d", EQStreamStr[m_streamid], m_arqSeqExp, m_cache.size()); #endif EQPacketMap::iterator it; EQPacketMap::iterator eraseIt; EQPacketFormat* pf; // check if the cache has grown large enough that we should give up // on seeing the current serverArqSeqExp // this should really only kick in for people with pathetic // network cards that missed the packet. if (m_cache.size() >= m_arqSeqGiveUp) { // ok, if the expected server arq sequence isn't here yet, give up // attempt to find the current expencted arq seq it = m_cache.find(m_arqSeqExp); // keep trying to find a new serverArqSeqExp if we haven't found a good // one yet... while(it == m_cache.end()) { seqDebug("SEQ: Giving up on finding arq %04x in stream %s cache, skipping!", m_arqSeqExp, EQStreamStr[m_streamid]); // incremente the expected arq sequence number m_arqSeqExp++; emit seqExpect(m_arqSeqExp, (int)m_streamid); // attempt to find the new current expencted arq seq it = m_cache.find(m_arqSeqExp); } } else { // haven't given up yet, just try to find the current serverArqSeqExp // attempt to find the current expected ARQ seq it = m_cache.find(m_arqSeqExp); } // iterate over cache until we reach the end or run out of // immediate followers while (it != m_cache.end()) { // get the PacketFormat for the iterator pf = it->second; // make sure this is the expected packet // (we might have incremented to the one after the one returned // by find above). if (pf->arq() != m_arqSeqExp) break; #ifdef PACKET_CACHE_DIAG seqDebug("SEQ: found next arq %04x in stream %s cache, cache count %04d", m_arqSeqExp, EQStreamStr[m_streamid], m_cache.size()); #endif #if defined (PACKET_CACHE_DIAG) && (PACKET_CACHE_DIAG > 2) // validate the packet against a memory corruption if (!pf->isValid()) { // Something's screwed up seqDebug("SEQ: INVALID PACKET: Bad CRC32 in packet in stream %s cache with arq %04x!", EQStreamStr[m_streamid], pf->arq()); } #endif #if defined (PACKET_CACHE_DIAG) && (PACKET_CACHE_DIAG > 2) seqDebug("SEQ: Found next arq in stream %s cache, incrementing arq seq, %04x", EQStreamStr[m_streamid], pf->arq()); #endif // Duplicate ARQ processing functionality from dispatchPacket, // should prolly be its own function processARQ() or some such beast if (!pf->isASQ() && !pf->isFragment() && !pf->isClosingHi()) { // seems to be a sort of ping from client to server, has ARQ // but no ASQ, Flags look like 0x0201 (network byte order) #if defined (PACKET_CACHE_DIAG) && (PACKET_CACHE_DIAG > 2) seqDebug("SEQ: ARQ without ASQ from stream %s arq 0x%04x", EQStreamStr[m_streamid], pf->arq()); #endif } // since the servers do not care about client closing sequences, we won't either else if (pf->isClosingHi() && pf->isClosingLo() && (m_streamid == zone2client)) { #if defined (PACKET_CACHE_DIAG) && (PACKET_CACHE_DIAG > 2) seqDebug("EQPacketStream: Closing HI & LO, stream %s arq %04x", EQStreamStr[m_streamid], pf->arq()); #endif if (m_session_tracking_enabled) m_session_tracking_enabled = 1; emit closing(); break; } // if the packet isn't a fragment dispatch normally, otherwise to split else if (pf->isFragment()) processFragment(*pf); else processPayload(pf->payload(), pf->payloadLength()); eraseIt = it; // increment the current position iterator it++; // erase the packet from the cache m_cache.erase(eraseIt); emit cacheSize(m_cache.size(), (int)m_streamid); #ifdef PACKET_CACHE_DIAG seqDebug("SEQ: REMOVING arq %04x from stream %s cache, cache count %04d", pf->arq(), EQStreamStr[m_streamid], m_cache.size()); #endif // delete the packet delete pf; // increment the expected arq number m_arqSeqExp++; emit seqExpect(m_arqSeqExp, (int)m_streamid); if (m_arqSeqExp == 0) it = m_cache.begin(); } #ifdef PACKET_CACHE_DIAG seqDebug("SEQ: FINISHED checking stream %s cache, arq %04x, cache count %04d", EQStreamStr[m_streamid], m_arqSeqExp, m_cache.size()); #endif }
//////////////////////////////////////////////////// // Cache processing void EQPacketStream::processCache() { #if defined(PACKET_CACHE_DIAG) seqDebug("SEQ: START checking stream %s cache, arq %04x, cache count %04d", EQStreamStr[m_streamid], m_arqSeqExp, m_cache.size()); #endif EQPacketMap::iterator it; EQPacketMap::iterator eraseIt; EQProtocolPacket* packet; // check if the cache has grown large enough that we should give up // on seeing the current serverArqSeqExp // this should really only kick in for people with pathetic // network cards that missed the packet. if (m_cache.size() >= m_arqSeqGiveUp) { // ok, if the expected server arq sequence isn't here yet, give up // attempt to find the current expencted arq seq it = m_cache.find(m_arqSeqExp); // keep trying to find a new serverArqSeqExp if we haven't found a good // one yet... while(it == m_cache.end()) { seqDebug("SEQ: Giving up on finding arq %04x in stream %s cache, skipping!", m_arqSeqExp, EQStreamStr[m_streamid]); // incremente the expected arq sequence number m_arqSeqExp++; emit seqExpect(m_arqSeqExp, (int)m_streamid); // attempt to find the new current expencted arq seq it = m_cache.find(m_arqSeqExp); } } else { // haven't given up yet, just try to find the current serverArqSeqExp // attempt to find the current expected ARQ seq it = m_cache.find(m_arqSeqExp); } // iterate over cache until we reach the end or run out of // immediate followers while (it != m_cache.end()) { // get the PacketFormat for the iterator packet = it->second; // make sure this is the expected packet // (we might have incremented to the one after the one returned // by find above). if (packet->arqSeq() != m_arqSeqExp) break; #ifdef PACKET_CACHE_DIAG seqDebug("SEQ: found next arq %04x in stream %s cache, cache count %04d", m_arqSeqExp, EQStreamStr[m_streamid], m_cache.size()); #endif #if defined (PACKET_CACHE_DIAG) && (PACKET_CACHE_DIAG > 2) // validate the packet against a memory corruption if (!packet->isValid()) { // Something's screwed up seqDebug("SEQ: INVALID PACKET: Bad CRC in packet in stream %s cache with arq %04x!", EQStreamStr[m_streamid], packet->arqSeq()); } #endif #if defined (PACKET_CACHE_DIAG) && (PACKET_CACHE_DIAG > 2) seqDebug("SEQ: Found next arq in stream %s cache, incrementing arq seq, %04x", EQStreamStr[m_streamid], packet->arqSeq()); #endif // Process the packet since it's next in the sequence and was just // received out of order processPacket(*packet, packet->isSubpacket()); // Need to drop from the cache eraseIt = it; // increment the current position iterator it++; // erase the packet from the cache m_cache.erase(eraseIt); emit cacheSize(m_cache.size(), (int)m_streamid); #ifdef PACKET_CACHE_DIAG seqDebug("SEQ: REMOVING arq %04x from stream %s cache, cache count %04d", packet->arqSeq(), EQStreamStr[m_streamid], m_cache.size()); #endif // delete the packet delete packet; if (m_arqSeqExp == 0) it = m_cache.begin(); } #ifdef PACKET_CACHE_DIAG seqDebug("SEQ: FINISHED checking stream %s cache, arq %04x, cache count %04d", EQStreamStr[m_streamid], m_arqSeqExp, m_cache.size()); #endif }