Skip to content

Commit

Permalink
Introducing HPM Datacheck
Browse files Browse the repository at this point in the history
  • Loading branch information
shennetsind committed Feb 2, 2014
1 parent 8a05e61 commit d334696
Show file tree
Hide file tree
Showing 86 changed files with 357 additions and 265 deletions.
6 changes: 3 additions & 3 deletions src/char/char.h
Expand Up @@ -2,8 +2,8 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams

#ifndef _CHAR_SQL_H_
#define _CHAR_SQL_H_
#ifndef _COMMON_CHAR_H_
#define _COMMON_CHAR_H_

#include "../config/core.h"
#include "../common/core.h" // CORE_ST_LAST
Expand Down Expand Up @@ -121,4 +121,4 @@ void global_accreg_to_login_start (int account_id, int char_id);
void global_accreg_to_login_send (void);
void global_accreg_to_login_add (const char *key, unsigned int index, intptr_t val, bool is_string);

#endif /* _CHAR_SQL_H_ */
#endif /* _COMMON_CHAR_H_ */
6 changes: 3 additions & 3 deletions src/char/int_auction.h
@@ -1,12 +1,12 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder

#ifndef _INT_AUCTION_SQL_H_
#define _INT_AUCTION_SQL_H_
#ifndef _CHAR_INT_AUCTION_H_
#define _CHAR_INT_AUCTION_H_

int inter_auction_parse_frommap(int fd);

int inter_auction_sql_init(void);
void inter_auction_sql_final(void);

#endif /* _INT_AUCTION_SQL_H_ */
#endif /* _CHAR_INT_AUCTION_H_ */
6 changes: 3 additions & 3 deletions src/char/int_elemental.h
@@ -1,8 +1,8 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder

#ifndef _INT_ELEMENTAL_SQL_H_
#define _INT_ELEMENTAL_SQL_H_
#ifndef _CHAR_INT_ELEMENTAL_H_
#define _CHAR_INT_ELEMENTAL_H_

struct s_elemental;

Expand All @@ -12,4 +12,4 @@ int inter_elemental_parse_frommap(int fd);

bool mapif_elemental_delete(int ele_id);

#endif /* _INT_ELEMENTAL_SQL_H_ */
#endif /* _CHAR_INT_ELEMENTAL_H_ */
6 changes: 3 additions & 3 deletions src/char/int_guild.h
@@ -1,8 +1,8 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder

#ifndef _INT_GUILD_SQL_H_
#define _INT_GUILD_SQL_H_
#ifndef _CHAR_INT_GUILD_H_
#define _CHAR_INT_GUILD_H_

enum {
GS_BASIC = 0x0001,
Expand Down Expand Up @@ -34,4 +34,4 @@ int inter_guild_charname_changed(int guild_id,int account_id, int char_id, char
int inter_guild_CharOnline(int char_id, int guild_id);
int inter_guild_CharOffline(int char_id, int guild_id);

#endif /* _INT_GUILD_SQL_H_ */
#endif /* _CHAR_INT_GUILD_H_ */
6 changes: 3 additions & 3 deletions src/char/int_homun.h
@@ -1,8 +1,8 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder

#ifndef _INT_HOMUN_SQL_H_
#define _INT_HOMUN_SQL_H_
#ifndef _CHAR_INT_HOMUN_H_
#define _CHAR_INT_HOMUN_H_

struct s_homunculus;

Expand All @@ -15,4 +15,4 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd);
bool mapif_homunculus_delete(int homun_id);
bool mapif_homunculus_rename(char *name);

#endif /* _INT_HOMUN_SQL_H_ */
#endif /* _CHAR_INT_HOMUN_H_ */
6 changes: 3 additions & 3 deletions src/char/int_mail.h
@@ -1,8 +1,8 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder

#ifndef _INT_MAIL_SQL_H_
#define _INT_MAIL_SQL_H_
#ifndef _CHAR_INT_MAIL_H_
#define _CHAR_INT_MAIL_H_

int inter_mail_parse_frommap(int fd);
void mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item);
Expand All @@ -13,4 +13,4 @@ void inter_mail_sql_final(void);
int mail_savemessage(struct mail_message* msg);
void mapif_Mail_new(struct mail_message *msg);

#endif /* _INT_MAIL_SQL_H_ */
#endif /* _CHAR_INT_MAIL_H_ */
6 changes: 3 additions & 3 deletions src/char/int_mercenary.h
@@ -1,8 +1,8 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder

#ifndef _INT_MERCENARY_SQL_H_
#define _INT_MERCENARY_SQL_H_
#ifndef _CHAR_INT_MERCENARY_H_
#define _CHAR_INT_MERCENARY_H_

struct s_mercenary;

Expand All @@ -17,4 +17,4 @@ bool mercenary_owner_delete(int char_id);

bool mapif_mercenary_delete(int merc_id);

#endif /* _INT_MERCENARY_SQL_H_ */
#endif /* _CHAR_INT_MERCENARY_H_ */
6 changes: 3 additions & 3 deletions src/char/int_party.h
@@ -1,8 +1,8 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder

#ifndef _INT_PARTY_SQL_H_
#define _INT_PARTY_SQL_H_
#ifndef _CHAR_INT_PARTY_H_
#define _CHAR_INT_PARTY_H_

//Party Flags on what to save/delete.
enum {
Expand All @@ -23,4 +23,4 @@ int inter_party_leave(int party_id,int account_id, int char_id);
int inter_party_CharOnline(int char_id, int party_id);
int inter_party_CharOffline(int char_id, int party_id);

#endif /* _INT_PARTY_SQL_H_ */
#endif /* _CHAR_INT_PARTY_H_ */
6 changes: 3 additions & 3 deletions src/char/int_pet.h
@@ -1,8 +1,8 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder

#ifndef _INT_PET_SQL_H_
#define _INT_PET_SQL_H_
#ifndef _CHAR_INT_PET_H_
#define _CHAR_INT_PET_H_

struct s_pet;

Expand All @@ -18,4 +18,4 @@ int inter_pet_sql_init(void);
//Exported for use in the TXT-SQL converter.
int inter_pet_tosql(int pet_id, struct s_pet *p);

#endif /* _INT_PET_SQL_H_ */
#endif /* _CHAR_INT_PET_H_ */
6 changes: 3 additions & 3 deletions src/char/int_quest.h
@@ -1,10 +1,10 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder

#ifndef _QUEST_H_
#define _QUEST_H_
#ifndef _CHAR_QUEST_H_
#define _CHAR_QUEST_H_

int inter_quest_parse_frommap(int fd);

#endif
#endif /* _CHAR_QUEST_H_ */

6 changes: 3 additions & 3 deletions src/char/int_storage.h
@@ -1,8 +1,8 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder

#ifndef _INT_STORAGE_SQL_H_
#define _INT_STORAGE_SQL_H_
#ifndef _CHAR_INT_STORAGE_H_
#define _CHAR_INT_STORAGE_H_

struct storage_data;
struct guild_storage;
Expand All @@ -19,4 +19,4 @@ int storage_fromsql(int account_id, struct storage_data* p);
int storage_tosql(int account_id,struct storage_data *p);
int guild_storage_tosql(int guild_id, struct guild_storage *p);

#endif /* _INT_STORAGE_SQL_H_ */
#endif /* _CHAR_INT_STORAGE_H_ */
6 changes: 3 additions & 3 deletions src/char/inter.h
Expand Up @@ -2,8 +2,8 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams

#ifndef _INTER_SQL_H_
#define _INTER_SQL_H_
#ifndef _CHAR_INTER_H_
#define _CHAR_INTER_H_

struct accreg;
#include "../common/sql.h"
Expand Down Expand Up @@ -41,4 +41,4 @@ uint64 inter_chk_lastuid(int8 flag, uint64 value);
#define updateLastUid(val_)
#endif

#endif /* _INTER_SQL_H_ */
#endif /* _CHAR_INTER_H_ */
6 changes: 3 additions & 3 deletions src/char/pincode.h
Expand Up @@ -2,8 +2,8 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams

#ifndef _PINCODE_H_
#define _PINCODE_H_
#ifndef _CHAR_PINCODE_H_
#define _CHAR_PINCODE_H_

#include "char.h"

Expand Down Expand Up @@ -40,4 +40,4 @@ struct pincode_interface *pincode;

void pincode_defaults(void);

#endif /* _PINCODE_H_ */
#endif /* _CHAR_PINCODE_H_ */
26 changes: 26 additions & 0 deletions src/common/HPM.c
Expand Up @@ -116,6 +116,8 @@ struct hplugin *hplugin_load(const char* filename) {
bool anyEvent = false;
void **import_symbol_ref;
Sql **sql_handle;
unsigned int *HPMDataCheckLen;
struct s_HPMDataCheck *HPMDataCheck;

if( HPM->exists(filename) ) {
ShowWarning("HPM:plugin_load: attempting to load duplicate '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename);
Expand Down Expand Up @@ -203,6 +205,24 @@ struct hplugin *hplugin_load(const char* filename) {
if( !HPM->populate(plugin,filename) )
return NULL;

if( !( HPMDataCheckLen = plugin_import(plugin->dll, "HPMDataCheckLen", unsigned int *) ) ) {
ShowWarning("HPM:plugin_load: failed to retrieve 'HPMDataCheckLen' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h, skipping...\n", filename);
HPM->unload(plugin);
return NULL;
}

if( !( HPMDataCheck = plugin_import(plugin->dll, "HPMDataCheck", struct s_HPMDataCheck *) ) ) {
ShowWarning("HPM:plugin_load: failed to retrieve 'HPMDataCheck' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h, skipping...\n", filename);
HPM->unload(plugin);
return NULL;
}

if( !HPM->DataCheck(HPMDataCheck,*HPMDataCheckLen,plugin->info->name) ) {
ShowWarning("HPM:plugin_load: '"CL_WHITE"%s"CL_RESET"' failed DataCheck, out of sync from the core (recompile plugin), skipping...\n", filename);
HPM->unload(plugin);
return NULL;
}

/* id */
plugin->hpi->pid = plugin->idx;
/* core */
Expand Down Expand Up @@ -255,6 +275,11 @@ void hplugins_config_read(void) {
const char *config_filename = "conf/plugins.conf"; // FIXME hardcoded name
FILE *fp;

if( !HPM->DataCheck ) {
ShowError("HPM:config_read: HPM->DataCheck not set! Failure\n");
return;
}

/* yes its ugly, its temporary and will be gone as soon as the new inter-server.conf is set */
if( (fp = fopen("conf/import/plugins.conf","r")) ) {
config_filename = "conf/import/plugins.conf";
Expand Down Expand Up @@ -829,4 +854,5 @@ void hpm_defaults(void) {
HPM->grabHPData = hplugins_grabHPData;
HPM->grabHPDataSub = NULL;
HPM->parseConf = hplugins_parse_conf;
HPM->DataCheck = NULL;
}
8 changes: 5 additions & 3 deletions src/common/HPM.h
@@ -1,8 +1,8 @@
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file

#ifndef _HPM_H_
#define _HPM_H_
#ifndef _COMMON_HPM_H_
#define _COMMON_HPM_H_

#include "../common/cbasetypes.h"
#include "../common/HPMi.h"
Expand Down Expand Up @@ -146,10 +146,12 @@ struct HPM_interface {
bool (*grabHPDataSub) (struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr);
/* for custom config parsing */
bool (*parseConf) (const char *w1, const char *w2, enum HPluginConfType point);
/* validates plugin data */
bool (*DataCheck) (struct s_HPMDataCheck *src, unsigned int size, char *name);
} HPM_s;

struct HPM_interface *HPM;

void hpm_defaults(void);

#endif /* _HPM_H_ */
#endif /* _COMMON_HPM_H_ */
15 changes: 10 additions & 5 deletions src/common/HPMi.h
@@ -1,8 +1,8 @@
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file

#ifndef _HPMi_H_
#define _HPMi_H_
#ifndef _COMMON_HPMi_H_
#define _COMMON_HPMi_H_

#include "../common/cbasetypes.h"
#include "../common/core.h"
Expand All @@ -20,7 +20,7 @@ struct map_session_data;
#define HPExport
#endif

#ifndef _SHOWMSG_H_
#ifndef _COMMON_SHOWMSG_H_
HPExport void (*ShowMessage) (const char *, ...);
HPExport void (*ShowStatus) (const char *, ...);
HPExport void (*ShowSQL) (const char *, ...);
Expand All @@ -45,6 +45,11 @@ struct hplugin_info {
char* req_version;
};

struct s_HPMDataCheck {
char *name;
unsigned int size;
};

HPExport void *(*import_symbol) (char *name, unsigned int pID);
HPExport Sql *mysql_handle;

Expand Down Expand Up @@ -187,8 +192,8 @@ HPExport struct HPMi_interface {
/* pc group permission */
void (*addPCGPermission) (unsigned int pluginID, char *name, unsigned int *mask);
} HPMi_s;
#ifndef _HPM_H_
#ifndef _COMMON_HPM_H_
HPExport struct HPMi_interface *HPMi;
#endif

#endif /* _HPMi_H_ */
#endif /* _COMMON_HPMi_H_ */
6 changes: 3 additions & 3 deletions src/common/atomic.h
@@ -1,8 +1,8 @@
// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL
// For more information, see LICENCE in the main folder

#ifndef _rA_ATOMIC_H_
#define _rA_ATOMIC_H_
#ifndef _COMMON_ATOMIC_H_
#define _COMMON_ATOMIC_H_

// Atomic Operations
// (Interlocked CompareExchange, Add .. and so on ..)
Expand Down Expand Up @@ -144,4 +144,4 @@ static forceinline int32 InterlockedExchange(volatile int32 *target, int32 val){
#endif //endif compiler decission


#endif
#endif /* _COMMON_ATOMIC_H_ */
6 changes: 3 additions & 3 deletions src/common/cbasetypes.h
@@ -1,5 +1,5 @@
#ifndef _CBASETYPES_H_
#define _CBASETYPES_H_
#ifndef _COMMON_CBASETYPES_H_
#define _COMMON_CBASETYPES_H_

/* +--------+-----------+--------+---------+
* | ILP32 | LP64 | ILP64 | (LL)P64 |
Expand Down Expand Up @@ -431,4 +431,4 @@ void SET_FUNCPOINTER(T1& var, T2 p)
#endif


#endif /* _CBASETYPES_H_ */
#endif /* _COMMON_CBASETYPES_H_ */
6 changes: 3 additions & 3 deletions src/common/conf.h
Expand Up @@ -2,8 +2,8 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams

#ifndef _CONF_H_
#define _CONF_H_
#ifndef _COMMON_CONF_H_
#define _COMMON_CONF_H_

#include "../common/cbasetypes.h"
#include "../../3rdparty/libconfig/libconfig.h"
Expand Down Expand Up @@ -94,4 +94,4 @@ struct libconfig_interface *libconfig;

void libconfig_defaults(void);

#endif // _CONF_H_
#endif // _COMMON_CONF_H_

0 comments on commit d334696

Please sign in to comment.