Skip to content

Commit

Permalink
Fix some style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1arm committed Aug 22, 2024
1 parent 437be4b commit 97c25cd
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 226 deletions.
8 changes: 1 addition & 7 deletions dep/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ if(BUILD_MANGOSD OR BUILD_TOOLS)
endif()

if(BUILD_TOOLS)
if(USE_STORMLIB)
add_subdirectory(StormLib)
add_subdirectory(tomlib)
else()
add_subdirectory(libmpq)
endif()
add_subdirectory(StormLib)
add_subdirectory(loadlib)
endif()

164 changes: 34 additions & 130 deletions dep/StormLib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
project(StormLib)
cmake_minimum_required(VERSION 2.8.12)
#
# This code is part of MaNGOS. Contributor & Copyright details are in AUTHORS/THANKS.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#

set(LIBRARY_NAME stormlib)

include(CMakeDependentOption)
project(StormLib VERSION 9.22)

option(BUILD_SHARED_LIBS "Compile shared libraries" OFF)
option(STORM_SKIP_INSTALL "Skip installing files" OFF)
option(STORM_BUILD_TESTS
"Compile StormLib test application" OFF
# "BUILD_TESTING" OFF # Stay coherent with CTest variables
)
set(LIBRARY_NAME stormlib)

set(SRC_FILES
src/adpcm/adpcm.cpp
Expand Down Expand Up @@ -45,14 +53,6 @@ set(SRC_FILES
src/libtomcrypt/src/misc/crypt_libc.c
)

if(MSVC)
# This file is used to create a DLL on windows
# Use BUILD_SHARED_LIBS to create StormLib.dll
set(STORM_DEF_FILES
src/DllMain.def
)
endif()

set(TOMCRYPT_FILES
src/libtomcrypt/src/hashes/hash_memory.c
src/libtomcrypt/src/hashes/md5.c
Expand Down Expand Up @@ -253,122 +253,26 @@ set(TOMMATH_FILES
src/libtommath/bn_s_mp_sub.c
)

# Needed for Windows
set(ZLIB_BZIP2_FILES
src/bzip2/blocksort.c
src/bzip2/bzlib.c
src/bzip2/compress.c
src/bzip2/crctable.c
src/bzip2/decompress.c
src/bzip2/huffman.c
src/bzip2/randtable.c
src/zlib/adler32.c
src/zlib/compress.c
src/zlib/crc32.c
src/zlib/deflate.c
src/zlib/inffast.c
src/zlib/inflate.c
src/zlib/inftrees.c
src/zlib/trees.c
src/zlib/zutil.c
)

set(TEST_SRC_FILES
test/StormTest.cpp
)

add_definitions(-D_7ZIP_ST -DBZ_STRICT_ANSI)

if(WIN32)
set(SRC_ADDITIONAL_FILES ${ZLIB_BZIP2_FILES} ${TOMCRYPT_FILES} ${TOMMATH_FILES})
set(LINK_LIBS wininet)
else()
find_package(ZLIB REQUIRED)
find_package(BZip2 REQUIRED)

include_directories(${ZLIB_INCLUDE_DIR} ${BZIP2_INCLUDE_DIR})
set(LINK_LIBS ${ZLIB_LIBRARY} ${BZIP2_LIBRARIES})

add_definitions(-D__SYS_ZLIB -D__SYS_BZLIB)

option(WITH_LIBTOMCRYPT "Use system LibTomCrypt library" OFF)
if(WITH_LIBTOMCRYPT)
set(LINK_LIBS ${LINK_LIBS} tomcrypt)
else()
set(SRC_ADDITIONAL_FILES ${TOMCRYPT_FILES} ${TOMMATH_FILES})
endif()
endif()
set(SRC_ADDITIONAL_FILES ${TOMCRYPT_FILES} ${TOMMATH_FILES})
add_definitions(-D_7ZIP_ST -DBZ_STRICT_ANSI -D__SYS_ZLIB -D__SYS_BZLIB)

if(${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD)
message(STATUS "Using FreeBSD port")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DO_LARGEFILE=0 -Dstat64=stat -Dlstat64=lstat -Dlseek64=lseek -Doff64_t=off_t -Dfstat64=fstat -Dftruncate64=ftruncate")
endif()

add_library(${LIBRARY_NAME} ${LIB_TYPE} ${SRC_FILES} ${SRC_ADDITIONAL_FILES} ${STORM_DEF_FILES})

target_link_libraries(${LIBRARY_NAME} ${LINK_LIBS})
target_compile_definitions(${LIBRARY_NAME} INTERFACE STORMLIB_NO_AUTO_LINK) #CMake will take care of the linking
target_include_directories(${LIBRARY_NAME} PUBLIC src/)
set_target_properties(${LIBRARY_NAME} PROPERTIES PUBLIC_HEADER "src/StormLib.h;src/StormPort.h")
if(BUILD_SHARED_LIBS)
message(STATUS "Linking against dependent libraries dynamically")

if(APPLE)
set_target_properties(${LIBRARY_NAME} PROPERTIES FRAMEWORK true)
set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS "-framework Carbon")
endif()
if(UNIX)
SET(VERSION_MAJOR "9")
SET(VERSION_MINOR "22")
SET(VERSION_PATCH "0")
SET(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
set_target_properties(${LIBRARY_NAME} PROPERTIES VERSION "${VERSION_STRING}")
set_target_properties(${LIBRARY_NAME} PROPERTIES SOVERSION "${VERSION_MAJOR}")
endif()
else()
message(STATUS "Linking against dependent libraries statically")
endif()

if (NOT STORM_SKIP_INSTALL)
install(TARGETS ${LIBRARY_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
FRAMEWORK DESTINATION /Library/Frameworks
PUBLIC_HEADER DESTINATION include
INCLUDES DESTINATION include)

#CPack configurtion
SET(CPACK_GENERATOR "DEB" "RPM")
SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MPQ manipulation library")
SET(CPACK_PACKAGE_VENDOR "Ladislav Zezula")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
SET(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}")
add_library(
${LIBRARY_NAME}
STATIC
${SRC_FILES}
${SRC_ADDITIONAL_FILES}
)

#DEB configuration
SET(CPACK_DEBIAN_PACKAGE_SECTION "libs")
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://www.zezula.net/en/mpq/stormlib.html")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "[email protected]")
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "zlib1g,bzip2")

#RPM configuration
SET(CPACK_RPM_PACKAGE_RELEASE 1)
SET(CPACK_RPM_PACKAGE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
SET(CPACK_RPM_PACKAGE_GROUP "${PROJECT_NAME}")
SET(CPACK_RPM_PACKAGE_URL "http://www.zezula.net/en/mpq/stormlib.html")
SET(CPACK_RPM_PACKAGE_REQUIRES "zlib,bzip2")

INCLUDE(CPack)
endif()

if(STORM_BUILD_TESTS)
add_executable(StormLib_test ${TEST_SRC_FILES})
target_link_libraries(StormLib_test ${LIBRARY_NAME})
install(TARGETS StormLib_test RUNTIME DESTINATION bin)
set(LINK_LIBS ${LINK_LIBS} ZLIB::ZLIB BZip2::BZip2)
if(WIN32)
set(LINK_LIBS ${LINK_LIBS} wininet)
endif()

target_link_libraries(${LIBRARY_NAME} PRIVATE ${LINK_LIBS})
target_compile_definitions(${LIBRARY_NAME} INTERFACE STORMLIB_NO_AUTO_LINK)
target_include_directories(${LIBRARY_NAME} PUBLIC src/)
set_target_properties(${LIBRARY_NAME} PROPERTIES PUBLIC_HEADER "src/StormLib.h;src/StormPort.h")
2 changes: 1 addition & 1 deletion dep/loadlib/ml/adt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
*
* Copyright (C) 2005-2023 MaNGOS project <http://getmangos.eu>
* Copyright (C) 2005-2023 MaNGOS <http://getmangos.eu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
48 changes: 17 additions & 31 deletions dep/loadlib/ml/loadlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,29 @@
#ifndef LOAD_LIB_H
#define LOAD_LIB_H

//#ifdef _DLL
//#undef _DLL
//#endif

#include <string>
#include "StormLib.h"
#include <cstdint>
#include <string>
#include <deque>
#include <map>

#ifdef WIN32
typedef __int64 int64;
typedef __int32 int32;
typedef __int16 int16;
//typedef __int8 int8; // This conflict
typedef unsigned __int64 uint64;
typedef unsigned __int32 uint32;
typedef unsigned __int16 uint16;
typedef unsigned __int8 uint8;
#else
#include <stdint.h>
#ifndef uint64_t
#ifdef __linux__
#include <linux/types.h>
#endif
#endif
typedef int64_t int64;
typedef int32_t int32;
typedef int16_t int16;
//typedef int8_t int8; // This conflict
typedef uint64_t uint64;
typedef uint32_t uint32;
typedef uint16_t uint16;
typedef uint8_t uint8;
#ifndef _WIN32
using HANDLE = void*;
#endif

typedef std::deque<HANDLE> ArchiveSet;
typedef std::pair<ArchiveSet::const_iterator, ArchiveSet::const_iterator> ArchiveSetBounds;
using int8 = int8_t;
using int16 = int16_t;
using int32 = int32_t;
using int64 = int64_t;
using uint8 = uint8_t;
using uint16 = uint16_t;
using uint32 = uint32_t;
using uint64 = uint64_t;


using ArchiveSet = std::deque<HANDLE>;
using ArchiveSetBounds = std::pair<ArchiveSet::const_iterator, ArchiveSet::const_iterator>;


/**
* @brief Open a MPQ file archive and return the Archive HANDLE to the calling method.
Expand Down
40 changes: 1 addition & 39 deletions dep/loadlib/ml/mpq.h
Original file line number Diff line number Diff line change
@@ -1,45 +1,7 @@
#define _CRT_SECURE_NO_DEPRECATE
#ifndef _CRT_SECURE_NO_WARNINGS // fuck the police^Wwarnings
#define _CRT_SECURE_NO_WARNINGS
#endif

#ifndef MPQ_H
#define MPQ_H

#include <string.h>
#include <ctype.h>
#include <vector>
#include <iostream>
#include <deque>
#include "StormLib.h"

#ifdef _WIN32
#include <Windows.h> // mainly only HANDLE definition is required
typedef __int64 int64;
typedef __int32 int32;
typedef __int16 int16;
typedef __int8 int8;
typedef unsigned __int64 uint64;
typedef unsigned __int32 uint32;
typedef unsigned __int16 uint16;
typedef unsigned __int8 uint8;
#else
#include <stdint.h>
#ifndef uint64_t
#ifdef __linux__
#include <linux/types.h>
#endif
#endif
typedef int64_t int64;
typedef int32_t int32;
typedef int16_t int16;
typedef int8_t int8;
typedef uint64_t uint64;
typedef uint32_t uint32;
typedef uint16_t uint16;
typedef uint8_t uint8;
typedef void* HANDLE;
#endif
#include "loadlib.h"

using namespace std;

Expand Down
4 changes: 4 additions & 0 deletions src/game/Object/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,9 @@ void Creature::SetLootRecipient(Unit* unit)

// pet-only kills don't drop when pet is killing a creature on its own without assistance from its owner (player)
if (unit->GetTypeId() != TYPEID_PLAYER && !unit->IsVehicle())
{
return;
}

Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself();
if (!player) // normal creature, no player involved
Expand Down Expand Up @@ -3025,7 +3027,9 @@ void Creature::AllLootRemovedFromCorpse()
time_t now = GameTime::GetGameTime();
// Do not reset corpse remove time if corpse is already removed
if (m_corpseDecayTimer <= now)
{
return;
}

float decayRate = m_ignoreCorpseDecayRatio ? 1.f : sWorld.getConfig(CONFIG_FLOAT_RATE_CORPSE_DECAY_LOOTED);

Expand Down
2 changes: 2 additions & 0 deletions src/game/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,9 @@ void WorldObject::SetMap(Map* map)

#ifdef ENABLE_ELUNA
if (!elunaEvents)
{
elunaEvents = new ElunaEventProcessor(&Eluna::GEluna, this);
}
#endif
}

Expand Down
5 changes: 4 additions & 1 deletion src/game/Server/DBCStores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ int ReadDBCLocale(const std::string sDataPath)
sFilename = sDBCpath + "component.wow-" + fullLocaleNameList[uLocaleIndex].name + ".txt";
if (FILE* file = fopen(sFilename.c_str(), "rb"))
{
if(uLocaleIndex==0) {uLocaleIndex=1;} // Map enus and engb to 0
if(uLocaleIndex==0)
{
uLocaleIndex=1; // Map enus and engb to 0
}

return uLocaleIndex-1; // Successfully located the locale
}
Expand Down
Loading

0 comments on commit 97c25cd

Please sign in to comment.