Exemple #1
0
void dspAPOpenItemsByVendor::sPopulateMenu(QMenu *pMenu, QTreeWidgetItem *selected, int)
{
  QString status(selected->text(1));
   
  QAction *menuItem;

  menuItem = pMenu->addAction(tr("Edit..."), this, SLOT(sEdit()));
  if (!_privileges->check("EditAPOpenItem"))
    menuItem->setEnabled(false);

  menuItem = pMenu->addAction(tr("View..."), this, SLOT(sView()));
  XSqlQuery menu;
  menu.prepare("SELECT apopen_status FROM apopen WHERE apopen_id=:apopen_id;");
  menu.bindValue(":apopen_id", list()->id());
  menu.exec();
  if (menu.first())
  {
    if(menu.value("apopen_status").toString() == "O")
    {
      menuItem = pMenu->addAction(tr("On Hold"), this, SLOT(sOnHold()));
      menuItem->setEnabled(_privileges->check("EditAPOpenItem"));
    }
    if(menu.value("apopen_status").toString() == "H") 
    {
      menuItem = pMenu->addAction(tr("Open"), this, SLOT(sOpen()));
      menuItem->setEnabled(_privileges->check("EditAPOpenItem"));
    }	
  }
}
Exemple #2
0
void Display_ARROW(char num, int x, int y)
{
    /* Look for explanations in place.c:PatchMe() */
    PatchHdrSmall P;
    FILE *in;
    in = sOpen("ARROWS.BUT", "rb", 0);
    fseek(in, (num) * (sizeof P), SEEK_CUR);
    fread(&P, sizeof P, 1, in);
    SwapPatchHdrSmall(&P);
    fseek(in, P.offset, SEEK_SET);

    if (P.w * P.h != P.size) {
        /* fprintf(stderr,
                "Display_ARROW(): w*h != size (%hhd*%hhd == %d != %hd)\n",
                P.w, P.h, P.w*P.h, P.size); */
        if ((P.w + 1) * P.h == P.size) {
            /* fprintf(stderr, "Display_ARROW(): P.w++ saves the day!\n"); */
            P.w++;
        }

        P.size = P.w * P.h;
    }

    display::Surface local(P.w, P.h);
    display::Surface local2(P.w, P.h);
    local2.copyFrom(display::graphics.screen(), x, y, x + P.w - 1, y + P.h - 1);
    fread(local.pixels(), P.size, 1, in);
    fclose(in);
// for (j=0;j<P.size;j++)
//   if(local.vptr[j]!=0) local2.vptr[j]=local.vptr[j];
    local.copyTo(display::graphics.screen(), x, y);
}
Exemple #3
0
void DrawRevText(char plr, int val)
{
    int index = 0;
    int length = 0;
    int line = 0;
    FILE *fin;
    memset(buffer, 0x00, 10000);
    fin = sOpen("P_REV.DAT", "rb", 0);  // Read Mission Structure
    fseek(fin, 204 * 18 * plr + 204 * val, SEEK_SET);
    fread(buffer, 204, 1, fin);
    fclose(fin);

    display::graphics.setForegroundColor(1);

    grMoveTo(20, 140);

    do {
        if (buffer[index] == '*') {
            length = 0;
            index++;
            line++;
            grMoveTo(20, 140 + 12 * line);
        }

        draw_character(buffer[index]);
        length++;
        index++;
    } while (buffer[index] != 0);
}
Exemple #4
0
void selectPayments::sPopulateMenu(QMenu *pMenu,QTreeWidgetItem *selected)
{
  QString status(selected->text(1));
  int menuItem;
  XSqlQuery menu;
  menu.prepare( "SELECT apopen_status FROM apopen WHERE apopen_id=:apopen_id;");
  menu.bindValue(":apopen_id", _apopen->id());
  menu.exec();
  if (menu.first())
  {
    if(menu.value("apopen_status").toString() == "O")
	{
    menuItem = pMenu->insertItem(tr("On Hold"), this, SLOT(sOnHold()), 0);
      if (_privileges->check("EditAPOpenItem"))
	  	pMenu->setItemEnabled(menuItem, TRUE);
	  else
      pMenu->setItemEnabled(menuItem, FALSE);
    }
    if(menu.value("apopen_status").toString() == "H")
	{
	menuItem = pMenu->insertItem(tr("Open"), this, SLOT(sOpen()), 0);
	  if (_privileges->check("EditAPOpenItem"))
	  	pMenu->setItemEnabled(menuItem, TRUE);
	  else
	  pMenu->setItemEnabled(menuItem, FALSE);
	}
  }
}
Exemple #5
0
void PadPict(char poff)
{
    SimpleHdr table;
    FILE *in;
    display::AutoPal p(display::graphics.legacyScreen());

    in = sOpen("LFACIL.BUT", "rb", 0);
    fread_SimpleHdr(&table, 1, in);
    fseek(in, 6 * sizeof_SimpleHdr, SEEK_SET);
    fread(p.pal, 768, 1, in);
    fseek(in, table.offset, SEEK_SET);
    fread(buffer, table.size, 1, in);

    display::LegacySurface local(148, 148);
    display::LegacySurface local2(148, 148);

    RLED_img(buffer, local.pixels(), table.size, local.width(), local.height());
    fseek(in, (poff)*sizeof_SimpleHdr, SEEK_SET);
    fread_SimpleHdr(&table, 1, in);
    fseek(in, table.offset, SEEK_SET);
    fread(buffer, table.size, 1, in);
    RLED_img(buffer, local2.pixels(), table.size, local2.width(), local2.height());

    local2.copyTo(display::graphics.legacyScreen(), 168, 28);

    fclose(in);
}
Exemple #6
0
void MainWindow::manageSlots() {
    connect(nTitle, SIGNAL(textChanged(QString)), this, SLOT(sParse()));
    connect(editor, SIGNAL(textChanged()), this, SLOT(sParse()));
    connect(parse, SIGNAL(triggered()), this, SLOT(sParse()));
    connect(open, SIGNAL(triggered()), this, SLOT(sOpen()));
    connect(save, SIGNAL(triggered()), this, SLOT(sSave()));
    connect(newN, SIGNAL(triggered()), this, SLOT(sNew()));
    connect(about, SIGNAL(triggered()), this, SLOT(aboutProgramme()));
}
Exemple #7
0
void GetFailStat(struct XFails *Now, char *FName, int rnum)
{
    DEBUG2("->GetFailStat(struct XFails *Now,char *FName,int rnum %d)", rnum);
    int i;
    FILE *fin;
    int32_t count;
    struct Fdt {
        char Code[6];
        int32_t offset;
        int16_t size;
    } Pul;

    fin = sOpen("FAILS.CDR", "rb", 0);
    count = 44;
    fread(&count, sizeof count, 1, fin); // never written to file
    Swap32bit(count);
    fread(&Pul, sizeof Pul, 1, fin);
    Swap32bit(Pul.offset);
    Swap16bit(Pul.size);
    i = 0;

    while (xstrncasecmp(Pul.Code, FName, 4) != 0 && i < count) {
        fread(&Pul, sizeof Pul, 1, fin);
        Swap32bit(Pul.offset);
        Swap16bit(Pul.size);
        i++;
    }

    if (i == count) {
        fclose(fin);
        return;
    }

    fseek(fin, Pul.offset, SEEK_SET);

    if (rnum < 0) { // Unmanned portion
        do {
            fread(Now, sizeof(struct XFails), 1, fin);
            Swap32bit(Now->per);    // Only need to swap this one since we're checking only that

        } while (Now->per != rnum);
    } else {
        do {
            fread(Now, sizeof(struct XFails), 1, fin);
            Swap32bit(Now->per);
            Swap16bit(Now->code);
            Swap16bit(Now->val);
            Swap16bit(Now->xtra);
            Swap16bit(Now->fail);
        } while (Now->per <= rnum);
    };

    fclose(fin);

    DEBUG1("<-GetFailStat()");
}
void Load_FUT_BUT(void)
{
    FILE *fin;
    unsigned i;
    fin = sOpen("NFUTBUT.BUT", "rb", 0);
    i = fread(display::graphics.legacyScreen()->pixels(), 1, MAX_X * MAX_Y, fin);
    fclose(fin);
    RLED_img(display::graphics.legacyScreen()->pixels(), vh->pixels(), i, vh->width(), vh->height());
    return;
}
void Load_FUT_BUT(void)
{
  FILE *fin;
  unsigned i;
  fin=sOpen("NFUTBUT.BUT","rb",0);
  i=fread(screen,1,MAX_X*MAX_Y,fin);
  fclose(fin);
  RLED_img((char *)screen,(char *)vh.vptr,(unsigned)i,vh.w,vh.h);
  return;
}
Exemple #10
0
void Settings::setChar(const char *key, char value)
{
    FILE *file = sOpen(key, false);
    if(!file) {											// failed to open settings?
        Debug::out(LOG_ERROR, "Settings::setChar -- could not write key %s", key);
        return;
    }

    fputc(value, file);
    fclose(file);
}
Exemple #11
0
void Settings::setFloat(const char *key, float value)
{
	FILE *file = sOpen(key, false);
	if(!file) {											// failed to open settings?
		Debug::out(LOG_ERROR, "Settings::setFloat -- could not write key %s", key);
		return;
	}

	fprintf(file, "%f\n", value);
	fclose(file);
}
Exemple #12
0
ssize_t
load_audio_file(const char *name, char **data, size_t *size)
{
    mm_file mf;
    unsigned channels, rate;
    const size_t def_size = 16 * 1024;
    size_t offset = 0;
    ssize_t read = 0;
    double start = get_time();

    /* make compiler happy */
    start *= 1.0;

    assert(name);
    assert(data);
    assert(size);

    if (mm_open_fp(&mf, sOpen(name, "rb", FT_AUDIO)) < 0) {
        return -1;
    }

    if (mm_audio_info(&mf, &channels, &rate) < 0) {
        CWARNING3(audio, "no audio data in file `%s'", name);
        mm_close(&mf);
        return -1;
    }

    if (channels != 1 || rate != 11025) {
        CERROR3(audio, "file `%s' should be mono, 11025Hz", name);
        mm_close(&mf);
        return -1;
    }

    if (!*data) {
        *data = (char *)xmalloc(*size = def_size);
    }

    while (0 < (read = mm_decode_audio(&mf,
                                       *data + offset, *size - offset))) {
        offset += read;

        if (*size <= offset) {
            *data = (char *)xrealloc(*data, *size *= 2);
        }
    }

    mm_close(&mf);

    CDEBUG4(audio, "loading file `%s' took %5.4f seconds",
            name, get_time() - start);

    return offset;
}
void SetParameters(void)
{
  int i;
  FILE *fin;
  fin=sOpen("MISSION.DAT","rb",0);
  for (i=0;i<62;i++) {
    fread(&Mis,sizeof Mis,1,fin);
    V[i].A=Mis.Doc;  V[i].B=Mis.EVA;
    V[i].C=Mis.LM;   V[i].D=Mis.Jt;
    V[i].E=Mis.Days; V[i].X=Mis.mCrew;
    V[i].Z=Mis.Dur;
  }
  fclose(fin);
  return;
}
Exemple #14
0
/** Read sequence name array from file
 *
 * \param keyname Name of the file to read from
 * \param tbl Pointer to the tblinfo to fill
 */
void
frm_read_tbl(char *keyname, struct tblinfo *tbl)
{
    FILE *fin;
    int lo, hi;
    int idx;
    char *p;
    size_t max_name_len = 8;
    char name[max_name_len + 1];

    if ((fin = sOpen(keyname, "rb", 0)) == NULL) {
        WARNING2("Unable to open file '%s'.", keyname);
        return;
    }

    /* get number of sequence keys */
    lo = getc(fin);
    hi = getc(fin);
    tbl->count = (hi << 8) | lo;

    /* alloc enough memory for all the sequence names */
    tbl->strings = (char **)xcalloc(tbl->count, sizeof * tbl->strings);

    idx = 0;

    while (fread(name, 1, max_name_len, fin) == max_name_len) {
        name[max_name_len] = '\0';

        for (p = name; *p; p++) {
            *p = tolower(*p);

            if (*p == '#') {
                *p = '_';
            }
        }

        TRACE4("Found name '%s' at position %d in file %s.", name, idx, keyname);
        tbl->strings[idx++] = xstrdup(name);
    }

    /* now idx is number of read strings */
    if (tbl->count != idx) {
        tbl->count = idx;
        tbl->strings = (char **)xrealloc(tbl->strings, sizeof * tbl->strings);
    }

    fclose(fin);
}
Exemple #15
0
void Settings::setBool(const char *key, bool value)
{
	FILE *file = sOpen(key, false);
	if(!file) {											// failed to open settings?
		Debug::out(LOG_ERROR, "Settings::setBool -- could not write key %s", key);
		return;
	}

	if(value) {					// if true, write 1
		fputs("1\n", file);
	} else {					// if false, write 0
		fputs("0\n", file);
	}

	fclose(file);
}
Exemple #16
0
void PresPict(char poff)
{
    SimpleHdr table;
    FILE *in;
    in = sOpen("PRESR.BUT", "rb", 0);
    fseek(in, poff * sizeof_SimpleHdr, SEEK_SET);
    fread_SimpleHdr(&table, 1, in);
    fseek(in, table.offset, SEEK_SET);
    fread(&display::graphics.palette()[96], 672, 1, in);
    fread(buffer, table.size, 1, in);
    fclose(in);
    display::Surface local(126, 84);
    RLED_img(buffer, local.pixels(), table.size, local.width(), local.height());

    local.copyTo(display::graphics.screen(), 183, 33);
}
Exemple #17
0
void HModel(char mode, char tx)
{
    SimpleHdr table;

    FILE *in;

    in = sOpen("PRFX.BUT", "rb", 0);
    fseek(in, (mode == 0 || mode == 1 || mode == 4)*sizeof_SimpleHdr, SEEK_CUR);
    fread_SimpleHdr(&table, 1, in);
    fseek(in, table.offset, SEEK_SET);
    display::LegacySurface local(127, 80);
    {
        display::AutoPal p(display::graphics.legacyScreen());
        fread(&p.pal[112 * 3], 96 * 3, 1, in); // Individual Palette
    }
    fread(buffer, table.size, 1, in); // Get Image
    fclose(in);

    vhptr->palette().copy_from(display::graphics.legacyScreen()->palette());

    RLED_img(buffer, local.pixels(), table.size, local.width(), local.height());

    local.filter(0, 112, display::LegacySurface::Any);

    fill_rectangle(96, 114, 223, 194, 0);

    local.copyTo(display::graphics.legacyScreen(), 97, 115);
    display::graphics.setForegroundColor(11);

    if (mode == 2 || mode == 3) {
        draw_string(100, 122, "HISTORICAL MODEL");
    } else if (mode == 0 || mode == 1) {
        draw_string(100, 122, "BASIC MODEL");
    } else if (mode == 4 || mode == 5) {
        draw_string(100, 122, "RANDOM MODEL");
    }

    display::graphics.setForegroundColor(9);

    if (mode == 0 || mode == 2 || mode == 4) {
        draw_string(100, 128, "HISTORICAL ROSTER");
    } else {
        draw_string(100, 128, "CUSTOM ROSTER");
    }

    return;
}
void dspAPOpenItemsByVendor::sPopulateMenu(QMenu *pMenu, QTreeWidgetItem *selected, int)
{
  QString status(selected->text(1));
   
  QAction *menuItem;

  if (list()->currentItem()->text("f_doctype") == tr("Voucher"))
  {
    menuItem = pMenu->addAction(tr("View Voucher..."), this, SLOT(sViewVoucher()));
    menuItem->setEnabled(_privileges->check("ViewVouchers") || _privileges->check("MaintainVouchers"));
  }
  
  menuItem = pMenu->addAction(tr("Edit..."), this, SLOT(sEdit()));
  if (!_privileges->check("EditAPOpenItem"))
    menuItem->setEnabled(false);

  menuItem = pMenu->addAction(tr("View..."), this, SLOT(sView()));
  XSqlQuery menu;
  menu.prepare("SELECT apopen_status FROM apopen WHERE apopen_id=:apopen_id;");
  menu.bindValue(":apopen_id", list()->id());
  menu.exec();
  if (menu.first())
  {
    if(menu.value("apopen_status").toString() == "O")
    {
      menuItem = pMenu->addAction(tr("On Hold"), this, SLOT(sOnHold()));
      menuItem->setEnabled(_privileges->check("EditAPOpenItem"));
    }
    if(menu.value("apopen_status").toString() == "H") 
    {
      menuItem = pMenu->addAction(tr("Open"), this, SLOT(sOpen()));
      menuItem->setEnabled(_privileges->check("EditAPOpenItem"));
    }	
  }

  menuItem = pMenu->addAction(tr("Print..."), this, SLOT(sPrintItem()));
  if (!_privileges->check("EditAPOpenItem"))
    menuItem->setEnabled(false);

  if (list()->currentItem()->text("f_doctype") == tr("Credit Memo"))
  {
    pMenu->addSeparator();
    menuItem = pMenu->addAction(tr("Apply Credit Memo..."), this, SLOT(sApplyAPOpenCM()));
    menuItem->setEnabled(_privileges->check("ApplyAPMemos"));
  }
}
Exemple #19
0
void AI_Begin(char plr)
{
    int i;
    FILE *fin;
    int32_t len[2];


    for (i = 0; i < 768; i++) {
        pal[i] = 0;
    }

    fin = sOpen("TURN.BUT", "rb", 0);
    fread(&pal, 768, 1, fin);
    len[0] = fread(screen, 1, MAX_X * MAX_Y, fin);
    fclose(fin);
    RLED_img((char *)screen, vhptr.vptr, (unsigned int)len[0],
             vhptr.w, vhptr.h);

    gxClearDisplay(0, 0);
    ShBox(0, 60, 319, 80);
    grSetColor(6 + plr * 3);

    if (plr == 0) {
        DispBig(15, 64, "DIRECTOR OF THE UNITED STATES", 0, -1);
    } else {
        DispBig(30, 64, "CHIEF DESIGNER OF THE USSR", 0, -1);
    }

    grSetColor(11);
    grMoveTo(175, 122);

    if (Data->Season == 0) {
        PrintAt(0, 0, "SPRING 19");
    } else {
        PrintAt(0, 0, "FALL 19");
    }

    DispNum(0, 0, Data->Year);
    gxVirtualDisplay(&vhptr, 1 + 110 * plr, 1, 30, 85, 30 + 107, 85 + 93, 0);
    grSetColor(11);
    PrintAt(60, 58, "COMPUTER TURN:  THINKING...");
    music_start(M_SOVTYP);
    FadeIn(2, pal, 10, 0, 0);
    colss = 0;
}
Exemple #20
0
//-------------------------	
float Settings::getFloat(const char *key, float defValue)
{
	FILE *file = sOpen(key, true);
	if(!file) {											// failed to open settings?
		return defValue;
	}

	int res;
    float val;
	res = fscanf(file, "%f", &val);						// try to read the value
	fclose(file);
	
	if(res != 1) {										// failed to read value?
		return defValue;
	}
	
	return val;											// return
}
void selectPayments::sPopulateMenu(QMenu *pMenu,QTreeWidgetItem *selected)
{
  QString status(selected->text(1));
  QAction *menuItem;
  XTreeWidgetItem * item = (XTreeWidgetItem*)selected;

  if (_apopen->currentItem()->text("doctype") == tr("Voucher"))
  {
    menuItem = pMenu->addAction(tr("View Voucher..."), this, SLOT(sViewVoucher()));
    menuItem->setEnabled(_privileges->check("ViewVouchers") || _privileges->check("MaintainVouchers"));

    if(item->rawValue("selected") == 0.0)
    {
      menuItem = pMenu->addAction(tr("Void Voucher..."), this, SLOT(sVoidVoucher()));
      menuItem->setEnabled(_privileges->check("VoidPostedVouchers"));
    }
  }
  
  XSqlQuery menu;
  menu.prepare( "SELECT apopen_status FROM apopen WHERE apopen_id=:apopen_id;");
  menu.bindValue(":apopen_id", _apopen->id());
  menu.exec();
  if (menu.first())
  {
    menuItem = pMenu->addAction(tr("Edit A/P Open..."), this, SLOT(sEdit()));
    menuItem->setEnabled(_privileges->check("EditAPOpenItem"));
    
    pMenu->addAction(tr("View A/P Open..."), this, SLOT(sView()));
    
    menuItem = pMenu->addAction(tr("View G/L Series..."), this, SLOT(sViewGLSeries()));
    menuItem->setEnabled(_privileges->check("ViewGLTransactions"));

    if(menu.value("apopen_status").toString() == "O")
    {
      menuItem = pMenu->addAction(tr("On Hold"), this, SLOT(sOnHold()));
      menuItem->setEnabled(_privileges->check("EditAPOpenItem"));
    }
    if(menu.value("apopen_status").toString() == "H")
    {
      menuItem = pMenu->addAction(tr("Open"), this, SLOT(sOpen()));
      menuItem->setEnabled(_privileges->check("EditAPOpenItem"));
    }
  }
}
Exemple #22
0
//-------------------------	
int Settings::getInt(const char *key, int defValue)
{
	FILE *file = sOpen(key, true);
	if(!file) {											// failed to open settings?
//		Debug::out(LOG_DEBUG, "Settings::getInt -- returning default value for %s", key);
		return defValue;
	}

	int val, res;
	res = fscanf(file, "%d", &val);						// try to read the value
	fclose(file);
	
	if(res != 1) {										// failed to read value?
//		Debug::out(LOG_DEBUG, "Settings::getInt -- returning default value for %s", key);
		return defValue;
	}
	
	return val;											// return
}
Exemple #23
0
void PresPict(char poff)
{
    GXHEADER local;
    SimpleHdr table;
    FILE *in;
    in = sOpen("PRESR.BUT", "rb", 0);
    fseek(in, poff * sizeof_SimpleHdr, SEEK_SET);
    fread_SimpleHdr(&table, 1, in);
    fseek(in, table.offset, SEEK_SET);
    fread(&pal[96], 672, 1, in);
    fread(buffer, table.size, 1, in);
    fclose(in);
    GV(&local, 126, 84);
    RLED_img(buffer, local.vptr, table.size, local.w, local.h);

    gxPutImage(&local, gxSET, 183, 33, 0);

    DV(&local);
    return;
}
Exemple #24
0
void MainWindow::setSingnals()
{
    connect(fileMenuNew, SIGNAL(triggered()), this, SLOT( sNew() ));
    connect(fileMenuOpen, SIGNAL(triggered()), this, SLOT( sOpen() ));
    connect(fileMenuSave, SIGNAL(triggered()), this, SLOT( sSave() ));
    connect(fileMenuQuit, SIGNAL(triggered()), qApp, SLOT(quit() ));
    connect(fileMenuSaveAs, SIGNAL(triggered()), this, SLOT( sSaveAs() ));
    connect(this->ui->send_button, SIGNAL(clicked()), this, SLOT(sSend()));
    //connect(przyklad, SIGNAL(triggered()), this, SLOT( sEg((QString)"przyklad") ));
    connect(Run, SIGNAL(triggered()), this, SLOT( sRun() ));
    connect(Debug, SIGNAL(triggered()), this, SLOT( sDebug() ));
    connect(Stop, SIGNAL(triggered()), this, SLOT( sStop() ));

    connect(Undo, SIGNAL(triggered()), this, SLOT( sUndo() ));
    connect(Redo, SIGNAL(triggered()), this, SLOT( sRedo() ));

    connect(Copy, SIGNAL(triggered()), this, SLOT(sCopy()));
    connect(Cut, SIGNAL(triggered()), this, SLOT(sCut()));
    connect(Paste, SIGNAL(triggered()), this, SLOT(sPaste()));
    connect(toC, SIGNAL(triggered()), this, SLOT(sToC()));
    connect(toJava, SIGNAL(triggered()), this, SLOT(sToJava()));

}
Exemple #25
0
//-------------------------	
char *Settings::getString(const char *key, const char *defValue)
{
	static char buffer[256];
	memset(buffer, 0, 256);

	FILE *file = sOpen(key, true);
	if(!file) {											// failed to open settings?
//		Debug::out(LOG_DEBUG, "Settings::getString -- returning default value for %s", key);
		strcpy(buffer, defValue);
		return buffer;
	}

	char *res;
	res = fgets(buffer, 256, file);						// try to read the value
	fclose(file);
	
	if(res == NULL) {									// failed to read value?
//		Debug::out(LOG_DEBUG, "Settings::getString -- returning default value for %s", key);
		strcpy(buffer, defValue);
		return buffer;
	}
	
	return buffer;											// return
}
Exemple #26
0
bool Settings::getBool(const char *key, bool defValue)
{
	FILE *file = sOpen(key, true);
	if(!file) {											// failed to open settings?
//		Debug::out(LOG_DEBUG, "Settings::getBool -- returning default value for %s", key);
		return defValue;
	}

	int val, res;
	res = fscanf(file, "%d", &val);						// try to read the value
	fclose(file);
	
	if(res != 1) {										// failed to read value?
//		Debug::out(LOG_DEBUG, "Settings::getBool -- returning default value for %s", key);
		return defValue;
	}
	
	bool ret = false;									// convert int to bool
	if(val == 1) {
		ret = true;
	}
	
	return ret;											// return
}
char REvent(char plr)
{
  FILE *fin;
  int32_t NoMods=1,i=0,j=0;
  int16_t m;
  if (NoMods==1)
  {
    m=0;
    if (Data->P[plr].Budget<40) Data->P[plr].Budget=40;
    if (Data->P[plr].Budget<=50) j=0;
    if (Data->P[plr].Budget>50 && Data->P[plr].Budget<=90) j=1;
    if (Data->P[plr].Budget>90 && Data->P[plr].Budget<=110) j=2;
    if (Data->P[plr].Budget>110 && Data->P[plr].Budget<=140) j=3;
    if (Data->P[plr].Budget>140 && Data->P[plr].Budget<=160) j=4;
    if (Data->P[plr].Budget>160) j=5;

    fin=sOpen("NTABLE.DAT","rb",0);
    fseek(fin,(sizeof (i16)) * ((plr*60) + (j*10) + random(10)) ,SEEK_SET);
    fread(&m,sizeof m,1,fin);
		Swap16bit(m);
//    m=BudgetMods[Data->P[plr].Level][(j*10)+random(10)];  // orig code
    fclose(fin);

    Data->P[plr].Budget+=m;
    /*grSetColor(15);
    PrintAt(200,30,"BUDGET MOD: ");
    if (m<0) {PrintAt(0,0,"-");m*=-1;};
    DispNum(0,0,m);
    PrintAt(200,40,"BUDGET: ");
    DispNum(0,0,Data->P[plr].Budget);
    DispNum(100,10,Data->Events[Data->Count]);*/
  } /* end if */

  if (Data->Year<=60 && Data->Events[Data->Count]>44) return 1;
  if (Data->Year<=62 && Data->Events[Data->Count]>63) return 1;
  if (Data->Year<=65 && Data->Events[Data->Count]>80) return 1;

  switch(Data->Events[Data->Count])
  {
   case  0: NoMods=0;break;    // Nothing Event
   case  1: case 44: case 59: case 63:  // Nothing Events
   case 67: case 68: case 69: case 70:
   case 71: case 72: case 73: case 74:
   case 75: case 81: case 86:
   case 87: case 88: case 90: case 97:
   case 98: break;

   // Cash Modifier Events --------------------------

     case 30: case 32:
	      evflag=random(10)+1;
	      Data->P[plr].Cash+=evflag;
	      break;

     case 31: evflag=random(6)+random(6)+random(6)+3;
	      Data->P[plr].Cash+=evflag;
	      break;

     case 33:if (Data->P[plr].Cash<10) return 1;
         evflag=Data->P[plr].Cash/10;
	      Data->P[plr].Cash-=evflag;
	      break;

   // Budget Modifier Events ------------------------

     case  9: case 76: // Budget increase of 15 MB
	      Data->P[plr].Budget+=15;
	      NoMods=0;
	      break;

     case 45: // increase budget by total two 10 side dice this year
	      evflag=random(10)+random(10)+2;
	      Data->P[plr].Budget+=evflag;
	      NoMods=0;
	      break;

     case 46: // increase budget by 5 MB's
	      Data->P[plr].Budget+=5;
	      NoMods=0;
	      break;

     case 91: // increase budget by 20MB's in the budget
	      if (Data->Year>65) return 1;
	      Data->P[plr].Budget+=20;
	      NoMods=0;
	      break;

     case 92: // 20% or 20MB's whichever is less
	      if ((Data->P[plr].Budget/5) < 20) evflag=Data->P[plr].Budget*4/5;
	       else evflag=20;
	      Data->P[plr].Budget-=evflag;
	      break;

     case 95: // 30% or 30MB's whichever is less
	      if ((Data->P[plr].Budget/3) < 30) evflag=Data->P[plr].Budget*7/10;
	       else evflag=30;
	      Data->P[plr].Budget-=evflag;
	      evflag=Data->P[plr].Budget;
	      break;

     case 96: // 25% or 25Mb's whichever is less
	      if (Data->Year>72) return 1;
	      if ((Data->P[plr].Budget/4) < 25) evflag=Data->P[plr].Budget*3/4;
	       else evflag=25;
	      Data->P[plr].Budget-=evflag;
	      evflag=Data->P[plr].Budget;
	      break;

     case 99:// deduct 5 M.B.s from budget
         Data->P[plr].Budget-=5;
         break;

   // RD Modifier Events ----------------------------

     case  2: case 12: case 13: case 14:  // RD improve by 1 : season
     case 15: case 16: case 17: case 18:
	      Data->P[plr].RDMods+=1;
	      break;

     case  3: case 61: case 62:// Minus one on all R&D for ONE year
	      Data->P[plr].RDMods-=1;
	      Data->P[plr].RDYear=-1;
	      break;

     case 19: // minus 2 on each die roll for R&D this turn
	      Data->P[plr].RDMods-=2;
	      break;

     case 41: // R&D will decrease for one year
	      Data->P[plr].RDMods-=2;
	      Data->P[plr].RDYear-=2;
	      break;

     case 42: case 43: /* increment R&D cost by 1 on particular program */
	      evflag=RDMods(plr,0,1,1);
	      if (evflag==0) return 1;
	      break;


   // Improve/Subtract Tech to Other players -------------------

     case 5: case 47: // Improve tech of plr prog to other's prog
	      evflag=Steal(plr,0,1);
	      if (evflag==0) return 1;
	      break;

     case 6: case  7:
	      // Lower tech of plr prog to other's prog
	      evflag=Steal(plr,0,-1);
	      if (evflag==0) return 1;
	      break;

   // Special Events -------------------------------------------

     case  8: // Allow females into space program
	      Data->P[plr].Female=1;
	      break;

   // Launch Affected ------------------------------------------

     case 4: // Next Launch must be a manned launch.  If the launch
	      // is not so then -10 on Budget
	      //Data->P[plr].Plans=1;
	      break;

     case 10: /* Launch window for Launch #x is blocked */
          { 
              int choice[3] = {0,0,0};

              evflag=0;
              if (Data->P[plr].Mission[0].MissionCode > 0)
                  choice[evflag++] = 1;
              if (Data->P[plr].Mission[1].MissionCode > 0)
                  choice[evflag++] = 2;
              if (Data->P[plr].Mission[2].MissionCode > 0)
                  choice[evflag++] = 3;
              if (evflag==0)
                  return 1;
              evflag = choice[random(evflag)] - 1;
              xMODE |= xMODE_CLOUDS;
              ClrMiss(plr,evflag+3);
          }
          break;
     case 35: // may launch only one mission this year ??? Season?!?
         evflag=0;
         if (Data->P[plr].Mission[0].Joint==1 ||
              Data->P[plr].Mission[1].Joint==1) return 1;
	      if (Data->P[plr].Mission[0].MissionCode > 0) evflag+=1;
	      if (Data->P[plr].Mission[1].MissionCode > 0) evflag+=2;
	      if (Data->P[plr].Mission[2].MissionCode > 0) evflag+=4;
	      if (evflag==0) return 1;
	      switch (evflag)
	      {
		    case 1: evflag=0;break;
	       case 2: evflag=0;break;
		    case 3: ClrMiss(plr,1+3);break;
	     	 case 4: evflag=0;break;
		    case 5: ClrMiss(plr,2+3);break;
		    case 6: ClrMiss(plr,2+3);break;
		    case 7: ClrMiss(plr,1+3);ClrMiss(plr,2+3);break;
         };
         if (evflag==0) return 1;
	      break;

     case 36: /* damage launch facility */
         if (Data->P[plr].Mission[0].MissionCode==0) Data->P[plr].LaunchFacility[0]=15;
          else return 1;
	      break;

   // Program Saving cards ------------------------------------

     case 11: /* Select program and set safety save to 1 */
	      evflag=SaveMods(plr,0);
	      if (evflag==0) return 1;
	      break;

     case 77: // set Save for Capsule Program
	      evflag=SaveMods(plr,3);
	      if (evflag==0) return 1;
	      break;

     case 93: // set Save for LEM Program
	      evflag=SaveMods(plr,4);
	      if (evflag==0) return 1;
	      break;

     case 20: /* the most advanced rocket program is affected.
 		   drop the safety factor in half. */
	      evflag=0;
	      for (i=3;i>=0;i--)
	      if (Data->P[plr].Rocket[i].Num>=0 && Data->P[plr].Rocket[i].Safety>50) evflag++;
	      if (evflag==0) return 1;
	      for (i=3;i>=0;i--)
	       if (Data->P[plr].Rocket[i].Num>=0 && Data->P[plr].Rocket[i].Safety>50)
           {
		      evflag=Data->P[plr].Rocket[i].Safety/2;
		      Data->P[plr].Rocket[i].Safety-=evflag;
		      strcpy(&Name[0],&Data->P[plr].Rocket[i].Name[0]);
		      break;
		    };
	      break;

     case 21: // Probes' and Sats' Max SF and RD up 5% */
	      for (i=1;i<3;i++)
           {
		      Data->P[plr].Probe[i].MaxRD+=5;
		      Data->P[plr].Probe[i].MaxSafety+=5;
		     };
	      for (i=1;i<3;i++)
          {
           if (Data->P[plr].Probe[i].MaxSafety>=99)
		      Data->P[plr].Probe[i].MaxSafety=99;
		     if (Data->P[plr].Probe[i].MaxRD>Data->P[plr].Probe[i].MaxSafety)
		      Data->P[plr].Probe[i].MaxRD=Data->P[plr].Probe[i].MaxSafety;
	       };
	      break;

   case 22: case 84: /* roll six 6-sided dice and add to the current safety
		   factor of the program */
	      x=random(6)+random(6)+random(6)+random(6)+random(6)+random(6)+6;
	      evflag=NMod(plr,3,1,x);
	      if (evflag==0) return 1;
	      evflag=x;
	      break;

     case 23: /* this applies to the most advanced rocket program.
	      roll six 6-sided dice and add to the current
	      safety factor. */
	      x=random(6)+random(6)+random(6)+random(6)+random(6)+random(6)+6;
	      evflag=NMod(plr,2,1,x);
	      if (evflag==0) return 1;
	      evflag=x;
	      break;

     case 24:  /* this for most adv. satellites, roll four 6-sided
	       dice and add to safety factor. */
	      x=random(6)+random(6)+random(6)+random(6)+4;
	      evflag=NMod(plr,1,1,x);
	      if (evflag==0) return 1;
	      evflag=x;
	      break;

     case 94:  /* this for most adv capsule, roll four 6-sided
	       dice and add to safety factor. */
	      x=random(6)+random(6)+random(6)+random(6)+4;
	      evflag=NMod(plr,3,1,x);
	      if (evflag==0) return 1;
	      evflag=x;
	      break;


     case 25:  /* the blank is all rockets. R&D can't cure it.
	      the options are to launch one rocket at this setback,
	      or cancel launch. - 20% if no visit to repairs.*/
	       evflag=DamMod(plr,2,-20,15);
	      if (evflag==0) return 1;
	      break;

     case 26:  /* select most advanced manned program and reduce safety by 25%	*/
	      evflag=NMod(plr,3,-1,25);
	      if (evflag==0) return 1;
	      evflag=25;
	      break;

     case 27:  /* select most advanced probe program and reduce safety by 15%	*/
	      evflag=NMod(plr,1,-1,15);
	      if (evflag==0) return 1;
	      evflag=15;
	      break;

     case 79: evflag=NMod(plr,0,-1,20);
	      if (evflag==0) return 1;
	      evflag=20;
	      break;

     case 28: // hardware cost 50% less this season
	      Data->P[plr].TurnOnly=3;
	      break;

     case 29: // set the delay of the rockets to 2 == one year
	      for (i=0;i<5;i++)
		    Data->P[plr].Rocket[i].Delay=2;
	      break;

     case 34: /* 20% loss most advanced capsule */
	      evflag=NMod(plr,3,-1,20);
	      if (evflag==0) return 1;
	      evflag=20;
	      break;

     case 37:  /* cost 10MB repear or 10% safety loss on the most advanced probe */
	      evflag=DamMod(plr,1,-10,10);
	      if (evflag==0) return 1;
	      break;

     case 38: case  39: /* most adv. rocket program 10 MB's or 5% safety loss */
	      evflag=DamMod(plr,2,-5,10);
	      if (evflag==0) return 1;
	      break;

     case 40: /* blank a program 10 MB's or 10% safety loss */
	      evflag=DamMod(plr,0,-10,10);
	      if (evflag==0) return 1;
	      break;

     case 54: /* most advanced rocket program 15 MB's or 20% safety loss */
	      evflag=DamMod(plr,2,-20,15);
	      if (evflag==0) return 1;
	      break;

     case 55: /* most advanced rocket program 20 MB's or 10% safety loss */
	      evflag=DamMod(plr,3,-10,20);
	      if (evflag==0) return 1;
	      break;

     case 48: // safety increased for rockets up 5%
	      evflag=SaveMods(plr,2);
	      if (evflag==0) return 1;
	      break;

// Astronaut Portion ------------------------------------

     case 49: /* pick random astronaut retire, budget minus 5 MB's */
	      evflag=0;
     	      for (i=0;i<Data->P[plr].AstroCount;i++){
		if (!(Data->P[plr].Pool[i].Status==AST_ST_DEAD || Data->P[plr].Pool[i].Status==AST_ST_RETIRED))  
		  evflag++;
     	      }
	      if (evflag==0) return 1;
	      Data->P[plr].Budget-=5;
	      i=random(Data->P[plr].AstroCount);
	      while (Data->P[plr].Pool[i].Status==AST_ST_DEAD || Data->P[plr].Pool[i].Status==AST_ST_RETIRED)  
	        i=random(Data->P[plr].AstroCount);
	      Data->P[plr].Pool[i].RDelay=2;
	      Data->P[plr].Pool[i].Mood=10;
	      strcpy(&Name[0],&Data->P[plr].Pool[i].Name[0]);
	      if (plr==1) {
	     	  Data->P[plr].Pool[i].Status=AST_ST_RETIRED;
		     Data->P[plr].Pool[i].RDelay=0;
	      };
         if (Data->P[plr].Pool[i].Status==AST_ST_RETIRED)
          Replace_Snaut(plr);
	      break;

     case 50: // backup crew will fly mission
         evflag=0;
	      for (i=0;i<3;i++)
   		if (Data->P[plr].Mission[i].MissionCode>0) evflag++;
	       if (evflag==0) return 1;
	      i=0;
	      while (Data->P[plr].Mission[i].MissionCode==0) i++;
         Data->P[plr].Mission[i].PCrew=0;
	      Data->P[plr].Mission[i].Crew=Data->P[plr].Mission[i].BCrew;
         evflag=i;
	      break;

     case 51: /* astronaut killed delay all manned missons = 1 */
	      evflag=0;
     	   for (i=0;i<Data->P[plr].AstroCount;i++)
		    if (!(Data->P[plr].Pool[i].Status==AST_ST_DEAD || Data->P[plr].Pool[i].Status==AST_ST_RETIRED))  evflag++;
	      if (evflag==0) return 1;
	      Data->P[plr].Budget-=5;
	      i=random(Data->P[plr].AstroCount);
	      while (Data->P[plr].Pool[i].Status==AST_ST_DEAD || Data->P[plr].Pool[i].Status==AST_ST_RETIRED)  
	        i=random(Data->P[plr].AstroCount);
	      strcpy(&Name[0],&Data->P[plr].Pool[i].Name[0]);
	      Data->P[plr].Pool[i].Status=AST_ST_DEAD;
	      Data->P[plr].Other=2;
         xMODE |= xMODE_SPOT_ANIM; //trigger spot anim
         //cancel manned missions
        ClrMiss(plr,0+3);ClrMiss(plr,1+3);ClrMiss(plr,2+3);
	      break;

     case 52: 
	      evflag=0;
     	   for (i=0;i<Data->P[plr].AstroCount;i++)
		    if (!(Data->P[plr].Pool[i].Status==AST_ST_DEAD || Data->P[plr].Pool[i].Status==AST_ST_RETIRED))  evflag++;
	      if (evflag==0) return 1;
	      i=random(Data->P[plr].AstroCount);
	      while (Data->P[plr].Pool[i].Status==AST_ST_DEAD || Data->P[plr].Pool[i].Status==AST_ST_RETIRED)  
	        i=random(Data->P[plr].AstroCount);
         strcpy(&Name[0],&Data->P[plr].Pool[i].Name[0]);
	      Data->P[plr].Pool[i].Status=AST_ST_DEAD;
	      Data->P[plr].Other=2;
	      Replace_Snaut(plr);
	      break;

     case 60: case 53: evflag=0;
     	   for (i=0;i<Data->P[plr].AstroCount;i++)
		    if (!(Data->P[plr].Pool[i].Status==AST_ST_DEAD || Data->P[plr].Pool[i].Status==AST_ST_RETIRED))  evflag++;
	      if (evflag==0) return 1;
	      i=random(Data->P[plr].AstroCount);
	      while (Data->P[plr].Pool[i].Status==AST_ST_DEAD || Data->P[plr].Pool[i].Status==AST_ST_RETIRED)  
	        i=random(Data->P[plr].AstroCount);
         strcpy(&Name[0],&Data->P[plr].Pool[i].Name[0]);
	      Data->P[plr].Pool[i].Status=AST_ST_INJURED;
	      Data->P[plr].Pool[i].IDelay=2;
	      Data->P[plr].Pool[i].Special=4;
         Replace_Snaut(plr);
	      break;

     case 56: /* hardware 50% less this season */
	      Data->P[plr].TurnOnly=3;
	      break;

     case 57:
          for (i=0;i<3;i++) {
	         if (i==0 && plr==0) strcpy(&Data->P[plr].Pool[Data->P[plr].AstroCount].Name[0],"MANKE");
	         else if (i==1 && plr==0) strcpy(&Data->P[plr].Pool[Data->P[plr].AstroCount].Name[0],"POWELL");
	         else if (i==2 && plr==0) strcpy(&Data->P[plr].Pool[Data->P[plr].AstroCount].Name[0],"YEAGER");
	         else if (i==0 && plr==1) strcpy(&Data->P[plr].Pool[Data->P[plr].AstroCount].Name[0],"ILYUSHIN");
	         else if (i==1 && plr==1) strcpy(&Data->P[plr].Pool[Data->P[plr].AstroCount].Name[0],"SHIBORIN");
	         else if (i==2 && plr==1) strcpy(&Data->P[plr].Pool[Data->P[plr].AstroCount].Name[0],"DOLGOV");
		 /* The original bonus astronauts & cosmonauts were:
		    REEVES, CHAMBERLAIN, YEAGER & STIPPOV, SCHLICKBERND, FARGOV -Leon */

            Data->P[plr].Pool[Data->P[plr].AstroCount].Status=AST_ST_TRAIN_BASIC_1;
            Data->P[plr].Pool[Data->P[plr].AstroCount].Face=random(10)+1;
	         Data->P[plr].Pool[Data->P[plr].AstroCount].Service=1;
	         Data->P[plr].Pool[Data->P[plr].AstroCount].Compat=random(10)+1;
	         Data->P[plr].Pool[Data->P[plr].AstroCount].CR=random(2)+1;
	         Data->P[plr].Pool[Data->P[plr].AstroCount].CL=random(2)+1;
	         Data->P[plr].Pool[Data->P[plr].AstroCount].Group=9;
	         Data->P[plr].Pool[Data->P[plr].AstroCount].Mood=85+5*random(4);
 	         Data->P[plr].AstroCount++;
          }; 
	      break;

     case 58: // 50% chance explosion on pad
	      Data->P[plr].TurnOnly=5;
	      break;

     case 64: /* launch facility repair 10MB's */
         for (j=0;j<20;j++)
          {
           i=rand()%3;
           if (Data->P[plr].LaunchFacility[i]==1 && Data->P[plr].Mission[i].MissionCode==0) break;
          }
         if (j==20) return 1;
	      /* get which of the three facilities damaged */
	      Data->P[plr].LaunchFacility[i]=10;
	      break;

     case 65: // Gemini or Voskhod will cost additional 2MB's per spacecraft
	      if (Data->P[plr].Manned[1].Num<0) return 1;
	      Data->P[plr].Manned[1].UnitCost+=2;  // Used to say "InitCost", which effectively disabled this newscast -Leon
	      break;

     case 83: // Apollo or Soyuz will cost additional 3MB's per spacecraft
	      if (Data->P[plr].Manned[2].Num<0) return 1;
	      Data->P[plr].Manned[2].UnitCost+=3;
	      break;

     case 66:// mission delay
         evflag=0;
         for (i=0;i<3;i++) {
          if (Data->P[plr].Mission[i].MissionCode>0) {
           GetMisType(Data->P[plr].Mission[i].MissionCode);
           if (!Mis.Jt) evflag++;
           }
         }
         if (evflag==0) return 1;
         i=random(3);
         while(Data->P[plr].Mission[i].MissionCode==0 || Data->P[plr].Mission[i].Joint==1) i=random(3);
         evflag=i;
         memcpy(&Data->P[plr].Future[i],&Data->P[plr].Mission[i],sizeof(struct MissionType)); 
         memset(&Data->P[plr].Mission[i],0x00,sizeof(struct MissionType));
         for (i=0;i<Data->P[plr].Future[evflag].Men+1;i++)
          {
           j=Data->P[plr].Crew[Data->P[plr].Future[evflag].Prog][Data->P[plr].Future[evflag].PCrew-1][i]-1;
           Data->P[plr].Pool[j].Prime++;
           j=Data->P[plr].Crew[Data->P[plr].Future[evflag].Prog][Data->P[plr].Future[evflag].BCrew-1][i]-1;
           Data->P[plr].Pool[j].Prime++;
          }
	      break;

     case 78: /* most advanced capsule 10MB's or 10% safety */
	      evflag=DamMod(plr,3,-10,10);
	      if (evflag==0) return 1;
	      break;

     case 80: // Can't Deliver any Cap/Mods this year
        for (i=0;i<5;i++)
          Data->P[plr].Manned[i].Delay=2;
	      break;

     case 82: // Duration E Mission Required
	      Data->P[plr].FuturePlans=5;
	      break;

     case 85: // Primary Crew Scrubbed - Backup Will Fly
	      evflag=0;
	      for (i=0;i<3;i++)
   		if (Data->P[plr].Mission[i].MissionCode>0) evflag++;
	       if (evflag==0) return 1;
	      i=0;
	      while (Data->P[plr].Mission[i].MissionCode==0) i++;
	      Data->P[plr].Mission[i].Crew=Data->P[plr].Mission[i].BCrew;
         evflag=i;
	      break;

     case 89: /* random astronaut not active */
        evflag=0;
        for (i=0;i<Data->P[plr].AstroCount;i++)
           if (Data->P[plr].Pool[i].Status==AST_ST_ACTIVE) evflag++;
	      if (evflag==0) return 1;
	      i=random(Data->P[plr].AstroCount);
	      while(Data->P[plr].Pool[i].Status!=AST_ST_ACTIVE) i=random(Data->P[plr].AstroCount);
	      strcpy(&Name[0],&Data->P[plr].Pool[i].Name[0]);
	      Data->P[plr].Pool[i].Status= AST_ST_INJURED;
	      Data->P[plr].Pool[i].IDelay=2;
	      break;

     default: break;
  } // End of Switch

  return 0;
}
Exemple #28
0
    connect(_searchAct, SIGNAL(triggered()), this, SLOT(sSearch()));

    _infoAct = new QAction(tr("Info..."), this);
    _infoAct->setShortcut(QKeySequence(tr("Ctrl+Shift+I")));
    _infoAct->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    _infoAct->setToolTip(tr("View record information"));
    _infoAct->setEnabled(false);
    connect(_infoAct, SIGNAL(triggered()), this, SLOT(sInfo()));
    addAction(_infoAct);

    _openAct = new QAction(tr("Open..."), this);
    _openAct->setShortcut(QKeySequence(tr("Ctrl+Shift+O")));
    _openAct->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    _openAct->setToolTip(tr("Open record detail"));
    _openAct->setEnabled(false);
    connect(_openAct, SIGNAL(triggered()), this, SLOT(sOpen()));
    addAction(_openAct);

    _copyAct = new QAction(tr("Copy..."), this);
    _copyAct->setShortcut(QKeySequence(tr("Ctrl+Shift+C")));
    _copyAct->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    _copyAct->setToolTip(tr("Copy record detail"));
    _copyAct->setEnabled(false);
    connect(_copyAct, SIGNAL(triggered()), this, SLOT(sCopy()));
    addAction(_copyAct);
  
    _newAct = new QAction(tr("New..."), this);
    _newAct->setShortcut(QKeySequence(tr("Ctrl+Shift+N")));
    _newAct->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    _newAct->setToolTip(tr("Create new record"));
    _newAct->setEnabled(false);
void DrawFuture(char plr,int mis,char pad)
{
  int i,j;
  FILE *fin;
  unsigned sz;
  strcpy(IKEY,"k011");strcpy(IDT,"i011");
  
  JointFlag=0; // initialize joint flag
  F1=F2=F3=F4=FMen=F5=0;
  for (i=0;i<5;i++) lck[i]=status[i]=0;
  FadeOut(2,pal,10,0,0);
  Load_FUT_BUT();
  fin=sOpen("FMIN.IMG","rb",0);
  fread(&pal[0],768,1,fin);
  sz=fread(screen,1,MAX_X*MAX_Y,fin);
  fclose(fin);
  RLED_img((char *)screen,(char *)vhptr.vptr,sz,vhptr.w,vhptr.h);
  gxClearDisplay(0,0);

  gr_sync ();

    if (pad==2) JointFlag=0; // third pad automatic no joint mission
    else
      if (Data->P[plr].LaunchFacility[pad+1] == 1)
      {
       if (Data->P[plr].Future[pad+1].MissionCode==0) JointFlag=1; // if no mission then set joint flag
	  else if (Data->P[plr].Future[pad+1].part==1) // check if the part of that second mission is set
		 {
		  JointFlag=1;
		  Data->P[plr].Future[pad+1].MissionCode=0; // clear mission
		  Data->P[plr].Future[pad+1].part=0;
		 };
      };

  if (pad==1 || pad==0) {
    if (Data->P[plr].LaunchFacility[pad+1]==1) JointFlag=1;
  }

  i=Data->Year;j=Data->Season;
  TRACE3("--- Setting i=Year (%d), j=Season (%d)", i, j);
  if ((i==60 && j==0) || (i==62 && j==0) || (i==64 && j==0) ||
      (i==66 && j==0) || (i==69 && j==1) || (i==71 && j==1) ||
      (i==73 && j==1)) {

     gxVirtualVirtual(&vhptr,1,2,12,11,&vhptr,198,153,gxSET); /* Mars */
     MarFlag=1; } else MarFlag=0;
  if ((i==60 || i==64 || i==68 || i==72 || i==73 || i==77)) {
    gxVirtualVirtual(&vhptr,14,2,64,54,&vhptr,214,130,gxSET); /* Jup */
    JupFlag=1; } else JupFlag=0;
  if (i==61 || i==66 || i==72) {
    gxVirtualVirtual(&vhptr,66,2,114,53,&vhptr,266,135,gxSET); /* Sat */
    SatFlag=1; } else SatFlag=0;

  RectFill(1,1,318,21,3);RectFill(317,22,318,198,3);RectFill(1,197,316,198,3);
  RectFill(1,22,2,196,3);OutBox(0,0,319,199);InBox(3,3,30,19);
  InBox(3,22,316,196);
  IOBox(242,3,315,19);
  ShBox(5,24,183,47);
  ShBox(5,24,201,47); //name box
  ShBox(5,74,41,82); // RESET
  ShBox(5,49,53,72); //dur/man
  ShBox(43,74,53,82); // lock
  ShBox(80,74,90,82);
  ShBox(117,74,127,82);
  ShBox(154,74,164,82);
  ShBox(191,74,201,82);
  ShBox(5,84,16,130);   //arrows up
  ShBox(5,132,16,146); //middle box
  ShBox(5,148,16,194);   //    down
  ShBox(203,24,238,31);  // new right boxes
  RectFill(206,36,235,44,7);
  ShBox(203,33,238,47);
  InBox(205,35,236,45);
  UPArrow(8,95);DNArrow(8,157);
  
  gxVirtualDisplay(&vh,140,5,5,132,15,146,0);
  Toggle(5,1);draw_Pie(0);OutBox(5,49,53,72);
  Toggle(1,1);TogBox(55,49,0);
  Toggle(2,1);TogBox(92,49,0);
  Toggle(3,1);TogBox(129,49,0);

  FMen=F1=F2=F3=F4=F5=0;
  for (i=1;i<4;i++){
    if (status[i]!=0) {
      Toggle(i,1);
    }
  };
	 if (JointFlag==0) {
      F4=2;lck[4]=1;
      Toggle(4,1);
      InBox(191,74,201,82);
      PlaceRX(5);
      TogBox(166,49,1);
    }
	 else {
      F4=0; lck[4]=0;
      status[4]=0;
      Toggle(4,1);
      OutBox(191,74,201,82);
      ClearRX(5);
      TogBox(166,49,0);
    };

  gr_sync ();
  Missions(plr,8,37,mis,1);
  GetMinus(plr);
  grSetColor(5);
  /* lines of text are 1:8,30  2:8,37   3:8,44    */
  switch(pad) { // These used to say Pad 1, 2, 3  -Leon
    case 0: PrintAt(8,30,"PAD A:");break;
    case 1: PrintAt(8,30,"PAD B:");break;
    case 2: PrintAt(8,30,"PAD C:");break;
    default:break;
  };
  grSetColor(1);
  PrintAt(9,80,"RESET");
  PrintAt(256,13,"CONTINUE");
  grSetColor(11);
   if (Data->Season==0) PrintAt(200,9,"SPRING");
   else PrintAt(205,9,"FALL");
   PrintAt(206,16,"19");
   DispNum(0,0,Data->Year);
  grSetColor(1);
  FlagSm(plr,4,4);
  DispBig(40,5,"FUTURE MISSIONS",0,-1);
  FadeIn(2,pal,10,0,0);
  
  return;
}
/** Missions() will draw the future missions among other things
 * 
 * \param plr Player
 * \param X screen coord for mission name string
 * \param Y screen coord for mission name string
 * \param val mission number
 * \param bub if set to 0 or 3 the function will not draw stuff
 */
void Missions(char plr,int X,int Y,int val,char bub)
{
  TRACE5("->Missions(plr, X %d, Y %d, val %d, bub %c)", X, Y, val, bub);
  
  if (bub==1 || bub==3) {
    PianoKey(val);
    Bub_Count=0;   // set the initial bub_count
    ClearDisplay();
    RectFill(6,31,182,46,3);
    RectFill(80,25,175,30,3);grSetColor(5);
    PrintAt(55,30,"TYPE: ");DispNum(0,0,val);
    grSetColor(5);
    if (V[val].E>0) {
      if (F5 > V[val].E && Mis.Dur==1) DurPri(F5);
	     else DurPri(V[val].E);}
	      else DurPri(F5);
  } else grSetColor(1);
  MissionName(val,X,Y,24);
  if (bub==3) GetMinus(plr);
  if (bub==0 || bub==3) {return;}
  
    
	MSteps=sOpen("missSteps.dat","r",FT_DATA);
	if (fgets(missStep, 1024, MSteps) == NULL)
		memset (missStep, 0, sizeof missStep);

	while (!feof(MSteps)&&((missStep[0]-0x30)*10+(missStep[1]-0x30))!=val) {
		if (fgets(missStep, 1024, MSteps) == NULL)
			break;
	}
	fclose(MSteps);

  int n;
	for (n=2;missStep[n]!='Z';n++)
		switch (missStep[n]) {
			case 'A': Draw_IJ	(B_Mis(++n));	break;
			case 'B': Draw_IJV	(B_Mis(++n));	break;
			case 'C': OrbOut	(B_Mis(n+1),B_Mis(n+2),B_Mis(n+3));	n+=3;	break;
			case 'D': LefEarth	(B_Mis(n+1),B_Mis(n+2));	n+=2; 	break;
			case 'E': OrbIn		(B_Mis(n+1),B_Mis(n+2),B_Mis(n+3));	n+=3; 	break;
			case 'F': OrbMid	(B_Mis(n+1),B_Mis(n+2),B_Mis(n+3),B_Mis(n+4));	n+=4;	break;
			case 'G': LefOrb	(B_Mis(n+1),B_Mis(n+2),B_Mis(n+3),B_Mis(n+4));	n+=4;	break;
			case 'H': Draw_LowS	(B_Mis(n+1),B_Mis(n+2),B_Mis(n+3),B_Mis(n+4),B_Mis(n+5),B_Mis(n+6));	n+=6;	break;
			case 'I': Fly_By	();		break;
			case 'J': VenMarMerc	(B_Mis(++n));	break;
			case 'K': Draw_PQR	();		break;
			case 'L': Draw_PST	();		break;
			case 'M': Draw_GH	(B_Mis(n+1),B_Mis(n+2));	n+=2;	break;
			case 'N': Q_Patch	();		break;
			case 'O': RghtMoon	(B_Mis(n+1),B_Mis(n+2));	n+=2; 	break;
			case 'P': DrawLunPas	(B_Mis(n+1),B_Mis(n+2),B_Mis(n+3),B_Mis(n+4));	n+=4;	break;
			case 'Q': DrawLefMoon	(B_Mis(n+1),B_Mis(n+2)); 	n+=2;	break;
			case 'R': DrawSTUV	(B_Mis(n+1),B_Mis(n+2),B_Mis(n+3),B_Mis(n+4));	n+=4;	break;
			case 'S': Draw_HighS	(B_Mis(n+1),B_Mis(n+2),B_Mis(n+3));	n+=3;	break;
			case 'T': DrawMoon	(B_Mis(n+1),B_Mis(n+2),B_Mis(n+3),B_Mis(n+4),B_Mis(n+5),B_Mis(n+6),B_Mis(n+7));	n+=7;	break;
			case 'U': LefGap	(B_Mis(++n));	break;
			case 'V': S_Patch	(B_Mis(++n));	break;
			case 'W': DrawZ		();		break;
			default : break;
		}
  gr_sync ();
  MissionCodes(plr,MisType,Pad);
  TRACE1("<-Missions()");
}  // end function missions