/* Grow all the continents */ static void grow_continents(void) { int c; for (c = 0; c < nc; ++c) { sectx[c][0] = capx[c]; secty[c][0] = capy[c]; own[sectx[c][0]][secty[c][0]] = c; sectx[c][1] = new_x(capx[c] + 2); secty[c][1] = capy[c]; own[sectx[c][1]][secty[c][1]] = c; } for (secs = 2; secs < sc && !fl_status; ++secs) { for (c = 0; c < nc; ++c) { find_coast(c); grow_one_sector(c); } } for (c = 0; c < nc; ++c) find_coast(c); if (fl_status) qprint("Only managed to grow %d out of %d sectors.\n", secs, sc); ctot = nc; }
void mainwindow::qfill() { /* Called when User Presses "Enter Key" after entering Roll Number. * Database Connection is mandatory. */ if(ui.leqroll->text().isEmpty()) return; if(ui.leqroll->text().toUpper() == lstroll) { qprint(); return; } mwsdt->stroll = ui.leqroll->text().toUpper(); ui.cstroll->setText(mwsdt->stroll); /* queryit() fetches details & also reports for database inconsistency. * returns true or false */ if(queryit(mwsdt)) { view_fill(mwsdt); sdttabfill(); } lstroll = mwsdt->stroll; }
static int grow_one_sector(int c) { int done, coast_search, try1, x, y, newx, newy, i, n, sx, sy; spike = roll0(100) < sp; if ((try1 = new_try(c)) == -1) return 0; x = sx = sectx[c][try1]; y = sy = secty[c][try1]; coast_search = 0; done = 0; do { if (spike) { for (i = roll0(6), n = 0; n < 12 && !done; i = (i + 1) % 6, ++n) { newx = new_x(x + dirx[i]); newy = new_y(y + diry[i]); if (own[newx][newy] == -1 && (n > 5 || (own[new_x(x+dirx[(i+5)%6])][new_y(y+diry[(i+5)%6])] == -1 && own[new_x(x+dirx[(i+1)%6])][new_y(y+diry[(i+1)%6])] == -1))) if (try_to_grow(c, newx, newy, c < nc ? di : id)) done = 1; } } else for (i = roll0(6), n = 0; n < 6 && !done; i = (i + 1) % 6, ++n) { newx = new_x(x + dirx[i]); newy = new_y(y + diry[i]); if (own[newx][newy] == -1) if (try_to_grow(c, newx, newy, c < nc ? di : id)) done = 1; } next_coast(c, x, y, &x, &y); ++coast_search; } while (!done && coast_search < COAST_SEARCH_MAX && (secs == 1 || x != sx || y != sy)); if (!done && c < nc) { qprint("fairland: error -- continent %c had no room to grow!\n", numletter[c % 62]); fl_status |= STATUS_NO_ROOM; } return done; }
static void grow_islands(void) { int c, x, y, isiz; for (c = nc; c < nc + ni; ++c) { secs = 0; if (!place_island(c, &x, &y)) return; isiz = roll(is) + roll0(is); do { ++secs; find_coast(c); } while (secs < isiz && grow_one_sector(c)); find_coast(c); qprint(" %d(%d)", c - nc + 1, secs); isecs[c] = secs; ctot++; } }
static void set_coastal_flags(void) { int i, j; struct sctstr *sp; qprint("setting coastal flags...\n"); for (i = 0; i < nc; ++i) { for (j = 0; j < sc; j++) { sp = getsectp(sectx[i][j], secty[i][j]); sp->sct_coastal = sectc[i][j]; } } for (i = nc; i < nc + ni; ++i) { for (j = 0; j < isecs[i]; j++) { sp = getsectp(sectx[i][j], secty[i][j]); sp->sct_coastal = sectc[i][j]; } } }
mainwindow::mainwindow() { // Interface Construction ui.setupUi(this); pt_mth = pt_type = -1; evt = isreset = 1; pdfpath = "./PDF/"; lstroll = ""; dt = QDate::currentDate().toString("dd.MM.yyyy"); ui.date->setText(dt); mwsdt = new sdetails(); // Scene Construction setdmscene(); // Load Modules btable = new bulkprint(this,ui.tab_5); btable->show(); selprint = new selectiveprint(this); setupmenu(); // Start the Authentication Dialog AuthenDialog *authendialog = new AuthenDialog(this); authendialog->show(); // Printer Info QPrinter print; QPrinterInfo pinfo(print); ui.pinfo->setText(pinfo.printerName());//.section("",-1,-1)); // Fetch Printing Positions QFile file2("./positions.dat"); file2.open(QIODevice::ReadOnly); QDataStream inp(&file2); inp >> lt; //set printer setprinter(); //Connections connect(ui.bselback,SIGNAL(pressed()),selprint,SLOT(back())); connect(ui.bqreset,SIGNAL(pressed()),this,SLOT(breset())); connect(ui.bqprint,SIGNAL(pressed()),this,SLOT(qprint())); connect(ui.bbulkprintall,SIGNAL(pressed()),this,SLOT(bprintall())); connect(ui.bbulkselprint,SIGNAL(pressed()),this,SLOT(bprintsel())); connect(ui.bselnext,SIGNAL(released()),selprint,SLOT(next())); connect(ui.babortprint,SIGNAL(released()),this,SLOT(abortprint())); connect(ui.bpositions,SIGNAL(released()),this,SLOT(positionsdialog())); connect(ui.changeButton,SIGNAL(released()),this,SLOT(changepasswd())); connect(ui.leqroll,SIGNAL(textChanged(const QString &)),this,SLOT(rollchanged(const QString &))); connect(ui.leqsname,SIGNAL(textChanged(const QString &)),this,SLOT(snamechanged(const QString &))); connect(ui.leqfname,SIGNAL(textChanged(const QString &)),this,SLOT(fnamechanged(const QString &))); connect(ui.cbcourse,SIGNAL(currentIndexChanged(const QString &)),this,SLOT(coursechanged(const QString &))); connect(ui.cbbranch,SIGNAL(currentIndexChanged(const QString &)),this,SLOT(branchchanged(const QString &))); connect(ui.cbyear,SIGNAL(currentIndexChanged(const QString &)),this,SLOT(yearchanged(const QString &))); connect(ui.cbsem,SIGNAL(currentIndexChanged(const QString &)),this,SLOT(semchanged(const QString &))); //connect(ui.cbpl,SIGNAL(currentIndexChanged(const QString &)),this,SLOT(ptchanged(const QString &))); connect(ui.leqfrom,SIGNAL(textChanged(const QString &)),this,SLOT(fromchanged(const QString &))); connect(ui.leqto,SIGNAL(textChanged(const QString &)),this,SLOT(tochanged(const QString &))); connect(ui.lepurpose,SIGNAL(textChanged(const QString &)),this,SLOT(ppchanged(const QString &))); connect(ui.cbgen,SIGNAL(currentIndexChanged(int)),this,SLOT(genchanged(int))); connect(ui.modetab,SIGNAL(currentChanged(int)),this,SLOT(pmode(int))); connect(ui.ptcombo,SIGNAL(currentIndexChanged(QString)),ui.ltype,SLOT(setText(const QString &))); connect(ui.outbox,SIGNAL(currentIndexChanged(QString)),ui.lout,SLOT(setText(const QString &))); connect(ui.gbcno,SIGNAL(toggled(bool)),this,SLOT(cidtoggle(bool))); connect(ui.sbcno,SIGNAL(valueChanged (int)),this,SLOT(cidvalue(int))); connect(ui.actionQuit,SIGNAL(triggered()),this,SLOT(close())); connect(ui.actionAbout,SIGNAL(triggered()),this,SLOT(about_p())); connect(actionselprintall,SIGNAL(triggered()),selprint,SLOT(printall())); connect(actionselprintsel,SIGNAL(triggered()),selprint,SLOT(printsel())); connect(ui.actionPrint,SIGNAL(triggered()),this,SLOT(qprint())); connect(ui.actionReset,SIGNAL(triggered()),this,SLOT(reset())); ui.leqroll->setFocus(); ui.lepurpose->setText("Bus Pass"); qp1 = "select STUDENT_ID from student_admission where STUDENT_ROLLNO="; qp2 = "select student_name,father_name,gender from student_info where student_id=" ; qp3 = "select course,branch_id,current_sem,current_year from student_academic where student_id=" ; }
int main(int argc, char *argv[]) { int opt; char *config_file = NULL; int i = 0; unsigned rnd_seed = 0; int seed_set = 0; program_name = argv[0]; while ((opt = getopt(argc, argv, "ae:hioqR:s:v")) != EOF) { switch (opt) { case 'a': AIRPORT_MARKER = 1; break; case 'e': config_file = optarg; break; case 'i': DISTINCT_ISLANDS = 0; break; case 'o': ORE = 0; break; case 'q': quiet = 1; break; case 'R': rnd_seed = strtoul(optarg, NULL, 10); seed_set = 1; break; case 's': outfile = optarg; break; case 'h': usage(); exit(0); case 'v': printf("%s\n\n%s", version, legal); exit(0); default: help(NULL); exit(1); } } parse_args(argc - optind, argv + optind); if (!seed_set) rnd_seed = pick_seed(); seed_prng(rnd_seed); empfile_init(); if (emp_config(config_file) < 0) exit(1); empfile_fixup(); allocate_memory(); print_vars(); qprint("\n #*# ...fairland rips open a rift in the datumplane... #*#\n\n"); qprint("seed is %u\n", rnd_seed); do { init(); if (i) qprint("\ntry #%d (out of %d)...\n", i + 1, NUMTRIES); qprint("placing capitals...\n"); if (!drift()) qprint("fairland: unstable drift -- try increasisg DRIFT_MAX\n"); qprint("growing continents...\n"); grow_continents(); } while (fl_status && ++i < NUMTRIES); if (fl_status) { fputs("ERROR: World not large enough to hold continents\n", stderr); exit(1); } qprint("growing islands:"); grow_islands(); qprint("\nelevating land...\n"); create_elevations(); qprint("designating sectors...\n"); if (ORE) qprint("adding resources...\n"); write_newcap_script(); if (chdir(gamedir)) { fprintf(stderr, "Can't chdir to %s (%s)\n", gamedir, strerror(errno)); exit(EXIT_FAILURE); } if (!ef_open(EF_SECTOR, EFF_MEM | EFF_NOTIME)) exit(1); write_sects(); qprint("writing to sectors file...\n"); if (!ef_close(EF_SECTOR)) exit(1); output(); qprint("\n\nA script for adding all the countries can be found in \"%s\".\n", outfile); if (!ORE) qprint("\t*** Resources have not been added ***\n"); exit(0); }