summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-07-12 22:53:58 +0300
committerGitHub <noreply@github.com>2016-07-12 22:53:58 +0300
commit69df5ffa970dbcafde7dbb5d360c0ea28300cb50 (patch)
treeba5165b102784eb793da8e9cd8dc35108fbeeed0
parent4b8dd1cdaadba7ae2200f114a4e11ef62454eaa1 (diff)
parent14c9f5228fec75fc4e9bc8552e3fbae16f356103 (diff)
downloadhercules-69df5ffa970dbcafde7dbb5d360c0ea28300cb50.tar.gz
hercules-69df5ffa970dbcafde7dbb5d360c0ea28300cb50.tar.bz2
hercules-69df5ffa970dbcafde7dbb5d360c0ea28300cb50.tar.xz
hercules-69df5ffa970dbcafde7dbb5d360c0ea28300cb50.zip
Merge pull request #1290 from HerculesWS/common_interfacing
Common interfacing
-rw-r--r--src/common/HPMDataCheck.h30
-rw-r--r--src/common/HPMSymbols.inc.h36
-rw-r--r--src/common/console.c38
-rw-r--r--src/common/console.h16
-rw-r--r--src/common/core.c26
-rw-r--r--src/common/des.c155
-rw-r--r--src/common/des.h45
-rw-r--r--src/common/grfio.c493
-rw-r--r--src/common/grfio.h108
-rw-r--r--src/common/md5calc.c156
-rw-r--r--src/common/md5calc.h44
-rw-r--r--src/common/mutex.c158
-rw-r--r--src/common/mutex.h168
-rw-r--r--src/common/random.c62
-rw-r--r--src/common/random.h84
-rw-r--r--src/common/spinlock.h89
-rw-r--r--src/common/thread.c250
-rw-r--r--src/common/thread.h232
-rw-r--r--src/login/lclif.c10
-rw-r--r--src/login/login.c14
-rw-r--r--src/map/battle.c2
-rw-r--r--src/map/clif.c5
-rw-r--r--src/map/homunculus.c50
-rw-r--r--src/map/map.c21
-rw-r--r--src/map/script.c4
-rw-r--r--src/map/skill.c4
-rw-r--r--src/plugins/HPMHooking.c6
-rw-r--r--src/plugins/HPMHooking/HPMHooking.Defs.inc94
-rw-r--r--src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc141
-rw-r--r--src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc39
-rw-r--r--src/plugins/HPMHooking/HPMHooking_char.Hooks.inc903
-rw-r--r--src/plugins/HPMHooking/HPMHooking_char.sources.inc5
-rw-r--r--src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc141
-rw-r--r--src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc39
-rw-r--r--src/plugins/HPMHooking/HPMHooking_login.Hooks.inc903
-rw-r--r--src/plugins/HPMHooking/HPMHooking_login.sources.inc5
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc170
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc47
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.Hooks.inc1091
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.sources.inc6
-rw-r--r--src/test/test_spinlock.c13
-rw-r--r--src/tool/mapcache.c10
-rw-r--r--tools/HPMHookGen/HPMDataCheckGen.pl2
-rwxr-xr-xtools/HPMHookGen/HPMHookGen.pl6
-rw-r--r--vcproj-11/char-server.vcxproj18
-rw-r--r--vcproj-11/char-server.vcxproj.filters12
-rw-r--r--vcproj-11/login-server.vcxproj18
-rw-r--r--vcproj-11/login-server.vcxproj.filters6
-rw-r--r--vcproj-12/char-server.vcxproj18
-rw-r--r--vcproj-12/char-server.vcxproj.filters12
-rw-r--r--vcproj-12/login-server.vcxproj18
-rw-r--r--vcproj-12/login-server.vcxproj.filters6
-rw-r--r--vcproj-14/char-server.vcxproj18
-rw-r--r--vcproj-14/char-server.vcxproj.filters12
-rw-r--r--vcproj-14/login-server.vcxproj18
-rw-r--r--vcproj-14/login-server.vcxproj.filters6
56 files changed, 5141 insertions, 942 deletions
diff --git a/src/common/HPMDataCheck.h b/src/common/HPMDataCheck.h
index 332857a90..d0e23811c 100644
--- a/src/common/HPMDataCheck.h
+++ b/src/common/HPMDataCheck.h
@@ -150,7 +150,8 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = {
#define COMMON_DB_H
#endif // COMMON_DB_H
#ifdef COMMON_DES_H
- { "BIT64", sizeof(struct BIT64), SERVER_TYPE_ALL },
+ { "des_bit64", sizeof(struct des_bit64), SERVER_TYPE_ALL },
+ { "des_interface", sizeof(struct des_interface), SERVER_TYPE_ALL },
#else
#define COMMON_DES_H
#endif // COMMON_DES_H
@@ -159,6 +160,11 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = {
#else
#define COMMON_ERS_H
#endif // COMMON_ERS_H
+ #ifdef COMMON_GRFIO_H
+ { "grfio_interface", sizeof(struct grfio_interface), SERVER_TYPE_MAP },
+ #else
+ #define COMMON_GRFIO_H
+ #endif // COMMON_GRFIO_H
#ifdef COMMON_HPMI_H
{ "HPMi_interface", sizeof(struct HPMi_interface), SERVER_TYPE_ALL },
{ "hplugin_info", sizeof(struct hplugin_info), SERVER_TYPE_ALL },
@@ -171,6 +177,11 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = {
#else
#define COMMON_MAPINDEX_H
#endif // COMMON_MAPINDEX_H
+ #ifdef COMMON_MD5CALC_H
+ { "md5_interface", sizeof(struct md5_interface), SERVER_TYPE_ALL },
+ #else
+ #define COMMON_MD5CALC_H
+ #endif // COMMON_MD5CALC_H
#ifdef COMMON_MEMMGR_H
{ "malloc_interface", sizeof(struct malloc_interface), SERVER_TYPE_ALL },
#else
@@ -210,11 +221,21 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = {
#else
#define COMMON_MMO_H
#endif // COMMON_MMO_H
+ #ifdef COMMON_MUTEX_H
+ { "mutex_interface", sizeof(struct mutex_interface), SERVER_TYPE_ALL },
+ #else
+ #define COMMON_MUTEX_H
+ #endif // COMMON_MUTEX_H
#ifdef COMMON_NULLPO_H
{ "nullpo_interface", sizeof(struct nullpo_interface), SERVER_TYPE_ALL },
#else
#define COMMON_NULLPO_H
#endif // COMMON_NULLPO_H
+ #ifdef COMMON_RANDOM_H
+ { "rnd_interface", sizeof(struct rnd_interface), SERVER_TYPE_ALL },
+ #else
+ #define COMMON_RANDOM_H
+ #endif // COMMON_RANDOM_H
#ifdef COMMON_SHOWMSG_H
{ "showmsg_interface", sizeof(struct showmsg_interface), SERVER_TYPE_ALL },
#else
@@ -230,7 +251,7 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = {
#define COMMON_SOCKET_H
#endif // COMMON_SOCKET_H
#ifdef COMMON_SPINLOCK_H
- { "SPIN_LOCK", sizeof(struct SPIN_LOCK), SERVER_TYPE_ALL },
+ { "spin_lock", sizeof(struct spin_lock), SERVER_TYPE_ALL },
#else
#define COMMON_SPINLOCK_H
#endif // COMMON_SPINLOCK_H
@@ -253,6 +274,11 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = {
#else
#define COMMON_SYSINFO_H
#endif // COMMON_SYSINFO_H
+ #ifdef COMMON_THREAD_H
+ { "thread_interface", sizeof(struct thread_interface), SERVER_TYPE_ALL },
+ #else
+ #define COMMON_THREAD_H
+ #endif // COMMON_THREAD_H
#ifdef COMMON_TIMER_H
{ "TimerData", sizeof(struct TimerData), SERVER_TYPE_ALL },
{ "timer_interface", sizeof(struct timer_interface), SERVER_TYPE_ALL },
diff --git a/src/common/HPMSymbols.inc.h b/src/common/HPMSymbols.inc.h
index 516222e8e..7ccb960de 100644
--- a/src/common/HPMSymbols.inc.h
+++ b/src/common/HPMSymbols.inc.h
@@ -68,6 +68,9 @@ struct core_interface *core;
#ifdef COMMON_DB_H /* DB */
struct db_interface *DB;
#endif // COMMON_DB_H
+#ifdef COMMON_DES_H /* des */
+struct des_interface *des;
+#endif // COMMON_DES_H
#ifdef MAP_DUEL_H /* duel */
struct duel_interface *duel;
#endif // MAP_DUEL_H
@@ -77,6 +80,9 @@ struct elemental_interface *elemental;
#ifdef CHAR_GEOIP_H /* geoip */
struct geoip_interface *geoip;
#endif // CHAR_GEOIP_H
+#ifdef COMMON_GRFIO_H /* grfio */
+struct grfio_interface *grfio;
+#endif // COMMON_GRFIO_H
#ifdef MAP_GUILD_H /* guild */
struct guild_interface *guild;
#endif // MAP_GUILD_H
@@ -167,12 +173,18 @@ struct mapit_interface *mapit;
#ifdef MAP_MAPREG_H /* mapreg */
struct mapreg_interface *mapreg;
#endif // MAP_MAPREG_H
+#ifdef COMMON_MD5CALC_H /* md5 */
+struct md5_interface *md5;
+#endif // COMMON_MD5CALC_H
#ifdef MAP_MERCENARY_H /* mercenary */
struct mercenary_interface *mercenary;
#endif // MAP_MERCENARY_H
#ifdef MAP_MOB_H /* mob */
struct mob_interface *mob;
#endif // MAP_MOB_H
+#ifdef COMMON_MUTEX_H /* mutex */
+struct mutex_interface *mutex;
+#endif // COMMON_MUTEX_H
#ifdef MAP_NPC_H /* npc_chat */
struct npc_chat_interface *npc_chat;
#endif // MAP_NPC_H
@@ -206,6 +218,9 @@ struct pincode_interface *pincode;
#ifdef MAP_QUEST_H /* quest */
struct quest_interface *quest;
#endif // MAP_QUEST_H
+#ifdef COMMON_RANDOM_H /* rnd */
+struct rnd_interface *rnd;
+#endif // COMMON_RANDOM_H
#ifdef MAP_SCRIPT_H /* script */
struct script_interface *script;
#endif // MAP_SCRIPT_H
@@ -242,6 +257,9 @@ struct sv_interface *sv;
#ifdef COMMON_SYSINFO_H /* sysinfo */
struct sysinfo_interface *sysinfo;
#endif // COMMON_SYSINFO_H
+#ifdef COMMON_THREAD_H /* thread */
+struct thread_interface *thread;
+#endif // COMMON_THREAD_H
#ifdef COMMON_TIMER_H /* timer */
struct timer_interface *timer;
#endif // COMMON_TIMER_H
@@ -300,6 +318,9 @@ if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("core", core)) return "core";
#ifdef COMMON_DB_H /* DB */
if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("DB", DB)) return "DB";
#endif // COMMON_DB_H
+#ifdef COMMON_DES_H /* des */
+if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("des", des)) return "des";
+#endif // COMMON_DES_H
#ifdef MAP_DUEL_H /* duel */
if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("duel", duel)) return "duel";
#endif // MAP_DUEL_H
@@ -309,6 +330,9 @@ if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("elemental", elemental)) retu
#ifdef CHAR_GEOIP_H /* geoip */
if ((server_type&(SERVER_TYPE_CHAR)) && !HPM_SYMBOL("geoip", geoip)) return "geoip";
#endif // CHAR_GEOIP_H
+#ifdef COMMON_GRFIO_H /* grfio */
+if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("grfio", grfio)) return "grfio";
+#endif // COMMON_GRFIO_H
#ifdef MAP_GUILD_H /* guild */
if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("guild", guild)) return "guild";
#endif // MAP_GUILD_H
@@ -399,12 +423,18 @@ if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("mapit", mapit)) return "mapi
#ifdef MAP_MAPREG_H /* mapreg */
if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("mapreg", mapreg)) return "mapreg";
#endif // MAP_MAPREG_H
+#ifdef COMMON_MD5CALC_H /* md5 */
+if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("md5", md5)) return "md5";
+#endif // COMMON_MD5CALC_H
#ifdef MAP_MERCENARY_H /* mercenary */
if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("mercenary", mercenary)) return "mercenary";
#endif // MAP_MERCENARY_H
#ifdef MAP_MOB_H /* mob */
if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("mob", mob)) return "mob";
#endif // MAP_MOB_H
+#ifdef COMMON_MUTEX_H /* mutex */
+if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("mutex", mutex)) return "mutex";
+#endif // COMMON_MUTEX_H
#ifdef MAP_NPC_H /* npc_chat */
if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("npc_chat", npc_chat)) return "npc_chat";
#endif // MAP_NPC_H
@@ -438,6 +468,9 @@ if ((server_type&(SERVER_TYPE_CHAR)) && !HPM_SYMBOL("pincode", pincode)) return
#ifdef MAP_QUEST_H /* quest */
if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("quest", quest)) return "quest";
#endif // MAP_QUEST_H
+#ifdef COMMON_RANDOM_H /* rnd */
+if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("rnd", rnd)) return "rnd";
+#endif // COMMON_RANDOM_H
#ifdef MAP_SCRIPT_H /* script */
if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("script", script)) return "script";
#endif // MAP_SCRIPT_H
@@ -474,6 +507,9 @@ if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("sv", sv)) return "sv";
#ifdef COMMON_SYSINFO_H /* sysinfo */
if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("sysinfo", sysinfo)) return "sysinfo";
#endif // COMMON_SYSINFO_H
+#ifdef COMMON_THREAD_H /* thread */
+if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("thread", thread)) return "thread";
+#endif // COMMON_THREAD_H
#ifdef COMMON_TIMER_H /* timer */
if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("timer", timer)) return "timer";
#endif // COMMON_TIMER_H
diff --git a/src/common/console.c b/src/common/console.c
index 0be33e5c3..f1b4523e2 100644
--- a/src/common/console.c
+++ b/src/common/console.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
@@ -57,6 +57,7 @@ struct console_interface console_s;
struct console_interface *console;
#ifdef CONSOLE_INPUT
struct console_input_interface console_input_s;
+struct spin_lock console_ptlock_s;
struct {
char queue[CONSOLE_PARSE_SIZE][MAX_CONSOLE_INPUT];
@@ -464,45 +465,45 @@ void *cThread_main(void *x) {
console->input->parse(input);
if( input[0] != '\0' ) {/* did we get something? */
- EnterSpinLock(&console->input->ptlock);
+ EnterSpinLock(console->input->ptlock);
if( cinput.count == CONSOLE_PARSE_SIZE ) {
- LeaveSpinLock(&console->input->ptlock);
+ LeaveSpinLock(console->input->ptlock);
continue;/* drop */
}
safestrncpy(cinput.queue[cinput.count++],input,MAX_CONSOLE_INPUT);
- LeaveSpinLock(&console->input->ptlock);
+ LeaveSpinLock(console->input->ptlock);
}
}
- ramutex_lock( console->input->ptmutex );
- racond_wait( console->input->ptcond, console->input->ptmutex, -1 );
- ramutex_unlock( console->input->ptmutex );
+ mutex->lock(console->input->ptmutex);
+ mutex->cond_wait(console->input->ptcond, console->input->ptmutex, -1);
+ mutex->unlock(console->input->ptmutex);
}
return NULL;
}
int console_parse_timer(int tid, int64 tick, int id, intptr_t data) {
int i;
- EnterSpinLock(&console->input->ptlock);
+ EnterSpinLock(console->input->ptlock);
for(i = 0; i < cinput.count; i++) {
console->input->parse_sub(cinput.queue[i]);
}
cinput.count = 0;
- LeaveSpinLock(&console->input->ptlock);
- racond_signal(console->input->ptcond);
+ LeaveSpinLock(console->input->ptlock);
+ mutex->cond_signal(console->input->ptcond);
return 0;
}
void console_parse_final(void) {
if( console->input->ptstate ) {
InterlockedDecrement(&console->input->ptstate);
- racond_signal(console->input->ptcond);
+ mutex->cond_signal(console->input->ptcond);
/* wait for thread to close */
- rathread_wait(console->input->pthread, NULL);
+ thread->wait(console->input->pthread, NULL);
- racond_destroy(console->input->ptcond);
- ramutex_destroy(console->input->ptmutex);
+ mutex->cond_destroy(console->input->ptcond);
+ mutex->destroy(console->input->ptmutex);
}
}
void console_parse_init(void) {
@@ -510,12 +511,12 @@ void console_parse_init(void) {
console->input->ptstate = 1;
- InitializeSpinLock(&console->input->ptlock);
+ InitializeSpinLock(console->input->ptlock);
- console->input->ptmutex = ramutex_create();
- console->input->ptcond = racond_create();
+ console->input->ptmutex = mutex->create();
+ console->input->ptcond = mutex->cond_create();
- if( (console->input->pthread = rathread_create(console->input->pthread_main, NULL)) == NULL ){
+ if( (console->input->pthread = thread->create(console->input->pthread_main, NULL)) == NULL ){
ShowFatalError("console_parse_init: failed to spawn console_parse thread.\n");
exit(EXIT_FAILURE);
}
@@ -563,6 +564,7 @@ void console_defaults(void)
console->display_gplnotice = display_gplnotice;
#ifdef CONSOLE_INPUT
console->input = &console_input_s;
+ console->input->ptlock = &console_ptlock_s;
console->input->parse_init = console_parse_init;
console->input->parse_final = console_parse_final;
console->input->parse_timer = console_parse_timer;
diff --git a/src/common/console.h b/src/common/console.h
index 57c750a7d..dd3a9cf2e 100644
--- a/src/common/console.h
+++ b/src/common/console.h
@@ -22,12 +22,14 @@
#include "common/hercules.h"
#include "common/db.h"
-#include "common/mutex.h"
#include "common/spinlock.h"
-#include "common/thread.h"
/* Forward Declarations */
struct Sql; // common/sql.h
+struct cond_data;
+struct mutex_data;
+struct spin_lock;
+struct thread_handle;
/**
* Queue Max
@@ -71,11 +73,11 @@ struct CParseEntry {
struct console_input_interface {
#ifdef CONSOLE_INPUT
/* vars */
- SPIN_LOCK ptlock;/* parse thread lock */
- rAthread *pthread;/* parse thread */
- volatile int32 ptstate;/* parse thread state */
- ramutex *ptmutex;/* parse thread mutex */
- racond *ptcond;/* parse thread cond */
+ struct spin_lock *ptlock; ///< parse thread lock.
+ struct thread_handle *pthread; ///< parse thread.
+ volatile int32 ptstate; ///< parse thread state.
+ struct mutex_data *ptmutex; ///< parse thread mutex.
+ struct cond_data *ptcond; ///< parse thread conditional variable.
/* */
VECTOR_DECL(struct CParseEntry *) command_list;
VECTOR_DECL(struct CParseEntry *) commands;
diff --git a/src/common/core.c b/src/common/core.c
index e6b522926..63123dfea 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
@@ -26,23 +26,27 @@
#include "common/cbasetypes.h"
#include "common/console.h"
#include "common/db.h"
+#include "common/des.h"
+#include "common/grfio.h"
#include "common/memmgr.h"
#include "common/mmo.h"
-#include "common/random.h"
+#include "common/nullpo.h"
#include "common/showmsg.h"
#include "common/strlib.h"
#include "common/sysinfo.h"
-#include "common/nullpo.h"
+#include "common/timer.h"
#include "common/utils.h"
#ifndef MINICORE
# include "common/HPM.h"
# include "common/conf.h"
# include "common/ers.h"
+# include "common/md5calc.h"
+# include "common/mutex.h"
+# include "common/random.h"
# include "common/socket.h"
# include "common/sql.h"
# include "common/thread.h"
-# include "common/timer.h"
#endif
#ifndef _WIN32
@@ -253,12 +257,18 @@ void core_defaults(void) {
malloc_defaults();
showmsg_defaults();
cmdline_defaults();
+ des_defaults();
+ grfio_defaults(); // Note: grfio is lazily loaded. grfio->init() and grfio->final() are not automatically called.
#ifndef MINICORE
+ mutex_defaults();
libconfig_defaults();
sql_defaults();
timer_defaults();
db_defaults();
socket_defaults();
+ rnd_defaults();
+ md5_defaults();
+ thread_defaults();
#endif
}
/**
@@ -498,7 +508,7 @@ int main (int argc, char **argv) {
set_server_type();
Sql_Init();
- rathread_init();
+ thread->init();
DB->init();
signals_init();
@@ -509,8 +519,7 @@ int main (int argc, char **argv) {
timer->init();
/* timer first */
- rnd_init();
- srand((unsigned int)timer->gettick());
+ rnd->init();
console->init();
@@ -535,8 +544,9 @@ int main (int argc, char **argv) {
timer->final();
sockt->final();
DB->final();
- rathread_final();
+ thread->final();
ers_final();
+ rnd->final();
#endif
cmdline->final();
//sysinfo->final(); Called by iMalloc->final()
diff --git a/src/common/des.c b/src/common/des.c
index ce64309f3..c680610e9 100644
--- a/src/common/des.c
+++ b/src/common/des.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
@@ -24,23 +24,23 @@
#include "common/cbasetypes.h"
-/// DES (Data Encryption Standard) algorithm, modified version.
-/// @see http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=5099.
-/// @see http://en.wikipedia.org/wiki/Data_Encryption_Standard
-/// @see http://en.wikipedia.org/wiki/DES_supplementary_material
+/** @file
+ * Implementation of the des interface.
+ */
+struct des_interface des_s;
+struct des_interface *des;
/// Bitmask for accessing individual bits of a byte.
static const uint8_t mask[8] = {
0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
};
-
-/// Initial permutation (IP).
-static void IP(BIT64* src)
+/**
+ * Initial permutation (IP).
+ */
+static void des_IP(struct des_bit64 *src)
{
- BIT64 tmp = {{0}};
-
static const uint8_t ip_table[64] = {
58, 50, 42, 34, 26, 18, 10, 2,
60, 52, 44, 36, 28, 20, 12, 4,
@@ -51,24 +51,23 @@ static void IP(BIT64* src)
61, 53, 45, 37, 29, 21, 13, 5,
63, 55, 47, 39, 31, 23, 15, 7,
};
+ struct des_bit64 tmp = {{0}};
+ int i;
- size_t i;
- for( i = 0; i < ARRAYLENGTH(ip_table); ++i )
- {
+ for(i = 0; i < ARRAYLENGTH(ip_table); ++i) {
uint8_t j = ip_table[i] - 1;
- if( src->b[(j >> 3) & 7] & mask[j & 7] )
- tmp .b[(i >> 3) & 7] |= mask[i & 7];
+ if (src->b[(j >> 3) & 7] & mask[j & 7])
+ tmp.b[(i >> 3) & 7] |= mask[i & 7];
}
*src = tmp;
}
-
-/// Final permutation (IP^-1).
-static void FP(BIT64* src)
+/**
+ * Final permutation (IP^-1).
+ */
+static void des_FP(struct des_bit64 *src)
{
- BIT64 tmp = {{0}};
-
static const uint8_t fp_table[64] = {
40, 8, 48, 16, 56, 24, 64, 32,
39, 7, 47, 15, 55, 23, 63, 31,
@@ -79,24 +78,26 @@ static void FP(BIT64* src)
34, 2, 42, 10, 50, 18, 58, 26,
33, 1, 41, 9, 49, 17, 57, 25,
};
+ struct des_bit64 tmp = {{0}};
+ int i;
- size_t i;
- for( i = 0; i < ARRAYLENGTH(fp_table); ++i )
- {
+ for (i = 0; i < ARRAYLENGTH(fp_table); ++i) {
uint8_t j = fp_table[i] - 1;
- if( src->b[(j >> 3) & 7] & mask[j & 7] )
- tmp .b[(i >> 3) & 7] |= mask[i & 7];
+ if (src->b[(j >> 3) & 7] & mask[j & 7])
+ tmp.b[(i >> 3) & 7] |= mask[i & 7];
}
*src = tmp;
}
-
-/// Expansion (E).
-/// Expands upper four 8-bits (32b) into eight 6-bits (48b).
-static void E(BIT64* src)
+/**
+ * Expansion (E).
+ *
+ * Expands upper four 8-bits (32b) into eight 6-bits (48b).
+ */
+static void des_E(struct des_bit64 *src)
{
- BIT64 tmp = {{0}};
+ struct des_bit64 tmp = {{0}};
#if 0
// original
@@ -110,13 +111,12 @@ static void E(BIT64* src)
24, 25, 26, 27, 28, 29,
28, 29, 30, 31, 32, 1,
};
+ int i;
- size_t i;
- for( i = 0; i < ARRAYLENGTH(expand_table); ++i )
- {
+ for (i = 0; i < ARRAYLENGTH(expand_table); ++i) {
uint8_t j = expand_table[i] - 1;
- if( src->b[j / 8 + 4] & mask[j % 8] )
- tmp .b[i / 6 + 0] |= mask[i % 6];
+ if (src->b[j / 8 + 4] & mask[j % 8])
+ tmp.b[i / 6 + 0] |= mask[i % 6];
}
#endif
// optimized
@@ -132,12 +132,11 @@ static void E(BIT64* src)
*src = tmp;
}
-
-/// Transposition (P-BOX).
-static void TP(BIT64* src)
+/**
+ * Transposition (P-BOX).
+ */
+static void des_TP(struct des_bit64 *src)
{
- BIT64 tmp = {{0}};
-
static const uint8_t tp_table[32] = {
16, 7, 20, 21,
29, 12, 28, 17,
@@ -148,25 +147,27 @@ static void TP(BIT64* src)
19, 13, 30, 6,
22, 11, 4, 25,
};
+ struct des_bit64 tmp = {{0}};
+ int i;
- size_t i;
- for( i = 0; i < ARRAYLENGTH(tp_table); ++i )
- {
+ for (i = 0; i < ARRAYLENGTH(tp_table); ++i) {
uint8_t j = tp_table[i] - 1;
- if( src->b[(j >> 3) + 0] & mask[j & 7] )
- tmp .b[(i >> 3) + 4] |= mask[i & 7];
+ if (src->b[(j >> 3) + 0] & mask[j & 7])
+ tmp.b[(i >> 3) + 4] |= mask[i & 7];
}
*src = tmp;
}
-/// Substitution boxes (S-boxes).
-/// NOTE: This implementation was optimized to process two nibbles in one step (twice as fast).
-static void SBOX(BIT64* src)
+/**
+ * Substitution boxes (S-boxes).
+ *
+ * This implementation was optimized to process two nibbles in one step (twice
+ * as fast).
+ */
+static void des_SBOX(struct des_bit64 *src)
{
- BIT64 tmp = {{0}};
-
static const uint8_t s_table[4][64] = {
{
0xef, 0x03, 0x41, 0xfd, 0xd8, 0x74, 0x1e, 0x47, 0x26, 0xef, 0xfb, 0x22, 0xb3, 0xd8, 0x84, 0x1e,
@@ -190,10 +191,10 @@ static void SBOX(BIT64* src)
0xa0, 0x9f, 0xf6, 0x5c, 0x6a, 0x09, 0x8d, 0xf0, 0x0f, 0xe3, 0x53, 0x25, 0x95, 0x36, 0x28, 0xcb,
}
};
+ struct des_bit64 tmp = {{0}};
+ int i;
- size_t i;
- for( i = 0; i < ARRAYLENGTH(s_table); ++i )
- {
+ for (i = 0; i < ARRAYLENGTH(s_table); ++i) {
tmp.b[i] = (s_table[i][src->b[i*2+0]] & 0xf0)
| (s_table[i][src->b[i*2+1]] & 0x0f);
}
@@ -201,15 +202,17 @@ static void SBOX(BIT64* src)
*src = tmp;
}
-
-/// DES round function.
-/// XORs src[0..3] with TP(SBOX(E(src[4..7]))).
-static void RoundFunction(BIT64* src)
+/**
+ * DES round function.
+ *
+ * XORs src[0..3] with TP(SBOX(E(src[4..7]))).
+ */
+static void des_RoundFunction(struct des_bit64 *src)
{
- BIT64 tmp = *src;
- E(&tmp);
- SBOX(&tmp);
- TP(&tmp);
+ struct des_bit64 tmp = *src;
+ des_E(&tmp);
+ des_SBOX(&tmp);
+ des_TP(&tmp);
src->b[0] ^= tmp.b[4];
src->b[1] ^= tmp.b[5];
@@ -217,20 +220,30 @@ static void RoundFunction(BIT64* src)
src->b[3] ^= tmp.b[7];
}
-
-void des_decrypt_block(BIT64* block)
+/// @copydoc des_interface::decrypt_block()
+void des_decrypt_block(struct des_bit64 *block)
{
- IP(block);
- RoundFunction(block);
- FP(block);
+ des_IP(block);
+ des_RoundFunction(block);
+ des_FP(block);
}
-
-void des_decrypt(unsigned char* data, size_t size)
+/// @copydoc des_interface::decrypt()
+void des_decrypt(unsigned char *data, size_t size)
{
- BIT64* p = (BIT64*)data;
+ struct des_bit64 *p = (struct des_bit64 *)data;
size_t i;
- for( i = 0; i*8 < size; i += 8 )
- des_decrypt_block(p);
+ for (i = 0; i*8 < size; i += 8)
+ des->decrypt_block(p);
+}
+
+/**
+ * Interface base initialization.
+ */
+void des_defaults(void)
+{
+ des = &des_s;
+ des->decrypt = des_decrypt;
+ des->decrypt_block = des_decrypt_block;
}
diff --git a/src/common/des.h b/src/common/des.h
index d62b5cc49..9924a044b 100644
--- a/src/common/des.h
+++ b/src/common/des.h
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
@@ -21,14 +21,49 @@
#ifndef COMMON_DES_H
#define COMMON_DES_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
+
+/**
+ * @file
+ *
+ * DES (Data Encryption Standard) algorithm, modified version.
+ *
+ * @see http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=5099
+ * @see http://en.wikipedia.org/wiki/Data_Encryption_Standard
+ * @see http://en.wikipedia.org/wiki/DES_supplementary_material
+ */
+
+/* Struct definitions */
/// One 64-bit block.
-typedef struct BIT64 { uint8_t b[8]; } BIT64;
+struct des_bit64 {
+ uint8_t b[8];
+};
+
+/* Interface */
+
+/// The des interface.
+struct des_interface {
+ /**
+ * Decrypts a block.
+ *
+ * @param[in,out] block The block to decrypt (in-place).
+ */
+ void (*decrypt_block) (struct des_bit64 *block);
+
+ /**
+ * Decrypts a buffer.
+ *
+ * @param [in,out] data The buffer to decrypt (in-place).
+ * @param [in] size The size of the data.
+ */
+ void (*decrypt) (unsigned char *data, size_t size);
+};
#ifdef HERCULES_CORE
-void des_decrypt_block(BIT64* block);
-void des_decrypt(unsigned char* data, size_t size);
+void des_defaults(void);
#endif // HERCULES_CORE
+HPShared struct des_interface *des; ///< Pointer to the des interface implementation.
+
#endif // COMMON_DES_H
diff --git a/src/common/grfio.c b/src/common/grfio.c
index c6e47d357..0a9708f17 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
@@ -35,10 +35,12 @@
#include <sys/stat.h>
#include <zlib.h>
-//----------------------------
-// file entry table struct
-//----------------------------
-typedef struct FILELIST {
+/** @file
+ * Implementation of the GRF I/O interface.
+ */
+
+/// File entry table struct.
+struct grf_filelist {
int srclen; ///< compressed size
int srclen_aligned;
int declen; ///< original size
@@ -48,11 +50,13 @@ typedef struct FILELIST {
char fn[128-4*5]; ///< file name
char *fnd; ///< if the file was cloned, contains name of original file
int8 gentry; ///< read grf file select
-} FILELIST;
+};
-#define FILELIST_TYPE_FILE 0x01 // entry is a file
-#define FILELIST_TYPE_ENCRYPT_MIXED 0x02 // encryption mode 0 (header DES + periodic DES/shuffle)
-#define FILELIST_TYPE_ENCRYPT_HEADER 0x04 // encryption mode 1 (header DES only)
+enum grf_filelist_type {
+ FILELIST_TYPE_FILE = 0x01, ///< entry is a file
+ FILELIST_TYPE_ENCRYPT_MIXED = 0x02, ///< encryption mode 0 (header DES + periodic DES/shuffle)
+ FILELIST_TYPE_ENCRYPT_HEADER = 0x04, ///< encryption mode 1 (header DES only)
+};
//gentry ... > 0 : data read from a grf file (gentry_table[gentry-1])
//gentry ... 0 : data read from a local file (data directory)
@@ -64,7 +68,7 @@ typedef struct FILELIST {
//#define GRFIO_LOCAL
// stores info about every loaded file
-FILELIST* filelist = NULL;
+struct grf_filelist *filelist = NULL;
int filelist_entrys = 0;
int filelist_maxentry = 0;
@@ -76,24 +80,30 @@ int gentry_maxentry = 0;
// the path to the data directory
char data_dir[1024] = "";
+struct grfio_interface grfio_s;
+struct grfio_interface *grfio;
+
// little endian char array to uint conversion
-static unsigned int getlong(unsigned char* p)
+static unsigned int getlong(unsigned char *p)
{
return (p[0] << 0 | p[1] << 8 | p[2] << 16 | p[3] << 24);
}
-static void NibbleSwap(unsigned char* src, int len)
+static void NibbleSwap(unsigned char *src, int len)
{
- while( len > 0 )
- {
+ while (len > 0) {
*src = (*src >> 4) | (*src << 4);
++src;
--len;
}
}
-/// Substitutes some specific values for others, leaves rest intact. Obfuscation.
-/// NOTE: Operation is symmetric (calling it twice gives back the original input).
+/**
+ * (De)-obfuscates data.
+ *
+ * Substitutes some specific values for others, leaves rest intact.
+ * NOTE: Operation is symmetric (calling it twice gives back the original input).
+ */
static uint8_t grf_substitution(uint8_t in)
{
uint8_t out;
@@ -121,9 +131,9 @@ static uint8_t grf_substitution(uint8_t in)
}
#if 0 /* this is not used anywhere, is it ok to delete? */
-static void grf_shuffle_enc(BIT64* src)
+static void grf_shuffle_enc(struct des_bit64 *src)
{
- BIT64 out;
+ struct des_bit64 out;
out.b[0] = src->b[3];
out.b[1] = src->b[4];
@@ -138,9 +148,9 @@ static void grf_shuffle_enc(BIT64* src)
}
#endif // 0
-static void grf_shuffle_dec(BIT64* src)
+static void grf_shuffle_dec(struct des_bit64 *src)
{
- BIT64 out;
+ struct des_bit64 out;
out.b[0] = src->b[3];
out.b[1] = src->b[4];
@@ -154,29 +164,42 @@ static void grf_shuffle_dec(BIT64* src)
*src = out;
}
-static void grf_decode_header(unsigned char* buf, size_t len)
+/**
+ * Decodes header-encrypted grf data.
+ *
+ * @param[in,out] buf Data to decode (in-place).
+ * @param[in] len Length of the data.
+ */
+static void grf_decode_header(unsigned char *buf, size_t len)
{
- BIT64* p = (BIT64*)buf;
- size_t nblocks = len / sizeof(BIT64);
+ struct des_bit64 *p = (struct des_bit64 *)buf;
+ size_t nblocks = len / sizeof(struct des_bit64);
size_t i;
// first 20 blocks are all des-encrypted
- for( i = 0; i < 20 && i < nblocks; ++i )
- des_decrypt_block(&p[i]);
+ for (i = 0; i < 20 && i < nblocks; ++i)
+ des->decrypt_block(&p[i]);
// the rest is plaintext, done.
}
-static void grf_decode_full(unsigned char* buf, size_t len, int cycle)
+/**
+ * Decodes fully encrypted grf data
+ *
+ * @param[in,out] buf Data to decode (in-place).
+ * @param[in] len Length of the data.
+ * @param[in] cycle The current decoding cycle.
+ */
+static void grf_decode_full(unsigned char *buf, size_t len, int cycle)
{
- BIT64* p = (BIT64*)buf;
- size_t nblocks = len / sizeof(BIT64);
+ struct des_bit64 *p = (struct des_bit64 *)buf;
+ size_t nblocks = len / sizeof(struct des_bit64);
int dcycle, scycle;
size_t i, j;
// first 20 blocks are all des-encrypted
- for( i = 0; i < 20 && i < nblocks; ++i )
- des_decrypt_block(&p[i]);
+ for (i = 0; i < 20 && i < nblocks; ++i)
+ des->decrypt_block(&p[i]);
// after that only one of every 'dcycle' blocks is des-encrypted
dcycle = cycle;
@@ -186,17 +209,16 @@ static void grf_decode_full(unsigned char* buf, size_t len, int cycle)
// so decrypt/de-shuffle periodically
j = (size_t)-1; // 0, adjusted to fit the ++j step
- for( i = 20; i < nblocks; ++i )
- {
- if( i % dcycle == 0 )
- {// decrypt block
- des_decrypt_block(&p[i]);
+ for (i = 20; i < nblocks; ++i) {
+ if (i % dcycle == 0) {
+ // decrypt block
+ des->decrypt_block(&p[i]);
continue;
}
++j;
- if( j % scycle == 0 && j != 0 )
- {// de-shuffle block
+ if (j % scycle == 0 && j != 0) {
+ // de-shuffle block
grf_shuffle_dec(&p[i]);
continue;
}
@@ -205,22 +227,25 @@ static void grf_decode_full(unsigned char* buf, size_t len, int cycle)
}
}
-/// Decodes grf data.
-/// @param buf data to decode (in-place)
-/// @param len length of the data
-/// @param entry_type flags associated with the data
-/// @param entry_len true (unaligned) length of the data
-static void grf_decode(unsigned char* buf, size_t len, char entry_type, int entry_len)
+/**
+ * Decodes grf data.
+ *
+ * @param[in,out] buf Data to decode (in-place).
+ * @param[in] len Length of the data
+ * @param[in] entry_type Flags associated with the data.
+ * @param[in] entry_len True (unaligned) length of the data.
+ */
+static void grf_decode(unsigned char *buf, size_t len, char entry_type, int entry_len)
{
- if( entry_type & FILELIST_TYPE_ENCRYPT_MIXED )
- {// fully encrypted
+ if (entry_type & FILELIST_TYPE_ENCRYPT_MIXED) {
+ // fully encrypted
int digits;
int cycle;
int i;
// compute number of digits of the entry length
digits = 1;
- for( i = 10; i <= entry_len; i *= 10 )
+ for (i = 10; i <= entry_len; i *= 10)
++digits;
// choose size of gap between two encrypted blocks
@@ -232,51 +257,47 @@ static void grf_decode(unsigned char* buf, size_t len, char entry_type, int entr
: digits + 15;
grf_decode_full(buf, len, cycle);
- }
- else
- if( entry_type & FILELIST_TYPE_ENCRYPT_HEADER )
- {// header encrypted
+ } else if (entry_type & FILELIST_TYPE_ENCRYPT_HEADER) {
+ // header encrypted
grf_decode_header(buf, len);
}
- else
- {// plaintext
- ;
- }
+ /* else plaintext */
}
-/******************************************************
- *** Zlib Subroutines ***
- ******************************************************/
+/* Zlib Subroutines */
-/// zlib crc32
-unsigned long grfio_crc32(const unsigned char* buf, unsigned int len)
+/// @copydoc grfio_interface::crc32()
+unsigned long grfio_crc32(const unsigned char *buf, unsigned int len)
{
return crc32(crc32(0L, Z_NULL, 0), buf, len);
}
-/// zlib uncompress
-int decode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen)
+/// @copydoc grfio_interface::decode_zip
+int grfio_decode_zip(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len)
{
- return uncompress((Bytef*)dest, destLen, (const Bytef*)source, sourceLen);
+ return uncompress(dest, dest_len, source, source_len);
}
-/// zlib compress
-int encode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen) {
- if( *destLen == 0 ) /* [Ind/Hercules] */
- *destLen = compressBound(sourceLen);
- if( dest == NULL ) { /* [Ind/Hercules] */
- CREATE(dest, unsigned char, *destLen);
+/// @copydoc grfio_interface::encode_zip
+int grfio_encode_zip(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len)
+{
+ if (*dest_len == 0) /* [Ind/Hercules] */
+ *dest_len = compressBound(source_len);
+ if (dest == NULL) {
+ /* [Ind/Hercules] */
+ CREATE(dest, unsigned char, *dest_len);
}
- return compress((Bytef*)dest, destLen, (const Bytef*)source, sourceLen);
+ return compress(dest, dest_len, source, source_len);
}
-/***********************************************************
- *** File List Subroutines ***
- ***********************************************************/
-// file list hash table
+/* File List Subroutines */
+
+/// File list hash table
int filelist_hash[256];
-// initializes the table that holds the first elements of all hash chains
+/**
+ * Initializes the table that holds the first elements of all hash chains
+ */
static void hashinit(void)
{
int i;
@@ -284,26 +305,37 @@ static void hashinit(void)
filelist_hash[i] = -1;
}
-// hashes a filename string into a number from {0..255}
-static int filehash(const char* fname)
+/**
+ * Hashes a filename string into a number from {0..255}
+ *
+ * @param fname The filename to hash.
+ * @return The hash.
+ */
+static int grf_filehash(const char *fname)
{
- unsigned int hash = 0;
- while(*fname) {
+ uint32 hash = 0;
+ while (*fname != '\0') {
hash = (hash<<1) + (hash>>7)*9 + TOLOWER(*fname);
fname++;
}
return hash & 255;
}
-// finds a FILELIST entry with the specified file name
-static FILELIST* filelist_find(const char* fname)
+/**
+ * Finds a grf_filelist entry with the specified file name
+ *
+ * @param fname The file to find.
+ * @return The file entry.
+ * @retval NULL if the file wasn't found.
+ */
+static struct grf_filelist *grfio_filelist_find(const char *fname)
{
int hash, index;
- if (!filelist)
+ if (filelist == NULL)
return NULL;
- hash = filelist_hash[filehash(fname)];
+ hash = filelist_hash[grf_filehash(fname)];
for (index = hash; index != -1; index = filelist[index].next)
if(!strcmpi(filelist[index].fn, fname))
break;
@@ -311,16 +343,23 @@ static FILELIST* filelist_find(const char* fname)
return (index >= 0) ? &filelist[index] : NULL;
}
-// returns the original file name
-char* grfio_find_file(const char* fname)
+/// @copydoc grfio_interface::find_file()
+const char *grfio_find_file(const char *fname)
{
- FILELIST *flist = filelist_find(fname);
- if (!flist) return NULL;
+ struct grf_filelist *flist = grfio_filelist_find(fname);
+ if (flist == NULL)
+ return NULL;
return (!flist->fnd ? flist->fn : flist->fnd);
}
-// adds a FILELIST entry into the list of loaded files
-static FILELIST* filelist_add(FILELIST* entry) {
+/**
+ * Adds a grf_filelist entry into the list of loaded files.
+ *
+ * @param entry The entry to add.
+ * @return A pointer to the added entry.
+ */
+static struct grf_filelist *grfio_filelist_add(struct grf_filelist *entry)
+{
int hash;
nullpo_ret(entry);
#ifdef __clang_analyzer__
@@ -331,16 +370,16 @@ static FILELIST* filelist_add(FILELIST* entry) {
#define FILELIST_ADDS 1024 // number increment of file lists `
if (filelist_entrys >= filelist_maxentry) {
- filelist = (FILELIST *)aRealloc(filelist, (filelist_maxentry + FILELIST_ADDS) * sizeof(FILELIST));
- memset(filelist + filelist_maxentry, '\0', FILELIST_ADDS * sizeof(FILELIST));
+ filelist = aRealloc(filelist, (filelist_maxentry + FILELIST_ADDS) * sizeof(struct grf_filelist));
+ memset(filelist + filelist_maxentry, '\0', FILELIST_ADDS * sizeof(struct grf_filelist));
filelist_maxentry += FILELIST_ADDS;
}
#undef FILELIST_ADDS
- memcpy(&filelist[filelist_entrys], entry, sizeof(FILELIST));
+ memcpy(&filelist[filelist_entrys], entry, sizeof(struct grf_filelist));
- hash = filehash(entry->fn);
+ hash = grf_filehash(entry->fn);
filelist[filelist_entrys].next = filelist_hash[hash];
filelist_hash[hash] = filelist_entrys;
@@ -349,63 +388,69 @@ static FILELIST* filelist_add(FILELIST* entry) {
return &filelist[filelist_entrys - 1];
}
-// adds a new FILELIST entry or overwrites an existing one
-static FILELIST* filelist_modify(FILELIST* entry)
+/**
+ * Adds a new grf_filelist entry or overwrites an existing one.
+ *
+ * @param entry The entry to add.
+ * @return A pointer to the added entry.
+ */
+static struct grf_filelist *grfio_filelist_modify(struct grf_filelist *entry)
{
- FILELIST* fentry = filelist_find(entry->fn);
+ struct grf_filelist *fentry = grfio_filelist_find(entry->fn);
if (fentry != NULL) {
int tmp = fentry->next;
- memcpy(fentry, entry, sizeof(FILELIST));
+ memcpy(fentry, entry, sizeof(struct grf_filelist));
fentry->next = tmp;
} else {
- fentry = filelist_add(entry);
+ fentry = grfio_filelist_add(entry);
}
return fentry;
}
-// shrinks the file list array if too long
-static void filelist_compact(void)
+/// Shrinks the file list array if too long.
+static void grfio_filelist_compact(void)
{
if (filelist == NULL)
return;
if (filelist_entrys < filelist_maxentry) {
- filelist = (FILELIST *)aRealloc(filelist, filelist_entrys * sizeof(FILELIST));
+ filelist = aRealloc(filelist, filelist_entrys * sizeof(struct grf_filelist));
filelist_maxentry = filelist_entrys;
}
}
-/***********************************************************
- *** Grfio Subroutines ***
- ***********************************************************/
+/* GRF I/O Subroutines */
-/// Combines are resource path with the data folder location to create local resource path.
-static void grfio_localpath_create(char* buffer, size_t size, const char* filename)
+/**
+ * Combines a resource path with the data folder location to create local
+ * resource path.
+ *
+ * @param[out] buffer The output buffer.
+ * @param[in] size The size of the output buffer.
+ * @param[in] filename Resource path.
+ */
+static void grfio_localpath_create(char *buffer, size_t size, const char *filename)
{
- unsigned int i;
+ int i;
size_t len;
len = strlen(data_dir);
- if( data_dir[0] == '\0' || data_dir[len-1] == '/' || data_dir[len-1] == '\\' )
- {
+ if (data_dir[0] == '\0' || data_dir[len-1] == '/' || data_dir[len-1] == '\\')
safesnprintf(buffer, size, "%s%s", data_dir, filename);
- }
else
- {
safesnprintf(buffer, size, "%s/%s", data_dir, filename);
- }
// normalize path
- for( i = 0; buffer[i] != '\0'; ++i )
- if( buffer[i] == '\\' )
+ for (i = 0; buffer[i] != '\0'; ++i)
+ if (buffer[i] == '\\')
buffer[i] = '/';
}
-/// Reads a file into a newly allocated buffer (from grf or data directory).
+/// @copydoc grfio_interface::reads()
void *grfio_reads(const char *fname, int *size)
{
- FILELIST* entry = filelist_find(fname);
+ struct grf_filelist *entry = grfio_filelist_find(fname);
if (entry == NULL || entry->gentry <= 0) {
// LocalFileCheck
char lfname[256];
@@ -424,7 +469,7 @@ void *grfio_reads(const char *fname, int *size)
return NULL;
}
fseek(in,0,SEEK_SET);
- buf = (unsigned char *)aMalloc(declen+1); // +1 for resnametable zero-termination
+ buf = aMalloc(declen+1); // +1 for resnametable zero-termination
buf[declen] = '\0';
if (fread(buf, 1, declen, in) != (size_t)declen) {
ShowError("An error occurred in fread grfio_reads, fname=%s \n",fname);
@@ -454,7 +499,7 @@ void *grfio_reads(const char *fname, int *size)
if (in != NULL) {
int fsize = entry->srclen_aligned;
- unsigned char *buf = (unsigned char *)aMalloc(fsize);
+ unsigned char *buf = aMalloc(fsize);
unsigned char *buf2 = NULL;
if (fseek(in, entry->srcpos, SEEK_SET) != 0
|| fread(buf, 1, fsize, in) != (size_t)fsize) {
@@ -465,14 +510,14 @@ void *grfio_reads(const char *fname, int *size)
}
fclose(in);
- buf2 = (unsigned char *)aMalloc(entry->declen+1); // +1 for resnametable zero-termination
+ buf2 = aMalloc(entry->declen+1); // +1 for resnametable zero-termination
buf2[entry->declen] = '\0';
if (entry->type & FILELIST_TYPE_FILE) {
// file
uLongf len;
grf_decode(buf, fsize, entry->type, entry->srclen);
len = entry->declen;
- decode_zip(buf2, &len, buf, entry->srclen);
+ grfio->decode_zip(buf2, &len, buf, entry->srclen);
if (len != (uLong)entry->declen) {
ShowError("decode_zip size mismatch err: %d != %d\n", (int)len, entry->declen);
aFree(buf);
@@ -498,35 +543,51 @@ void *grfio_reads(const char *fname, int *size)
return NULL;
}
-/// Decodes encrypted filename from a version 01xx grf index.
-static char* decode_filename(unsigned char* buf, int len)
+/**
+ * Decodes encrypted filename from a version 01xx grf index.
+ *
+ * @param[in,out] buf The encrypted filename (decrypted in-place).
+ * @param[in] len The filename length.
+ * @return A pointer to the decrypted filename.
+ */
+static char *grfio_decode_filename(unsigned char *buf, int len)
{
- int lop;
- for(lop=0;lop<len;lop+=8) {
- NibbleSwap(&buf[lop],8);
- des_decrypt(&buf[lop],8);
+ int i;
+ for (i = 0; i < len; i += 8) {
+ NibbleSwap(&buf[i],8);
+ des->decrypt(&buf[i],8);
}
return (char*)buf;
}
-/// Compares file extension against known large file types.
-/// @return true if the file should undergo full mode 0 decryption, and true otherwise.
-static bool isFullEncrypt(const char* fname)
+/**
+ * Compares file extension against known large file types.
+ *
+ * @param fname The file name.
+ * @return true if the file should undergo full mode 0 decryption, and true otherwise.
+ */
+static bool grfio_is_full_encrypt(const char *fname)
{
- const char* ext = strrchr(fname, '.');
- if( ext != NULL ) {
- static const char extensions[4][5] = { ".gnd", ".gat", ".act", ".str" };
- size_t i;
- for( i = 0; i < ARRAYLENGTH(extensions); ++i )
- if( strcmpi(ext, extensions[i]) == 0 )
+ const char *ext = strrchr(fname, '.');
+ if (ext != NULL) {
+ static const char *extensions[] = { ".gnd", ".gat", ".act", ".str" };
+ int i;
+ for (i = 0; i < ARRAYLENGTH(extensions); ++i)
+ if (strcmpi(ext, extensions[i]) == 0)
return false;
}
return true;
}
-/// Loads all entries in the specified grf file into the filelist.
-/// @param gentry index of the grf file name in the gentry_table
+/**
+ * Loads all entries in the specified grf file into the filelist.
+ *
+ * @param grfname Name of the grf file.
+ * @param gentry Index of the grf file name in the gentry_table.
+ * @return Error code.
+ * @retval 0 in case of success.
+ */
static int grfio_entryread(const char *grfname, int gentry)
{
long grf_size;
@@ -535,12 +596,11 @@ static int grfio_entryread(const char *grfname, int gentry)
unsigned char *grf_filelist;
FILE *fp = fopen(grfname, "rb");
- if( fp == NULL ) {
- ShowWarning("GRF data file not found: '%s'\n",grfname);
+ if (fp == NULL) {
+ ShowWarning("GRF data file not found: '%s'\n", grfname);
return 1; // 1:not found error
- } else {
- ShowInfo("GRF data file found: '%s'\n",grfname);
}
+ ShowInfo("GRF data file found: '%s'\n", grfname);
fseek(fp,0,SEEK_END);
grf_size = ftell(fp);
@@ -551,7 +611,7 @@ static int grfio_entryread(const char *grfname, int gentry)
fclose(fp);
return 2; // 2:file format error
}
- if (strcmp((const char*)grf_header,"Master of Magic") != 0 || fseek(fp,getlong(grf_header+0x1e),SEEK_CUR) != 0) {
+ if (strcmp((const char*)grf_header, "Master of Magic") != 0 || fseek(fp, getlong(grf_header+0x1e), SEEK_CUR) != 0) {
fclose(fp);
ShowError("GRF %s read error\n", grfname);
return 2; // 2:file format error
@@ -561,9 +621,8 @@ static int grfio_entryread(const char *grfname, int gentry)
if (grf_version == 0x01) {
// ****** Grf version 01xx ******
- long list_size;
- list_size = grf_size - ftell(fp);
- grf_filelist = (unsigned char *)aMalloc(list_size);
+ long list_size = grf_size - ftell(fp);
+ grf_filelist = aMalloc(list_size);
if (fread(grf_filelist,1,list_size,fp) != (size_t)list_size) {
ShowError("Couldn't read all grf_filelist element of %s \n", grfname);
aFree(grf_filelist);
@@ -576,11 +635,11 @@ static int grfio_entryread(const char *grfname, int gentry)
// Get an entry
for (entry = 0, ofs = 0; entry < entrys; ++entry) {
- FILELIST aentry;
+ struct grf_filelist aentry = { 0 };
int ofs2 = ofs+getlong(grf_filelist+ofs)+4;
unsigned char type = grf_filelist[ofs2+12];
if (type&FILELIST_TYPE_FILE) {
- char *fname = decode_filename(grf_filelist+ofs+6, grf_filelist[ofs]-6);
+ char *fname = grfio_decode_filename(grf_filelist+ofs+6, grf_filelist[ofs]-6);
int srclen = getlong(grf_filelist+ofs2+0) - getlong(grf_filelist+ofs2+8) - 715;
if (strlen(fname) > sizeof(aentry.fn) - 1) {
@@ -589,7 +648,7 @@ static int grfio_entryread(const char *grfname, int gentry)
return 5; // 5: file name too long
}
- type |= isFullEncrypt(fname) ? FILELIST_TYPE_ENCRYPT_MIXED : FILELIST_TYPE_ENCRYPT_HEADER;
+ type |= grfio_is_full_encrypt(fname) ? FILELIST_TYPE_ENCRYPT_MIXED : FILELIST_TYPE_ENCRYPT_HEADER;
aentry.srclen = srclen;
aentry.srclen_aligned = getlong(grf_filelist+ofs2+4)-37579;
@@ -603,7 +662,7 @@ static int grfio_entryread(const char *grfname, int gentry)
#else
aentry.gentry = (char)(gentry+1); // With no first time LocalFileCheck
#endif
- filelist_modify(&aentry);
+ grfio_filelist_modify(&aentry);
}
ofs = ofs2 + 17;
@@ -630,7 +689,7 @@ static int grfio_entryread(const char *grfname, int gentry)
return 4;
}
- rBuf = (unsigned char *)aMalloc(rSize); // Get a Read Size
+ rBuf = aMalloc(rSize); // Get a Read Size
if (fread(rBuf,1,rSize,fp) != rSize) {
ShowError("An error occurred in fread \n");
fclose(fp);
@@ -638,8 +697,8 @@ static int grfio_entryread(const char *grfname, int gentry)
return 4;
}
fclose(fp);
- grf_filelist = (unsigned char *)aMalloc(eSize); // Get a Extend Size
- decode_zip(grf_filelist, &eSize, rBuf, rSize); // Decode function
+ grf_filelist = aMalloc(eSize); // Get a Extend Size
+ grfio->decode_zip(grf_filelist, &eSize, rBuf, rSize); // Decode function
aFree(rBuf);
entrys = getlong(grf_header+0x26) - 7;
@@ -647,7 +706,7 @@ static int grfio_entryread(const char *grfname, int gentry)
// Get an entry
for (entry = 0, ofs = 0; entry < entrys; ++entry) {
- FILELIST aentry;
+ struct grf_filelist aentry;
char *fname = (char*)(grf_filelist+ofs);
int ofs2 = ofs + (int)strlen(fname)+1;
int type = grf_filelist[ofs2+12];
@@ -672,84 +731,89 @@ static int grfio_entryread(const char *grfname, int gentry)
#else
aentry.gentry = (char)(gentry+1); // With no first time LocalFileCheck
#endif
- filelist_modify(&aentry);
+ grfio_filelist_modify(&aentry);
}
ofs = ofs2 + 17;
}
aFree(grf_filelist);
- } else {// ****** Grf Other version ******
+ } else {
+ // ****** Grf Other version ******
fclose(fp);
ShowError("GRF version %04x not supported\n",getlong(grf_header+0x2a));
return 4;
}
- filelist_compact(); // Unnecessary area release of filelist
+ grfio_filelist_compact(); // Unnecessary area release of filelist
return 0; // 0:no error
}
-static bool grfio_parse_restable_row(const char* row)
+/**
+ * Parses a Resource file table row.
+ *
+ * @param row The row data.
+ * @return success state.
+ * @retval true in case of success.
+ */
+static bool grfio_parse_restable_row(const char *row)
{
char w1[256], w2[256];
char src[256], dst[256];
char local[256];
- FILELIST* entry;
+ struct grf_filelist *entry = NULL;
if (sscanf(row, "%255[^#\r\n]#%255[^#\r\n]#", w1, w2) != 2)
return false;
- if( strstr(w2, ".gat") == NULL && strstr(w2, ".rsw") == NULL )
+ if (strstr(w2, ".gat") == NULL && strstr(w2, ".rsw") == NULL)
return false; // we only need the maps' GAT and RSW files
sprintf(src, "data\\%s", w1);
sprintf(dst, "data\\%s", w2);
- entry = filelist_find(dst);
- if( entry != NULL )
- {// alias for GRF resource
- FILELIST fentry;
- memcpy(&fentry, entry, sizeof(FILELIST));
+ entry = grfio_filelist_find(dst);
+ if (entry != NULL) {
+ // alias for GRF resource
+ struct grf_filelist fentry = *entry;
safestrncpy(fentry.fn, src, sizeof(fentry.fn));
fentry.fnd = aStrdup(dst);
- filelist_modify(&fentry);
+ grfio_filelist_modify(&fentry);
return true;
}
grfio_localpath_create(local, sizeof(local), dst);
- if( exists(local) )
- {// alias for local resource
- FILELIST fentry;
- memset(&fentry, 0, sizeof(fentry));
+ if (exists(local)) {
+ // alias for local resource
+ struct grf_filelist fentry = { 0 };
safestrncpy(fentry.fn, src, sizeof(fentry.fn));
fentry.fnd = aStrdup(dst);
- filelist_modify(&fentry);
+ grfio_filelist_modify(&fentry);
return true;
}
return false;
}
-/// Grfio Resource file check.
+/**
+ * Grfio Resource file check.
+ */
static void grfio_resourcecheck(void)
{
char restable[256];
- char *buf;
- int size;
- FILE* fp;
- int i = 0;
+ char *buf = NULL;
+ FILE *fp = NULL;
+ int size = 0, i = 0;
// read resnametable from data directory and return if successful
grfio_localpath_create(restable, sizeof(restable), "data\\resnametable.txt");
fp = fopen(restable, "rb");
- if( fp != NULL )
- {
+ if (fp != NULL) {
char line[256];
- while( fgets(line, sizeof(line), fp) )
- {
- if( grfio_parse_restable_row(line) )
+ while (fgets(line, sizeof(line), fp)) {
+ if (grfio_parse_restable_row(line))
++i;
}
@@ -759,20 +823,19 @@ static void grfio_resourcecheck(void)
}
// read resnametable from loaded GRF's, only if it cannot be loaded from the data directory
- buf = (char *)grfio_reads("data\\resnametable.txt", &size);
- if( buf != NULL )
- {
- char *ptr;
+ buf = grfio->reads("data\\resnametable.txt", &size);
+ if (buf != NULL) {
+ char *ptr = NULL;
buf[size] = '\0';
ptr = buf;
- while( ptr - buf < size )
- {
- if( grfio_parse_restable_row(ptr) )
+ while (ptr - buf < size) {
+ if (grfio_parse_restable_row(ptr))
++i;
ptr = strchr(ptr, '\n');
- if( ptr == NULL ) break;
+ if (ptr == NULL)
+ break;
ptr++;
}
@@ -782,13 +845,19 @@ static void grfio_resourcecheck(void)
}
}
-/// Reads a grf file and adds it to the list.
-static int grfio_add(const char* fname)
+/**
+ * Reads a grf file and adds it to the list.
+ *
+ * @param fname The file name to read.
+ * @return Error code.
+ * @retval 0 in case of success.
+ */
+static int grfio_add(const char *fname)
{
if (gentry_entrys >= gentry_maxentry) {
#define GENTRY_ADDS 4 // The number increment of gentry_table entries
gentry_maxentry += GENTRY_ADDS;
- gentry_table = (char**)aRealloc(gentry_table, gentry_maxentry * sizeof(char*));
+ gentry_table = aRealloc(gentry_table, gentry_maxentry * sizeof(char*));
memset(gentry_table + (gentry_maxentry - GENTRY_ADDS), 0, sizeof(char*) * GENTRY_ADDS);
#undef GENTRY_ADDS
}
@@ -798,7 +867,7 @@ static int grfio_add(const char* fname)
return grfio_entryread(fname, gentry_entrys - 1);
}
-/// Finalizes grfio.
+/// @copydoc grfio_interface::final()
void grfio_final(void)
{
if (filelist != NULL) {
@@ -824,36 +893,33 @@ void grfio_final(void)
gentry_entrys = gentry_maxentry = 0;
}
-/// Initializes grfio.
-void grfio_init(const char* fname)
+/// @copydoc grfio_interface::init()
+void grfio_init(const char *fname)
{
- FILE* data_conf;
+ FILE *data_conf;
int grf_num = 0;
hashinit(); // hash table initialization
data_conf = fopen(fname, "r");
- if( data_conf != NULL )
- {
+ if (data_conf != NULL) {
char line[1024];
- while( fgets(line, sizeof(line), data_conf) )
- {
+ while (fgets(line, sizeof(line), data_conf)) {
char w1[1024], w2[1024];
- if( line[0] == '/' && line[1] == '/' )
+ if (line[0] == '/' && line[1] == '/')
continue; // skip comments
if (sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2) != 2)
continue; // skip unrecognized lines
// Entry table reading
- if( strcmp(w1, "grf") == 0 ) // GRF file
- {
- if( grfio_add(w2) == 0 )
+ if (strcmp(w1, "grf") == 0) {
+ // GRF file
+ if (grfio_add(w2) == 0)
++grf_num;
- }
- else if( strcmp(w1,"data_dir") == 0 ) // Data directory
- {
+ } else if (strcmp(w1,"data_dir") == 0) {
+ // Data directory
safestrncpy(data_dir, w2, sizeof(data_dir));
}
}
@@ -862,12 +928,25 @@ void grfio_init(const char* fname)
ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n", fname);
}
- if( grf_num == 0 )
+ if (grf_num == 0)
ShowInfo("No GRF loaded, using default data directory\n");
// Unnecessary area release of filelist
- filelist_compact();
+ grfio_filelist_compact();
// Resource check
grfio_resourcecheck();
}
+
+/// Interface base initialization.
+void grfio_defaults(void)
+{
+ grfio = &grfio_s;
+ grfio->init = grfio_init;
+ grfio->final = grfio_final;
+ grfio->reads = grfio_reads;
+ grfio->find_file = grfio_find_file;
+ grfio->crc32 = grfio_crc32;
+ grfio->decode_zip = grfio_decode_zip;
+ grfio->encode_zip = grfio_encode_zip;
+}
diff --git a/src/common/grfio.h b/src/common/grfio.h
index 36ed8fb39..857bc507e 100644
--- a/src/common/grfio.h
+++ b/src/common/grfio.h
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
@@ -21,16 +21,104 @@
#ifndef COMMON_GRFIO_H
#define COMMON_GRFIO_H
+#include "common/hercules.h"
+
+/** @file
+ * GRF I/O library.
+ */
+
+/// The GRF I/O interface.
+struct grfio_interface {
+ /**
+ * Interface initialization.
+ *
+ * @param fname Name of the configuration file.
+ */
+ void (*init) (const char *fname);
+
+ /// Interface finalization.
+ void (*final) (void);
+
+ /**
+ * Reads a file into a newly allocated buffer (from grf or data directory).
+ *
+ * @param[in] fname Name of the file to read.
+ * @param[out] size Buffer to return the size of the read file (optional).
+ * @return The file data.
+ * @retval NULL in case of error.
+ */
+ void *(*reads) (const char *fname, int *size);
+
+ /**
+ * Finds a file in the grf or data directory
+ *
+ * @param fname The file to find.
+ * @return The original file name.
+ * @retval NULL if the file wasn't found.
+ */
+ const char *(*find_file) (const char *fname);
+
+ /**
+ * Calculates a CRC32 hash.
+ *
+ * @param buf The data to hash.
+ * @param len Data length.
+ *
+ * @return The CRC32 hash.
+ */
+ unsigned long (*crc32) (const unsigned char *buf, unsigned int len);
+
+ /**
+ * Decompresses ZIP data.
+ *
+ * Decompresses the source buffer into the destination buffer.
+ * source_len is the byte length of the source buffer. Upon entry,
+ * dest_len is the total size of the destination buffer, which must be
+ * large enough to hold the entire uncompressed data. (The size of the
+ * uncompressed data must have been saved previously by the compressor
+ * and transmitted to the decompressor by some mechanism outside the
+ * scope of this compression library.) Upon exit, dest_len is the
+ * actual size of the uncompressed buffer.
+ *
+ * @param[in,out] dest The destination (uncompressed) buffer.
+ * @param[in,out] dest_len Max length of the destination buffer, returns length of the decompressed data.
+ * @param[in] source The source (compressed) buffer.
+ * @param[in] source_len Source data length.
+ * @return error code.
+ * @retval Z_OK in case of success.
+ */
+ int (*decode_zip) (void *dest, unsigned long *dest_len, const void *source, unsigned long source_len);
+
+ /**
+ * Compresses data to ZIP format.
+ *
+ * Compresses the source buffer into the destination buffer.
+ * source_len is the byte length of the source buffer. Upon entry,
+ * dest_len is the total size of the destination buffer, which must be
+ * at least the value returned by compressBound(source_len). Upon
+ * exit, dest_len is the actual size of the compressed buffer.
+ *
+ * @param[in,out] dest The destination (compressed) buffer (if NULL, a new buffer will be created).
+ * @param[in,out] dest_len Max length of the destination buffer (if 0, it will be calculated).
+ * @param[in] source The source (uncompressed) buffer.
+ * @param[in] source_len Source data length.
+ */
+ int (*encode_zip) (void *dest, unsigned long *dest_len, const void *source, unsigned long source_len);
+};
+
+/**
+ * Reads a file into a newly allocated buffer (from grf or data directory)
+ *
+ * @param fn The filename to read.
+ *
+ * @see grfio_interface::reads()
+ * @related grfio_interface
+ */
+#define grfio_read(fn) grfio->reads((fn), NULL)
+
#ifdef HERCULES_CORE
-void grfio_init(const char* fname);
-void grfio_final(void);
-void* grfio_reads(const char* fname, int* size);
-char* grfio_find_file(const char* fname);
-#define grfio_read(fn) grfio_reads((fn), NULL)
-
-unsigned long grfio_crc32(const unsigned char *buf, unsigned int len);
-int decode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen);
-int encode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen);
+void grfio_defaults(void);
#endif // HERCULES_CORE
+HPShared struct grfio_interface *grfio; ///< Pointer to the grfio interface.
#endif /* COMMON_GRFIO_H */
diff --git a/src/common/md5calc.c b/src/common/md5calc.c
index d346c8aa4..bd6b48f10 100644
--- a/src/common/md5calc.c
+++ b/src/common/md5calc.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
@@ -20,27 +20,27 @@
*/
#define HERCULES_CORE
-/***********************************************************
- * md5 calculation algorithm
- *
- * The source code referred to the following URL.
- * http://www.geocities.co.jp/SiliconValley-Oakland/8878/lab17/lab17.html
- *
- ***********************************************************/
-
#include "md5calc.h"
#include "common/cbasetypes.h"
+#include "common/nullpo.h"
#include "common/random.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-// Global variable
+/** @file
+ * Implementation of the md5 interface.
+ */
+
+struct md5_interface md5_s;
+struct md5_interface *md5;
+
+/// Global variable
static unsigned int *pX;
-// String Table
+/// String Table
static const unsigned int T[] = {
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, //0
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, //4
@@ -60,99 +60,102 @@ static const unsigned int T[] = {
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 //60
};
-// ROTATE_LEFT The left is made to rotate x [ n-bit ]. This is diverted as it is from RFC.
+/// The left is made to rotate x [ n-bit ]. This is diverted as it is from RFC.
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
// The function used for other calculation
-static unsigned int F(unsigned int X, unsigned int Y, unsigned int Z)
+static unsigned int md5_F(unsigned int X, unsigned int Y, unsigned int Z)
{
return (X & Y) | (~X & Z);
}
-static unsigned int G(unsigned int X, unsigned int Y, unsigned int Z)
+
+static unsigned int md5_G(unsigned int X, unsigned int Y, unsigned int Z)
{
return (X & Z) | (Y & ~Z);
}
-static unsigned int H(unsigned int X, unsigned int Y, unsigned int Z)
+
+static unsigned int md5_H(unsigned int X, unsigned int Y, unsigned int Z)
{
return X ^ Y ^ Z;
}
-static unsigned int I(unsigned int X, unsigned int Y, unsigned int Z)
+
+static unsigned int md5_I(unsigned int X, unsigned int Y, unsigned int Z)
{
return Y ^ (X | ~Z);
}
-static unsigned int Round(unsigned int a, unsigned int b, unsigned int FGHI,
+static unsigned int md5_Round(unsigned int a, unsigned int b, unsigned int FGHI,
unsigned int k, unsigned int s, unsigned int i)
{
return b + ROTATE_LEFT(a + FGHI + pX[k] + T[i], s);
}
-static void Round1(unsigned int *a, unsigned int b, unsigned int c,
+static void md5_Round1(unsigned int *a, unsigned int b, unsigned int c,
unsigned int d,unsigned int k, unsigned int s, unsigned int i)
{
- *a = Round(*a, b, F(b,c,d), k, s, i);
+ *a = md5_Round(*a, b, md5_F(b,c,d), k, s, i);
}
-static void Round2(unsigned int *a, unsigned int b, unsigned int c,
+static void md5_Round2(unsigned int *a, unsigned int b, unsigned int c,
unsigned int d,unsigned int k, unsigned int s, unsigned int i)
{
- *a = Round(*a, b, G(b,c,d), k, s, i);
+ *a = md5_Round(*a, b, md5_G(b,c,d), k, s, i);
}
-static void Round3(unsigned int *a, unsigned int b, unsigned int c,
+static void md5_Round3(unsigned int *a, unsigned int b, unsigned int c,
unsigned int d,unsigned int k, unsigned int s, unsigned int i)
{
- *a = Round(*a, b, H(b,c,d), k, s, i);
+ *a = md5_Round(*a, b, md5_H(b,c,d), k, s, i);
}
-static void Round4(unsigned int *a, unsigned int b, unsigned int c,
+static void md5_Round4(unsigned int *a, unsigned int b, unsigned int c,
unsigned int d,unsigned int k, unsigned int s, unsigned int i)
{
- *a = Round(*a, b, I(b,c,d), k, s, i);
+ *a = md5_Round(*a, b, md5_I(b,c,d), k, s, i);
}
-static void MD5_Round_Calculate(const unsigned char *block,
+static void md5_Round_Calculate(const unsigned char *block,
unsigned int *A2, unsigned int *B2, unsigned int *C2, unsigned int *D2)
{
//create X It is since it is required.
unsigned int X[16]; //512bit 64byte
- int j,k;
+ int j, k;
//Save A as AA, B as BB, C as CC, and and D as DD (saving of A, B, C, and D)
- unsigned int A=*A2, B=*B2, C=*C2, D=*D2;
- unsigned int AA = A,BB = B,CC = C,DD = D;
+ unsigned int A = *A2, B = *B2, C = *C2, D = *D2;
+ unsigned int AA = A, BB = B, CC = C, DD = D;
//It is a large region variable reluctantly because of calculation of a round. . . for Round1...4
pX = X;
//Copy block(padding_message) i into X
- for (j=0,k=0; j<64; j+=4,k++)
- X[k] = ( (unsigned int )block[j] ) // 8byte*4 -> 32byte conversion
- | ( ((unsigned int )block[j+1]) << 8 ) // A function called Decode as used in the field of RFC
- | ( ((unsigned int )block[j+2]) << 16 )
- | ( ((unsigned int )block[j+3]) << 24 );
-
+ for (j = 0, k = 0; j < 64; j += 4, k++) {
+ X[k] = ((unsigned int)block[j]) // 8byte*4 -> 32byte conversion
+ | (((unsigned int)block[j+1]) << 8) // A function called Decode as used in the field of RFC
+ | (((unsigned int)block[j+2]) << 16)
+ | (((unsigned int)block[j+3]) << 24);
+ }
//Round 1
- Round1(&A,B,C,D, 0, 7, 0); Round1(&D,A,B,C, 1, 12, 1); Round1(&C,D,A,B, 2, 17, 2); Round1(&B,C,D,A, 3, 22, 3);
- Round1(&A,B,C,D, 4, 7, 4); Round1(&D,A,B,C, 5, 12, 5); Round1(&C,D,A,B, 6, 17, 6); Round1(&B,C,D,A, 7, 22, 7);
- Round1(&A,B,C,D, 8, 7, 8); Round1(&D,A,B,C, 9, 12, 9); Round1(&C,D,A,B, 10, 17, 10); Round1(&B,C,D,A, 11, 22, 11);
- Round1(&A,B,C,D, 12, 7, 12); Round1(&D,A,B,C, 13, 12, 13); Round1(&C,D,A,B, 14, 17, 14); Round1(&B,C,D,A, 15, 22, 15);
+ md5_Round1(&A,B,C,D, 0, 7, 0); md5_Round1(&D,A,B,C, 1, 12, 1); md5_Round1(&C,D,A,B, 2, 17, 2); md5_Round1(&B,C,D,A, 3, 22, 3);
+ md5_Round1(&A,B,C,D, 4, 7, 4); md5_Round1(&D,A,B,C, 5, 12, 5); md5_Round1(&C,D,A,B, 6, 17, 6); md5_Round1(&B,C,D,A, 7, 22, 7);
+ md5_Round1(&A,B,C,D, 8, 7, 8); md5_Round1(&D,A,B,C, 9, 12, 9); md5_Round1(&C,D,A,B, 10, 17, 10); md5_Round1(&B,C,D,A, 11, 22, 11);
+ md5_Round1(&A,B,C,D, 12, 7, 12); md5_Round1(&D,A,B,C, 13, 12, 13); md5_Round1(&C,D,A,B, 14, 17, 14); md5_Round1(&B,C,D,A, 15, 22, 15);
//Round 2
- Round2(&A,B,C,D, 1, 5, 16); Round2(&D,A,B,C, 6, 9, 17); Round2(&C,D,A,B, 11, 14, 18); Round2(&B,C,D,A, 0, 20, 19);
- Round2(&A,B,C,D, 5, 5, 20); Round2(&D,A,B,C, 10, 9, 21); Round2(&C,D,A,B, 15, 14, 22); Round2(&B,C,D,A, 4, 20, 23);
- Round2(&A,B,C,D, 9, 5, 24); Round2(&D,A,B,C, 14, 9, 25); Round2(&C,D,A,B, 3, 14, 26); Round2(&B,C,D,A, 8, 20, 27);
- Round2(&A,B,C,D, 13, 5, 28); Round2(&D,A,B,C, 2, 9, 29); Round2(&C,D,A,B, 7, 14, 30); Round2(&B,C,D,A, 12, 20, 31);
+ md5_Round2(&A,B,C,D, 1, 5, 16); md5_Round2(&D,A,B,C, 6, 9, 17); md5_Round2(&C,D,A,B, 11, 14, 18); md5_Round2(&B,C,D,A, 0, 20, 19);
+ md5_Round2(&A,B,C,D, 5, 5, 20); md5_Round2(&D,A,B,C, 10, 9, 21); md5_Round2(&C,D,A,B, 15, 14, 22); md5_Round2(&B,C,D,A, 4, 20, 23);
+ md5_Round2(&A,B,C,D, 9, 5, 24); md5_Round2(&D,A,B,C, 14, 9, 25); md5_Round2(&C,D,A,B, 3, 14, 26); md5_Round2(&B,C,D,A, 8, 20, 27);
+ md5_Round2(&A,B,C,D, 13, 5, 28); md5_Round2(&D,A,B,C, 2, 9, 29); md5_Round2(&C,D,A,B, 7, 14, 30); md5_Round2(&B,C,D,A, 12, 20, 31);
//Round 3
- Round3(&A,B,C,D, 5, 4, 32); Round3(&D,A,B,C, 8, 11, 33); Round3(&C,D,A,B, 11, 16, 34); Round3(&B,C,D,A, 14, 23, 35);
- Round3(&A,B,C,D, 1, 4, 36); Round3(&D,A,B,C, 4, 11, 37); Round3(&C,D,A,B, 7, 16, 38); Round3(&B,C,D,A, 10, 23, 39);
- Round3(&A,B,C,D, 13, 4, 40); Round3(&D,A,B,C, 0, 11, 41); Round3(&C,D,A,B, 3, 16, 42); Round3(&B,C,D,A, 6, 23, 43);
- Round3(&A,B,C,D, 9, 4, 44); Round3(&D,A,B,C, 12, 11, 45); Round3(&C,D,A,B, 15, 16, 46); Round3(&B,C,D,A, 2, 23, 47);
+ md5_Round3(&A,B,C,D, 5, 4, 32); md5_Round3(&D,A,B,C, 8, 11, 33); md5_Round3(&C,D,A,B, 11, 16, 34); md5_Round3(&B,C,D,A, 14, 23, 35);
+ md5_Round3(&A,B,C,D, 1, 4, 36); md5_Round3(&D,A,B,C, 4, 11, 37); md5_Round3(&C,D,A,B, 7, 16, 38); md5_Round3(&B,C,D,A, 10, 23, 39);
+ md5_Round3(&A,B,C,D, 13, 4, 40); md5_Round3(&D,A,B,C, 0, 11, 41); md5_Round3(&C,D,A,B, 3, 16, 42); md5_Round3(&B,C,D,A, 6, 23, 43);
+ md5_Round3(&A,B,C,D, 9, 4, 44); md5_Round3(&D,A,B,C, 12, 11, 45); md5_Round3(&C,D,A,B, 15, 16, 46); md5_Round3(&B,C,D,A, 2, 23, 47);
//Round 4
- Round4(&A,B,C,D, 0, 6, 48); Round4(&D,A,B,C, 7, 10, 49); Round4(&C,D,A,B, 14, 15, 50); Round4(&B,C,D,A, 5, 21, 51);
- Round4(&A,B,C,D, 12, 6, 52); Round4(&D,A,B,C, 3, 10, 53); Round4(&C,D,A,B, 10, 15, 54); Round4(&B,C,D,A, 1, 21, 55);
- Round4(&A,B,C,D, 8, 6, 56); Round4(&D,A,B,C, 15, 10, 57); Round4(&C,D,A,B, 6, 15, 58); Round4(&B,C,D,A, 13, 21, 59);
- Round4(&A,B,C,D, 4, 6, 60); Round4(&D,A,B,C, 11, 10, 61); Round4(&C,D,A,B, 2, 15, 62); Round4(&B,C,D,A, 9, 21, 63);
+ md5_Round4(&A,B,C,D, 0, 6, 48); md5_Round4(&D,A,B,C, 7, 10, 49); md5_Round4(&C,D,A,B, 14, 15, 50); md5_Round4(&B,C,D,A, 5, 21, 51);
+ md5_Round4(&A,B,C,D, 12, 6, 52); md5_Round4(&D,A,B,C, 3, 10, 53); md5_Round4(&C,D,A,B, 10, 15, 54); md5_Round4(&B,C,D,A, 1, 21, 55);
+ md5_Round4(&A,B,C,D, 8, 6, 56); md5_Round4(&D,A,B,C, 15, 10, 57); md5_Round4(&C,D,A,B, 6, 15, 58); md5_Round4(&B,C,D,A, 13, 21, 59);
+ md5_Round4(&A,B,C,D, 4, 6, 60); md5_Round4(&D,A,B,C, 11, 10, 61); md5_Round4(&C,D,A,B, 2, 15, 62); md5_Round4(&B,C,D,A, 9, 21, 63);
// Then perform the following additions. (let's add)
*A2 = A + AA;
@@ -164,7 +167,8 @@ static void MD5_Round_Calculate(const unsigned char *block,
memset(pX, 0, sizeof(X));
}
-static void MD5_String2binary(const char * string, unsigned char * output)
+/// @copydoc md5_interface::binary()
+static void md5_string2binary(const char *string, unsigned char *output)
{
//var
/*8bit*/
@@ -196,7 +200,7 @@ static void MD5_String2binary(const char * string, unsigned char * output)
//1-2 Repeat calculation until length becomes less than 64 bytes.
for (i=string_byte_len; 64<=i; i-=64,pstring+=64)
- MD5_Round_Calculate(pstring, A,B,C,D);
+ md5_Round_Calculate(pstring, A,B,C,D);
//1-3
copy_len = string_byte_len % 64; //The number of bytes which remained is computed.
@@ -207,7 +211,7 @@ static void MD5_String2binary(const char * string, unsigned char * output)
//1-4
//If 56 bytes or more (less than 64 bytes) of remainder becomes, it will calculate by extending to 64 bytes.
if (56 <= copy_len) {
- MD5_Round_Calculate(padding_message, A,B,C,D);
+ md5_Round_Calculate(padding_message, A,B,C,D);
memset(padding_message, 0, 56); //56 bytes is newly fill uped with 0.
}
@@ -219,31 +223,26 @@ static void MD5_String2binary(const char * string, unsigned char * output)
if (UINT_MAX / 8 < string_byte_len) {
unsigned int high = (string_byte_len - UINT_MAX / 8) * 8;
memcpy(&padding_message[60], &high, 4);
- } else
+ } else {
memset(&padding_message[60], 0, 4); //In this case, it is good for a higher rank at 0.
+ }
//Step 4.Process Message in 16-Word Blocks (calculation of MD5)
- MD5_Round_Calculate(padding_message, A,B,C,D);
+ md5_Round_Calculate(padding_message, A,B,C,D);
//Step 5.Output (output)
memcpy(output,msg_digest,16);
}
-//-------------------------------------------------------------------
-// The function for the exteriors
-
-/** output is the coded binary in the character sequence which wants to code string. */
-void MD5_Binary(const char * string, unsigned char * output)
-{
- MD5_String2binary(string,output);
-}
-
-/** output is the coded character sequence in the character sequence which wants to code string. */
-void MD5_String(const char *string, char *output)
+/// @copydoc md5_interface::string()
+void md5_string(const char *string, char *output)
{
unsigned char digest[16];
- MD5_String2binary(string,digest);
+ nullpo_retv(string);
+ nullpo_retv(output);
+
+ md5->binary(string,digest);
snprintf(output, 33, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
digest[ 0], digest[ 1], digest[ 2], digest[ 3],
digest[ 4], digest[ 5], digest[ 6], digest[ 7],
@@ -251,11 +250,24 @@ void MD5_String(const char *string, char *output)
digest[12], digest[13], digest[14], digest[15]);
}
-/** output is a sequence of non-zero characters to be used as password salt. */
-void MD5_Salt(unsigned int len, char * output)
+/// @copydoc md5_interface::salt();
+void md5_salt(int len, char *output)
{
- unsigned int i;
- for( i = 0; i < len; ++i )
+ int i;
+ Assert_retv(len > 0);
+
+ for (i = 0; i < len; ++i)
output[i] = (char)(1 + rnd() % 255);
}
+
+/**
+ * Interface base initialization.
+ */
+void md5_defaults(void)
+{
+ md5 = &md5_s;
+ md5->binary = md5_string2binary;
+ md5->string = md5_string;
+ md5->salt = md5_salt;
+}
diff --git a/src/common/md5calc.h b/src/common/md5calc.h
index 0294c3ca1..b4d4995f9 100644
--- a/src/common/md5calc.h
+++ b/src/common/md5calc.h
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
@@ -21,10 +21,46 @@
#ifndef COMMON_MD5CALC_H
#define COMMON_MD5CALC_H
+#include "common/hercules.h"
+
+/** @file
+ * md5 calculation algorithm.
+ *
+ * The source code referred to the following URL.
+ * http://www.geocities.co.jp/SiliconValley-Oakland/8878/lab17/lab17.html
+ */
+
+/// The md5 interface
+struct md5_interface {
+ /**
+ * Hashes a string, returning the hash in string format.
+ *
+ * @param[in] string The source string (NUL terminated).
+ * @param[out] output Output buffer (at least 33 bytes available).
+ */
+ void (*string) (const char *string, char *output);
+
+ /**
+ * Hashes a string, returning the buffer in binary format.
+ *
+ * @param[in] string The source string.
+ * @param[out] output Output buffer (at least 16 bytes available).
+ */
+ void (*binary) (const char *string, unsigned char *output);
+
+ /**
+ * Generates a random salt.
+ *
+ * @param[in] len The desired salt length.
+ * @param[out] output The output buffer (at least len bytes available).
+ */
+ void (*salt) (int len, char *output);
+};
+
#ifdef HERCULES_CORE
-void MD5_String(const char * string, char * output);
-void MD5_Binary(const char * string, unsigned char * output);
-void MD5_Salt(unsigned int len, char * output);
+void md5_defaults(void);
#endif // HERCULES_CORE
+HPShared struct md5_interface *md5; ///< Pointer to the md5 interface.
+
#endif /* COMMON_MD5CALC_H */
diff --git a/src/common/mutex.c b/src/common/mutex.c
index 0f02b153f..bdc2fb4dc 100644
--- a/src/common/mutex.c
+++ b/src/common/mutex.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) rAthena Project (www.rathena.org)
*
* Hercules is free software: you can redistribute it and/or modify
@@ -34,7 +34,14 @@
#include <sys/time.h>
#endif
-struct ramutex{
+/** @file
+ * Implementation of the mutex interface.
+ */
+
+struct mutex_interface mutex_s;
+struct mutex_interface *mutex;
+
+struct mutex_data {
#ifdef WIN32
CRITICAL_SECTION hMutex;
#else
@@ -42,32 +49,26 @@ struct ramutex{
#endif
};
-struct racond{
+struct cond_data {
#ifdef WIN32
HANDLE events[2];
ra_align(8) volatile LONG nWaiters;
CRITICAL_SECTION waiters_lock;
-
#define EVENT_COND_SIGNAL 0
#define EVENT_COND_BROADCAST 1
-
#else
pthread_cond_t hCond;
#endif
};
-////////////////////
-// Mutex
-//
-// Implementation:
-//
+/* Mutex */
-ramutex *ramutex_create(void) {
- struct ramutex *m;
-
- m = (struct ramutex*)aMalloc( sizeof(struct ramutex) );
+/// @copydoc mutex_interface::create()
+struct mutex_data *mutex_create(void)
+{
+ struct mutex_data *m = aMalloc(sizeof(struct mutex_data));
if (m == NULL) {
- ShowFatalError("ramutex_create: OOM while allocating %"PRIuS" bytes.\n", sizeof(struct ramutex));
+ ShowFatalError("ramutex_create: OOM while allocating %"PRIuS" bytes.\n", sizeof(struct mutex_data));
return NULL;
}
@@ -78,10 +79,11 @@ ramutex *ramutex_create(void) {
#endif
return m;
-}//end: ramutex_create()
-
-void ramutex_destroy(ramutex *m) {
+}
+/// @copydoc mutex_interface::destroy()
+void mutex_destroy(struct mutex_data *m)
+{
#ifdef WIN32
DeleteCriticalSection(&m->hMutex);
#else
@@ -89,53 +91,49 @@ void ramutex_destroy(ramutex *m) {
#endif
aFree(m);
+}
-}//end: ramutex_destroy()
-
-void ramutex_lock(ramutex *m) {
-
+/// @copydoc mutex_interface::lock()
+void mutex_lock(struct mutex_data *m)
+{
#ifdef WIN32
EnterCriticalSection(&m->hMutex);
#else
pthread_mutex_lock(&m->hMutex);
#endif
-}//end: ramutex_lock
+}
-bool ramutex_trylock(ramutex *m) {
+/// @copydoc mutex_interface::trylock()
+bool mutex_trylock(struct mutex_data *m)
+{
#ifdef WIN32
- if(TryEnterCriticalSection(&m->hMutex) != FALSE)
+ if (TryEnterCriticalSection(&m->hMutex) != FALSE)
return true;
-
- return false;
#else
- if(pthread_mutex_trylock(&m->hMutex) == 0)
+ if (pthread_mutex_trylock(&m->hMutex) == 0)
return true;
-
- return false;
#endif
-}//end: ramutex_trylock()
+ return false;
+}
-void ramutex_unlock(ramutex *m) {
+/// @copydoc mutex_interface::unlock()
+void mutex_unlock(struct mutex_data *m)
+{
#ifdef WIN32
LeaveCriticalSection(&m->hMutex);
#else
pthread_mutex_unlock(&m->hMutex);
#endif
+}
-}//end: ramutex_unlock()
-
-///////////////
-// Condition Variables
-//
-// Implementation:
-//
+/* Conditional variable */
-racond *racond_create(void) {
- struct racond *c;
-
- c = (struct racond*)aMalloc( sizeof(struct racond) );
+/// @copydoc mutex_interface::cond_create()
+struct cond_data *cond_create(void)
+{
+ struct cond_data *c = aMalloc(sizeof(struct cond_data));
if (c == NULL) {
- ShowFatalError("racond_create: OOM while allocating %"PRIuS" bytes\n", sizeof(struct racond));
+ ShowFatalError("racond_create: OOM while allocating %"PRIuS" bytes\n", sizeof(struct cond_data));
return NULL;
}
@@ -149,21 +147,25 @@ racond *racond_create(void) {
#endif
return c;
-}//end: racond_create()
+}
-void racond_destroy(racond *c) {
+/// @copydoc mutex_interface::cond_destroy()
+void cond_destroy(struct cond_data *c)
+{
#ifdef WIN32
- CloseHandle( c->events[ EVENT_COND_SIGNAL ] );
- CloseHandle( c->events[ EVENT_COND_BROADCAST ] );
- DeleteCriticalSection( &c->waiters_lock );
+ CloseHandle(c->events[EVENT_COND_SIGNAL]);
+ CloseHandle(c->events[EVENT_COND_BROADCAST]);
+ DeleteCriticalSection(&c->waiters_lock);
#else
pthread_cond_destroy(&c->hCond);
#endif
aFree(c);
-}//end: racond_destroy()
+}
-void racond_wait(racond *c, ramutex *m, sysint timeout_ticks) {
+/// @copydoc mutex_interface::cond_wait()
+void cond_wait(struct cond_data *c, struct mutex_data *m, sysint timeout_ticks)
+{
#ifdef WIN32
register DWORD ms;
int result;
@@ -173,7 +175,7 @@ void racond_wait(racond *c, ramutex *m, sysint timeout_ticks) {
c->nWaiters++;
LeaveCriticalSection(&c->waiters_lock);
- if(timeout_ticks < 0)
+ if (timeout_ticks < 0)
ms = INFINITE;
else
ms = (timeout_ticks > MAXDWORD) ? (MAXDWORD - 1) : (DWORD)timeout_ticks;
@@ -181,27 +183,27 @@ void racond_wait(racond *c, ramutex *m, sysint timeout_ticks) {
// we can release the mutex (m) here, cause win's
// manual reset events maintain state when used with
// SetEvent()
- ramutex_unlock(m);
+ mutex->unlock(m);
result = WaitForMultipleObjects(2, c->events, FALSE, ms);
EnterCriticalSection(&c->waiters_lock);
c->nWaiters--;
- if( (result == WAIT_OBJECT_0 + EVENT_COND_BROADCAST) && (c->nWaiters == 0) )
+ if ((result == WAIT_OBJECT_0 + EVENT_COND_BROADCAST) && (c->nWaiters == 0))
is_last = true; // Broadcast called!
LeaveCriticalSection(&c->waiters_lock);
// we are the last waiter that has to be notified, or to stop waiting
// so we have to do a manual reset
- if(is_last == true)
+ if (is_last == true)
ResetEvent( c->events[EVENT_COND_BROADCAST] );
- ramutex_lock(m);
+ mutex->lock(m);
#else
- if(timeout_ticks < 0){
- pthread_cond_wait( &c->hCond, &m->hMutex );
- }else{
+ if (timeout_ticks < 0) {
+ pthread_cond_wait(&c->hCond, &m->hMutex);
+ } else {
struct timespec wtime;
int64 exact_timeout = timer->gettick() + timeout_ticks;
@@ -210,11 +212,12 @@ void racond_wait(racond *c, ramutex *m, sysint timeout_ticks) {
pthread_cond_timedwait( &c->hCond, &m->hMutex, &wtime);
}
-
#endif
-}//end: racond_wait()
+}
-void racond_signal(racond *c) {
+/// @copydoc mutex_interface::cond_signal()
+void cond_signal(struct cond_data *c)
+{
#ifdef WIN32
# if 0
bool has_waiters = false;
@@ -225,13 +228,15 @@ void racond_signal(racond *c) {
if(has_waiters == true)
# endif // 0
- SetEvent( c->events[ EVENT_COND_SIGNAL ] );
+ SetEvent(c->events[EVENT_COND_SIGNAL]);
#else
pthread_cond_signal(&c->hCond);
#endif
-}//end: racond_signal()
+}
-void racond_broadcast(racond *c) {
+/// @copydoc mutex_interface::cond_broadcast()
+void cond_broadcast(struct cond_data *c)
+{
#ifdef WIN32
# if 0
bool has_waiters = false;
@@ -242,8 +247,27 @@ void racond_broadcast(racond *c) {
if(has_waiters == true)
# endif // 0
- SetEvent( c->events[ EVENT_COND_BROADCAST ] );
+ SetEvent(c->events[EVENT_COND_BROADCAST]);
#else
pthread_cond_broadcast(&c->hCond);
#endif
-}//end: racond_broadcast()
+}
+
+/**
+ * Interface base initialization.
+ */
+void mutex_defaults(void)
+{
+ mutex = &mutex_s;
+ mutex->create = mutex_create;
+ mutex->destroy = mutex_destroy;
+ mutex->lock = mutex_lock;
+ mutex->trylock = mutex_trylock;
+ mutex->unlock = mutex_unlock;
+
+ mutex->cond_create = cond_create;
+ mutex->cond_destroy = cond_destroy;
+ mutex->cond_wait = cond_wait;
+ mutex->cond_signal = cond_signal;
+ mutex->cond_broadcast = cond_broadcast;
+}
diff --git a/src/common/mutex.h b/src/common/mutex.h
index e49791493..0569fb0da 100644
--- a/src/common/mutex.h
+++ b/src/common/mutex.h
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) rAthena Project (www.rathena.org)
*
* Hercules is free software: you can redistribute it and/or modify
@@ -21,91 +21,111 @@
#ifndef COMMON_MUTEX_H
#define COMMON_MUTEX_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
-typedef struct ramutex ramutex; // Mutex
-typedef struct racond racond; // Condition Var
-
-#ifdef HERCULES_CORE
-/**
- * Creates a Mutex
- *
- * @return not NULL
+/** @file
+ * Mutex and conditional variables implementation for Hercules.
*/
-ramutex *ramutex_create(void);
-/**
- * Destroys a Mutex
- *
- * @param m - the mutex to destroy
- */
-void ramutex_destroy(ramutex *m);
+/* Opaque types */
-/**
- * Gets a lock
- *
- * @param m - the mutex to lock
- */
-void ramutex_lock(ramutex *m);
+struct mutex_data; ///< Mutex
+struct cond_data; ///< Conditional variable
-/**
- * Trys to get the Lock
- *
- * @param m - the mutex try to lock
- *
- * @return boolean (true = got the lock)
- */
-bool ramutex_trylock(ramutex *m);
+/* Interface */
-/**
- * Unlocks a mutex
- *
- * @param m - the mutex to unlock
- */
-void ramutex_unlock(ramutex *m);
+/// The mutex interface.
+struct mutex_interface {
+ /**
+ * Creates a mutex.
+ *
+ * @return The created mutex.
+ */
+ struct mutex_data *(*create) (void);
+ /**
+ * Destroys a mutex.
+ *
+ * @param m the mutex to destroy.
+ */
+ void (*destroy) (struct mutex_data *m);
-/**
- * Creates a Condition variable
- *
- * @return not NULL
- */
-racond *racond_create(void);
+ /**
+ * Gets a lock.
+ *
+ * This function blocks until the lock can be acquired.
+ *
+ * @param m The mutex to lock.
+ */
+ void (*lock) (struct mutex_data *m);
-/**
- * Destroy a Condition variable
- *
- * @param c - the condition variable to destroy
- */
-void racond_destroy(racond *c);
+ /**
+ * Tries to get a lock.
+ *
+ * This function returns immediately.
+ *
+ * @param m The mutex to try to lock.
+ * @return success status.
+ * @retval true if the lock was acquired.
+ * @retval false if the mutex couldn't be locked.
+ */
+ bool (*trylock) (struct mutex_data *m);
-/**
- * Waits Until state is signaled
- *
- * @param c - the condition var to wait for signaled state
- * @param m - the mutex used for synchronization
- * @param timeout_ticks - timeout in ticks ( -1 = INFINITE )
- */
-void racond_wait(racond *c, ramutex *m, sysint timeout_ticks);
+ /**
+ * Unlocks a mutex.
+ *
+ * @param m The mutex to unlock.
+ */
+ void (*unlock) (struct mutex_data *m);
-/**
- * Sets the given condition var to signaled state
- *
- * @param c - condition var to set in signaled state.
- *
- * @note:
- * Only one waiter gets notified.
- */
-void racond_signal(racond *c);
+ /**
+ * Creates a conditional variable.
+ *
+ * @return the created conditional variable.
+ */
+ struct cond_data *(*cond_create) (void);
-/**
- * Sets notifies all waiting threads thats signaled.
- * @param c - condition var to set in signaled state
- *
- * @note:
- * All Waiters getting notified.
- */
-void racond_broadcast(racond *c);
+ /**
+ * Destroys a conditional variable.
+ *
+ * @param c the conditional variable to destroy.
+ */
+ void (*cond_destroy) (struct cond_data *c);
+
+ /**
+ * Waits Until state is signaled.
+ *
+ * @param c The condition var to wait for signaled state.
+ * @param m The mutex used for synchronization.
+ * @param timeout_ticks Timeout in ticks (-1 = INFINITE)
+ */
+ void (*cond_wait) (struct cond_data *c, struct mutex_data *m, sysint timeout_ticks);
+
+ /**
+ * Sets the given condition var to signaled state.
+ *
+ * @remark
+ * Only one waiter gets notified.
+ *
+ * @param c Condition var to set in signaled state.
+ */
+ void (*cond_signal) (struct cond_data *c);
+
+ /**
+ * Sets notifies all waiting threads thats signaled.
+ *
+ * @remark
+ * All Waiters getting notified.
+ *
+ * @param c Condition var to set in signaled state.
+ */
+ void (*cond_broadcast) (struct cond_data *c);
+};
+
+#ifdef HERCULES_CORE
+void mutex_defaults(void);
#endif // HERCULES_CORE
+HPShared struct mutex_interface *mutex; ///< Pointer to the mutex interface.
+
#endif /* COMMON_MUTEX_H */
diff --git a/src/common/random.c b/src/common/random.c
index ba70a5c1d..b3a13e054 100644
--- a/src/common/random.c
+++ b/src/common/random.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
@@ -27,6 +27,7 @@
#include "common/timer.h" // gettick
#include <mt19937ar/mt19937ar.h> // init_genrand, genrand_int32, genrand_res53
+#include <stdlib.h>
#if defined(WIN32)
# include "common/winapi.h"
@@ -35,8 +36,14 @@
# include <unistd.h>
#endif
+/** @file
+ * Implementation of the random number generator interface.
+ */
+
+struct rnd_interface rnd_s;
+struct rnd_interface *rnd;
-/// Initializes the random number generator with an appropriate seed.
+/// @copydoc rnd_interface::init()
void rnd_init(void)
{
unsigned long seed = (unsigned long)timer->gettick();
@@ -53,53 +60,64 @@ void rnd_init(void)
#endif // HAVE_GETTID
#endif
init_genrand(seed);
+
+ // Also initialize the stdlib rng, just in case it's used somewhere.
+ srand((unsigned int)seed);
}
+/// @copydoc rnd_interface::final()
+void rnd_final(void)
+{
+}
-/// Initializes the random number generator.
+/// @copydoc rnd_interface::seed()
void rnd_seed(uint32 seed)
{
init_genrand(seed);
}
-
-/// Generates a random number in the interval [0, SINT32_MAX]
-int32 rnd(void)
+/// @copydoc rnd_interface::random()
+int32 rnd_random(void)
{
return (int32)genrand_int31();
}
-
-/// Generates a random number in the interval [0, dice_faces)
-/// NOTE: interval is open ended, so dice_faces is excluded (unless it's 0)
+/// @copydoc rnd_interface::roll()
uint32 rnd_roll(uint32 dice_faces)
{
- return (uint32)(rnd_uniform()*dice_faces);
+ return (uint32)(rnd->uniform()*dice_faces);
}
-
-/// Generates a random number in the interval [min, max]
-/// Returns min if range is invalid.
+/// @copydoc rnd_interface::value()
int32 rnd_value(int32 min, int32 max)
{
- if( min >= max )
+ if (min >= max)
return min;
- return min + (int32)(rnd_uniform()*(max-min+1));
+ return min + (int32)(rnd->uniform()*(max-min+1));
}
-
-/// Generates a random number in the interval [0.0, 1.0)
-/// NOTE: interval is open ended, so 1.0 is excluded
+/// @copydoc rnd_interface::uniform()
double rnd_uniform(void)
{
return ((uint32)genrand_int32())*(1.0/4294967296.0);// divided by 2^32
}
-
-/// Generates a random number in the interval [0.0, 1.0) with 53-bit resolution
-/// NOTE: interval is open ended, so 1.0 is excluded
-/// NOTE: 53 bits is the maximum precision of a double
+/// @copydoc rnd_interface::uniform53()
double rnd_uniform53(void)
{
return genrand_res53();
}
+
+/// Interface base initialization.
+void rnd_defaults(void)
+{
+ rnd = &rnd_s;
+ rnd->init = rnd_init;
+ rnd->final = rnd_final;
+ rnd->seed = rnd_seed;
+ rnd->random = rnd_random;
+ rnd->roll = rnd_roll;
+ rnd->value = rnd_value;
+ rnd->uniform = rnd_uniform;
+ rnd->uniform53 = rnd_uniform53;
+}
diff --git a/src/common/random.h b/src/common/random.h
index 0b5abbcdc..1b249ef19 100644
--- a/src/common/random.h
+++ b/src/common/random.h
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
@@ -21,17 +21,81 @@
#ifndef COMMON_RANDOM_H
#define COMMON_RANDOM_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
+
+/** @file
+ * The random number generator interface.
+ */
+
+/// Random interface.
+struct rnd_interface {
+ /**
+ * Interface initialization.
+ *
+ * During initialization, the RNG is seeded with a random seed.
+ */
+ void (*init) (void);
+
+ /// Interface finalization.
+ void (*final) (void);
+
+ /**
+ * Re-seeds the random number generator.
+ *
+ * @param seed The new seed.
+ */
+ void (*seed) (uint32 seed);
+
+ /**
+ * Generates a random number in the interval [0, SINT32_MAX].
+ */
+ int32 (*random) (void);
+
+ /**
+ * Generates a random number in the interval [0, dice_faces).
+ *
+ * @remark
+ * interval is open ended, so dice_faces is excluded (unless it's 0)
+ */
+ uint32 (*roll) (uint32 dice_faces);
+
+ /**
+ * Generates a random number in the interval [min, max].
+ *
+ * @retval min if range is invalid.
+ */
+ int32 (*value) (int32 min, int32 max);
+
+ /**
+ * Generates a random number in the interval [0.0, 1.0)
+ *
+ * @remark
+ * interval is open ended, so 1.0 is excluded
+ */
+ double (*uniform) (void);
+
+ /**
+ * Generates a random number in the interval [0.0, 1.0) with 53-bit resolution.
+ *
+ * 53 bits is the maximum precision of a double.
+ *
+ * @remark
+ * interval is open ended, so 1.0 is excluded
+ */
+ double (*uniform53) (void);
+};
+
+/**
+ * Utlity macro to call the frequently used rnd_interface#random().
+ *
+ * @related rnd_interface.
+ */
+#define rnd() rnd->random()
#ifdef HERCULES_CORE
-void rnd_init(void);
-void rnd_seed(uint32);
-
-int32 rnd(void);// [0, SINT32_MAX]
-uint32 rnd_roll(uint32 dice_faces);// [0, dice_faces)
-int32 rnd_value(int32 min, int32 max);// [min, max]
-double rnd_uniform(void);// [0.0, 1.0)
-double rnd_uniform53(void);// [0.0, 1.0)
+void rnd_defaults(void);
#endif // HERCULES_CORE
+HPShared struct rnd_interface *rnd; ///< Pointer to the random interface.
+
#endif /* COMMON_RANDOM_H */
diff --git a/src/common/spinlock.h b/src/common/spinlock.h
index 4d9c4c668..c04416285 100644
--- a/src/common/spinlock.h
+++ b/src/common/spinlock.h
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) rAthena Project (www.rathena.org)
*
* Hercules is free software: you can redistribute it and/or modify
@@ -37,74 +37,75 @@
#endif
#ifdef WIN32
-
-typedef struct __declspec( align(64) ) SPIN_LOCK{
+struct __declspec(align(64)) spin_lock {
volatile LONG lock;
volatile LONG nest;
volatile LONG sync_lock;
-} SPIN_LOCK;
+};
#else
-typedef struct SPIN_LOCK{
- volatile int32 lock;
- volatile int32 nest; // nesting level.
-
- volatile int32 sync_lock;
-} __attribute__((aligned(64))) SPIN_LOCK;
+struct spin_lock {
+ volatile int32 lock;
+ volatile int32 nest; // nesting level.
+ volatile int32 sync_lock;
+} __attribute__((aligned(64)));
#endif
-
#ifdef HERCULES_CORE
-static forceinline void InitializeSpinLock(SPIN_LOCK *lck){
- lck->lock = 0;
- lck->nest = 0;
- lck->sync_lock = 0;
+static forceinline void InitializeSpinLock(struct spin_lock *lck)
+{
+ lck->lock = 0;
+ lck->nest = 0;
+ lck->sync_lock = 0;
}
-static forceinline void FinalizeSpinLock(SPIN_LOCK *lck){
+static forceinline void FinalizeSpinLock(struct spin_lock *lck)
+{
return;
}
-#define getsynclock(l) do { if(InterlockedCompareExchange((l), 1, 0) == 0) break; rathread_yield(); } while(/*always*/1)
+#define getsynclock(l) do { if(InterlockedCompareExchange((l), 1, 0) == 0) break; thread->yield(); } while(/*always*/1)
#define dropsynclock(l) do { InterlockedExchange((l), 0); } while(0)
-static forceinline void EnterSpinLock(SPIN_LOCK *lck){
- int tid = rathread_get_tid();
+static forceinline void EnterSpinLock(struct spin_lock *lck)
+{
+ int tid = thread->get_tid();
- // Get Sync Lock && Check if the requester thread already owns the lock.
- // if it owns, increase nesting level
- getsynclock(&lck->sync_lock);
- if(InterlockedCompareExchange(&lck->lock, tid, tid) == tid){
- InterlockedIncrement(&lck->nest);
- dropsynclock(&lck->sync_lock);
- return; // Got Lock
- }
- // drop sync lock
+ // Get Sync Lock && Check if the requester thread already owns the lock.
+ // if it owns, increase nesting level
+ getsynclock(&lck->sync_lock);
+ if (InterlockedCompareExchange(&lck->lock, tid, tid) == tid) {
+ InterlockedIncrement(&lck->nest);
dropsynclock(&lck->sync_lock);
-
- // Spin until we've got it !
- while(1){
- if(InterlockedCompareExchange(&lck->lock, tid, 0) == 0){
- InterlockedIncrement(&lck->nest);
- return; // Got Lock
- }
- rathread_yield(); // Force ctxswitch to another thread.
+ return; // Got Lock
+ }
+ // drop sync lock
+ dropsynclock(&lck->sync_lock);
+
+ // Spin until we've got it !
+ while (true) {
+ if (InterlockedCompareExchange(&lck->lock, tid, 0) == 0) {
+ InterlockedIncrement(&lck->nest);
+ return; // Got Lock
}
+ thread->yield(); // Force ctxswitch to another thread.
+ }
}
-static forceinline void LeaveSpinLock(SPIN_LOCK *lck){
- int tid = rathread_get_tid();
+static forceinline void LeaveSpinLock(struct spin_lock *lck)
+{
+ int tid = thread->get_tid();
- getsynclock(&lck->sync_lock);
+ getsynclock(&lck->sync_lock);
- if(InterlockedCompareExchange(&lck->lock, tid, tid) == tid){ // this thread owns the lock.
- if(InterlockedDecrement(&lck->nest) == 0)
- InterlockedExchange(&lck->lock, 0); // Unlock!
- }
+ if (InterlockedCompareExchange(&lck->lock, tid, tid) == tid) { // this thread owns the lock.
+ if (InterlockedDecrement(&lck->nest) == 0)
+ InterlockedExchange(&lck->lock, 0); // Unlock!
+ }
- dropsynclock(&lck->sync_lock);
+ dropsynclock(&lck->sync_lock);
}
#endif // HERCULES_CORE
diff --git a/src/common/thread.c b/src/common/thread.c
index b724344e6..aaafab943 100644
--- a/src/common/thread.c
+++ b/src/common/thread.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) rAthena Project (www.rathena.org)
*
* Hercules is free software: you can redistribute it and/or modify
@@ -20,10 +20,6 @@
*/
#define HERCULES_CORE
-// Basic Threading abstraction (for pthread / win32 based systems)
-//
-// Author: Florian Wilkemeyer <fw@f-ws.de>
-
#include "thread.h"
#include "common/cbasetypes.h"
@@ -48,13 +44,22 @@
#define HAS_TLS
#endif
-#define RA_THREADS_MAX 64
+/** @file
+ * Thread interface implementation.
+ * @author Florian Wilkemeyer <fw@f-ws.de>
+ */
+
+struct thread_interface thread_s;
+struct thread_interface *thread;
-struct rAthread {
+/// The maximum amount of threads.
+#define THREADS_MAX 64
+
+struct thread_handle {
unsigned int myID;
- RATHREAD_PRIO prio;
- rAthreadProc proc;
+ enum thread_priority prio;
+ threadFunc proc;
void *param;
#ifdef WIN32
@@ -68,16 +73,17 @@ struct rAthread {
__thread int g_rathread_ID = -1;
#endif
-///
-/// Subystem Code
-///
-static struct rAthread l_threads[RA_THREADS_MAX];
+// Subystem Code
+
+static struct thread_handle l_threads[THREADS_MAX];
-void rathread_init(void) {
- register unsigned int i;
- memset(&l_threads, 0x00, RA_THREADS_MAX * sizeof(struct rAthread) );
+/// @copydoc thread_interface::init()
+void thread_init(void)
+{
+ register int i;
+ memset(&l_threads, 0x00, THREADS_MAX * sizeof(struct thread_handle));
- for(i = 0; i < RA_THREADS_MAX; i++){
+ for (i = 0; i < THREADS_MAX; i++) {
l_threads[i].myID = i;
}
@@ -85,46 +91,53 @@ void rathread_init(void) {
#ifdef HAS_TLS
g_rathread_ID = 0;
#endif
- l_threads[0].prio = RAT_PRIO_NORMAL;
- l_threads[0].proc = (rAthreadProc)0xDEADCAFE;
+ l_threads[0].prio = THREADPRIO_NORMAL;
+ l_threads[0].proc = (threadFunc)0xDEADCAFE;
-}//end: rathread_init()
+}
-void rathread_final(void) {
- register unsigned int i;
+/// @copydoc thread_interface::final()
+void thread_final(void)
+{
+ register int i;
// Unterminated Threads Left?
- // Shouldn't happen ..
- // Kill 'em all!
- //
- for(i = 1; i < RA_THREADS_MAX; i++){
- if(l_threads[i].proc != NULL){
- ShowWarning("rAthread_final: unterminated Thread (tid %u entryPoint %p) - forcing to terminate (kill)\n", i, l_threads[i].proc);
- rathread_destroy(&l_threads[i]);
+ // Shouldn't happen ... Kill 'em all!
+ for (i = 1; i < THREADS_MAX; i++) {
+ if (l_threads[i].proc != NULL){
+ ShowWarning("thread_final: unterminated Thread (tid %d entry_point %p) - forcing to terminate (kill)\n", i, l_threads[i].proc);
+ thread->destroy(&l_threads[i]);
}
}
+}
-}//end: rathread_final()
-
-// gets called whenever a thread terminated ..
-static void rat_thread_terminated(rAthread *handle) {
+/**
+ * Gets called whenever a thread terminated.
+ *
+ * @param handle The terminated thread's handle.
+ */
+static void thread_terminated(struct thread_handle *handle)
+{
// Preserve handle->myID and handle->hThread, set everything else to its default value
handle->param = NULL;
handle->proc = NULL;
- handle->prio = RAT_PRIO_NORMAL;
-}//end: rat_thread_terminated()
+ handle->prio = THREADPRIO_NORMAL;
+}
#ifdef WIN32
-DWORD WINAPI raThreadMainRedirector(LPVOID p){
+DWORD WINAPI thread_main_redirector(LPVOID p)
+{
#else
-static void *raThreadMainRedirector( void *p ){
+static void *thread_main_redirector(void *p)
+{
sigset_t set; // on Posix Thread platforms
#endif
void *ret;
+ struct thread_handle *self = p;
// Update myID @ TLS to right id.
#ifdef HAS_TLS
- g_rathread_ID = ((rAthread*)p)->myID;
+ g_rathread_ID = self->myID;
#endif
#ifndef WIN32
@@ -138,66 +151,68 @@ static void *raThreadMainRedirector( void *p ){
(void)sigaddset(&set, SIGPIPE);
pthread_sigmask(SIG_BLOCK, &set, NULL);
-
#endif
- ret = ((rAthread*)p)->proc( ((rAthread*)p)->param ) ;
+ ret = self->proc(self->param);
#ifdef WIN32
- CloseHandle( ((rAthread*)p)->hThread );
+ CloseHandle(self->hThread);
#endif
- rat_thread_terminated( (rAthread*)p );
+ thread_terminated(self);
#ifdef WIN32
return (DWORD)ret;
#else
return ret;
#endif
-}//end: raThreadMainRedirector()
+}
+
+// API Level
-///
-/// API Level
-///
-rAthread *rathread_create(rAthreadProc entryPoint, void *param) {
- return rathread_createEx( entryPoint, param, (1<<23) /*8MB*/, RAT_PRIO_NORMAL );
-}//end: rathread_create()
+/// @copydoc thread_interface::create()
+struct thread_handle *thread_create(threadFunc entry_point, void *param)
+{
+ return thread->create_opt(entry_point, param, (1<<23) /*8MB*/, THREADPRIO_NORMAL);
+}
-rAthread *rathread_createEx(rAthreadProc entryPoint, void *param, size_t szStack, RATHREAD_PRIO prio) {
+/// @copydoc thread_interface::create_opt()
+struct thread_handle *thread_create_opt(threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio)
+{
#ifndef WIN32
pthread_attr_t attr;
#endif
size_t tmp;
- unsigned int i;
- rAthread *handle = NULL;
+ int i;
+ struct thread_handle *handle = NULL;
// given stacksize aligned to systems pagesize?
- tmp = szStack % sysinfo->getpagesize();
- if(tmp != 0)
- szStack += tmp;
+ tmp = stack_size % sysinfo->getpagesize();
+ if (tmp != 0)
+ stack_size += tmp;
// Get a free Thread Slot.
- for(i = 0; i < RA_THREADS_MAX; i++){
+ for (i = 0; i < THREADS_MAX; i++) {
if(l_threads[i].proc == NULL){
handle = &l_threads[i];
break;
}
}
- if(handle == NULL){
- ShowError("rAthread: cannot create new thread (entryPoint: %p) - no free thread slot found!", entryPoint);
+ if (handle == NULL) {
+ ShowError("thread_create_opt: cannot create new thread (entry_point: %p) - no free thread slot found!", entry_point);
return NULL;
}
- handle->proc = entryPoint;
+ handle->proc = entry_point;
handle->param = param;
#ifdef WIN32
- handle->hThread = CreateThread(NULL, szStack, raThreadMainRedirector, (void*)handle, 0, NULL);
+ handle->hThread = CreateThread(NULL, stack_size, thread_main_redirector, handle, 0, NULL);
#else
pthread_attr_init(&attr);
- pthread_attr_setstacksize(&attr, szStack);
+ pthread_attr_setstacksize(&attr, stack_size);
- if(pthread_create(&handle->hThread, &attr, raThreadMainRedirector, (void*)handle) != 0){
+ if (pthread_create(&handle->hThread, &attr, thread_main_redirector, handle) != 0) {
handle->proc = NULL;
handle->param = NULL;
return NULL;
@@ -205,99 +220,122 @@ rAthread *rathread_createEx(rAthreadProc entryPoint, void *param, size_t szStack
pthread_attr_destroy(&attr);
#endif
- rathread_prio_set( handle, prio );
+ thread->prio_set(handle, prio);
return handle;
-}//end: rathread_createEx
+}
-void rathread_destroy(rAthread *handle) {
+/// @copydoc thread_interface::destroy()
+void thread_destroy(struct thread_handle *handle)
+{
#ifdef WIN32
- if( TerminateThread(handle->hThread, 0) != FALSE){
+ if (TerminateThread(handle->hThread, 0) != FALSE) {
CloseHandle(handle->hThread);
- rat_thread_terminated(handle);
+ thread_terminated(handle);
}
#else
- if( pthread_cancel( handle->hThread ) == 0){
+ if (pthread_cancel(handle->hThread) == 0) {
// We have to join it, otherwise pthread wont re-cycle its internal resources assoc. with this thread.
- pthread_join( handle->hThread, NULL );
+ pthread_join(handle->hThread, NULL);
// Tell our manager to release resources ;)
- rat_thread_terminated(handle);
+ thread_terminated(handle);
}
#endif
-}//end: rathread_destroy()
+}
-rAthread *rathread_self(void) {
+struct thread_handle *thread_self(void)
+{
#ifdef HAS_TLS
- rAthread *handle = &l_threads[g_rathread_ID];
+ struct thread_handle *handle = &l_threads[g_rathread_ID];
- if(handle->proc != NULL) // entry point set, so its used!
+ if (handle->proc != NULL) // entry point set, so its used!
return handle;
#else
// .. so no tls means we have to search the thread by its api-handle ..
int i;
- #ifdef WIN32
- HANDLE hSelf;
- hSelf = GetCurrent = GetCurrentThread();
- #else
- pthread_t hSelf;
- hSelf = pthread_self();
- #endif
+#ifdef WIN32
+ HANDLE hSelf;
+ hSelf = GetCurrent = GetCurrentThread();
+#else
+ pthread_t hSelf;
+ hSelf = pthread_self();
+#endif
- for(i = 0; i < RA_THREADS_MAX; i++){
- if(l_threads[i].hThread == hSelf && l_threads[i].proc != NULL)
+ for (i = 0; i < THREADS_MAX; i++) {
+ if (l_threads[i].hThread == hSelf && l_threads[i].proc != NULL)
return &l_threads[i];
}
#endif
return NULL;
-}//end: rathread_self()
+}
-int rathread_get_tid(void) {
-
-#ifdef HAS_TLS
+/// @copydoc thread_interface::get_tid()
+int thread_get_tid(void)
+{
+#if defined(HAS_TLS)
return g_rathread_ID;
+#elif defined(WIN32)
+ return (int)GetCurrentThreadId();
#else
- // TODO
- #ifdef WIN32
- return (int)GetCurrentThreadId();
- #else
- return (int)pthread_self();
- #endif
+ return (int)pthread_self();
#endif
+}
-}//end: rathread_get_tid()
-
-bool rathread_wait(rAthread *handle, void **out_exitCode) {
+/// @copydoc thread_interface::wait()
+bool thread_wait(struct thread_handle *handle, void **out_exit_code)
+{
// Hint:
// no thread data cleanup routine call here!
// its managed by the callProxy itself..
- //
#ifdef WIN32
WaitForSingleObject(handle->hThread, INFINITE);
return true;
#else
- if(pthread_join(handle->hThread, out_exitCode) == 0)
+ if (pthread_join(handle->hThread, out_exit_code) == 0)
return true;
return false;
#endif
-}//end: rathread_wait()
+}
-void rathread_prio_set(rAthread *handle, RATHREAD_PRIO prio) {
- handle->prio = RAT_PRIO_NORMAL;
+/// @copydoc thread_interface::prio_set()
+void thread_prio_set(struct thread_handle *handle, enum thread_priority prio)
+{
+ handle->prio = THREADPRIO_NORMAL;
//@TODO
-}//end: rathread_prio_set()
+}
-RATHREAD_PRIO rathread_prio_get(rAthread *handle) {
+/// @copydoc thread_interface::prio_get()
+enum thread_priority thread_prio_get(struct thread_handle *handle)
+{
return handle->prio;
-}//end: rathread_prio_get()
+}
-void rathread_yield(void) {
+/// @copydoc thread_interface::yield()
+void thread_yield(void) {
#ifdef WIN32
SwitchToThread();
#else
sched_yield();
#endif
-}//end: rathread_yield()
+}
+
+/// Interface base initialization.
+void thread_defaults(void)
+{
+ thread = &thread_s;
+ thread->init = thread_init;
+ thread->final = thread_final;
+ thread->create = thread_create;
+ thread->create_opt = thread_create_opt;
+ thread->destroy = thread_destroy;
+ thread->self = thread_self;
+ thread->get_tid = thread_get_tid;
+ thread->wait = thread_wait;
+ thread->prio_set = thread_prio_set;
+ thread->prio_get = thread_prio_get;
+ thread->yield = thread_yield;
+}
diff --git a/src/common/thread.h b/src/common/thread.h
index 261735306..c668afbb4 100644
--- a/src/common/thread.h
+++ b/src/common/thread.h
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) rAthena Project (www.rathena.org)
*
* Hercules is free software: you can redistribute it and/or modify
@@ -21,114 +21,136 @@
#ifndef COMMON_THREAD_H
#define COMMON_THREAD_H
-#include "common/cbasetypes.h"
+#include "common/hercules.h"
-typedef struct rAthread rAthread;
-typedef void* (*rAthreadProc)(void*);
-
-typedef enum RATHREAD_PRIO {
- RAT_PRIO_LOW = 0,
- RAT_PRIO_NORMAL,
- RAT_PRIO_HIGH
-} RATHREAD_PRIO;
-
-
-#ifdef HERCULES_CORE
-/**
- * Creates a new Thread
- *
- * @param entyPoint - entryProc,
- * @param param - general purpose parameter, would be given as parameter to the thread's entry point.
- *
- * @return not NULL if success
+/** @file
+ * Basic Threading abstraction (for pthread / win32 based systems).
*/
-rAthread *rathread_create(rAthreadProc entryPoint, void *param);
+/* Opaque Types */
+struct thread_handle; ///< Thread handle.
+typedef void *(*threadFunc)(void *); ///< Thread entry point function.
+
+/* Enums */
+
+/// Thread priority
+enum thread_priority {
+ THREADPRIO_LOW = 0,
+ THREADPRIO_NORMAL,
+ THREADPRIO_HIGH
+};
+
+/// The thread interface
+struct thread_interface {
+ /// Interface initialization.
+ void (*init) (void);
+
+ /// Interface finalization.
+ void (*final) (void);
+
+ /**
+ * Creates a new Thread.
+ *
+ * @param enty_point Thread's entry point.
+ * @param param General purpose parameter, would be given as
+ * parameter to the thread's entry point.
+ *
+ * @return The created thread object.
+ * @retval NULL in vase of failure.
+ */
+ struct thread_handle *(*create) (threadFunc entry_point, void *param);
+
+ /**
+ * Creates a new Thread (with more creation options).
+ *
+ * @param enty_point Thread's entry point.
+ * @param param General purpose parameter, would be given as
+ * parameter to the thread's entry point.
+ * @param stack_size Stack Size in bytes.
+ * @param prio Priority of the Thread in the OS scheduler.
+ *
+ * @return The created thread object.
+ * @retval NULL in case of failure.
+ */
+ struct thread_handle *(*create_opt) (threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio);
+
+ /**
+ * Destroys the given Thread immediately.
+ *
+ * @remark
+ * The Handle gets invalid after call! don't use it afterwards.
+ *
+ * @param handle The thread to destroy.
+ */
+ void (*destroy) (struct thread_handle *handle);
+
+ /**
+ * Returns the thread handle of the thread calling this function.
+ *
+ * @remark
+ * This won't work in the program's main thread.
+ *
+ * @warning
+ * The underlying implementation might not perform very well, cache
+ * the value received!
+ *
+ * @return the thread handle.
+ * @retval NULL in case of failure.
+ */
+ struct thread_handle *(*self) (void);
+
+ /**
+ * Returns own thread id (TID).
+ *
+ * @remark
+ * This is an unique identifier for the calling thread, and depends
+ * on platform/ compiler, and may not be the systems Thread ID!
+ *
+ * @return the thread ID.
+ * @retval -1 in case of failure.
+ */
+ int (*get_tid) (void);
+
+ /**
+ * Waits for the given thread to terminate.
+ *
+ * @param[in] handle The thread to wait (join) for.
+ * @param[out] out_exit_code Pointer to return the exit code of the
+ * given thread after termination (optional).
+ *
+ * @retval true if the given thread has been terminated.
+ */
+ bool (*wait) (struct thread_handle *handle, void **out_exit_code);
+
+ /**
+ * Sets the given priority in the OS scheduler.
+ *
+ * @param handle The thread to set the priority for.
+ * @param prio The priority to set (@see enum thread_priority).
+ */
+ void (*prio_set) (struct thread_handle *handle, enum thread_priority prio);
+
+ /**
+ * Gets the current priority of the given thread.
+ *
+ * @param handle The thread to get the priority for.
+ */
+ enum thread_priority (*prio_get) (struct thread_handle *handle);
+
+ /**
+ * Tells the OS scheduler to yield the execution of the calling thread.
+ *
+ * @remark
+ * This will not "pause" the thread, it just allows the OS to spend
+ * the remaining time of the slice to another thread.
+ */
+ void (*yield) (void);
+};
-/**
- * Creates a new Thread (with more creation options)
- *
- * @param entyPoint - entryProc,
- * @param param - general purpose parameter, would be given as parameter to the thread's entry point
- * @param szStack - stack Size in bytes
- * @param prio - Priority of the Thread @ OS Scheduler..
- *
- * @return not NULL if success
- */
-rAthread *rathread_createEx(rAthreadProc entryPoint, void *param, size_t szStack, RATHREAD_PRIO prio);
-
-
-/**
- * Destroys the given Thread immediately
- *
- * @note The Handle gets invalid after call! don't use it afterwards.
- *
- * @param handle - thread to destroy.
- */
-void rathread_destroy(rAthread *handle);
-
-
-/**
- * Returns the thread handle of the thread calling this function
- *
- * @note this wont work @ programs main thread
- * @note the underlying implementation might not perform very well, cache the value received!
- *
- * @return not NULL if success
- */
-rAthread *rathread_self(void);
-
-
-/**
- * Returns own thread id (TID)
- *
- * @note this is an unique identifier for the calling thread, and
- * depends on platform/ compiler, and may not be the systems Thread ID!
- *
- * @return -1 when fails, otherwise >= 0
- */
-int rathread_get_tid(void);
-
-
-/**
- * Waits for the given thread to terminate
- *
- * @param handle - thread to wait (join) for
- * @param out_Exitcode - [OPTIONAL] - if given => Exitcode (value) of the given thread - if it's terminated
- *
- * @return true - if the given thread has been terminated.
- */
-bool rathread_wait(rAthread *handle, void **out_exitCode);
-
-
-/**
- * Sets the given PRIORITY @ OS Task Scheduler
- *
- * @param handle - thread to set prio for
- * @param rio - the priority (RAT_PRIO_LOW ... )
- */
-void rathread_prio_set(rAthread *handle, RATHREAD_PRIO prio);
-
-
-/**
- * Gets the current Prio of the given thread
- *
- * @param handle - the thread to get the prio for.
- */
-RATHREAD_PRIO rathread_prio_get(rAthread *handle);
-
-
-/**
- * Tells the OS scheduler to yield the execution of the calling thread
- *
- * @note: this will not "pause" the thread,
- * it just allows the OS to spend the remaining time
- * of the slice to another thread.
- */
-void rathread_yield(void);
-
-void rathread_init(void);
-void rathread_final(void);
+#ifdef HERCULES_CORE
+void thread_defaults(void);
#endif // HERCULES_CORE
+HPShared struct thread_interface *thread; ///< Pointer to the thread interface.
+
#endif /* COMMON_THREAD_H */
diff --git a/src/login/lclif.c b/src/login/lclif.c
index 9515c5940..3ed257e85 100644
--- a/src/login/lclif.c
+++ b/src/login/lclif.c
@@ -86,7 +86,7 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN(int fd, struct login_session_data *sd)
safestrncpy(sd->passwd, packet->password, PASSWD_LEN);
if (login->config->use_md5_passwds)
- MD5_String(sd->passwd, sd->passwd);
+ md5->string(sd->passwd, sd->passwd);
sd->passwdenc = PWENC_NONE;
login->client_login(fd, sd);
@@ -160,7 +160,7 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN_PCBANG(int fd, struct login_session_da
safestrncpy(sd->passwd, packet->password, PASSWD_LEN);
if (login->config->use_md5_passwds)
- MD5_String(sd->passwd, sd->passwd);
+ md5->string(sd->passwd, sd->passwd);
sd->passwdenc = PWENC_NONE;
login->client_login(fd, sd);
@@ -183,7 +183,7 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN_HAN(int fd, struct login_session_data
safestrncpy(sd->passwd, packet->password, PASSWD_LEN);
if (login->config->use_md5_passwds)
- MD5_String(sd->passwd, sd->passwd);
+ md5->string(sd->passwd, sd->passwd);
sd->passwdenc = PWENC_NONE;
login->client_login(fd, sd);
@@ -209,7 +209,7 @@ enum parsefunc_rcode lclif_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_d
safestrncpy(sd->passwd, packet->t1, min(tokenlen + 1, PASSWD_LEN)); // Variable-length field, don't copy more than necessary
if (login->config->use_md5_passwds)
- MD5_String(sd->passwd, sd->passwd);
+ md5->string(sd->passwd, sd->passwd);
sd->passwdenc = PWENC_NONE;
login->client_login(fd, sd);
@@ -222,7 +222,7 @@ enum parsefunc_rcode lclif_parse_CA_REQ_HASH(int fd, struct login_session_data *
{
memset(sd->md5key, '\0', sizeof(sd->md5key));
sd->md5keylen = (uint16)(12 + rnd() % 4);
- MD5_Salt(sd->md5keylen, sd->md5key);
+ md5->salt(sd->md5keylen, sd->md5key);
lclif->coding_key(fd, sd);
return PACKET_VALID;
diff --git a/src/login/login.c b/src/login/login.c
index a8ba3d9b7..7f5f78a4d 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -239,7 +239,7 @@ bool login_check_encrypted(const char* str1, const char* str2, const char* passw
nullpo_ret(str2);
nullpo_ret(passwd);
safesnprintf(tmpstr, sizeof(tmpstr), "%s%s", str1, str2);
- MD5_String(tmpstr, md5str);
+ md5->string(tmpstr, md5str);
return (0==strcmp(passwd, md5str));
}
@@ -1378,7 +1378,7 @@ void login_parse_request_connection(int fd, struct login_session_data* sd, const
safestrncpy(sd->userid, RFIFOP(fd,2), NAME_LENGTH);
safestrncpy(sd->passwd, RFIFOP(fd,26), NAME_LENGTH);
if (login->config->use_md5_passwds)
- MD5_String(sd->passwd, sd->passwd);
+ md5->string(sd->passwd, sd->passwd);
sd->passwdenc = PWENC_NONE;
sd->version = login->config->client_version_to_connect; // hack to skip version check
server_ip = ntohl(RFIFOL(fd,54));
@@ -1529,14 +1529,14 @@ int login_config_read(const char *cfgName)
login->config->client_hash_check = config_switch(w2);
else if(!strcmpi(w1, "client_hash")) {
int group = 0;
- char md5[33];
- memset(md5, '\0', 33);
+ char md5hash[33];
+ memset(md5hash, '\0', 33);
- if (sscanf(w2, "%d, %32s", &group, md5) == 2) {
+ if (sscanf(w2, "%d, %32s", &group, md5hash) == 2) {
struct client_hash_node *nnode;
CREATE(nnode, struct client_hash_node, 1);
- if (strcmpi(md5, "disabled") == 0) {
+ if (strcmpi(md5hash, "disabled") == 0) {
nnode->hash[0] = '\0';
} else {
int i;
@@ -1544,7 +1544,7 @@ int login_config_read(const char *cfgName)
char buf[3];
unsigned int byte;
- memcpy(buf, &md5[i], 2);
+ memcpy(buf, &md5hash[i], 2);
buf[2] = 0;
sscanf(buf, "%x", &byte);
diff --git a/src/map/battle.c b/src/map/battle.c
index 944271efa..76b74a766 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -2431,7 +2431,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
RE_LVL_DMOD(100);
break;
case LG_OVERBRAND_PLUSATK:
- skillratio = 200 * skill_lv + rnd_value( 10, 100);
+ skillratio = 200 * skill_lv + rnd->value(10, 100);
RE_LVL_DMOD(100);
break;
case LG_RAYOFGENESIS:
diff --git a/src/map/clif.c b/src/map/clif.c
index 9619a7201..3069e95ad 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
@@ -12878,7 +12878,8 @@ bool clif_validate_emblem(const uint8 *emblem, unsigned long emblem_len) {
int header = 0, bitmap = 0, offbits = 0, palettesize = 0;
nullpo_retr(false, emblem);
- if( decode_zip(buf, &buf_len, emblem, emblem_len) != 0 || buf_len < BITMAPFILEHEADER_SIZE + BITMAPINFOHEADER_SIZE
+ if (grfio->decode_zip(buf, &buf_len, emblem, emblem_len) != 0
+ || buf_len < BITMAPFILEHEADER_SIZE + BITMAPINFOHEADER_SIZE
|| RBUFW(buf,0) != 0x4d42 // BITMAPFILEHEADER.bfType (signature)
|| RBUFL(buf,2) != buf_len // BITMAPFILEHEADER.bfSize (file size)
|| RBUFL(buf,14) != BITMAPINFOHEADER_SIZE // BITMAPINFOHEADER.biSize (other headers are not supported)
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index 66cce23e6..080a314b8 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -356,14 +356,14 @@ bool homunculus_levelup(struct homun_data *hd) {
max = &hd->homunculusDB->gmax;
min = &hd->homunculusDB->gmin;
- growth_max_hp = rnd_value(min->HP, max->HP);
- growth_max_sp = rnd_value(min->SP, max->SP);
- growth_str = rnd_value(min->str, max->str);
- growth_agi = rnd_value(min->agi, max->agi);
- growth_vit = rnd_value(min->vit, max->vit);
- growth_dex = rnd_value(min->dex, max->dex);
- growth_int = rnd_value(min->int_,max->int_);
- growth_luk = rnd_value(min->luk, max->luk);
+ growth_max_hp = rnd->value(min->HP, max->HP);
+ growth_max_sp = rnd->value(min->SP, max->SP);
+ growth_str = rnd->value(min->str, max->str);
+ growth_agi = rnd->value(min->agi, max->agi);
+ growth_vit = rnd->value(min->vit, max->vit);
+ growth_dex = rnd->value(min->dex, max->dex);
+ growth_int = rnd->value(min->int_,max->int_);
+ growth_luk = rnd->value(min->luk, max->luk);
//Aegis discards the decimals in the stat growth values!
growth_str-=growth_str%10;
@@ -432,14 +432,14 @@ bool homunculus_evolve(struct homun_data *hd) {
hom = &hd->homunculus;
max = &hd->homunculusDB->emax;
min = &hd->homunculusDB->emin;
- hom->max_hp += rnd_value(min->HP, max->HP);
- hom->max_sp += rnd_value(min->SP, max->SP);
- hom->str += 10*rnd_value(min->str, max->str);
- hom->agi += 10*rnd_value(min->agi, max->agi);
- hom->vit += 10*rnd_value(min->vit, max->vit);
- hom->int_+= 10*rnd_value(min->int_,max->int_);
- hom->dex += 10*rnd_value(min->dex, max->dex);
- hom->luk += 10*rnd_value(min->luk, max->luk);
+ hom->max_hp += rnd->value(min->HP, max->HP);
+ hom->max_sp += rnd->value(min->SP, max->SP);
+ hom->str += 10*rnd->value(min->str, max->str);
+ hom->agi += 10*rnd->value(min->agi, max->agi);
+ hom->vit += 10*rnd->value(min->vit, max->vit);
+ hom->int_+= 10*rnd->value(min->int_,max->int_);
+ hom->dex += 10*rnd->value(min->dex, max->dex);
+ hom->luk += 10*rnd->value(min->luk, max->luk);
hom->intimacy = 500;
unit->remove_map(&hd->bl, CLR_OUTSIGHT, ALC_MARK);
@@ -848,7 +848,7 @@ bool homunculus_call(struct map_session_data *sd) {
nullpo_retr(false, sd);
if (!sd->status.hom_id) //Create a new homun.
- return homun->creation_request(sd, HM_CLASS_BASE + rnd_value(0, 7));
+ return homun->creation_request(sd, HM_CLASS_BASE + rnd->value(0, 7));
// If homunc not yet loaded, load it
if (!sd->hd)
@@ -1075,14 +1075,14 @@ bool homunculus_shuffle(struct homun_data *hd) {
//Evolved bonuses
struct s_homunculus *hom = &hd->homunculus;
struct h_stats *max = &hd->homunculusDB->emax, *min = &hd->homunculusDB->emin;
- hom->max_hp += rnd_value(min->HP, max->HP);
- hom->max_sp += rnd_value(min->SP, max->SP);
- hom->str += 10*rnd_value(min->str, max->str);
- hom->agi += 10*rnd_value(min->agi, max->agi);
- hom->vit += 10*rnd_value(min->vit, max->vit);
- hom->int_+= 10*rnd_value(min->int_,max->int_);
- hom->dex += 10*rnd_value(min->dex, max->dex);
- hom->luk += 10*rnd_value(min->luk, max->luk);
+ hom->max_hp += rnd->value(min->HP, max->HP);
+ hom->max_sp += rnd->value(min->SP, max->SP);
+ hom->str += 10*rnd->value(min->str, max->str);
+ hom->agi += 10*rnd->value(min->agi, max->agi);
+ hom->vit += 10*rnd->value(min->vit, max->vit);
+ hom->int_+= 10*rnd->value(min->int_,max->int_);
+ hom->dex += 10*rnd->value(min->dex, max->dex);
+ hom->luk += 10*rnd->value(min->luk, max->luk);
}
hd->homunculus.exp = exp;
diff --git a/src/map/map.c b/src/map/map.c
index 30c849ed1..c5ea7c1f3 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
@@ -2851,7 +2851,7 @@ void map_cellfromcache(struct map_data *m) {
size = (unsigned long)info->xs*(unsigned long)info->ys;
// TO-DO: Maybe handle the scenario, if the decoded buffer isn't the same size as expected? [Shinryo]
- decode_zip(decode_buffer, &size, m->cellPos+sizeof(struct map_cache_map_info), info->len);
+ grfio->decode_zip(decode_buffer, &size, m->cellPos+sizeof(struct map_cache_map_info), info->len);
CREATE(m->cell, struct mapcell, size);
// Set cell properties
@@ -3579,17 +3579,18 @@ void map_flags_init(void) {
int map_waterheight(char* mapname)
{
char fn[256];
- char *rsw, *found;
+ char *rsw = NULL;
+ const char *found;
nullpo_retr(NO_WATER, mapname);
//Look up for the rsw
snprintf(fn, sizeof(fn), "data\\%s.rsw", mapname);
- if ( (found = grfio_find_file(fn)) )
+ if ((found = grfio->find_file(fn)))
safestrncpy(fn, found, sizeof(fn)); // replace with real name
// read & convert fn
- rsw = (char *) grfio_read (fn);
+ rsw = grfio_read(fn);
if (rsw) {
//Load water height from file
int wh = (int) *(float*)(rsw+166);
@@ -3613,7 +3614,7 @@ int map_readgat (struct map_data* m)
nullpo_ret(m);
sprintf(filename, "data\\%s.gat", m->name);
- gat = (uint8 *) grfio_read(filename);
+ gat = grfio_read(filename);
if (gat == NULL)
return 0;
@@ -5677,8 +5678,8 @@ int do_final(void) {
map->map_db->destroy(map->map_db, map->db_final);
mapindex->final();
- if(map->enable_grf)
- grfio_final();
+ if (map->enable_grf)
+ grfio->final();
db_destroy(map->id_db);
db_destroy(map->pc_db);
@@ -6122,8 +6123,8 @@ int do_init(int argc, char *argv[])
}
}
- if(map->enable_grf)
- grfio_init(map->GRF_PATH_FILENAME);
+ if (map->enable_grf)
+ grfio->init(map->GRF_PATH_FILENAME);
map->readallmaps();
diff --git a/src/map/script.c b/src/map/script.c
index 90a70e48d..effe40ea5 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
@@ -16049,7 +16049,7 @@ BUILDIN(md5)
tmpstr = script_getstr(st,2);
md5str = (char *)aMalloc((32+1)*sizeof(char));
- MD5_String(tmpstr, md5str);
+ md5->string(tmpstr, md5str);
script_pushstr(st, md5str);
return true;
}
diff --git a/src/map/skill.c b/src/map/skill.c
index 76ee3d3fd..0b66c1ded 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -8827,9 +8827,9 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if (is_boss(bl)) break;
joblvbonus = ( sd ? sd->status.job_level : 50 );
//First we set the success chance based on the caster's build which increases the chance.
- rate = 10 * skill_lv + rnd_value( sstatus->dex / 12, sstatus->dex / 4 ) + joblvbonus + status->get_lv(src) / 10;
+ rate = 10 * skill_lv + rnd->value( sstatus->dex / 12, sstatus->dex / 4 ) + joblvbonus + status->get_lv(src) / 10;
// We then reduce the success chance based on the target's build.
- rate -= rnd_value( tstatus->agi / 6, tstatus->agi / 3 ) + tstatus->luk / 10 + ( dstsd ? (dstsd->max_weight / 10 - dstsd->weight / 10 ) / 100 : 0 ) + status->get_lv(bl) / 10;
+ rate -= rnd->value( tstatus->agi / 6, tstatus->agi / 3 ) + tstatus->luk / 10 + ( dstsd ? (dstsd->max_weight / 10 - dstsd->weight / 10 ) / 100 : 0 ) + status->get_lv(bl) / 10;
//Finally we set the minimum success chance cap based on the caster's skill level and DEX.
rate = cap_value( rate, skill_lv + sstatus->dex / 20, 100);
clif->skill_nodamage(src,bl,skill_id,0,sc_start(src,bl,type,rate,skill_lv,skill->get_time(skill_id,skill_lv)));
diff --git a/src/plugins/HPMHooking.c b/src/plugins/HPMHooking.c
index 4fb7911c2..0b98ea99f 100644
--- a/src/plugins/HPMHooking.c
+++ b/src/plugins/HPMHooking.c
@@ -97,6 +97,7 @@
#include "map/storage.h"
#include "map/trade.h"
#include "map/unit.h"
+#include "common/grfio.h"
#include "common/mapindex.h"
#else
#define HPM_SERVER_TYPE SERVER_TYPE_UNKNOWN
@@ -109,13 +110,18 @@
#include "common/conf.h"
#include "common/console.h"
#include "common/db.h"
+#include "common/des.h"
+#include "common/md5calc.h"
#include "common/memmgr.h"
+#include "common/mutex.h"
#include "common/nullpo.h"
+#include "common/random.h"
#include "common/showmsg.h"
#include "common/socket.h"
#include "common/sql.h"
#include "common/strlib.h"
#include "common/sysinfo.h"
+#include "common/thread.h"
#include "common/timer.h"
#include "common/utils.h"
diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc
index b6a0a28c0..4f033ccaf 100644
--- a/src/plugins/HPMHooking/HPMHooking.Defs.inc
+++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc
@@ -2271,6 +2271,12 @@ typedef void (*HPMHOOK_post_DB_init) (void);
typedef void (*HPMHOOK_pre_DB_final) (void);
typedef void (*HPMHOOK_post_DB_final) (void);
#endif // COMMON_DB_H
+#ifdef COMMON_DES_H /* des */
+typedef void (*HPMHOOK_pre_des_decrypt_block) (struct des_bit64 **block);
+typedef void (*HPMHOOK_post_des_decrypt_block) (struct des_bit64 *block);
+typedef void (*HPMHOOK_pre_des_decrypt) (unsigned char **data, size_t *size);
+typedef void (*HPMHOOK_post_des_decrypt) (unsigned char *data, size_t size);
+#endif // COMMON_DES_H
#ifdef MAP_DUEL_H /* duel */
typedef int (*HPMHOOK_pre_duel_create) (struct map_session_data **sd, const unsigned int *maxpl);
typedef int (*HPMHOOK_post_duel_create) (int retVal___, struct map_session_data *sd, const unsigned int maxpl);
@@ -2365,6 +2371,22 @@ typedef void (*HPMHOOK_post_geoip_final) (bool shutdown);
typedef void (*HPMHOOK_pre_geoip_init) (void);
typedef void (*HPMHOOK_post_geoip_init) (void);
#endif // CHAR_GEOIP_H
+#ifdef COMMON_GRFIO_H /* grfio */
+typedef void (*HPMHOOK_pre_grfio_init) (const char **fname);
+typedef void (*HPMHOOK_post_grfio_init) (const char *fname);
+typedef void (*HPMHOOK_pre_grfio_final) (void);
+typedef void (*HPMHOOK_post_grfio_final) (void);
+typedef void* (*HPMHOOK_pre_grfio_reads) (const char **fname, int **size);
+typedef void* (*HPMHOOK_post_grfio_reads) (void* retVal___, const char *fname, int *size);
+typedef const char* (*HPMHOOK_pre_grfio_find_file) (const char **fname);
+typedef const char* (*HPMHOOK_post_grfio_find_file) (const char* retVal___, const char *fname);
+typedef unsigned long (*HPMHOOK_pre_grfio_crc32) (const unsigned char **buf, unsigned int *len);
+typedef unsigned long (*HPMHOOK_post_grfio_crc32) (unsigned long retVal___, const unsigned char *buf, unsigned int len);
+typedef int (*HPMHOOK_pre_grfio_decode_zip) (void **dest, unsigned long **dest_len, const void **source, unsigned long *source_len);
+typedef int (*HPMHOOK_post_grfio_decode_zip) (int retVal___, void *dest, unsigned long *dest_len, const void *source, unsigned long source_len);
+typedef int (*HPMHOOK_pre_grfio_encode_zip) (void **dest, unsigned long **dest_len, const void **source, unsigned long *source_len);
+typedef int (*HPMHOOK_post_grfio_encode_zip) (int retVal___, void *dest, unsigned long *dest_len, const void *source, unsigned long source_len);
+#endif // COMMON_GRFIO_H
#ifdef MAP_GUILD_H /* guild */
typedef void (*HPMHOOK_pre_guild_init) (bool *minimal);
typedef void (*HPMHOOK_post_guild_init) (bool minimal);
@@ -4427,6 +4449,14 @@ typedef void (*HPMHOOK_post_mapreg_reload) (void);
typedef bool (*HPMHOOK_pre_mapreg_config_read) (const char **w1, const char **w2);
typedef bool (*HPMHOOK_post_mapreg_config_read) (bool retVal___, const char *w1, const char *w2);
#endif // MAP_MAPREG_H
+#ifdef COMMON_MD5CALC_H /* md5 */
+typedef void (*HPMHOOK_pre_md5_string) (const char **string, char **output);
+typedef void (*HPMHOOK_post_md5_string) (const char *string, char *output);
+typedef void (*HPMHOOK_pre_md5_binary) (const char **string, unsigned char **output);
+typedef void (*HPMHOOK_post_md5_binary) (const char *string, unsigned char *output);
+typedef void (*HPMHOOK_pre_md5_salt) (int *len, char **output);
+typedef void (*HPMHOOK_post_md5_salt) (int len, char *output);
+#endif // COMMON_MD5CALC_H
#ifdef MAP_MERCENARY_H /* mercenary */
typedef void (*HPMHOOK_pre_mercenary_init) (bool *minimal);
typedef void (*HPMHOOK_post_mercenary_init) (bool minimal);
@@ -4687,6 +4717,28 @@ typedef void (*HPMHOOK_post_mob_clear_spawninfo) (void);
typedef void (*HPMHOOK_pre_mob_destroy_mob_db) (int *index);
typedef void (*HPMHOOK_post_mob_destroy_mob_db) (int index);
#endif // MAP_MOB_H
+#ifdef COMMON_MUTEX_H /* mutex */
+typedef struct mutex_data* (*HPMHOOK_pre_mutex_create) (void);
+typedef struct mutex_data* (*HPMHOOK_post_mutex_create) (struct mutex_data* retVal___);
+typedef void (*HPMHOOK_pre_mutex_destroy) (struct mutex_data **m);
+typedef void (*HPMHOOK_post_mutex_destroy) (struct mutex_data *m);
+typedef void (*HPMHOOK_pre_mutex_lock) (struct mutex_data **m);
+typedef void (*HPMHOOK_post_mutex_lock) (struct mutex_data *m);
+typedef bool (*HPMHOOK_pre_mutex_trylock) (struct mutex_data **m);
+typedef bool (*HPMHOOK_post_mutex_trylock) (bool retVal___, struct mutex_data *m);
+typedef void (*HPMHOOK_pre_mutex_unlock) (struct mutex_data **m);
+typedef void (*HPMHOOK_post_mutex_unlock) (struct mutex_data *m);
+typedef struct cond_data* (*HPMHOOK_pre_mutex_cond_create) (void);
+typedef struct cond_data* (*HPMHOOK_post_mutex_cond_create) (struct cond_data* retVal___);
+typedef void (*HPMHOOK_pre_mutex_cond_destroy) (struct cond_data **c);
+typedef void (*HPMHOOK_post_mutex_cond_destroy) (struct cond_data *c);
+typedef void (*HPMHOOK_pre_mutex_cond_wait) (struct cond_data **c, struct mutex_data **m, sysint *timeout_ticks);
+typedef void (*HPMHOOK_post_mutex_cond_wait) (struct cond_data *c, struct mutex_data *m, sysint timeout_ticks);
+typedef void (*HPMHOOK_pre_mutex_cond_signal) (struct cond_data **c);
+typedef void (*HPMHOOK_post_mutex_cond_signal) (struct cond_data *c);
+typedef void (*HPMHOOK_pre_mutex_cond_broadcast) (struct cond_data **c);
+typedef void (*HPMHOOK_post_mutex_cond_broadcast) (struct cond_data *c);
+#endif // COMMON_MUTEX_H
#ifdef MAP_NPC_H /* npc_chat */
typedef int (*HPMHOOK_pre_npc_chat_sub) (struct block_list **bl, va_list ap);
typedef int (*HPMHOOK_post_npc_chat_sub) (int retVal___, struct block_list *bl, va_list ap);
@@ -5663,6 +5715,24 @@ typedef int (*HPMHOOK_post_quest_read_db) (int retVal___);
typedef struct quest_db* (*HPMHOOK_pre_quest_read_db_sub) (struct config_setting_t **cs, int *n, const char **source);
typedef struct quest_db* (*HPMHOOK_post_quest_read_db_sub) (struct quest_db* retVal___, struct config_setting_t *cs, int n, const char *source);
#endif // MAP_QUEST_H
+#ifdef COMMON_RANDOM_H /* rnd */
+typedef void (*HPMHOOK_pre_rnd_init) (void);
+typedef void (*HPMHOOK_post_rnd_init) (void);
+typedef void (*HPMHOOK_pre_rnd_final) (void);
+typedef void (*HPMHOOK_post_rnd_final) (void);
+typedef void (*HPMHOOK_pre_rnd_seed) (uint32 *seed);
+typedef void (*HPMHOOK_post_rnd_seed) (uint32 seed);
+typedef int32 (*HPMHOOK_pre_rnd_random) (void);
+typedef int32 (*HPMHOOK_post_rnd_random) (int32 retVal___);
+typedef uint32 (*HPMHOOK_pre_rnd_roll) (uint32 *dice_faces);
+typedef uint32 (*HPMHOOK_post_rnd_roll) (uint32 retVal___, uint32 dice_faces);
+typedef int32 (*HPMHOOK_pre_rnd_value) (int32 *min, int32 *max);
+typedef int32 (*HPMHOOK_post_rnd_value) (int32 retVal___, int32 min, int32 max);
+typedef double (*HPMHOOK_pre_rnd_uniform) (void);
+typedef double (*HPMHOOK_post_rnd_uniform) (double retVal___);
+typedef double (*HPMHOOK_pre_rnd_uniform53) (void);
+typedef double (*HPMHOOK_post_rnd_uniform53) (double retVal___);
+#endif // COMMON_RANDOM_H
#ifdef MAP_SCRIPT_H /* script */
typedef void (*HPMHOOK_pre_script_init) (bool *minimal);
typedef void (*HPMHOOK_post_script_init) (bool minimal);
@@ -7009,6 +7079,30 @@ typedef void (*HPMHOOK_post_sysinfo_init) (void);
typedef void (*HPMHOOK_pre_sysinfo_final) (void);
typedef void (*HPMHOOK_post_sysinfo_final) (void);
#endif // COMMON_SYSINFO_H
+#ifdef COMMON_THREAD_H /* thread */
+typedef void (*HPMHOOK_pre_thread_init) (void);
+typedef void (*HPMHOOK_post_thread_init) (void);
+typedef void (*HPMHOOK_pre_thread_final) (void);
+typedef void (*HPMHOOK_post_thread_final) (void);
+typedef struct thread_handle* (*HPMHOOK_pre_thread_create) (threadFunc *entry_point, void **param);
+typedef struct thread_handle* (*HPMHOOK_post_thread_create) (struct thread_handle* retVal___, threadFunc entry_point, void *param);
+typedef struct thread_handle* (*HPMHOOK_pre_thread_create_opt) (threadFunc *entry_point, void **param, size_t *stack_size, enum thread_priority *prio);
+typedef struct thread_handle* (*HPMHOOK_post_thread_create_opt) (struct thread_handle* retVal___, threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio);
+typedef void (*HPMHOOK_pre_thread_destroy) (struct thread_handle **handle);
+typedef void (*HPMHOOK_post_thread_destroy) (struct thread_handle *handle);
+typedef struct thread_handle* (*HPMHOOK_pre_thread_self) (void);
+typedef struct thread_handle* (*HPMHOOK_post_thread_self) (struct thread_handle* retVal___);
+typedef int (*HPMHOOK_pre_thread_get_tid) (void);
+typedef int (*HPMHOOK_post_thread_get_tid) (int retVal___);
+typedef bool (*HPMHOOK_pre_thread_wait) (struct thread_handle **handle, void ***out_exit_code);
+typedef bool (*HPMHOOK_post_thread_wait) (bool retVal___, struct thread_handle *handle, void **out_exit_code);
+typedef void (*HPMHOOK_pre_thread_prio_set) (struct thread_handle **handle, enum thread_priority *prio);
+typedef void (*HPMHOOK_post_thread_prio_set) (struct thread_handle *handle, enum thread_priority prio);
+typedef enum thread_priority (*HPMHOOK_pre_thread_prio_get) (struct thread_handle **handle);
+typedef enum thread_priority (*HPMHOOK_post_thread_prio_get) (enum thread_priority retVal___, struct thread_handle *handle);
+typedef void (*HPMHOOK_pre_thread_yield) (void);
+typedef void (*HPMHOOK_post_thread_yield) (void);
+#endif // COMMON_THREAD_H
#ifdef COMMON_TIMER_H /* timer */
typedef int64 (*HPMHOOK_pre_timer_gettick) (void);
typedef int64 (*HPMHOOK_post_timer_gettick) (int64 retVal___);
diff --git a/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc
index 3477a58a7..f51ddcffc 100644
--- a/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc
+++ b/src/plugins/HPMHooking/HPMHooking_char.HPMHooksCore.inc
@@ -408,6 +408,10 @@ struct {
struct HPMHookPoint *HP_DB_init_post;
struct HPMHookPoint *HP_DB_final_pre;
struct HPMHookPoint *HP_DB_final_post;
+ struct HPMHookPoint *HP_des_decrypt_block_pre;
+ struct HPMHookPoint *HP_des_decrypt_block_post;
+ struct HPMHookPoint *HP_des_decrypt_pre;
+ struct HPMHookPoint *HP_des_decrypt_post;
struct HPMHookPoint *HP_geoip_getcountry_pre;
struct HPMHookPoint *HP_geoip_getcountry_post;
struct HPMHookPoint *HP_geoip_final_pre;
@@ -1152,6 +1156,32 @@ struct {
struct HPMHookPoint *HP_mapindex_id2name_post;
struct HPMHookPoint *HP_mapindex_check_default_pre;
struct HPMHookPoint *HP_mapindex_check_default_post;
+ struct HPMHookPoint *HP_md5_string_pre;
+ struct HPMHookPoint *HP_md5_string_post;
+ struct HPMHookPoint *HP_md5_binary_pre;
+ struct HPMHookPoint *HP_md5_binary_post;
+ struct HPMHookPoint *HP_md5_salt_pre;
+ struct HPMHookPoint *HP_md5_salt_post;
+ struct HPMHookPoint *HP_mutex_create_pre;
+ struct HPMHookPoint *HP_mutex_create_post;
+ struct HPMHookPoint *HP_mutex_destroy_pre;
+ struct HPMHookPoint *HP_mutex_destroy_post;
+ struct HPMHookPoint *HP_mutex_lock_pre;
+ struct HPMHookPoint *HP_mutex_lock_post;
+ struct HPMHookPoint *HP_mutex_trylock_pre;
+ struct HPMHookPoint *HP_mutex_trylock_post;
+ struct HPMHookPoint *HP_mutex_unlock_pre;
+ struct HPMHookPoint *HP_mutex_unlock_post;
+ struct HPMHookPoint *HP_mutex_cond_create_pre;
+ struct HPMHookPoint *HP_mutex_cond_create_post;
+ struct HPMHookPoint *HP_mutex_cond_destroy_pre;
+ struct HPMHookPoint *HP_mutex_cond_destroy_post;
+ struct HPMHookPoint *HP_mutex_cond_wait_pre;
+ struct HPMHookPoint *HP_mutex_cond_wait_post;
+ struct HPMHookPoint *HP_mutex_cond_signal_pre;
+ struct HPMHookPoint *HP_mutex_cond_signal_post;
+ struct HPMHookPoint *HP_mutex_cond_broadcast_pre;
+ struct HPMHookPoint *HP_mutex_cond_broadcast_post;
struct HPMHookPoint *HP_nullpo_assert_report_pre;
struct HPMHookPoint *HP_nullpo_assert_report_post;
struct HPMHookPoint *HP_pincode_handle_pre;
@@ -1174,6 +1204,22 @@ struct {
struct HPMHookPoint *HP_pincode_check_post;
struct HPMHookPoint *HP_pincode_config_read_pre;
struct HPMHookPoint *HP_pincode_config_read_post;
+ struct HPMHookPoint *HP_rnd_init_pre;
+ struct HPMHookPoint *HP_rnd_init_post;
+ struct HPMHookPoint *HP_rnd_final_pre;
+ struct HPMHookPoint *HP_rnd_final_post;
+ struct HPMHookPoint *HP_rnd_seed_pre;
+ struct HPMHookPoint *HP_rnd_seed_post;
+ struct HPMHookPoint *HP_rnd_random_pre;
+ struct HPMHookPoint *HP_rnd_random_post;
+ struct HPMHookPoint *HP_rnd_roll_pre;
+ struct HPMHookPoint *HP_rnd_roll_post;
+ struct HPMHookPoint *HP_rnd_value_pre;
+ struct HPMHookPoint *HP_rnd_value_post;
+ struct HPMHookPoint *HP_rnd_uniform_pre;
+ struct HPMHookPoint *HP_rnd_uniform_post;
+ struct HPMHookPoint *HP_rnd_uniform53_pre;
+ struct HPMHookPoint *HP_rnd_uniform53_post;
struct HPMHookPoint *HP_showmsg_init_pre;
struct HPMHookPoint *HP_showmsg_init_post;
struct HPMHookPoint *HP_showmsg_final_pre;
@@ -1402,6 +1448,28 @@ struct {
struct HPMHookPoint *HP_sysinfo_init_post;
struct HPMHookPoint *HP_sysinfo_final_pre;
struct HPMHookPoint *HP_sysinfo_final_post;
+ struct HPMHookPoint *HP_thread_init_pre;
+ struct HPMHookPoint *HP_thread_init_post;
+ struct HPMHookPoint *HP_thread_final_pre;
+ struct HPMHookPoint *HP_thread_final_post;
+ struct HPMHookPoint *HP_thread_create_pre;
+ struct HPMHookPoint *HP_thread_create_post;
+ struct HPMHookPoint *HP_thread_create_opt_pre;
+ struct HPMHookPoint *HP_thread_create_opt_post;
+ struct HPMHookPoint *HP_thread_destroy_pre;
+ struct HPMHookPoint *HP_thread_destroy_post;
+ struct HPMHookPoint *HP_thread_self_pre;
+ struct HPMHookPoint *HP_thread_self_post;
+ struct HPMHookPoint *HP_thread_get_tid_pre;
+ struct HPMHookPoint *HP_thread_get_tid_post;
+ struct HPMHookPoint *HP_thread_wait_pre;
+ struct HPMHookPoint *HP_thread_wait_post;
+ struct HPMHookPoint *HP_thread_prio_set_pre;
+ struct HPMHookPoint *HP_thread_prio_set_post;
+ struct HPMHookPoint *HP_thread_prio_get_pre;
+ struct HPMHookPoint *HP_thread_prio_get_post;
+ struct HPMHookPoint *HP_thread_yield_pre;
+ struct HPMHookPoint *HP_thread_yield_post;
struct HPMHookPoint *HP_timer_gettick_pre;
struct HPMHookPoint *HP_timer_gettick_post;
struct HPMHookPoint *HP_timer_gettick_nocache_pre;
@@ -1813,6 +1881,10 @@ struct {
int HP_DB_init_post;
int HP_DB_final_pre;
int HP_DB_final_post;
+ int HP_des_decrypt_block_pre;
+ int HP_des_decrypt_block_post;
+ int HP_des_decrypt_pre;
+ int HP_des_decrypt_post;
int HP_geoip_getcountry_pre;
int HP_geoip_getcountry_post;
int HP_geoip_final_pre;
@@ -2557,6 +2629,32 @@ struct {
int HP_mapindex_id2name_post;
int HP_mapindex_check_default_pre;
int HP_mapindex_check_default_post;
+ int HP_md5_string_pre;
+ int HP_md5_string_post;
+ int HP_md5_binary_pre;
+ int HP_md5_binary_post;
+ int HP_md5_salt_pre;
+ int HP_md5_salt_post;
+ int HP_mutex_create_pre;
+ int HP_mutex_create_post;
+ int HP_mutex_destroy_pre;
+ int HP_mutex_destroy_post;
+ int HP_mutex_lock_pre;
+ int HP_mutex_lock_post;
+ int HP_mutex_trylock_pre;
+ int HP_mutex_trylock_post;
+ int HP_mutex_unlock_pre;
+ int HP_mutex_unlock_post;
+ int HP_mutex_cond_create_pre;
+ int HP_mutex_cond_create_post;
+ int HP_mutex_cond_destroy_pre;
+ int HP_mutex_cond_destroy_post;
+ int HP_mutex_cond_wait_pre;
+ int HP_mutex_cond_wait_post;
+ int HP_mutex_cond_signal_pre;
+ int HP_mutex_cond_signal_post;
+ int HP_mutex_cond_broadcast_pre;
+ int HP_mutex_cond_broadcast_post;
int HP_nullpo_assert_report_pre;
int HP_nullpo_assert_report_post;
int HP_pincode_handle_pre;
@@ -2579,6 +2677,22 @@ struct {
int HP_pincode_check_post;
int HP_pincode_config_read_pre;
int HP_pincode_config_read_post;
+ int HP_rnd_init_pre;
+ int HP_rnd_init_post;
+ int HP_rnd_final_pre;
+ int HP_rnd_final_post;
+ int HP_rnd_seed_pre;
+ int HP_rnd_seed_post;
+ int HP_rnd_random_pre;
+ int HP_rnd_random_post;
+ int HP_rnd_roll_pre;
+ int HP_rnd_roll_post;
+ int HP_rnd_value_pre;
+ int HP_rnd_value_post;
+ int HP_rnd_uniform_pre;
+ int HP_rnd_uniform_post;
+ int HP_rnd_uniform53_pre;
+ int HP_rnd_uniform53_post;
int HP_showmsg_init_pre;
int HP_showmsg_init_post;
int HP_showmsg_final_pre;
@@ -2807,6 +2921,28 @@ struct {
int HP_sysinfo_init_post;
int HP_sysinfo_final_pre;
int HP_sysinfo_final_post;
+ int HP_thread_init_pre;
+ int HP_thread_init_post;
+ int HP_thread_final_pre;
+ int HP_thread_final_post;
+ int HP_thread_create_pre;
+ int HP_thread_create_post;
+ int HP_thread_create_opt_pre;
+ int HP_thread_create_opt_post;
+ int HP_thread_destroy_pre;
+ int HP_thread_destroy_post;
+ int HP_thread_self_pre;
+ int HP_thread_self_post;
+ int HP_thread_get_tid_pre;
+ int HP_thread_get_tid_post;
+ int HP_thread_wait_pre;
+ int HP_thread_wait_post;
+ int HP_thread_prio_set_pre;
+ int HP_thread_prio_set_post;
+ int HP_thread_prio_get_pre;
+ int HP_thread_prio_get_post;
+ int HP_thread_yield_pre;
+ int HP_thread_yield_post;
int HP_timer_gettick_pre;
int HP_timer_gettick_post;
int HP_timer_gettick_nocache_pre;
@@ -2842,6 +2978,7 @@ struct {
struct console_interface console;
struct core_interface core;
struct db_interface DB;
+ struct des_interface des;
struct geoip_interface geoip;
struct inter_auction_interface inter_auction;
struct inter_elemental_interface inter_elemental;
@@ -2859,8 +2996,11 @@ struct {
struct malloc_interface iMalloc;
struct mapif_interface mapif;
struct mapindex_interface mapindex;
+ struct md5_interface md5;
+ struct mutex_interface mutex;
struct nullpo_interface nullpo;
struct pincode_interface pincode;
+ struct rnd_interface rnd;
struct showmsg_interface showmsg;
struct socket_interface sockt;
struct sql_interface SQL;
@@ -2868,5 +3008,6 @@ struct {
struct strlib_interface strlib;
struct sv_interface sv;
struct sysinfo_interface sysinfo;
+ struct thread_interface thread;
struct timer_interface timer;
} source;
diff --git a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc
index 9844e61b6..4371cf81a 100644
--- a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc
+++ b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc
@@ -223,6 +223,9 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(DB->data2ptr, HP_DB_data2ptr) },
{ HP_POP(DB->init, HP_DB_init) },
{ HP_POP(DB->final, HP_DB_final) },
+/* des_interface */
+ { HP_POP(des->decrypt_block, HP_des_decrypt_block) },
+ { HP_POP(des->decrypt, HP_des_decrypt) },
/* geoip_interface */
{ HP_POP(geoip->getcountry, HP_geoip_getcountry) },
{ HP_POP(geoip->final, HP_geoip_final) },
@@ -612,6 +615,21 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(mapindex->name2id, HP_mapindex_name2id) },
{ HP_POP(mapindex->id2name, HP_mapindex_id2name) },
{ HP_POP(mapindex->check_default, HP_mapindex_check_default) },
+/* md5_interface */
+ { HP_POP(md5->string, HP_md5_string) },
+ { HP_POP(md5->binary, HP_md5_binary) },
+ { HP_POP(md5->salt, HP_md5_salt) },
+/* mutex_interface */
+ { HP_POP(mutex->create, HP_mutex_create) },
+ { HP_POP(mutex->destroy, HP_mutex_destroy) },
+ { HP_POP(mutex->lock, HP_mutex_lock) },
+ { HP_POP(mutex->trylock, HP_mutex_trylock) },
+ { HP_POP(mutex->unlock, HP_mutex_unlock) },
+ { HP_POP(mutex->cond_create, HP_mutex_cond_create) },
+ { HP_POP(mutex->cond_destroy, HP_mutex_cond_destroy) },
+ { HP_POP(mutex->cond_wait, HP_mutex_cond_wait) },
+ { HP_POP(mutex->cond_signal, HP_mutex_cond_signal) },
+ { HP_POP(mutex->cond_broadcast, HP_mutex_cond_broadcast) },
/* nullpo_interface */
{ HP_POP(nullpo->assert_report, HP_nullpo_assert_report) },
/* pincode_interface */
@@ -625,6 +643,15 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(pincode->compare, HP_pincode_compare) },
{ HP_POP(pincode->check, HP_pincode_check) },
{ HP_POP(pincode->config_read, HP_pincode_config_read) },
+/* rnd_interface */
+ { HP_POP(rnd->init, HP_rnd_init) },
+ { HP_POP(rnd->final, HP_rnd_final) },
+ { HP_POP(rnd->seed, HP_rnd_seed) },
+ { HP_POP(rnd->random, HP_rnd_random) },
+ { HP_POP(rnd->roll, HP_rnd_roll) },
+ { HP_POP(rnd->value, HP_rnd_value) },
+ { HP_POP(rnd->uniform, HP_rnd_uniform) },
+ { HP_POP(rnd->uniform53, HP_rnd_uniform53) },
/* showmsg_interface */
{ HP_POP(showmsg->init, HP_showmsg_init) },
{ HP_POP(showmsg->final, HP_showmsg_final) },
@@ -746,6 +773,18 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(sysinfo->is_superuser, HP_sysinfo_is_superuser) },
{ HP_POP(sysinfo->init, HP_sysinfo_init) },
{ HP_POP(sysinfo->final, HP_sysinfo_final) },
+/* thread_interface */
+ { HP_POP(thread->init, HP_thread_init) },
+ { HP_POP(thread->final, HP_thread_final) },
+ { HP_POP(thread->create, HP_thread_create) },
+ { HP_POP(thread->create_opt, HP_thread_create_opt) },
+ { HP_POP(thread->destroy, HP_thread_destroy) },
+ { HP_POP(thread->self, HP_thread_self) },
+ { HP_POP(thread->get_tid, HP_thread_get_tid) },
+ { HP_POP(thread->wait, HP_thread_wait) },
+ { HP_POP(thread->prio_set, HP_thread_prio_set) },
+ { HP_POP(thread->prio_get, HP_thread_prio_get) },
+ { HP_POP(thread->yield, HP_thread_yield) },
/* timer_interface */
{ HP_POP(timer->gettick, HP_timer_gettick) },
{ HP_POP(timer->gettick_nocache, HP_timer_gettick_nocache) },
diff --git a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc
index b1f2f58b7..aecffbecd 100644
--- a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc
+++ b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc
@@ -5100,6 +5100,59 @@ void HP_DB_final(void) {
}
return;
}
+/* des_interface */
+void HP_des_decrypt_block(struct des_bit64 *block) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_des_decrypt_block_pre ) {
+ void (*preHookFunc) (struct des_bit64 **block);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_block_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_des_decrypt_block_pre[hIndex].func;
+ preHookFunc(&block);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.des.decrypt_block(block);
+ }
+ if( HPMHooks.count.HP_des_decrypt_block_post ) {
+ void (*postHookFunc) (struct des_bit64 *block);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_block_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_des_decrypt_block_post[hIndex].func;
+ postHookFunc(block);
+ }
+ }
+ return;
+}
+void HP_des_decrypt(unsigned char *data, size_t size) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_des_decrypt_pre ) {
+ void (*preHookFunc) (unsigned char **data, size_t *size);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_des_decrypt_pre[hIndex].func;
+ preHookFunc(&data, &size);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.des.decrypt(data, size);
+ }
+ if( HPMHooks.count.HP_des_decrypt_post ) {
+ void (*postHookFunc) (unsigned char *data, size_t size);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_des_decrypt_post[hIndex].func;
+ postHookFunc(data, size);
+ }
+ }
+ return;
+}
/* geoip_interface */
const char* HP_geoip_getcountry(uint32 ipnum) {
int hIndex = 0;
@@ -15067,6 +15120,349 @@ bool HP_mapindex_check_default(void) {
}
return retVal___;
}
+/* md5_interface */
+void HP_md5_string(const char *string, char *output) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_md5_string_pre ) {
+ void (*preHookFunc) (const char **string, char **output);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_string_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_md5_string_pre[hIndex].func;
+ preHookFunc(&string, &output);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.md5.string(string, output);
+ }
+ if( HPMHooks.count.HP_md5_string_post ) {
+ void (*postHookFunc) (const char *string, char *output);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_string_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_md5_string_post[hIndex].func;
+ postHookFunc(string, output);
+ }
+ }
+ return;
+}
+void HP_md5_binary(const char *string, unsigned char *output) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_md5_binary_pre ) {
+ void (*preHookFunc) (const char **string, unsigned char **output);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_md5_binary_pre[hIndex].func;
+ preHookFunc(&string, &output);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.md5.binary(string, output);
+ }
+ if( HPMHooks.count.HP_md5_binary_post ) {
+ void (*postHookFunc) (const char *string, unsigned char *output);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_md5_binary_post[hIndex].func;
+ postHookFunc(string, output);
+ }
+ }
+ return;
+}
+void HP_md5_salt(int len, char *output) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_md5_salt_pre ) {
+ void (*preHookFunc) (int *len, char **output);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_salt_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_md5_salt_pre[hIndex].func;
+ preHookFunc(&len, &output);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.md5.salt(len, output);
+ }
+ if( HPMHooks.count.HP_md5_salt_post ) {
+ void (*postHookFunc) (int len, char *output);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_salt_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_md5_salt_post[hIndex].func;
+ postHookFunc(len, output);
+ }
+ }
+ return;
+}
+/* mutex_interface */
+struct mutex_data* HP_mutex_create(void) {
+ int hIndex = 0;
+ struct mutex_data* retVal___ = NULL;
+ if( HPMHooks.count.HP_mutex_create_pre ) {
+ struct mutex_data* (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_create_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_create_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mutex.create();
+ }
+ if( HPMHooks.count.HP_mutex_create_post ) {
+ struct mutex_data* (*postHookFunc) (struct mutex_data* retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_create_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_create_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+void HP_mutex_destroy(struct mutex_data *m) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_destroy_pre ) {
+ void (*preHookFunc) (struct mutex_data **m);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_destroy_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_destroy_pre[hIndex].func;
+ preHookFunc(&m);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.destroy(m);
+ }
+ if( HPMHooks.count.HP_mutex_destroy_post ) {
+ void (*postHookFunc) (struct mutex_data *m);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_destroy_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_destroy_post[hIndex].func;
+ postHookFunc(m);
+ }
+ }
+ return;
+}
+void HP_mutex_lock(struct mutex_data *m) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_lock_pre ) {
+ void (*preHookFunc) (struct mutex_data **m);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_lock_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_lock_pre[hIndex].func;
+ preHookFunc(&m);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.lock(m);
+ }
+ if( HPMHooks.count.HP_mutex_lock_post ) {
+ void (*postHookFunc) (struct mutex_data *m);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_lock_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_lock_post[hIndex].func;
+ postHookFunc(m);
+ }
+ }
+ return;
+}
+bool HP_mutex_trylock(struct mutex_data *m) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_mutex_trylock_pre ) {
+ bool (*preHookFunc) (struct mutex_data **m);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_trylock_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_trylock_pre[hIndex].func;
+ retVal___ = preHookFunc(&m);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mutex.trylock(m);
+ }
+ if( HPMHooks.count.HP_mutex_trylock_post ) {
+ bool (*postHookFunc) (bool retVal___, struct mutex_data *m);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_trylock_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_trylock_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, m);
+ }
+ }
+ return retVal___;
+}
+void HP_mutex_unlock(struct mutex_data *m) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_unlock_pre ) {
+ void (*preHookFunc) (struct mutex_data **m);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_unlock_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_unlock_pre[hIndex].func;
+ preHookFunc(&m);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.unlock(m);
+ }
+ if( HPMHooks.count.HP_mutex_unlock_post ) {
+ void (*postHookFunc) (struct mutex_data *m);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_unlock_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_unlock_post[hIndex].func;
+ postHookFunc(m);
+ }
+ }
+ return;
+}
+struct cond_data* HP_mutex_cond_create(void) {
+ int hIndex = 0;
+ struct cond_data* retVal___ = NULL;
+ if( HPMHooks.count.HP_mutex_cond_create_pre ) {
+ struct cond_data* (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_create_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_cond_create_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mutex.cond_create();
+ }
+ if( HPMHooks.count.HP_mutex_cond_create_post ) {
+ struct cond_data* (*postHookFunc) (struct cond_data* retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_create_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_cond_create_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+void HP_mutex_cond_destroy(struct cond_data *c) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_cond_destroy_pre ) {
+ void (*preHookFunc) (struct cond_data **c);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_destroy_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_cond_destroy_pre[hIndex].func;
+ preHookFunc(&c);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.cond_destroy(c);
+ }
+ if( HPMHooks.count.HP_mutex_cond_destroy_post ) {
+ void (*postHookFunc) (struct cond_data *c);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_destroy_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_cond_destroy_post[hIndex].func;
+ postHookFunc(c);
+ }
+ }
+ return;
+}
+void HP_mutex_cond_wait(struct cond_data *c, struct mutex_data *m, sysint timeout_ticks) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_cond_wait_pre ) {
+ void (*preHookFunc) (struct cond_data **c, struct mutex_data **m, sysint *timeout_ticks);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_wait_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_cond_wait_pre[hIndex].func;
+ preHookFunc(&c, &m, &timeout_ticks);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.cond_wait(c, m, timeout_ticks);
+ }
+ if( HPMHooks.count.HP_mutex_cond_wait_post ) {
+ void (*postHookFunc) (struct cond_data *c, struct mutex_data *m, sysint timeout_ticks);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_wait_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_cond_wait_post[hIndex].func;
+ postHookFunc(c, m, timeout_ticks);
+ }
+ }
+ return;
+}
+void HP_mutex_cond_signal(struct cond_data *c) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_cond_signal_pre ) {
+ void (*preHookFunc) (struct cond_data **c);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_signal_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_cond_signal_pre[hIndex].func;
+ preHookFunc(&c);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.cond_signal(c);
+ }
+ if( HPMHooks.count.HP_mutex_cond_signal_post ) {
+ void (*postHookFunc) (struct cond_data *c);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_signal_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_cond_signal_post[hIndex].func;
+ postHookFunc(c);
+ }
+ }
+ return;
+}
+void HP_mutex_cond_broadcast(struct cond_data *c) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_cond_broadcast_pre ) {
+ void (*preHookFunc) (struct cond_data **c);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_broadcast_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_cond_broadcast_pre[hIndex].func;
+ preHookFunc(&c);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.cond_broadcast(c);
+ }
+ if( HPMHooks.count.HP_mutex_cond_broadcast_post ) {
+ void (*postHookFunc) (struct cond_data *c);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_broadcast_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_cond_broadcast_post[hIndex].func;
+ postHookFunc(c);
+ }
+ }
+ return;
+}
/* nullpo_interface */
void HP_nullpo_assert_report(const char *file, int line, const char *func, const char *targetname, const char *title) {
int hIndex = 0;
@@ -15357,6 +15753,220 @@ bool HP_pincode_config_read(char *w1, char *w2) {
}
return retVal___;
}
+/* rnd_interface */
+void HP_rnd_init(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_rnd_init_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_init_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.rnd.init();
+ }
+ if( HPMHooks.count.HP_rnd_init_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_init_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_rnd_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_rnd_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.rnd.final();
+ }
+ if( HPMHooks.count.HP_rnd_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_rnd_seed(uint32 seed) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_rnd_seed_pre ) {
+ void (*preHookFunc) (uint32 *seed);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_seed_pre[hIndex].func;
+ preHookFunc(&seed);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.rnd.seed(seed);
+ }
+ if( HPMHooks.count.HP_rnd_seed_post ) {
+ void (*postHookFunc) (uint32 seed);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_seed_post[hIndex].func;
+ postHookFunc(seed);
+ }
+ }
+ return;
+}
+int32 HP_rnd_random(void) {
+ int hIndex = 0;
+ int32 retVal___ = 0;
+ if( HPMHooks.count.HP_rnd_random_pre ) {
+ int32 (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_random_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.rnd.random();
+ }
+ if( HPMHooks.count.HP_rnd_random_post ) {
+ int32 (*postHookFunc) (int32 retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_random_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+uint32 HP_rnd_roll(uint32 dice_faces) {
+ int hIndex = 0;
+ uint32 retVal___ = 0;
+ if( HPMHooks.count.HP_rnd_roll_pre ) {
+ uint32 (*preHookFunc) (uint32 *dice_faces);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_roll_pre[hIndex].func;
+ retVal___ = preHookFunc(&dice_faces);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.rnd.roll(dice_faces);
+ }
+ if( HPMHooks.count.HP_rnd_roll_post ) {
+ uint32 (*postHookFunc) (uint32 retVal___, uint32 dice_faces);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_roll_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, dice_faces);
+ }
+ }
+ return retVal___;
+}
+int32 HP_rnd_value(int32 min, int32 max) {
+ int hIndex = 0;
+ int32 retVal___ = 0;
+ if( HPMHooks.count.HP_rnd_value_pre ) {
+ int32 (*preHookFunc) (int32 *min, int32 *max);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_value_pre[hIndex].func;
+ retVal___ = preHookFunc(&min, &max);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.rnd.value(min, max);
+ }
+ if( HPMHooks.count.HP_rnd_value_post ) {
+ int32 (*postHookFunc) (int32 retVal___, int32 min, int32 max);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_value_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, min, max);
+ }
+ }
+ return retVal___;
+}
+double HP_rnd_uniform(void) {
+ int hIndex = 0;
+ double retVal___ = 0.;
+ if( HPMHooks.count.HP_rnd_uniform_pre ) {
+ double (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_uniform_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.rnd.uniform();
+ }
+ if( HPMHooks.count.HP_rnd_uniform_post ) {
+ double (*postHookFunc) (double retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_uniform_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+double HP_rnd_uniform53(void) {
+ int hIndex = 0;
+ double retVal___ = 0.;
+ if( HPMHooks.count.HP_rnd_uniform53_pre ) {
+ double (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_uniform53_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.rnd.uniform53();
+ }
+ if( HPMHooks.count.HP_rnd_uniform53_post ) {
+ double (*postHookFunc) (double retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_uniform53_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
/* showmsg_interface */
void HP_showmsg_init(void) {
int hIndex = 0;
@@ -18440,6 +19050,299 @@ void HP_sysinfo_final(void) {
}
return;
}
+/* thread_interface */
+void HP_thread_init(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_thread_init_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_init_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.thread.init();
+ }
+ if( HPMHooks.count.HP_thread_init_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_init_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_thread_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_thread_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.thread.final();
+ }
+ if( HPMHooks.count.HP_thread_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+struct thread_handle* HP_thread_create(threadFunc entry_point, void *param) {
+ int hIndex = 0;
+ struct thread_handle* retVal___ = NULL;
+ if( HPMHooks.count.HP_thread_create_pre ) {
+ struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_create_pre[hIndex].func;
+ retVal___ = preHookFunc(&entry_point, &param);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.create(entry_point, param);
+ }
+ if( HPMHooks.count.HP_thread_create_post ) {
+ struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_create_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, entry_point, param);
+ }
+ }
+ return retVal___;
+}
+struct thread_handle* HP_thread_create_opt(threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio) {
+ int hIndex = 0;
+ struct thread_handle* retVal___ = NULL;
+ if( HPMHooks.count.HP_thread_create_opt_pre ) {
+ struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param, size_t *stack_size, enum thread_priority *prio);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_create_opt_pre[hIndex].func;
+ retVal___ = preHookFunc(&entry_point, &param, &stack_size, &prio);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.create_opt(entry_point, param, stack_size, prio);
+ }
+ if( HPMHooks.count.HP_thread_create_opt_post ) {
+ struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_create_opt_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, entry_point, param, stack_size, prio);
+ }
+ }
+ return retVal___;
+}
+void HP_thread_destroy(struct thread_handle *handle) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_thread_destroy_pre ) {
+ void (*preHookFunc) (struct thread_handle **handle);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_destroy_pre[hIndex].func;
+ preHookFunc(&handle);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.thread.destroy(handle);
+ }
+ if( HPMHooks.count.HP_thread_destroy_post ) {
+ void (*postHookFunc) (struct thread_handle *handle);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_destroy_post[hIndex].func;
+ postHookFunc(handle);
+ }
+ }
+ return;
+}
+struct thread_handle* HP_thread_self(void) {
+ int hIndex = 0;
+ struct thread_handle* retVal___ = NULL;
+ if( HPMHooks.count.HP_thread_self_pre ) {
+ struct thread_handle* (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_self_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.self();
+ }
+ if( HPMHooks.count.HP_thread_self_post ) {
+ struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_self_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+int HP_thread_get_tid(void) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_thread_get_tid_pre ) {
+ int (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_get_tid_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.get_tid();
+ }
+ if( HPMHooks.count.HP_thread_get_tid_post ) {
+ int (*postHookFunc) (int retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_get_tid_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+bool HP_thread_wait(struct thread_handle *handle, void **out_exit_code) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_thread_wait_pre ) {
+ bool (*preHookFunc) (struct thread_handle **handle, void ***out_exit_code);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_wait_pre[hIndex].func;
+ retVal___ = preHookFunc(&handle, &out_exit_code);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.wait(handle, out_exit_code);
+ }
+ if( HPMHooks.count.HP_thread_wait_post ) {
+ bool (*postHookFunc) (bool retVal___, struct thread_handle *handle, void **out_exit_code);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_wait_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, handle, out_exit_code);
+ }
+ }
+ return retVal___;
+}
+void HP_thread_prio_set(struct thread_handle *handle, enum thread_priority prio) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_thread_prio_set_pre ) {
+ void (*preHookFunc) (struct thread_handle **handle, enum thread_priority *prio);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_prio_set_pre[hIndex].func;
+ preHookFunc(&handle, &prio);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.thread.prio_set(handle, prio);
+ }
+ if( HPMHooks.count.HP_thread_prio_set_post ) {
+ void (*postHookFunc) (struct thread_handle *handle, enum thread_priority prio);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_prio_set_post[hIndex].func;
+ postHookFunc(handle, prio);
+ }
+ }
+ return;
+}
+enum thread_priority HP_thread_prio_get(struct thread_handle *handle) {
+ int hIndex = 0;
+ enum thread_priority retVal___ = THREADPRIO_NORMAL;
+ if( HPMHooks.count.HP_thread_prio_get_pre ) {
+ enum thread_priority (*preHookFunc) (struct thread_handle **handle);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_prio_get_pre[hIndex].func;
+ retVal___ = preHookFunc(&handle);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.prio_get(handle);
+ }
+ if( HPMHooks.count.HP_thread_prio_get_post ) {
+ enum thread_priority (*postHookFunc) (enum thread_priority retVal___, struct thread_handle *handle);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_prio_get_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, handle);
+ }
+ }
+ return retVal___;
+}
+void HP_thread_yield(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_thread_yield_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_yield_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.thread.yield();
+ }
+ if( HPMHooks.count.HP_thread_yield_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_yield_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
/* timer_interface */
int64 HP_timer_gettick(void) {
int hIndex = 0;
diff --git a/src/plugins/HPMHooking/HPMHooking_char.sources.inc b/src/plugins/HPMHooking/HPMHooking_char.sources.inc
index 21d1f6531..54ae8f030 100644
--- a/src/plugins/HPMHooking/HPMHooking_char.sources.inc
+++ b/src/plugins/HPMHooking/HPMHooking_char.sources.inc
@@ -31,6 +31,7 @@ memcpy(&HPMHooks.source.cmdline, cmdline, sizeof(struct cmdline_interface));
memcpy(&HPMHooks.source.console, console, sizeof(struct console_interface));
memcpy(&HPMHooks.source.core, core, sizeof(struct core_interface));
memcpy(&HPMHooks.source.DB, DB, sizeof(struct db_interface));
+memcpy(&HPMHooks.source.des, des, sizeof(struct des_interface));
memcpy(&HPMHooks.source.geoip, geoip, sizeof(struct geoip_interface));
memcpy(&HPMHooks.source.inter_auction, inter_auction, sizeof(struct inter_auction_interface));
memcpy(&HPMHooks.source.inter_elemental, inter_elemental, sizeof(struct inter_elemental_interface));
@@ -48,8 +49,11 @@ memcpy(&HPMHooks.source.loginif, loginif, sizeof(struct loginif_interface));
memcpy(&HPMHooks.source.iMalloc, iMalloc, sizeof(struct malloc_interface));
memcpy(&HPMHooks.source.mapif, mapif, sizeof(struct mapif_interface));
memcpy(&HPMHooks.source.mapindex, mapindex, sizeof(struct mapindex_interface));
+memcpy(&HPMHooks.source.md5, md5, sizeof(struct md5_interface));
+memcpy(&HPMHooks.source.mutex, mutex, sizeof(struct mutex_interface));
memcpy(&HPMHooks.source.nullpo, nullpo, sizeof(struct nullpo_interface));
memcpy(&HPMHooks.source.pincode, pincode, sizeof(struct pincode_interface));
+memcpy(&HPMHooks.source.rnd, rnd, sizeof(struct rnd_interface));
memcpy(&HPMHooks.source.showmsg, showmsg, sizeof(struct showmsg_interface));
memcpy(&HPMHooks.source.sockt, sockt, sizeof(struct socket_interface));
memcpy(&HPMHooks.source.SQL, SQL, sizeof(struct sql_interface));
@@ -57,4 +61,5 @@ memcpy(&HPMHooks.source.StrBuf, StrBuf, sizeof(struct stringbuf_interface));
memcpy(&HPMHooks.source.strlib, strlib, sizeof(struct strlib_interface));
memcpy(&HPMHooks.source.sv, sv, sizeof(struct sv_interface));
memcpy(&HPMHooks.source.sysinfo, sysinfo, sizeof(struct sysinfo_interface));
+memcpy(&HPMHooks.source.thread, thread, sizeof(struct thread_interface));
memcpy(&HPMHooks.source.timer, timer, sizeof(struct timer_interface));
diff --git a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc
index 3e63de124..b97b6ea7f 100644
--- a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc
+++ b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc
@@ -92,6 +92,10 @@ struct {
struct HPMHookPoint *HP_DB_init_post;
struct HPMHookPoint *HP_DB_final_pre;
struct HPMHookPoint *HP_DB_final_post;
+ struct HPMHookPoint *HP_des_decrypt_block_pre;
+ struct HPMHookPoint *HP_des_decrypt_block_post;
+ struct HPMHookPoint *HP_des_decrypt_pre;
+ struct HPMHookPoint *HP_des_decrypt_post;
struct HPMHookPoint *HP_lclif_init_pre;
struct HPMHookPoint *HP_lclif_init_post;
struct HPMHookPoint *HP_lclif_final_pre;
@@ -400,8 +404,50 @@ struct {
struct HPMHookPoint *HP_iMalloc_post_shutdown_post;
struct HPMHookPoint *HP_iMalloc_init_messages_pre;
struct HPMHookPoint *HP_iMalloc_init_messages_post;
+ struct HPMHookPoint *HP_md5_string_pre;
+ struct HPMHookPoint *HP_md5_string_post;
+ struct HPMHookPoint *HP_md5_binary_pre;
+ struct HPMHookPoint *HP_md5_binary_post;
+ struct HPMHookPoint *HP_md5_salt_pre;
+ struct HPMHookPoint *HP_md5_salt_post;
+ struct HPMHookPoint *HP_mutex_create_pre;
+ struct HPMHookPoint *HP_mutex_create_post;
+ struct HPMHookPoint *HP_mutex_destroy_pre;
+ struct HPMHookPoint *HP_mutex_destroy_post;
+ struct HPMHookPoint *HP_mutex_lock_pre;
+ struct HPMHookPoint *HP_mutex_lock_post;
+ struct HPMHookPoint *HP_mutex_trylock_pre;
+ struct HPMHookPoint *HP_mutex_trylock_post;
+ struct HPMHookPoint *HP_mutex_unlock_pre;
+ struct HPMHookPoint *HP_mutex_unlock_post;
+ struct HPMHookPoint *HP_mutex_cond_create_pre;
+ struct HPMHookPoint *HP_mutex_cond_create_post;
+ struct HPMHookPoint *HP_mutex_cond_destroy_pre;
+ struct HPMHookPoint *HP_mutex_cond_destroy_post;
+ struct HPMHookPoint *HP_mutex_cond_wait_pre;
+ struct HPMHookPoint *HP_mutex_cond_wait_post;
+ struct HPMHookPoint *HP_mutex_cond_signal_pre;
+ struct HPMHookPoint *HP_mutex_cond_signal_post;
+ struct HPMHookPoint *HP_mutex_cond_broadcast_pre;
+ struct HPMHookPoint *HP_mutex_cond_broadcast_post;
struct HPMHookPoint *HP_nullpo_assert_report_pre;
struct HPMHookPoint *HP_nullpo_assert_report_post;
+ struct HPMHookPoint *HP_rnd_init_pre;
+ struct HPMHookPoint *HP_rnd_init_post;
+ struct HPMHookPoint *HP_rnd_final_pre;
+ struct HPMHookPoint *HP_rnd_final_post;
+ struct HPMHookPoint *HP_rnd_seed_pre;
+ struct HPMHookPoint *HP_rnd_seed_post;
+ struct HPMHookPoint *HP_rnd_random_pre;
+ struct HPMHookPoint *HP_rnd_random_post;
+ struct HPMHookPoint *HP_rnd_roll_pre;
+ struct HPMHookPoint *HP_rnd_roll_post;
+ struct HPMHookPoint *HP_rnd_value_pre;
+ struct HPMHookPoint *HP_rnd_value_post;
+ struct HPMHookPoint *HP_rnd_uniform_pre;
+ struct HPMHookPoint *HP_rnd_uniform_post;
+ struct HPMHookPoint *HP_rnd_uniform53_pre;
+ struct HPMHookPoint *HP_rnd_uniform53_post;
struct HPMHookPoint *HP_showmsg_init_pre;
struct HPMHookPoint *HP_showmsg_init_post;
struct HPMHookPoint *HP_showmsg_final_pre;
@@ -630,6 +676,28 @@ struct {
struct HPMHookPoint *HP_sysinfo_init_post;
struct HPMHookPoint *HP_sysinfo_final_pre;
struct HPMHookPoint *HP_sysinfo_final_post;
+ struct HPMHookPoint *HP_thread_init_pre;
+ struct HPMHookPoint *HP_thread_init_post;
+ struct HPMHookPoint *HP_thread_final_pre;
+ struct HPMHookPoint *HP_thread_final_post;
+ struct HPMHookPoint *HP_thread_create_pre;
+ struct HPMHookPoint *HP_thread_create_post;
+ struct HPMHookPoint *HP_thread_create_opt_pre;
+ struct HPMHookPoint *HP_thread_create_opt_post;
+ struct HPMHookPoint *HP_thread_destroy_pre;
+ struct HPMHookPoint *HP_thread_destroy_post;
+ struct HPMHookPoint *HP_thread_self_pre;
+ struct HPMHookPoint *HP_thread_self_post;
+ struct HPMHookPoint *HP_thread_get_tid_pre;
+ struct HPMHookPoint *HP_thread_get_tid_post;
+ struct HPMHookPoint *HP_thread_wait_pre;
+ struct HPMHookPoint *HP_thread_wait_post;
+ struct HPMHookPoint *HP_thread_prio_set_pre;
+ struct HPMHookPoint *HP_thread_prio_set_post;
+ struct HPMHookPoint *HP_thread_prio_get_pre;
+ struct HPMHookPoint *HP_thread_prio_get_post;
+ struct HPMHookPoint *HP_thread_yield_pre;
+ struct HPMHookPoint *HP_thread_yield_post;
struct HPMHookPoint *HP_timer_gettick_pre;
struct HPMHookPoint *HP_timer_gettick_post;
struct HPMHookPoint *HP_timer_gettick_nocache_pre;
@@ -725,6 +793,10 @@ struct {
int HP_DB_init_post;
int HP_DB_final_pre;
int HP_DB_final_post;
+ int HP_des_decrypt_block_pre;
+ int HP_des_decrypt_block_post;
+ int HP_des_decrypt_pre;
+ int HP_des_decrypt_post;
int HP_lclif_init_pre;
int HP_lclif_init_post;
int HP_lclif_final_pre;
@@ -1033,8 +1105,50 @@ struct {
int HP_iMalloc_post_shutdown_post;
int HP_iMalloc_init_messages_pre;
int HP_iMalloc_init_messages_post;
+ int HP_md5_string_pre;
+ int HP_md5_string_post;
+ int HP_md5_binary_pre;
+ int HP_md5_binary_post;
+ int HP_md5_salt_pre;
+ int HP_md5_salt_post;
+ int HP_mutex_create_pre;
+ int HP_mutex_create_post;
+ int HP_mutex_destroy_pre;
+ int HP_mutex_destroy_post;
+ int HP_mutex_lock_pre;
+ int HP_mutex_lock_post;
+ int HP_mutex_trylock_pre;
+ int HP_mutex_trylock_post;
+ int HP_mutex_unlock_pre;
+ int HP_mutex_unlock_post;
+ int HP_mutex_cond_create_pre;
+ int HP_mutex_cond_create_post;
+ int HP_mutex_cond_destroy_pre;
+ int HP_mutex_cond_destroy_post;
+ int HP_mutex_cond_wait_pre;
+ int HP_mutex_cond_wait_post;
+ int HP_mutex_cond_signal_pre;
+ int HP_mutex_cond_signal_post;
+ int HP_mutex_cond_broadcast_pre;
+ int HP_mutex_cond_broadcast_post;
int HP_nullpo_assert_report_pre;
int HP_nullpo_assert_report_post;
+ int HP_rnd_init_pre;
+ int HP_rnd_init_post;
+ int HP_rnd_final_pre;
+ int HP_rnd_final_post;
+ int HP_rnd_seed_pre;
+ int HP_rnd_seed_post;
+ int HP_rnd_random_pre;
+ int HP_rnd_random_post;
+ int HP_rnd_roll_pre;
+ int HP_rnd_roll_post;
+ int HP_rnd_value_pre;
+ int HP_rnd_value_post;
+ int HP_rnd_uniform_pre;
+ int HP_rnd_uniform_post;
+ int HP_rnd_uniform53_pre;
+ int HP_rnd_uniform53_post;
int HP_showmsg_init_pre;
int HP_showmsg_init_post;
int HP_showmsg_final_pre;
@@ -1263,6 +1377,28 @@ struct {
int HP_sysinfo_init_post;
int HP_sysinfo_final_pre;
int HP_sysinfo_final_post;
+ int HP_thread_init_pre;
+ int HP_thread_init_post;
+ int HP_thread_final_pre;
+ int HP_thread_final_post;
+ int HP_thread_create_pre;
+ int HP_thread_create_post;
+ int HP_thread_create_opt_pre;
+ int HP_thread_create_opt_post;
+ int HP_thread_destroy_pre;
+ int HP_thread_destroy_post;
+ int HP_thread_self_pre;
+ int HP_thread_self_post;
+ int HP_thread_get_tid_pre;
+ int HP_thread_get_tid_post;
+ int HP_thread_wait_pre;
+ int HP_thread_wait_post;
+ int HP_thread_prio_set_pre;
+ int HP_thread_prio_set_post;
+ int HP_thread_prio_get_pre;
+ int HP_thread_prio_get_post;
+ int HP_thread_yield_pre;
+ int HP_thread_yield_post;
int HP_timer_gettick_pre;
int HP_timer_gettick_post;
int HP_timer_gettick_nocache_pre;
@@ -1297,12 +1433,16 @@ struct {
struct console_interface console;
struct core_interface core;
struct db_interface DB;
+ struct des_interface des;
struct lclif_interface lclif;
struct lclif_interface_private PRIV__lclif;
struct libconfig_interface libconfig;
struct login_interface login;
struct malloc_interface iMalloc;
+ struct md5_interface md5;
+ struct mutex_interface mutex;
struct nullpo_interface nullpo;
+ struct rnd_interface rnd;
struct showmsg_interface showmsg;
struct socket_interface sockt;
struct sql_interface SQL;
@@ -1310,5 +1450,6 @@ struct {
struct strlib_interface strlib;
struct sv_interface sv;
struct sysinfo_interface sysinfo;
+ struct thread_interface thread;
struct timer_interface timer;
} source;
diff --git a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc
index cd846840b..2d3e37bc3 100644
--- a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc
+++ b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc
@@ -64,6 +64,9 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(DB->data2ptr, HP_DB_data2ptr) },
{ HP_POP(DB->init, HP_DB_init) },
{ HP_POP(DB->final, HP_DB_final) },
+/* des_interface */
+ { HP_POP(des->decrypt_block, HP_des_decrypt_block) },
+ { HP_POP(des->decrypt, HP_des_decrypt) },
/* lclif_interface */
{ HP_POP(lclif->init, HP_lclif_init) },
{ HP_POP(lclif->final, HP_lclif_final) },
@@ -223,8 +226,32 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(iMalloc->usage, HP_iMalloc_usage) },
{ HP_POP(iMalloc->post_shutdown, HP_iMalloc_post_shutdown) },
{ HP_POP(iMalloc->init_messages, HP_iMalloc_init_messages) },
+/* md5_interface */
+ { HP_POP(md5->string, HP_md5_string) },
+ { HP_POP(md5->binary, HP_md5_binary) },
+ { HP_POP(md5->salt, HP_md5_salt) },
+/* mutex_interface */
+ { HP_POP(mutex->create, HP_mutex_create) },
+ { HP_POP(mutex->destroy, HP_mutex_destroy) },
+ { HP_POP(mutex->lock, HP_mutex_lock) },
+ { HP_POP(mutex->trylock, HP_mutex_trylock) },
+ { HP_POP(mutex->unlock, HP_mutex_unlock) },
+ { HP_POP(mutex->cond_create, HP_mutex_cond_create) },
+ { HP_POP(mutex->cond_destroy, HP_mutex_cond_destroy) },
+ { HP_POP(mutex->cond_wait, HP_mutex_cond_wait) },
+ { HP_POP(mutex->cond_signal, HP_mutex_cond_signal) },
+ { HP_POP(mutex->cond_broadcast, HP_mutex_cond_broadcast) },
/* nullpo_interface */
{ HP_POP(nullpo->assert_report, HP_nullpo_assert_report) },
+/* rnd_interface */
+ { HP_POP(rnd->init, HP_rnd_init) },
+ { HP_POP(rnd->final, HP_rnd_final) },
+ { HP_POP(rnd->seed, HP_rnd_seed) },
+ { HP_POP(rnd->random, HP_rnd_random) },
+ { HP_POP(rnd->roll, HP_rnd_roll) },
+ { HP_POP(rnd->value, HP_rnd_value) },
+ { HP_POP(rnd->uniform, HP_rnd_uniform) },
+ { HP_POP(rnd->uniform53, HP_rnd_uniform53) },
/* showmsg_interface */
{ HP_POP(showmsg->init, HP_showmsg_init) },
{ HP_POP(showmsg->final, HP_showmsg_final) },
@@ -346,6 +373,18 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(sysinfo->is_superuser, HP_sysinfo_is_superuser) },
{ HP_POP(sysinfo->init, HP_sysinfo_init) },
{ HP_POP(sysinfo->final, HP_sysinfo_final) },
+/* thread_interface */
+ { HP_POP(thread->init, HP_thread_init) },
+ { HP_POP(thread->final, HP_thread_final) },
+ { HP_POP(thread->create, HP_thread_create) },
+ { HP_POP(thread->create_opt, HP_thread_create_opt) },
+ { HP_POP(thread->destroy, HP_thread_destroy) },
+ { HP_POP(thread->self, HP_thread_self) },
+ { HP_POP(thread->get_tid, HP_thread_get_tid) },
+ { HP_POP(thread->wait, HP_thread_wait) },
+ { HP_POP(thread->prio_set, HP_thread_prio_set) },
+ { HP_POP(thread->prio_get, HP_thread_prio_get) },
+ { HP_POP(thread->yield, HP_thread_yield) },
/* timer_interface */
{ HP_POP(timer->gettick, HP_timer_gettick) },
{ HP_POP(timer->gettick_nocache, HP_timer_gettick_nocache) },
diff --git a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc
index 23e2e2c90..013a56104 100644
--- a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc
+++ b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc
@@ -911,6 +911,59 @@ void HP_DB_final(void) {
}
return;
}
+/* des_interface */
+void HP_des_decrypt_block(struct des_bit64 *block) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_des_decrypt_block_pre ) {
+ void (*preHookFunc) (struct des_bit64 **block);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_block_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_des_decrypt_block_pre[hIndex].func;
+ preHookFunc(&block);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.des.decrypt_block(block);
+ }
+ if( HPMHooks.count.HP_des_decrypt_block_post ) {
+ void (*postHookFunc) (struct des_bit64 *block);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_block_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_des_decrypt_block_post[hIndex].func;
+ postHookFunc(block);
+ }
+ }
+ return;
+}
+void HP_des_decrypt(unsigned char *data, size_t size) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_des_decrypt_pre ) {
+ void (*preHookFunc) (unsigned char **data, size_t *size);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_des_decrypt_pre[hIndex].func;
+ preHookFunc(&data, &size);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.des.decrypt(data, size);
+ }
+ if( HPMHooks.count.HP_des_decrypt_post ) {
+ void (*postHookFunc) (unsigned char *data, size_t size);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_des_decrypt_post[hIndex].func;
+ postHookFunc(data, size);
+ }
+ }
+ return;
+}
/* lclif_interface */
void HP_lclif_init(void) {
int hIndex = 0;
@@ -5036,6 +5089,349 @@ void HP_iMalloc_init_messages(void) {
}
return;
}
+/* md5_interface */
+void HP_md5_string(const char *string, char *output) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_md5_string_pre ) {
+ void (*preHookFunc) (const char **string, char **output);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_string_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_md5_string_pre[hIndex].func;
+ preHookFunc(&string, &output);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.md5.string(string, output);
+ }
+ if( HPMHooks.count.HP_md5_string_post ) {
+ void (*postHookFunc) (const char *string, char *output);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_string_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_md5_string_post[hIndex].func;
+ postHookFunc(string, output);
+ }
+ }
+ return;
+}
+void HP_md5_binary(const char *string, unsigned char *output) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_md5_binary_pre ) {
+ void (*preHookFunc) (const char **string, unsigned char **output);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_md5_binary_pre[hIndex].func;
+ preHookFunc(&string, &output);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.md5.binary(string, output);
+ }
+ if( HPMHooks.count.HP_md5_binary_post ) {
+ void (*postHookFunc) (const char *string, unsigned char *output);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_md5_binary_post[hIndex].func;
+ postHookFunc(string, output);
+ }
+ }
+ return;
+}
+void HP_md5_salt(int len, char *output) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_md5_salt_pre ) {
+ void (*preHookFunc) (int *len, char **output);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_salt_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_md5_salt_pre[hIndex].func;
+ preHookFunc(&len, &output);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.md5.salt(len, output);
+ }
+ if( HPMHooks.count.HP_md5_salt_post ) {
+ void (*postHookFunc) (int len, char *output);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_salt_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_md5_salt_post[hIndex].func;
+ postHookFunc(len, output);
+ }
+ }
+ return;
+}
+/* mutex_interface */
+struct mutex_data* HP_mutex_create(void) {
+ int hIndex = 0;
+ struct mutex_data* retVal___ = NULL;
+ if( HPMHooks.count.HP_mutex_create_pre ) {
+ struct mutex_data* (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_create_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_create_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mutex.create();
+ }
+ if( HPMHooks.count.HP_mutex_create_post ) {
+ struct mutex_data* (*postHookFunc) (struct mutex_data* retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_create_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_create_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+void HP_mutex_destroy(struct mutex_data *m) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_destroy_pre ) {
+ void (*preHookFunc) (struct mutex_data **m);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_destroy_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_destroy_pre[hIndex].func;
+ preHookFunc(&m);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.destroy(m);
+ }
+ if( HPMHooks.count.HP_mutex_destroy_post ) {
+ void (*postHookFunc) (struct mutex_data *m);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_destroy_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_destroy_post[hIndex].func;
+ postHookFunc(m);
+ }
+ }
+ return;
+}
+void HP_mutex_lock(struct mutex_data *m) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_lock_pre ) {
+ void (*preHookFunc) (struct mutex_data **m);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_lock_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_lock_pre[hIndex].func;
+ preHookFunc(&m);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.lock(m);
+ }
+ if( HPMHooks.count.HP_mutex_lock_post ) {
+ void (*postHookFunc) (struct mutex_data *m);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_lock_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_lock_post[hIndex].func;
+ postHookFunc(m);
+ }
+ }
+ return;
+}
+bool HP_mutex_trylock(struct mutex_data *m) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_mutex_trylock_pre ) {
+ bool (*preHookFunc) (struct mutex_data **m);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_trylock_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_trylock_pre[hIndex].func;
+ retVal___ = preHookFunc(&m);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mutex.trylock(m);
+ }
+ if( HPMHooks.count.HP_mutex_trylock_post ) {
+ bool (*postHookFunc) (bool retVal___, struct mutex_data *m);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_trylock_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_trylock_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, m);
+ }
+ }
+ return retVal___;
+}
+void HP_mutex_unlock(struct mutex_data *m) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_unlock_pre ) {
+ void (*preHookFunc) (struct mutex_data **m);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_unlock_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_unlock_pre[hIndex].func;
+ preHookFunc(&m);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.unlock(m);
+ }
+ if( HPMHooks.count.HP_mutex_unlock_post ) {
+ void (*postHookFunc) (struct mutex_data *m);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_unlock_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_unlock_post[hIndex].func;
+ postHookFunc(m);
+ }
+ }
+ return;
+}
+struct cond_data* HP_mutex_cond_create(void) {
+ int hIndex = 0;
+ struct cond_data* retVal___ = NULL;
+ if( HPMHooks.count.HP_mutex_cond_create_pre ) {
+ struct cond_data* (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_create_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_cond_create_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mutex.cond_create();
+ }
+ if( HPMHooks.count.HP_mutex_cond_create_post ) {
+ struct cond_data* (*postHookFunc) (struct cond_data* retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_create_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_cond_create_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+void HP_mutex_cond_destroy(struct cond_data *c) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_cond_destroy_pre ) {
+ void (*preHookFunc) (struct cond_data **c);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_destroy_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_cond_destroy_pre[hIndex].func;
+ preHookFunc(&c);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.cond_destroy(c);
+ }
+ if( HPMHooks.count.HP_mutex_cond_destroy_post ) {
+ void (*postHookFunc) (struct cond_data *c);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_destroy_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_cond_destroy_post[hIndex].func;
+ postHookFunc(c);
+ }
+ }
+ return;
+}
+void HP_mutex_cond_wait(struct cond_data *c, struct mutex_data *m, sysint timeout_ticks) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_cond_wait_pre ) {
+ void (*preHookFunc) (struct cond_data **c, struct mutex_data **m, sysint *timeout_ticks);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_wait_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_cond_wait_pre[hIndex].func;
+ preHookFunc(&c, &m, &timeout_ticks);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.cond_wait(c, m, timeout_ticks);
+ }
+ if( HPMHooks.count.HP_mutex_cond_wait_post ) {
+ void (*postHookFunc) (struct cond_data *c, struct mutex_data *m, sysint timeout_ticks);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_wait_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_cond_wait_post[hIndex].func;
+ postHookFunc(c, m, timeout_ticks);
+ }
+ }
+ return;
+}
+void HP_mutex_cond_signal(struct cond_data *c) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_cond_signal_pre ) {
+ void (*preHookFunc) (struct cond_data **c);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_signal_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_cond_signal_pre[hIndex].func;
+ preHookFunc(&c);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.cond_signal(c);
+ }
+ if( HPMHooks.count.HP_mutex_cond_signal_post ) {
+ void (*postHookFunc) (struct cond_data *c);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_signal_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_cond_signal_post[hIndex].func;
+ postHookFunc(c);
+ }
+ }
+ return;
+}
+void HP_mutex_cond_broadcast(struct cond_data *c) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_cond_broadcast_pre ) {
+ void (*preHookFunc) (struct cond_data **c);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_broadcast_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_cond_broadcast_pre[hIndex].func;
+ preHookFunc(&c);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.cond_broadcast(c);
+ }
+ if( HPMHooks.count.HP_mutex_cond_broadcast_post ) {
+ void (*postHookFunc) (struct cond_data *c);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_broadcast_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_cond_broadcast_post[hIndex].func;
+ postHookFunc(c);
+ }
+ }
+ return;
+}
/* nullpo_interface */
void HP_nullpo_assert_report(const char *file, int line, const char *func, const char *targetname, const char *title) {
int hIndex = 0;
@@ -5063,6 +5459,220 @@ void HP_nullpo_assert_report(const char *file, int line, const char *func, const
}
return;
}
+/* rnd_interface */
+void HP_rnd_init(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_rnd_init_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_init_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.rnd.init();
+ }
+ if( HPMHooks.count.HP_rnd_init_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_init_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_rnd_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_rnd_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.rnd.final();
+ }
+ if( HPMHooks.count.HP_rnd_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_rnd_seed(uint32 seed) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_rnd_seed_pre ) {
+ void (*preHookFunc) (uint32 *seed);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_seed_pre[hIndex].func;
+ preHookFunc(&seed);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.rnd.seed(seed);
+ }
+ if( HPMHooks.count.HP_rnd_seed_post ) {
+ void (*postHookFunc) (uint32 seed);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_seed_post[hIndex].func;
+ postHookFunc(seed);
+ }
+ }
+ return;
+}
+int32 HP_rnd_random(void) {
+ int hIndex = 0;
+ int32 retVal___ = 0;
+ if( HPMHooks.count.HP_rnd_random_pre ) {
+ int32 (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_random_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.rnd.random();
+ }
+ if( HPMHooks.count.HP_rnd_random_post ) {
+ int32 (*postHookFunc) (int32 retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_random_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+uint32 HP_rnd_roll(uint32 dice_faces) {
+ int hIndex = 0;
+ uint32 retVal___ = 0;
+ if( HPMHooks.count.HP_rnd_roll_pre ) {
+ uint32 (*preHookFunc) (uint32 *dice_faces);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_roll_pre[hIndex].func;
+ retVal___ = preHookFunc(&dice_faces);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.rnd.roll(dice_faces);
+ }
+ if( HPMHooks.count.HP_rnd_roll_post ) {
+ uint32 (*postHookFunc) (uint32 retVal___, uint32 dice_faces);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_roll_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, dice_faces);
+ }
+ }
+ return retVal___;
+}
+int32 HP_rnd_value(int32 min, int32 max) {
+ int hIndex = 0;
+ int32 retVal___ = 0;
+ if( HPMHooks.count.HP_rnd_value_pre ) {
+ int32 (*preHookFunc) (int32 *min, int32 *max);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_value_pre[hIndex].func;
+ retVal___ = preHookFunc(&min, &max);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.rnd.value(min, max);
+ }
+ if( HPMHooks.count.HP_rnd_value_post ) {
+ int32 (*postHookFunc) (int32 retVal___, int32 min, int32 max);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_value_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, min, max);
+ }
+ }
+ return retVal___;
+}
+double HP_rnd_uniform(void) {
+ int hIndex = 0;
+ double retVal___ = 0.;
+ if( HPMHooks.count.HP_rnd_uniform_pre ) {
+ double (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_uniform_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.rnd.uniform();
+ }
+ if( HPMHooks.count.HP_rnd_uniform_post ) {
+ double (*postHookFunc) (double retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_uniform_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+double HP_rnd_uniform53(void) {
+ int hIndex = 0;
+ double retVal___ = 0.;
+ if( HPMHooks.count.HP_rnd_uniform53_pre ) {
+ double (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_uniform53_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.rnd.uniform53();
+ }
+ if( HPMHooks.count.HP_rnd_uniform53_post ) {
+ double (*postHookFunc) (double retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_uniform53_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
/* showmsg_interface */
void HP_showmsg_init(void) {
int hIndex = 0;
@@ -8146,6 +8756,299 @@ void HP_sysinfo_final(void) {
}
return;
}
+/* thread_interface */
+void HP_thread_init(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_thread_init_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_init_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.thread.init();
+ }
+ if( HPMHooks.count.HP_thread_init_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_init_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_thread_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_thread_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.thread.final();
+ }
+ if( HPMHooks.count.HP_thread_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+struct thread_handle* HP_thread_create(threadFunc entry_point, void *param) {
+ int hIndex = 0;
+ struct thread_handle* retVal___ = NULL;
+ if( HPMHooks.count.HP_thread_create_pre ) {
+ struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_create_pre[hIndex].func;
+ retVal___ = preHookFunc(&entry_point, &param);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.create(entry_point, param);
+ }
+ if( HPMHooks.count.HP_thread_create_post ) {
+ struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_create_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, entry_point, param);
+ }
+ }
+ return retVal___;
+}
+struct thread_handle* HP_thread_create_opt(threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio) {
+ int hIndex = 0;
+ struct thread_handle* retVal___ = NULL;
+ if( HPMHooks.count.HP_thread_create_opt_pre ) {
+ struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param, size_t *stack_size, enum thread_priority *prio);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_create_opt_pre[hIndex].func;
+ retVal___ = preHookFunc(&entry_point, &param, &stack_size, &prio);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.create_opt(entry_point, param, stack_size, prio);
+ }
+ if( HPMHooks.count.HP_thread_create_opt_post ) {
+ struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_create_opt_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, entry_point, param, stack_size, prio);
+ }
+ }
+ return retVal___;
+}
+void HP_thread_destroy(struct thread_handle *handle) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_thread_destroy_pre ) {
+ void (*preHookFunc) (struct thread_handle **handle);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_destroy_pre[hIndex].func;
+ preHookFunc(&handle);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.thread.destroy(handle);
+ }
+ if( HPMHooks.count.HP_thread_destroy_post ) {
+ void (*postHookFunc) (struct thread_handle *handle);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_destroy_post[hIndex].func;
+ postHookFunc(handle);
+ }
+ }
+ return;
+}
+struct thread_handle* HP_thread_self(void) {
+ int hIndex = 0;
+ struct thread_handle* retVal___ = NULL;
+ if( HPMHooks.count.HP_thread_self_pre ) {
+ struct thread_handle* (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_self_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.self();
+ }
+ if( HPMHooks.count.HP_thread_self_post ) {
+ struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_self_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+int HP_thread_get_tid(void) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_thread_get_tid_pre ) {
+ int (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_get_tid_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.get_tid();
+ }
+ if( HPMHooks.count.HP_thread_get_tid_post ) {
+ int (*postHookFunc) (int retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_get_tid_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+bool HP_thread_wait(struct thread_handle *handle, void **out_exit_code) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_thread_wait_pre ) {
+ bool (*preHookFunc) (struct thread_handle **handle, void ***out_exit_code);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_wait_pre[hIndex].func;
+ retVal___ = preHookFunc(&handle, &out_exit_code);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.wait(handle, out_exit_code);
+ }
+ if( HPMHooks.count.HP_thread_wait_post ) {
+ bool (*postHookFunc) (bool retVal___, struct thread_handle *handle, void **out_exit_code);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_wait_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, handle, out_exit_code);
+ }
+ }
+ return retVal___;
+}
+void HP_thread_prio_set(struct thread_handle *handle, enum thread_priority prio) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_thread_prio_set_pre ) {
+ void (*preHookFunc) (struct thread_handle **handle, enum thread_priority *prio);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_prio_set_pre[hIndex].func;
+ preHookFunc(&handle, &prio);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.thread.prio_set(handle, prio);
+ }
+ if( HPMHooks.count.HP_thread_prio_set_post ) {
+ void (*postHookFunc) (struct thread_handle *handle, enum thread_priority prio);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_prio_set_post[hIndex].func;
+ postHookFunc(handle, prio);
+ }
+ }
+ return;
+}
+enum thread_priority HP_thread_prio_get(struct thread_handle *handle) {
+ int hIndex = 0;
+ enum thread_priority retVal___ = THREADPRIO_NORMAL;
+ if( HPMHooks.count.HP_thread_prio_get_pre ) {
+ enum thread_priority (*preHookFunc) (struct thread_handle **handle);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_prio_get_pre[hIndex].func;
+ retVal___ = preHookFunc(&handle);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.prio_get(handle);
+ }
+ if( HPMHooks.count.HP_thread_prio_get_post ) {
+ enum thread_priority (*postHookFunc) (enum thread_priority retVal___, struct thread_handle *handle);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_prio_get_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, handle);
+ }
+ }
+ return retVal___;
+}
+void HP_thread_yield(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_thread_yield_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_yield_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.thread.yield();
+ }
+ if( HPMHooks.count.HP_thread_yield_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_yield_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
/* timer_interface */
int64 HP_timer_gettick(void) {
int hIndex = 0;
diff --git a/src/plugins/HPMHooking/HPMHooking_login.sources.inc b/src/plugins/HPMHooking/HPMHooking_login.sources.inc
index 10558043c..6677a0c55 100644
--- a/src/plugins/HPMHooking/HPMHooking_login.sources.inc
+++ b/src/plugins/HPMHooking/HPMHooking_login.sources.inc
@@ -30,12 +30,16 @@ memcpy(&HPMHooks.source.cmdline, cmdline, sizeof(struct cmdline_interface));
memcpy(&HPMHooks.source.console, console, sizeof(struct console_interface));
memcpy(&HPMHooks.source.core, core, sizeof(struct core_interface));
memcpy(&HPMHooks.source.DB, DB, sizeof(struct db_interface));
+memcpy(&HPMHooks.source.des, des, sizeof(struct des_interface));
memcpy(&HPMHooks.source.lclif, lclif, sizeof(struct lclif_interface));
memcpy(&HPMHooks.source.PRIV__lclif, lclif->p, sizeof(struct lclif_interface_private));
memcpy(&HPMHooks.source.libconfig, libconfig, sizeof(struct libconfig_interface));
memcpy(&HPMHooks.source.login, login, sizeof(struct login_interface));
memcpy(&HPMHooks.source.iMalloc, iMalloc, sizeof(struct malloc_interface));
+memcpy(&HPMHooks.source.md5, md5, sizeof(struct md5_interface));
+memcpy(&HPMHooks.source.mutex, mutex, sizeof(struct mutex_interface));
memcpy(&HPMHooks.source.nullpo, nullpo, sizeof(struct nullpo_interface));
+memcpy(&HPMHooks.source.rnd, rnd, sizeof(struct rnd_interface));
memcpy(&HPMHooks.source.showmsg, showmsg, sizeof(struct showmsg_interface));
memcpy(&HPMHooks.source.sockt, sockt, sizeof(struct socket_interface));
memcpy(&HPMHooks.source.SQL, SQL, sizeof(struct sql_interface));
@@ -43,4 +47,5 @@ memcpy(&HPMHooks.source.StrBuf, StrBuf, sizeof(struct stringbuf_interface));
memcpy(&HPMHooks.source.strlib, strlib, sizeof(struct strlib_interface));
memcpy(&HPMHooks.source.sv, sv, sizeof(struct sv_interface));
memcpy(&HPMHooks.source.sysinfo, sysinfo, sizeof(struct sysinfo_interface));
+memcpy(&HPMHooks.source.thread, thread, sizeof(struct thread_interface));
memcpy(&HPMHooks.source.timer, timer, sizeof(struct timer_interface));
diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
index 591c6b147..7131f486c 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
@@ -1928,6 +1928,10 @@ struct {
struct HPMHookPoint *HP_DB_init_post;
struct HPMHookPoint *HP_DB_final_pre;
struct HPMHookPoint *HP_DB_final_post;
+ struct HPMHookPoint *HP_des_decrypt_block_pre;
+ struct HPMHookPoint *HP_des_decrypt_block_post;
+ struct HPMHookPoint *HP_des_decrypt_pre;
+ struct HPMHookPoint *HP_des_decrypt_post;
struct HPMHookPoint *HP_duel_create_pre;
struct HPMHookPoint *HP_duel_create_post;
struct HPMHookPoint *HP_duel_invite_pre;
@@ -2010,6 +2014,20 @@ struct {
struct HPMHookPoint *HP_elemental_ai_timer_post;
struct HPMHookPoint *HP_elemental_read_db_pre;
struct HPMHookPoint *HP_elemental_read_db_post;
+ struct HPMHookPoint *HP_grfio_init_pre;
+ struct HPMHookPoint *HP_grfio_init_post;
+ struct HPMHookPoint *HP_grfio_final_pre;
+ struct HPMHookPoint *HP_grfio_final_post;
+ struct HPMHookPoint *HP_grfio_reads_pre;
+ struct HPMHookPoint *HP_grfio_reads_post;
+ struct HPMHookPoint *HP_grfio_find_file_pre;
+ struct HPMHookPoint *HP_grfio_find_file_post;
+ struct HPMHookPoint *HP_grfio_crc32_pre;
+ struct HPMHookPoint *HP_grfio_crc32_post;
+ struct HPMHookPoint *HP_grfio_decode_zip_pre;
+ struct HPMHookPoint *HP_grfio_decode_zip_post;
+ struct HPMHookPoint *HP_grfio_encode_zip_pre;
+ struct HPMHookPoint *HP_grfio_encode_zip_post;
struct HPMHookPoint *HP_guild_init_pre;
struct HPMHookPoint *HP_guild_init_post;
struct HPMHookPoint *HP_guild_final_pre;
@@ -3310,6 +3328,12 @@ struct {
struct HPMHookPoint *HP_mapreg_reload_post;
struct HPMHookPoint *HP_mapreg_config_read_pre;
struct HPMHookPoint *HP_mapreg_config_read_post;
+ struct HPMHookPoint *HP_md5_string_pre;
+ struct HPMHookPoint *HP_md5_string_post;
+ struct HPMHookPoint *HP_md5_binary_pre;
+ struct HPMHookPoint *HP_md5_binary_post;
+ struct HPMHookPoint *HP_md5_salt_pre;
+ struct HPMHookPoint *HP_md5_salt_post;
struct HPMHookPoint *HP_mercenary_init_pre;
struct HPMHookPoint *HP_mercenary_init_post;
struct HPMHookPoint *HP_mercenary_class_pre;
@@ -3566,6 +3590,26 @@ struct {
struct HPMHookPoint *HP_mob_clear_spawninfo_post;
struct HPMHookPoint *HP_mob_destroy_mob_db_pre;
struct HPMHookPoint *HP_mob_destroy_mob_db_post;
+ struct HPMHookPoint *HP_mutex_create_pre;
+ struct HPMHookPoint *HP_mutex_create_post;
+ struct HPMHookPoint *HP_mutex_destroy_pre;
+ struct HPMHookPoint *HP_mutex_destroy_post;
+ struct HPMHookPoint *HP_mutex_lock_pre;
+ struct HPMHookPoint *HP_mutex_lock_post;
+ struct HPMHookPoint *HP_mutex_trylock_pre;
+ struct HPMHookPoint *HP_mutex_trylock_post;
+ struct HPMHookPoint *HP_mutex_unlock_pre;
+ struct HPMHookPoint *HP_mutex_unlock_post;
+ struct HPMHookPoint *HP_mutex_cond_create_pre;
+ struct HPMHookPoint *HP_mutex_cond_create_post;
+ struct HPMHookPoint *HP_mutex_cond_destroy_pre;
+ struct HPMHookPoint *HP_mutex_cond_destroy_post;
+ struct HPMHookPoint *HP_mutex_cond_wait_pre;
+ struct HPMHookPoint *HP_mutex_cond_wait_post;
+ struct HPMHookPoint *HP_mutex_cond_signal_pre;
+ struct HPMHookPoint *HP_mutex_cond_signal_post;
+ struct HPMHookPoint *HP_mutex_cond_broadcast_pre;
+ struct HPMHookPoint *HP_mutex_cond_broadcast_post;
struct HPMHookPoint *HP_npc_chat_sub_pre;
struct HPMHookPoint *HP_npc_chat_sub_post;
struct HPMHookPoint *HP_npc_chat_finalize_pre;
@@ -4500,6 +4544,22 @@ struct {
struct HPMHookPoint *HP_quest_read_db_post;
struct HPMHookPoint *HP_quest_read_db_sub_pre;
struct HPMHookPoint *HP_quest_read_db_sub_post;
+ struct HPMHookPoint *HP_rnd_init_pre;
+ struct HPMHookPoint *HP_rnd_init_post;
+ struct HPMHookPoint *HP_rnd_final_pre;
+ struct HPMHookPoint *HP_rnd_final_post;
+ struct HPMHookPoint *HP_rnd_seed_pre;
+ struct HPMHookPoint *HP_rnd_seed_post;
+ struct HPMHookPoint *HP_rnd_random_pre;
+ struct HPMHookPoint *HP_rnd_random_post;
+ struct HPMHookPoint *HP_rnd_roll_pre;
+ struct HPMHookPoint *HP_rnd_roll_post;
+ struct HPMHookPoint *HP_rnd_value_pre;
+ struct HPMHookPoint *HP_rnd_value_post;
+ struct HPMHookPoint *HP_rnd_uniform_pre;
+ struct HPMHookPoint *HP_rnd_uniform_post;
+ struct HPMHookPoint *HP_rnd_uniform53_pre;
+ struct HPMHookPoint *HP_rnd_uniform53_post;
struct HPMHookPoint *HP_script_init_pre;
struct HPMHookPoint *HP_script_init_post;
struct HPMHookPoint *HP_script_final_pre;
@@ -5822,6 +5882,28 @@ struct {
struct HPMHookPoint *HP_sysinfo_init_post;
struct HPMHookPoint *HP_sysinfo_final_pre;
struct HPMHookPoint *HP_sysinfo_final_post;
+ struct HPMHookPoint *HP_thread_init_pre;
+ struct HPMHookPoint *HP_thread_init_post;
+ struct HPMHookPoint *HP_thread_final_pre;
+ struct HPMHookPoint *HP_thread_final_post;
+ struct HPMHookPoint *HP_thread_create_pre;
+ struct HPMHookPoint *HP_thread_create_post;
+ struct HPMHookPoint *HP_thread_create_opt_pre;
+ struct HPMHookPoint *HP_thread_create_opt_post;
+ struct HPMHookPoint *HP_thread_destroy_pre;
+ struct HPMHookPoint *HP_thread_destroy_post;
+ struct HPMHookPoint *HP_thread_self_pre;
+ struct HPMHookPoint *HP_thread_self_post;
+ struct HPMHookPoint *HP_thread_get_tid_pre;
+ struct HPMHookPoint *HP_thread_get_tid_post;
+ struct HPMHookPoint *HP_thread_wait_pre;
+ struct HPMHookPoint *HP_thread_wait_post;
+ struct HPMHookPoint *HP_thread_prio_set_pre;
+ struct HPMHookPoint *HP_thread_prio_set_post;
+ struct HPMHookPoint *HP_thread_prio_get_pre;
+ struct HPMHookPoint *HP_thread_prio_get_post;
+ struct HPMHookPoint *HP_thread_yield_pre;
+ struct HPMHookPoint *HP_thread_yield_post;
struct HPMHookPoint *HP_timer_gettick_pre;
struct HPMHookPoint *HP_timer_gettick_post;
struct HPMHookPoint *HP_timer_gettick_nocache_pre;
@@ -7885,6 +7967,10 @@ struct {
int HP_DB_init_post;
int HP_DB_final_pre;
int HP_DB_final_post;
+ int HP_des_decrypt_block_pre;
+ int HP_des_decrypt_block_post;
+ int HP_des_decrypt_pre;
+ int HP_des_decrypt_post;
int HP_duel_create_pre;
int HP_duel_create_post;
int HP_duel_invite_pre;
@@ -7967,6 +8053,20 @@ struct {
int HP_elemental_ai_timer_post;
int HP_elemental_read_db_pre;
int HP_elemental_read_db_post;
+ int HP_grfio_init_pre;
+ int HP_grfio_init_post;
+ int HP_grfio_final_pre;
+ int HP_grfio_final_post;
+ int HP_grfio_reads_pre;
+ int HP_grfio_reads_post;
+ int HP_grfio_find_file_pre;
+ int HP_grfio_find_file_post;
+ int HP_grfio_crc32_pre;
+ int HP_grfio_crc32_post;
+ int HP_grfio_decode_zip_pre;
+ int HP_grfio_decode_zip_post;
+ int HP_grfio_encode_zip_pre;
+ int HP_grfio_encode_zip_post;
int HP_guild_init_pre;
int HP_guild_init_post;
int HP_guild_final_pre;
@@ -9267,6 +9367,12 @@ struct {
int HP_mapreg_reload_post;
int HP_mapreg_config_read_pre;
int HP_mapreg_config_read_post;
+ int HP_md5_string_pre;
+ int HP_md5_string_post;
+ int HP_md5_binary_pre;
+ int HP_md5_binary_post;
+ int HP_md5_salt_pre;
+ int HP_md5_salt_post;
int HP_mercenary_init_pre;
int HP_mercenary_init_post;
int HP_mercenary_class_pre;
@@ -9523,6 +9629,26 @@ struct {
int HP_mob_clear_spawninfo_post;
int HP_mob_destroy_mob_db_pre;
int HP_mob_destroy_mob_db_post;
+ int HP_mutex_create_pre;
+ int HP_mutex_create_post;
+ int HP_mutex_destroy_pre;
+ int HP_mutex_destroy_post;
+ int HP_mutex_lock_pre;
+ int HP_mutex_lock_post;
+ int HP_mutex_trylock_pre;
+ int HP_mutex_trylock_post;
+ int HP_mutex_unlock_pre;
+ int HP_mutex_unlock_post;
+ int HP_mutex_cond_create_pre;
+ int HP_mutex_cond_create_post;
+ int HP_mutex_cond_destroy_pre;
+ int HP_mutex_cond_destroy_post;
+ int HP_mutex_cond_wait_pre;
+ int HP_mutex_cond_wait_post;
+ int HP_mutex_cond_signal_pre;
+ int HP_mutex_cond_signal_post;
+ int HP_mutex_cond_broadcast_pre;
+ int HP_mutex_cond_broadcast_post;
int HP_npc_chat_sub_pre;
int HP_npc_chat_sub_post;
int HP_npc_chat_finalize_pre;
@@ -10457,6 +10583,22 @@ struct {
int HP_quest_read_db_post;
int HP_quest_read_db_sub_pre;
int HP_quest_read_db_sub_post;
+ int HP_rnd_init_pre;
+ int HP_rnd_init_post;
+ int HP_rnd_final_pre;
+ int HP_rnd_final_post;
+ int HP_rnd_seed_pre;
+ int HP_rnd_seed_post;
+ int HP_rnd_random_pre;
+ int HP_rnd_random_post;
+ int HP_rnd_roll_pre;
+ int HP_rnd_roll_post;
+ int HP_rnd_value_pre;
+ int HP_rnd_value_post;
+ int HP_rnd_uniform_pre;
+ int HP_rnd_uniform_post;
+ int HP_rnd_uniform53_pre;
+ int HP_rnd_uniform53_post;
int HP_script_init_pre;
int HP_script_init_post;
int HP_script_final_pre;
@@ -11779,6 +11921,28 @@ struct {
int HP_sysinfo_init_post;
int HP_sysinfo_final_pre;
int HP_sysinfo_final_post;
+ int HP_thread_init_pre;
+ int HP_thread_init_post;
+ int HP_thread_final_pre;
+ int HP_thread_final_post;
+ int HP_thread_create_pre;
+ int HP_thread_create_post;
+ int HP_thread_create_opt_pre;
+ int HP_thread_create_opt_post;
+ int HP_thread_destroy_pre;
+ int HP_thread_destroy_post;
+ int HP_thread_self_pre;
+ int HP_thread_self_post;
+ int HP_thread_get_tid_pre;
+ int HP_thread_get_tid_post;
+ int HP_thread_wait_pre;
+ int HP_thread_wait_post;
+ int HP_thread_prio_set_pre;
+ int HP_thread_prio_set_post;
+ int HP_thread_prio_get_pre;
+ int HP_thread_prio_get_post;
+ int HP_thread_yield_pre;
+ int HP_thread_yield_post;
int HP_timer_gettick_pre;
int HP_timer_gettick_post;
int HP_timer_gettick_nocache_pre;
@@ -11953,8 +12117,10 @@ struct {
struct console_interface console;
struct core_interface core;
struct db_interface DB;
+ struct des_interface des;
struct duel_interface duel;
struct elemental_interface elemental;
+ struct grfio_interface grfio;
struct guild_interface guild;
struct guild_storage_interface gstorage;
struct homunculus_interface homun;
@@ -11970,8 +12136,10 @@ struct {
struct mapindex_interface mapindex;
struct mapit_interface mapit;
struct mapreg_interface mapreg;
+ struct md5_interface md5;
struct mercenary_interface mercenary;
struct mob_interface mob;
+ struct mutex_interface mutex;
struct npc_chat_interface npc_chat;
struct npc_interface npc;
struct nullpo_interface nullpo;
@@ -11982,6 +12150,7 @@ struct {
struct pcre_interface libpcre;
struct pet_interface pet;
struct quest_interface quest;
+ struct rnd_interface rnd;
struct script_interface script;
struct searchstore_interface searchstore;
struct showmsg_interface showmsg;
@@ -11994,6 +12163,7 @@ struct {
struct strlib_interface strlib;
struct sv_interface sv;
struct sysinfo_interface sysinfo;
+ struct thread_interface thread;
struct timer_interface timer;
struct trade_interface trade;
struct unit_interface unit;
diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
index 014497ae2..cbf7ba79f 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
@@ -990,6 +990,9 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(DB->data2ptr, HP_DB_data2ptr) },
{ HP_POP(DB->init, HP_DB_init) },
{ HP_POP(DB->final, HP_DB_final) },
+/* des_interface */
+ { HP_POP(des->decrypt_block, HP_des_decrypt_block) },
+ { HP_POP(des->decrypt, HP_des_decrypt) },
/* duel_interface */
{ HP_POP(duel->create, HP_duel_create) },
{ HP_POP(duel->invite, HP_duel_invite) },
@@ -1033,6 +1036,14 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(elemental->ai_sub_foreachclient, HP_elemental_ai_sub_foreachclient) },
{ HP_POP(elemental->ai_timer, HP_elemental_ai_timer) },
{ HP_POP(elemental->read_db, HP_elemental_read_db) },
+/* grfio_interface */
+ { HP_POP(grfio->init, HP_grfio_init) },
+ { HP_POP(grfio->final, HP_grfio_final) },
+ { HP_POP(grfio->reads, HP_grfio_reads) },
+ { HP_POP(grfio->find_file, HP_grfio_find_file) },
+ { HP_POP(grfio->crc32, HP_grfio_crc32) },
+ { HP_POP(grfio->decode_zip, HP_grfio_decode_zip) },
+ { HP_POP(grfio->encode_zip, HP_grfio_encode_zip) },
/* guild_interface */
{ HP_POP(guild->init, HP_guild_init) },
{ HP_POP(guild->final, HP_guild_final) },
@@ -1698,6 +1709,10 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(mapreg->destroyreg, HP_mapreg_destroyreg) },
{ HP_POP(mapreg->reload, HP_mapreg_reload) },
{ HP_POP(mapreg->config_read, HP_mapreg_config_read) },
+/* md5_interface */
+ { HP_POP(md5->string, HP_md5_string) },
+ { HP_POP(md5->binary, HP_md5_binary) },
+ { HP_POP(md5->salt, HP_md5_salt) },
/* mercenary_interface */
{ HP_POP(mercenary->init, HP_mercenary_init) },
{ HP_POP(mercenary->class, HP_mercenary_class) },
@@ -1828,6 +1843,17 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(mob->load, HP_mob_load) },
{ HP_POP(mob->clear_spawninfo, HP_mob_clear_spawninfo) },
{ HP_POP(mob->destroy_mob_db, HP_mob_destroy_mob_db) },
+/* mutex_interface */
+ { HP_POP(mutex->create, HP_mutex_create) },
+ { HP_POP(mutex->destroy, HP_mutex_destroy) },
+ { HP_POP(mutex->lock, HP_mutex_lock) },
+ { HP_POP(mutex->trylock, HP_mutex_trylock) },
+ { HP_POP(mutex->unlock, HP_mutex_unlock) },
+ { HP_POP(mutex->cond_create, HP_mutex_cond_create) },
+ { HP_POP(mutex->cond_destroy, HP_mutex_cond_destroy) },
+ { HP_POP(mutex->cond_wait, HP_mutex_cond_wait) },
+ { HP_POP(mutex->cond_signal, HP_mutex_cond_signal) },
+ { HP_POP(mutex->cond_broadcast, HP_mutex_cond_broadcast) },
/* npc_chat_interface */
{ HP_POP(npc_chat->sub, HP_npc_chat_sub) },
{ HP_POP(npc_chat->finalize, HP_npc_chat_finalize) },
@@ -2305,6 +2331,15 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(quest->clear, HP_quest_clear) },
{ HP_POP(quest->read_db, HP_quest_read_db) },
{ HP_POP(quest->read_db_sub, HP_quest_read_db_sub) },
+/* rnd_interface */
+ { HP_POP(rnd->init, HP_rnd_init) },
+ { HP_POP(rnd->final, HP_rnd_final) },
+ { HP_POP(rnd->seed, HP_rnd_seed) },
+ { HP_POP(rnd->random, HP_rnd_random) },
+ { HP_POP(rnd->roll, HP_rnd_roll) },
+ { HP_POP(rnd->value, HP_rnd_value) },
+ { HP_POP(rnd->uniform, HP_rnd_uniform) },
+ { HP_POP(rnd->uniform53, HP_rnd_uniform53) },
/* script_interface */
{ HP_POP(script->init, HP_script_init) },
{ HP_POP(script->final, HP_script_final) },
@@ -2978,6 +3013,18 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(sysinfo->is_superuser, HP_sysinfo_is_superuser) },
{ HP_POP(sysinfo->init, HP_sysinfo_init) },
{ HP_POP(sysinfo->final, HP_sysinfo_final) },
+/* thread_interface */
+ { HP_POP(thread->init, HP_thread_init) },
+ { HP_POP(thread->final, HP_thread_final) },
+ { HP_POP(thread->create, HP_thread_create) },
+ { HP_POP(thread->create_opt, HP_thread_create_opt) },
+ { HP_POP(thread->destroy, HP_thread_destroy) },
+ { HP_POP(thread->self, HP_thread_self) },
+ { HP_POP(thread->get_tid, HP_thread_get_tid) },
+ { HP_POP(thread->wait, HP_thread_wait) },
+ { HP_POP(thread->prio_set, HP_thread_prio_set) },
+ { HP_POP(thread->prio_get, HP_thread_prio_get) },
+ { HP_POP(thread->yield, HP_thread_yield) },
/* timer_interface */
{ HP_POP(timer->gettick, HP_timer_gettick) },
{ HP_POP(timer->gettick_nocache, HP_timer_gettick_nocache) },
diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
index 850c54f80..2317f9392 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
@@ -25109,6 +25109,59 @@ void HP_DB_final(void) {
}
return;
}
+/* des_interface */
+void HP_des_decrypt_block(struct des_bit64 *block) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_des_decrypt_block_pre ) {
+ void (*preHookFunc) (struct des_bit64 **block);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_block_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_des_decrypt_block_pre[hIndex].func;
+ preHookFunc(&block);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.des.decrypt_block(block);
+ }
+ if( HPMHooks.count.HP_des_decrypt_block_post ) {
+ void (*postHookFunc) (struct des_bit64 *block);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_block_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_des_decrypt_block_post[hIndex].func;
+ postHookFunc(block);
+ }
+ }
+ return;
+}
+void HP_des_decrypt(unsigned char *data, size_t size) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_des_decrypt_pre ) {
+ void (*preHookFunc) (unsigned char **data, size_t *size);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_des_decrypt_pre[hIndex].func;
+ preHookFunc(&data, &size);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.des.decrypt(data, size);
+ }
+ if( HPMHooks.count.HP_des_decrypt_post ) {
+ void (*postHookFunc) (unsigned char *data, size_t size);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_des_decrypt_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_des_decrypt_post[hIndex].func;
+ postHookFunc(data, size);
+ }
+ }
+ return;
+}
/* duel_interface */
int HP_duel_create(struct map_session_data *sd, const unsigned int maxpl) {
int hIndex = 0;
@@ -26217,6 +26270,194 @@ int HP_elemental_read_db(void) {
}
return retVal___;
}
+/* grfio_interface */
+void HP_grfio_init(const char *fname) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_grfio_init_pre ) {
+ void (*preHookFunc) (const char **fname);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_grfio_init_pre[hIndex].func;
+ preHookFunc(&fname);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.grfio.init(fname);
+ }
+ if( HPMHooks.count.HP_grfio_init_post ) {
+ void (*postHookFunc) (const char *fname);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_grfio_init_post[hIndex].func;
+ postHookFunc(fname);
+ }
+ }
+ return;
+}
+void HP_grfio_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_grfio_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_grfio_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.grfio.final();
+ }
+ if( HPMHooks.count.HP_grfio_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_grfio_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void* HP_grfio_reads(const char *fname, int *size) {
+ int hIndex = 0;
+ void* retVal___ = NULL;
+ if( HPMHooks.count.HP_grfio_reads_pre ) {
+ void* (*preHookFunc) (const char **fname, int **size);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_reads_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_grfio_reads_pre[hIndex].func;
+ retVal___ = preHookFunc(&fname, &size);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.grfio.reads(fname, size);
+ }
+ if( HPMHooks.count.HP_grfio_reads_post ) {
+ void* (*postHookFunc) (void* retVal___, const char *fname, int *size);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_reads_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_grfio_reads_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, fname, size);
+ }
+ }
+ return retVal___;
+}
+const char* HP_grfio_find_file(const char *fname) {
+ int hIndex = 0;
+ const char* retVal___ = NULL;
+ if( HPMHooks.count.HP_grfio_find_file_pre ) {
+ const char* (*preHookFunc) (const char **fname);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_find_file_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_grfio_find_file_pre[hIndex].func;
+ retVal___ = preHookFunc(&fname);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.grfio.find_file(fname);
+ }
+ if( HPMHooks.count.HP_grfio_find_file_post ) {
+ const char* (*postHookFunc) (const char* retVal___, const char *fname);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_find_file_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_grfio_find_file_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, fname);
+ }
+ }
+ return retVal___;
+}
+unsigned long HP_grfio_crc32(const unsigned char *buf, unsigned int len) {
+ int hIndex = 0;
+ unsigned long retVal___ = 0;
+ if( HPMHooks.count.HP_grfio_crc32_pre ) {
+ unsigned long (*preHookFunc) (const unsigned char **buf, unsigned int *len);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_crc32_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_grfio_crc32_pre[hIndex].func;
+ retVal___ = preHookFunc(&buf, &len);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.grfio.crc32(buf, len);
+ }
+ if( HPMHooks.count.HP_grfio_crc32_post ) {
+ unsigned long (*postHookFunc) (unsigned long retVal___, const unsigned char *buf, unsigned int len);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_crc32_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_grfio_crc32_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, buf, len);
+ }
+ }
+ return retVal___;
+}
+int HP_grfio_decode_zip(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_grfio_decode_zip_pre ) {
+ int (*preHookFunc) (void **dest, unsigned long **dest_len, const void **source, unsigned long *source_len);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_decode_zip_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_grfio_decode_zip_pre[hIndex].func;
+ retVal___ = preHookFunc(&dest, &dest_len, &source, &source_len);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.grfio.decode_zip(dest, dest_len, source, source_len);
+ }
+ if( HPMHooks.count.HP_grfio_decode_zip_post ) {
+ int (*postHookFunc) (int retVal___, void *dest, unsigned long *dest_len, const void *source, unsigned long source_len);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_decode_zip_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_grfio_decode_zip_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, dest, dest_len, source, source_len);
+ }
+ }
+ return retVal___;
+}
+int HP_grfio_encode_zip(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_grfio_encode_zip_pre ) {
+ int (*preHookFunc) (void **dest, unsigned long **dest_len, const void **source, unsigned long *source_len);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_encode_zip_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_grfio_encode_zip_pre[hIndex].func;
+ retVal___ = preHookFunc(&dest, &dest_len, &source, &source_len);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.grfio.encode_zip(dest, dest_len, source, source_len);
+ }
+ if( HPMHooks.count.HP_grfio_encode_zip_post ) {
+ int (*postHookFunc) (int retVal___, void *dest, unsigned long *dest_len, const void *source, unsigned long source_len);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_grfio_encode_zip_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_grfio_encode_zip_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, dest, dest_len, source, source_len);
+ }
+ }
+ return retVal___;
+}
/* guild_interface */
void HP_guild_init(bool minimal) {
int hIndex = 0;
@@ -43809,6 +44050,85 @@ bool HP_mapreg_config_read(const char *w1, const char *w2) {
}
return retVal___;
}
+/* md5_interface */
+void HP_md5_string(const char *string, char *output) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_md5_string_pre ) {
+ void (*preHookFunc) (const char **string, char **output);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_string_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_md5_string_pre[hIndex].func;
+ preHookFunc(&string, &output);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.md5.string(string, output);
+ }
+ if( HPMHooks.count.HP_md5_string_post ) {
+ void (*postHookFunc) (const char *string, char *output);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_string_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_md5_string_post[hIndex].func;
+ postHookFunc(string, output);
+ }
+ }
+ return;
+}
+void HP_md5_binary(const char *string, unsigned char *output) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_md5_binary_pre ) {
+ void (*preHookFunc) (const char **string, unsigned char **output);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_md5_binary_pre[hIndex].func;
+ preHookFunc(&string, &output);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.md5.binary(string, output);
+ }
+ if( HPMHooks.count.HP_md5_binary_post ) {
+ void (*postHookFunc) (const char *string, unsigned char *output);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_md5_binary_post[hIndex].func;
+ postHookFunc(string, output);
+ }
+ }
+ return;
+}
+void HP_md5_salt(int len, char *output) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_md5_salt_pre ) {
+ void (*preHookFunc) (int *len, char **output);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_salt_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_md5_salt_pre[hIndex].func;
+ preHookFunc(&len, &output);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.md5.salt(len, output);
+ }
+ if( HPMHooks.count.HP_md5_salt_post ) {
+ void (*postHookFunc) (int len, char *output);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_salt_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_md5_salt_post[hIndex].func;
+ postHookFunc(len, output);
+ }
+ }
+ return;
+}
/* mercenary_interface */
void HP_mercenary_init(bool minimal) {
int hIndex = 0;
@@ -47334,6 +47654,270 @@ void HP_mob_destroy_mob_db(int index) {
}
return;
}
+/* mutex_interface */
+struct mutex_data* HP_mutex_create(void) {
+ int hIndex = 0;
+ struct mutex_data* retVal___ = NULL;
+ if( HPMHooks.count.HP_mutex_create_pre ) {
+ struct mutex_data* (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_create_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_create_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mutex.create();
+ }
+ if( HPMHooks.count.HP_mutex_create_post ) {
+ struct mutex_data* (*postHookFunc) (struct mutex_data* retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_create_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_create_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+void HP_mutex_destroy(struct mutex_data *m) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_destroy_pre ) {
+ void (*preHookFunc) (struct mutex_data **m);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_destroy_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_destroy_pre[hIndex].func;
+ preHookFunc(&m);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.destroy(m);
+ }
+ if( HPMHooks.count.HP_mutex_destroy_post ) {
+ void (*postHookFunc) (struct mutex_data *m);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_destroy_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_destroy_post[hIndex].func;
+ postHookFunc(m);
+ }
+ }
+ return;
+}
+void HP_mutex_lock(struct mutex_data *m) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_lock_pre ) {
+ void (*preHookFunc) (struct mutex_data **m);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_lock_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_lock_pre[hIndex].func;
+ preHookFunc(&m);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.lock(m);
+ }
+ if( HPMHooks.count.HP_mutex_lock_post ) {
+ void (*postHookFunc) (struct mutex_data *m);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_lock_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_lock_post[hIndex].func;
+ postHookFunc(m);
+ }
+ }
+ return;
+}
+bool HP_mutex_trylock(struct mutex_data *m) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_mutex_trylock_pre ) {
+ bool (*preHookFunc) (struct mutex_data **m);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_trylock_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_trylock_pre[hIndex].func;
+ retVal___ = preHookFunc(&m);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mutex.trylock(m);
+ }
+ if( HPMHooks.count.HP_mutex_trylock_post ) {
+ bool (*postHookFunc) (bool retVal___, struct mutex_data *m);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_trylock_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_trylock_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, m);
+ }
+ }
+ return retVal___;
+}
+void HP_mutex_unlock(struct mutex_data *m) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_unlock_pre ) {
+ void (*preHookFunc) (struct mutex_data **m);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_unlock_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_unlock_pre[hIndex].func;
+ preHookFunc(&m);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.unlock(m);
+ }
+ if( HPMHooks.count.HP_mutex_unlock_post ) {
+ void (*postHookFunc) (struct mutex_data *m);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_unlock_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_unlock_post[hIndex].func;
+ postHookFunc(m);
+ }
+ }
+ return;
+}
+struct cond_data* HP_mutex_cond_create(void) {
+ int hIndex = 0;
+ struct cond_data* retVal___ = NULL;
+ if( HPMHooks.count.HP_mutex_cond_create_pre ) {
+ struct cond_data* (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_create_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_cond_create_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.mutex.cond_create();
+ }
+ if( HPMHooks.count.HP_mutex_cond_create_post ) {
+ struct cond_data* (*postHookFunc) (struct cond_data* retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_create_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_cond_create_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+void HP_mutex_cond_destroy(struct cond_data *c) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_cond_destroy_pre ) {
+ void (*preHookFunc) (struct cond_data **c);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_destroy_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_cond_destroy_pre[hIndex].func;
+ preHookFunc(&c);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.cond_destroy(c);
+ }
+ if( HPMHooks.count.HP_mutex_cond_destroy_post ) {
+ void (*postHookFunc) (struct cond_data *c);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_destroy_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_cond_destroy_post[hIndex].func;
+ postHookFunc(c);
+ }
+ }
+ return;
+}
+void HP_mutex_cond_wait(struct cond_data *c, struct mutex_data *m, sysint timeout_ticks) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_cond_wait_pre ) {
+ void (*preHookFunc) (struct cond_data **c, struct mutex_data **m, sysint *timeout_ticks);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_wait_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_cond_wait_pre[hIndex].func;
+ preHookFunc(&c, &m, &timeout_ticks);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.cond_wait(c, m, timeout_ticks);
+ }
+ if( HPMHooks.count.HP_mutex_cond_wait_post ) {
+ void (*postHookFunc) (struct cond_data *c, struct mutex_data *m, sysint timeout_ticks);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_wait_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_cond_wait_post[hIndex].func;
+ postHookFunc(c, m, timeout_ticks);
+ }
+ }
+ return;
+}
+void HP_mutex_cond_signal(struct cond_data *c) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_cond_signal_pre ) {
+ void (*preHookFunc) (struct cond_data **c);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_signal_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_cond_signal_pre[hIndex].func;
+ preHookFunc(&c);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.cond_signal(c);
+ }
+ if( HPMHooks.count.HP_mutex_cond_signal_post ) {
+ void (*postHookFunc) (struct cond_data *c);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_signal_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_cond_signal_post[hIndex].func;
+ postHookFunc(c);
+ }
+ }
+ return;
+}
+void HP_mutex_cond_broadcast(struct cond_data *c) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_mutex_cond_broadcast_pre ) {
+ void (*preHookFunc) (struct cond_data **c);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_broadcast_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_mutex_cond_broadcast_pre[hIndex].func;
+ preHookFunc(&c);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.mutex.cond_broadcast(c);
+ }
+ if( HPMHooks.count.HP_mutex_cond_broadcast_post ) {
+ void (*postHookFunc) (struct cond_data *c);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_mutex_cond_broadcast_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_mutex_cond_broadcast_post[hIndex].func;
+ postHookFunc(c);
+ }
+ }
+ return;
+}
/* npc_chat_interface */
int HP_npc_chat_sub(struct block_list *bl, va_list ap) {
int hIndex = 0;
@@ -59988,6 +60572,220 @@ struct quest_db* HP_quest_read_db_sub(struct config_setting_t *cs, int n, const
}
return retVal___;
}
+/* rnd_interface */
+void HP_rnd_init(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_rnd_init_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_init_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.rnd.init();
+ }
+ if( HPMHooks.count.HP_rnd_init_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_init_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_rnd_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_rnd_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.rnd.final();
+ }
+ if( HPMHooks.count.HP_rnd_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_rnd_seed(uint32 seed) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_rnd_seed_pre ) {
+ void (*preHookFunc) (uint32 *seed);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_seed_pre[hIndex].func;
+ preHookFunc(&seed);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.rnd.seed(seed);
+ }
+ if( HPMHooks.count.HP_rnd_seed_post ) {
+ void (*postHookFunc) (uint32 seed);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_seed_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_seed_post[hIndex].func;
+ postHookFunc(seed);
+ }
+ }
+ return;
+}
+int32 HP_rnd_random(void) {
+ int hIndex = 0;
+ int32 retVal___ = 0;
+ if( HPMHooks.count.HP_rnd_random_pre ) {
+ int32 (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_random_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.rnd.random();
+ }
+ if( HPMHooks.count.HP_rnd_random_post ) {
+ int32 (*postHookFunc) (int32 retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_random_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_random_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+uint32 HP_rnd_roll(uint32 dice_faces) {
+ int hIndex = 0;
+ uint32 retVal___ = 0;
+ if( HPMHooks.count.HP_rnd_roll_pre ) {
+ uint32 (*preHookFunc) (uint32 *dice_faces);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_roll_pre[hIndex].func;
+ retVal___ = preHookFunc(&dice_faces);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.rnd.roll(dice_faces);
+ }
+ if( HPMHooks.count.HP_rnd_roll_post ) {
+ uint32 (*postHookFunc) (uint32 retVal___, uint32 dice_faces);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_roll_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_roll_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, dice_faces);
+ }
+ }
+ return retVal___;
+}
+int32 HP_rnd_value(int32 min, int32 max) {
+ int hIndex = 0;
+ int32 retVal___ = 0;
+ if( HPMHooks.count.HP_rnd_value_pre ) {
+ int32 (*preHookFunc) (int32 *min, int32 *max);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_value_pre[hIndex].func;
+ retVal___ = preHookFunc(&min, &max);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.rnd.value(min, max);
+ }
+ if( HPMHooks.count.HP_rnd_value_post ) {
+ int32 (*postHookFunc) (int32 retVal___, int32 min, int32 max);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_value_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_value_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, min, max);
+ }
+ }
+ return retVal___;
+}
+double HP_rnd_uniform(void) {
+ int hIndex = 0;
+ double retVal___ = 0.;
+ if( HPMHooks.count.HP_rnd_uniform_pre ) {
+ double (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_uniform_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.rnd.uniform();
+ }
+ if( HPMHooks.count.HP_rnd_uniform_post ) {
+ double (*postHookFunc) (double retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_uniform_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+double HP_rnd_uniform53(void) {
+ int hIndex = 0;
+ double retVal___ = 0.;
+ if( HPMHooks.count.HP_rnd_uniform53_pre ) {
+ double (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_rnd_uniform53_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.rnd.uniform53();
+ }
+ if( HPMHooks.count.HP_rnd_uniform53_post ) {
+ double (*postHookFunc) (double retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_rnd_uniform53_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_rnd_uniform53_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
/* script_interface */
void HP_script_init(bool minimal) {
int hIndex = 0;
@@ -78017,6 +78815,299 @@ void HP_sysinfo_final(void) {
}
return;
}
+/* thread_interface */
+void HP_thread_init(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_thread_init_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_init_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.thread.init();
+ }
+ if( HPMHooks.count.HP_thread_init_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_init_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_init_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+void HP_thread_final(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_thread_final_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_final_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.thread.final();
+ }
+ if( HPMHooks.count.HP_thread_final_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_final_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_final_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
+struct thread_handle* HP_thread_create(threadFunc entry_point, void *param) {
+ int hIndex = 0;
+ struct thread_handle* retVal___ = NULL;
+ if( HPMHooks.count.HP_thread_create_pre ) {
+ struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_create_pre[hIndex].func;
+ retVal___ = preHookFunc(&entry_point, &param);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.create(entry_point, param);
+ }
+ if( HPMHooks.count.HP_thread_create_post ) {
+ struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_create_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, entry_point, param);
+ }
+ }
+ return retVal___;
+}
+struct thread_handle* HP_thread_create_opt(threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio) {
+ int hIndex = 0;
+ struct thread_handle* retVal___ = NULL;
+ if( HPMHooks.count.HP_thread_create_opt_pre ) {
+ struct thread_handle* (*preHookFunc) (threadFunc *entry_point, void **param, size_t *stack_size, enum thread_priority *prio);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_create_opt_pre[hIndex].func;
+ retVal___ = preHookFunc(&entry_point, &param, &stack_size, &prio);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.create_opt(entry_point, param, stack_size, prio);
+ }
+ if( HPMHooks.count.HP_thread_create_opt_post ) {
+ struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___, threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_create_opt_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_create_opt_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, entry_point, param, stack_size, prio);
+ }
+ }
+ return retVal___;
+}
+void HP_thread_destroy(struct thread_handle *handle) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_thread_destroy_pre ) {
+ void (*preHookFunc) (struct thread_handle **handle);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_destroy_pre[hIndex].func;
+ preHookFunc(&handle);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.thread.destroy(handle);
+ }
+ if( HPMHooks.count.HP_thread_destroy_post ) {
+ void (*postHookFunc) (struct thread_handle *handle);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_destroy_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_destroy_post[hIndex].func;
+ postHookFunc(handle);
+ }
+ }
+ return;
+}
+struct thread_handle* HP_thread_self(void) {
+ int hIndex = 0;
+ struct thread_handle* retVal___ = NULL;
+ if( HPMHooks.count.HP_thread_self_pre ) {
+ struct thread_handle* (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_self_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.self();
+ }
+ if( HPMHooks.count.HP_thread_self_post ) {
+ struct thread_handle* (*postHookFunc) (struct thread_handle* retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_self_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_self_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+int HP_thread_get_tid(void) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_thread_get_tid_pre ) {
+ int (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_get_tid_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.get_tid();
+ }
+ if( HPMHooks.count.HP_thread_get_tid_post ) {
+ int (*postHookFunc) (int retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_get_tid_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_get_tid_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
+bool HP_thread_wait(struct thread_handle *handle, void **out_exit_code) {
+ int hIndex = 0;
+ bool retVal___ = false;
+ if( HPMHooks.count.HP_thread_wait_pre ) {
+ bool (*preHookFunc) (struct thread_handle **handle, void ***out_exit_code);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_wait_pre[hIndex].func;
+ retVal___ = preHookFunc(&handle, &out_exit_code);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.wait(handle, out_exit_code);
+ }
+ if( HPMHooks.count.HP_thread_wait_post ) {
+ bool (*postHookFunc) (bool retVal___, struct thread_handle *handle, void **out_exit_code);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_wait_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_wait_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, handle, out_exit_code);
+ }
+ }
+ return retVal___;
+}
+void HP_thread_prio_set(struct thread_handle *handle, enum thread_priority prio) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_thread_prio_set_pre ) {
+ void (*preHookFunc) (struct thread_handle **handle, enum thread_priority *prio);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_prio_set_pre[hIndex].func;
+ preHookFunc(&handle, &prio);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.thread.prio_set(handle, prio);
+ }
+ if( HPMHooks.count.HP_thread_prio_set_post ) {
+ void (*postHookFunc) (struct thread_handle *handle, enum thread_priority prio);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_set_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_prio_set_post[hIndex].func;
+ postHookFunc(handle, prio);
+ }
+ }
+ return;
+}
+enum thread_priority HP_thread_prio_get(struct thread_handle *handle) {
+ int hIndex = 0;
+ enum thread_priority retVal___ = THREADPRIO_NORMAL;
+ if( HPMHooks.count.HP_thread_prio_get_pre ) {
+ enum thread_priority (*preHookFunc) (struct thread_handle **handle);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_prio_get_pre[hIndex].func;
+ retVal___ = preHookFunc(&handle);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.thread.prio_get(handle);
+ }
+ if( HPMHooks.count.HP_thread_prio_get_post ) {
+ enum thread_priority (*postHookFunc) (enum thread_priority retVal___, struct thread_handle *handle);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_prio_get_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_prio_get_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, handle);
+ }
+ }
+ return retVal___;
+}
+void HP_thread_yield(void) {
+ int hIndex = 0;
+ if( HPMHooks.count.HP_thread_yield_pre ) {
+ void (*preHookFunc) (void);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_thread_yield_pre[hIndex].func;
+ preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return;
+ }
+ }
+ {
+ HPMHooks.source.thread.yield();
+ }
+ if( HPMHooks.count.HP_thread_yield_post ) {
+ void (*postHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_thread_yield_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_thread_yield_post[hIndex].func;
+ postHookFunc();
+ }
+ }
+ return;
+}
/* timer_interface */
int64 HP_timer_gettick(void) {
int hIndex = 0;
diff --git a/src/plugins/HPMHooking/HPMHooking_map.sources.inc b/src/plugins/HPMHooking/HPMHooking_map.sources.inc
index f98330b88..54861ed6f 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.sources.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.sources.inc
@@ -38,8 +38,10 @@ memcpy(&HPMHooks.source.cmdline, cmdline, sizeof(struct cmdline_interface));
memcpy(&HPMHooks.source.console, console, sizeof(struct console_interface));
memcpy(&HPMHooks.source.core, core, sizeof(struct core_interface));
memcpy(&HPMHooks.source.DB, DB, sizeof(struct db_interface));
+memcpy(&HPMHooks.source.des, des, sizeof(struct des_interface));
memcpy(&HPMHooks.source.duel, duel, sizeof(struct duel_interface));
memcpy(&HPMHooks.source.elemental, elemental, sizeof(struct elemental_interface));
+memcpy(&HPMHooks.source.grfio, grfio, sizeof(struct grfio_interface));
memcpy(&HPMHooks.source.guild, guild, sizeof(struct guild_interface));
memcpy(&HPMHooks.source.gstorage, gstorage, sizeof(struct guild_storage_interface));
memcpy(&HPMHooks.source.homun, homun, sizeof(struct homunculus_interface));
@@ -55,8 +57,10 @@ memcpy(&HPMHooks.source.map, map, sizeof(struct map_interface));
memcpy(&HPMHooks.source.mapindex, mapindex, sizeof(struct mapindex_interface));
memcpy(&HPMHooks.source.mapit, mapit, sizeof(struct mapit_interface));
memcpy(&HPMHooks.source.mapreg, mapreg, sizeof(struct mapreg_interface));
+memcpy(&HPMHooks.source.md5, md5, sizeof(struct md5_interface));
memcpy(&HPMHooks.source.mercenary, mercenary, sizeof(struct mercenary_interface));
memcpy(&HPMHooks.source.mob, mob, sizeof(struct mob_interface));
+memcpy(&HPMHooks.source.mutex, mutex, sizeof(struct mutex_interface));
memcpy(&HPMHooks.source.npc_chat, npc_chat, sizeof(struct npc_chat_interface));
memcpy(&HPMHooks.source.npc, npc, sizeof(struct npc_interface));
memcpy(&HPMHooks.source.nullpo, nullpo, sizeof(struct nullpo_interface));
@@ -67,6 +71,7 @@ memcpy(&HPMHooks.source.pc, pc, sizeof(struct pc_interface));
memcpy(&HPMHooks.source.libpcre, libpcre, sizeof(struct pcre_interface));
memcpy(&HPMHooks.source.pet, pet, sizeof(struct pet_interface));
memcpy(&HPMHooks.source.quest, quest, sizeof(struct quest_interface));
+memcpy(&HPMHooks.source.rnd, rnd, sizeof(struct rnd_interface));
memcpy(&HPMHooks.source.script, script, sizeof(struct script_interface));
memcpy(&HPMHooks.source.searchstore, searchstore, sizeof(struct searchstore_interface));
memcpy(&HPMHooks.source.showmsg, showmsg, sizeof(struct showmsg_interface));
@@ -79,6 +84,7 @@ memcpy(&HPMHooks.source.StrBuf, StrBuf, sizeof(struct stringbuf_interface));
memcpy(&HPMHooks.source.strlib, strlib, sizeof(struct strlib_interface));
memcpy(&HPMHooks.source.sv, sv, sizeof(struct sv_interface));
memcpy(&HPMHooks.source.sysinfo, sysinfo, sizeof(struct sysinfo_interface));
+memcpy(&HPMHooks.source.thread, thread, sizeof(struct thread_interface));
memcpy(&HPMHooks.source.timer, timer, sizeof(struct timer_interface));
memcpy(&HPMHooks.source.trade, trade, sizeof(struct trade_interface));
memcpy(&HPMHooks.source.unit, unit, sizeof(struct unit_interface));
diff --git a/src/test/test_spinlock.c b/src/test/test_spinlock.c
index 6ffc4eafc..34102a845 100644
--- a/src/test/test_spinlock.c
+++ b/src/test/test_spinlock.c
@@ -38,7 +38,7 @@
#define PERINC 100000
#define LOOPS 47
-static SPIN_LOCK lock;
+static struct spin_lock lock;
static unsigned int val = 0;
static volatile int32 done_threads = 0;
@@ -60,13 +60,14 @@ static void *worker(void *p){
return NULL;
}//end: worker()
-int do_init(int argc, char **argv){
- rAthread *t[THRC];
+int do_init(int argc, char **argv)
+{
+ struct thread_handle *t[THRC];
int j, i;
int ok;
ShowStatus("==========\n");
- ShowStatus("TEST: %u Runs, (%u Threads)\n", LOOPS, THRC);
+ ShowStatus("TEST: %d Runs, (%d Threads)\n", LOOPS, THRC);
ShowStatus("This can take a while\n");
ShowStatus("\n\n");
@@ -78,13 +79,13 @@ int do_init(int argc, char **argv){
InitializeSpinLock(&lock);
for(i =0; i < THRC; i++){
- t[i] = rathread_createEx( worker, NULL, 1024*512, RAT_PRIO_NORMAL);
+ t[i] = thread->create_opt(worker, NULL, 1024*512, THREADPRIO_NORMAL);
}
while(1){
if(InterlockedCompareExchange(&done_threads, THRC, THRC) == THRC)
break;
- rathread_yield();
+ thread->yield();
}
FinalizeSpinLock(&lock);
diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c
index 41dfcf022..7bb2f4465 100644
--- a/src/tool/mapcache.c
+++ b/src/tool/mapcache.c
@@ -77,13 +77,13 @@ int read_map(char *name, struct map_data *m)
// Open map GAT
sprintf(filename,"data\\%s.gat", name);
- gat = (unsigned char *)grfio_read(filename);
+ gat = grfio_read(filename);
if (gat == NULL)
return 0;
// Open map RSW
sprintf(filename,"data\\%s.rsw", name);
- rsw = (unsigned char *)grfio_read(filename);
+ rsw = grfio_read(filename);
// Read water height
if (rsw) {
@@ -139,7 +139,7 @@ bool cache_map(char *name, struct map_data *m)
len = (unsigned long)m->xs*(unsigned long)m->ys*2;
write_buf = (unsigned char *)aMalloc(len);
// Compress the cells and get the compressed length
- encode_zip(write_buf, &len, m->cells, m->xs*m->ys);
+ grfio->encode_zip(write_buf, &len, m->cells, m->xs*m->ys);
// Fill the map header
safestrncpy(info.name, name, MAP_NAME_LENGTH);
@@ -286,7 +286,7 @@ int do_init(int argc, char** argv)
cmdline->exec(argc, argv, CMDLINE_OPT_NORMAL);
ShowStatus("Initializing grfio with %s\n", grf_list_file);
- grfio_init(grf_list_file);
+ grfio->init(grf_list_file);
// Attempt to open the map cache file and force rebuild if not found
ShowStatus("Opening map cache: %s\n", map_cache_file);
@@ -360,7 +360,7 @@ int do_init(int argc, char** argv)
fclose(map_cache_fp);
ShowStatus("Finalizing grfio\n");
- grfio_final();
+ grfio->final();
ShowInfo("%d maps now in cache\n", header.map_count);
diff --git a/tools/HPMHookGen/HPMDataCheckGen.pl b/tools/HPMHookGen/HPMDataCheckGen.pl
index f8712f329..e78a7bd93 100644
--- a/tools/HPMHookGen/HPMDataCheckGen.pl
+++ b/tools/HPMHookGen/HPMDataCheckGen.pl
@@ -47,6 +47,8 @@ foreach my $file (@files) {
if ($foldername eq 'COMMON') {
if ($filename eq 'MAPINDEX_H') {
$plugintypes = 'SERVER_TYPE_CHAR|SERVER_TYPE_MAP';
+ } elsif ($filename eq 'GRFIO_H') {
+ $plugintypes = 'SERVER_TYPE_MAP';
} else {
$plugintypes = 'SERVER_TYPE_ALL';
}
diff --git a/tools/HPMHookGen/HPMHookGen.pl b/tools/HPMHookGen/HPMHookGen.pl
index 1d6a3e122..3203e0b70 100755
--- a/tools/HPMHookGen/HPMHookGen.pl
+++ b/tools/HPMHookGen/HPMHookGen.pl
@@ -242,6 +242,8 @@ sub parse($$) {
$rtinit = ' = PACKET_UNKNOWN';
} elsif ($x =~ /^(?:enum\s+)?DBOptions$/) { # Known enum DBOptions
$rtinit = ' = DB_OPT_BASE';
+ } elsif ($x =~ /^enum\s+thread_priority$/) { # Known enum DBOptions
+ $rtinit = ' = THREADPRIO_NORMAL';
} elsif ($x eq 'DBComparator' or $x eq 'DBHasher' or $x eq 'DBReleaser') { # DB function pointers
$rtinit = ' = NULL';
} elsif ($x =~ /^(?:struct|union)\s+.*$/) { # Structs and unions
@@ -304,6 +306,9 @@ foreach my $file (@files) { # Loop through the xml files
} elsif ($key eq "mapindex_interface") {
push @servertypes, ("map", "char"); # Currently not used by the login server
$servermask = 'SERVER_TYPE_MAP|SERVER_TYPE_CHAR';
+ } elsif ($key eq "grfio_interface") {
+ push @servertypes, ("map"); # Currently not used by the login and char servers
+ $servermask = 'SERVER_TYPE_MAP';
} else {
push @servertypes, ("map", "char", "login");
$servermask = 'SERVER_TYPE_ALL';
@@ -359,6 +364,7 @@ foreach my $file (@files) { # Loop through the xml files
my $bstart = $b->{location}->[0]->{bodystart} || $b->{location}->[0]->{line};
$astart <=> $bstart
} @$memberdef) { # Loop through the members
+ next unless $f->{kind} eq 'variable'; # Skip macros
my $t = $f->{argsstring}->[0];
my $def = $f->{definition}->[0];
if ($f->{type}->[0] =~ /^\s*LoginParseFunc\s*\*\s*$/) {
diff --git a/vcproj-11/char-server.vcxproj b/vcproj-11/char-server.vcxproj
index 764fb3378..7107d2e54 100644
--- a/vcproj-11/char-server.vcxproj
+++ b/vcproj-11/char-server.vcxproj
@@ -54,7 +54,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessToFile>false</PreprocessToFile>
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
@@ -74,9 +74,9 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
- <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
- <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -98,8 +98,8 @@
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LIBCONFIG_STATIC;YY_USE_CONST;FD_SETSIZE=4096;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalOptions>
@@ -113,9 +113,9 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
- <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
- <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -148,6 +148,7 @@
<ClInclude Include="..\src\common\db.h" />
<ClInclude Include="..\src\common\des.h" />
<ClInclude Include="..\src\common\ers.h" />
+ <ClInclude Include="..\src\common\grfio.h" />
<ClInclude Include="..\src\common\hercules.h" />
<ClInclude Include="..\src\common\HPM.h" />
<ClInclude Include="..\src\common\HPMDataCheck.h" />
@@ -155,6 +156,7 @@
<ClInclude Include="..\src\common\HPMSymbols.inc.h" />
<ClInclude Include="..\src\common\memmgr.h" />
<ClInclude Include="..\src\common\mapindex.h" />
+ <ClInclude Include="..\src\common\md5calc.h" />
<ClInclude Include="..\src\common\mmo.h" />
<ClInclude Include="..\src\common\mutex.h" />
<ClInclude Include="..\src\common\nullpo.h" />
@@ -205,9 +207,11 @@
<ClCompile Include="..\src\common\db.c" />
<ClCompile Include="..\src\common\des.c" />
<ClCompile Include="..\src\common\ers.c" />
+ <ClCompile Include="..\src\common\grfio.c" />
<ClCompile Include="..\src\common\HPM.c" />
<ClCompile Include="..\src\common\memmgr.c" />
<ClCompile Include="..\src\common\mapindex.c" />
+ <ClCompile Include="..\src\common\md5calc.c" />
<ClCompile Include="..\src\common\mutex.c" />
<ClCompile Include="..\src\common\nullpo.c" />
<ClCompile Include="..\src\common\random.c" />
diff --git a/vcproj-11/char-server.vcxproj.filters b/vcproj-11/char-server.vcxproj.filters
index 751afc993..2299a2402 100644
--- a/vcproj-11/char-server.vcxproj.filters
+++ b/vcproj-11/char-server.vcxproj.filters
@@ -16,6 +16,9 @@
<ClCompile Include="..\src\common\ers.c">
<Filter>common</Filter>
</ClCompile>
+ <ClCompile Include="..\src\common\grfio.c">
+ <Filter>common</Filter>
+ </ClCompile>
<ClCompile Include="..\src\common\HPM.c">
<Filter>common</Filter>
</ClCompile>
@@ -25,6 +28,9 @@
<ClCompile Include="..\src\common\mapindex.c">
<Filter>common</Filter>
</ClCompile>
+ <ClCompile Include="..\src\common\md5calc.c">
+ <Filter>common</Filter>
+ </ClCompile>
<ClCompile Include="..\src\common\nullpo.c">
<Filter>common</Filter>
</ClCompile>
@@ -150,6 +156,9 @@
<ClInclude Include="..\src\common\ers.h">
<Filter>common</Filter>
</ClInclude>
+ <ClInclude Include="..\src\common\grfio.h">
+ <Filter>common</Filter>
+ </ClInclude>
<ClInclude Include="..\src\common\HPM.h">
<Filter>common</Filter>
</ClInclude>
@@ -162,6 +171,9 @@
<ClInclude Include="..\src\common\mapindex.h">
<Filter>common</Filter>
</ClInclude>
+ <ClInclude Include="..\src\common\md5calc.h">
+ <Filter>common</Filter>
+ </ClInclude>
<ClInclude Include="..\src\common\mmo.h">
<Filter>common</Filter>
</ClInclude>
diff --git a/vcproj-11/login-server.vcxproj b/vcproj-11/login-server.vcxproj
index a715ff5e2..6e9088f10 100644
--- a/vcproj-11/login-server.vcxproj
+++ b/vcproj-11/login-server.vcxproj
@@ -53,8 +53,8 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;WITH_SQL;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessToFile>false</PreprocessToFile>
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
<ExceptionHandling>
@@ -73,9 +73,9 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
- <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
- <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -97,8 +97,8 @@
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;WITH_SQL;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalOptions>
@@ -116,9 +116,9 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
- <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
- <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -170,6 +170,7 @@
<ClInclude Include="..\src\common\console.h" />
<ClInclude Include="..\src\common\db.h" />
<ClInclude Include="..\src\common\ers.h" />
+ <ClInclude Include="..\src\common\grfio.h" />
<ClInclude Include="..\src\common\HPM.h" />
<ClInclude Include="..\src\common\HPMi.h" />
<ClInclude Include="..\src\common\memmgr.h" />
@@ -206,6 +207,7 @@
<ClCompile Include="..\src\common\console.c" />
<ClCompile Include="..\src\common\db.c" />
<ClCompile Include="..\src\common\ers.c" />
+ <ClCompile Include="..\src\common\grfio.c" />
<ClCompile Include="..\src\common\HPM.c" />
<ClCompile Include="..\src\common\memmgr.c" />
<ClCompile Include="..\src\common\md5calc.c" />
diff --git a/vcproj-11/login-server.vcxproj.filters b/vcproj-11/login-server.vcxproj.filters
index a5beedc71..f41fcdfac 100644
--- a/vcproj-11/login-server.vcxproj.filters
+++ b/vcproj-11/login-server.vcxproj.filters
@@ -31,6 +31,9 @@
<ClCompile Include="..\src\common\ers.c">
<Filter>common</Filter>
</ClCompile>
+ <ClCompile Include="..\src\common\grfio.c">
+ <Filter>common</Filter>
+ </ClCompile>
<ClCompile Include="..\src\common\HPM.c">
<Filter>common</Filter>
</ClCompile>
@@ -132,6 +135,9 @@
<ClInclude Include="..\src\common\ers.h">
<Filter>common</Filter>
</ClInclude>
+ <ClInclude Include="..\src\common\grfio.h">
+ <Filter>common</Filter>
+ </ClInclude>
<ClInclude Include="..\src\common\HPM.h">
<Filter>common</Filter>
</ClInclude>
diff --git a/vcproj-12/char-server.vcxproj b/vcproj-12/char-server.vcxproj
index 2077f08ee..0c72ef671 100644
--- a/vcproj-12/char-server.vcxproj
+++ b/vcproj-12/char-server.vcxproj
@@ -53,7 +53,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessToFile>false</PreprocessToFile>
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
@@ -73,9 +73,9 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
- <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
- <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -97,8 +97,8 @@
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LIBCONFIG_STATIC;YY_USE_CONST;FD_SETSIZE=4096;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalOptions>
@@ -112,9 +112,9 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
- <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
- <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -147,6 +147,7 @@
<ClInclude Include="..\src\common\db.h" />
<ClInclude Include="..\src\common\des.h" />
<ClInclude Include="..\src\common\ers.h" />
+ <ClInclude Include="..\src\common\grfio.h" />
<ClInclude Include="..\src\common\hercules.h" />
<ClInclude Include="..\src\common\HPM.h" />
<ClInclude Include="..\src\common\HPMDataCheck.h" />
@@ -154,6 +155,7 @@
<ClInclude Include="..\src\common\HPMSymbols.inc.h" />
<ClInclude Include="..\src\common\memmgr.h" />
<ClInclude Include="..\src\common\mapindex.h" />
+ <ClInclude Include="..\src\common\md5calc.h" />
<ClInclude Include="..\src\common\mmo.h" />
<ClInclude Include="..\src\common\mutex.h" />
<ClInclude Include="..\src\common\nullpo.h" />
@@ -204,9 +206,11 @@
<ClCompile Include="..\src\common\db.c" />
<ClCompile Include="..\src\common\des.c" />
<ClCompile Include="..\src\common\ers.c" />
+ <ClCompile Include="..\src\common\grfio.c" />
<ClCompile Include="..\src\common\HPM.c" />
<ClCompile Include="..\src\common\memmgr.c" />
<ClCompile Include="..\src\common\mapindex.c" />
+ <ClCompile Include="..\src\common\md5calc.c" />
<ClCompile Include="..\src\common\mutex.c" />
<ClCompile Include="..\src\common\nullpo.c" />
<ClCompile Include="..\src\common\random.c" />
diff --git a/vcproj-12/char-server.vcxproj.filters b/vcproj-12/char-server.vcxproj.filters
index 751afc993..2299a2402 100644
--- a/vcproj-12/char-server.vcxproj.filters
+++ b/vcproj-12/char-server.vcxproj.filters
@@ -16,6 +16,9 @@
<ClCompile Include="..\src\common\ers.c">
<Filter>common</Filter>
</ClCompile>
+ <ClCompile Include="..\src\common\grfio.c">
+ <Filter>common</Filter>
+ </ClCompile>
<ClCompile Include="..\src\common\HPM.c">
<Filter>common</Filter>
</ClCompile>
@@ -25,6 +28,9 @@
<ClCompile Include="..\src\common\mapindex.c">
<Filter>common</Filter>
</ClCompile>
+ <ClCompile Include="..\src\common\md5calc.c">
+ <Filter>common</Filter>
+ </ClCompile>
<ClCompile Include="..\src\common\nullpo.c">
<Filter>common</Filter>
</ClCompile>
@@ -150,6 +156,9 @@
<ClInclude Include="..\src\common\ers.h">
<Filter>common</Filter>
</ClInclude>
+ <ClInclude Include="..\src\common\grfio.h">
+ <Filter>common</Filter>
+ </ClInclude>
<ClInclude Include="..\src\common\HPM.h">
<Filter>common</Filter>
</ClInclude>
@@ -162,6 +171,9 @@
<ClInclude Include="..\src\common\mapindex.h">
<Filter>common</Filter>
</ClInclude>
+ <ClInclude Include="..\src\common\md5calc.h">
+ <Filter>common</Filter>
+ </ClInclude>
<ClInclude Include="..\src\common\mmo.h">
<Filter>common</Filter>
</ClInclude>
diff --git a/vcproj-12/login-server.vcxproj b/vcproj-12/login-server.vcxproj
index 49d35a400..91fa58082 100644
--- a/vcproj-12/login-server.vcxproj
+++ b/vcproj-12/login-server.vcxproj
@@ -53,8 +53,8 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;WITH_SQL;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessToFile>false</PreprocessToFile>
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
<ExceptionHandling>
@@ -73,9 +73,9 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
- <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
- <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -97,8 +97,8 @@
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;WITH_SQL;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalOptions>
@@ -116,9 +116,9 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
- <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
- <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -170,6 +170,7 @@
<ClInclude Include="..\src\common\console.h" />
<ClInclude Include="..\src\common\db.h" />
<ClInclude Include="..\src\common\ers.h" />
+ <ClInclude Include="..\src\common\grfio.h" />
<ClInclude Include="..\src\common\HPM.h" />
<ClInclude Include="..\src\common\HPMi.h" />
<ClInclude Include="..\src\common\memmgr.h" />
@@ -206,6 +207,7 @@
<ClCompile Include="..\src\common\console.c" />
<ClCompile Include="..\src\common\db.c" />
<ClCompile Include="..\src\common\ers.c" />
+ <ClCompile Include="..\src\common\grfio.c" />
<ClCompile Include="..\src\common\HPM.c" />
<ClCompile Include="..\src\common\memmgr.c" />
<ClCompile Include="..\src\common\md5calc.c" />
diff --git a/vcproj-12/login-server.vcxproj.filters b/vcproj-12/login-server.vcxproj.filters
index a5beedc71..f41fcdfac 100644
--- a/vcproj-12/login-server.vcxproj.filters
+++ b/vcproj-12/login-server.vcxproj.filters
@@ -31,6 +31,9 @@
<ClCompile Include="..\src\common\ers.c">
<Filter>common</Filter>
</ClCompile>
+ <ClCompile Include="..\src\common\grfio.c">
+ <Filter>common</Filter>
+ </ClCompile>
<ClCompile Include="..\src\common\HPM.c">
<Filter>common</Filter>
</ClCompile>
@@ -132,6 +135,9 @@
<ClInclude Include="..\src\common\ers.h">
<Filter>common</Filter>
</ClInclude>
+ <ClInclude Include="..\src\common\grfio.h">
+ <Filter>common</Filter>
+ </ClInclude>
<ClInclude Include="..\src\common\HPM.h">
<Filter>common</Filter>
</ClInclude>
diff --git a/vcproj-14/char-server.vcxproj b/vcproj-14/char-server.vcxproj
index 4e30a1f74..542b675bb 100644
--- a/vcproj-14/char-server.vcxproj
+++ b/vcproj-14/char-server.vcxproj
@@ -54,7 +54,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessToFile>false</PreprocessToFile>
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
@@ -74,9 +74,9 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
- <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
- <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
@@ -97,8 +97,8 @@
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LIBCONFIG_STATIC;YY_USE_CONST;FD_SETSIZE=4096;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalOptions>
@@ -112,9 +112,9 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
- <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
- <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
@@ -146,6 +146,7 @@
<ClInclude Include="..\src\common\db.h" />
<ClInclude Include="..\src\common\des.h" />
<ClInclude Include="..\src\common\ers.h" />
+ <ClInclude Include="..\src\common\grfio.h" />
<ClInclude Include="..\src\common\hercules.h" />
<ClInclude Include="..\src\common\HPM.h" />
<ClInclude Include="..\src\common\HPMDataCheck.h" />
@@ -153,6 +154,7 @@
<ClInclude Include="..\src\common\HPMSymbols.inc.h" />
<ClInclude Include="..\src\common\memmgr.h" />
<ClInclude Include="..\src\common\mapindex.h" />
+ <ClInclude Include="..\src\common\md5calc.h" />
<ClInclude Include="..\src\common\mmo.h" />
<ClInclude Include="..\src\common\mutex.h" />
<ClInclude Include="..\src\common\nullpo.h" />
@@ -203,9 +205,11 @@
<ClCompile Include="..\src\common\db.c" />
<ClCompile Include="..\src\common\des.c" />
<ClCompile Include="..\src\common\ers.c" />
+ <ClCompile Include="..\src\common\grfio.c" />
<ClCompile Include="..\src\common\HPM.c" />
<ClCompile Include="..\src\common\memmgr.c" />
<ClCompile Include="..\src\common\mapindex.c" />
+ <ClCompile Include="..\src\common\md5calc.c" />
<ClCompile Include="..\src\common\mutex.c" />
<ClCompile Include="..\src\common\nullpo.c" />
<ClCompile Include="..\src\common\random.c" />
diff --git a/vcproj-14/char-server.vcxproj.filters b/vcproj-14/char-server.vcxproj.filters
index 751afc993..2299a2402 100644
--- a/vcproj-14/char-server.vcxproj.filters
+++ b/vcproj-14/char-server.vcxproj.filters
@@ -16,6 +16,9 @@
<ClCompile Include="..\src\common\ers.c">
<Filter>common</Filter>
</ClCompile>
+ <ClCompile Include="..\src\common\grfio.c">
+ <Filter>common</Filter>
+ </ClCompile>
<ClCompile Include="..\src\common\HPM.c">
<Filter>common</Filter>
</ClCompile>
@@ -25,6 +28,9 @@
<ClCompile Include="..\src\common\mapindex.c">
<Filter>common</Filter>
</ClCompile>
+ <ClCompile Include="..\src\common\md5calc.c">
+ <Filter>common</Filter>
+ </ClCompile>
<ClCompile Include="..\src\common\nullpo.c">
<Filter>common</Filter>
</ClCompile>
@@ -150,6 +156,9 @@
<ClInclude Include="..\src\common\ers.h">
<Filter>common</Filter>
</ClInclude>
+ <ClInclude Include="..\src\common\grfio.h">
+ <Filter>common</Filter>
+ </ClInclude>
<ClInclude Include="..\src\common\HPM.h">
<Filter>common</Filter>
</ClInclude>
@@ -162,6 +171,9 @@
<ClInclude Include="..\src\common\mapindex.h">
<Filter>common</Filter>
</ClInclude>
+ <ClInclude Include="..\src\common\md5calc.h">
+ <Filter>common</Filter>
+ </ClInclude>
<ClInclude Include="..\src\common\mmo.h">
<Filter>common</Filter>
</ClInclude>
diff --git a/vcproj-14/login-server.vcxproj b/vcproj-14/login-server.vcxproj
index d376a9903..445d21ee4 100644
--- a/vcproj-14/login-server.vcxproj
+++ b/vcproj-14/login-server.vcxproj
@@ -53,8 +53,8 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;WITH_SQL;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessToFile>false</PreprocessToFile>
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
<ExceptionHandling>
@@ -73,9 +73,9 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
- <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libcmtd.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
- <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
@@ -96,8 +96,8 @@
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;WITH_SQL;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\src;..\3rdparty;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalOptions>
@@ -115,9 +115,9 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
- <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libcmt.lib;oldnames.lib;ws2_32.lib;libmysql.lib;zdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
- <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>..\3rdparty\mysql\lib;..\3rdparty\zlib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
@@ -168,6 +168,7 @@
<ClInclude Include="..\src\common\console.h" />
<ClInclude Include="..\src\common\db.h" />
<ClInclude Include="..\src\common\ers.h" />
+ <ClInclude Include="..\src\common\grfio.h" />
<ClInclude Include="..\src\common\HPM.h" />
<ClInclude Include="..\src\common\HPMi.h" />
<ClInclude Include="..\src\common\memmgr.h" />
@@ -204,6 +205,7 @@
<ClCompile Include="..\src\common\console.c" />
<ClCompile Include="..\src\common\db.c" />
<ClCompile Include="..\src\common\ers.c" />
+ <ClCompile Include="..\src\common\grfio.c" />
<ClCompile Include="..\src\common\HPM.c" />
<ClCompile Include="..\src\common\memmgr.c" />
<ClCompile Include="..\src\common\md5calc.c" />
diff --git a/vcproj-14/login-server.vcxproj.filters b/vcproj-14/login-server.vcxproj.filters
index a5beedc71..f41fcdfac 100644
--- a/vcproj-14/login-server.vcxproj.filters
+++ b/vcproj-14/login-server.vcxproj.filters
@@ -31,6 +31,9 @@
<ClCompile Include="..\src\common\ers.c">
<Filter>common</Filter>
</ClCompile>
+ <ClCompile Include="..\src\common\grfio.c">
+ <Filter>common</Filter>
+ </ClCompile>
<ClCompile Include="..\src\common\HPM.c">
<Filter>common</Filter>
</ClCompile>
@@ -132,6 +135,9 @@
<ClInclude Include="..\src\common\ers.h">
<Filter>common</Filter>
</ClInclude>
+ <ClInclude Include="..\src\common\grfio.h">
+ <Filter>common</Filter>
+ </ClInclude>
<ClInclude Include="..\src\common\HPM.h">
<Filter>common</Filter>
</ClInclude>