| 141 | COMMAND(delalias, "s"); |
| 142 | |
| 143 | void alias(const char *name, const char *action, bool temp, bool constant) |
| 144 | { |
| 145 | ident *b = idents->access(name); |
| 146 | if(!b) |
| 147 | { // new alias |
| 148 | ident b(ID_ALIAS, newstring(name), newstring(action), persistidents && !constant && !temp, execcontext); |
| 149 | b.isconst = constant; |
| 150 | b.istemp = temp; |
| 151 | idents->access(b.name, b); |
| 152 | return; |
| 153 | } |
| 154 | else if(b->type != ID_ALIAS) conoutf("cannot redefine builtin %s with an alias", name); |
| 155 | else if(identaccessdenied(b)) conoutf("cannot redefine alias %s in this execution context", name); |
| 156 | else if(b->isconst) conoutf("alias %s is a constant and cannot be redefined", name); |
| 157 | else |
| 158 | { // new action |
| 159 | b->isconst = constant; |
| 160 | if(temp) b->istemp = true; |
| 161 | if(!constant || (action && action[0])) |
| 162 | { |
| 163 | if(b->action != b->executing) delete[] b->action; |
| 164 | b->action = newstring(action); |
| 165 | if(!b->stack) b->persist = persistidents != 0; |
| 166 | } |
| 167 | if(b->istemp) b->persist = false; |
| 168 | return; |
| 169 | } |
| 170 | scripterr(); |
| 171 | } |
| 172 | |
| 173 | COMMANDF(alias, "ss", (const char *name, const char *action) { alias(name, action, false, false); }); |
| 174 | COMMANDF(tempalias, "ss", (const char *name, const char *action) { alias(name, action, true, false); }); |
no test coverage detected