src/map/atcommand.c | 27 +++++++++++++++++++++++++++
src/map/chrif.c | 23 +++++++++++++++++++++++
src/map/chrif.h | 5 +++++
3 files changed, 55 insertions(+)
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index b5e8fa7..c444661 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -1171,7 +1171,18 @@ static inline const char* atcommand_help_string(AtCommandInfo *info) {
}
item_id = item_data->nameid;
+
+ for ( i = 0; i < chrif->item_deny_total; i++ ) {
+ if ( chrif->item_deny_id[i] == item_id ) {
+ if ( pc_get_group_level(sd) < chrif->item_deny_lv[i] ) {
+ clif->message( fd, "You are restricted from creating this item." );
+ return false;
+ }
+ }
+ }
+
get_count = number;
+
//Check if it's stackable.
if (!itemdb->isstackable2(item_data)) {
if( bound && (item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) ) {
@@ -9374,6 +9385,21 @@ static inline void atcmd_channel_help(int fd, const char *command, bool can_crea
clif->message(fd,atcmd_output);
return true;
}
+
+ACMD(reloaditemdeny) {
+ int i;
+ char aaa[255];
+ chrif->load_item_deny();
+ clif->message( fd, "Item Deny has been reloaded." );
+ safesnprintf( aaa, 255, "Total -> %d", chrif->item_deny_total );
+ clif->message( fd, aaa );
+ for ( i = 0; i < chrif->item_deny_total; i++ ) {
+ safesnprintf( aaa, 255, "Item ID %d : Deny lv %d", chrif->item_deny_id[i], chrif->item_deny_lv[i] );
+ clif->message( fd, aaa );
+ }
+ return true;
+}
+
/**
* Fills the reference of available commands in atcommand DBMap
**/
@@ -9384,6 +9410,7 @@ void atcommand_basecommands(void) {
* Command reference list, place the base of your commands here
**/
AtCommandInfo atcommand_base[] = {
+ ACMD_DEF(reloaditemdeny),
ACMD_DEF2("warp", mapmove),
ACMD_DEF(where),
ACMD_DEF(jumpto),
diff --git a/src/map/chrif.c b/src/map/chrif.c
index ebdace2..7907255 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -413,6 +413,25 @@ bool chrif_changemapserverack(int account_id, int login_id1, int login_id2, int
return (!login_id1)?false:true; // Is this the best approach here?
}
+void chrif_load_item_deny(void) {
+ if ( SQL->Query( map->mysql_handle, "select * from item_deny" ) == SQL_ERROR )
+ Sql_ShowDebug( map->mysql_handle );
+ else {
+ int i = 0;
+ char *data;
+ while ( SQL->NextRow( map->mysql_handle ) == SQL_SUCCESS ) {
+ if ( SQL->GetData( map->mysql_handle, 0, &data, NULL ) == SQL_SUCCESS )
+ chrif->item_deny_id[i] = atoi(data);
+ if ( SQL->GetData( map->mysql_handle, 1, &data, NULL ) == SQL_SUCCESS )
+ chrif->item_deny_lv[i] = atoi(data);
+ i++;
+ }
+ chrif->item_deny_total = i;
+ SQL->FreeResult( map->mysql_handle );
+ }
+ return;
+}
+
/*==========================================
*
*------------------------------------------*/
@@ -439,6 +458,8 @@ void chrif_connectack(int fd) {
sockt->datasync(fd, true);
chrif->skillid2idx(fd);
+
+ chrif->load_item_deny();
}
/**
@@ -1753,4 +1774,6 @@ void chrif_defaults(void) {
chrif->parse = chrif_parse;
chrif->save_scdata_single = chrif_save_scdata_single;
chrif->del_scdata_single = chrif_del_scdata_single;
+
+ chrif->load_item_deny = chrif_load_item_deny;
}
diff --git a/src/map/chrif.h b/src/map/chrif.h
index 11baaf5..37b7dd6 100644
--- a/src/map/chrif.h
+++ b/src/map/chrif.h
@@ -146,6 +146,11 @@ struct chrif_interface {
int (*parse) (int fd);
void (*save_scdata_single) (int account_id, int char_id, short type, struct status_change_entry *sce);
void (*del_scdata_single) (int account_id, int char_id, short type);
+
+ void (*load_item_deny) (void);
+ int item_deny_id[999]; // deny up to 999 items,
+ int item_deny_lv[999]; // which means allow up to 999 entries in `item_deny` table
+ int item_deny_total;
};
struct chrif_interface *chrif;