Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: src/map/atcommand.c
- ===================================================================
- --- src/map/atcommand.c (revision 14829)
- +++ src/map/atcommand.c (working copy)
- @@ -8916,6 +8916,13 @@
- return ( i < ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
- }
- +int get_atcommandindex_byname(const char* name)
- +{
- + int i;
- + if( *name == atcommand_symbol || *name == charcommand_symbol ) name++; // for backwards compatibility
- + ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, strcmpi(atcommand_info[i].command, name) == 0 );
- + return ( i < ARRAYLENGTH(atcommand_info) ) ? i : -1;
- +}
- /*==========================================
- * Retrieve the command's required gm level
- @@ -8942,6 +8949,7 @@
- TBL_PC * ssd = NULL; //sd for target
- AtCommandInfo * info;
- + int index;
- nullpo_retr(false, sd);
- @@ -9032,7 +9040,9 @@
- params[0] = '\0';
- //Grab the command information and check for the proper GM level required to use it or if the command exists
- - info = get_atcommandinfo_byname(command);
- + index = get_atcommandindex_byname(command);
- + info = ( index > 0) ? &atcommand_info[index] : NULL;
- +
- if( info == NULL || info->func == NULL || ( type && ((*atcmd_msg == atcommand_symbol && pc_isGM(sd) < info->level) || (*atcmd_msg == charcommand_symbol && pc_isGM(sd) < info->level2)) ) )
- {
- sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
- @@ -9040,6 +9050,12 @@
- return true;
- }
- + //Atcmd Restrictions
- + if(type && atcmd_restrictions[MAX_MAP_PER_SERVER * sd->bl.m + index] > pc_isGM(sd)) {
- + clif_displaymessage(fd, "This command has been disabled on this map." );
- + return false;
- + }
- +
- //Attempt to use the command
- if( strcmpi("adjgmlvl",command+1) && ssd ) { lv = ssd->gmlevel; ssd->gmlevel = sd->gmlevel; }
- if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
- @@ -9187,3 +9203,13 @@
- return 0;
- }
- +
- +void init_atcmd_restrictions()
- +{
- + atcmd_restrictions = (int *)aCalloc(MAX_MAP_PER_SERVER * ARRAYLENGTH(atcommand_info), sizeof(int));
- +}
- +
- +void clear_atcmd_restrictions()
- +{
- + aFree(atcmd_restrictions);
- +}
- Index: src/map/atcommand.h
- ===================================================================
- --- src/map/atcommand.h (revision 14829)
- +++ src/map/atcommand.h (working copy)
- @@ -45,4 +45,9 @@
- int msg_config_read(const char* cfgName);
- void do_final_msg(void);
- +int* atcmd_restrictions;
- +void init_atcmd_restrictions();
- +void clear_atcmd_restrictions();
- +int get_atcommandindex_byname(const char* name);
- +
- #endif /* _ATCOMMAND_H_ */
- Index: src/map/map.c
- ===================================================================
- --- src/map/map.c (revision 14829)
- +++ src/map/map.c (working copy)
- @@ -3462,7 +3462,8 @@
- do_final_unit();
- do_final_battleground();
- do_final_duel();
- -
- + clear_atcmd_restrictions();
- +
- map_db->destroy(map_db, map_db_final);
- for (i=0; i<map_num; i++) {
- @@ -3671,6 +3672,9 @@
- map_readallmaps();
- + //atcmd restrictions
- + init_atcmd_restrictions();
- +
- add_timer_func_list(map_freeblock_timer, "map_freeblock_timer");
- add_timer_func_list(map_clearflooritem_timer, "map_clearflooritem_timer");
- add_timer_func_list(map_removemobs_timer, "map_removemobs_timer");
- Index: src/map/script.c
- ===================================================================
- --- src/map/script.c (revision 14829)
- +++ src/map/script.c (working copy)
- @@ -3806,6 +3806,10 @@
- {
- userfunc_db->clear(userfunc_db,do_final_userfunc_sub);
- scriptlabel_db->clear(scriptlabel_db, NULL);
- +
- + //atcmd restrictions
- + clear_atcmd_restrictions();
- + init_atcmd_restrictions();
- if(sleep_db) {
- struct linkdb_node *n = (struct linkdb_node *)sleep_db;
- @@ -14867,7 +14871,27 @@
- return 0;
- }
- +//restrictatcmd(<map>, <atcmd>, <mingmlvl>)
- +BUILDIN_FUNC(restrictatcmd)
- +{
- + int m,a,gm;
- + m = map_mapname2mapid(script_getstr(st,2));
- + a = get_atcommandindex_byname(script_getstr(st,3));
- + gm=script_getnum(st,4);
- +
- + if(m < 0) {
- + ShowError("buildin_restrictatcmd: Invalid map\n");
- + return 1;
- + } else if( a < 0) {
- + ShowError("buildin_restrictatcmd: Invalid atcmd\n");
- + return 1;
- + }
- +
- + atcmd_restrictions[MAX_MAP_PER_SERVER * m + a] = gm;
- + return 0;
- +}
- +
- // declarations that were supposed to be exported from npc_chat.c
- #ifdef PCRE_SUPPORT
- BUILDIN_FUNC(defpattern);
- @@ -15270,5 +15294,7 @@
- BUILDIN_DEF(checkquest, "i?"),
- BUILDIN_DEF(changequest, "ii"),
- BUILDIN_DEF(showevent, "ii"),
- +
- + BUILDIN_DEF(restrictatcmd, "ssi"),
- {NULL,NULL,NULL},
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement