Example #1
0
Value &Value::operator=(const Value &other) {
  // protect against invalid self-assignment
  if (this != &other) {
    m_sourceInlined = other.m_sourceInlined;
    m_valueType = other.m_valueType;
    m_cleanUp = true;
    std::copy(other.m_data, other.m_data + 16, m_data);

    // Deep copy if needed
    if (m_sourceInlined == false && other.IsNull() == false) {
      switch (m_valueType) {
        case VALUE_TYPE_VARBINARY:
        case VALUE_TYPE_VARCHAR:
        case VALUE_TYPE_ARRAY: {
          Varlen *src_sref = *reinterpret_cast<Varlen *const *>(other.m_data);
          Varlen *new_sref = Varlen::Clone(*src_sref, nullptr);

          SetObjectValue(new_sref);
        } break;

        default:
          break;
      }
    }
  }

  // by convention, always return *this
  return *this;
}
Lockable* Object::SetNetworkCell(unsigned int cell)
{
	if (!cell)
		return NULL;

	return SetObjectValue(this->cell_Network, cell);
}
Lockable* Object::SetNetworkPos(unsigned char axis, double pos)
{
	if (!IsValidCoordinate(pos))
		return NULL;

	return SetObjectValue(this->object_Network_Pos.at(axis), pos);
}
Lockable* Object::SetGameCell(unsigned int cell)
{
	if (!cell)
		return NULL;

	return SetObjectValue(this->cell_Game, cell);
}
Lockable* Object::SetAngle(unsigned char axis, double angle)
{
	if (!IsValidAngle(angle))
		return NULL;

	return SetObjectValue(this->object_Angle.at(axis), angle);
}
Example #6
0
Value &Value::operator=(const Value &other) {
  // protect against invalid self-assignment
  if (this != &other) {
    m_sourceInlined = other.m_sourceInlined;
    m_valueType = other.m_valueType;
    m_cleanUp = true;
    std::copy(other.m_data, other.m_data + 16, m_data);

    // Deep copy if needed
    if (m_sourceInlined == false && other.IsNull() == false) {
      switch (m_valueType) {
        case VALUE_TYPE_VARBINARY:
        case VALUE_TYPE_VARCHAR:
        case VALUE_TYPE_ARRAY: {
          Varlen *src_sref = *reinterpret_cast<Varlen *const *>(other.m_data);
          Varlen *new_sref = Varlen::Clone(*src_sref, nullptr);

          // TODO: Fix memory leak problem.
          // If a varchar value having been assigned chars.
          // = will replace old value without release,
          // which is memory leak.
          SetObjectValue(new_sref);
        } break;

        default:
          break;
      }
    }
  }

  // by convention, always return *this
  return *this;
}
Example #7
0
Lockable* Object::SetGamePos(unsigned char axis, double pos)
{
	if (!IsValidCoordinate(pos))
		return nullptr;

	return SetObjectValue(this->object_Game_Pos.at(axis), pos);
}
Example #8
0
Value::Value(const Value &other) {
  m_sourceInlined = other.m_sourceInlined;
  m_valueType = other.m_valueType;
  m_cleanUp = true;
  std::copy(other.m_data, other.m_data + 16, m_data);

  // Deep copy if needed
  if (m_sourceInlined == false && other.IsNull() == false) {
    switch (m_valueType) {
      case VALUE_TYPE_VARBINARY:
      case VALUE_TYPE_VARCHAR:
      case VALUE_TYPE_ARRAY: {
        Varlen *src_sref = *reinterpret_cast<Varlen *const *>(other.m_data);
        Varlen *new_sref = Varlen::Clone(*src_sref, nullptr);

        SetObjectValue(new_sref);
      } break;

      default:
        break;
    }
  }
}
Lockable* Object::SetEnabled(bool state)
{
	return SetObjectValue(this->state_Enabled, state);
}
Lockable* Object::SetName(string name)
{
	return SetObjectValue(this->object_Name, name);
}
Lockable* Item::SetItemCondition(double condition)
{
	return SetObjectValue(this->item_Condition, condition);
}
Lockable* Item::SetItemCount(unsigned int count)
{
	return SetObjectValue(this->item_Count, count);
}
Lockable* Item::SetItemStick(bool stick)
{
	return SetObjectValue(this->flag_Stick, stick);
}
Lockable* Item::SetItemSilent(bool silent)
{
	return SetObjectValue(this->flag_Silent, silent);
}
Lockable* Item::SetItemEquipped(bool state)
{
	return SetObjectValue(this->state_Equipped, state);
}
Example #16
0
Lockable* Item::SetItemContainer(NetworkID id)
{
	return SetObjectValue(this->item_Container, id);
}