本文整理汇总了C++中Location函数的典型用法代码示例。如果您正苦于以下问题:C++ Location函数的具体用法?C++ Location怎么用?C++ Location使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Location函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: do_chown
/** Change an object's owner.
* \verbatim
* This implements @chown.
* \endverbatim
* \param player the enactor.
* \param name name of object to change owner of.
* \param newobj name of new owner for object.
* \param preserve if 1, preserve privileges and don't halt the object.
* \param pe_info the pe_info for lock checks
*/
void
do_chown(dbref player, const char *name, const char *newobj, int preserve,
NEW_PE_INFO *pe_info)
{
dbref thing;
dbref newowner = NOTHING;
long match_flags = MAT_POSSESSION | MAT_HERE | MAT_EXIT | MAT_ABSOLUTE;
/* check for '@chown <object>/<atr>=<player>' */
if (strchr(name, '/')) {
do_atrchown(player, name, newobj);
return;
}
if (Wizard(player))
match_flags |= MAT_PLAYER;
if ((thing = noisy_match_result(player, name, TYPE_THING, match_flags))
== NOTHING)
return;
if (!*newobj || !strcasecmp(newobj, "me")) {
newowner = player;
} else {
if ((newowner = lookup_player(newobj)) == NOTHING) {
notify(player, T("I couldn't find that player."));
return;
}
}
if (IsPlayer(thing) && !God(player)) {
notify(player, T("Players always own themselves."));
return;
}
/* Permissions checking */
if (!chown_ok(player, thing, newowner, pe_info)) {
notify(player, T("Permission denied."));
return;
}
if (IsThing(thing) && !Hasprivs(player) &&
!(GoodObject(Location(thing)) && (Location(thing) == player))) {
notify(player, T("You must carry the object to @chown it."));
return;
}
if (preserve && !Wizard(player)) {
notify(player, T("You cannot @CHOWN/PRESERVE. Use normal @CHOWN."));
return;
}
/* chowns to the zone master don't count towards fees */
if (!ZMaster(newowner)) {
/* Debit the owner-to-be */
if (!can_pay_fees(newowner, Pennies(thing))) {
/* not enough money or quota */
if (newowner != player)
notify(player,
T
("That player doesn't have enough money or quota to receive that object."));
return;
}
/* Credit the current owner */
giveto(Owner(thing), Pennies(thing));
change_quota(Owner(thing), QUOTA_COST);
}
chown_object(player, thing, newowner, preserve);
notify(player, T("Owner changed."));
}
开发者ID:FranticFanatic,项目名称:pennmush,代码行数:76,代码来源:set.c
示例2: Align
extern void Align( WPARAM wparam )
/********************************/
{
/* Perform the requested alignment of current objects relative to the primary
* object
*/
OBJPTR currobj;
OBJPTR primary;
RECT primrect;
RECT rect;
BOOL atleasttwo;
POINT offset;
LIST *objlist;
primary = GetPrimaryObject();
if( primary == NULL ) {
return;
}
atleasttwo = FALSE;
currobj = GetECurrObject();
while( currobj != NULL && !atleasttwo ) {
if( currobj != primary ) {
atleasttwo = TRUE;
} else {
currobj = GetNextECurrObject( currobj );
}
}
if( !atleasttwo ) {
return;
}
if( !CheckMoveOperation( &objlist ) ) {
return;
}
BeginMoveOperation( objlist );
ListFree( objlist );
currobj = GetECurrObject();
primary = GetPrimaryObject();
Location( primary, &primrect );
while( currobj != NULL ) {
if( currobj != primary ) {
Location( currobj, &rect );
switch( LOWORD( wparam ) ) {
case IDM_FMLEFT:
offset.x = primrect.left - rect.left;
offset.y = 0;
break;
case IDM_FMHCENTRE:
offset.x = ((primrect.right + primrect.left) / 2) -
((rect.right + rect.left) / 2);
offset.y = 0;
break;
case IDM_FMRIGHT:
offset.x = primrect.right - rect.right;
offset.y = 0;
break;
case IDM_FMTOP:
offset.x = 0;
offset.y = primrect.top - rect.top;
break;
case IDM_FMVCENTRE:
offset.x = 0;
offset.y = ((primrect.bottom + primrect.top) / 2) -
((rect.bottom + rect.top) / 2);
break;
case IDM_FMBOTTOM:
offset.x = 0;
offset.y = primrect.bottom - rect.bottom;
break;
}
Move( currobj, &offset, TRUE );
}
currobj = GetNextECurrObject( currobj );
}
FinishMoveOperation( TRUE );
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:75,代码来源:align.c
示例3: Location
static inline Location bindingArrayElement (deUint32 binding_, deUint32 arrayElement)
{
return Location(binding_, arrayElement);
}
开发者ID:eth0047,项目名称:VK-GL-CTS,代码行数:4,代码来源:vkBuilderUtil.hpp
示例4: main
int main()
{
{
Location p1(0,0,0);
Location p2(10,0,0);
Location p3(0,0,10);
Location p(10,0,0);
interpolate(p1, p2, p3, p);
assertEqual(p, Location(10,0,0));
}
{
Location p1(0,0,0);
Location p2(10,0,0);
Location p3(0,0,10);
Location p(1,0,1);
interpolate(p1, p2, p3, p);
assertEqual(p, Location(1,0,1));
}
{
Location p1(0,2,0);
Location p2(2,0,0);
Location p3(0,0,2);
Location p(1,0,0);
interpolate(p1, p2, p3, p);
assertEqual(p, Location(1,1,0));
}
{
Location p1(0,2,0);
Location p2(2,0,0);
Location p3(0,0,2);
Location p(0,0,1);
interpolate(p1, p2, p3, p);
assertEqual(p, Location(0,1,1));
}
{
Location p1(0,2,0);
Location p2(2,0,0);
Location p3(0,0,2);
Location p(0,0,1);
interpolate(p1, p2, p3, p);
assertEqual(p, Location(0,1,1));
}
{
Location p1(0,2,0);
Location p2(2,0,0);
Location p3(0,0,2);
Location p(FixedPoint(1,2),0,FixedPoint(1,2));
interpolate(p1, p2, p3, p);
assertEqual(p, Location(FixedPoint(1,2),1,FixedPoint(1,2)));
}
}
开发者ID:soulaim,项目名称:worldofapo,代码行数:69,代码来源:interpolationtest.cpp
示例5: Location
Area Location::get_world_area_offset(int offset, int radius) {
Area area;
area.p1 = Location(this->x + offset, this->y + offset);
area.p2 = Location((this->x + offset) + radius, (this->y + offset) + radius);
return area;
}
开发者ID:rlt3,项目名称:rogue,代码行数:6,代码来源:Location.cpp
示例6: MoveVal
MoveVal::MoveVal() : MoveVal(0, Location()) { }
开发者ID:Jasonkatz,项目名称:AI-Project-1,代码行数:1,代码来源:Utils.cpp
示例7: Y
int Y() { int nY; return Location(nullptr, &nY) ? nY : -1; }
开发者ID:etorth,项目名称:mir2x,代码行数:1,代码来源:creature.hpp
示例8: give_thing
static void give_thing (dbref giver, dbref recipient, int key, char *what)
{
dbref thing, loc;
char *str, *sp;
init_match(giver, what, TYPE_THING);
match_possession();
match_me();
thing = match_result();
switch (thing) {
case NOTHING:
notify(giver, "You don't have that!");
return;
case AMBIGUOUS:
notify(giver, "I don't know which you mean!");
return;
}
if (thing == giver) {
notify(giver, "You can't give yourself away!");
return;
}
if (((Typeof(thing) != TYPE_THING) &&
(Typeof(thing) != TYPE_PLAYER)) ||
!(Enter_ok(recipient) || controls(giver, recipient))) {
notify(giver, "Permission denied.");
return;
}
if ((Flags3(thing) & NOMOVE) && !Wizard(giver)) {
notify(giver, "Permission denied.");
return;
}
if (!could_doit(giver, thing, A_LGIVE,1)) {
sp = str = alloc_lbuf("do_give.gfail");
safe_str((char *)"You can't give ", str, &sp);
safe_str(Name(thing), str, &sp);
safe_str((char *)" away.", str, &sp);
*sp = '\0';
did_it(giver, thing, A_GFAIL, str, A_OGFAIL, NULL,
A_AGFAIL, (char **)NULL, 0);
free_lbuf(str);
return;
}
if (!could_doit(thing, recipient, A_LRECEIVE,1)) {
sp = str = alloc_lbuf("do_give.rfail");
safe_str(Name(recipient), str, &sp);
safe_str((char *)" doesn't want ", str, &sp);
safe_str(Name(thing), str, &sp);
safe_chr('.', str, &sp);
*sp = '\0';
did_it(giver, recipient, A_RFAIL, str, A_ORFAIL, NULL,
A_ARFAIL, (char **)NULL, 0);
free_lbuf(str);
return;
}
loc = Location(giver);
if ( !Good_obj(loc) || loc == NOTHING || loc == AMBIGUOUS || Recover(loc) || Going(loc) )
loc = giver;
if (!could_doit(giver, loc, A_LGIVETO, 1)) {
sp = str = alloc_lbuf("do_giveto.rfail");
safe_str((char *)"You can not give ", str, &sp);
safe_str(Name(thing), str, &sp);
safe_str((char *)" away at this location.", str, &sp);
*sp = '\0';
notify(giver, str);
free_lbuf(str);
return;
}
move_via_generic(thing, recipient, giver, 0);
divest_object(thing);
if (!(key & GIVE_QUIET)) {
str = alloc_lbuf("do_give.thing.ok");
strcpy(str, Name(giver));
notify_with_cause(recipient, giver,
unsafe_tprintf("%s gave you %s.", str, Name(thing)));
notify(giver, "Given.");
notify_with_cause(thing, giver,
unsafe_tprintf("%s gave you to %s.", str, Name(recipient)));
free_lbuf(str);
}
else {
notify(giver, "Given. (quiet)");
}
did_it(giver, thing, A_DROP, NULL, A_ODROP, NULL, A_ADROP,
(char **)NULL, 0);
did_it(recipient, thing, A_SUCC, NULL, A_OSUCC, NULL, A_ASUCC,
(char **)NULL, 0);
}
开发者ID:Haunted-Memories,项目名称:rhost,代码行数:95,代码来源:rob.c
示例9: Move
Move Board::RandomLegalMove (const Player& player) const {
return Move(player,
Location(_fast_field_map[Rand::next_rand(_moves_left)]));
}
开发者ID:lukaszlew,项目名称:MiMHex,代码行数:4,代码来源:board.cpp
示例10: emergency_eject
/* leave a flying ship through the escape pod */
void emergency_eject(dbref player)
{
dbref nav, pad;
hship *ship;
hcelestial *cel, *min_cel;
ATTR *a;
char *r, *s;
char buff[512];
double dist, min_dist;
dbref min_pad;
hship *sptr, *min_ship;
/* check for a BAY */
a = atr_get(Location(player), "BAY");
if (!a)
{
/* no BAY, see if we're next to the nav console */
ship = find_ship(player);
if (ship)
{
if (Location(ship->objnum) != Location(player))
{
notify(player, "You can't eject from here.");
return;
}
}
}
else
{
/* there's a BAY, see if the ship is valid */
nav = parse_dbref(atr_value(a));
if (!IsShip(nav))
{
notify(player, "You can't eject from here.");
return;
}
ship = find_ship_by_nav(nav);
}
if (!ship)
{
notify(player, "You can't eject from here.");
return;
}
/* only eject when flying, not when landing or docking */
if (!ship->uid || ship->landed || ship->docked)
{
notify(player, "You may only eject while flying.");
return;
}
/* find a planet with a drop pad */
min_pad = NOTHING;
min_dist = 1000000.0;
min_cel = NULL;
for (cel = ship->uid->head_celestial; cel; cel = cel->next)
{
if (!HasFlag(cel->type, HS_PLANET))
continue;
pad = atr_parse_dbref(cel->objnum, "DROPPADS");
if (!RealGoodObject(pad))
continue;
dist = ship_celestial_distance(ship, cel);
if (dist < min_dist)
{
min_dist = dist;
min_pad = pad;
min_cel = cel;
}
}
min_ship = NULL;
for (sptr = ship->uid->head_ship; sptr; sptr = sptr->next)
{
if (min_cel)
break;
if (!HasFlag(sptr->type, HS_STATION | HS_CAPITAL))
continue;
pad = atr_parse_dbref(sptr->objnum, "BAY");
if (!RealGoodObject(pad))
continue;
dist = ship_distance(ship, sptr);
if (dist < min_dist)
{
min_cel = NULL;
min_ship = sptr;
min_dist = dist;
min_pad = pad;
}
}
//.........这里部分代码省略.........
开发者ID:jrsteensen,项目名称:hspace3g,代码行数:101,代码来源:hscmds.c
示例11: do_kill
void do_kill (dbref player, dbref cause, int key, char *what, char *costchar)
{
dbref victim;
char *buf1, *buf2;
int cost;
init_match(player, what, TYPE_PLAYER);
match_neighbor();
match_me();
match_here();
if (Wizard(player)) {
match_player();
match_absolute();
}
victim = match_result();
switch (victim) {
case NOTHING:
notify(player, "I don't see that player here.");
break;
case AMBIGUOUS:
notify(player, "I don't know who you mean!");
break;
default:
if ((Typeof(victim) != TYPE_PLAYER) &&
(Typeof(victim) != TYPE_THING)) {
notify(player,
"Sorry, you can only kill players and things.");
break;
}
if ((Haven(Location(victim)) && !Wizard(player)) ||
(controls(victim, Location(victim)) &&
!controls(player, Location(victim))) ||
Immortal(victim)) {
notify(player, "Sorry.");
break;
}
if (key == KILL_SLAY) {
if (Builder(player) && Builder(victim)) {
notify(player, "Sorry.");
break;
}
}
/* go for it */
cost = atoi(costchar);
if (key == KILL_KILL) {
if (HasPriv(victim,player,POWER_NOKILL,POWER4,NOTHING)) {
notify(player, "Sorry.");
break;
}
if (cost < mudconf.killmin)
cost = mudconf.killmin;
if (cost > mudconf.killmax)
cost = mudconf.killmax;
/* see if it works */
if (!payfor(player, cost)) {
notify(player,
unsafe_tprintf("You don't have enough %s.",
mudconf.many_coins));
return;
}
} else {
cost = 0;
}
if (!(((random() % mudconf.killguarantee) < cost) ||
(key == KILL_SLAY)) ||
Wizard(victim)) {
/* Failure: notify player and victim only */
notify(player, "Your murder attempt failed.");
buf1 = alloc_lbuf("do_kill.failed");
sprintf(buf1, "%s tried to kill you!", Name(player));
notify_with_cause(victim, player, buf1);
if (Suspect(player)) {
strcpy(buf1, Name(player));
if (player == Owner(player)) {
raw_broadcast(0, WIZARD,
"[Suspect] %s tried to kill %s(#%d).",
buf1, Name(victim), victim);
} else {
buf2 = alloc_lbuf("do_kill.SUSP.failed");
strcpy(buf2, Name(Owner(player)));
raw_broadcast(0, WIZARD,
"[Suspect] %s <via %s(#%d)> tried to kill %s(#%d).",
buf2, buf1, player,
Name(victim), victim);
free_lbuf(buf2);
}
}
free_lbuf(buf1);
break;
}
/* Success! You killed him */
//.........这里部分代码省略.........
开发者ID:Haunted-Memories,项目名称:rhost,代码行数:101,代码来源:rob.c
示例12: disembark
/* leave a landed/docked ship through the hatch */
void disembark(dbref player)
{
dbref nav, obj, newobj;
hship *ship;
ATTR *a;
int security;
/* check if we can disembark from here */
a = atr_get(Location(player), "BAY");
if (!a)
{
/* no BAY, check if we're near the nav console */
ship = find_ship(player);
if (ship)
{
if (Location(ship->objnum) != Location(player))
{
notify(player, "You can't disembark from here.");
return;
}
}
}
else
{
/* there's a BAY here, make sure it's a good one */
nav = parse_dbref(atr_value(a));
if (!IsShip(nav))
{
notify(player, "You can't disembark from here.");
return;
}
ship = find_ship_by_nav(nav);
}
if (!ship)
{
notify(player, "You can't disembark from here.");
return;
}
/* no ditching in space, or early after launching, or prematurely when landing */
if ((ship->uid || ship->landing || ship->launching) && !ship->linked)
{
notify(player, "You can't disembark while in space.");
return;
}
obj = atr_parse_dbref(ship->objnum, "SHIPOBJ");
if (!RealGoodObject(obj))
{
notify(player, "This ship can not be disembarked.");
return;
}
/* check whether we're docking or landing, save the new space object */
if (ship->landed)
{
newobj = ship->landed->objnum;
}
else if (ship->docked)
{
newobj = ship->docked->objnum;
}
else if (ship->linked)
{
newobj = ship->linked->objnum;
} else {
notify(player, "You can't disembark while in space.");
return;
}
if (ship->linked)
{
/* check the boarding code, if necessary */
security = atr_parse_integer(ship->linked->objnum, "SECURITY", 0);
if (security)
{
notify(player, "Unable to use boarding link while the other ship has security enabled.");
return;
}
security = atr_parse_integer(ship->objnum, "SECURITY", 0);
if (security)
{
notify(player, "Unable to use boarding link while security is enabled.");
return;
}
obj = atr_parse_dbref(ship->linked->objnum, "BAY");
if (!RealGoodObject(obj))
obj = Location(ship->linked->objnum);
moveto(player, obj, hs_options.space_wiz, NULL);
} else {
moveto(player, Location(obj), hs_options.space_wiz, NULL);
}
/* finish up by setting HSPACE attribute and notifying everybody about the move */
//.........这里部分代码省略.........
开发者ID:jrsteensen,项目名称:hspace3g,代码行数:101,代码来源:hscmds.c
示例13: man_console
//.........这里部分代码省略.........
{
notify(player, "Can't reload weapons in combat!");
stype = sec->type;
ptype = pri->type;
} else {
ptype = load_weapon(player, pri, HS_PRIMARY);
stype = load_weapon(player, sec, HS_SECONDARY);
}
type = HasFlag(ptype | stype, HS_ANY_WEAPON);
if (con)
{
/* this is an auxiliary console */
/* no missiles on the aux consoles */
if (HasFlag(type, HS_MISSILE))
{
clear_weapon(pri);
clear_weapon(sec);
notify(player, "You may not man an auxiliary console with missiles equipped.");
return;
}
if (HasFlag(type, HS_WIRETAP))
con->type = HS_OPS;
else if (HasFlag(type, HS_CAPACITOR))
con->type = HS_ENG;
else if (HasFlag(type, HS_CANNON | HS_EMITTER | HS_WEAPON))
con->type = HS_GUN;
else
con->type = HS_CIV;
} else {
/* this is a nav console */
/* no cans, caps or taps */
if (HasFlag(type, HS_CANNON))
{
clear_weapon(pri);
clear_weapon(sec);
notify(player, "You may not man a navigation console with a cannon equipped.");
return;
}
}
/* the equipment slots check out, and the console
has been set to the appropriate type, if needed */
if (prompt)
{
*prompt = HasFlag(atr_parse_integer(player, "HSPROMPT_FREQUENCY", 1), HS_PROMPT_FREQUENCY);
FlagOn(*prompt, atr_parse_flags(player, hs_prompt_flags, "HSPROMPT_FLAGS"));
}
manning = get_console(player);
if (manning != NOTHING)
{
manner = get_user(manning);
if (manner == player)
{
con = find_console(manning);
if (con)
{
load_weapon(manning, &(con->primary), HS_PRIMARY);
load_weapon(manning, &(con->secondary), HS_SECONDARY);
}
set_user(manning, NOTHING);
notify(player, tprintf("You unman the %s.", Name(manning)));
notify_except(manning, Location(manning), player,
tprintf("%s unmans the %s.", Name(player), Name(manning)), 0);
}
}
/* set the HSPACE attribute in case something was fishy */
if (!IsSim(ship->objnum))
{
atr_add(player, "HSPACE", unparse_dbref(ship->objnum), hs_options.space_wiz, 0);
}
set_user(console, player);
execute_trigger(console, "AMAN", ship);
if (con)
{
notify(player, tprintf("You man the %s (%s%s%s).", Name(console),
ANSI_HILITE, STR(hs_console_types, con->type), ANSI_NORMAL));
notify_except(console, Location(console), player,
tprintf("%s mans the %s (%s%s%s).", Name(player), Name(console),
ANSI_HILITE, STR(hs_console_types, con->type), ANSI_NORMAL), 0);
} else {
notify(player, tprintf("You man the %s.", Name(console)));
notify_except(console, Location(console), player,
tprintf("%s mans the %s.", Name(player), Name(console)), 0);
}
}
开发者ID:jrsteensen,项目名称:hspace3g,代码行数:101,代码来源:hscmds.c
示例14: Location
Location Location::GetLocation(const Direction& direction) {
if (i == -1 or j == -1) {
return Location(-1, -1);
}
switch (direction) {
case EAST:
return Location(i + 1, j);
case SOUTH_EAST:
if (j % 2 == 0) {
return Location(i + 1, j + 1);
}
return Location(i, j + 1);
case SOUTH_WEST:
if (j % 2 == 0) {
return Location(i, j + 1);
}
return Location(i - 1, j + 1);
case WEST:
return Location(i - 1, j);
case NORTH_WEST:
if (j % 2 == 0) {
return Location(i, j - 1);
}
return Location(i - 1, j - 1);
case NORTH_EAST:
if (j % 2 == 0) {
return Location(i + 1, j - 1);
}
return Location(i, j - 1);
default:
return Location(-1, -1);
}
}
开发者ID:Li2012,项目名称:SlowBall,代码行数:34,代码来源:map.cpp
示例15: ct_exit
static void
ct_exit(dbref player, dbref i, warn_type flags)
{
dbref j, src, dst;
int count = 0;
int lt;
/* i must be an exit, must be in a valid room, and must lead to a
* different room
* Remember, for exit i, Exits(i) = source room
* and Location(i) = destination room
*/
dst = Destination(i);
if ((flags & W_EXIT_UNLINKED) && (dst == NOTHING))
complain(player, i, "exit-unlinked",
T("exit is unlinked; anyone can steal it"));
if ((flags & W_EXIT_UNLINKED) && dst == AMBIGUOUS) {
ATTR *a;
const char *var = "DESTINATION";
a = atr_get(i, "DESTINATION");
if (!a)
a = atr_get(i, "EXITTO");
if (a)
var = "EXITTO";
if (!a)
complain(player, i, "exit-unlinked",
T("Variable exit has no %s attribute"), var);
else {
const char *x = atr_value(a);
if (!x || !*x)
complain(player, i, "exit-unlinked",
T("Variable exit has empty %s attribute"), var);
}
}
if (!Dark(i)) {
if (flags & W_EXIT_MSGS) {
lt = warning_lock_type(getlock(i, Basic_Lock));
if ((lt & W_UNLOCKED) &&
(!atr_get(i, "OSUCCESS") || !atr_get(i, "ODROP") ||
!atr_get(i, "SUCCESS")))
complain(player, i, "exit-msgs",
T("possibly unlocked exit missing succ/osucc/odrop"));
if ((lt & W_LOCKED) && !atr_get(i, "FAILURE"))
complain(player, i, "exit-msgs",
T("possibly locked exit missing fail"));
}
if (flags & W_EXIT_DESC) {
if (!atr_get(i, "DESCRIBE"))
complain(player, i, "exit-desc", T("exit is missing description"));
}
}
src = Source(i);
if (!GoodObject(src) || !IsRoom(src))
return;
if (src == dst)
return;
/* Don't complain about exits linked to HOME or variable exits. */
if (!GoodObject(dst))
return;
for (j = Exits(dst); GoodObject(j); j = Next(j))
if (Location(j) == src) {
if (!(flags & W_EXIT_MULTIPLE))
return;
else
count++;
}
if ((count == 0) && (flags & W_EXIT_ONEWAY))
complain(player, i, "exit-oneway", T("exit has no return exit"));
else if ((count > 1) && (flags & W_EXIT_MULTIPLE))
complain(player, i, "exit-multiple",
T("exit has multiple (%d) return exits"), count);
}
开发者ID:nveid,项目名称:cobramush,代码行数:76,代码来源:warnings.c
示例16: do_link
/** Link an exit, room, player, or thing.
* \verbatim
* This is the top-level function for @link, which is used to link an
* exit to a destination, set a player or thing's home, or set a
* drop-to on a room.
*
* Linking an exit usually seizes ownership of the exit and costs 1 penny.
* 1 penny is also transferred to the former owner.
* \endverbatim
* \param player the enactor.
* \param name the name of the object to link.
* \param room_name the name of the link destination.
* \param preserve if 1, preserve ownership and zone data on exit relink.
*/
void
do_link(dbref player, const char *name, const char *room_name, int preserve)
{
/* Use this to link to a room that you own.
* It usually seizes ownership of the exit and costs 1 penny,
* plus a penny transferred to the exit owner if they aren't you.
* You must own the linked-to room AND specify it by room number.
*/
dbref thing;
dbref room;
if (!room_name || !*room_name) {
do_unlink(player, name);
return;
}
if (!IsRoom(player) && GoodObject(Location(player)) &&
IsExit(Location(player))) {
notify(player, T("You somehow wound up in a exit. No biscuit."));
return;
}
if ((thing = noisy_match_result(player, name, TYPE_EXIT, MAT_EVERYTHING))
!= NOTHING) {
switch (Typeof(thing)) {
case TYPE_EXIT:
if ((room = check_var_link(room_name)) == NOTHING)
room = parse_linkable_room(player, room_name);
if (room == NOTHING)
return;
if (GoodObject(room) && !can_link_to(player, room)) {
notify(player, T("Permission denied."));
break;
}
/* We may link an exit if it's unlinked and we pass the link-lock
* or if we control it.
*/
if (!(controls(player, thing)
|| ((Location(thing) == NOTHING)
&& eval_lock(player, thing, Link_Lock)))) {
notify(player, T("Permission denied."));
return;
}
if (preserve && !Wizard(player)) {
notify(player, T("Permission denied."));
return;
}
/* handle costs */
if (Owner(thing) == Owner(player)) {
if (!payfor(player, LINK_COST)) {
notify_format(player, T("It costs %d %s to link this exit."),
LINK_COST, ((LINK_COST == 1) ? MONEY : MONIES));
return;
}
} else {
if (!payfor(player, LINK_COST + EXIT_COST)) {
int a = LINK_COST + EXIT_COST;
notify_format(player, T("It costs %d %s to link this exit."), a,
((a == 1) ? MONEY : MONIES));
return;
} else if (!preserve) {
/* pay the owner for his loss */
giveto(Owner(thing), EXIT_COST);
chown_object(player, thing, player, 0);
}
}
/* link has been validated and paid for; do it */
if (!preserve) {
Owner(thing) = Owner(player);
Zone(thing) = Zone(player);
}
Location(thing) = room;
/* notify the player */
notify_format(player, T("Linked exit #%d to %s"), thing,
unparse_object(player, room));
break;
case TYPE_PLAYER:
case TYPE_THING:
if ((room =
noisy_match_result(player, room_name, NOTYPE,
MAT_EVERYTHING)) == NOTHING) {
notify(player, T("No match."));
return;
}
if (IsExit(room)) {
//.........这里部分代码省略.........
开发者ID:tkrajcar,项目名称:pypenn,代码行数:101,代码来源:create.c
示例17: strcat
if (firstMatch) {
firstMatch = false;
strcat(regName, "(");
} else {
strcat(regName, "/");
}
strcat(regName, name);
}
}
char* reg_names(fint reg) {
// try to find source-level name(s) for reg
// inefficient but only used during debugging, so what
regName = NEW_RESOURCE_ARRAY(char, 80);
firstMatch = true;
regToMatch = Location(reg);
sprintf(regName, "%s", RegisterNames[reg]);
if (printPC == NULL) return regName;
fint bci = printPC->byteCode;
for (ScopeDesc* scope = printScope; scope; scope = scope->sender()) {
scope->doForNames(bci, printMatchingSlot);
if (!scope->isTop()) bci = scope->senderByteCodeIndex();
}
if (!firstMatch) strcat(regName, ")");
return regName;
}
void print_stack_temp_name(fint offset) {
// The disassembler just printed something like "ld [%sp+offset";
// augment it with the symbolic name for stack temps if possible.
// The code below isn't perfect -- doesn't distinguish extra args
开发者ID:ardeujho,项目名称:self,代码行数:31,代码来源:disasm_sparc.cpp
示例18: do_create
/** Create a thing.
* \verbatim
* This is the top-level function for @create.
* \endverbatim
* \param player the enactor.
* \param name name of thing to create.
* \param cost pennies spent in creation.
* \paran newdbref the (unparsed) dbref to give the object, or NULL to use the next free
* \return dbref of new thing, or NOTHING.
*/
dbref
do_create(dbref player, char *name, int cost, char *newdbref)
{
dbref loc;
dbref thing;
char *flaglist, *flagname;
char flagbuff[BUFFER_LEN];
if (*name == '\0') {
notify(player, T("Create what?"));
return NOTHING;
} else if (!ok_name(name, 0)) {
notify(player, T("That's a silly name for a thing!"));
return NOTHING;
} else if (cost < OBJECT_COST) {
cost = OBJECT_COST;
}
if (!make_first_free_wrapper(player, newdbref)) {
return NOTHING;
}
if (can_pay_fees(player, cost)) {
/* create the object */
thing = new_object();
/* initialize everything */
set_name(thing, name);
if (!IsExit(player)) /* Exits shouldn't have contents! */
Location(thing) = player;
else
Location(thing) = Source(player);
Owner(thing) = Owner(player);
Zone(thing) = Zone(player);
s_Pennies(thing, cost);
Type(thing) = TYPE_THING;
Flags(thing) = new_flag_bitmask("FLAG");
strcpy(flagbuff, options.thing_flags);
flaglist = trim_space_sep(flagbuff, ' ');
if (*flaglist != '\0') {
while (flaglist) {
flagname = split_token(&flaglist, ' ');
twiddle_flag_internal("FLAG", thing, flagname, 0);
}
}
/* home is here (if we can link to it) or player's home */
if ((loc = Location(player)) != NOTHING &&
(controls(player, loc) || Abode(loc))) {
Home(thing) = loc; /* home */
} else {
Home(thing) = Home(player); /* home */
}
/* link it in */
if (!IsExit(player))
PUSH(thing, Contents(player));
else
PUSH(thing, Contents(Source(player)));
/* and we're done */
notify_format(player, T("Created: Object %s."), unparse_dbref(thing));
current_state.things++;
local_data_create(thing);
queue_event(player, "OBJECT`CREATE", "%s", unparse_objid(thing));
return thing;
}
return NOTHING;
}
开发者ID:tkrajcar,项目名称:pypenn,代码行数:82,代码来源:create.c
示例19: X
int X() { int nX; return Location(&nX, nullptr) ? nX : -1; }
开发者ID:etorth,项目名称:mir2x,代码行数:1,代码来源:creature.hpp
示例20: do_clone
/** Clone an object.
* \verbatim
* This is the top-level function for @clone, which creates a duplicate
* of a (non-player) object.
* \endverbatim
* \param player the enactor.
* \param name the name of the object to clone.
* \param newname the name to give the duplicate.
* \param preserve if 1, preserve ownership and privileges on duplicate.
* \paran newdbref the (unparsed) dbref to give the object, or NULL to use the next free
* \return dbref of the duplicate, or NOTHING.
*/
dbref
do_clone(dbref player, char *name, char *newname, int preserve, char *newdbref)
{
dbref clone, thing;
char dbnum[BUFFER_LEN];
thing = noisy_match_result(player, name, NOTYPE, MAT_EVERYTHING);
if ((thing == NOTHING))
return NOTHING;
if (newname && *newname && !ok_name(newname, IsExit(thing))) {
notify(player, T("That is not a reasonable name."));
return NOTHING;
}
if (!controls(player, thing) || IsPlayer(thing) ||
(IsRoom(thing) && !command_check_byname(player, "@dig")) ||
(IsExit(thing) && !command_check_byname(player, "@open")) ||
(IsThing(thing) && !command_check_byname(player, "@create"))) {
notify(player, T("Permission denied."));
return NOTHING;
}
/* don't allow cloning of destructed things */
if (IsGarbage(thing)) {
notify(player, T("There's nothing left of it to clone!"));
return NOTHING;
}
if (preserve && !Wizard(player)) {
notify(player, T("You cannot @CLONE/PRESERVE. Use normal @CLONE instead."));
return NOTHING;
}
if (!make_first_free_wrapper(player, newdbref)) {
return NOTHING;
}
/* make sure owner can afford it */
switch (Typeof(thing)) {
case TYPE_THING:
if (can_pay_fees(player, Pennies(thing))) {
clone = clone_object(player, thing, newname, preserve);
notify_format(player, T("Cloned: Object %s."), unparse_dbref(clone));
if (IsRoom(player))
moveto(clone, player, player, "cloned");
else
moveto(clone, Location(player), player, "cloned");
current_state.things++;
local_data_clone(clone, thing);
real_did_it(player, clone, NULL, NULL, NULL, NULL, "ACLONE", NOTHING,
global_eval_context.wenv, 0);
return clone;
}
return NOTHING;
break;
case TYPE_ROOM:
if (can_pay_fees(player, ROOM_COST)) {
clone = clone_object(player, thing, newname, preserve);
Exits(clone) = NOTHING;
notify_format(player, T("Cloned: Room #%d."), clone);
current_state.rooms++;
local_data_clone(clone, thing);
real_did_it(player, clone, NULL, NULL, NULL, NULL, "ACLONE", NOTHING,
global_eval_context.wenv, 0);
return clone;
}
return NOTHING;
break;
case TYPE_EXIT:
/* For exits, we don't want people to be able to link it to
a location they can't with @open. So, all this stuff.
*/
switch (Location(thing)) {
case NOTHING:
strcpy(dbnum, "#-1");
break;
case HOME:
strcpy(dbnum, "home");
break;
case AMBIGUOUS:
strcpy(dbnum, "variable");
break;
default:
strcpy(dbnum, unparse_dbref(Location(thing)));
}
if (newname && *newname)
clone = do_real_open(player, newname, dbnum, NOTHING);
else
clone = do_real_open(player, Name(thing), dbnum, NOTHING);
//.........这里部分代码省略.........
开发者ID:tkrajcar,项目名称:pypenn,代码行数:101,代码来源:create.c
注:本文中的Location函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论