Skip to content

Commit

Permalink
Merge pull request ddnet#7153 from infclass/for-ddnet4
Browse files Browse the repository at this point in the history
Mod Support: CMake: Use DDNet_VERSION to construct DDNET_VERSION_NUMBER
  • Loading branch information
def- authored Sep 8, 2023
2 parents f3eaa10 + 6b78013 commit b951eab
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,16 @@ if(IPO)
endif()
endif()

if("0${PROJECT_VERSION_PATCH}" GREATER 9)
message(SEND_ERROR "Invalid project patch version (the version is \"${PROJECT_VERSION}\", the patch part must be in range 0-9 if set)")
if("0${DDNet_VERSION_PATCH}" GREATER 9)
message(SEND_ERROR "Invalid DDNet patch version (the version is \"${DDNet_VERSION}\", the patch part must be in range 0-9 if set)")
endif()
if(${PROJECT_VERSION_MINOR} GREATER 99)
message(SEND_ERROR "Invalid project minor version (the version is \"${PROJECT_VERSION}\", the minor part must be in range 0-99)")
if(${DDNet_VERSION_MINOR} GREATER 99)
message(SEND_ERROR "Invalid DDNet minor version (the version is \"${DDNet_VERSION}\", the minor part must be in range 0-99)")
endif()
if(${PROJECT_VERSION_MINOR} GREATER 9)
set(CLIENT_VERSIONNR ${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}${PROJECT_VERSION_PATCH})
if(${DDNet_VERSION_MINOR} GREATER 9)
set(DDNET_VERSION_NUMBER ${DDNet_VERSION_MAJOR}${DDNet_VERSION_MINOR}${DDNet_VERSION_PATCH})
else()
set(CLIENT_VERSIONNR ${PROJECT_VERSION_MAJOR}0${PROJECT_VERSION_MINOR}${PROJECT_VERSION_PATCH})
set(DDNET_VERSION_NUMBER ${DDNet_VERSION_MAJOR}0${DDNet_VERSION_MINOR}${DDNet_VERSION_PATCH})
endif()

configure_file(src/game/version.h.in ${PROJECT_BINARY_DIR}/src/game/version.h)
Expand Down Expand Up @@ -2893,7 +2893,7 @@ set(CPACK_SOURCE_GENERATOR ZIP TGZ TBZ2 TXZ)
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})

if(TARGET_OS AND TARGET_BITS)
Expand Down
2 changes: 1 addition & 1 deletion src/engine/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ int CServer::GetClientVersion(int ClientID) const
{
// Assume latest client version for server demos
if(ClientID == SERVER_DEMO_CLIENT)
return CLIENT_VERSIONNR;
return DDNET_VERSION_NUMBER;

CClientInfo Info;
if(GetClientInfo(ClientID, &Info))
Expand Down
4 changes: 2 additions & 2 deletions src/game/client/gameclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ using namespace std::chrono_literals;

const char *CGameClient::Version() const { return GAME_VERSION; }
const char *CGameClient::NetVersion() const { return GAME_NETVERSION; }
int CGameClient::DDNetVersion() const { return CLIENT_VERSIONNR; }
int CGameClient::DDNetVersion() const { return DDNET_VERSION_NUMBER; }
const char *CGameClient::DDNetVersionStr() const { return m_aDDNetVersionStr; }
const char *CGameClient::GetItemName(int Type) const { return m_NetObjHandler.GetObjName(Type); }

Expand Down Expand Up @@ -1770,7 +1770,7 @@ void CGameClient::OnNewSnapshot()
continue;
}
CMsgPacker Msg(NETMSGTYPE_CL_ISDDNETLEGACY, false);
Msg.AddInt(CLIENT_VERSIONNR);
Msg.AddInt(DDNetVersion());
Client()->SendMsg(i, &Msg, MSGFLAG_VITAL);
m_aDDRaceMsgSent[i] = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define GAME_RELEASE_VERSION "${PROJECT_VERSION}"
#define GAME_VERSION "0.6.4, " GAME_RELEASE_VERSION
#define GAME_NETVERSION "0.6 626fce9a778df4d4"
#define CLIENT_VERSIONNR ${CLIENT_VERSIONNR}
#define DDNET_VERSION_NUMBER ${DDNET_VERSION_NUMBER}
extern const char *GIT_SHORTREV_HASH;
#define GAME_NAME "DDNet"
#endif

0 comments on commit b951eab

Please sign in to comment.