Beispiel #1
0
int PyObj_setcontainerlocked  (PyObject *self, PyObject *value, void *closure) {
  OBJ_DATA *obj = PyObj_AsObj(self);
  if(obj == NULL) {
    PyErr_Format(PyExc_StandardError, "Tried to change locked on nonexistent "
		 "container, %d", PyObj_AsUid(self));
    return -1;
  }
  else if(!objIsType(obj, "container")) {
    PyErr_Format(PyExc_TypeError, "Tried to set locked for non-container, %s",
		 objGetClass(obj));
    return -1;
  }

  if(!PyInt_Check(value)) {
    PyErr_Format(PyExc_TypeError, "container lock status must be a boolean.");
    return -1;
  }

  containerSetLocked(obj, PyInt_AsLong(value));
  if(PyInt_AsLong(value) != 0) {
    containerSetClosable(obj, TRUE);
    containerSetClosed(obj, TRUE);
  }
  return 0;
}
Beispiel #2
0
int PyObj_setfurntype(PyObject *self, PyObject *value, void *closure) {
  OBJ_DATA *obj = PyObj_AsObj(self);
  if(obj == NULL) {
    PyErr_Format(PyExc_StandardError, "Tried to set furniture type for "
		 "nonexistent furniture, %d", PyObj_AsUid(self));
    return -1;
  }
  else if(!objIsType(obj, "furniture")) {
    PyErr_Format(PyExc_TypeError, "Tried to set furniture type for "
		 "non-furniture, %s", objGetClass(obj));
    return -1;
  }

  if(!PyString_Check(value)) {
    PyErr_Format(PyExc_TypeError, "furniture type must be a string.");
    return -1;
  }
  else if(furnitureTypeGetNum(PyString_AsString(value)) == FURNITURE_NONE) {
    PyErr_Format(PyExc_TypeError, "Invalid furniture type, %s", 
		 PyString_AsString(value));
    return -1;
  }

  furnitureSetType(obj, furnitureTypeGetNum(PyString_AsString(value)));
  return 0;
}
void  expand_obj_dynamic_descs(const char *info) {
  OBJ_DATA  *me = NULL;
  CHAR_DATA *ch = NULL;
  hookParseInfo(info, &me, &ch);

  PyObject *pyme = objGetPyForm(me);
  char   *locale = strdup(get_key_locale(objGetClass(me))); 
  expand_dynamic_descs(charGetLookBuffer(ch), pyme, ch, locale);
  Py_DECREF(pyme);
  free(locale);
}
Beispiel #4
0
int PyObj_setcontainerkey(PyObject *self, PyObject *value, void *closure) {
  OBJ_DATA   *obj = PyObj_AsObj(self);
  const char *key = NULL;
  if(obj == NULL) {
    PyErr_Format(PyExc_StandardError, "Tried to set key for nonexistent "
		 "container, %d", PyObj_AsUid(self));
    return -1;
  }
  else if(!objIsType(obj, "container")) {
    PyErr_Format(PyExc_TypeError, "Tried to set key for non-container, %s",
		 objGetClass(obj));
    return -1;
  }

  if(PyString_Check(value))
    key =get_fullkey(PyString_AsString(value),get_key_locale(objGetClass(obj)));
  else if(PyObj_Check(value)) {
    OBJ_DATA *key_obj = PyObj_AsObj(value);
    if(key_obj != NULL)
      key = objGetClass(key_obj);
    else {
      PyErr_Format(PyExc_TypeError, "Tried to set key for %s as nonexistaent "
		   "obj, %d", objGetClass(obj), PyObj_AsUid(value));
      return -1;
    }
  }

  // make sure we have a key
  if(key == NULL) {
    PyErr_Format(PyExc_TypeError, "Container keys must be strings or objects.");
    return -1;
  }

  containerSetKey(obj, key);
  return 0;
}
Beispiel #5
0
int PyObj_setfurncapacity(PyObject *self, PyObject *value, void *closure) {
  OBJ_DATA *obj = PyObj_AsObj(self);
  if(obj == NULL) {
    PyErr_Format(PyExc_StandardError, "Tried to set capacity for nonexistent "
		 "furniture, %d", PyObj_AsUid(self));
    return -1;
  }
  else if(!objIsType(obj, "furniture")) {
    PyErr_Format(PyExc_TypeError, "Tried to set capacity for non-furniture, %s",
		 objGetClass(obj));
    return -1;
  }

  if(!PyInt_Check(value)) {
    PyErr_Format(PyExc_TypeError, "furniture capacity must be an integer.");
    return -1;
  }

  furnitureSetCapacity(obj, PyInt_AsLong(value));
  return 0;
}
Beispiel #6
0
int PyObj_setcontainerpickdiff(PyObject *self, PyObject *value, void *closure) {
  OBJ_DATA *obj = PyObj_AsObj(self);
  if(obj == NULL) {
    PyErr_Format(PyExc_StandardError, "Tried to change pickdiff on nonexistent "
		 "container, %d", PyObj_AsUid(self));
    return -1;
  }
  else if(!objIsType(obj, "container")) {
    PyErr_Format(PyExc_TypeError, "Tried to set pick for non-container, %s",
		 objGetClass(obj));
    return -1;
  }

  if(!PyInt_Check(value)) {
    PyErr_Format(PyExc_TypeError, "container pickdiff must be an integer.");
    return -1;
  }

  containerSetPickDiff(obj, PyInt_AsLong(value));
  return 0;
}
Beispiel #7
0
int PyObj_setcontainercapacity(PyObject *self, PyObject *value, void *closure) {
  OBJ_DATA *obj = PyObj_AsObj(self);
  if(obj == NULL) {
    PyErr_Format(PyExc_StandardError, "Tried to set capacity for nonexistent "
		 "container, %d", PyObj_AsUid(self));
    return -1;
  }
  else if(!objIsType(obj, "container")) {
    PyErr_Format(PyExc_TypeError, "Tried to set capacity for non-container, %s",
		 objGetClass(obj));
    return -1;
  }

  if(!PyFloat_Check(value)) {
    PyErr_Format(PyExc_TypeError, "container capacity must be a double.");
    return -1;
  }

  containerSetCapacity(obj, PyFloat_AsDouble(value));
  return 0;
}