MCPcopy Create free account
hub / github.com/assaultcube/AC / editentity

Function editentity

source/src/world.cpp:501–549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499COMMAND(addentity, "s");
500
501void editentity(char **args, int numargs) // index x y z a1 a2 a3 a4 ...
502{
503 string res = "";
504 if(numargs > 0)
505 {
506 int n = ATOI(args[0]);
507 EDIT("editentity");
508 if(!*args[0] || !ents.inrange(n)) return;
509 entity &e = ents[n];
510 bool edit = false;
511 for(int i = 1; i < numargs; i++) if(*args[i]) edit = true; // only arguments other than empty strings can edit anything - otherwise we're just browsing
512 int t = e.type < MAXENTTYPES ? e.type : NOTUSED;
513 if((edit) && !multiplayer("editentity"))
514 {
515 if(e.type == SOUND)
516 { // disable sound /before/ changing it
517 entityreference entref(&e);
518 location *loc = audiomgr.locations.find(e.attr1, &entref, mapsounds);
519 if(loc) loc->drop();
520 }
521 for(int i = 1; i < numargs; i++) if(*args[i])
522 {
523 int v = atof(args[i]) * (i < 4 || i > 10 ? 1 : entscale[t][i - 4]);
524 switch(i)
525 {
526 case 1: e.x = v; break;
527 case 2: e.y = v; break;
528 case 3: e.z = v; break;
529 case 4: e.attr1 = v; break;
530 case 5: e.attr2 = v; break;
531 case 6: e.attr3 = v; break;
532 case 7: e.attr4 = v; break;
533 case 8: e.attr5 = v; break;
534 case 9: e.attr6 = v; break;
535 case 10: e.attr7 = v; break;
536 }
537 }
538 clampentityattributes(e);
539 switch(e.type)
540 {
541 case LIGHT: calclight(); break;
542 case SOUND: audiomgr.preloadmapsound(e); break;
543 }
544 unsavededits++;
545 }
546 formatstring(res)("%s %d %d %d %s", entnames[t], e.x, e.y, e.z, formatentityattributes(e)); // double space is for human readability; scripts don't care.
547 }
548 result(res);
549}
550COMMAND(editentity, "v");
551
552void enumentities(char *type)

Callers

nothing calls this directly

Calls 9

multiplayerFunction · 0.85
clampentityattributesFunction · 0.85
calclightFunction · 0.85
formatentityattributesFunction · 0.85
resultFunction · 0.85
inrangeMethod · 0.80
preloadmapsoundMethod · 0.80
findMethod · 0.45
dropMethod · 0.45

Tested by

no test coverage detected