int aw_server_world_change (int id)

DESCRIPTION

Changes an existing world configuration in a world server.

CALLBACK

AW_CALLBACK_ADMIN_WORLD_LIST

NOTES

This method is new in Active Worlds 3.1 and requires at least SDK build 18 and world server build 28. 

This is an administration mode method and can only be used by instances created with aw_server_admin.

aw_server_world_change changes the configuration of the identified by id in the current world server.  The following attributes are changed:

AW_SERVER_ENABLED
AW_SERVER_NAME
AW_SERVER_PASSWORD
AW_SERVER_REGISTRY
AW_SERVER_CARETAKERS

EXAMPLE

/* code to add a new caretaker to an existing world */

int world_id;
int enabled;
char name[256];
char password[256];
char registry[256];
char caretakers[256 + 20];
int found;

void handle_world_info (void)
{

  if (aw_int (AW_SERVER_ID) == world_id) {
    strcpy (name, aw_string (AW_SERVER_NAME));
    strcpy (password, aw_string (AW_SERVER_PASSWORD));
    strcpy (registry, aw_string (AW_SERVER_REGISTRY));
    strcpy (name, aw_string (AW_SERVER_CARETAKERS));
    enabled = aw_bool (AW_SERVER_ENABLED);
    found = TRUE;
  }

}

void add_caretaker (int world, int caretaker)
{

  int rc;
  /* first we have to find the world  */
  world_id = world;
  aw_callback_set (AW_CALLBACK_ADMIN_WORLD_LIST, NULL);
  aw_event_set (AW_EVENT_ADMIN_WORLD_INFO, handle_world_info);
  aw_int_set (AW_SERVER_ID, 0);
  found = FALSE;
  do
    aw_server_world_list ();
  while (!found && aw_bool (AW_SERVER_MORE));
  if (found) {
    /* found the world, now add the caretaker */
    sprintf (caretakers + strlen (caretakers), " %d", caretaker);
    if (strlen (caretakers) > 255)
      printf ("Unable to add caretaker: too many caretakers!\n");
    else {
      aw_string_set (AW_SERVER_NAME, name);
      aw_string_set (AW_SERVER_PASSWORD, password);
      aw_string_set (AW_SERVER_REGISTRY, registry);
      aw_string_set (AW_SERVER_CARETAKERS, caretakers);
      aw_bool_set (AW_SERVER_ENABLED, enabled);
      if (rc = aw_server_world_change (world))
        printf ("Unable to change world (reason %d)\n", rc);
      else
        printf ("Caretaker %d added to world %s.\n", caretaker, name);
    }
  } else
    printf ("Could not find world %d.\n", world);

}

SEE ALSO

aw_server_admin
aw_server_world_add
aw_server_world_delete
aw_server_world_list
aw_server_world_set
aw_server_world_start
aw_server_world_stop