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; }
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; }
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); } }
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); }
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; } }
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; }
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; }
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; }
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; } }
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; }
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; }
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; }
void socialSetRoomTgt(SOCIAL_DATA *social, const char *mssg) { if(social->to_room_tgt) free(social->to_room_tgt); social->to_room_tgt = strdupsafe(mssg); }
void socialSetVictTgt(SOCIAL_DATA *social, const char *mssg) { if(social->to_vict_tgt) free(social->to_vict_tgt); social->to_vict_tgt = strdupsafe(mssg); }
void socialSetRoomSelf(SOCIAL_DATA *social, const char *mssg) { if(social->to_room_self) free(social->to_room_self); social->to_room_self = strdupsafe(mssg); }
void socialSetCharNotgt(SOCIAL_DATA *social, const char *mssg) { if(social->to_char_notgt) free(social->to_char_notgt); social->to_char_notgt = strdupsafe(mssg); }
void register_tedit_opt(const char *type, const char *desc) { if(tedit_opts == NULL) tedit_opts = newHashtable(); hashPut(tedit_opts, type, strdupsafe(desc)); }
void containerDataCopyTo(CONTAINER_DATA *from, CONTAINER_DATA *to) { *to = *from; to->key = strdupsafe(from->key); }
void resetListSetKey(RESET_LIST *list, const char *key) { if(list->key) free(list->key); list->key = strdupsafe(key); }