void watch_enemy_missile(void) { OBJECT *obj=current_proc->pa8; /* wem1 */ do { if (obj->oypos.u.intpos>SCY(260)) { /* wem9 */ missile_count--; delobj(obj); process_suicide(); } if (are_we_hitting_player()) { kill_player(); /* wem9 */ missile_count--; delobj(obj); process_suicide(); } /* wem2 */ process_sleep(1); } while(1); }
/* assemble call as string in C code */ void menu_ttest2() { char cmd[256]; done = 0; create_dialog(); setaction(bCancel, cancel2); show(win); for(;;) { R_WaitEvent(); R_ProcessEvents(); if(done > 0) break; } if(done == 1) { sprintf(cmd, "t.test(x=%s, y=%s, alternative=\"%s\",\n paired=%s, var.equal=%s, conf.level=%s)\n", v[0], v[1], alts[getlistitem(alt)], ischecked(paired) ? "TRUE" : "FALSE", ischecked(varequal) ? "TRUE" : "FALSE", GA_gettext(lvl)); Rconsolecmd(cmd); } hide(win); delobj(bApply); delobj(win); }
void CmOutputDriver(void) { struct objlist *graobj, *g2wobj; int id, g2wid, g2woid; N_VALUE *g2winst; int ret; struct savedstdio stdio; if (Menulock || Globallock) return; if (Menulocal.select_data && ! SetFileHidden()) return; FileAutoScale(); AdjustAxis(); graobj = chkobject("gra"); if (graobj == NULL) return; g2wobj = chkobject("gra2prn"); if (g2wobj == NULL) return; g2wid = newobj(g2wobj); if (g2wid < 0) return; DriverDialog(&DlgDriver, g2wobj, g2wid); ret = DialogExecute(TopLevel, &DlgDriver); if (ret == IDOK) { SetStatusBar(_("Spawning external driver.")); g2winst = chkobjinst(g2wobj, g2wid); _getobj(g2wobj, "oid", g2winst, &g2woid); id = newobj(graobj); init_graobj(graobj, id, "gra2prn", g2woid); ignorestdio(&stdio); draw_gra(graobj, id, _("Drawing."), TRUE); restorestdio(&stdio); delobj(graobj, id); ResetStatusBar(); } delobj(g2wobj, g2wid); if (Menulocal.select_data) { FileWinUpdate(NgraphApp.FileWin.data.data, TRUE); } }
void awsp11(OBJECT *pa9) { create_explosions_a4((current_proc->pa8)->oxpos.u.intpos,(current_proc->pa8)->oypos.u.intpos); delobj(pa9); missile_count--; return; }
void ce4b(void) { OBJECT *obj; XYTYPE temp; gso_dmawnz(obj,(ADDRESS)&expld1,hidden_anims,0); alloc_cache(&expld1,&hidden_anims,obj); temp.yx=(LONG)current_proc->pa9; set_xy_coordinates(obj,temp.u.xpos+2,temp.u.ypos+5); insert_object(obj,&objlst); process_sleep(2); set_xy_coordinates(obj,temp.u.xpos+2,temp.u.ypos+5); animate(SINGLE_ANI,&expld2,obj->oflags); process_sleep(2); animate(SINGLE_ANI,&expld3,obj->oflags); process_sleep(2); animate(SINGLE_ANI,&expld4,obj->oflags); process_sleep(2); animate(SINGLE_ANI,&expld5,obj->oflags); process_sleep(2); delobj(obj); process_suicide(); }
void CmMergeUpdate(void *w, gpointer client_data) { struct narray farray; struct objlist *obj; int i, j; int *array, num; if (Menulock || Globallock) return; if ((obj = chkobject("merge")) == NULL) return; if (chkobjlastinst(obj) == -1) return; SelectDialog(&DlgSelect, obj, FileCB, (struct narray *) &farray, NULL); if (DialogExecute(TopLevel, &DlgSelect) == IDOK) { num = arraynum(&farray); array = arraydata(&farray); for (i = 0; i < num; i++) { MergeDialog(NgraphApp.MergeWin.data.data, array[i], -1); if (DialogExecute(TopLevel, &DlgMerge) == IDDELETE) { delobj(obj, array[i]); set_graph_modified(); for (j = i + 1; j < num; j++) array[j]--; } } MergeWinUpdate(NgraphApp.MergeWin.data.data, TRUE); } arraydel(&farray); }
void CmMergeClose(void *w, gpointer client_data) { struct narray farray; struct objlist *obj; int i; int num, *array; if (Menulock || Globallock) return; if ((obj = chkobject("merge")) == NULL) return; if (chkobjlastinst(obj) == -1) return; SelectDialog(&DlgSelect, obj, FileCB, (struct narray *) &farray, NULL); if (DialogExecute(TopLevel, &DlgSelect) == IDOK) { num = arraynum(&farray); array = arraydata(&farray); for (i = num - 1; i >= 0; i--) { delobj(obj, array[i]); set_graph_modified(); } MergeWinUpdate(NgraphApp.MergeWin.data.data, TRUE); } arraydel(&farray); }
void take_gold() { #ifndef GOLDOBJ if (u.ugold <= 0) { You("VERB_HAVE eine seltsame Empfindung."); /* EN You_feel("a strange sensation."); */ } else { You("VERB_BEMERKEN, dass SUBJECT_IM_SATZ PRONOMEN_PERSONAL kein Gold mehr VERB_HAVE!"); /* EN You("notice you have no gold!"); */ u.ugold = 0; flags.botl = 1; } #else struct obj *otmp, *nobj; int lost_money = 0; for (otmp = invent; otmp; otmp = nobj) { nobj = otmp->nobj; if (otmp->oclass == COIN_CLASS) { lost_money = 1; delobj(otmp); } } if (!lost_money) { You("VERB_HAVE eine seltsame Empfindung."); /* EN You_feel("a strange sensation."); */ } else { You("VERB_BEMERKEN, dass SUBJECT_IM_SATZ PRONOMEN_PERSONAL kein Gold mehr VERB_HAVE!"); /* EN You("notice you have no money!"); */ flags.botl = 1; } #endif }
/* take away the hero's money */ void take_gold() { struct obj *otmp, *nobj; int lost_money = 0; for (otmp = invent; otmp; otmp = nobj) { nobj = otmp->nobj; if (otmp->oclass == COIN_CLASS) { lost_money = 1; remove_worn_item(otmp, FALSE); delobj(otmp); } } if (!lost_money) { /*JP You_feel("a strange sensation."); */ You("奇妙な感覚を覚えた."); } else { /*JP You("notice you have no money!"); */ You("お金を持ってないことに気がついた!"); context.botl = 1; } }
void take_gold() { #ifndef GOLDOBJ if (u.ugold <= 0) { You_feel("a strange sensation."); } else { You("notice you have no gold!"); u.ugold = 0; flags.botl = 1; } #else struct obj *otmp, *nobj; int lost_money = 0; for (otmp = invent; otmp; otmp = nobj) { nobj = otmp->nobj; if (otmp->oclass == COIN_CLASS) { lost_money = 1; delobj(otmp); } } if (!lost_money) { You_feel("a strange sensation."); } else { You("notice you have no money!"); flags.botl = 1; } #endif }
void CmMergeOpen(void *w, gpointer client_data) { struct objlist *obj; char *name = NULL; int id, ret; if (Menulock || Globallock) return; if ((obj = chkobject("merge")) == NULL) return; if (nGetOpenFileName(TopLevel, _("Add Merge file"), "gra", NULL, NULL, &name, TRUE, Menulocal.changedirectory) != IDOK || ! name) return; id = newobj(obj); if (id >= 0) { changefilename(name); putobj(obj, "file", id, name); MergeDialog(NgraphApp.MergeWin.data.data, id, -1); ret = DialogExecute(TopLevel, &DlgMerge); if ((ret == IDDELETE) || (ret == IDCANCEL)) { delobj(obj, id); } else { set_graph_modified(); } } else { g_free(name); } MergeWinUpdate(NgraphApp.MergeWin.data.data, TRUE); }
SEXP menu_ttest3() { char cmd[256]; SEXP cmdSexp, cmdexpr, ans = R_NilValue; int i; ParseStatus status; done = 0; create_dialog(); setaction(bCancel, cancel2); show(win); for(;;) { R_WaitEvent(); R_ProcessEvents(); if(done > 0) break; } if(done == 1) { sprintf(cmd, "t.test(x=%s, y=%s, alternative=\"%s\",\n paired=%s, var.equal=%s, conf.level=%s)\n", v[0], v[1], alts[getlistitem(alt)], ischecked(paired) ? "TRUE" : "FALSE", ischecked(varequal) ? "TRUE" : "FALSE", GA_gettext(lvl)); } hide(win); delobj(bApply); delobj(win); if(done == 1) { PROTECT(cmdSexp = allocVector(STRSXP, 1)); SET_STRING_ELT(cmdSexp, 0, mkChar(cmd)); cmdexpr = PROTECT(R_ParseVector(cmdSexp, -1, &status, R_NilValue)); if (status != PARSE_OK) { UNPROTECT(2); error("invalid call %s", cmd); } /* Loop is needed here as EXPSEXP will be of length > 1 */ for(i = 0; i < length(cmdexpr); i++) ans = eval(VECTOR_ELT(cmdexpr, i), R_GlobalEnv); UNPROTECT(2); } return ans; }
/* just retrieve values from the dialog box and assemble call in interpreted code */ void menu_ttest(char **vars, int ints[], double level[]) { done = 0; create_dialog(); setaction(bCancel, cancel); show(win); for(;;) { R_WaitEvent(); R_ProcessEvents(); if(done > 0) break; } vars[0] = v[0]; vars[1] = v[1]; ints[0] = getlistitem(alt); ints[1] = ischecked(paired); ints[2] = ischecked(varequal); ints[3] = done; level[0] = R_atof(GA_gettext(lvl)); hide(win); delobj(bApply); delobj(win); }
OBJECT *wte1(OBJECT *pa0) { if ( pa0->oypos.u.intpos<0 ) { missile_count--; delobj(pa0); return(NULL); } else { return(pa0); } }
static bool revive(struct obj *obj) { struct monst *mtmp = NULL; if(obj->olet == FOOD_SYM && obj->otyp > CORPSE) { /* do not (yet) revive shopkeepers */ /* Note: this might conceivably produce two monsters at the same position - strange, but harmless */ mtmp = mkmon_at(CORPSE_I_TO_C(obj->otyp),obj->ox,obj->oy); delobj(obj); } return(!!mtmp); /* TRUE if some monster created */ }
static bool bhito(struct obj *obj, struct obj *otmp) /* object obj was hit by the effect of wand otmp */ /* returns TRUE if sth was done */ { int res = TRUE; if(obj == uball || obj == uchain) res = FALSE; else switch(otmp->otyp) { case WAN_POLYMORPH: /* preserve symbol and quantity, but turn rocks into gems */ mkobj_at((obj->otyp == ROCK || obj->otyp == ENORMOUS_ROCK) ? GEM_SYM : obj->olet, obj->ox, obj->oy) -> quan = obj->quan; delobj(obj); break; case WAN_STRIKING: if(obj->otyp == ENORMOUS_ROCK) fracture_rock(obj); else res = FALSE; break; case WAN_CANCELLATION: if(obj->spe && obj->olet != AMULET_SYM) { obj->spe = 0; } break; case WAN_TELEPORTATION: rloco(obj); break; case WAN_MAKE_INVISIBLE: obj->oinvis = 1; break; case WAN_UNDEAD_TURNING: res = revive(obj); break; case WAN_SLOW_MONSTER: /* no effect on objects */ case WAN_SPEED_MONSTER: #ifdef WAN_PROBING case WAN_PROBING: #endif /* WAN_PROBING */ res = FALSE; break; default: impossible("What an interesting wand (%u)", otmp->otyp); } return(res); }
void be_9(WORD flag) { if (flag) { rsnd_enemy_boom(); delobj(current_proc->pa8); } /* be_99 */ if (--count_left==0) { game_over_w(); } process_suicide(); }
static void changeFont(control c) { char fontname[LF_FACESIZE+4]; if (samplefont) delobj(samplefont); if(ischecked(tt_font)) strcpy(fontname, "TT "); else strcpy(fontname, ""); if (sampleFontNum >= 0) { strcat(fontname, FontsList[sampleFontNum]); } else strcat(fontname, gettext(f_font)); samplefont = gnewfont(NULL, fontname, sampleStyle, samplePointsize, 0.0, 1); settextfont(guisample, samplefont); clickColor(c, getlistitem(guicolor)); }
void stealgold (struct monst *mtmp) { struct obj *gold = g_at(u.ux, u.uy); long tmp; if (gold && ( !u.ugold || gold->quan > u.ugold || !rn2(5))) { mtmp->mgold += gold->quan; delobj(gold); newsym(u.ux, u.uy); message_monster(MSG_M_QUICKLY_SNATCHES_GOLD_FROM_BEETWEEN_YOUR_LEGS, mtmp); if(!u.ugold || !rn2(5)) { if (!tele_restrict(mtmp)) (void) rloc(mtmp, false); /* do not set mtmp->mavenge here; gold on the floor is fair game */ monflee(mtmp, 0, false, false); } } else if(u.ugold) { u.ugold -= (tmp = somegold()); Your("purse feels lighter."); mtmp->mgold += tmp; if (!tele_restrict(mtmp)) (void) rloc(mtmp, false); mtmp->mavenge = 1; monflee(mtmp, 0, false, false); } }
int windelmenuitem(const char * item, const char * menu, char *errmsg) { int i; char mitem[1002]; if (strlen(item) + strlen(menu) > 1000) { strcpy(errmsg, G_("menu + item is limited to 1000 bytes")); return 5; } strcpy(mitem, menu); strcat(mitem, "/"); strcat(mitem, item); for (i = 0; i < nitems; i++) { if (strcmp(mitem, umitems[i]->name) == 0) break; } if (i == nitems) { strcpy(errmsg, G_("menu or item does not exist")); return 3; } delobj(umitems[i]->m); strcpy(umitems[i]->name, "invalid"); free(umitems[i]->action); show(RConsole); return 0; }
static void cleanup(void) { hide(wconfig); delobj(l_mdi); delobj(rb_mdi); delobj(rb_sdi); delobj(toolbar); delobj(statusbar); delobj(l_mwin); delobj(g_mwin); delobj(rb_mwin); delobj(rb_swin); delobj(l_lang); delobj(f_lang); delobj(l_font); delobj(f_font); delobj(tt_font); delobj(l_point); delobj(d_point); delobj(l_style); delobj(f_style); delobj(l_crows); delobj(f_crows); delobj(l_ccols); delobj(f_ccols); delobj(c_resize); delobj(c_buff); delobj(l_cx); delobj(f_cx); delobj(l_cy); delobj(f_cy); delobj(l_cbb); delobj(f_cbb); delobj(l_cbl); delobj(f_cbl); delobj(l_blink); delobj(f_blink); delobj(l_prows); delobj(f_prows); delobj(l_pcols); delobj(f_pcols); delobj(l_grx); delobj(f_grx); delobj(l_gry); delobj(f_gry); delobj(l_cols); delobj(guielement); delobj(guicolor); delobj(guisample); delobj(bApply); delobj(bSave); delobj(bOK); delobj(bCancel); delobj(wconfig); }
/* * return 1: guard moved, 0: guard didn't, -1: let m_move do it, -2: died */ int gd_move(struct monst *grd) { int x, y, nx, ny, m, n; int dx, dy, gx, gy, fci; unsigned char typ; struct fakecorridor *fcp; struct egd *egrd = EGD(grd); struct rm *crm; bool goldincorridor = false, u_in_vault = vault_occupied(u.urooms) ? true : false, grd_in_vault = *in_rooms(grd->mx, grd->my, VAULT) ? true : false; bool disappear_msg_seen = false, semi_dead = (grd->mhp <= 0); bool u_carry_gold = ((u.ugold + hidden_gold()) > 0L); bool see_guard; if (!on_level(&(egrd->gdlevel), &u.uz)) return (-1); nx = ny = m = n = 0; if (!u_in_vault && !grd_in_vault) wallify_vault(grd); if (!grd->mpeaceful) { if (semi_dead) { egrd->gddone = 1; goto newpos; } if (!u_in_vault && (grd_in_vault || (in_fcorridor(grd, grd->mx, grd->my) && !in_fcorridor(grd, u.ux, u.uy)))) { (void)rloc(grd, false); wallify_vault(grd); (void)clear_fcorr(grd, true); goto letknow; } if (!in_fcorridor(grd, grd->mx, grd->my)) (void)clear_fcorr(grd, true); return (-1); } if (abs(egrd->ogx - grd->mx) > 1 || abs(egrd->ogy - grd->my) > 1) return (-1); /* teleported guard - treat as monster */ if (egrd->fcend == 1) { if (u_in_vault && (u_carry_gold || um_dist(grd->mx, grd->my, 1))) { if (egrd->warncnt == 3) verbalize("I repeat, %sfollow me!", u_carry_gold ? (!u.ugold ? "drop that hidden gold and " : "drop that gold and ") : ""); if (egrd->warncnt == 7) { m = grd->mx; n = grd->my; verbalize("You've been warned, knave!"); mnexto(grd); levl[m][n].typ = egrd->fakecorr[0].ftyp; newsym(m, n); grd->mpeaceful = 0; return (-1); } /* not fair to get mad when (s)he's fainted or paralyzed */ if (!is_fainted() && multi >= 0) egrd->warncnt++; return (0); } if (!u_in_vault) { if (u_carry_gold) { /* player teleported */ m = grd->mx; n = grd->my; (void)rloc(grd, false); levl[m][n].typ = egrd->fakecorr[0].ftyp; newsym(m, n); grd->mpeaceful = 0; letknow: if (!cansee(grd->mx, grd->my) || !mon_visible(grd)) { You_hear("the shrill sound of a guard's whistle."); } else { const char * fmt = um_dist(grd->mx, grd->my, 2) ? "see an angry %s approaching." : "are confronted by an angry %s."; char name[BUFSZ]; g_monnam(name, BUFSZ, grd); You(fmt, name); } return (-1); } else { verbalize("Well, begone."); wallify_vault(grd); egrd->gddone = 1; goto cleanup; } } } if (egrd->fcend > 1) { if (egrd->fcend > 2 && in_fcorridor(grd, grd->mx, grd->my) && !egrd->gddone && !in_fcorridor(grd, u.ux, u.uy) && levl[egrd->fakecorr[0].fx][egrd->fakecorr[0].fy].typ == egrd->fakecorr[0].ftyp) { char name[BUFSZ]; g_monnam(name, BUFSZ, grd); pline_The("%s, confused, disappears.", name); disappear_msg_seen = true; goto cleanup; } if (u_carry_gold && (in_fcorridor(grd, u.ux, u.uy) || /* cover a 'blind' spot */ (egrd->fcend > 1 && u_in_vault))) { if (!grd->mx) { restfakecorr(grd); return (-2); } if (egrd->warncnt < 6) { egrd->warncnt = 6; verbalize("Drop all your gold, scoundrel!"); return (0); } else { verbalize("So be it, rogue!"); grd->mpeaceful = 0; return (-1); } } } for (fci = egrd->fcbeg; fci < egrd->fcend; fci++) if (g_at(egrd->fakecorr[fci].fx, egrd->fakecorr[fci].fy)) { m = egrd->fakecorr[fci].fx; n = egrd->fakecorr[fci].fy; goldincorridor = true; } if (goldincorridor && !egrd->gddone) { x = grd->mx; y = grd->my; if (m == u.ux && n == u.uy) { struct obj *gold = g_at(m, n); /* Grab the gold from between the hero's feet. */ grd->mgold += gold->quan; delobj(gold); newsym(m, n); } else if (m == x && n == y) { mpickgold(grd); /* does a newsym */ } else { /* just for insurance... */ if (MON_AT(m, n) && m != grd->mx && n != grd->my) { verbalize("Out of my way, scum!"); (void)rloc(m_at(m, n), false); } remove_monster(grd->mx, grd->my); newsym(grd->mx, grd->my); place_monster(grd, m, n); mpickgold(grd); /* does a newsym */ } if (cansee(m, n)) { char name[BUFSZ]; Monnam(name, BUFSZ, grd); pline("%s%s picks up the gold.", name, grd->mpeaceful ? " calms down and" : ""); } if (x != grd->mx || y != grd->my) { remove_monster(grd->mx, grd->my); newsym(grd->mx, grd->my); place_monster(grd, x, y); newsym(x, y); } if (!grd->mpeaceful) return (-1); else { egrd->warncnt = 5; return (0); } } if (um_dist(grd->mx, grd->my, 1) || egrd->gddone) { if (!egrd->gddone && !rn2(10)) verbalize("Move along!"); restfakecorr(grd); return (0); /* didn't move */ } x = grd->mx; y = grd->my; if (u_in_vault) goto nextpos; /* look around (hor & vert only) for accessible places */ for (nx = x - 1; nx <= x + 1; nx++) { for (ny = y - 1; ny <= y + 1; ny++) { if ((nx == x || ny == y) && (nx != x || ny != y) && isok(nx, ny)) { typ = (crm = &levl[nx][ny])->typ; if (!IS_STWALL(typ) && !IS_POOL(typ)) { if (in_fcorridor(grd, nx, ny)) goto nextnxy; if (*in_rooms(nx, ny, VAULT)) continue; /* seems we found a good place to leave him alone */ egrd->gddone = 1; if (ACCESSIBLE(typ)) goto newpos; crm->typ = (typ == SCORR) ? CORR : DOOR; if (crm->typ == DOOR) crm->flags = D_NODOOR; goto proceed; } } nextnxy: ; } } nextpos: nx = x; ny = y; gx = egrd->gdx; gy = egrd->gdy; dx = (gx > x) ? 1 : (gx < x) ? -1 : 0; dy = (gy > y) ? 1 : (gy < y) ? -1 : 0; if (abs(gx - x) >= abs(gy - y)) nx += dx; else ny += dy; while ((typ = (crm = &levl[nx][ny])->typ) != 0) { /* in view of the above we must have IS_WALL(typ) or typ == POOL */ /* must be a wall here */ if (isok(nx + nx - x, ny + ny - y) && !IS_POOL(typ) && IS_ROOM(levl[nx+nx-x][ny+ny-y].typ)) { crm->typ = DOOR; crm->flags = D_NODOOR; goto proceed; } if (dy && nx != x) { nx = x; ny = y + dy; continue; } if (dx && ny != y) { ny = y; nx = x + dx; dy = 0; continue; } /* I don't like this, but ... */ if (IS_ROOM(typ)) { crm->typ = DOOR; crm->flags = D_NODOOR; goto proceed; } break; } crm->typ = CORR; proceed: unblock_point(nx, ny); /* doesn't block light */ if (cansee(nx, ny)) newsym(nx, ny); fcp = &(egrd->fakecorr[egrd->fcend]); if (egrd->fcend++ == FCSIZ) impossible("fakecorr overflow"); fcp->fx = nx; fcp->fy = ny; fcp->ftyp = typ; newpos: if (egrd->gddone) { /* The following is a kludge. We need to keep */ /* the guard around in order to be able to make */ /* the fake corridor disappear as the player */ /* moves out of it, but we also need the guard */ /* out of the way. We send the guard to never- */ /* never land. We set ogx ogy to mx my in order */ /* to avoid a check at the top of this function. */ /* At the end of the process, the guard is killed */ /* in restfakecorr(). */ cleanup: x = grd->mx; y = grd->my; see_guard = canspotmon(grd); wallify_vault(grd); remove_monster(grd->mx, grd->my); newsym(grd->mx, grd->my); place_monster(grd, 0, 0); egrd->ogx = grd->mx; egrd->ogy = grd->my; restfakecorr(grd); if (!semi_dead && (in_fcorridor(grd, u.ux, u.uy) || cansee(x, y))) { if (!disappear_msg_seen && see_guard) { char name[BUFSZ]; g_monnam(name, BUFSZ, grd); pline("Suddenly, the %s disappears.", name); } return (1); } return (-2); } egrd->ogx = grd->mx; /* update old positions */ egrd->ogy = grd->my; remove_monster(grd->mx, grd->my); place_monster(grd, nx, ny); newsym(grd->mx, grd->my); restfakecorr(grd); return (1); }
WORD fp_9d(void) { delobj(current_proc->pa8); return(SYSTEM_CARRY_SET); }
void CmOutputPrinter(int select_file, int show_dialog) { GtkPrintOperation *print; GtkPrintOperationResult res; char buf[MESSAGE_BUF_SIZE]; struct objlist *graobj, *g2wobj; int id, g2wid, g2woid, opt; N_VALUE *g2winst; GError *error; struct print_obj pobj; GtkPaperSize *paper_size; GtkPageSetup *page_setup; if (Menulock || Globallock) return; if (select_file && ! SetFileHidden()) return; FileAutoScale(); AdjustAxis(); graobj = chkobject("gra"); if (graobj == NULL) return; g2wobj = chkobject("gra2gtkprint"); if (g2wobj == NULL) return; g2wid = newobj(g2wobj); if (g2wid < 0) return; putobj(g2wobj, "use_opacity", g2wid, &Menulocal.use_opacity); g2winst = chkobjinst(g2wobj, g2wid); _getobj(g2wobj, "oid", g2winst, &g2woid); id = newobj(graobj); init_graobj(graobj, id, "gra2gtkprint", g2woid); print = gtk_print_operation_new(); gtk_print_operation_set_n_pages(print, 1); #if GTK_CHECK_VERSION(2, 18, 0) gtk_print_operation_set_has_selection(print, FALSE); gtk_print_operation_set_support_selection(print, FALSE); gtk_print_operation_set_embed_page_setup(print, FALSE); #endif gtk_print_operation_set_use_full_page(print, TRUE); if (PrintSettings == NULL) PrintSettings = gtk_print_settings_new(); if (Menulocal.PaperId == PAPER_ID_CUSTOM) { paper_size = gtk_paper_size_new_custom(Menulocal.PaperName, Menulocal.PaperName, Menulocal.PaperWidth / 100.0, Menulocal.PaperHeight / 100.0, GTK_UNIT_MM); } else { paper_size = gtk_paper_size_new(Menulocal.PaperName); } page_setup = gtk_page_setup_new(); gtk_page_setup_set_paper_size(page_setup, paper_size); if (Menulocal.PaperLandscape) { gtk_page_setup_set_orientation(page_setup, GTK_PAGE_ORIENTATION_LANDSCAPE); } else { gtk_page_setup_set_orientation(page_setup, GTK_PAGE_ORIENTATION_PORTRAIT); } gtk_print_operation_set_default_page_setup(print, page_setup); gtk_print_operation_set_print_settings(print, PrintSettings); pobj.graobj = graobj; pobj.id = id; pobj.g2wobj = g2wobj; pobj.g2winst = g2winst; g_signal_connect(print, "draw_page", G_CALLBACK(draw_page), &pobj); switch (show_dialog) { case PRINT_SHOW_DIALOG_NONE: opt = GTK_PRINT_OPERATION_ACTION_PRINT; break; case PRINT_SHOW_DIALOG_PREVIEW: opt = GTK_PRINT_OPERATION_ACTION_PREVIEW; break; case PRINT_SHOW_DIALOG_DIALOG: opt = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG; break; default: opt = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG; } res = gtk_print_operation_run(print, opt, GTK_WINDOW(TopLevel), &error); if (res == GTK_PRINT_OPERATION_RESULT_ERROR) { snprintf(buf, sizeof(buf), _("Printing error: %s"), error->message); message_box(NULL, buf, _("Print"), RESPONS_ERROR); g_error_free(error); } else if (res == GTK_PRINT_OPERATION_RESULT_APPLY) { if (PrintSettings) g_object_unref(PrintSettings); PrintSettings = g_object_ref(gtk_print_operation_get_print_settings(print)); } g_object_unref(print); delobj(graobj, id); delobj(g2wobj, g2wid); if (select_file && NgraphApp.FileWin.data.data) { FileWinUpdate(NgraphApp.FileWin.data.data, TRUE); } }
static void CmOutputEMF(int type) { struct objlist *graobj, *g2wobj; int id, g2wid, g2woid; N_VALUE *g2winst; int ret; char *title, *ext_str; char *file, *tmp; if (Menulock || Globallock) return; title = "Save as Windows Enhanced Metafile (EMF)"; file = NULL; if (type == MenuIdOutputEMFFile) { ext_str = "emf"; tmp = get_base_ngp_name(); ret = nGetSaveFileName(TopLevel, title, ext_str, NULL, tmp, &file, FALSE, Menulocal.changedirectory); if (tmp) { g_free(tmp); } if (ret != IDOK) { return; } if (file == NULL) { return; } } if (Menulocal.select_data && ! SetFileHidden()) return; FileAutoScale(); AdjustAxis(); graobj = chkobject("gra"); if (graobj == NULL) { g_free(file); return; } g2wobj = chkobject("gra2emf"); if (g2wobj == NULL) { g_free(file); return; } g2wid = newobj(g2wobj); if (g2wid < 0) { g_free(file); return; } g2winst = chkobjinst(g2wobj, g2wid); _getobj(g2wobj, "oid", g2winst, &g2woid); id = newobj(graobj); putobj(g2wobj, "file", g2wid, file); init_graobj(graobj, id, "gra2emf", g2woid); draw_gra(graobj, id, _("Drawing."), TRUE); delobj(graobj, id); delobj(g2wobj, g2wid); if (Menulocal.select_data) { FileWinUpdate(NgraphApp.FileWin.data.data, TRUE); } }
static void CmPrintGRAFile(void) { struct objlist *graobj, *g2wobj; int id, g2wid, g2woid, ret; N_VALUE *g2winst; char *tmp, *file; if (Menulock || Globallock) return; tmp = get_base_ngp_name(); ret = nGetSaveFileName(TopLevel, _("GRA file"), "gra", NULL, tmp, &file, FALSE, Menulocal.changedirectory); if (tmp) g_free(tmp); if (ret != IDOK) return; if (file == NULL) { return; } if (Menulocal.select_data && ! SetFileHidden()) return; FileAutoScale(); AdjustAxis(); if ((graobj = chkobject("gra")) == NULL) { g_free(file); return; } if ((g2wobj = chkobject("gra2file")) == NULL) { g_free(file); return; } g2wid = newobj(g2wobj); if (g2wid < 0) { g_free(file); return; } g2winst = chkobjinst(g2wobj, g2wid); _getobj(g2wobj, "oid", g2winst, &g2woid); putobj(g2wobj, "file", g2wid, file); id = newobj(graobj); init_graobj(graobj, id, "gra2file", g2woid); draw_gra(graobj, id, _("Making GRA file."), TRUE); delobj(graobj, id); delobj(g2wobj, g2wid); if (Menulocal.select_data) { FileWinUpdate(NgraphApp.FileWin.data.data, TRUE); } }
static void CmOutputImage(int type) { struct objlist *graobj, *g2wobj; int id, g2wid, g2woid; N_VALUE *g2winst; int ret; char *title, *ext_str; char *file, *tmp; if (Menulock || Globallock) return; switch (type) { case MenuIdOutputPSFile: title = "Save as PostScript"; ext_str = "ps"; break; case MenuIdOutputEPSFile: title = "Save as Encapsulated PostScript"; ext_str = "eps"; break; case MenuIdOutputPDFFile: title = "Save as Portable Document Format (PDF)"; ext_str = "pdf"; break; case MenuIdOutputPNGFile: title = "Save as Portable Network Graphics (PNG)"; ext_str = "png"; break; case MenuIdOutputSVGFile: title = "Save as Scalable Vector Graphics (SVG)"; ext_str = "svg"; break; #ifdef CAIRO_HAS_WIN32_SURFACE case MenuIdOutputCairoEMFFile: title = "Save as Windows Enhanced Metafile (EMF)"; ext_str = "emf"; break; #endif /* CAIRO_HAS_WIN32_SURFACE */ default: /* not reachable */ title = NULL; ext_str = NULL; } tmp = get_base_ngp_name(); ret = nGetSaveFileName(TopLevel, title, ext_str, NULL, tmp, &file, FALSE, Menulocal.changedirectory); if (tmp) { g_free(tmp); } if (ret != IDOK) { return; } if (file == NULL) { return; } OutputImageDialog(&DlgImageOut, type); ret = DialogExecute(TopLevel, &DlgImageOut); if (ret != IDOK) { g_free(file); return; } if (Menulocal.select_data && ! SetFileHidden()) return; FileAutoScale(); AdjustAxis(); graobj = chkobject("gra"); if (graobj == NULL) { g_free(file); return; } g2wobj = chkobject("gra2cairofile"); if (g2wobj == NULL) { g_free(file); return; } g2wid = newobj(g2wobj); if (g2wid < 0) { g_free(file); return; } g2winst = chkobjinst(g2wobj, g2wid); _getobj(g2wobj, "oid", g2winst, &g2woid); id = newobj(graobj); putobj(g2wobj, "file", g2wid, file); switch (type) { case MenuIdOutputPSFile: case MenuIdOutputEPSFile: case MenuIdOutputSVGFile: case MenuIdOutputPDFFile: #ifdef CAIRO_HAS_WIN32_SURFACE case MenuIdOutputCairoEMFFile: #endif /* CAIRO_HAS_WIN32_SURFACE */ putobj(g2wobj, "text2path", g2wid, &DlgImageOut.text2path); break; case MenuIdOutputPNGFile: break; } putobj(g2wobj, "use_opacity", g2wid, &DlgImageOut.UseOpacity); putobj(g2wobj, "dpi", g2wid, &DlgImageOut.Dpi); putobj(g2wobj, "format", g2wid, &DlgImageOut.Version); init_graobj(graobj, id, "gra2cairofile", g2woid); draw_gra(graobj, id, _("Drawing."), TRUE); delobj(graobj, id); delobj(g2wobj, g2wid); if (Menulocal.select_data) { FileWinUpdate(NgraphApp.FileWin.data.data, TRUE); } }
/* Called every turn during chest-forcing. The caller must set u.utracked[tos_lock] to the chest in question. */ static int forcelock(void) { struct monst *shkp; boolean costly; struct obj *otmp; struct obj *box = u.utracked[tos_lock]; if (!obj_with_u(box)) return reset_pick(); if (!uwep_can_force()) /* prints the messages; ensures uwep != NULL */ return reset_pick(); if (u.uoccupation_progress[tos_lock]++ >= 50 || nohands(youmonst.data)) { pline(msgc_failrandom, "You give up your attempt to force the lock."); if (!nohands(youmonst.data)) exercise(is_blade(uwep) ? A_DEX : A_STR, TRUE); return reset_pick(); } if (is_blade(uwep)) { if (rn2(1000 - (int)uwep->spe) > (992 - greatest_erosion(uwep) * 10) && !uwep->cursed && !obj_resists(uwep, 0, 99)) { /* for a +0 weapon, probability that it survives an unsuccessful attempt to force the lock is (.992)^50 = .67 */ pline(msgc_substitute, "%sour %s broke!", (uwep->quan > 1L) ? "One of y" : "Y", xname(uwep)); useup(uwep); pline_implied(msgc_failcurse, "You can't exactly force that lock now."); exercise(A_DEX, TRUE); return reset_pick(); } } else /* blunt */ wake_nearby(FALSE); /* due to hammering on the container */ if (rn2(100) >= objects[uwep->otyp].oc_wldam * 2) return 1; /* still busy */ pline(msgc_actionok, "You succeed in forcing the lock."); box->olocked = 0; box->obroken = 1; costly = (*u.ushops && costly_spot(youmonst.mx, youmonst.my)); shkp = costly ? shop_keeper(level, *u.ushops) : 0; if (!is_blade(uwep) && !rn2(3)) { long loss = 0L; pline(msgc_substitute, "In fact, you've totally destroyed %s.", the(xname(box))); /* Put the contents on ground at the hero's feet. */ while ((otmp = box->cobj) != 0) { obj_extract_self(otmp); if (!rn2(3) || otmp->oclass == POTION_CLASS) { chest_shatter_msg(otmp); if (costly) loss += stolen_value(otmp, youmonst.mx, youmonst.my, (boolean) shkp->mpeaceful, TRUE); if (otmp->quan == 1L) { obfree(otmp, NULL); continue; } useup(otmp); } if (box->otyp == ICE_BOX && otmp->otyp == CORPSE) { otmp->age = moves - otmp->age; /* actual age */ start_corpse_timeout(otmp); } place_object(otmp, level, youmonst.mx, youmonst.my); stackobj(otmp); } if (costly) loss += stolen_value(box, youmonst.mx, youmonst.my, (boolean) shkp->mpeaceful, TRUE); if (loss) pline(msgc_unpaid, "You owe %ld %s for objects destroyed.", loss, currency(loss)); delobj(box); } else { if (costly) { struct obj *cobjbak = box->cobj; box->cobj = (struct obj *)0; verbalize(msgc_unpaid, "You damage it, you bought it!"); bill_dummy_object(box); box->cobj = cobjbak; } } exercise(is_blade(uwep) ? A_DEX : A_STR, TRUE); return reset_pick(); }
/* return 0 (no move), 1 (move) or 2 (dead) */ int dog_move(struct monst *mtmp, int after) { int nx, ny, omx, omy, appr, nearer, j; int udist, chi, i, whappr; struct monst *mtmp2; struct permonst *mdat = mtmp->data; struct edog *edog = EDOG(mtmp); struct obj *obj; struct trap *trap; xchar cnt, chcnt, nix, niy; schar dogroom, uroom; xchar gx, gy, gtyp, otyp; /* current goal */ coord poss[9]; int info[9]; #define GDIST(x,y) ((x-gx)*(x-gx) + (y-gy)*(y-gy)) #define DDIST(x,y) ((x-omx)*(x-omx) + (y-omy)*(y-omy)) if(moves <= edog->eattime) return(0); /* dog is still eating */ omx = mtmp->mx; omy = mtmp->my; whappr = (moves - EDOG(mtmp)->whistletime < 5); if(moves > edog->hungrytime + 500 && !mtmp->mconf){ mtmp->mconf = 1; mtmp->mhpmax /= 3; if(mtmp->mhp > mtmp->mhpmax) mtmp->mhp = mtmp->mhpmax; if(cansee(omx,omy)) pline("%s is confused from hunger.", Monnam(mtmp)); else pline("You feel worried about %s.", monnam(mtmp)); } else if(moves > edog->hungrytime + 750 || mtmp->mhp < 1){ if(cansee(omx,omy)) pline("%s dies from hunger.", Monnam(mtmp)); else pline("You have a sad feeling for a moment, then it passes."); mondied(mtmp); return(2); } dogroom = inroom(omx,omy); uroom = inroom(u.ux,u.uy); udist = dist(omx,omy); /* maybe we tamed him while being swallowed --jgm */ if(!udist) return(0); /* if we are carrying sth then we drop it (perhaps near @) */ /* Note: if apport == 1 then our behaviour is independent of udist */ if(mtmp->minvent){ if(!rn2(udist) || !rn2((int) edog->apport)) if(rn2(10) < edog->apport){ relobj(mtmp, (int) mtmp->minvis); if(edog->apport > 1) edog->apport--; edog->dropdist = udist; /* hpscdi!jon */ edog->droptime = moves; } } else { if ((obj = o_at(omx,omy))) if(!strchr("0_", obj->olet)){ if((otyp = dogfood(obj)) <= CADAVER){ nix = omx; niy = omy; goto eatobj; } if (obj->owt < 10*mtmp->data->mlevel) if (rn2(20) < edog->apport+3) if (rn2(udist) || !rn2((int) edog->apport)){ freeobj(obj); unpobj(obj); /* if(levl[omx][omy].scrsym == obj->olet) newsym(omx,omy); */ mpickobj(mtmp,obj); } } } /* first we look for food */ gtyp = UNDEF; /* no goal as yet */ gx = gy = 0; for(obj = fobj; obj; obj = obj->nobj) { otyp = dogfood(obj); if(otyp > gtyp || otyp == UNDEF) continue; if(inroom(obj->ox,obj->oy) != dogroom) continue; if(otyp < MANFOOD && (dogroom >= 0 || DDIST(obj->ox,obj->oy) < 10)) { if(otyp < gtyp || (otyp == gtyp && DDIST(obj->ox,obj->oy) < DDIST(gx,gy))){ gx = obj->ox; gy = obj->oy; gtyp = otyp; } } else if(gtyp == UNDEF && dogroom >= 0 && uroom == dogroom && !mtmp->minvent && edog->apport > rn2(8)){ gx = obj->ox; gy = obj->oy; gtyp = APPORT; } } if(gtyp == UNDEF || (gtyp != DOGFOOD && gtyp != APPORT && moves < edog->hungrytime)){ if(dogroom < 0 || dogroom == uroom){ gx = u.ux; gy = u.uy; #ifndef QUEST } else { int tmp = rooms[(int)dogroom].fdoor; cnt = rooms[(int)dogroom].doorct; gx = gy = FAR; /* random, far away */ while(cnt--){ if(dist(gx,gy) > dist(doors[tmp].x, doors[tmp].y)){ gx = doors[tmp].x; gy = doors[tmp].y; } tmp++; } /* here gx == FAR e.g. when dog is in a vault */ if(gx == FAR || (gx == omx && gy == omy)){ gx = u.ux; gy = u.uy; } #endif /* QUEST */ } appr = (udist >= 9) ? 1 : (mtmp->mflee) ? -1 : 0; if(after && udist <= 4 && gx == u.ux && gy == u.uy) return(0); if(udist > 1){ if (!IS_ROOM(levl[(int)u.ux][(int)u.uy].typ) || !rn2(4) || whappr || (mtmp->minvent && rn2((int) edog->apport))) appr = 1; } /* if you have dog food he'll follow you more closely */ if (appr == 0) { obj = invent; while(obj){ if(obj->otyp == TRIPE_RATION){ appr = 1; break; } obj = obj->nobj; } } } else appr = 1; /* gtyp != UNDEF */ if(mtmp->mconf) appr = 0; if(gx == u.ux && gy == u.uy && (dogroom != uroom || dogroom < 0)){ coord *cp; cp = gettrack(omx,omy); if(cp){ gx = cp->x; gy = cp->y; } } nix = omx; niy = omy; cnt = mfndpos(mtmp,poss,info,ALLOW_M | ALLOW_TRAPS); chcnt = 0; chi = -1; for(i=0; i<cnt; i++){ nx = poss[i].x; ny = poss[i].y; if(info[i] & ALLOW_M){ mtmp2 = m_at(nx,ny); if(mtmp2->data->mlevel >= mdat->mlevel+2 || mtmp2->data->mlet == 'c') continue; if(after) return(0); /* hit only once each move */ if(hitmm(mtmp, mtmp2) == 1 && rn2(4) && mtmp2->mlstmv != moves && hitmm(mtmp2,mtmp) == 2) return(2); return(0); } /* dog avoids traps */ /* but perhaps we have to pass a trap in order to follow @ */ if((info[i] & ALLOW_TRAPS) && (trap = t_at(nx,ny))){ if(!trap->tseen && rn2(40)) continue; if(rn2(10)) continue; } /* dog eschewes cursed objects */ /* but likes dog food */ obj = fobj; while(obj){ if(obj->ox != nx || obj->oy != ny) goto nextobj; if(obj->cursed) goto nxti; if(obj->olet == FOOD_SYM && (otyp = dogfood(obj)) < MANFOOD && (otyp < ACCFOOD || edog->hungrytime <= moves)){ /* Note: our dog likes the food so much that he might eat it even when it conceals a cursed object */ nix = nx; niy = ny; chi = i; eatobj: edog->eattime = moves + obj->quan * objects[obj->otyp].oc_delay; if(edog->hungrytime < moves) edog->hungrytime = moves; edog->hungrytime += 5*obj->quan * objects[obj->otyp].nutrition; mtmp->mconf = 0; if(cansee(nix,niy)) pline("%s ate %s.", Monnam(mtmp), doname(obj)); /* perhaps this was a reward */ if(otyp != CADAVER) edog->apport += 200/(edog->dropdist+moves-edog->droptime); delobj(obj); goto newdogpos; } nextobj: obj = obj->nobj; } for(j=0; j<MTSZ && j<cnt-1; j++) if(nx == mtmp->mtrack[j].x && ny == mtmp->mtrack[j].y) if(rn2(4*(cnt-j))) goto nxti; /* Some stupid C compilers cannot compute the whole expression at once. */ nearer = GDIST(nx,ny); nearer -= GDIST(nix,niy); nearer *= appr; if((nearer == 0 && !rn2(++chcnt)) || nearer<0 || (nearer > 0 && !whappr && ((omx == nix && omy == niy && !rn2(3)) || !rn2(12)) )){ nix = nx; niy = ny; if(nearer < 0) chcnt = 0; chi = i; } nxti: ; } newdogpos: if(nix != omx || niy != omy){ if(info[chi] & ALLOW_U){ (void) hitu(mtmp, d(mdat->damn, mdat->damd)+1); return(0); } mtmp->mx = nix; mtmp->my = niy; for(j=MTSZ-1; j>0; j--) mtmp->mtrack[j] = mtmp->mtrack[j-1]; mtmp->mtrack[0].x = omx; mtmp->mtrack[0].y = omy; } if(mintrap(mtmp) == 2) /* he died */ return(2); pmon(mtmp); return(1); }
int ngraph_object_del(struct objlist *obj, int id) { return delobj(obj, id); }