diff --git a/CMakeLists.txt b/CMakeLists.txt index e7ab2e9..f61962b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,17 +19,38 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") # Set environment variables set(METIN2_OS_NAME ${CMAKE_SYSTEM}) -set(METIN2_COMPILER_NAME ${CMAKE_CXX_COMPILER_ID}) +set(METIN2_COMPILER "${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}") set(METIN2_CPU_TARGET ${CMAKE_SYSTEM_PROCESSOR}) # Git revision include(FindGit) find_package(Git) -set(METIN2_REVISION "unknown") +if(GIT_FOUND) + GIT_WC_INFO(${PROJECT_SOURCE_DIR} Metin2) + set(METIN2_REVISION ${Metin2_WC_REVISION_NAME}) + set(METIN2_LAST_CHANGED_DATE ${Metin2_WC_LAST_CHANGED_DATE}) + + if (${Metin2_WC_LATEST_TAG} NOT STREQUAL "") + set(METIN2_LATEST_TAG ${Metin2_WC_LATEST_TAG}) + else() + set(METIN2_LATEST_TAG "unknown") + endif() +else() + set(METIN2_REVISION "unknown") + set(METIN2_LAST_CHANGED_DATE "\"unknown\"") + set(METIN2_LATEST_TAG "unknown") +endif() message(STATUS "Current revision is ${METIN2_REVISION}") +# Generate the version header +configure_file ( + "${PROJECT_SOURCE_DIR}/common/version.h.in" + "${PROJECT_BINARY_DIR}/common/version.h" +) +include_directories(${PROJECT_BINARY_DIR}/common/) + # Set the global include directories include_directories(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/common/version.h.in b/common/version.h.in new file mode 100644 index 0000000..08dee7d --- /dev/null +++ b/common/version.h.in @@ -0,0 +1,15 @@ +#ifndef __INC_METIN_II_VERSION_H__ +#define __INC_METIN_II_VERSION_H__ + +#include + +#define __REVISION__ "@METIN2_REVISION@" +#define __COMMIT_DATE__ @METIN2_LAST_CHANGED_DATE@ +#define __COMMIT_TAG__ "@METIN2_LATEST_TAG@" +#define __OS_NAME__ "@METIN2_OS_NAME@" +#define __COMPILER__ "@METIN2_COMPILER@" +#define __CPU_TARGET__ "@METIN2_CPU_TARGET@" + +void WriteVersion(std::ostream& out); + +#endif diff --git a/db/CMakeLists.txt b/db/CMakeLists.txt index 58bfe42..f9307a2 100644 --- a/db/CMakeLists.txt +++ b/db/CMakeLists.txt @@ -6,9 +6,7 @@ file(GLOB_RECURSE sources src/*.cpp src/*.h ) - -include_directories(${PROJECT_BINARY_DIR}/src/) - +# Add the src directory to the include path include_directories(src/) add_executable(${PROJECT_NAME} ${sources}) diff --git a/db/src/Main.cpp b/db/src/Main.cpp index 6cc69e7..efda49d 100644 --- a/db/src/Main.cpp +++ b/db/src/Main.cpp @@ -12,6 +12,7 @@ #include "Monarch.h" #include "BlockCountry.h" #include "ItemIDRangeManager.h" +#include #ifdef __AUCTION__ #include "AuctionManager.h" #endif @@ -48,8 +49,6 @@ int g_iItemPriceListTableCacheFlushSeconds = 540; extern const char * _malloc_options; #endif -extern void WriteVersion(); - void emergency_sig(int sig) { if (sig == SIGSEGV) @@ -63,7 +62,7 @@ void emergency_sig(int sig) int main() { - WriteVersion(); + WriteVersion(std::cout); #ifdef __FreeBSD__ _malloc_options = "A"; diff --git a/db/src/stdafx.h b/db/src/stdafx.h index 7617a8a..df0b38d 100644 --- a/db/src/stdafx.h +++ b/db/src/stdafx.h @@ -19,5 +19,6 @@ #include #include +#include #endif diff --git a/db/src/version.cpp b/db/src/version.cpp index c9b82c1..f9972a6 100644 --- a/db/src/version.cpp +++ b/db/src/version.cpp @@ -1,21 +1,15 @@ -#include -#include +#include -void WriteVersion() -{ -#ifndef __WIN32__ - FILE* fp(fopen("VERSION.txt", "w")); +void WriteVersion(std::ostream& out) { + out << "Metin2 DB Cache version " << __COMMIT_TAG__ << " " + << "(rev. " << __REVISION__ << ", date: " << __COMMIT_DATE__ << ")" + << std::endl; - if (NULL != fp) - { - fprintf(fp, "db\n"); - fclose(fp); - } - else - { - fprintf(stderr, "cannot open VERSION.txt\n"); - exit(0); - } -#endif + out << "OS: " << __OS_NAME__ << ", " + << "target arch: " << __CPU_TARGET__ << ", " + << "compiler: " << __COMPILER__ + << std::endl; + + out << std::endl; } diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index 288156a..25d8b4f 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -6,8 +6,7 @@ file(GLOB_RECURSE sources src/*.cpp src/*.h ) -include_directories(${PROJECT_BINARY_DIR}/src/) - +# Add the src directory to the include path include_directories(src/) # Find dependencies diff --git a/game/src/char.cpp b/game/src/char.cpp index 3de9100..1ca3455 100644 --- a/game/src/char.cpp +++ b/game/src/char.cpp @@ -3622,7 +3622,7 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast if (GetDesc()) { - struct packet_point_change pack; + TPacketGCPointChange pack; pack.header = HEADER_GC_CHARACTER_POINT_CHANGE; pack.dwVID = m_vid; @@ -3635,7 +3635,7 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast pack.amount = 0; if (!bBroadcast) - GetDesc()->Packet(&pack, sizeof(struct packet_point_change)); + GetDesc()->Packet(&pack, sizeof(TPacketGCPointChange)); else PacketAround(&pack, sizeof(pack)); } diff --git a/game/src/input.h b/game/src/input.h index 3a05164..e90d256 100644 --- a/game/src/input.h +++ b/game/src/input.h @@ -63,8 +63,6 @@ class CInputHandshake : public CInputProcessor virtual int Analyze(LPDESC d, BYTE bHeader, const char * c_pData); protected: - void GuildMarkLogin(LPDESC d, const char* c_pData); - CPacketInfo * m_pMainPacketInfo; }; diff --git a/game/src/main.cpp b/game/src/main.cpp index d65336e..e93ff7a 100644 --- a/game/src/main.cpp +++ b/game/src/main.cpp @@ -58,6 +58,7 @@ #include "skill_power.h" #include "SpeedServer.h" #include "DragonSoul.h" +#include #include #include #include @@ -70,7 +71,6 @@ #include #endif -extern void WriteVersion(); //extern const char * _malloc_options; #if defined(__FreeBSD__) && defined(DEBUG_ALLOC) extern void (*_malloc_message)(const char* p1, const char* p2, const char* p3, const char* p4); @@ -331,7 +331,7 @@ int main(int argc, char **argv) ilInit(); // DevIL Initialize - WriteVersion(); + WriteVersion(std::cout); SECTREE_MANAGER sectree_manager; CHARACTER_MANAGER char_manager; diff --git a/game/src/packet.h b/game/src/packet.h index 3463fbc..8b1eb1e 100644 --- a/game/src/packet.h +++ b/game/src/packet.h @@ -931,7 +931,7 @@ typedef struct packet_char_additional_info BYTE bEmpire; DWORD dwGuildID; DWORD dwLevel; - short sAlignment; + sh_int sAlignment; BYTE bPKMode; DWORD dwMountVnum; } TPacketGCCharacterAdditionalInfo; @@ -950,7 +950,7 @@ typedef struct packet_char_additional_info DWORD dwAffectFlag[2]; DWORD dwGuildID; - short sAlignment; + sh_int sAlignment; BYTE bPKMode; DWORD dwMountVnum; } TPacketGCCharacterUpdateOld; @@ -961,7 +961,7 @@ typedef struct packet_update_char BYTE header; DWORD dwVID; - WORD awPart[CHR_EQUIPPART_NUM]; + WORD awPart[CHR_EQUIPPART_NUM]; BYTE bMovingSpeed; BYTE bAttackSpeed; @@ -969,7 +969,7 @@ typedef struct packet_update_char DWORD dwAffectFlag[2]; DWORD dwGuildID; - short sAlignment; + sh_int sAlignment; BYTE bPKMode; DWORD dwMountVnum; //WORD wRaceNum; @@ -1060,7 +1060,7 @@ typedef struct packet_skill_level typedef struct packet_point_change { - INT header; + BYTE header; DWORD dwVID; BYTE type; LONG amount; @@ -1573,7 +1573,7 @@ typedef struct packet_party_update DWORD pid; BYTE role; BYTE percent_hp; - short affects[7]; + sh_int affects[7]; } TPacketGCPartyUpdate; typedef struct packet_party_remove diff --git a/game/src/stdafx.h b/game/src/stdafx.h index 53c0548..a380ca7 100644 --- a/game/src/stdafx.h +++ b/game/src/stdafx.h @@ -6,14 +6,15 @@ #include "debug_allocator.h" -#include "../../libthecore/include/stdafx.h" +#include #include #include #include +#include #include -#include +#include #include #include #include @@ -22,7 +23,7 @@ #include #include -#include +#include #include #include @@ -32,12 +33,5 @@ #define PASSES_PER_SEC(sec) ((sec) * passes_per_sec) -#ifndef M_PI -#define M_PI 3.14159265358979323846 /* pi */ -#endif -#ifndef M_PI_2 -#define M_PI_2 1.57079632679489661923 /* pi/2 */ -#endif - #define IN #define OUT diff --git a/game/src/version.cpp b/game/src/version.cpp index f042c2b..5bb175a 100644 --- a/game/src/version.cpp +++ b/game/src/version.cpp @@ -1,16 +1,15 @@ -#include +#include -void WriteVersion() -{ -#ifndef __WIN32__ - FILE* fp = fopen("ver.txt", "w"); +void WriteVersion(std::ostream& out) { + out << "Metin2 Game Server version " << __COMMIT_TAG__ << " " + << "(rev. " << __REVISION__ << ", date: " << __COMMIT_DATE__ << ")" + << std::endl; - if (fp) - { - fprintf(fp, "emulated game server\n"); - //fprintf(fp, "%s@%s:%s\n", __USER__, __HOSTNAME__, __PWD__); - fclose(fp); - } -#endif + out << "OS: " << __OS_NAME__ << ", " + << "target arch: " << __CPU_TARGET__ << ", " + << "compiler: " << __COMPILER__ + << std::endl; + + out << std::endl; }