예제 #1
0
void write_scoreBuffer(AuthServer_Private& client, const Auth_GetScores& msg,
                       const DS::FifoMessage& reply)
{
    client.m_buffer.write<uint32_t>(reply.m_messageType);
    if (reply.m_messageType != DS::e_NetSuccess) {
        client.m_buffer.write<uint32_t>(0); // Score Count
        client.m_buffer.write<uint32_t>(0); // Buffer Size
    } else {
        client.m_buffer.write<uint32_t>(msg.m_scores.size());
        // eap sucks -- need utf16 string length in bytes
        DS::StringBuffer<char16_t> name = msg.m_name.toUtf16();
        uint32_t bufsz = msg.m_scores.size() *
                        (Auth_GetScores::GameScore::BaseStride +
                        ((name.length() + 1) * sizeof(char16_t)));
        client.m_buffer.write<uint32_t>(bufsz);
        for (auto& score : msg.m_scores) {
            client.m_buffer.write<uint32_t>(score.m_scoreId);
            client.m_buffer.write<uint32_t>(score.m_owner);
            client.m_buffer.write<uint32_t>(score.m_createTime);
            client.m_buffer.write<uint32_t>(score.m_type);
            client.m_buffer.write<uint32_t>(score.m_points);
            // evil string shit
            client.m_buffer.write<uint32_t>((name.length() + 1) * sizeof(char16_t));
            client.m_buffer.writeBytes(name.data(), name.length() * sizeof(char16_t));
            client.m_buffer.write<char16_t>(0);
        }
    }
}
예제 #2
0
void cb_getPublicAges(AuthServer_Private& client)
{
    START_REPLY(e_AuthToCli_PublicAgeList);

    // Trans ID
    uint32_t transId = DS::CryptRecvValue<uint32_t>(client.m_sock, client.m_crypt);
    client.m_buffer.write<uint32_t>(transId);

    Auth_PubAgeRequest msg;
    msg.m_client = &client;
    msg.m_agename = DS::CryptRecvString(client.m_sock, client.m_crypt);
    s_authChannel.putMessage(e_AuthGetPublic, reinterpret_cast<void*>(&msg));

    DS::FifoMessage reply = client.m_channel.getMessage();
    client.m_buffer.write<uint32_t>(reply.m_messageType);
    if (reply.m_messageType != DS::e_NetSuccess) {
        client.m_buffer.write<uint32_t>(0);
    } else {
        client.m_buffer.write<uint32_t>(msg.m_ages.size());
        for (size_t i = 0; i < msg.m_ages.size(); i++) {
            client.m_buffer.writeBytes(msg.m_ages[i].m_instance.m_bytes, sizeof(client.m_acctUuid.m_bytes));

            char16_t strbuffer[2048];
            DS::StringBuffer<char16_t> buf;
            uint32_t copylen;

            buf = msg.m_agename.toUtf16();
            copylen = buf.length() < 64 ? buf.length() : 63;
            memcpy(strbuffer, buf.data(), copylen * sizeof(char16_t));
            strbuffer[copylen] = 0;
            client.m_buffer.writeBytes(strbuffer, 64 * sizeof(char16_t));

            buf = msg.m_ages[i].m_instancename.toUtf16();
            copylen = buf.length() < 64 ? buf.length() : 63;
            memcpy(strbuffer, buf.data(), copylen * sizeof(char16_t));
            strbuffer[copylen] = 0;
            client.m_buffer.writeBytes(strbuffer, 64 * sizeof(char16_t));

            buf = msg.m_ages[i].m_username.toUtf16();
            copylen = buf.length() < 64 ? buf.length() : 63;
            memcpy(strbuffer, buf.data(), copylen * sizeof(char16_t));
            strbuffer[copylen] = 0;
            client.m_buffer.writeBytes(strbuffer, 64 * sizeof(char16_t));

            buf = msg.m_ages[i].m_description.toUtf16();
            copylen = buf.length() < 1024 ? buf.length() : 1023;
            memcpy(strbuffer, buf.data(), copylen * sizeof(char16_t));
            strbuffer[copylen] = 0;
            client.m_buffer.writeBytes(strbuffer, 1024 * sizeof(char16_t));

            client.m_buffer.write<uint32_t>(msg.m_ages[i].m_sequence);
            client.m_buffer.write<uint32_t>(msg.m_ages[i].m_language);
            client.m_buffer.write<uint32_t>(msg.m_ages[i].m_population);
            client.m_buffer.write<uint32_t>(msg.m_ages[i].m_curPopulation);
        }
    }

    SEND_REPLY();
}
예제 #3
0
void MOUL::NetMsgSharedState::write(DS::Stream* stream)
{
    NetMsgObject::write(stream);

    // Save the state to a stream
    NetMsgStream msgStream;
    msgStream.m_compression = m_compression;

    DS::StringBuffer<chr8_t> name = m_stateName.toUtf8();
    msgStream.m_stream.write<uint16_t>(name.length());
    msgStream.m_stream.writeBytes(name.data(), name.length());
    msgStream.m_stream.write<uint32_t>(m_vars.size());
    msgStream.m_stream.writeBool(m_serverMayDelete);

    for (size_t i=0; i<m_vars.size(); ++i)
        m_vars[i].write(&msgStream.m_stream);
    msgStream.m_stream.seek(0, SEEK_SET);
    msgStream.write(stream);

    stream->write<uint8_t>(m_lockRequest);
}