viewing paste topic/7040- item_deny_load.diff | Diff

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
 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;
 
Viewed 1242 times, submitted by AnnieRuru.