Aw object delete

From ActiveWiki
Revision as of 12:40, 12 February 2009 by Macavity (talk | contribs) (Added two missing attributes)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Minimum requirements
Added in version 2.1
SDKbuild 13


int aw_object_delete (void)

Description

Deletes an object.

Callback

AW_CALLBACK_OBJECT_RESULT

Notes

The object to be deleted can be specified in two ways. This is the old method for doing it:

There is also new method which was introduced in version 4.1:

If the callback AW_CALLBACK_OBJECT_RESULT is installed then AW_OBJECT_NUMBER and AW_OBJECT_ID will be set during the callback to indicate which object the callback is for. This can be useful in applications that issue multiple asynchronous building requests.

It is possible to tell which call to a method an AW_CALLBACK_OBJECT_RESULT is for. This is done by setting AW_OBJECT_CALLBACK_REFERENCE before calling it. The attribute will be set to the specified value when the call completes (only useful within the callback).

Arguments

None

Argument attributes

AW_OBJECT_NUMBER
AW_OBJECT_X
AW_OBJECT_Z
AW_OBJECT_ID
AW_OBJECT_CALLBACK_REFERENCE

Return values

RC_SUCCESS (1) (2)
RC_NOT_INITIALIZED (1)
RC_NO_INSTANCE (1)
RC_NO_CONNECTION (1)
The connection to the world is down.
RC_UNAUTHORIZED (2)
Only world server administration instances or those with build capability (i.e. aw_bool (AW_WORLD_BUILD_CAPABILITY) returns 1) may use this method.
RC_RESTRICTED_AREA (2)
RC_NO_SUCH_OBJECT (2)
RC_ENCROACHES (2)
RC_NOT_DELETE_OWNER (2)
Only world server administration instances or those with eminent domain capability (i.e. aw_bool (AW_WORLD_EMINENT_DOMAIN_CAPABILITY) returns 1) may delete an object owned by someone else.
RC_RESTRICTED_OBJECT (2)
RC_UNABLE_TO_SET_SEQUENCE (2)
Unable to increment sequence number of the sector.

(1) Possible return values when a callback is installed.

(2) Returned by the world server.

Returned attributes

AW_OBJECT_NUMBER
AW_OBJECT_ID
AW_OBJECT_CALLBACK_REFERENCE (1)
AW_CELL_X (1)
AW_CELL_Z (1)

(1) Added in SDK build 70.

Usage

/* reference by cell coordinates and object number */
void delete_object (int x, int z, int number)
{
  int rc;
  
  aw_int_set (AW_OBJECT_ID, 0);
  aw_int_set (AW_OBJECT_NUMBER, number);
  aw_int_set (AW_OBJECT_X, x);
  aw_int_set (AW_OBJECT_Z, z);
  
  rc = aw_object_delete ();
  if (rc != RC_SUCCESS)
    printf ("Unable to delete object (reason %d)\n", rc);
  else
    puts ("Object deleted");
}

/* reference by object id */
void delete_object (int id)
{
  int rc;
  
  aw_int_set (AW_OBJECT_ID, id);
  aw_int_set (AW_OBJECT_NUMBER, 0);
  aw_int_set (AW_OBJECT_X, 0);
  aw_int_set (AW_OBJECT_Z, 0);
  
  rc = aw_object_delete ();
  if (rc != RC_SUCCESS)
    printf ("Unable to delete object (reason %d)\n", rc);
  else
    puts ("Object deleted");
}

See also