示例#1
0
文件: pystorage.c 项目: KaSt/nereamud
//
// initialize a new storage set
int PyStorageSet_init(PyStorageSet *self, PyObject *args, PyObject *kwds) {
  static char *kwlist[] = {"file", NULL};
  char            *file = NULL;

  // get the universal id
  if (!PyArg_ParseTupleAndKeywords(args, kwds, "|s", kwlist, &file)) {
    PyErr_Format(PyExc_TypeError,
		 "Storage Set initializers may only take filename args.");
    return -1;
  }

  // if we have a filename, load up the storage set there
  if(file != NULL) {
    self->set = storage_read(file);
    // the file doesn't exist... just make a blank storage set
    if(self->set == NULL)
      self->set = new_storage_set();
  }
  // no argument... make a new storage set
  else
    self->set = new_storage_set();

  // no errors
  return 0;
}
示例#2
0
文件: alias.c 项目: KaSt/nereamud
STORAGE_SET *aliasAuxDataStore(ALIAS_AUX_DATA *data) {
  // if we have no hashtable, return an empty set
  if(data->aliases == NULL || hashSize(data->aliases) == 0)
    return new_storage_set();

  STORAGE_SET *set       = new_storage_set();
  STORAGE_SET_LIST *list = new_storage_list();
  HASH_ITERATOR  *hash_i = newHashIterator(data->aliases);
  const char       *name = NULL;
  const char        *cmd = NULL;

  store_list(set, "aliases", list);
  ITERATE_HASH(name, cmd, hash_i) {
    STORAGE_SET *alias_set = new_storage_set();
    store_string(alias_set, "key", name);
    store_string(alias_set, "val", hashIteratorCurrentVal(hash_i));
    storage_list_put(list, alias_set);
  }
示例#3
0
文件: container.c 项目: KaSt/nereamud
STORAGE_SET *containerDataStore(CONTAINER_DATA *data) {
  STORAGE_SET *set = new_storage_set();
  store_double(set, "capacity", data->capacity);
  store_string(set, "key",      data->key);
  store_int   (set, "pick_diff",data->pick_diff);
  store_int   (set, "closable", data->closable);
  store_int   (set, "closed",   data->closed);
  store_int   (set, "locked",   data->locked);
  return set;
}
示例#4
0
STORAGE_SET   *resetStore       (RESET_DATA *reset) {
  STORAGE_SET *set = new_storage_set();
  store_int   (set, "type",     reset->type);
  store_int   (set, "times",    reset->times);
  store_int   (set, "chance",   reset->chance);
  store_int   (set, "max",      reset->max);
  store_int   (set, "room_max", reset->room_max);
  store_string(set, "arg",      bufferString(reset->arg));
  store_list  (set, "in",       gen_store_list(reset->in,   resetStore));
  store_list  (set, "on",       gen_store_list(reset->on,   resetStore));
  store_list  (set, "then",     gen_store_list(reset->then, resetStore));
  return set;
}
示例#5
0
文件: socials.c 项目: KaSt/nereamud
STORAGE_SET *socialStore(SOCIAL_DATA *data) {
  STORAGE_SET *set = new_storage_set();
  store_string(set, "cmds",          data->cmds);
  store_string(set, "to_char_notgt", data->to_char_notgt);
  store_string(set, "to_room_notgt", data->to_room_notgt);
  store_string(set, "to_char_self",  data->to_char_self);
  store_string(set, "to_room_self",  data->to_room_self);
  store_string(set, "to_char_tgt",   data->to_char_tgt);
  store_string(set, "to_vict_tgt",   data->to_vict_tgt);
  store_string(set, "to_room_tgt",   data->to_room_tgt);
  store_string(set, "min_pos",       posGetName(data->min_pos));
  store_string(set, "max_pos",       posGetName(data->max_pos));
  return set;
}
示例#6
0
文件: socials.c 项目: KaSt/nereamud
//
// save all of the socials to disk
//
void save_socials() {
  STORAGE_SET       *set = new_storage_set();
  LIST         *soc_list = newList();

  // iterate across the social table and save all of the unique socials
  HASH_ITERATOR  *hash_i = newHashIterator(social_table);
  const char        *cmd = NULL;
  SOCIAL_DATA      *data = NULL;

  ITERATE_HASH(cmd, data, hash_i)
    listPut(soc_list, data);
  deleteHashIterator(hash_i);

  store_list(set, "socials", gen_store_list(soc_list, socialStore));
  deleteList(soc_list);

  // write the set
  storage_write(set, SOCIALS_FILE);
  
  // close the set
  storage_close(set);
}
// Store COMBAT_AUX_DATA in STORAGE_SET
// Normally named CombatAuxDataStore(*COMBAT_AUX_DATA)
STORAGE_SET *storeCombatAuxData(COMBAT_AUX_DATA *data) {
  STORAGE_SET *storage = new_storage_set();
  store_int(storage, "busy", data->busy);
  return storage;
}
示例#8
0
文件: furniture.c 项目: KaSt/nereamud
STORAGE_SET *furnitureDataStore(FURNITURE_DATA *data) {
  STORAGE_SET *set = new_storage_set();
  store_int(set, "capacity", data->capacity);
  store_int(set, "type",     data->type);
  return set;
}
示例#9
0
STORAGE_SET *resetListStore(RESET_LIST *list) {
  STORAGE_SET *set = new_storage_set();
  store_list(set, "resets", gen_store_list(list->resets, resetStore));
  return set;
}
示例#10
0
STORAGE_SET *triggerAuxDataStore(TRIGGER_AUX_DATA *data) {
  STORAGE_SET *set = new_storage_set();
  store_list(set, "triggers", gen_store_list(data->triggers,store_one_trigger));
  return set;
}
示例#11
0
STORAGE_SET *store_one_trigger(char *key) {
  STORAGE_SET *set = new_storage_set();
  store_string(set, "trigger", key);
  return set;
}
示例#12
0
STORAGE_SET *persistentDataStore(PERSISTENT_DATA *data) {
  STORAGE_SET *set = new_storage_set();
  store_bool(set, "persistent", data->persistent);
  store_int(set,  "activity",   data->activity);
  return set;
}