VOID KG3DBaseCoordImp::RenderIntersectMesh(RepresentData& RpData, const D3DXMATRIX& matView, const D3DXMATRIX& matProj) { //检查其它Drawer是否正确 #if 0 g_CheckFrameDrawers(RpData.vecPos, GetSelectorRingRadius(RpData)); #endif GraphicsStruct::RenderState rs1(D3DRS_AMBIENT, 0xffffffff); GraphicsStruct::RenderState rs2(D3DRS_ZENABLE, D3DZB_FALSE); GraphicsStruct::RenderState rs3(D3DRS_ALPHABLENDENABLE, TRUE); GraphicsStruct::RenderState rs4(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); GraphicsStruct::RenderState rs5(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); GraphicsStruct::RenderState rs6(D3DRS_CULLMODE, D3DCULL_NONE); GraphicsStruct::RenderState rs7(D3DRS_SPECULARENABLE, TRUE); GraphicsStruct::RenderState rs8(D3DRS_FILLMODE, D3DFILL_SOLID); GraphicsStruct::RenderState rs9(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); GraphicsStruct::SaveMatrix SaveWorld(D3DTS_WORLD); GraphicsStruct::SaveMatrix SaveView(D3DTS_VIEW); GraphicsStruct::SaveMatrix SaveProj(D3DTS_PROJECTION); g_pd3dDevice->SetTransform(D3DTS_VIEW, &matView); g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &matProj); GraphicsStruct::TextureStageState tssColorOp0(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); GraphicsStruct::TextureStageState tssColorOp1(1, D3DTSS_COLOROP, D3DTOP_DISABLE); GraphicsStruct::TextureStageState tssColorArg0(0, D3DTSS_COLORARG1, D3DTA_TFACTOR); GraphicsStruct::TextureStageState tssAlphaOp0(0,D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); GraphicsStruct::TextureStageState tssAlphaArg1(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR); g_pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR, 0xffffffff); D3DXMATRIX matUse; { D3DXMATRIX vMatScaling; FLOAT fScale = GetSelectorRingRadius(RpData) / em_mesh_range; D3DXMatrixScaling(&vMatScaling, fScale, fScale, fScale); D3DXMATRIX vMatTrans; D3DXMatrixTranslation(&vMatTrans, RpData.vecPos.x, RpData.vecPos.y, RpData.vecPos.z); matUse = vMatScaling * vMatTrans; } g_pd3dDevice->SetTransform(D3DTS_WORLD, &matUse); _ASSERTE(_countof(RpData.MeshForAxis) == _countof(RpData.MeshForPlane)); for (size_t i = 0; i < _countof(RpData.MeshForAxis); ++i) { if(NULL != RpData.MeshForAxis[i]) RpData.MeshForAxis[i]->DrawSubset(0); if(NULL != RpData.MeshForPlane[i]) RpData.MeshForPlane[i]->DrawSubset(0); } if(NULL != RpData.MeshForIntegration) RpData.MeshForIntegration->DrawSubset(0); }
TEST(RangeTest, max) { Ranges rs("199"); EXPECT_EQ(rs.max(), 199); Ranges rs1("1, 10000, 10-30, 4000-5000"); EXPECT_EQ(rs1.max(), 10000); Ranges rs2("1, 1000, 10-30, 4000-5000, 633-877"); EXPECT_EQ(rs2.max(), 5000); }
int main () { std::vector<Point> points; //use the stair example for testing load_xy_file_points<Point>("data/stair-noise00.xy", points); for (std::size_t i = 1 ; i <= points.size() ; i += 20) { CGAL::Reconstruction_simplification_2<K> rs2(points); rs2.run_until(i); rs2.print_stats_debug(); assert(rs2.number_of_vertices() == i); } }
TEST( RocksRecordStoreTest, TwoCollections ) { unittest::TempDir td( _rocksRecordStoreTestDir ); scoped_ptr<rocksdb::DB> db( getDB( td.path() ) ); rocksdb::ColumnFamilyHandle* cf1; rocksdb::ColumnFamilyHandle* cf2; rocksdb::ColumnFamilyHandle* cf1_m; rocksdb::ColumnFamilyHandle* cf2_m; rocksdb::Status status; status = db->CreateColumnFamily( rocksdb::ColumnFamilyOptions(), "foo.bar1", &cf1 ); ASSERT_OK( toMongoStatus( status ) ); status = db->CreateColumnFamily( rocksdb::ColumnFamilyOptions(), "foo.bar2", &cf2 ); ASSERT_OK( toMongoStatus( status ) ); status = db->CreateColumnFamily( rocksdb::ColumnFamilyOptions(), "foo.bar1&", &cf1_m ); ASSERT_OK( toMongoStatus( status ) ); status = db->CreateColumnFamily( rocksdb::ColumnFamilyOptions(), "foo.bar2&", &cf2_m ); ASSERT_OK( toMongoStatus( status ) ); RocksRecordStore rs1( "foo.bar1", db.get(), cf1, cf1_m ); RocksRecordStore rs2( "foo.bar2", db.get(), cf2, cf2_m ); DiskLoc a; DiskLoc b; { MyOperationContext opCtx( db.get() ); WriteUnitOfWork uow( opCtx.recoveryUnit() ); StatusWith<DiskLoc> result = rs1.insertRecord( &opCtx, "a", 2, -1 ); ASSERT_OK( result.getStatus() ); a = result.getValue(); result = rs2.insertRecord( &opCtx, "b", 2, -1 ); ASSERT_OK( result.getStatus() ); b = result.getValue(); } ASSERT_EQUALS( a, b ); ASSERT_EQUALS( string("a"), rs1.dataFor( a ).data() ); ASSERT_EQUALS( string("b"), rs2.dataFor( b ).data() ); delete cf2; delete cf1; }
template<typename MatrixType> void schur(int size = MatrixType::ColsAtCompileTime) { // Test basic functionality: T is quasi-triangular and A = U T U* for(int counter = 0; counter < g_repeat; ++counter) { MatrixType A = MatrixType::Random(size, size); RealSchur<MatrixType> schurOfA(A); VERIFY_IS_EQUAL(schurOfA.info(), Success); MatrixType U = schurOfA.matrixU(); MatrixType T = schurOfA.matrixT(); verifyIsQuasiTriangular(T); VERIFY_IS_APPROX(A, U * T * U.transpose()); } // Test asserts when not initialized RealSchur<MatrixType> rsUninitialized; VERIFY_RAISES_ASSERT(rsUninitialized.matrixT()); VERIFY_RAISES_ASSERT(rsUninitialized.matrixU()); VERIFY_RAISES_ASSERT(rsUninitialized.info()); // Test whether compute() and constructor returns same result MatrixType A = MatrixType::Random(size, size); RealSchur<MatrixType> rs1; rs1.compute(A); RealSchur<MatrixType> rs2(A); VERIFY_IS_EQUAL(rs1.info(), Success); VERIFY_IS_EQUAL(rs2.info(), Success); VERIFY_IS_EQUAL(rs1.matrixT(), rs2.matrixT()); VERIFY_IS_EQUAL(rs1.matrixU(), rs2.matrixU()); // Test computation of only T, not U RealSchur<MatrixType> rsOnlyT(A, false); VERIFY_IS_EQUAL(rsOnlyT.info(), Success); VERIFY_IS_EQUAL(rs1.matrixT(), rsOnlyT.matrixT()); VERIFY_RAISES_ASSERT(rsOnlyT.matrixU()); if (size > 2) { // Test matrix with NaN A(0,0) = std::numeric_limits<typename MatrixType::Scalar>::quiet_NaN(); RealSchur<MatrixType> rsNaN(A); VERIFY_IS_EQUAL(rsNaN.info(), NoConvergence); } }
bool SegmentationShrinkRegionAutoTest(int width, int height, const FuncSR & f1, const FuncSR & f2) { bool result = true; TEST_LOG_SS(Info, "Test " << f1.description << " & " << f2.description << " for size [" << width << "," << height << "]."); const uint8_t index = 3; View s(width, height, View::Gray8, NULL, TEST_ALIGN(width)); Rect rs1(s.Size()), rs2(s.Size()), rd1, rd2; FillRhombMask(s, Rect(width*1/15, height*2/15, width*11/15, height*12/15), index); TEST_EXECUTE_AT_LEAST_MIN_TIME(f1.Call(s, index, rs1, rd1)); TEST_EXECUTE_AT_LEAST_MIN_TIME(f2.Call(s, index, rs2, rd2)); result = result && Compare(rd1, rd2, true); return result; }
int main () { PointMassList points; //use the stair example for testing load_xy_file<PointMassList, Point>("data/stair-noise00.xy", points); Point_property_map point_pmap; Mass_property_map mass_pmap; CGAL::Reconstruction_simplification_2<K, Point_property_map, Mass_property_map> rs2(points, point_pmap, mass_pmap); rs2.run_until(9); std::cout << "Total_edge_cost: "<< rs2.total_edge_cost() << std::endl; assert(rs2.total_edge_cost() < 0.3); assert(0 < rs2.total_edge_cost()); rs2.print_stats_debug(); }
bool SegmentationShrinkRegionDataTest(bool create, int width, int height, const FuncSR & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View s(width, height, View::Gray8, NULL, TEST_ALIGN(width)); Rect rs1(s.Size()), rs2(s.Size()), rd1, rd2; const uint8_t index = 3; if(create) { FillRhombMask(s, Rect(width*1/15, height*2/15, width*11/15, height*12/15), index); TEST_SAVE(s); f.Call(s, index, rs1, rd1); TEST_SAVE(rd1); } else { TEST_LOAD(s); TEST_LOAD(rd1); f.Call(s, index, rs2, rd2); TEST_SAVE(rd2); result = result && Compare(rd1, rd2, true); } return result; }
inline void Assembler::jmpl( Register s1, Register s2, Register d ) { insert_nop_after_cbcond(); cti(); emit_int32( op(arith_op) | rd(d) | op3(jmpl_op3) | rs1(s1) | rs2(s2)); has_delay_slot(); }
inline void Assembler::flush( Register s1, Register s2) { emit_int32( op(arith_op) | op3(flush_op3) | rs1(s1) | rs2(s2)); }
// compare and branch inline void Assembler::cbcond(Condition c, CC cc, Register s1, Register s2, Label& L) { cti(); no_cbcond_before(); emit_data(op(branch_op) | cond_cbcond(c) | op2(bpr_op2) | branchcc(cc) | wdisp10(intptr_t(target(L)), intptr_t(pc())) | rs1(s1) | rs2(s2)); }
inline void Assembler::add(Register s1, Register s2, Register d ) { emit_int32( op(arith_op) | rd(d) | op3(add_op3) | rs1(s1) | rs2(s2) ); }
inline void Assembler::swap( Register s1, Register s2, Register d) { v9_dep(); emit_int32( op(ldst_op) | rd(d) | op3(swap_op3) | rs1(s1) | rs2(s2) ); }
inline void Assembler::std( Register d, Register s1, Register s2) { v9_dep(); assert(d->is_even(), "not even"); emit_int32( op(ldst_op) | rd(d) | op3(std_op3) | rs1(s1) | rs2(s2) ); }
void test_edge_collapse() { std::cerr << "test_edge_collapse" << std::endl; PointMassList points; //use the stair example for testing load_xy_file<PointMassList, Point>("data/stair-noise00.xy", points); Point_property_map point_pmap; Mass_property_map mass_pmap; CGAL::Reconstruction_simplification_2<K, Point_property_map, Mass_property_map> rs2(points, point_pmap, mass_pmap); Rt_2 rt2; rs2.extract_tds_output(rt2); FT min_priority = 1000; R_edge_2 contract_edge; for (Finite_edges_iterator ei = rt2.finite_edges_begin(); ei != rt2.finite_edges_end(); ++ei) { R_edge_2 cur_r_edge; if(!rs2.create_pedge(*ei, cur_r_edge)) continue; print_edge(cur_r_edge); if (cur_r_edge.priority() < min_priority && cur_r_edge.priority() > 0) { min_priority = cur_r_edge.priority(); contract_edge = cur_r_edge; } } R_edge_2 pedge; rs2.pick_edge(0, pedge); std::cout << "--------" << std::endl; print_edge(contract_edge); print_edge(pedge); std::cout << "--------" << std::endl; //test that the right edge was picked for collapsing // N.B.: it can be two different edges if several edges have the same // priority value. assert(CGAL::abs(pedge.priority() - contract_edge.priority()) < pedge.priority()*1e-13); rs2.do_collapse(contract_edge.edge()); bool found = false; for (Finite_edges_iterator ei = rt2.finite_edges_begin(); ei != rt2.finite_edges_end(); ++ei) { if (*ei == contract_edge.edge()) { found = true; break; } } //test that the edge was collapsed assert(!found); CGAL_USE(found); }
inline void Assembler::stw( Register d, Register s1, Register s2) { emit_int32( op(ldst_op) | rd(d) | op3(stw_op3) | rs1(s1) | rs2(s2) ); }
//--------------------------------------------------------------------------- void tTVPScrollDivisibleData::Blend(tTVPScrollTransFrom from, tTVPScrollTransStay stay, tjs_int phase) { // scroll the image tjs_int imagewidth; tjs_int imageheight; Src1->GetWidth(&imagewidth); Src1->GetHeight(&imageheight); tjs_int src1left = 0; tjs_int src1top = 0; tjs_int src2left = 0; tjs_int src2top = 0; switch(from) { case sttLeft: if(stay == ststNoStay) src1left = phase, src2left = phase - imagewidth; else if(stay == ststStayDest) src2left = phase - imagewidth; else if(stay == ststStaySrc) src1left = phase; break; case sttTop: if(stay == ststNoStay) src1top = phase, src2top = phase - imageheight; else if(stay == ststStayDest) src2top = phase - imageheight; else if(stay == ststStaySrc) src1top = phase; break; case sttRight: if(stay == ststNoStay) src1left = -phase, src2left = imagewidth - phase; else if(stay == ststStayDest) src2left = imagewidth - phase; else if(stay == ststStaySrc) src1left = -phase; break; case sttBottom: if(stay == ststNoStay) src1top = -phase, src2top = imageheight - phase; else if(stay == ststStayDest) src2top = imageheight - phase; else if(stay == ststStaySrc) src1top = -phase; break; } tTVPRect rdest(Left, Top, Width+Left, Height+Top); tTVPRect rs1(src1left, src1top, imagewidth + src1left, imageheight + src1top); tTVPRect rs2(src2left, src2top, imagewidth + src2left, imageheight + src2top); if(stay == ststNoStay) { // both layers have no priority than another. // nothing to do. } else if(stay == ststStayDest) { // Src2 has priority. if(from == sttLeft || from == sttRight) { if(rs2.right >= rs1.left && rs2.right < rs1.right) rs1.left = rs2.right; if(rs2.left >= rs1.left && rs2.left < rs1.right) rs1.right = rs2.left; } else { if(rs2.bottom >= rs1.top && rs2.bottom < rs1.bottom) rs1.top = rs2.bottom; if(rs2.top >= rs1.top && rs2.top < rs1.bottom) rs1.bottom = rs2.top; } } else if(stay == ststStaySrc) { // Src1 has priority. if(from == sttLeft || from == sttRight) { if(rs1.right >= rs2.left && rs1.right < rs2.right) rs2.left = rs1.right; if(rs1.left >= rs2.left && rs1.left < rs2.right) rs2.right = rs1.left; } else { if(rs1.bottom >= rs2.top && rs1.bottom < rs2.bottom) rs2.top = rs1.bottom; if(rs1.top >= rs2.top && rs1.top < rs2.bottom) rs2.bottom = rs1.top; } } // copy to destination image tTVPRect d; if(TVPIntersectRect(&d, rdest, rs1)) { tjs_int dl = d.left - Left + DestLeft, dt = d.top - Top + DestTop; d.add_offsets(-src1left, -src1top); TVPSLPCopyRect(Dest, dl, dt, Src1, d); } if(TVPIntersectRect(&d, rdest, rs2)) { tjs_int dl = d.left - Left + DestLeft, dt = d.top - Top + DestTop; d.add_offsets(-src2left, -src2top); TVPSLPCopyRect(Dest, dl, dt, Src2, d); } }
inline void Assembler::lduh( Register s1, Register s2, Register d) { emit_int32( op(ldst_op) | rd(d) | op3(lduh_op3) | rs1(s1) | rs2(s2) ); }
void plogin::process() { obj2["data"] = amf3object(); amf3object & data2 = obj2["data"]; //errors: //-5 = captcha //-99 = general error //-100 = holiday string username = data["user"]; string password = data["pwd"]; if (gserver->maxplayers <= gserver->currentplayersonline + 1) { gserver->SendObject(req.conn, gserver->CreateError("server.LoginResponse", -99, "Servers are currently overloaded. Please try again later.")); return; } string newuser; string newpass; newuser = makesafe(username); newpass = makesafe(password); { Session ses(gserver->accountpool->get()); Statement select(ses); select << "SELECT COUNT(*) AS a FROM `account` WHERE `email`=?;", use(newuser); select.execute(); RecordSet rs(select); if (rs.value("a").convert<int32_t>() == 0) { //account does not exist - insert new row try { Statement insert(ses); insert << "INSERT INTO `account` (`name`, `email`, `ip`, `lastlogin`, `creation`, `password`, `status`, `reason`) VALUES ('null', ?, '', ?, ?, ?, 0, '');", use(newuser), use(unixtime()), use(unixtime()), use(newpass), now; } catch (Poco::Data::MySQL::StatementException * e) { gserver->consoleLogger->error(Poco::format("Account Create Exception: %s", e->displayText())); return; } } } { Session ses(gserver->accountpool->get()); Statement select(ses); select << "SELECT * FROM `account` WHERE `email`=? AND `password`=?;", use(newuser), use(newpass); select.execute(); RecordSet rs(select); if (rs.rowCount() == 0) { //account doesn't exist or password is wrong gserver->SendObject(req.conn, gserver->CreateError("server.LoginResponse", -2, "Incorrect account or password.")); return; } else { int32_t masteraccountid = rs.value("id").convert<int32_t>(); client = gserver->GetClientByParent(masteraccountid); bool banned = false; { //are they banned? if so, globally or for this server? Session ses2(gserver->serverpool->get()); Statement select2(ses2); select2 << "SELECT * FROM `accounts` WHERE `parentid`=?;", use(masteraccountid); select2.execute(); RecordSet rs2(select2); if (rs.value("status").convert<int32_t>() == -99) banned = true; if (rs2.rowCount() > 0 && rs2.value("status").convert<int32_t>() == -99) banned = true; if (banned) { string errormsg = "You are banned. Reason: "; errormsg += rs.value("reason").convert<string>().length() > 0 ? rs.value("reason").convert<string>() : rs2.value("reason").convert<string>(); gserver->SendObject(req.conn, gserver->CreateError("server.LoginResponse", -99, errormsg)); return; } } //client = gserver->GetClientByParent(parentid); if (client == 0) { client = gserver->NewClient(); client->masteraccountid = masteraccountid; client->m_socknum = req.conn->uid; client->socket = req.conn; req.conn->client_ = client; client->m_connected = true; } else { if (client->m_connected) { //player already logged on gserver->CloseClient(client, 3, "");//multiple people logging into the same account } //Login is valid client->m_connected = true; double logintime = unixtime(); if (logintime - client->m_lastlogin < 1000 * 5) { gserver->SendObject(req.conn, gserver->CreateError("server.LoginResponse", 6, "You have tried logging in too frequently. Please try again later.")); req.conn->stop(); return; } client->m_lastlogin = logintime; if (client->socket) gserver->CloseClient(client, 3, ""); client->socket = req.conn; client->m_socknum = req.conn->uid; client->m_ipaddress = req.conn->address; req.conn->client_ = client; gserver->consoleLogger->information(Poco::format("Already established client found # %?d", (uint32_t)client->m_clientnumber)); if (client->m_email == "Daisy") { client->m_bdenyotherplayer = true; client->m_icon = 7; } } if (client == 0) { //error creating client object gserver->consoleLogger->information(Poco::format("Error creating client object @ %s:%?d", (string)__FILE__, __LINE__)); gserver->SendObject(client, gserver->CreateError("server.LoginResponse", -99, "Error with connecting. Please contact support.")); return; } //account exists Session ses2(gserver->serverpool->get()); Statement select2(ses2); select2 << "SELECT * FROM `accounts` WHERE `parentid`=?;", use(masteraccountid); select2.execute(); RecordSet rs2(select2); if (rs2.rowCount() == 0) { //does not have an account on server gserver->SendObject(client, gserver->CreateError("server.LoginResponse", -4, "need create player")); client->m_loggedin = true; return; } else { int accountid = rs2.value("accountid").convert<int32_t>(); client->m_accountid = accountid; //has an account, what about cities? Session ses3(gserver->serverpool->get()); Statement select3(ses3); select3 << "SELECT * FROM `cities` WHERE `accountid`=?;", use(accountid); select3.execute(); RecordSet rs3(select3); if (rs3.rowCount() == 0) { //does not have any cities on server but did have an account - this only happens if you try to "restart" your account. it saves the account info while deleting your cities gserver->SendObject(client, gserver->CreateError("server.LoginResponse", -4, "need create player")); client->m_loggedin = true; return; } else { //has an account and cities. process the list and send account info amf3object obj; obj["cmd"] = "server.LoginResponse"; obj["data"] = amf3object(); amf3object & data = obj["data"]; data["packageId"] = 0.0f; double tslag = unixtime(); if (client->GetItemCount("consume.1.a") < 10000) client->SetItem("consume.1.a", 10000); client->m_cents = 5000; data["player"] = client->ToObject(); //UNLOCK(M_CLIENTLIST); if (client->m_city.size() == 0) { //problem gserver->consoleLogger->error(Poco::format("Error client has no cities @ %s:%?d", (string)__FILE__, __LINE__)); gserver->SendObject(client, gserver->CreateError("server.LoginResponse", -99, "Error with connecting. Please contact support.")); return; } client->m_currentcityid = ((PlayerCity*)client->m_city.at(0))->m_castleid; client->m_currentcityindex = 0; client->m_accountexists = true; //check for holiday status stBuff * holiday = client->GetBuff("FurloughBuff"); if (holiday && holiday->endtime > tslag) { //is in holiday - send holiday info too string s; { int32_t hours; int32_t mins; int32_t secs = (holiday->endtime - tslag) / 1000; hours = secs / 60 / 60; mins = secs / 60 - hours * 60; secs = secs - mins * 60 - hours * 60 * 60; std::stringstream ss; ss << hours << "," << mins << "," << secs; s = ss.str(); } data["ok"] = -100; data["msg"] = s; data["errorMsg"] = s; } else { data["ok"] = 1; data["msg"] = "success"; } gserver->SendObject(client, obj); //SendObject(*req.connection, obj); client->m_lag = unixtime() - tslag; client->m_loggedin = true; gserver->currentplayersonline++; client->SaveToDB(); return; } } } } return; }
inline void Assembler::ldf(FloatRegisterImpl::Width w, Register s1, Register s2, FloatRegister d) { emit_int32( op(ldst_op) | fd(d, w) | alt_op3(ldf_op3, w) | rs1(s1) | rs2(s2) ); }
inline void Assembler::stx( Register d, Register s1, Register s2) { v9_only(); emit_int32( op(ldst_op) | rd(d) | op3(stx_op3) | rs1(s1) | rs2(s2) ); }
inline void Assembler::ldxfsr( Register s1, Register s2) { v9_only(); emit_int32( op(ldst_op) | rd(G1) | op3(ldfsr_op3) | rs1(s1) | rs2(s2) ); }
bool LocationType::Load(iResultRow &row, iEngine* engine, iDataConnection* db) { id = row.GetInt("id"); name = row["name"]; if(!name.Length()) { CPrintf(CON_ERROR, "Location Types must all have name attributes.\n"); return false; } // Load all with same master location type Result rs(db->Select("select loc.*,s.name as sector from sc_locations loc, sectors s where loc.loc_sector_id = s.id and type_id = %d and id_prev_loc_in_region <= 0",id)); // Only load locations, regions to be loaded later if(!rs.IsValid()) { Error2("Could not load locations from db: %s",db->GetLastError()); return false; } for(int i=0; i<(int)rs.Count(); i++) { Location* newloc = new Location; newloc->Load(rs[i],engine,db); newloc->type = this; locs.Push(newloc); } // Load region with same master location type Result rs2(db->Select("select loc.*,s.name as sector from sc_locations loc, sectors s where loc.loc_sector_id = s.id and type_id = %d and id_prev_loc_in_region > 0",id)); // Only load regions, locations has been loaded allready csArray<Location*> tmpLocs; if(!rs2.IsValid()) { Error2("Could not load locations from db: %s",db->GetLastError()); return false; } for(int i=0; i<(int)rs2.Count(); i++) { Location* newloc = new Location; newloc->Load(rs2[i],engine,db); newloc->type = this; tmpLocs.Push(newloc); } while(tmpLocs.GetSize()) { Location* curr, *first; curr = first = tmpLocs.Pop(); bool found; first->type = this; first->locs.Push(first); first->region = first; do { found = false; for(size_t i= 0; i<tmpLocs.GetSize(); i++) { if(curr->id == tmpLocs[i]->id_prev_loc_in_region) { curr = tmpLocs[i]; tmpLocs.DeleteIndex(i); curr->type = this; first->locs.Push(curr); curr->region = first; found = true; break; } } } while(found); //when not a closed loop of at least 3 points, delete this //polygon, but continue with rest. if(first->locs.GetSize() <= 2) { Error1("Only two locs for region defined!"); //delete all locations in 'polygon'. When deleting first, //it will recursively delete its polygon locations, in this //case including itself. So remove that reference first first->locs.DeleteIndex(0); delete first; } else if(curr->id != first->id_prev_loc_in_region) { Error1("First and last loc not connected!"); //delete all locations in 'polygon'. When deleting first, //it will recursively delete its polygon locations, in this //case including itself. So remove that reference first first->locs.DeleteIndex(0); delete first; } else { first->type = this; locs.Push(first); first->CalculateBoundingBox(); } } return true; }
bool psPathNetwork::Load(iEngine *engine, iDataConnection *db,psWorld * world) { // First initialize pointers to some importent classes this->engine = engine; this->db = db; this->world = world; Result rs(db->Select("select wp.*,s.name as sector from sc_waypoints wp, sectors s where wp.loc_sector_id = s.id")); if (!rs.IsValid()) { Error2("Could not load waypoints from db: %s",db->GetLastError() ); return false; } for (int i=0; i<(int)rs.Count(); i++) { Waypoint *wp = new Waypoint(); if (wp->Load(rs[i],engine)) { Result rs2(db->Select("select id,alias,rotation_angle from sc_waypoint_aliases where wp_id=%d",wp->GetID())); for (int j=0; j<(int)rs2.Count(); j++) { wp->AddAlias(rs2[j].GetInt(0),rs2[j][1],rs2[j].GetFloat(2)*PI/180.0); } waypoints.Push(wp); // Push in groups if (strcmp(wp->GetGroup(),"")!=0) { AddWaypointToGroup(wp->GetGroup(),wp); } } else { Error2("Could not load waypoint: %s",db->GetLastError() ); delete wp; return false; } } Result rs1(db->Select("select * from sc_waypoint_links")); if (!rs1.IsValid()) { Error2("Could not load waypoint links from db: %s",db->GetLastError() ); return false; } for (int i=0; i<(int)rs1.Count(); i++) { Waypoint * wp1 = FindWaypoint(rs1[i].GetInt("wp1")); Waypoint * wp2 = FindWaypoint(rs1[i].GetInt("wp2")); if(!wp1 || !wp2) { if(!wp1) Error2("Could not find waypoint wp1 link with id %d",rs1[i].GetInt("wp1") ); if(!wp2) Error2("Could not find waypoint wp2 link with id %d",rs1[i].GetInt("wp2") ); return false; } psString flagStr(rs1[i]["flags"]); int pathId = rs1[i].GetInt("id"); csString pathType = rs1[i]["type"]; psPath * path; if (strcasecmp(pathType,"linear") == 0) { path = new psLinearPath(pathId,rs1[i]["name"],flagStr); } else { path = new psLinearPath(pathId,rs1[i]["name"],flagStr); // For now } path->SetStart(wp1); if (!path->Load(db,engine)) { Error1("Failed to load path"); return false; } path->SetEnd(wp2); paths.Push(path); float dist = path->GetLength(world,engine); wp1->AddLink(path,wp2,psPath::FORWARD,dist); if (!path->oneWay) { wp2->AddLink(path,wp1,psPath::REVERSE,dist); // bi-directional link is implied } } return true; }
inline void Assembler::rett( Register s1, Register s2 ) { cti(); emit_int32( op(arith_op) | op3(rett_op3) | rs1(s1) | rs2(s2)); has_delay_slot(); }