void Map::mapGenerator() { for (int i = 0; i < m_width; ++i) { for (int j = 0; j < m_heigth; ++j) { m_tiles[i][j] = Tile(whichType(bruitPerlin(i+0.5f,j+0.5f,10))); } } }
QQJson::StateCode_Type AbstractState::doExpectValue(AbstractContext*context, QQJson::jsonPtr ptr) { std::stack<QQJson::jsonPtr> & Stack = context->getStack(); auto Key = Stack.top(); Stack.pop(); if (Key->whichType() != QQJsonX::QQJSON_KEY) return QQJson::FORMAT_ERROR; auto Object = Stack.top(); Stack.pop(); if (Object->whichType() != QQJsonX::QQJSON_OBJECT) return QQJson::FORMAT_ERROR; auto Obj = std::dynamic_pointer_cast<QQJsonObject>(Object); Obj->addVaule(Key->toString(), ptr); Stack.push(Object); return QQJson::SUCCESS; }
QQJson::StateCode_Type AbstractState::doExpectArrayValue(AbstractContext *context, QQJson::jsonPtr json) { std::stack<QQJson::jsonPtr> & Stack = context->getStack(); auto array = Stack.top(); if (array->whichType() != QQJsonX::QQJSON_ARRAY) return QQJson::FORMAT_ERROR; auto jsonArray = std::dynamic_pointer_cast<QQJsonArray>(array); jsonArray->addValue(json); return QQJson::SUCCESS; }
/* * md back-end code for menu-driven BSD disklabel editor. */ int md_make_bsd_partitions(void) { FILE *f; int i, j, pl; EBZB *bzb; /* * Scan for any problems and report them before continuing. * The user can abort installation and we'll take them back * to the main menu; continue ignoring the warnings, or * ask to reedit the Disk Partition Map. */ while (1) { if (check_for_errors()) { process_menu (MENU_sanity, NULL); if (yesno < 0) return 0; else if (yesno) break; edit_diskmap(); } else break; } /* Build standard partitions */ memset(&bsdlabel, 0, sizeof bsdlabel); /* * The mac68k port has a predefined partition for "c" which * is the size of the disk, everything else is unused. */ bsdlabel[RAW_PART].pi_size = dlsize; /* * Now, scan through the Disk Partition Map and transfer the * information into the incore disklabel. */ for (i=0;i<map.usable_cnt;i++) { j = map.mblk[i]; bzb = (EBZB *)&map.blk[j].pmBootArgs[0]; if (bzb->flags.part) { pl = bzb->flags.part - 'a'; switch (whichType(&map.blk[j])) { case HFS_PART: bsdlabel[pl].pi_fstype = FS_HFS; strcpy (bsdlabel[pl].pi_mount, (char *)bzb->mount_point); break; case ROOT_PART: case UFS_PART: bsdlabel[pl].pi_fstype = FS_BSDFFS; strcpy (bsdlabel[pl].pi_mount, (char *)bzb->mount_point); bsdlabel[pl].pi_flags |= PIF_NEWFS | PIF_MOUNT; break; case SWAP_PART: bsdlabel[pl].pi_fstype = FS_SWAP; break; case SCRATCH_PART: bsdlabel[pl].pi_fstype = FS_OTHER; strcpy (bsdlabel[pl].pi_mount, (char *)bzb->mount_point); default: break; } if (bsdlabel[pl].pi_fstype != FS_UNUSED) { bsdlabel[pl].pi_size = map.blk[j].pmPartBlkCnt; bsdlabel[pl].pi_offset = map.blk[j].pmPyPartStart; if (bsdlabel[pl].pi_fstype != FS_SWAP) { bsdlabel[pl].pi_frag = 8; bsdlabel[pl].pi_fsize = 1024; } } } } /* Disk name - don't bother asking, just use the physical name*/ strcpy (bsddiskname, diskdev); #ifdef DEBUG f = fopen ("/tmp/disktab", "w"); #else f = fopen ("/etc/disktab", "w"); #endif if (f == NULL) { endwin(); (void) fprintf (stderr, "Could not open /etc/disktab"); exit (1); } (void)fprintf (f, "%s|NetBSD installation generated:\\\n", bsddiskname); (void)fprintf (f, "\t:dt=%s:ty=winchester:\\\n", disktype); (void)fprintf (f, "\t:nc#%d:nt#%d:ns#%d:\\\n", dlcyl, dlhead, dlsec); (void)fprintf (f, "\t:sc#%d:su#%" PRIu32 ":\\\n", dlhead*dlsec, (uint32_t)dlsize); (void)fprintf (f, "\t:se#%d:%s\\\n", blk_size, doessf); for (i=0; i<8; i++) { if (bsdlabel[i].pi_fstype == FS_HFS) (void)fprintf (f, "\t:p%c#%d:o%c#%d:t%c=macos:", 'a'+i, bsdlabel[i].pi_size, 'a'+i, bsdlabel[i].pi_offset, 'a'+i); else (void)fprintf (f, "\t:p%c#%d:o%c#%d:t%c=%s:", 'a'+i, bsdlabel[i].pi_size, 'a'+i, bsdlabel[i].pi_offset, 'a'+i, getfslabelname(bsdlabel[i].pi_fstype)); if (bsdlabel[i].pi_fstype == FS_BSDFFS) (void)fprintf (f, "b%c#%d:f%c#%d", 'a'+i, bsdlabel[i].pi_fsize * bsdlabel[i].pi_frag, 'a'+i, bsdlabel[i].pi_fsize); if (i < 7) (void)fprintf (f, "\\\n"); else (void)fprintf (f, "\n"); } fclose (f); /* Everything looks OK. */ return 1; }