예제 #1
0
RACE_DATA *newRace(const char *name, const char *abbrev, BODY_DATA *body,
		   bool pc_ok) {
  RACE_DATA *data = malloc(sizeof(RACE_DATA));
  data->name   = strdupsafe(name);
  data->abbrev = strdupsafe(abbrev);
  data->body   = bodyCopy(body);
  data->pc_ok  = pc_ok;
  return data;
}
예제 #2
0
파일: hedit.c 프로젝트: KaSt/nereamud
HELP_OLC *newHelpOLC(const char *keywords, const char *info, 
		     const char *user_groups, const char *related) {
  HELP_OLC     *data = malloc(sizeof(HELP_OLC));
  data->old_keywords = strdupsafe(keywords);
  data->keywords     = strdupsafe(keywords);
  data->user_groups  = strdupsafe(user_groups);
  data->related      = strdupsafe(related);
  data->info         = newBuffer(1);
  bufferCat(data->info, info);
  return data;
}
예제 #3
0
void run_code(PyObject *code, PyObject *dict, const char *locale) {
  if(script_loop_depth >= MAX_LOOP_DEPTH) {
    // should we flag some sort of error, here?
    //***********
    // FINISH ME
    //***********

    script_ok = FALSE;
  }
  else {
    listPush(locale_stack, strdupsafe(locale));

    // try executing the code
    script_ok = TRUE;
    script_loop_depth++;
    PyObject *retval = PyEval_EvalCode((PyCodeObject *)code, dict, dict);
    script_loop_depth--;

    // did we throw an error?
    if(retval == NULL && PyErr_Occurred() != PyExc_SystemExit)
      script_ok = FALSE;

    // garbage collection
    free(listPop(locale_stack));
    Py_XDECREF(retval);
  }
}
예제 #4
0
파일: room_reset.c 프로젝트: KaSt/nereamud
void resetListCopyTo(RESET_LIST *from, RESET_LIST *to) {
  if(to->resets)   deleteListWith(to->resets, deleteReset);
  if(from->resets) to->resets = listCopyWith(from->resets, resetCopy);
  else             to->resets = newList();
  if(to->key)      free(to->key);
  to->key =        strdupsafe(from->key);
}
예제 #5
0
파일: container.c 프로젝트: KaSt/nereamud
bool iedit_container_parser (SOCKET_DATA *sock, CONTAINER_DATA *data, int choice, 
			  const char *arg) {
  switch(choice) {
  case IEDIT_CONTAINER_CAPACITY: {
    double capacity = atof(arg);
    if(capacity <= 0)
      return FALSE;
    data->capacity = capacity;
    return TRUE;
  }
  case IEDIT_CONTAINER_KEY: {
    if(data->key) free(data->key);
    data->key = strdupsafe(arg);
    return TRUE;
  }
  case IEDIT_CONTAINER_PICK_DIFF: {
    int diff = atoi(arg);
    if(diff < 0 || !isdigit(*arg))
      return FALSE;
    data->pick_diff = diff;
    return TRUE;
  }
  default: return FALSE;
  }
}
예제 #6
0
파일: trighooks.c 프로젝트: KaSt/nereamud
OPT_VAR *newOptVar(const char *name, void *data, int type) {
  OPT_VAR *var = malloc(sizeof(OPT_VAR));
  var->name    = strdupsafe(name);
  var->data    = data;
  var->type    = type;
  return var;
}
예제 #7
0
파일: room_reset.c 프로젝트: KaSt/nereamud
RESET_LIST *resetListCopy(RESET_LIST *list) {
  RESET_LIST *newlist = malloc(sizeof(RESET_LIST));
  if(list->resets) newlist->resets = listCopyWith(list->resets, resetCopy);
  else             newlist->resets = newList();
  newlist->key =   strdupsafe(list->key);
  return newlist;
}
예제 #8
0
파일: container.c 프로젝트: KaSt/nereamud
CONTAINER_DATA *containerDataRead(STORAGE_SET *set) {
  CONTAINER_DATA *data = newContainerData();
  data->key      = strdupsafe(read_string(set, "key"));
  data->capacity = read_double(set, "capacity");
  data->pick_diff= read_int   (set, "pick_diff");
  data->closable = read_int   (set, "closable");
  data->closed   = read_int   (set, "closed");
  data->locked   = read_int   (set, "locked");
  return data;
}
예제 #9
0
파일: hedit.c 프로젝트: KaSt/nereamud
bool hedit_parser(SOCKET_DATA *sock, HELP_OLC *data, int choice, 
		  const char *arg) {
  switch(choice) {
  case HEDIT_KEYWORDS:
    free(data->keywords);
    data->keywords = strdupsafe(arg);
    return TRUE;
  case HEDIT_RELATED:
    free(data->related);
    data->related = strdupsafe(arg);
    return TRUE;
  case HEDIT_USER_GROUPS:
    free(data->user_groups);
    data->user_groups = strdupsafe(arg);
    return TRUE;
  default: 
    return FALSE;
  }
}
예제 #10
0
PyObject *eval_script(PyObject *dict, const char *statement,const char *locale){
  listPush(locale_stack, strdupsafe(locale));
 
  // run the statement
  PyObject *retval = PyRun_String(statement, Py_eval_input, dict, dict);

  // did we encounter an error?
  if(retval == NULL)
    log_pyerr("eval_script terminated with an error:\r\n%s", statement);

  free(listPop(locale_stack));
  return retval;
}
예제 #11
0
파일: socials.c 프로젝트: KaSt/nereamud
SOCIAL_DATA *newSocial(const char *cmds,
		       const char *to_char_notgt,
		       const char *to_room_notgt,
		       const char *to_char_self,
		       const char *to_room_self,
		       const char *to_char_tgt,
		       const char *to_vict_tgt,
		       const char *to_room_tgt,
		       int min_pos, int max_pos) {
  SOCIAL_DATA *data = malloc(sizeof(SOCIAL_DATA));
  data->cmds          = strdupsafe(cmds);
  data->to_char_notgt = strdupsafe(to_char_notgt);
  data->to_room_notgt = strdupsafe(to_room_notgt);
  data->to_char_self  = strdupsafe(to_char_self);
  data->to_room_self  = strdupsafe(to_room_self);
  data->to_char_tgt   = strdupsafe(to_char_tgt);
  data->to_vict_tgt   = strdupsafe(to_vict_tgt);
  data->to_room_tgt   = strdupsafe(to_room_tgt);
  data->min_pos       = min_pos;
  data->max_pos       = max_pos;
  return data;
}
예제 #12
0
파일: socials.c 프로젝트: KaSt/nereamud
void socialCopyTo(SOCIAL_DATA *from, SOCIAL_DATA *to) {
  // free all of the strings
  if(to->cmds)          free(to->cmds);
  if(to->to_char_notgt) free(to->to_char_notgt);
  if(to->to_room_notgt) free(to->to_room_notgt);
  if(to->to_char_self)  free(to->to_char_self);
  if(to->to_room_self)  free(to->to_room_self);
  if(to->to_char_tgt)   free(to->to_char_tgt);
  if(to->to_vict_tgt)   free(to->to_vict_tgt);
  if(to->to_room_tgt)   free(to->to_room_tgt);

  // copy over all of the new descs and commands
  to->cmds          = strdupsafe(from->cmds);
  to->to_char_notgt = strdupsafe(from->to_char_notgt);
  to->to_room_notgt = strdupsafe(from->to_room_notgt);
  to->to_char_self  = strdupsafe(from->to_char_self);
  to->to_room_self  = strdupsafe(from->to_room_self);
  to->to_char_tgt   = strdupsafe(from->to_char_tgt);
  to->to_vict_tgt   = strdupsafe(from->to_vict_tgt);
  to->to_room_tgt   = strdupsafe(from->to_room_tgt);
  to->min_pos       = from->min_pos;
  to->max_pos       = from->max_pos;
}
예제 #13
0
파일: socials.c 프로젝트: KaSt/nereamud
void socialSetRoomTgt(SOCIAL_DATA *social, const char *mssg) {
  if(social->to_room_tgt) free(social->to_room_tgt);
  social->to_room_tgt   = strdupsafe(mssg);
}
예제 #14
0
파일: socials.c 프로젝트: KaSt/nereamud
void socialSetVictTgt(SOCIAL_DATA *social, const char *mssg) {
  if(social->to_vict_tgt) free(social->to_vict_tgt);
  social->to_vict_tgt   = strdupsafe(mssg);
}
예제 #15
0
파일: socials.c 프로젝트: KaSt/nereamud
void socialSetRoomSelf(SOCIAL_DATA *social, const char *mssg) {
  if(social->to_room_self) free(social->to_room_self);
  social->to_room_self   = strdupsafe(mssg);
}
예제 #16
0
파일: socials.c 프로젝트: KaSt/nereamud
void socialSetCharNotgt(SOCIAL_DATA *social, const char *mssg) {
  if(social->to_char_notgt) free(social->to_char_notgt);
  social->to_char_notgt   = strdupsafe(mssg);
}
예제 #17
0
파일: trighooks.c 프로젝트: KaSt/nereamud
void register_tedit_opt(const char *type, const char *desc) {
  if(tedit_opts == NULL)
    tedit_opts = newHashtable();
  hashPut(tedit_opts, type, strdupsafe(desc));
}
예제 #18
0
파일: container.c 프로젝트: KaSt/nereamud
void containerDataCopyTo(CONTAINER_DATA *from, CONTAINER_DATA *to) {
  *to = *from;
  to->key = strdupsafe(from->key);
}
예제 #19
0
파일: room_reset.c 프로젝트: KaSt/nereamud
void resetListSetKey(RESET_LIST *list, const char *key) {
  if(list->key) free(list->key);
  list->key = strdupsafe(key);
}