From d3db3f258c6445dc3afc9680330e0dfda7a3220b Mon Sep 17 00:00:00 2001 From: Asheraf Date: Wed, 7 Feb 2024 12:15:14 +0100 Subject: [PATCH 1/5] Adding github actions workflows for macos x64 and ARM --- .github/workflows/controller.yml | 8 ++ .github/workflows/macos_latest.yml | 81 ++++++++++++++ .github/workflows/macos_m1.yml | 81 ++++++++++++++ configure | 167 ++++++++++++++++++++++++----- configure.ac | 27 ++--- tools/ci/travis.sh | 8 +- 6 files changed, 330 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/macos_latest.yml create mode 100644 .github/workflows/macos_m1.yml diff --git a/.github/workflows/controller.yml b/.github/workflows/controller.yml index 96dbfcf206..7e73f429c6 100644 --- a/.github/workflows/controller.yml +++ b/.github/workflows/controller.yml @@ -51,3 +51,11 @@ jobs: needs: build if: ${{ !failure() && !cancelled() }} uses: ./.github/workflows/mysql.yml + macos_latest: + needs: build + if: ${{ !failure() && !cancelled() }} + uses: ./.github/workflows/macos_latest.yml + macos_m1: + needs: build + if: ${{ !failure() && !cancelled() }} + uses: ./.github/workflows/macos_m1.yml diff --git a/.github/workflows/macos_latest.yml b/.github/workflows/macos_latest.yml new file mode 100644 index 0000000000..02e2a86734 --- /dev/null +++ b/.github/workflows/macos_latest.yml @@ -0,0 +1,81 @@ +name: macos_latest + +on: workflow_call + +env: + MYSQL_DATABASE: 'ragnarok' + MYSQL_USER: 'ragnarok' + MYSQL_PASSWORD: 'ragnarok' + MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' + MACOS_COMMON_PACKAGES: make zlib pcre mysql mysql-client mysql-connector-c + SQLHOST: 'localhost' + +jobs: + build: + runs-on: macos-latest + timeout-minutes: 60 + strategy: + matrix: + CC: [clang] + RENEWAL: ["", "--disable-renewal"] + CLIENT_TYPE: ["", "--enable-packetver-re", "--enable-packetver-zero"] + HTTPLIB: ["", "--with-http_parser=llhttp"] + SANITIZER: ["--disable-manager", "--disable-manager --enable-sanitize=full"] + PACKET_VERSION: ["--enable-packetver=20221024", "--enable-packetver=20130724"] + exclude: + - PACKET_VERSION: "--enable-packetver=20130724" + CLIENT_TYPE: "--enable-packetver-zero" + + # github.head_ref will stop previous runs in the same PR (if in a PR) + # github.run_id is a fallback when outside a PR (e.g. every merge in master will run, and previous won't stop) + concurrency: + group: macos-x64-${{ github.head_ref || github.run_id }}_${{ matrix.CC }}_${{ matrix.RENEWAL }}_${{ matrix.CLIENT_TYPE }}_${{ matrix.HTTPLIB }}_${{ matrix.SANITIZER }}_${{ matrix.PACKET_VERSION}} + cancel-in-progress: true + + env: + CC: ${{ matrix.CC }} + CONFIGURE_FLAGS: CC=${{ matrix.CC }} --enable-debug --enable-Werror --enable-buildbot ${{ matrix.RENEWAL }} ${{ matrix.HTTPLIB }} ${{ matrix.CLIENT_TYPE }} ${{ matrix.SANITIZER }} ${{ matrix.PACKET_VERSION }} + PACKET_VERSION: ${{ matrix.PACKET_VERSION }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: info + run: | + uname -a + + - name: prepare the build environment + run: | + echo "CPPFLAGS=-I$(brew --prefix)/include" >> $GITHUB_ENV + echo "LDFLAGS=-L$(brew --prefix)/lib" >> $GITHUB_ENV + + - name: install packages + run: | + brew update || true + ./tools/ci/retry.sh brew install $MACOS_COMMON_PACKAGES + + - name: setup mysql server + run: | + brew services start mysql + ./tools/ci/retry.sh mysqladmin ping --silent + ./tools/ci/travis.sh createdb $MYSQL_DATABASE root + ./tools/ci/travis.sh adduser $MYSQL_DATABASE $MYSQL_USER $MYSQL_PASSWORD root '' $SQLHOST + ./tools/ci/travis.sh importdb $MYSQL_DATABASE root + + - name: get plugins + run: | + ./tools/ci/travis.sh getplugins || true + + - name: build + run: | + ./tools/ci/travis.sh build $CONFIGURE_FLAGS --with-mysql=$(brew --prefix mysql)/bin/mysql_config + + - name: test + run: | + ./tools/ci/travis.sh test ragnarok ragnarok ragnarok $SQLHOST + + - name: extra test + if: env.PACKET_VERSION != '--enable-packetver=20130724' + run: | + ./tools/ci/travis.sh extratest diff --git a/.github/workflows/macos_m1.yml b/.github/workflows/macos_m1.yml new file mode 100644 index 0000000000..f4dbfa2945 --- /dev/null +++ b/.github/workflows/macos_m1.yml @@ -0,0 +1,81 @@ +name: macos_m1 + +on: workflow_call + +env: + MYSQL_DATABASE: 'ragnarok' + MYSQL_USER: 'ragnarok' + MYSQL_PASSWORD: 'ragnarok' + MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' + MACOS_COMMON_PACKAGES: make zlib pcre mysql mysql-client mysql-connector-c + SQLHOST: 'localhost' + +jobs: + build: + runs-on: macos-14 + timeout-minutes: 60 + strategy: + matrix: + CC: [clang] + RENEWAL: ["", "--disable-renewal"] + CLIENT_TYPE: ["", "--enable-packetver-re", "--enable-packetver-zero"] + HTTPLIB: ["", "--with-http_parser=llhttp"] + SANITIZER: ["--disable-manager", "--disable-manager --enable-sanitize=full"] + PACKET_VERSION: ["--enable-packetver=20221024", "--enable-packetver=20130724"] + exclude: + - PACKET_VERSION: "--enable-packetver=20130724" + CLIENT_TYPE: "--enable-packetver-zero" + + # github.head_ref will stop previous runs in the same PR (if in a PR) + # github.run_id is a fallback when outside a PR (e.g. every merge in master will run, and previous won't stop) + concurrency: + group: macos-arm-${{ github.head_ref || github.run_id }}_${{ matrix.CC }}_${{ matrix.RENEWAL }}_${{ matrix.CLIENT_TYPE }}_${{ matrix.HTTPLIB }}_${{ matrix.SANITIZER }}_${{ matrix.PACKET_VERSION}} + cancel-in-progress: true + + env: + CC: ${{ matrix.CC }} + CONFIGURE_FLAGS: CC=${{ matrix.CC }} --enable-debug --enable-Werror --enable-buildbot ${{ matrix.RENEWAL }} ${{ matrix.HTTPLIB }} ${{ matrix.CLIENT_TYPE }} ${{ matrix.SANITIZER }} ${{ matrix.PACKET_VERSION }} + PACKET_VERSION: ${{ matrix.PACKET_VERSION }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: info + run: | + uname -a + + - name: prepare the build environment + run: | + echo "CPPFLAGS=-I$(brew --prefix)/include" >> $GITHUB_ENV + echo "LDFLAGS=-L$(brew --prefix)/lib" >> $GITHUB_ENV + + - name: install packages + run: | + brew update || true + ./tools/ci/retry.sh brew install $MACOS_COMMON_PACKAGES + + - name: setup mysql server + run: | + brew services start mysql + ./tools/ci/retry.sh mysqladmin ping --silent + ./tools/ci/travis.sh createdb $MYSQL_DATABASE root + ./tools/ci/travis.sh adduser $MYSQL_DATABASE $MYSQL_USER $MYSQL_PASSWORD root '' $SQLHOST + ./tools/ci/travis.sh importdb $MYSQL_DATABASE root + + - name: get plugins + run: | + ./tools/ci/travis.sh getplugins || true + + - name: build + run: | + ./tools/ci/travis.sh build $CONFIGURE_FLAGS --with-mysql=$(brew --prefix mysql)/bin/mysql_config + + - name: test + run: | + ./tools/ci/travis.sh test ragnarok ragnarok ragnarok $SQLHOST + + - name: extra test + if: env.PACKET_VERSION != '--enable-packetver=20130724' + run: | + ./tools/ci/travis.sh extratest diff --git a/configure b/configure index 67bbd3e4dc..86dc664358 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac a16c389a2. +# From configure.ac ce12b6b8f. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.71. # @@ -1396,38 +1396,39 @@ Optional Features: --enable-packetver-ad Sets or unsets the PACKETVER_AD define - see src/common/mmo.h (currently disabled by default) --enable-epoll use epoll(4) on Linux - --enable-debug[=ARG] Compiles extra debug code. (yes by default) + --enable-debug[=ARG] Compiles extra debug code. (yes by default) (available options: yes, no, gdb) --enable-libbacktrace[=ARG] - Compiles with libbacktrace. (no by default - + Compiles with libbacktrace. (no by default - experimental) --enable-buildbot[=ARG] (available options: yes, no) - --enable-rdtsc Uses rdtsc as timing source (disabled by default) - Enable it when you've timing issues. (For example: - in conjunction with XEN or Other Virtualization - mechanisms) Note: Please ensure that you've disabled - dynamic CPU-Frequencys, such as power saving - options. (On most modern Dedicated Servers cpufreq - is preconfigured, see your distribution's manual how - to disable it). Furthermore, If your CPU has - built-in CPU-Frequency scaling features (such as - Intel's SpeedStep(R)), do not enable this option. - Recent CPUs (Intel Core or newer) guarantee a fixed - increment rate for their TSC, so it should be safe - to use, but please doublecheck the documentation of - both your CPU and OS before enabling this option. + --enable-rdtsc Uses rdtsc as timing source (disabled by default) + Enable it when you've timing issues. (For + example: in conjunction with XEN or Other + Virtualization mechanisms) Note: Please ensure + that you've disabled dynamic CPU-Frequencys, such as + power saving options. (On most modern Dedicated + Servers cpufreq is preconfigured, see your + distribution's manual how to disable it). + Furthermore, If your CPU has built-in CPU-Frequency + scaling features (such as Intel's SpeedStep(R)), do + not enable this option. Recent CPUs (Intel Core or + newer) guarantee a fixed increment rate for their + TSC, so it should be safe to use, but please + doublecheck the documentation of both your CPU and + OS before enabling this option. --enable-profiler=ARG Profilers: no, gprof (disabled by default) - --disable-64bit Enforce 32bit output on x86_64 systems. - --enable-lto Enables or Disables Linktime Code Optimization (LTO - is disabled by default) - --enable-static Enables or Disables Statick Linking (STATIC is + --disable-64bit Enforce 32bit output on x86_64 systems. + --enable-lto Enables or Disables Linktime Code Optimization + (LTO is disabled by default) + --enable-static Enables or Disables Statick Linking (STATIC is disabled by default) - --enable-sanitize[=ARG] Enables sanitizer. (disabled by default) (available - options: yes, no, full) - --enable-Werror Enables -Werror in the compiler flags. (disabled by - default) - --disable-renewal Disable Ragnarok Renewal support (override settings - in src/config/renewal.h) + --enable-sanitize[=ARG] Enables sanitizer. (disabled by default) + (available options: yes, no, full) + --enable-Werror Enables -Werror in the compiler flags. (disabled + by default) + --disable-renewal Disable Ragnarok Renewal support (override + settings in src/config/renewal.h) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -2540,6 +2541,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu + ac_config_files="$ac_config_files Makefile src/common/Makefile" ac_config_files="$ac_config_files 3rdparty/mt19937ar/Makefile 3rdparty/libconfig/Makefile 3rdparty/libbacktrace/Makefile 3rdparty/libbacktrace/backtrace-supported.h" @@ -5681,6 +5683,9 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : pointers_fit_in_ints="yes" +else $as_nop + + fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext if test "$pointers_fit_in_ints" = "no" ; then @@ -5700,6 +5705,9 @@ _ACEOF if ac_fn_c_try_compile "$LINENO" then : pointers_fit_in_ints="yes (with -m32)" +else $as_nop + + fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi @@ -10488,6 +10496,103 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +case $host_os in +Darwin*) + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-deprecated-declarations" >&5 +printf %s "checking whether $CC supports -Wno-deprecated-declarations... " >&6; } + OLD_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror -Wno-deprecated-declarations" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int foo; +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + + # Recent versions of gcc don't fail if -Wno-foo is not recognized + # (unless there are also other warnings), so we also check for -Wfoo + # which always fails if not supported + CFLAGS="$OLD_CFLAGS -Werror -Wdeprecated-declarations" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int foo; +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + CFLAGS="$OLD_CFLAGS -Wno-deprecated-declarations" + # Optionally, run a test + if test "x" != "x"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wno-deprecated-declarations" >&5 +printf %s "checking whether $CC can actually use -Wno-deprecated-declarations... " >&6; } + CFLAGS="$OLD_CFLAGS -Werror -Wdeprecated-declarations" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: not needed but enabled" >&5 +printf "%s\n" "not needed but enabled" >&6; } + CFLAGS="$OLD_CFLAGS" + +else $as_nop + + CFLAGS="$OLD_CFLAGS -Werror -Wno-deprecated-declarations" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + CFLAGS="$OLD_CFLAGS -Wno-deprecated-declarations" + +else $as_nop + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + CFLAGS="$OLD_CFLAGS" + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + fi + +else $as_nop + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + CFLAGS="$OLD_CFLAGS" + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + +else $as_nop + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + CFLAGS="$OLD_CFLAGS" + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + + + ;; +esac + # Certain versions of gcc make -Wshadow completely useless by making it flood # you with unnecessary warnings # Let's check if we can really use it @@ -12608,9 +12713,17 @@ then : CFLAGS="$CFLAGS -DHAVE_EXECINFO" +else $as_nop + + + fi +else $as_nop + + + fi done diff --git a/configure.ac b/configure.ac index 03f9c468cd..c67777e959 100644 --- a/configure.ac +++ b/configure.ac @@ -20,9 +20,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -AC_INIT(Hercules) +AC_INIT +AC_CONFIG_SRCDIR([Hercules]) AC_REVISION([m4_esyscmd_s([type git >/dev/null 2>&1 && git describe --always 2>/dev/null || echo '(unknown version)'])]) -AC_PREREQ([2.69]) +AC_PREREQ([2.71]) AC_CONFIG_SRCDIR([src/common/cbasetypes.h]) AC_CONFIG_FILES([Makefile src/common/Makefile]) AC_CONFIG_FILES([3rdparty/mt19937ar/Makefile 3rdparty/libconfig/Makefile 3rdparty/libbacktrace/Makefile 3rdparty/libbacktrace/backtrace-supported.h]) @@ -34,10 +35,10 @@ AC_CONFIG_FILES([src/test/Makefile]) AC_CONFIG_FILES([tools/HPMHookGen/Makefile]) AC_CONFIG_FILES([tools/doxygen/Makefile]) -dnl AC_USE_SYSTEM_EXTENSIONS requires autoconf 2.60 or newer. Fall back to AC_GNU_SOURCE otherwise. +dnl AC_USE_SYSTEM_EXTENSIONS requires autoconf 2.60 or newer. Fall back to AC_USE_SYSTEM_EXTENSIONS otherwise. m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], [AC_USE_SYSTEM_EXTENSIONS], - [AC_GNU_SOURCE] + [AC_USE_SYSTEM_EXTENSIONS] ) AC_MSG_CHECKING([host OS]) @@ -144,10 +145,8 @@ AC_ARG_ENABLE( # AC_ARG_ENABLE( [old-cashshop-preview-patch], - AC_HELP_STRING( - [--enable-old-cashshop-preview-patch], - [Enable Nemo patch ExtendOldCashShopPreview.] - ), + AS_HELP_STRING([--enable-old-cashshop-preview-patch],[Enable Nemo patch ExtendOldCashShopPreview. + ]), [enable_old_cashshop_preview_patch=1], [enable_old_cashshop_preview_patch=0] ) @@ -672,10 +671,8 @@ AC_ARG_WITH( # Select http parser AC_ARG_WITH( [http_parser], - AC_HELP_STRING( - [--with-http_parser=ARG], - [select http parser. Allowed values: http-parser, llhttp)] - ), + AS_HELP_STRING([--with-http_parser=ARG],[select http parser. Allowed values: http-parser, llhttp) + ]), [ case $withval in http-parser* ) @@ -1247,6 +1244,12 @@ AC_CHECK_COMPILER_WNOFLAG(deprecated-non-prototype) # issue in clang-15 in libconfig AC_CHECK_COMPILER_WNOFLAG(unused-but-set-variable) +case $host_os in +Darwin*) + AC_CHECK_COMPILER_WNOFLAG(deprecated-declarations) + ;; +esac + # Certain versions of gcc make -Wshadow completely useless by making it flood # you with unnecessary warnings # Let's check if we can really use it diff --git a/tools/ci/travis.sh b/tools/ci/travis.sh index 2876b1d820..82f8321cda 100755 --- a/tools/ci/travis.sh +++ b/tools/ci/travis.sh @@ -160,10 +160,12 @@ case "$MODE" in mysql $DBUSER_ARG $DBPASS_ARG $DBHOST_ARG --execute="CREATE USER '$NEWUSER'@'$DBHOST' IDENTIFIED BY '$NEWPASS';" || true mysql $DBUSER_ARG $DBPASS_ARG $DBHOST_ARG --execute="GRANT SELECT,INSERT,UPDATE,DELETE ON $DBNAME.* TO '$NEWUSER'@'$DBHOST';" || true mysql $DBUSER_ARG $DBPASS_ARG $DBHOST_ARG --execute="ALTER USER '$NEWUSER'@'$DBHOST' IDENTIFIED BY '$NEWPASS';" || true - mysql --defaults-file=/etc/mysql/debian.cnf $DBPASS_ARG $DBHOST_ARG --execute="CREATE USER '$NEWUSER'@'$DBHOST' IDENTIFIED BY '$NEWPASS';" || true - mysql --defaults-file=/etc/mysql/debian.cnf $DBPASS_ARG $DBHOST_ARG --execute="GRANT SELECT,INSERT,UPDATE,DELETE ON $DBNAME.* TO '$NEWUSER'@'$DBHOST';" || true - mysql --defaults-file=/etc/mysql/debian.cnf $DBPASS_ARG $DBHOST_ARG --execute="ALTER USER '$NEWUSER'@'$DBHOST' IDENTIFIED BY '$NEWPASS';" || true + if [[ -n "$(uname -a | grep -i linux)" ]]; then + mysql --defaults-file=/etc/mysql/debian.cnf $DBPASS_ARG $DBHOST_ARG --execute="CREATE USER '$NEWUSER'@'$DBHOST' IDENTIFIED BY '$NEWPASS';" || true + mysql --defaults-file=/etc/mysql/debian.cnf $DBPASS_ARG $DBHOST_ARG --execute="GRANT SELECT,INSERT,UPDATE,DELETE ON $DBNAME.* TO '$NEWUSER'@'$DBHOST';" || true + mysql --defaults-file=/etc/mysql/debian.cnf $DBPASS_ARG $DBHOST_ARG --execute="ALTER USER '$NEWUSER'@'$DBHOST' IDENTIFIED BY '$NEWPASS';" || true + fi ;; build) if [[ -z "${SKIP_VALIDATE_INTERFACES}" ]]; then From 56dac51bcfb93c84749c378d50106bc31eed586c Mon Sep 17 00:00:00 2001 From: "Guilherme G. Menaldo" Date: Sat, 10 Feb 2024 11:53:32 -0300 Subject: [PATCH 2/5] Rename memmngr macros "m"/"n" params to size/number gcc-14 validates the order of parameters in calloc, so giving proper names for each of them makes easier to tell what should go in each one. it should always be (number of element, size of each element) or gcc 14 will give warnings. other macros were adjusted where size/number also applied to keep the name standard --- src/common/memmgr.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/common/memmgr.h b/src/common/memmgr.h index a732b5f114..91a94a516c 100644 --- a/src/common/memmgr.h +++ b/src/common/memmgr.h @@ -42,13 +42,13 @@ // Enable memory manager logging by default #define LOG_MEMMGR -#define aMalloc(n) (malloc_proxy((n), ALC_MARK)) -#define aCalloc(m, n) (calloc_proxy((m), (n),ALC_MARK)) -#define aFree(p) (free_proxy((p), ALC_MARK)) -#define aStrdup(p) (strdup_proxy((p),ALC_MARK)) -#define aStrndup(p,n) (strndup_proxy((p),(n),ALC_MARK)) -#define aRealloc(p,n) (iMalloc->realloc((p),(n),ALC_MARK)) -#define aReallocz(p,n) (iMalloc->reallocz((p),(n),ALC_MARK)) +#define aMalloc(size) (malloc_proxy((size), ALC_MARK)) +#define aCalloc(num, size) (calloc_proxy((num), (size), ALC_MARK)) +#define aFree(p) (free_proxy((p), ALC_MARK)) +#define aStrdup(p) (strdup_proxy((p), ALC_MARK)) +#define aStrndup(p, size) (strndup_proxy((p), (size), ALC_MARK)) +#define aRealloc(p, size) (iMalloc->realloc((p), (size), ALC_MARK)) +#define aReallocz(p, size) (iMalloc->reallocz((p), (size), ALC_MARK)) /////////////// Buffer Creation ///////////////// // Full credit for this goes to Shinomori [Ajarn] From 02ab21f97f617f7d19748666b0c1368ff51a27fc Mon Sep 17 00:00:00 2001 From: "Guilherme G. Menaldo" Date: Sat, 10 Feb 2024 12:01:12 -0300 Subject: [PATCH 3/5] Fix order of aCalloc parameters in entire src folder aCalloc should be called with (number of elements, size of each element) or gcc 14 will warn. --- src/char/int_party.c | 2 +- src/char/int_pet.c | 2 +- src/map/instance.c | 8 ++++---- src/map/map.c | 8 ++++---- src/map/mob.c | 4 ++-- src/map/npc_chat.c | 6 +++--- src/map/script.c | 8 ++++---- src/map/storage.c | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/char/int_party.c b/src/char/int_party.c index 5d806ac5dc..fab9a1a347 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -363,7 +363,7 @@ static int inter_party_sql_init(void) { //memory alloc inter_party->db = idb_alloc(DB_OPT_RELEASE_DATA); - inter_party->pt = (struct party_data*)aCalloc(sizeof(struct party_data), 1); + inter_party->pt = (struct party_data*)aCalloc(1, sizeof(struct party_data)); if (!inter_party->pt) { ShowFatalError("inter_party->sql_init: Out of Memory!\n"); exit(EXIT_FAILURE); diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 94c21ebc93..ab943abffd 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -206,7 +206,7 @@ static int inter_pet_fromsql(int pet_id, struct s_pet *p) static int inter_pet_sql_init(void) { //memory alloc - inter_pet->pt = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1); + inter_pet->pt = (struct s_pet*)aCalloc(1, sizeof(struct s_pet)); return 0; } diff --git a/src/map/instance.c b/src/map/instance.c index fd586d95f9..d76f57e033 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -259,8 +259,8 @@ static int instance_add_map(const char *name, int instance_id, bool usebasename, } size = map->list[im].bxs * map->list[im].bys * sizeof(struct block_list*); - map->list[im].block = (struct block_list**)aCalloc(size, 1); - map->list[im].block_mob = (struct block_list**)aCalloc(size, 1); + map->list[im].block = (struct block_list**)aCalloc(1, size); + map->list[im].block_mob = (struct block_list**)aCalloc(1, size); memset(map->list[im].npc, 0x00, sizeof(map->list[i].npc)); map->list[im].npc_num = 0; @@ -670,7 +670,7 @@ static void instance_check_idle(int instance_id) timer->delete(instance->list[instance_id].idle_timer, instance->destroy_timer); instance->list[instance_id].idle_timer = INVALID_TIMER; instance->list[instance_id].idle_timeout = 0; - + // Notify instance users normal instance expiration clif->instance(instance_id, INSTANCE_WND_INFO_PROGRESS_TIME, 0); } else if (instance->list[instance_id].idle_timer == INVALID_TIMER && idle) { @@ -678,7 +678,7 @@ static void instance_check_idle(int instance_id) int64 destroy_tick = timer->gettick() + instance->list[instance_id].idle_timeoutval * 1000; instance->list[instance_id].idle_timeout = now + instance->list[instance_id].idle_timeoutval; instance->list[instance_id].idle_timer = timer->add(destroy_tick, instance->destroy_timer, instance_id, 0); - + // Notify instance users it will be destroyed if no user join it again in "X" time clif->instance(instance_id, INSTANCE_WND_INFO_IDLE_TIME, 0); } diff --git a/src/map/map.c b/src/map/map.c index 2c60283949..d181fe5632 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -4031,8 +4031,8 @@ static int map_readallmaps(void) map->list[i].bys = (map->list[i].ys + BLOCK_SIZE - 1) / BLOCK_SIZE; size = map->list[i].bxs * map->list[i].bys * sizeof(struct block_list*); - map->list[i].block = (struct block_list**)aCalloc(size, 1); - map->list[i].block_mob = (struct block_list**)aCalloc(size, 1); + map->list[i].block = (struct block_list**)aCalloc(1, size); + map->list[i].block_mob = (struct block_list**)aCalloc(1, size); map->list[i].getcellp = map->sub_getcellp; map->list[i].setcell = map->sub_setcell; @@ -4585,7 +4585,7 @@ static bool inter_config_read_database_names(const char *filename, const struct /** * Looks up configuration "name" which is expect to have a final value of int, but may be specified by a string constant. - * + * * If the config is a string, it will be looked up using script->get_constant function to find the actual integer value. * * @param[in] setting The setting to read. @@ -4616,7 +4616,7 @@ static bool map_setting_lookup_const(const struct config_setting_t *setting, con /** * Looks up configuration "name" which is expect to have a final value of int, * but may be specified by a string constant or an array of bitflag constants. - * + * * If the config is a string, it will be looked up using script->get_constant function to find the actual integer value. * If the config is an array, each value will be read and added to the final bitmask. * diff --git a/src/map/mob.c b/src/map/mob.c index b9d983331a..8c53a5bee6 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -4377,7 +4377,7 @@ static bool mob_read_optdrops_optslot(struct config_setting_t *optslot, int n, i } struct optdrop_group_optslot *entry = &(mob->opt_drop_groups[group_id].optslot[n]); - entry->options = aCalloc(sizeof(struct optdrop_group_option), count); + entry->options = aCalloc(count, sizeof(struct optdrop_group_option)); int idx = 0; int i = 0; @@ -4458,7 +4458,7 @@ static bool mob_read_optdrops_db(void) int i = 0; if (its != NULL && (groups = libconfig->setting_get_elem(its, 0)) != NULL) { int count = libconfig->setting_length(groups); - mob->opt_drop_groups = aCalloc(sizeof(struct optdrop_group), count); + mob->opt_drop_groups = aCalloc(count, sizeof(struct optdrop_group)); mob->opt_drop_groups_count = count; // maximum size (used by assertions) struct config_setting_t *group = NULL; diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index 13b0e4de39..60e7113284 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -118,7 +118,7 @@ static struct pcrematch_set *lookup_pcreset(struct npc_data *nd, int setid) nullpo_retr(NULL, nd); npcParse = nd->chatdb; if (npcParse == NULL) - nd->chatdb = npcParse = (struct npc_parse *)aCalloc(sizeof(struct npc_parse), 1); + nd->chatdb = npcParse = (struct npc_parse *) aCalloc(1, sizeof(struct npc_parse)); pcreset = npcParse->active; @@ -137,7 +137,7 @@ static struct pcrematch_set *lookup_pcreset(struct npc_data *nd, int setid) } if (pcreset == NULL) { - pcreset = (struct pcrematch_set *)aCalloc(sizeof(struct pcrematch_set), 1); + pcreset = (struct pcrematch_set *) aCalloc(1, sizeof(struct pcrematch_set)); pcreset->next = npcParse->inactive; if (pcreset->next != NULL) pcreset->next->prev = pcreset; @@ -284,7 +284,7 @@ static struct pcrematch_entry *create_pcrematch_entry(struct pcrematch_set *set) struct pcrematch_entry *last; nullpo_retr(NULL, set); - e = (struct pcrematch_entry *)aCalloc(sizeof(struct pcrematch_entry), 1); + e = (struct pcrematch_entry *) aCalloc(1, sizeof(struct pcrematch_entry)); last = set->head; // Normally we would have just stuck it at the end of the list but diff --git a/src/map/script.c b/src/map/script.c index 85d77c429e..d2c911614c 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -7050,7 +7050,7 @@ static BUILDIN(callfunc) return false; } - ref = (struct reg_db *)aCalloc(sizeof(struct reg_db), 2); + ref = (struct reg_db *)aCalloc(2, sizeof(struct reg_db)); ref[0].vars = st->stack->scope.vars; if (!st->stack->scope.arrays) st->stack->scope.arrays = idb_alloc(DB_OPT_BASE); // TODO: Can this happen? when? @@ -7145,7 +7145,7 @@ static BUILDIN(callfunctionofnpc) { } // alloc a reg_db reference of the current scope for the new scope - struct reg_db *ref = (struct reg_db *)aCalloc(sizeof(struct reg_db), 2); + struct reg_db *ref = (struct reg_db *)aCalloc(2, sizeof(struct reg_db)); // scope variables (.@var) ref[0].vars = st->stack->scope.vars; ref[0].arrays = st->stack->scope.arrays; @@ -7214,7 +7214,7 @@ static BUILDIN(callsub) return false; } - ref = (struct reg_db *)aCalloc(sizeof(struct reg_db), 1); + ref = (struct reg_db *) aCalloc(1, sizeof(struct reg_db)); ref[0].vars = st->stack->scope.vars; if (!st->stack->scope.arrays) st->stack->scope.arrays = idb_alloc(DB_OPT_BASE); // TODO: Can this happen? when? @@ -7312,7 +7312,7 @@ static BUILDIN(return) // npc variable if( !data->ref ) { // npc variable without a reference set, link to current script - data->ref = (struct reg_db *)aCalloc(sizeof(struct reg_db), 1); + data->ref = (struct reg_db *) aCalloc(1, sizeof(struct reg_db)); script->add_pending_ref(st, data->ref); data->ref->vars = st->script->local.vars; if( !st->script->local.arrays ) diff --git a/src/map/storage.c b/src/map/storage.c index fb8750a36b..6542da49c8 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -457,7 +457,7 @@ static void storage_storage_quit(struct map_session_data *sd, int flag) static struct DBData create_guildstorage(union DBKey key, va_list args) { struct guild_storage *gs = NULL; - gs = (struct guild_storage *) aCalloc(sizeof(struct guild_storage), 1); + gs = (struct guild_storage *) aCalloc(1, sizeof(struct guild_storage)); gs->guild_id=key.i; return DB->ptr2data(gs); } From 7c94ef59d54d2220cf76ac1ef3e13f6d51f2e75c Mon Sep 17 00:00:00 2001 From: "Guilherme G. Menaldo" Date: Tue, 13 Feb 2024 23:36:34 -0300 Subject: [PATCH 4/5] Fix AutoSpell not always setting the new skill SC_AUTOSPELL val1 should be the AutoSpell skill level, not the selected skill learned level. This was broken during the refactor and is now fixed. Giving it the selected skill level would prevent restarting the buff mid way if the previous buff had a higher level for the target skill. e.g. a Lv10 Fire Bolt would not be replaced by a Lv5 Earth Spikes --- src/map/skill.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/map/skill.c b/src/map/skill.c index 5f23103ceb..4346a6c96c 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -17922,7 +17922,7 @@ static int skill_autospell_spell_selected(struct map_session_data *sd, uint16 sk if (max_lv > skill_lv) max_lv = skill_lv; - sc_start4(&sd->bl, &sd->bl, SC_AUTOSPELL, 100, skill_lv, skill_id, max_lv, 0, + sc_start4(&sd->bl, &sd->bl, SC_AUTOSPELL, 100, autospell_lv, skill_id, max_lv, 0, skill->get_time(SA_AUTOSPELL, skill_lv), SA_AUTOSPELL); return 0; } From 4e38e6640ee1984a15fd2aaf614e1157a6a72035 Mon Sep 17 00:00:00 2001 From: Haru Date: Fri, 1 Mar 2024 00:48:33 +0100 Subject: [PATCH 5/5] Release v2024.02 Signed-off-by: Haru --- CHANGELOG.md | 27 +++++++++++++++++++++++++++ doc/constants_pre-re.md | 2 +- doc/constants_re.md | 2 +- src/config/core.h | 2 +- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 086faf202f..7845a6ee88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,32 @@ If you are reading this in a text editor, simply ignore this section ### Removed --> +## [v2024.02] `February 2024` + +### Added + +- Added GitHub Actions CI builds on macOS (Intel and ARM). (#3281) + +### Changed + +- Renamed the arguments of the `aMalloc()`, `aCalloc()`, `aStrndup()`, `aRealloc()`, `aReallocz()` macros to make it harder to accidentally swap their order. (#3280) + +### Fixed + +- Fixed `expandinventory()` not allowing to return to the initial minimum inventory size. (#3270) +- Fixed a race condition allowing for a call to `clif->pLoadEndAck()` before the client's loadendack is received. (#3277) +- Fixed a memory leak of emblem data when guilds are unloaded or disbanded. (#3278) +- Fixed several instances of swapped arguments in `aCalloc()` calls, causing warnings in gcc-14. (#3280) +- Fixed a regression causing AutoSpell not to replace the selected skill when the new skill has lower level than the previous one. (#3282) + +### Deprecated + +### Removed + +### Other + +- Updated copyright headers for year 2024. + ## [v2023.12] `December 2023` ### Added @@ -2991,6 +3017,7 @@ Note: everything included in this release is part of PR #3198 which consists of - New versioning scheme and project changelogs/release notes (#1853) [Unreleased]: https://github.com/HerculesWS/Hercules/compare/stable...master +[v2024.02]: https://github.com/HerculesWS/Hercules/compare/v2023.12...v2024.02 [v2023.12]: https://github.com/HerculesWS/Hercules/compare/v2023.11...v2023.12 [v2023.11]: https://github.com/HerculesWS/Hercules/compare/v2023.10...v2023.11 [v2023.10]: https://github.com/HerculesWS/Hercules/compare/v2023.08...v2023.10 diff --git a/doc/constants_pre-re.md b/doc/constants_pre-re.md index b123d2f504..33de13f3c5 100644 --- a/doc/constants_pre-re.md +++ b/doc/constants_pre-re.md @@ -4874,7 +4874,7 @@ ### Server defines - `PACKETVER`: 20190530 -- `HERCULES_VERSION`: 202312000 +- `HERCULES_VERSION`: 202402000 - `MAX_LEVEL`: 175 - `MAX_STORAGE`: 600 - `MAX_GUILD_STORAGE`: 500 diff --git a/doc/constants_re.md b/doc/constants_re.md index 7d6955a918..851b01a782 100644 --- a/doc/constants_re.md +++ b/doc/constants_re.md @@ -4874,7 +4874,7 @@ ### Server defines - `PACKETVER`: 20190530 -- `HERCULES_VERSION`: 202312000 +- `HERCULES_VERSION`: 202402000 - `MAX_LEVEL`: 175 - `MAX_STORAGE`: 600 - `MAX_GUILD_STORAGE`: 500 diff --git a/src/config/core.h b/src/config/core.h index ecf143e914..e402703099 100644 --- a/src/config/core.h +++ b/src/config/core.h @@ -22,7 +22,7 @@ #define CONFIG_CORE_H /// Hercules version. From tag vYYYY.MM(+PPP) -> YYYYMMPPP -#define HERCULES_VERSION 202312000 +#define HERCULES_VERSION 202402000 /// Max number of items on @autolootid list #define AUTOLOOTITEM_SIZE 10