Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.58 KB | None | 0 0
  1. // COMMAND.CPP CHANGES/ADDITIONS
  2.  
  3. void consterr(const char *name)
  4. {
  5.     defformatstring(o)("Alias %s is a constant and cannot be overwritten.", name);
  6.     conoutf(o);
  7. }
  8.  
  9. COMMAND(consterr, ARG_1STR);
  10.  
  11. void alias(const char *name, const char *action)
  12. {
  13.     ident *b = idents->access(name);
  14.     if(!b)
  15.     {
  16.         if(identexists("constant_aliases")) {
  17.             if(strstr(getalias("constant_aliases"), name)) {
  18.                 consterr(name);
  19.                 return;
  20.             }
  21.         }
  22.         ident b(ID_ALIAS, newstring(name), newstring(action), persistidents, execcontext);
  23.         idents->access(b.name, b);
  24.     }
  25.     else if(b->type==ID_ALIAS)
  26.     {
  27.         if(contextisolated[execcontext] && execcontext > b->context)
  28.         {
  29.             conoutf("cannot redefine alias %s in this execution context", b->name);
  30.             scripterr();
  31.             return;
  32.         }
  33.         if(identexists("constant_aliases")) {
  34.             if(strstr(getalias("constant_aliases"), name)) {
  35.                 consterr(name);
  36.                 return;
  37.             }
  38.         }
  39.         if(b->action!=b->executing) delete[] b->action;
  40.         b->action = newstring(action);
  41.         if(b->persist!=persistidents) b->persist = persistidents;
  42.     }
  43.     else
  44.     {
  45.         conoutf("cannot redefine builtin %s with an alias", name);
  46.         scripterr();
  47.     }
  48. }
  49.  
  50. // SCRIPTS.CFG ADDITIONS
  51. if (! (checkalias constant_aliases)) [ constant_aliases = "" ]
  52.  
  53. const = [
  54.   if (! (strstr $constant_aliases $arg1)) [
  55.     $arg1 = $arg2
  56.     add2list constant_aliases $arg1
  57.   ] [ consterr $arg1 ]
  58. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement