//-----% Room Generation Functions %------ int recurClear(lvl *level, int h, int w, int x, int y, int doH, int showGen){ if (h && doH == 1) recurClear(level, h-1, w, x, y,1, showGen); if (w) recurClear(level, h, w-1, x, y,0, showGen); if(rb(1,CHANCE_HIGH)==1) level->nodeSet(y+h,x+w, '$'); else if(rb(1,CHANCE_LOW)==1) level->nodeSet(y+h,x+w, '*'); else if(rb(1,CHANCE_MED)==1) level->nodeSet(y+h,x+w, 'o'); else level->nodeSet(y+h,x+w, ' '); if (showGen){ system("CLS"); for (int i = 0; i < MAX_H; i++){ for (int j = 0; j < MAX_W; j++){ printf("%c", level->nodeGet(i,j)); } printf("\n"); } } return 1; }
void makeStartInv(){ FILE* invFile; invFile = fopen("../playerFiles/playerInv.txt","w"); char itemName[MAX_NAME_LEN]; fprintf(invFile,"%s %i %i\n", weaponNameGen(itemName, rb(1,3), 2),0,WEAPON_FLAG); fprintf(invFile,"%s %i %i\n", armorNameGen(itemName, rb(1,5), 2),0,ARMOR_FLAG); fclose(invFile); }
static int getmarker(void) { int c; c = rb(0); if (c == -1) return -1; if (c!=0xff) return -1; c = rb(0); return c; }
void addRandToInv(int type){ FILE* invFile; invFile = fopen("../playerFiles/playerInv.txt","a"); char itemName[MAX_NAME_LEN]; if (type == 1) fprintf(invFile,"%s %i %i\n", weaponNameGen(itemName, rb(1,3), MIN_WEP_ATK + 0.5 * WEP_ATK_INC),0,WEAPON_FLAG); else fprintf(invFile,"%s %i %i\n", armorNameGen(itemName, rb(1,5), MIN_ARM_DEF + 0.5 * ARM_DEF_INC),0,ARMOR_FLAG); fclose(invFile); }
static int getlength(void) { int x1,x2; x1 = rb(1); if (x1 == -1) return -1; x2 = rb(1); if (x2 == -1) return -1; x1 = (x1 << 8) | x2; fprintf(stderr,"(%d)",x1); return x1; }
static int rd(int len, char *data) { unsigned int c,i; for (i=0;i<len;i++) { c = rb(1); if (c == -1) return -1; if (c == 0xff) c = rb(1); if (c == -1) return -1; data[i] = c; } return len; }
void shuffleDeck (cardType *deck) { cardType temp; int i1, i2; for (int i = 0; i < NUM_SHUFFLES; i++) { i1 = rb (0, NUM_CARDS - 1); i2 = rb (0, NUM_CARDS - 1); temp = deck[i1]; deck[i1] = deck[i2]; deck[i2] = temp; } }
static void move(t_env *env, t_sort *s) { if (s->dir) rb(env); else rrb(env); }
btRigidBody* BulletPhysics::addObject(osg::MatrixTransform *root, osg::Node *node, btScalar mass, btVector3 inertia, collisionShapeType_t ctype, CollisionDataType * data,osg::Node * colShape) { btCollisionShape* cs; if(colShape==NULL) cs=GetCSFromOSG( node, ctype); else cs=GetCSFromOSG( colShape, ctype); MyMotionState* motion = new MyMotionState(node,root); cs->calculateLocalInertia( mass, inertia ); btRigidBody::btRigidBodyConstructionInfo rb( mass, motion, cs, inertia ); btRigidBody* body = new btRigidBody( rb ); body->setUserPointer(data); //addRigidBody adds its own collision masks, changing after object creation do not update masks so objects are removed and readded in order to update masks to improve collisions performance. dynamicsWorld->addRigidBody( body); if(data->isVehicle){ dynamicsWorld->btCollisionWorld::removeCollisionObject(body); dynamicsWorld->addCollisionObject(body,short( COL_VEHICLE),short(vehicleCollidesWith)); } else{ dynamicsWorld->btCollisionWorld::removeCollisionObject(body); dynamicsWorld->addCollisionObject(body,short( COL_OBJECTS),short(objectsCollidesWith)); } return( body ); }
int main(int argc, char ** argv) { try { Int64 x1 = std::numeric_limits<Int64>::min(); Int64 x2 = 0; std::string s; std::cerr << static_cast<Int64>(x1) << std::endl; { DB::WriteBufferFromString wb(s); DB::writeIntText(x1, wb); } std::cerr << s << std::endl; { DB::ReadBufferFromString rb(s); DB::readIntText(x2, rb); } std::cerr << static_cast<Int64>(x2) << std::endl; } catch (const DB::Exception & e) { std::cerr << e.what() << ", " << e.displayText() << std::endl; return 1; } return 0; }
void ofxMesh::addFace(ofRectangle r) { ofVec2f lt(r.x,r.y); ofVec2f rt(r.x+r.width,r.y); ofVec2f rb(r.x+r.width,r.y+r.height); ofVec2f lb(r.x,r.y+r.height); addFace(lt,lb,rb,rt); }
void DataTypeArray::deserializeTextCSV(IColumn & column, ReadBuffer & istr, const FormatSettings & settings) const { String s; readCSV(s, istr, settings.csv); ReadBufferFromString rb(s); deserializeText(column, rb, settings); }
virtual void on_draw() { int width = rbuf_window().width(); int height = rbuf_window().height(); typedef agg::scanline_u8_am<agg::alpha_mask_gray8> scanline_type; typedef agg::renderer_base<agg::pixfmt_bgr24> ren_base; typedef agg::renderer_scanline_aa_solid<ren_base> renderer; agg::pixfmt_bgr24 pixf(rbuf_window()); ren_base rb(pixf); renderer r(rb); scanline_type sl(g_alpha_mask); rb.clear(agg::rgba8(255, 255, 255)); agg::trans_affine mtx; mtx *= agg::trans_affine_translation(-g_base_dx, -g_base_dy); mtx *= agg::trans_affine_scaling(g_scale, g_scale); mtx *= agg::trans_affine_rotation(g_angle + agg::pi); mtx *= agg::trans_affine_skewing(g_skew_x/1000.0, g_skew_y/1000.0); mtx *= agg::trans_affine_translation(width/2, height/2); agg::conv_transform<agg::path_storage, agg::trans_affine> trans(g_path, mtx); agg::render_all_paths(g_rasterizer, sl, r, trans, g_colors, g_path_idx, g_npaths); }
void ResourceBundleTest::TestGetLocaleByType(void) { const struct { const char *requestedLocale; const char *resourceKey; const char *validLocale; const char *actualLocale; } test[] = { { "te_IN_BLAH", "string_only_in_te_IN", "te_IN", "te_IN" }, { "te_IN_BLAH", "string_only_in_te", "te_IN", "te" }, { "te_IN_BLAH", "string_only_in_Root", "te_IN", "root" }, { "te_IN_BLAH_01234567890_01234567890_01234567890_01234567890_01234567890_01234567890", "array_2d_only_in_Root", "te_IN", "root" }, { "te_IN_BLAH@currency=euro", "array_2d_only_in_te_IN", "te_IN", "te_IN" }, { "te_IN_BLAH@calendar=thai;collation=phonebook", "array_2d_only_in_te", "te_IN", "te" } }; UErrorCode status = U_ZERO_ERROR; const char* testdatapath = loadTestData(status); int32_t i = 0; Locale locale; if(U_FAILURE(status)) { dataerrln("Could not load testdata.dat %s\n", u_errorName(status)); return; } for(i = 0; i < (int32_t)(sizeof(test)/sizeof(test[0])); i++) { ResourceBundle rb(testdatapath, test[i].requestedLocale, status); if(U_FAILURE(status)) { err("Could not open resource bundle %s (error %s)\n", test[i].requestedLocale, u_errorName(status)); status = U_ZERO_ERROR; continue; } ResourceBundle res = rb.get(test[i].resourceKey, status); if(U_FAILURE(status)) { err("Couldn't find the key %s. Error: %s\n", test[i].resourceKey, u_errorName(status)); status = U_ZERO_ERROR; continue; } locale = res.getLocale(ULOC_REQUESTED_LOCALE, status); if(locale != Locale::getDefault()) { err("Expected requested locale to be %s. Got %s\n", test[i].requestedLocale, locale.getName()); } locale = res.getLocale(ULOC_VALID_LOCALE, status); if(strcmp(locale.getName(), test[i].validLocale) != 0) { err("Expected valid locale to be %s. Got %s\n", test[i].requestedLocale, locale.getName()); } locale = res.getLocale(ULOC_ACTUAL_LOCALE, status); if(strcmp(locale.getName(), test[i].actualLocale) != 0) { err("Expected actual locale to be %s. Got %s\n", test[i].requestedLocale, locale.getName()); } } }
//------------------------------------------------------------------------ void draw_dashes_draft() { pixfmt pixf(rbuf_window()); base_renderer rb(pixf); primitives_renderer prim(rb); outline_rasterizer ras(prim); int i; for(i = 0; i < m_graph.get_num_edges(); i++) { graph::edge e = m_graph.get_edge(i); graph::node n1 = m_graph.get_node(e.node1, width(), height()); graph::node n2 = m_graph.get_node(e.node2, width(), height()); curve c(n1.x, n1.y, n2.x, n2.y); dash_stroke_draft<curve> s(c, 6.0, 3.0, m_width.value()); int r = rand() & 0x7F; int g = rand() & 0x7F; int b = rand() & 0x7F; int a = 255; if(m_translucent.status()) a = 80; prim.line_color(agg::srgba8(r, g, b, a)); ras.add_path(s); } }
template<class VertexSource> void generate_alpha_mask(VertexSource& vs) { unsigned cx = (unsigned)width(); unsigned cy = (unsigned)height(); delete [] m_alpha_buf; m_alpha_buf = new unsigned char[cx * cy]; m_alpha_mask_rbuf.attach(m_alpha_buf, cx, cy, cx); typedef agg::renderer_base<agg::pixfmt_gray8> ren_base; typedef agg::renderer_scanline_aa_solid<ren_base> renderer; agg::pixfmt_gray8 pixf(m_alpha_mask_rbuf); ren_base rb(pixf); renderer ren(rb); start_timer(); if(m_operation.cur_item() == 0) { rb.clear(agg::gray8(0)); ren.color(agg::gray8(255)); } else { rb.clear(agg::gray8(255)); ren.color(agg::gray8(0)); } m_ras.add_path(vs); agg::render_scanlines(m_ras, m_sl, ren); double t1 = elapsed_time(); char buf[100]; sprintf(buf, "Generate AlphaMask: %.3fms", t1); draw_text(250, 20, buf); }
int main() { init_random(); m_buffer_t rb(64); constexpr std::size_t n_readers = 2; m_reader_t rd[n_readers] = { rb, rb }; rb.mlock(); constexpr std::size_t max = 10000; std::vector<m_type> random_numbers(max + 1); for(std::size_t count = 0; count < max; ++count) { random_numbers[count] = random_number(rb.maximum_eventual_write_space() - 1) + 1; } random_numbers[max] = 0; try { std::thread t1(write_messages, &rb, random_numbers); std::thread t2(read_messages, rd); std::thread t3(read_messages, rd + 1); t1.join(); t2.join(); t3.join(); } catch(const char* s) { std::cerr << s << std::endl; return 1; } return 0; }
static int skipdata(int len, int suppress) { int x,i; for (i=0;i<len;i++) { x = rb(suppress); if (x == -1) return x; if (x == 0xff) { x = rb(suppress); if (x == -1) return x; } } return 1; }
int addRoom(lvl *level, int showGen, room *rooms, int tries){ int x = rb(1, MAX_W-RM_MAXX-2); int y = rb(1, MAX_H-RM_MAXY-2); int w = rb(3, RM_MAXX); int h = rb(3, RM_MAXY); if (validRoom(level, h+2, w+2, x-2, y-2, 1, showGen)){ rooms->setPoints(x,y,x+w,y+h); recurClear(level, h, w, x, y, 1, showGen); return (1); } else if(tries<=30){ return (addRoom(level, showGen, rooms, ++tries)); } return 0; }
void ReBindRefsPass::run_pass( DexStoresVector& stores, ConfigFiles& cfg, PassManager& mgr) { Scope scope = build_class_scope(stores); Rebinder rb(scope, mgr); rb.rewrite_refs(); rb.print_stats(); }
btRigidBody* BulletPhysics::addFloatingObject(osg::MatrixTransform *root, osg::Node *node, btScalar mass, btVector3 inertia, collisionShapeType_t ctype, CollisionDataType * data,osg::Node * colShape) { btConvexShape* cs; if(colShape==NULL) cs=GetConvexCSFromOSG( node, ctype); else cs=GetConvexCSFromOSG( colShape, ctype); MyMotionState* motion = new MyMotionState(node,root); cs->calculateLocalInertia( mass, inertia ); btHfFluidBuoyantConvexShape* buoyantShape = new btHfFluidBuoyantConvexShape(cs); buoyantShape->generateShape (btScalar(0.05f), btScalar(0.01f)); buoyantShape->setFloatyness (btScalar(1.0f)); btRigidBody::btRigidBodyConstructionInfo rb( mass, motion, buoyantShape, inertia ); btRigidBody* body= new btRigidBody( rb ); body->setUserPointer(data); //addRigidBody adds its own collision masks, changing after object creation do not update masks so objects are removed and readded in order to update masks to improve collisions performance. dynamicsWorld->addRigidBody( body); dynamicsWorld->btCollisionWorld::removeCollisionObject(body); dynamicsWorld->addCollisionObject(body,short( COL_OBJECTS),short(objectsCollidesWith)); body->setActivationState( DISABLE_DEACTIVATION ); return( body ); }
static ssize_t pad_size() { RingBuffer* rb(0); // cppcheck-suppress nullPounter return (PREAMBLE_LEN * sizeof(*(rb->preamble_)) + HEADER_LEN * sizeof(*(rb->header_))); }
virtual void on_draw() { prim_pixfmt_type pixf(rbuf_window()); prim_ren_base_type rb(pixf); rb.clear(agg::rgba8(255, 255, 255)); generate_color_ramp(m_ramp1, agg::rgba(0, 0, 0, m_alpha_dst.value()), agg::rgba(0, 0, 1, m_alpha_dst.value()), agg::rgba(0, 1, 0, m_alpha_dst.value()), agg::rgba(1, 0, 0, 0)); generate_color_ramp(m_ramp2, agg::rgba(0, 0, 0, m_alpha_src.value()), agg::rgba(0, 0, 1, m_alpha_src.value()), agg::rgba(0, 1, 0, m_alpha_src.value()), agg::rgba(1, 0, 0, 0)); render_scene(rb); agg::renderer_scanline_aa_solid<prim_ren_base_type> ren(rb); agg::render_ctrl_rs(m_ras, m_sl, ren, m_alpha_dst); agg::render_ctrl_rs(m_ras, m_sl, ren, m_alpha_src); agg::render_ctrl_rs(m_ras, m_sl, ren, m_comp_op); }
void monitorable_actor::bounce(mailbox_element_ptr& what, const error& err) { // make sure that a request always gets a response; // the exit reason reflects the first actor on the // forwarding chain that is out of service detail::sync_request_bouncer rb{err}; rb(*what); }
virtual void on_ctrl_change() { if(m_benchmark.status()) { int i; on_draw(); update_window(); scanline_rasterizer ras; pixfmt pixf(rbuf_window()); base_renderer rb(pixf); solid_renderer solid(rb); draft_renderer draft(rb); char buf[256]; if(m_draft.status()) { start_timer(); for(i = 0; i < 10; i++) { draw_scene(ras, solid, draft); } sprintf(buf, "%3.3f milliseconds", elapsed_time()); } else { double times[5]; for(m_draw = 0; m_draw < 4; m_draw++) { start_timer(); for(i = 0; i < 10; i++) { draw_scene(ras, solid, draft); } times[m_draw] = elapsed_time(); } m_draw = 3; times[4] = times[3]; times[3] -= times[2]; times[2] -= times[1]; times[1] -= times[0]; FILE* fd = fopen(full_file_name("benchmark"), "a"); fprintf(fd, "%10.3f %10.3f %10.3f %10.3f %10.3f\n", times[0], times[1], times[2], times[3], times[4]); fclose(fd); sprintf(buf, " pipeline add_path sort render total\n" "%10.3f %10.3f %10.3f %10.3f %10.3f", times[0], times[1], times[2], times[3], times[4]); } message(buf); m_benchmark.status(false); force_redraw(); } }
void draw_aliased() { pixfmt pixf(rbuf_window()); renderer_base rb(pixf); renderer_bin ren_bin(rb); agg::path_storage path; path.move_to(m_x[0] - 200, m_y[0]); path.line_to(m_x[1] - 200, m_y[1]); path.line_to(m_x[2] - 200, m_y[2]); path.close_polygon(); ren_bin.color(agg::rgba(0.1, 0.5, 0.7, m_alpha.value())); m_ras.gamma(agg::gamma_threshold(m_gamma.value())); m_ras.add_path(path); agg::render_scanlines(m_ras, m_sl_bin, ren_bin); //-- Drawing an outline with subpixel accuracy (aliased) //typedef agg::renderer_primitives<renderer_base> renderer_pr; //renderer_pr ren_pr(rb); //agg::rasterizer_outline<renderer_pr> ras_line(ren_pr); //ren_pr.line_color(agg::rgba(0.0, 0.0, 0.0)); //ras_line.add_path(path); }
/** * Y2R_U::GetSpacialDithering service function * Outputs: * 1 : Result of function, 0 on success, otherwise error code * 2 : u8, 0 = Disabled, 1 = Enabled */ static void GetSpacialDithering(Interface* self) { IPC::RequestBuilder rb(Kernel::GetCommandBuffer(), 0xA, 2, 0); rb.Push(RESULT_SUCCESS); rb.Push(spacial_dithering_enabled != 0); LOG_WARNING(Service_Y2R, "(STUBBED) called"); }
void ft_suite_de_merde(unsigned int i, char op, t_swap **ba, t_swap **bb) { if (i % 8 == 5) { ft_putstr("sb "); op ? sb(bb) : 0; } else if (i % 8 == 6) { ft_putstr("rb "); op ? rb(bb) : 0; } else if (i % 8 == 7) { ft_putstr("rrb "); op ? rrb(bb) : 0; } else if (i % 8 == 3) { ft_putstr("pa "); op ? pa(ba, bb) : 0; } else if (i % 8 == 4) { ft_putstr("pb "); op ? pb(bb, ba) : 0; } }
void generate_alpha_mask(int cx, int cy) { delete [] m_alpha_buf; m_alpha_buf = new unsigned char[cx * cy]; g_alpha_mask_rbuf.attach(m_alpha_buf, cx, cy, cx); typedef agg::renderer_base<agg::pixfmt_gray8> ren_base; typedef agg::renderer_scanline_aa_solid<ren_base> renderer; agg::pixfmt_gray8 pixf(g_alpha_mask_rbuf); ren_base rb(pixf); renderer r(rb); agg::scanline_p8 sl; rb.clear(agg::gray8(0)); agg::ellipse ell; int i; for(i = 0; i < 10; i++) { ell.init(rand() % cx, rand() % cy, rand() % 100 + 20, rand() % 100 + 20, 100); g_rasterizer.add_path(ell); r.color(agg::gray8(rand() & 0xFF, rand() & 0xFF)); agg::render_scanlines(g_rasterizer, sl, r); } }
void AutoSearchFrame::layout() { dwt::Rectangle r(dwt::Point(0, 0), getClientAreaSize()); layoutStatus(r); /// @todo dynamic width const int ybutton = add->getTextSize(_T("A")).y + 10; const int xbutton = 90; const int xborder = 10; dwt::Rectangle rb(r.getBottom(ybutton)); r.size.y -= ybutton; items->setBounds(r); rb.size.x = xbutton; add->setBounds(rb); rb.pos.x += xbutton + xborder; properties->setBounds(rb); rb.pos.x += xbutton + xborder; up->setBounds(rb); rb.pos.x += xbutton + xborder; down->setBounds(rb); rb.pos.x += xbutton + xborder; remove->setBounds(rb); rb.pos.x += xbutton + xborder; help->setBounds(rb); }