int main( string param ) { string from, to; object ob, inv, env; int nok = 0, nfail = 0; WIZ_CHECK if( !param ) { notify_fail("==> [Format] wempty object [[in]to object]\n"); return 0; } if ( (sscanf( param, "%s into %s", from, to ) < 2) && (sscanf( param, "%s to %s", from, to) < 2) ) { from = param; } if( !from ) { notify_fail("==> [Format] wempty object [[in]to object]\n"); return 0; } ob = find_thing( from ); if( !ob ) { notify_fail("I don't understand what you are trying to empty.\n"); return 0; } env = find_thing( to ); if (!env) { if ( !ob || !(env = environment(ob))) { env = find_thing("/obj/void"); } } foreach( inv : all_inventory(ob) ) { inv->move( env ); if( !inv || environment(inv) == env ) nok++; else nfail++; if( !inv ) continue; inv->set_x( this_player()->query_x() ); inv->set_y( this_player()->query_y() ); } if( nfail ) msg( "" + nok + " object(s) moved successfully to " + as_string(env) + ", " + nfail + " did not move.\n"); else msg( "" + nok + " object(s) moved successfully to " + as_string(env) ); return 1; }
main(string param) { object ob, *obs, i, n, env; string s; ADM_CHECK if(!param) { msg("==> [Format] nuke <objects>"); return 1; } ob = find_thing(param); if(!ob) { notify_fail("==> [Error] Unable to locate object "+param+"\n"); return 0; } obs = all_inventory( ob ); set_target(ob); this_player()->msg_local("~CBRT~Name ~verbclap ~poss hands. A heavy banging sound is heard, like a cannon-shot.~CDEF"); foreach( ob : obs ) { if( !ob->query_is_player() ) destruct(ob); } return 1; }
void menu_motion(WThing *thing, XMotionEvent *ev, int dx, int dy, WFunction *func, WFuncArg arg) { WMenu *menu; int ret; if(!WTHING_IS(thing, WTHING_MENU)) return; menu=(WMenu*)thing; if(!menu_select_at(menu, ev->x_root, ev->y_root)){ thing=find_thing(ev->subwindow); if(thing==(WThing*)menu || thing==NULL || !WTHING_IS(thing, WTHING_MENU)){ end_scroll(); return; } wglobal.grab_holder=thing; menu=(WMenu*)thing; if(!menu_select_at(menu, ev->x_root, ev->y_root)){ end_scroll(); return; } } if(test_scroll(menu, ev->x_root, ev->y_root)) start_scroll(menu); }
WThing *find_thing_t(Window win, int type) { WThing *thing=find_thing(win); if(thing==NULL || !WTHING_IS(thing, type)) return NULL; return thing; }
WWinObj *find_winobj_of(Window win) { WThing *thing=find_thing(win); if(thing==NULL) return NULL; if(WTHING_IS(thing, WTHING_FRAME)) return (WWinObj*)thing; if(WTHING_IS(thing, WTHING_CLIENTWIN) && thing->t_parent!=NULL && WTHING_IS(thing->t_parent, WTHING_WINOBJ)) return (WWinObj*)thing->t_parent; return NULL; }
// Ok, this isn't going to work until we get 3.3.x online. // Rats. Will look at it later. -- Acius. int main( string param ) { string obname, fname; object ob; string obfile; string curr, buf; int line, i; if( !param || sscanf(param, "%s->%s", obname, fname) != 2 ) { notify_fail( query_verb() + " obj->func\n" ); return 0; } ob = find_thing( obname ); if( !ob ) { notify_fail( "Can't find object: " + obname + "\n" ); return 0; } obfile = function_exists( fname, ob, FEXISTS_FILENAME ); line = function_exists( fname, ob, FEXISTS_LINENO ); if( !obfile || !line ) { notify_fail("Can't find the function.\n"); return 0; } buf = read_file( obfile, line, 1 ); for( i = 1; i < 40 && line - i > 0; i++ ) { curr = read_file( obfile, line - i ); if( curr[0..2] == "/**" || curr[0..2] == "///" || curr[0..1] == " *" || curr[0..1] == " */" ) buf = curr + buf; else break; } buf += read_file( obfile, line+1, 40 ); i = strstr(buf, "\n}\n", 0); if( i > 0 ) buf = buf[..i+2]; msg("Function " + fname + " in file " + obfile + ":\n" + buf ); return 1; }
int main( string param ) { object ob; string obname; int ix, iy, x, y, w, h; WIZ_CHECK if( !param ) { notify_fail("==> [Format] rmspot scenery [x,y[,w,h]]\n"); return 0; } if( sscanf(param, "%s %d,%d,%d,%d", obname, x, y, w, h) != 5 ) { w = 1; h = 1; if( sscanf(param, "%s %d,%d", obname, x, y) != 3 ) { x = this_player()->query_x(); y = this_player()->query_y(); obname = param; } } ob = find_thing( obname ); if( !ob ) { notify_fail("==> [Error] Can't find '"+obname+"'\n"); return 0; } if( w > 80 || h > 30 ) { notify_fail("Sorry, no insane values of w and h allowed.\n"); return 0; } for( ix = 0; ix < w; ix++ ) for( iy = 0; iy < h; iy++ ) ob->remove_spot( MAKE_C(x+ix,y+iy,0) ); environment(ob)->clear_map(); return 1; }
/** Converts a reference into an object pointer. You should only * pass in one parameter; the second \a rcheck parameter is used * internally. * * \return The object referenced by \a str, or 0 on failure. */ varargs object find_thing(string str, status rcheck) { object ob; string a, b; if(!str) return 0; if( this_player() ) { ob = present(str, this_player()); if(environment(this_player())) { /* Believe it or not, this was necessary. */ if(!ob) ob = present(str, environment(this_player())); if(!ob && (environment(this_player())->id(str) == environment(this_player()) || str == "env")) ob = environment(this_player()); } } if(!ob) { ob = find_player(str); } if(!ob) { ob = find_living(str); } if(!ob) { ob = find_object(str); } if(!ob) { ob = find_objectref(str); } if(!ob && sscanf(str, "%s %s",a,b)!=2 && file_exists(str+".c") ) { call_other(str, "this_function_does_not_exist\n"); ob = find_object(str); } if(!ob && str == "me") ob = this_player(); if(!ob) ob = find_room( str, this_player() ); if(!ob) ob = single_present( str, this_player() ); if(!ob) ob = single_present( str, environment(this_player()) ); if(!rcheck && !ob && this_player() ) ob = find_thing(this_player()->make_path_absolute(str), 1); return ob; }
/** A highly unusual function that lets you generate and execute a snippet of code * that will execute. Just pass in the snippet. Warning: This can't handle recursive * calls; the old call will be trashed by the new. * * \return The return value of the call, converted to a string. */ string exec_call(string code) { string buf; string obj, func, func_name, err; mixed param, ret; string fname; if( !this_player() ) raise_error("exec_call must have a valid this_player() using it"); fname = this_player()->make_path_absolute( EXEC_OBJ ); if( ret = find_object(fname) ) destruct(ret); if( file_exists(fname + ".c") && !rm( fname + ".c" ) ) return "Unable to clear out the old "+fname+" to execute the call (uid="+getuid(this_object())+")."; buf = HEADER + EXEC_MACROS + "\ndo_call() {\n"; if( sscanf(code, "%s->%s", obj, func) == 2 ) { func_name = func; if( sscanf(func, "%~s(%~s)") != 2 ) { code = func; if( sscanf( code, "%s %d", func, param) == 2) func = (func_name = func) + "( " + param + " );"; else if( sscanf( code, "%s %s", func, param) == 2) func = (func_name = func) + "( \"" + param + "\" );"; else func = (func_name = code) + "();"; } else sscanf( func_name, "%s(%~s)", func_name ); } else if( sscanf(code, "%s %s(%s)%~s", obj, func, param) == 4 && member(func, ' ') < 0 ) func = (func_name = func) + "( " + param +" );"; else if( sscanf(code, "%s %s %d", obj, func, param) == 3 ) func = (func_name = func) + "( " + param + " );"; else if( sscanf(code, "%s %s %s", obj, func, param) == 3 ) func = (func_name = func) + "( \"" + param + "\" );"; else if( sscanf(code, "%s %s", obj, func) == 2 ) func = (func_name = func) + "();"; else raise_error("Ill formatted exec_call"); if( !find_thing(obj) ) return "No such object: "+obj; if( !function_exists(func_name, find_thing(obj)) && !function_exists("catch_call", find_thing(obj)) ) return "No such function: "+obj+"->"+func_name+"()"; // if( sscanf(func, "%s(%s)%s", ret, ret, ret) != 3 ) func += "();"; if( func[<1] != ';' ) func += ";"; buf += " object ob;\n"; buf += " ob = find_thing(\""+obj+"\");\n"; buf += " if( !ob ) return \"Could not find object "+obj+"!\";\n"; buf += " return ob->"+func+"\n}\n"; write_file( fname + ".c", buf ); err = catch(ret = load_object( fname )); if( err ) { msg("==> [Call Error] "+err); return "<Invalid>"; } seteuid( getuid(this_player()) ); export_uid( ret ); seteuid( getuid(this_object()) ); err = catch(ret = fname->do_call()); if( err ) { msg("==> [Call Runtime Error] "+err); return "<Invalid>"; } return as_lpc(ret); }