Exemplo n.º 1
0
void cProtocol142::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay)
{
	cCSLock Lock(m_CSPacket);
	WriteByte (PACKET_UPDATE_TIME);
	WriteInt64(a_WorldAge);
	WriteInt64(a_TimeOfDay);
	Flush();
}
Exemplo n.º 2
0
            void InteropOutputStream::WriteDouble(const double val)
            {
                BinaryDoubleInt64 u;

                u.d = val;

                WriteInt64(u.i);
            }
Exemplo n.º 3
0
void cProtocol125::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay)
{
	cCSLock Lock(m_CSPacket);
	WriteByte (PACKET_UPDATE_TIME);
	// Use a_WorldAge for daycount, and a_TimeOfDay for the proper time of day:
	WriteInt64((24000 * (a_WorldAge / 24000)) + (a_TimeOfDay % 24000));
	Flush();
}
Exemplo n.º 4
0
void Serializer::WriteRepeatedMessageField(google::protobuf::Message const& value, google::protobuf::FieldDescriptor const* field)
{
    google::protobuf::Reflection const* reflection = value.GetReflection();
    for (int32 i = 0; i < reflection->FieldSize(value, field); ++i)
    {
        switch (field->cpp_type())
        {
            case google::protobuf::FieldDescriptor::CPPTYPE_INT32:
                WriteInt32(reflection->GetRepeatedInt32(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_INT64:
                WriteInt64(reflection->GetRepeatedInt64(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_UINT32:
                WriteUInt32(reflection->GetRepeatedUInt32(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_UINT64:
                WriteUInt64(reflection->GetRepeatedUInt64(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE:
                WriteDouble(reflection->GetRepeatedDouble(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT:
                WriteFloat(reflection->GetRepeatedFloat(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_BOOL:
                WriteBool(reflection->GetRepeatedBool(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_ENUM:
                WriteEnum(reflection->GetRepeatedEnum(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_STRING:
            {
                std::string strValue = reflection->GetRepeatedString(value, field, i);
                if (field->type() == google::protobuf::FieldDescriptor::TYPE_STRING)
                    WriteString(strValue);
                else
                {
                    _writer.StartArray();
                    for (std::size_t j = 0; j < strValue.length(); ++j)
                        WriteUInt32(uint32(strValue[j]));
                    _writer.EndArray();
                }
                break;
            }
            case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE:
                WriteMessage(reflection->GetRepeatedMessage(value, field, i));
                break;
            default:
                break;
        }
    }
}
Exemplo n.º 5
0
void ezJSONWriter::AddVariableInt64(const char* szName, ezInt64 value)
{
  BeginVariable(szName);
  WriteInt64(value);
  EndVariable();
}
Exemplo n.º 6
0
void ezJSONWriter::WriteVariant(const ezVariant& value)
{
  switch (value.GetType())
  {
  case ezVariant::Type::Invalid:
    //EZ_REPORT_FAILURE("Variant of Type 'Invalid' cannot be written as JSON.");
    WriteNULL();
    return;
  case ezVariant::Type::Bool:
    WriteBool(value.Get<bool>());
    return;
  case ezVariant::Type::Int8:
    WriteInt32(value.Get<ezInt8>());
    return;
  case ezVariant::Type::UInt8:
    WriteUInt32(value.Get<ezUInt8>());
    return;
  case ezVariant::Type::Int16:
    WriteInt32(value.Get<ezInt16>());
    return;
  case ezVariant::Type::UInt16:
    WriteUInt32(value.Get<ezUInt16>());
    return;
  case ezVariant::Type::Int32:
    WriteInt32(value.Get<ezInt32>());
    return;
  case ezVariant::Type::UInt32:
    WriteUInt32(value.Get<ezUInt32>());
    return;
  case ezVariant::Type::Int64:
    WriteInt64(value.Get<ezInt64>());
    return;
  case ezVariant::Type::UInt64:
    WriteUInt64(value.Get<ezUInt64>());
    return;
  case ezVariant::Type::Float:
    WriteFloat(value.Get<float>());
    return;
  case ezVariant::Type::Double:
    WriteDouble(value.Get<double>());
    return;
  case ezVariant::Type::Color:
    WriteColor(value.Get<ezColor>());
    return;
  case ezVariant::Type::Vector2:
    WriteVec2(value.Get<ezVec2>());
    return;
  case ezVariant::Type::Vector3:
    WriteVec3(value.Get<ezVec3>());
    return;
  case ezVariant::Type::Vector4:
    WriteVec4(value.Get<ezVec4>());
    return;
  case ezVariant::Type::Quaternion:
    WriteQuat(value.Get<ezQuat>());
    return;
  case ezVariant::Type::Matrix3:
    WriteMat3(value.Get<ezMat3>());
    return;
  case ezVariant::Type::Matrix4:
    WriteMat4(value.Get<ezMat4>());
    return;
  case ezVariant::Type::String:
    WriteString(value.Get<ezString>().GetData());
    return;
  case ezVariant::Type::Time:
    WriteTime(value.Get<ezTime>());
    return;
  case ezVariant::Type::Uuid:
    WriteUuid(value.Get<ezUuid>());
    return;

  default:
    break;
  }

  EZ_REPORT_FAILURE("The Variant Type %i is not supported by ezJSONWriter::WriteVariant.", value.GetType());
}