Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional backwards compatibility with older clients #195

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions AuthServ/AuthServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,33 @@ void auth_init(AuthServer_Private& client)
/* BCast Shard Capabilities */
START_REPLY(e_AuthToCli_ServerCaps);
uint32_t bufSzPos = client.m_buffer.tell();
#ifdef DS_OU_COMPATIBLE
// OpenUru parses this as the start of a FileDownloadChunk message,
// which will be ignored,
// because no file download transaction is active.
client.m_buffer.write<uint32_t>(37);

// H'uru sees: 0x25 bytes of data, bit vector is 1 dword long, value is [caps]
// OpenUru sees: message type 0x25 (FileDownloadChunk), transaction ID 0x10000, error code 0x[caps]0000, file size 0x0000[caps] (continued below)
caps.write(&client.m_buffer);

// Ensure the caps haven't changed size and broken this compat hack
uint32_t newBufPos = client.m_buffer.tell();
DS_ASSERT(newBufPos - bufSzPos == 3 * sizeof(uint32_t));

// ServerCaps message extra data, which is ignored by H'uru,
// because the bit vector doesn't have this many dwords.
// OpenUru parses this as the rest of FileDownloadChunk message:
client.m_buffer.write<uint16_t>(0); // file size 0x0000[caps] (continued)
client.m_buffer.write<uint32_t>(0); // chunk offset 0
client.m_buffer.write<uint32_t>(19); // chunk size 19
client.m_buffer.writeBytes("[ServerCaps compat]", 19); // 19 bytes of chunk data
#else
client.m_buffer.write<uint32_t>(0);
caps.write(&client.m_buffer);
client.m_buffer.seek(bufSzPos, 0);
client.m_buffer.write<uint32_t>(client.m_buffer.size() - bufSzPos - sizeof(uint32_t));
#endif
SEND_REPLY();
}

Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ set(DS_HOOD_INST_NAME "Neighborhood"
set(DS_HOOD_POP_THRESHOLD "20"
CACHE STRING "Default Neighborhood Max Population")

option(DS_OU_COMPATIBLE "Enable backwards compatibility with older game clients" OFF)

add_compile_options(-Wall -Wextra -Wno-unused-parameter)

list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake")
Expand Down Expand Up @@ -133,6 +135,7 @@ add_library(dirtsand STATIC ${dirtsand_SOURCES} ${SDL_SOURCES} ${PlasMOUL_SOURCE

target_compile_definitions(dirtsand PRIVATE
$<$<CONFIG:Debug>:DEBUG>
$<$<BOOL:${DS_OU_COMPATIBLE}>:DS_OU_COMPATIBLE>
PRODUCT_BRANCH_ID=${PRODUCT_BRANCH_ID}
PRODUCT_BUILD_ID=${PRODUCT_BUILD_ID}
PRODUCT_BUILD_TYPE=${PRODUCT_BUILD_TYPE}
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ ARG PRODUCT_UUID=ea489821-6c35-4bd0-9dae-bb17c585e680
ARG DS_HOOD_USER_NAME=DS
ARG DS_HOOD_INST_NAME=Neighborhood
ARG DS_HOOD_POP_THRESHOLD=20
ARG DS_OU_COMPATIBLE=ON

RUN \
mkdir -p /opt/dirtsand/db && cp dirtsand/db/*.sql /opt/dirtsand/db && \
cmake -DCMAKE_INSTALL_PREFIX=/opt/dirtsand -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DPRODUCT_BRANCH_ID=${PRODUCT_BRANCH_ID} -DPRODUCT_BUILD_ID=${PRODUCT_BUILD_ID} \
-DPRODUCT_BUILD_TYPE=${PRODUCT_BUILD_TYPE} -DPRODUCT_UUID=${PRODUCT_UUID} \
-DDS_HOOD_USER_NAME=${DS_HOOD_USER_NAME} -DDS_HOOD_INST_NAME=${DS_HOOD_INST_NAME} \
-DDS_HOOD_POP_THRESHOLD=${DS_HOOD_POP_THRESHOLD} -DENABLE_TESTS=OFF \
-B dirtsand/build -S dirtsand && \
-DDS_HOOD_POP_THRESHOLD=${DS_HOOD_POP_THRESHOLD} -DDS_OU_COMPATIBLE=${DS_OU_COMPATIBLE} \
-DENABLE_TESTS=OFF -B dirtsand/build -S dirtsand && \
cmake --build dirtsand/build --parallel && cmake --build dirtsand/build --target install && \
mkdir -p /opt/dirtsand/etc && \
\
Expand Down
1 change: 1 addition & 0 deletions bin/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ Server.Status "${SHARD_STATUS_URL:-http://${DS_HOST:-127.0.0.1}:8080/welcome}"

# Shard front-end server address.
Server.Gate.Host "${DS_HOST:-127.0.0.1}"
Server.Auth.Host "${DS_HOST:-127.0.0.1}"
Server.Port ${SHARD_PORT:-14617}

# Shard name - NOTE: this is currently not visible anywhere.
Expand Down