// Destroy the overlay of two windows. void Rocface:: clear_overlay( const char *m1, const char *m2) { COM_assertion_msg( validate_object()==0, "Invalid object"); std::string n1 = m1; std::string n2 = m2; // Create new data structures for data transfer. std::string wn1, wn2; get_name( n1, n2, wn1); get_name( n2, n1, wn2); TRS_Windows::iterator it1 = _trs_windows.find( wn1); if ( it1 != _trs_windows.end()) { delete it1->second; _trs_windows.erase( it1); TRS_Windows::iterator it2 = _trs_windows.find( wn2); RFC_assertion( it2 != _trs_windows.end()); delete it2->second; _trs_windows.erase( it2); } else { std::cerr << "ROCFACE: ERROR: The overlay of window \"" << n1 << "\" and window \"" << n2 << "\" does not exist for deleting" << std::endl; RFC_assertion(false); MPI_Abort(MPI_COMM_WORLD, -1); } }
void Rocface:: set_tags( const COM::DataItem *src, const COM::DataItem *trg, const COM::DataItem *tags) { COM_assertion_msg( validate_object()==0, "Invalid object"); RFC_assertion( tags && tags->data_type() == COM_INT || tags->data_type() == COM_INTEGER ); std::string n1 = src->window()->name(); std::string n2 = trg->window()->name(); std::string wn2; get_name( n2, n1, wn2); TRS_Windows::iterator it2 = _trs_windows.find( wn2); if ( it2 == _trs_windows.end()) { std::cerr << "ROCFACE::ERROR: The overlay of window \"" << n1 << "\" and window \"" << n2 << "\" does not exist" << std::endl; RFC_assertion( false); MPI_Abort( MPI_COMM_WORLD, -1); } // Loop through the panes it2->second->set_tags( tags); }
// Write out the two windows in binary or Rocout format. // Precondition: The overlay has been computed previously. void Rocface:: write_overlay( const COM::DataItem *a1, const COM::DataItem *a2, const char *prefix1, const char *prefix2, const char *format) { COM_assertion_msg( validate_object()==0, "Invalid object"); std::string n1 = a1->window()->name(); std::string n2 = a2->window()->name(); // Create new data structures for data transfer. std::string wn1, wn2; get_name( n1, n2, wn1); get_name( n2, n1, wn2); TRS_Windows::iterator it1 = _trs_windows.find( wn1); if ( it1 == _trs_windows.end()) { std::cerr << "ROCFACE: ERROR: The overlay of window \"" << n1 << "\" and window \"" << n2 << "\" does not exist for output" << std::endl; RFC_assertion( false); MPI_Abort( MPI_COMM_WORLD, -1); } TRS_Windows::iterator it2 = _trs_windows.find( wn2); RFC_assertion( it2 != _trs_windows.end()); if ( prefix1 == NULL) prefix1 = n1.c_str(); if ( prefix2 == NULL) prefix2 = n2.c_str(); if ( it1->second->comm_rank()==0) { std::cout << "ROCFACE: Writing subdivision of window \"" << n1 << "\"...." << std::flush; } if ( format && std::strcmp( format, "Tecplot")==0) { it1->second->write_tec_ascii( (std::string(prefix1)+"_orig").c_str()); it1->second->write_tec_sub( prefix1); } else it1->second->write_sdv( prefix1, format); if ( it1->second->comm_rank()==0) { std::cout << "Done" << std::endl; } if ( it2->second->comm_rank()==0) { std::cout << "ROCFACE: Writing subdivision of window \"" << n2 << "\"...." << std::flush; } if ( format && std::strcmp( format, "Tecplot")==0) { it2->second->write_tec_ascii( (std::string(prefix2)+"_orig").c_str()); it2->second->write_tec_sub( prefix2); } else it2->second->write_sdv( prefix2, format); if ( it2->second->comm_rank()==0) { std::cout << "Done" << std::endl; } }
// Transfer data from a window to another using the traditional interpolation. void Rocface:: interpolate( const COM::DataItem *src, COM::DataItem *trg) { COM_assertion_msg( validate_object()==0, "Invalid object"); RFC_assertion( trg->is_nodal() && src->is_nodal()); transfer< Nodal_data_const, Nodal_data, false> ( src, trg, 1.); }
int doinvoke(struct obj *obj) { if (obj && !validate_object(obj, invoke_types, "invoke, break, or rub")) return 0; else if (!obj) obj = getobj(invoke_types, "invoke, break, or rub"); if (!obj) return 0; if (obj->oartifact && !touch_artifact(obj, &youmonst)) return 1; return arti_invoke(obj); }
int dowield(struct obj *wep) { struct obj *oldwep; int result; /* May we attempt this? */ multi = 0; if (cantwield(youmonst.data)) { pline("Don't be ridiculous!"); return 0; } /* Prompt for a new weapon */ if (wep && !validate_object(wep, wield_objs, "wield")) return 0; else if (!wep) wep = getobj(wield_objs, "wield"); if (!wep) /* Cancelled */ return 0; else if (wep == uwep) { pline("You are already wielding that!"); if (is_weptool(wep)) unweapon = FALSE; /* [see setuwep()] */ return 0; } else if (welded(uwep)) { weldmsg(uwep); /* previously interrupted armor removal mustn't be resumed */ reset_remarm(); return 0; } /* Handle no object, or object in other slot */ if (wep == &zeroobj) wep = NULL; else if (wep == uswapwep) return doswapweapon(); else if (wep == uquiver) setuqwep(NULL); else if (wep->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL | W_SADDLE)) { pline("You cannot wield that!"); return 0; } /* Set your new primary weapon */ oldwep = uwep; result = ready_weapon(wep); if (flags.pushweapon && oldwep && uwep != oldwep) setuswapwep(oldwep); untwoweapon(); return result; }
// Transfer data from a window to another using the least squares // data transfer formulation. void Rocface:: least_squares_transfer( const COM::DataItem *src, COM::DataItem *trg, const Real *alp_in, const int *ord_in, Real *tol_io, int *iter_io) { COM_assertion_msg( validate_object()==0, "Invalid object"); Real alpha = (alp_in == NULL) ? 1. : *alp_in; int order = (ord_in == NULL) ? 1+trg->is_nodal() : *ord_in; COM_assertion( alpha>=0 && alpha<=1); if ( trg->is_nodal()) { Real tol = (tol_io == NULL) ? 1.e-6 : *tol_io; int iter = (iter_io == NULL) ? 100 : *iter_io; if ( src->is_nodal()) { transfer<Nodal_data_const, Nodal_data, true> ( src, trg, alpha, order, &tol, &iter); } else { transfer<Facial_data_const, Nodal_data, true> ( src, trg, alpha, order, &tol, &iter); } if (tol_io != NULL) *tol_io = tol; if (iter_io != NULL) *iter_io = iter; } else { if ( src->is_nodal()) { transfer<Nodal_data_const, Facial_data, true> ( src, trg, alpha, order); } else { transfer< Facial_data_const, Facial_data, true> ( src, trg, alpha, order); } } }
// Associate two windows given by a1->window() and a2->window(). void Rocface:: overlay( const COM::DataItem *a1, const COM::DataItem *a2, const MPI_Comm *comm, const char *path) { COM_assertion_msg( validate_object()==0, "Invalid object"); std::string n1 = a1->window()->name(); std::string n2 = a2->window()->name(); Overlay ovl( a1->window(), a2->window(), path); ovl.set_tolerance( _ctrl.snap); // set tolerance for snapping vertices // Perform overlay ovl.overlay(); // Create new data structures for data transfer. std::string wn1, wn2; get_name( n1, n2, wn1); get_name( n2, n1, wn2); TRS_Windows::iterator it1 = _trs_windows.find( wn1); TRS_Windows::iterator it2 = _trs_windows.find( wn2); if ( it1 != _trs_windows.end()) { RFC_assertion( it2 != _trs_windows.end()); delete it1->second; delete it2->second; } else { it1 = _trs_windows. insert( TRS_Windows::value_type( wn1, NULL)).first; RFC_assertion( it2 == _trs_windows.end()); it2 = _trs_windows. insert( TRS_Windows::value_type( wn2, NULL)).first; } MPI_Comm com = (comm==NULL)?MPI_COMM_WORLD:*comm; it1->second = new RFC_Window_transfer(const_cast<COM::Window*>(a1->window()), BLUE, com); it2->second = new RFC_Window_transfer(const_cast<COM::Window*>(a2->window()), GREEN, com); ovl.export_windows( it1->second, it2->second); }
static void push_on_mark_stack(Managed_Object_Handle ref) { if(ref == NULL) { return; } if(mark_stack_ptr >= MARK_STACK_SIZE) { // Of course, it would be trivial to realloc the mark stack. DIE("Fatal GC error: exceeded mark stack"); } // Verify the referenced object. Object_With_Header *obj; if (GC::compressing_references) { Managed_Object_Handle ref2 = (Managed_Object_Handle)(GC::heap_base + (COMPRESSED_REFERENCE)ref); obj = (Object_With_Header *)(((Byte *)ref2) - sizeof(GC_Overhead)); } else { obj = (Object_With_Header *)(((Byte *)ref) - sizeof(GC_Overhead)); } validate_object(obj); mark_stack[mark_stack_ptr] = ref; mark_stack_ptr++; } //push_on_mark_stack
/* return 1 if action took 1 (or more) moves, 0 if error or aborted */ int doengrave(struct obj *otmp) { boolean dengr = FALSE; /* TRUE if we wipe out the current engraving */ boolean doblind = FALSE;/* TRUE if engraving blinds the player */ boolean doknown = FALSE;/* TRUE if we identify the stylus */ boolean eow = FALSE; /* TRUE if we are overwriting oep */ boolean jello = FALSE; /* TRUE if we are engraving in slime */ boolean ptext = TRUE; /* TRUE if we must prompt for engrave text */ boolean teleengr =FALSE;/* TRUE if we move the old engraving */ boolean zapwand = FALSE;/* TRUE if we remove a wand charge */ xchar type = DUST; /* Type of engraving made */ char buf[BUFSZ]; /* Buffer for final/poly engraving text */ char ebuf[BUFSZ]; /* Buffer for initial engraving text */ char qbuf[QBUFSZ]; /* Buffer for query text */ char post_engr_text[BUFSZ]; /* Text displayed after engraving prompt */ const char *everb; /* Present tense of engraving type */ const char *eloc; /* Where the engraving is (ie dust/floor/...) */ char *sp; /* Place holder for space count of engr text */ int len; /* # of nonspace chars of new engraving text */ int maxelen; /* Max allowable length of engraving text */ struct engr *oep = engr_at(level, u.ux,u.uy); /* The current engraving */ char *writer; multi = 0; /* moves consumed */ nomovemsg = NULL; /* occupation end message */ buf[0] = (char)0; ebuf[0] = (char)0; post_engr_text[0] = (char)0; maxelen = BUFSZ - 1; if (is_demon(youmonst.data) || youmonst.data->mlet == S_VAMPIRE) type = ENGR_BLOOD; /* Can the adventurer engrave at all? */ if (u.uswallow) { if (is_animal(u.ustuck->data)) { pline("What would you write? \"Jonah was here\"?"); return 0; } else if (is_whirly(u.ustuck->data)) { pline("You can't reach the %s.", surface(u.ux,u.uy)); return 0; } else jello = TRUE; } else if (is_lava(level, u.ux, u.uy)) { pline("You can't write on the lava!"); return 0; } else if (Underwater) { pline("You can't write underwater!"); return 0; } else if (is_pool(level, u.ux,u.uy) || IS_FOUNTAIN(level->locations[u.ux][u.uy].typ)) { pline("You can't write on the water!"); return 0; } if (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)/* in bubble */) { pline("You can't write in thin air!"); return 0; } if (cantwield(youmonst.data)) { pline("You can't even hold anything!"); return 0; } if (check_capacity(NULL)) return 0; /* One may write with finger, or weapon, or wand, or..., or... * Edited by GAN 10/20/86 so as not to change weapon wielded. */ if (otmp && !validate_object(otmp, styluses, "write with")) return 0; else if (!otmp) otmp = getobj(styluses, "write with"); if (!otmp) return 0; /* otmp == zeroobj if fingers */ if (otmp == &zeroobj) writer = makeplural(body_part(FINGER)); else writer = xname(otmp); /* There's no reason you should be able to write with a wand * while both your hands are tied up. */ if (!freehand() && otmp != uwep && !otmp->owornmask) { pline("You have no free %s to write with!", body_part(HAND)); return 0; } if (jello) { pline("You tickle %s with your %s.", mon_nam(u.ustuck), writer); pline("Your message dissolves..."); return 0; } if (otmp->oclass != WAND_CLASS && !can_reach_floor()) { pline("You can't reach the %s!", surface(u.ux,u.uy)); return 0; } if (IS_ALTAR(level->locations[u.ux][u.uy].typ)) { pline("You make a motion towards the altar with your %s.", writer); altar_wrath(u.ux, u.uy); return 0; } if (IS_GRAVE(level->locations[u.ux][u.uy].typ)) { if (otmp == &zeroobj) { /* using only finger */ pline("You would only make a small smudge on the %s.", surface(u.ux, u.uy)); return 0; } else if (!level->locations[u.ux][u.uy].disturbed) { pline("You disturb the undead!"); level->locations[u.ux][u.uy].disturbed = 1; makemon(&mons[PM_GHOUL], level, u.ux, u.uy, NO_MM_FLAGS); exercise(A_WIS, FALSE); return 1; } } /* SPFX for items */ switch (otmp->oclass) { default: case AMULET_CLASS: case CHAIN_CLASS: case POTION_CLASS: case COIN_CLASS: break; case RING_CLASS: /* "diamond" rings and others should work */ case GEM_CLASS: /* diamonds & other hard gems should work */ if (objects[otmp->otyp].oc_tough) { type = ENGRAVE; break; } break; case ARMOR_CLASS: if (is_boots(otmp)) { type = DUST; break; } /* fall through */ /* Objects too large to engrave with */ case BALL_CLASS: case ROCK_CLASS: pline("You can't engrave with such a large object!"); ptext = FALSE; break; /* Objects too silly to engrave with */ case FOOD_CLASS: case SCROLL_CLASS: case SPBOOK_CLASS: pline("Your %s would get %s.", xname(otmp), is_ice(level, u.ux, u.uy) ? "all frosty" : "too dirty"); ptext = FALSE; break; case RANDOM_CLASS: /* This should mean fingers */ break; /* The charge is removed from the wand before prompting for * the engraving text, because all kinds of setup decisions * and pre-engraving messages are based upon knowing what type * of engraving the wand is going to do. Also, the player * will have potentially seen "You wrest .." message, and * therefore will know they are using a charge. */ case WAND_CLASS: if (zappable(otmp)) { check_unpaid(otmp); zapwand = TRUE; if (Levitation) ptext = FALSE; switch (otmp->otyp) { /* DUST wands */ default: break; /* NODIR wands */ case WAN_LIGHT: case WAN_SECRET_DOOR_DETECTION: case WAN_CREATE_MONSTER: case WAN_WISHING: case WAN_ENLIGHTENMENT: zapnodir(otmp); break; /* IMMEDIATE wands */ /* If wand is "IMMEDIATE", remember to affect the * previous engraving even if turning to dust. */ case WAN_STRIKING: strcpy(post_engr_text, "The wand unsuccessfully fights your attempt to write!" ); break; case WAN_SLOW_MONSTER: if (!Blind) { sprintf(post_engr_text, "The bugs on the %s slow down!", surface(u.ux, u.uy)); } break; case WAN_SPEED_MONSTER: if (!Blind) { sprintf(post_engr_text, "The bugs on the %s speed up!", surface(u.ux, u.uy)); } break; case WAN_POLYMORPH: if (oep) { if (!Blind) { type = (xchar)0; /* random */ random_engraving(buf); } dengr = TRUE; } break; case WAN_NOTHING: case WAN_UNDEAD_TURNING: case WAN_OPENING: case WAN_LOCKING: case WAN_PROBING: break; /* RAY wands */ case WAN_MAGIC_MISSILE: ptext = TRUE; if (!Blind) { sprintf(post_engr_text, "The %s is riddled by bullet holes!", surface(u.ux, u.uy)); } break; /* can't tell sleep from death - Eric Backus */ case WAN_SLEEP: case WAN_DEATH: if (!Blind) { sprintf(post_engr_text, "The bugs on the %s stop moving!", surface(u.ux, u.uy)); } break; case WAN_COLD: if (!Blind) strcpy(post_engr_text, "A few ice cubes drop from the wand."); if (!oep || (oep->engr_type != BURN)) break; case WAN_CANCELLATION: case WAN_MAKE_INVISIBLE: if (oep && oep->engr_type != HEADSTONE) { if (!Blind) pline("The engraving on the %s vanishes!", surface(u.ux,u.uy)); dengr = TRUE; } break; case WAN_TELEPORTATION: if (oep && oep->engr_type != HEADSTONE) { if (!Blind) pline("The engraving on the %s vanishes!", surface(u.ux,u.uy)); teleengr = TRUE; } break; /* type = ENGRAVE wands */ case WAN_DIGGING: ptext = TRUE; type = ENGRAVE; if (!objects[otmp->otyp].oc_name_known) { if (flags.verbose) pline("This %s is a wand of digging!", xname(otmp)); doknown = TRUE; } if (!Blind) strcpy(post_engr_text, IS_GRAVE(level->locations[u.ux][u.uy].typ) ? "Chips fly out from the headstone." : is_ice(level, u.ux, u.uy) ? "Ice chips fly up from the ice surface!" : "Gravel flies up from the floor."); else strcpy(post_engr_text, "You hear drilling!"); break; /* type = BURN wands */ case WAN_FIRE: ptext = TRUE; type = BURN; if (!objects[otmp->otyp].oc_name_known) { if (flags.verbose) pline("This %s is a wand of fire!", xname(otmp)); doknown = TRUE; } strcpy(post_engr_text, Blind ? "You feel the wand heat up." : "Flames fly from the wand."); break; case WAN_LIGHTNING: ptext = TRUE; type = BURN; if (!objects[otmp->otyp].oc_name_known) { if (flags.verbose) pline("This %s is a wand of lightning!", xname(otmp)); doknown = TRUE; } if (!Blind) { strcpy(post_engr_text, "Lightning arcs from the wand."); doblind = TRUE; } else strcpy(post_engr_text, "You hear crackling!"); break; /* type = MARK wands */ /* type = ENGR_BLOOD wands */ } } else /* end if zappable */ if (!can_reach_floor()) { pline("You can't reach the %s!", surface(u.ux,u.uy)); /* If it's a wrestable wand, the player wasted a turn trying. */ if (wrestable(otmp)) return 1; else return 0; } break; case WEAPON_CLASS: if (is_blade(otmp)) { if ((int)otmp->spe > -3) type = ENGRAVE; else pline("Your %s too dull for engraving.", aobjnam(otmp,"are")); } break; case TOOL_CLASS: if (otmp == ublindf) { pline( "That is a bit difficult to engrave with, don't you think?"); return 0; } switch (otmp->otyp) { case MAGIC_MARKER: if (otmp->spe <= 0) pline("Your marker has dried out."); else type = MARK; break; case TOWEL: /* Can't really engrave with a towel */ ptext = FALSE; if (oep) if ((oep->engr_type == DUST ) || (oep->engr_type == ENGR_BLOOD) || (oep->engr_type == MARK )) { if (!Blind) pline("You wipe out the message here."); else pline("Your %s %s %s.", xname(otmp), otense(otmp, "get"), is_ice(level, u.ux, u.uy) ? "frosty" : "dusty"); dengr = TRUE; } else pline("Your %s can't wipe out this engraving.", xname(otmp)); else pline("Your %s %s %s.", xname(otmp), otense(otmp, "get"), is_ice(level, u.ux, u.uy) ? "frosty" : "dusty"); break; default: break; } break; case VENOM_CLASS: if (wizard) { pline("Writing a poison pen letter??"); break; } case ILLOBJ_CLASS: impossible("You're engraving with an illegal object!"); break; } if (IS_GRAVE(level->locations[u.ux][u.uy].typ)) { if (type == ENGRAVE || type == 0) type = HEADSTONE; else { /* ensures the "cannot wipe out" case */ type = DUST; dengr = FALSE; teleengr = FALSE; buf[0] = (char)0; } } /* End of implement setup */ /* Identify stylus */ if (doknown) { makeknown(otmp->otyp); more_experienced(0,10); } if (teleengr) { rloc_engr(oep); oep = NULL; } if (dengr) { del_engr(oep, level); oep = NULL; } /* Something has changed the engraving here */ if (*buf) { make_engr_at(level, u.ux, u.uy, buf, moves, type); pline("The engraving now reads: \"%s\".", buf); ptext = FALSE; } if (zapwand && (otmp->spe < 0)) { pline("%s %sturns to dust.", The(xname(otmp)), Blind ? "" : "glows violently, then "); if (!IS_GRAVE(level->locations[u.ux][u.uy].typ)) pline("You are not going to get anywhere trying to write in the %s with your dust.", is_ice(level, u.ux, u.uy) ? "frost" : "dust"); useup(otmp); ptext = FALSE; } if (!ptext) { /* Early exit for some implements. */ if (otmp->oclass == WAND_CLASS && !can_reach_floor()) pline("You can't reach the %s!", surface(u.ux,u.uy)); return 1; } /* Special effects should have deleted the current engraving (if * possible) by now. */ if (oep) { char c = 'n'; /* Give player the choice to add to engraving. */ if (type == HEADSTONE) { /* no choice, only append */ c = 'y'; } else if ( (type == oep->engr_type) && (!Blind || (oep->engr_type == BURN) || (oep->engr_type == ENGRAVE)) ) { c = yn_function("Do you want to add to the current engraving?", ynqchars, 'y'); if (c == 'q') { pline("Never mind."); return 0; } } if (c == 'n' || Blind) { if ( (oep->engr_type == DUST) || (oep->engr_type == ENGR_BLOOD) || (oep->engr_type == MARK) ) { if (!Blind) { pline("You wipe out the message that was %s here.", ((oep->engr_type == DUST) ? "written in the dust" : ((oep->engr_type == ENGR_BLOOD) ? "scrawled in blood" : "written"))); del_engr(oep, level); oep = NULL; } else /* Don't delete engr until after we *know* we're engraving */ eow = TRUE; } else if ( (type == DUST) || (type == MARK) || (type == ENGR_BLOOD) ) { pline( "You cannot wipe out the message that is %s the %s here.", oep->engr_type == BURN ? (is_ice(level, u.ux, u.uy) ? "melted into" : "burned into") : "engraved in", surface(u.ux,u.uy)); return 1; } else if ( (type != oep->engr_type) || (c == 'n') ) { if (!Blind || can_reach_floor()) pline("You will overwrite the current message."); eow = TRUE; } } } eloc = surface(u.ux,u.uy); switch(type){ default: everb = (oep && !eow ? "add to the weird writing on" : "write strangely on"); break; case DUST: everb = (oep && !eow ? "add to the writing in" : "write in"); eloc = is_ice(level, u.ux, u.uy) ? "frost" : "dust"; break; case HEADSTONE: everb = (oep && !eow ? "add to the epitaph on" : "engrave on"); break; case ENGRAVE: everb = (oep && !eow ? "add to the engraving in" : "engrave in"); break; case BURN: everb = (oep && !eow ? ( is_ice(level, u.ux,u.uy) ? "add to the text melted into" : "add to the text burned into") : ( is_ice(level, u.ux,u.uy) ? "melt into" : "burn into")); break; case MARK: everb = (oep && !eow ? "add to the graffiti on" : "scribble on"); break; case ENGR_BLOOD: everb = (oep && !eow ? "add to the scrawl on" : "scrawl on"); break; } /* Tell adventurer what is going on */ if (otmp != &zeroobj) pline("You %s the %s with %s.", everb, eloc, doname(otmp)); else pline("You %s the %s with your %s.", everb, eloc, makeplural(body_part(FINGER))); /* Prompt for engraving! */ sprintf(qbuf,"What do you want to %s the %s here?", everb, eloc); getlin(qbuf, ebuf); /* Count the actual # of chars engraved not including spaces */ len = strlen(ebuf); for (sp = ebuf; *sp; sp++) if (isspace(*sp)) len -= 1; if (len == 0 || strchr(ebuf, '\033')) { if (zapwand) { if (!Blind) pline("%s, then %s.", Tobjnam(otmp, "glow"), otense(otmp, "fade")); return 1; } else { pline("Never mind."); if (otmp && otmp->oclass == WAND_CLASS && wrestable(otmp)) return 1; /* disallow zero turn wrest */ else return 0; } } /* A single `x' is the traditional signature of an illiterate person */ if (len != 1 || (!strchr(ebuf, 'x') && !strchr(ebuf, 'X'))) u.uconduct.literate++; /* Mix up engraving if surface or state of mind is unsound. Note: this won't add or remove any spaces. */ for (sp = ebuf; *sp; sp++) { if (isspace(*sp)) continue; if (((type == DUST || type == ENGR_BLOOD) && !rn2(25)) || (Blind && !rn2(11)) || (Confusion && !rn2(7)) || (Stunned && !rn2(4)) || (Hallucination && !rn2(2))) *sp = ' ' + rnd(96 - 2); /* ASCII '!' thru '~' (excludes ' ' and DEL) */ } /* Previous engraving is overwritten */ if (eow) { del_engr(oep, level); oep = NULL; } /* Figure out how long it took to engrave, and if player has * engraved too much. */ switch(type){ default: multi = -(len/10); if (multi) nomovemsg = "You finish your weird engraving."; break; case DUST: multi = -(len/10); if (multi) nomovemsg = "You finish writing in the dust."; break; case HEADSTONE: case ENGRAVE: multi = -(len/10); if ((otmp->oclass == WEAPON_CLASS) && ((otmp->otyp != ATHAME) || otmp->cursed)) { multi = -len; maxelen = ((otmp->spe + 3) * 2) + 1; /* -2 = 3, -1 = 5, 0 = 7, +1 = 9, +2 = 11 * Note: this does not allow a +0 anything (except * an athame) to engrave "Elbereth" all at once. * However, you could now engrave "Elb", then * "ere", then "th". */ pline("Your %s dull.", aobjnam(otmp, "get")); if (otmp->unpaid) { struct monst *shkp = shop_keeper(level, *u.ushops); if (shkp) { pline("You damage it, you pay for it!"); bill_dummy_object(otmp); } } if (len > maxelen) { multi = -maxelen; otmp->spe = -3; } else if (len > 1) otmp->spe -= len >> 1; else otmp->spe -= 1; /* Prevent infinite engraving */ } else
// Read in the two windows in binary or Rocin format. void Rocface:: read_overlay( const COM::DataItem *a1, const COM::DataItem *a2, const MPI_Comm *comm, const char *prefix1, const char *prefix2, const char *format) { COM_assertion_msg( validate_object()==0, "Invalid object"); std::string n1 = a1->window()->name(); std::string n2 = a2->window()->name(); // Create new data structures for data transfer. std::string wn1, wn2; get_name( n1, n2, wn1); get_name( n2, n1, wn2); TRS_Windows::iterator it1 = _trs_windows.find( wn1); TRS_Windows::iterator it2 = _trs_windows.find( wn2); if ( it1 != _trs_windows.end()) { RFC_assertion( it2 != _trs_windows.end()); delete it1->second; delete it2->second; } else { it1 = _trs_windows. insert( TRS_Windows::value_type( wn1, NULL)).first; it2 = _trs_windows. insert( TRS_Windows::value_type( wn2, NULL)).first; } MPI_Comm com = (comm==NULL)?a1->window()->get_communicator():*comm; it1->second = new RFC_Window_transfer(const_cast<COM::Window*>(a1->window()), BLUE, com, prefix1, format); COM_assertion(comm||com==a2->window()->get_communicator()); it2->second = new RFC_Window_transfer(const_cast<COM::Window*>(a2->window()), GREEN, com, prefix2, format); if ( prefix1 == NULL) prefix1 = n1.c_str(); if ( prefix2 == NULL) prefix2 = n2.c_str(); if ( it1->second->comm_rank()==0) { std::cout << "ROCFACE: Reading in subdivision of window " << n1 << " from files with prefix \"" << prefix1 << "\"...." << std::flush; } it1->second->read_sdv( prefix1, format); if ( it1->second->comm_rank()==0) { std::cout << "Done" << std::endl; } if ( it2->second->comm_rank()==0) { std::cout << "ROCFACE: Reading in subdivision of window " << n2 << " from files with prefix \"" << prefix2 << "\"...." << std::flush; } it2->second->read_sdv( prefix2, format); if ( it2->second->comm_rank()==0) { std::cout << "Done" << std::endl; } }
int dowieldquiver(struct obj *newquiver) { const char *quivee_types = (uslinging() || (uswapwep && objects[uswapwep->otyp].oc_skill == P_SLING)) ? bullets : ready_objs; /* Since the quiver isn't in your hands, don't check cantwield(), */ /* will_weld(), touch_petrifies(), etc. */ multi = 0; if (newquiver && !validate_object(newquiver, quivee_types, "ready")) return 0; else if (!newquiver) /* Prompt for a new quiver */ newquiver = getobj(quivee_types, "ready"); if (!newquiver) /* Cancelled */ return 0; /* Handle no object, or object in other slot */ /* Any type is okay, since we give no intrinsics anyways */ if (newquiver == &zeroobj) { /* Explicitly nothing */ if (uquiver) { pline("You now have no ammunition readied."); setuqwep(newquiver = NULL); } else { pline("You already have no ammunition readied!"); return 0; } } else if (newquiver == uquiver) { pline("That ammunition is already readied!"); return 0; } else if (newquiver == uwep) { /* Prevent accidentally readying the main weapon */ pline("%s already being used as a weapon!", !is_plural(uwep) ? "That is" : "They are"); return 0; } else if (newquiver->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL | W_SADDLE)) { pline("You cannot ready that!"); return 0; } else { long dummy; /* Check if it's the secondary weapon */ if (newquiver == uswapwep) { setuswapwep(NULL); untwoweapon(); } /* Okay to put in quiver; print it */ dummy = newquiver->owornmask; newquiver->owornmask |= W_QUIVER; prinv(NULL, newquiver, 0L); newquiver->owornmask = dummy; } /* Finally, place it in the quiver */ setuqwep(newquiver); /* Take no time since this is a convenience slot */ return 0; }
void mark_recursive(Managed_Object_Handle ref, bool ref_is_compressed) { // If ref_is_compressed, ref is a compressed reference: the uint32 offset to an object in the heap. // ref_is_compressed => (GC::compressing_references && is_compressed_reference(ref)) assert(!ref_is_compressed || (GC::compressing_references && is_compressed_reference((COMPRESSED_REFERENCE)ref))); uint64 null_ref = (GC::compressing_references? GC::heap_base : NULL); if (ref_is_compressed) { if (ref == 0) { return; } } else { if ((uint64)ref == null_ref) { return; } } Object_With_Header *obj; if (ref_is_compressed) { Managed_Object_Handle ref2 = (Managed_Object_Handle)(GC::heap_base + (COMPRESSED_REFERENCE)ref); obj = (Object_With_Header *)(((Byte *)ref2) - sizeof(GC_Overhead)); } else { obj = (Object_With_Header *)(((Byte *)ref) - sizeof(GC_Overhead)); } unsigned space = obj->header.semispace; validate_object(obj); if(false && GC::verbosegc) { #ifdef GC_STATS printf("Marking object: %s%p [id=%I64d]\n", (ref_is_compressed? "compressed " : ""), ref, obj->header.id); #endif //GC_STATS } if(is_marked(obj)) { return; } set_marked(obj); Vtable_GC *vt = obj->vt(); if(false && GC::verbosegc) { printf("\tObject of type %s\n", class_get_name(vt->gcvt->ch)); } if(vt->gcvt->is_scannable_array) { scan_array(obj); } else { uint16 *offsets = vt->gcvt->offsets; Managed_Object_Handle ref2 = ref; if (ref_is_compressed) { ref2 = (Managed_Object_Handle)(GC::heap_base + (COMPRESSED_REFERENCE)ref); } if (GC::compressing_references) { while(*offsets) { COMPRESSED_REFERENCE *slot = (COMPRESSED_REFERENCE *)(((Byte *)ref2) + (*offsets)); COMPRESSED_REFERENCE val_offset = (COMPRESSED_REFERENCE)(*slot); assert(is_compressed_reference(val_offset)); Managed_Object_Handle val = (Managed_Object_Handle)(GC::heap_base + val_offset); push_on_mark_stack(val); offsets++; } } else { while(*offsets) { Managed_Object_Handle *slot = (Managed_Object_Handle *)(((Byte *)ref2) + *offsets); push_on_mark_stack(*slot); offsets++; } } } } //mark_recursive