Aw server world delete

From ActiveWiki
Jump to: navigation, search


Minimum requirements
Added in version 3.1
SDKbuild 18
Worldbuild 28


int aw_server_world_delete (int id)

Description

Deletes an existing world configuration from a world server.

Callback

AW_CALLBACK_ADMIN_WORLD_RESULT

Notes

This method removes the configuration identified by id from the current world server. Only the configuration data is deleted; to completely delete a world, use aw_world_attributes_reset to delete the world's attributes, aw_delete_all_objects to delete the objects and aw_terrain_delete_all to delete the terrain data.

Arguments

id
Unique id number of a particular world configuration.

Argument attributes

None

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 may use this method.
RC_NO_SUCH_WORLD (2)
No world has been set or it has become invalid.
RC_DATABASE_ERROR (2)
Unable to delete the world configuration from the database.

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

(2) Returned by the world server.

Returned attributes

AW_SERVER_ID
AW_SERVER_INSTANCE
AW_SERVER_NAME

Usage

Delete all traces of a world from the server.

void delete_world (int world)
{
  int rc;
  
  /* first, set the current world so that the world server knows which
     world aw_world_attributes_reset and aw_delete_all_objects are
     referring to */
  rc = aw_server_world_set (world);
  if (rc != RC_SUCCESS)
  {
    printf ("Unable to set world (reason %d)\n", rc);
    return;
  }
  
  /* reset the attributes */
  rc = aw_world_attributes_reset ();
  if (rc != RC_SUCCESS)
  {
    printf ("Unable to delete attributes (reason %d)\n", rc);
    return;
  }
  
  /* delete the terrain */
  rc = aw_terrain_delete_all (world);
  if (rc != RC_SUCCESS)
  {
    printf ("Unable to delete terrain (reason %d)\n", rc);
    return;
  }
  
  /* delete the objects */
  rc = aw_delete_all_objects (world);
  if (rc != RC_SUCCESS)
  {
    printf ("Unable to delete objects (reason %d)\n", rc);
    return;
  }
  
  /* finally, delete the world itself */
  rc = aw_server_world_delete (world)
  if (rc != RC_SUCCESS)
  {
    printf ("Unable to delete world (reason %d)\n", rc);
    return;
  }
  
  printf ("World deleted.\n");
}

See also