MCPcopy Index your code
hub / github.com/assaultcube/AC / alias

Function alias

source/src/command.cpp:143–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141COMMAND(delalias, "s");
142
143void 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
173COMMANDF(alias, "ss", (const char *name, const char *action) { alias(name, action, false, false); });
174COMMANDF(tempalias, "ss", (const char *name, const char *action) { alias(name, action, true, false); });

Callers 15

newmapFunction · 0.85
changemapservFunction · 0.85
menuselectFunction · 0.85
addfavcategoryFunction · 0.85
serverskeyFunction · 0.85
command.cppFile · 0.85
modifyvarFunction · 0.85
modifyfvarFunction · 0.85
load_worldFunction · 0.85
loopvFunction · 0.85
setkillmessageFunction · 0.85
startmapFunction · 0.85

Calls 5

newstringFunction · 0.85
identaccessdeniedFunction · 0.85
scripterrFunction · 0.85
accessMethod · 0.80
conoutfFunction · 0.70

Tested by

no test coverage detected