void Matrix4::identity() { loadBase( {1.0, 0.0, 0.0, 0.0}, {0.0, 1.0, 0.0, 0.0}, {0.0, 0.0, 1.0, 0.0}, {0.0, 0.0, 0.0, 1.0} ); }
// Loads the map into the memory bool CVorticonMapLoaderBase::load( Uint8 episode, Uint8 level, const std::string& path, bool loadNewMusic ) { std::vector<Uint16> planeitems; if( !loadBase( episode, level, path, loadNewMusic) ) { return false; } // Set Map Delegation Object and refresh whole level mpMap->drawAll(); gVideoDriver.updateScrollBuffer( mpMap->m_scrollx, mpMap->m_scrolly ); return true; }
int main() { int T, total_score; setbuf(stdout, NULL); //freopen("sample_input.txt", "r", stdin); scanf("%d", &T); loadBase(); total_score = 0; for (int testcase = 1; testcase <= T; ++testcase) { init_m(); run(); printf("#%d %d\n", testcase, point); if (point == expected) total_score++; } printf("total score = %d\n", total_score * 100 / T); return 0; }
void Game::createScene() { mRegistry = new Registry(); //创建Geometry单一对象Singleton mGettextManager = new GettextManager(); mGeometry = new Geometry(); mObjectFactory = new ObjectFactory(); //创建RigidManager单一对象 mRigidManager = new RigidManager(); mRigidToolManager = new RigidToolManager(); mHotkeyManager = new HotkeyManager(); mLuaManager = new LuaManager(); mLuaC = new LuaControlet(); mLuaManager->setLuaLocation(""); for( LuaVector::iterator i = mPreLuaLocation.begin();i!=mPreLuaLocation.end();i++ ) { mLuaManager->addLuaLocation( *i ); } for( LuaVector::iterator j = mPreLuaScript.begin();j!=mPreLuaScript.end();j++ ) { mLuaManager->doFile( *j ); } for( LuaVector::iterator k = mPreLoad.begin();k!=mPreLoad.end();k++ ) { loadBase( *k ); } //打开阴影 setShadowTechnique( static_cast<Ogre::ShadowTechnique>( static_cast<int>(Ogre::SHADOWDETAILTYPE_STENCIL) | static_cast<int>(Ogre::SHADOWDETAILTYPE_MODULATIVE) ) ); if( mInfo ) mInfo->setVisible( false ); }
bool CVorticonMapLoaderWithPlayer::load( Uint8 episode, Uint8 level, const std::string& path, bool loadNewMusic, bool stategame ) { if( !loadBase( episode, level, path, loadNewMusic ) ) { return false; } if( !stategame ) { loadSprites(episode, level ); } // Set Map Delegation Object and refresh whole level mpMap->drawAll(); gVideoDriver.updateScrollBuffer( mpMap->m_scrollx, mpMap->m_scrolly ); return true; }
void ResAtlasGeneric::loadAtlas2(CreateResourceContext& context) { _current = 0; pugi::xml_node node = context.walker.getNode(); int w = node.attribute("width").as_int(defaultAtlasWidth); int h = node.attribute("height").as_int(defaultAtlasHeight); const char* format = node.attribute("format").as_string("8888"); loadBase(node); atlas_data ad; TextureFormat tf = string2TextureFormat(format); bool compressed = false; std::vector<ResAnim*> anims; while (true) { XmlWalker walker = context.walker.next(); if (walker.empty()) break; pugi::xml_node child_node = walker.getNode(); const char* name = child_node.name(); if (strcmp(name, "image")) continue; std::string id = child_node.attribute("id").value(); std::string file = child_node.attribute("file").value(); if (file.empty()) { createEmpty(walker, context); continue; } bool trim = child_node.attribute("trim").as_bool(true); bool extend = child_node.attribute("extend").as_bool(true); Point offset = extend ? Point(2, 2) : Point(0, 0); MemoryTexture mt; ImageData im; int columns = 0; int rows = 0; int frame_width = 0; int frame_height = 0; float frame_scale = 1.0f; bool loaded = false; file::buffer bf; file::read(walker.getPath("file"), bf); mt.init(bf, true, tf); im = mt.lock(); if (im.w) { rows = child_node.attribute("rows").as_int(); frame_width = child_node.attribute("frame_width").as_int(); columns = child_node.attribute("cols").as_int(); frame_height = child_node.attribute("frame_height").as_int(); if (!rows) rows = 1; if (!columns) columns = 1; if (frame_width) columns = im.w / frame_width; else frame_width = im.w / columns; if (frame_height) rows = im.h / frame_height; else frame_height = im.h / rows; } if (columns) { animationFrames frames; int frames_count = rows * columns; frames.reserve(frames_count); ResAnim* ra = new ResAnim(this); anims.push_back(ra); for (int y = 0; y < rows; ++y) { for (int x = 0; x < columns; ++x) { Rect frameRect; frameRect.pos = Point(x * frame_width, y * frame_height); frameRect.size = Point(frame_width, frame_height); ImageData srcImage_ = im.getRect(frameRect); HitTestData adata; ImageData src; Rect bounds(0, 0, im.w, im.h); if (trim) makeAlpha(srcImage_, bounds, _hitTestBuffer, adata, walker.getAlphaHitTest()); src = srcImage_.getRect(bounds); Rect dest(0, 0, 0, 0); if (!ad.texture) { std::string atlas_id = getName(); nextAtlas(w, h, tf, ad, atlas_id.c_str()); } bool s = ad.atlas.add(&ad.mt, src, dest, offset); if (s == false) { applyAtlas(ad, _linearFilter, _clamp2edge); nextAtlas(w, h, tf, ad, walker.getCurrentFolder().c_str()); s = ad.atlas.add(&ad.mt, src, dest, offset); OX_ASSERT(s); } //extend = false; if (extend) { //duplicate image edges MemoryTexture& mt = ad.mt; ImageData tmp; if (bounds.getY() == 0 && dest.pos.y != 0) { tmp = mt.lock(Rect(dest.pos.x, dest.pos.y - 1, src.w, 1)); operations::copy(src.getRect(Rect(0, 0, src.w, 1)), tmp); } if (bounds.getHeight() == im.h && dest.getBottom() != mt.getHeight()) { tmp = mt.lock(Rect(dest.pos.x, dest.pos.y + src.h, src.w, 1)); operations::copy(src.getRect(Rect(0, src.h - 1, src.w, 1)), tmp); } if (bounds.getX() == 0 && dest.pos.x != 0) { tmp = mt.lock(Rect(dest.pos.x - 1, dest.pos.y, 1, src.h)); operations::copy(src.getRect(Rect(0, 0, 1, src.h)), tmp); } if (bounds.getWidth() == im.w && dest.getRight() != mt.getWidth()) { tmp = mt.lock(Rect(dest.pos.x + src.w, dest.pos.y, 1, src.h)); operations::copy(src.getRect(Rect(src.w - 1, 0, 1, src.h)), tmp); } } //operations::copy(src.getRect(Rect(0, 0, 1, 1)), mt.lock(&Rect(dest.pos.x - 1, dest.pos.y - 1, 1, 1))); //operations::copy(src.getRect(Rect(src.w - 1, 0, 1, 1)), mt.lock(&Rect(dest.pos.x + src.w, dest.pos.y - 1, 1, 1))); //operations::copy(src.getRect(Rect(0, src.h - 1, 1, 1)), mt.lock(&Rect(dest.pos.x - 1, dest.pos.y + src.h, 1, 1))); //operations::copy(src.getRect(Rect(src.w - 1, src.h - 1, 1, 1)), mt.lock(&Rect(dest.pos.x + src.w, dest.pos.y + src.h, 1, 1))); float iw = 1.0f; float ih = 1.0f; RectF srcRect(dest.pos.x * iw, dest.pos.y * ih, dest.size.x * iw, dest.size.y * ih); Vector2 sizeScaled = Vector2((float)dest.size.x, (float)dest.size.y) * walker.getScaleFactor(); RectF destRect(bounds.pos.cast<Vector2>(), sizeScaled); AnimationFrame frame; Diffuse df; df.base = ad.texture; df.premultiplied = true;//!Renderer::getPremultipliedAlphaRender(); Vector2 fsize = Vector2((float)frame_width, (float)frame_height) * walker.getScaleFactor(); frame.init2(ra, x, y, df, srcRect, destRect, fsize); frame.setHitTestData(adata); frames.push_back(frame); } } init_resAnim(ra, file, child_node); ra->init(frames, columns, walker.getScaleFactor(), 1.0f / walker.getScaleFactor()); ra->setParent(this); context.resources->add(ra, context.options->_shortenIDS); } } applyAtlas(ad, _linearFilter, _clamp2edge); for (std::vector<ResAnim*>::iterator i = anims.begin(); i != anims.end(); ++i) { ResAnim* rs = *i; int num = rs->getTotalFrames(); for (int n = 0; n < num; ++n) { AnimationFrame& frame = const_cast<AnimationFrame&>(rs->getFrame(n)); float iw = 1.0f / frame.getDiffuse().base->getWidth(); float ih = 1.0f / frame.getDiffuse().base->getHeight(); RectF rect = frame.getSrcRect(); rect.pos.x *= iw; rect.pos.y *= ih; rect.size.x *= iw; rect.size.y *= ih; frame.setSrcRect(rect); HitTestData ad = frame.getHitTestData(); if (ad.pitch) { ad.data = &_hitTestBuffer[reinterpret_cast<size_t>(ad.data)]; frame.setHitTestData(ad); } } } }
void BaseManager::setupResources() { loadBase(mResourceXMLName,mPreLuaScript,mPreLuaLocation,mPreLoad); }
D2Data::D2Data() : itemTypes(DictionaryMap::alNum) , baseItems(DictionaryMap::alNum) , images(DictionaryMap::pathName) , fonts(DictionaryMap::pathName) { WideString path = cfg.getwstr("d2path"); if (path.empty()) path = getAppPath(); int loaded = !!loader.loadArchive(WideString::buildFullName(path, L"resources.mpq")); loaded += !!loader.loadArchive(WideString::buildFullName(path, L"d2data.mpq")); loaded += !!loader.loadArchive(WideString::buildFullName(path, L"d2exp.mpq")); loaded += !!loader.loadArchive(WideString::buildFullName(path, L"patch_d2.mpq")); if (!loaded) { path = getAppPath(); loaded = !!loader.loadArchive(WideString::buildFullName(path, L"resources.mpq")); } if (!loaded) return; cfg.setwstr("d2path", path); for (int f = 0; f < 10; f++) for (int t = 0; t < 21; t++) for (int i = 0; i < 256; i++) tints[f][t][i] = i; TempFile(loader.load("data\\global\\items\\Palette\\grey.dat"))->read(tints[1], 256 * 21); TempFile(loader.load("data\\global\\items\\Palette\\grey2.dat"))->read(tints[2], 256 * 21); TempFile(loader.load("data\\global\\items\\Palette\\gold.dat"))->read(tints[3], 256 * 21); TempFile(loader.load("data\\global\\items\\Palette\\brown.dat"))->read(tints[4], 256 * 21); TempFile(loader.load("data\\global\\items\\Palette\\greybrown.dat"))->read(tints[5], 256 * 21); TempFile(loader.load("data\\global\\items\\Palette\\invgrey.dat"))->read(tints[6], 256 * 21); TempFile(loader.load("data\\global\\items\\Palette\\invgrey2.dat"))->read(tints[7], 256 * 21); TempFile(loader.load("data\\global\\items\\Palette\\invgreybrown.dat"))->read(tints[8], 256 * 21); LocalPtr<File> pal = loader.load("data\\global\\palette\\ACT1\\pal.dat"); for (int i = 0; i < 256; i++) { int b = pal->getc(), g = pal->getc(), r = pal->getc();//, a = pal->getc(); palette[i] = Image::clr(r, g, b); } memset(textColor, 0xFF, sizeof textColor); { LocalPtr<File> pl2 = loader.load("data\\global\\palette\\ACT1\\Pal.PL2"); pl2->seek(1024 + 49 * 256, SEEK_SET); pl2->read(blendTable, sizeof blendTable); pl2->seek(1024 + 1714 * 256, SEEK_SET); for (int i = 0; i < 13; i++) { int r = pl2->getc(), g = pl2->getc(), b = pl2->getc(); textColor[i] = Image::clr(r, g, b); } pl2->seek(256, SEEK_CUR); for (int i = 1; i < 13; i++) pl2->read(tints[9][i], 256); } strings.load(TempFile(loader.load("data\\local\\lng\\eng\\string.tbl")), 0); strings.load(TempFile(loader.load("data\\local\\lng\\eng\\expansionstring.tbl")), 20000); strings.load(TempFile(loader.load("data\\local\\lng\\eng\\patchstring.tbl")), 10000); rootType.name = "All Items"; loadTypes(TempFile(loader.load("data\\global\\excel\\ItemTypes.txt"))); loadBase(TempFile(loader.load("data\\global\\excel\\weapons.txt"))); loadBase(TempFile(loader.load("data\\global\\excel\\armor.txt"))); loadBase(TempFile(loader.load("data\\global\\excel\\misc.txt"))); baseMatch.build(); itemTypes.get("h2h2").bases = 0; itemTypes.get("mcha").name = strings.byIndex(20436); itemTypes.get("lcha").name = strings.byIndex(20437); itemTypes.get("ques").setType(D2Item::tMisc, 0, 0); itemTypes.get("key").setType(D2Item::tMisc, 0, 0); itemTypes.get("weap").setType(D2Item::tAuto, 0); itemTypes.get("armo").setType(D2Item::tAuto, 1); itemTypes.get("ring").setType(D2Item::tAuto, 2); itemTypes.get("amul").setType(D2Item::tAuto, 2); itemTypes.get("char").setType(D2Item::tCharm, 0); itemTypes.get("gem").setType(D2Item::tSocket, 0, 0); itemTypes.get("rune").setType(D2Item::tSocket, 1, 0); itemTypes.get("jewl").setType(D2Item::tSocket, 2); for (uint32 cur = baseItems.enumStart(); cur; cur = baseItems.enumNext(cur)) { D2BaseItem* base = &baseItems.enumGetValue(cur); while (base->type && base->type->bases == 0) base->type = base->type->parent; } mergeType(&rootType); { D2Excel table(TempFile(loader.load("data\\global\\excel\\PlayerClass.txt"))); int id = 0; for (int i = 0; i < table.rows(); i++) { if (!*table.value(i, 1)) continue; charClass.set(table.value(i, 1), id); classNames[id] = strings.byName(table.value(i, 0)); id++; } } statData = new D2StatData(this); loadUnique(); loadGems(); loadBackground(); LocalPtr<mpq::ListFile> list = loader.buildListFile(); list->sort(); for (uint32 cur = baseItems.enumStart(); cur; cur = baseItems.enumNext(cur)) unpack(&loader, list, baseItems.enumGetValue(cur).invfile); for (uint32 cur = itemTypes.enumStart(); cur; cur = itemTypes.enumNext(cur)) { D2ItemType& type = itemTypes.enumGetValue(cur); for (int i = 0; i < type.invgfx.length(); i++) unpack(&loader, list, type.invgfx[i]); } for (int i = 0; i < uniqueItems.length(); i++) unpack(&loader, list, uniqueItems[i]->invfile); }