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

Function toggleedit

source/src/editing.cpp:43–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41VARFP(showeditingsettings, 0, 0, 3, { if(showeditingsettings){ toucheditingsettings(true); }else{ keepshowingeditingsettingsfrom = keepshowingeditingsettingstill = 0; }}); // 0:almost entirely off, 1: all off after duration, 2: text off after duration, 3: permanent
42
43void toggleedit(bool force)
44{
45 if(player1->state==CS_DEAD) return; // do not allow dead players to edit to avoid state confusion
46 if(!force && !editmode && !allowedittoggle()) return; // not in most multiplayer modes
47 if(player1->state == CS_SPECTATE)
48 {
49 if(watchingdemo)
50 {
51 if(player1->spectatemode != SM_FLY) spectatemode(SM_FLY); // release in a place of followed player
52 }
53 else return;
54 }
55
56 if(!(editmode = !editmode))
57 {
58 float oldz = player1->o.z;
59 entinmap(player1); // find spawn closest to current floating pos
60 player1->timeinair = player1->o.z == oldz ? 0: 300;
61 }
62 else
63 {
64 player1->attacking = false;
65 toucheditingsettings(true);
66 }
67 keyrepeat(editmode, KR_EDITMODE);
68 editing = editmode ? 1 : 0;
69 editing_sp = editmode && !multiplayer(NULL) ? 1 : 0;
70 player1->state = editing ? CS_EDITING : (watchingdemo ? CS_SPECTATE : CS_ALIVE);
71 if(editing && player1->onladder) player1->onladder = false;
72 if(editing && (player1->weaponsel->type == GUN_SNIPER && ((sniperrifle *)player1->weaponsel)->scoped)) ((sniperrifle *)player1->weaponsel)->onownerdies(); // or ondeselecting()
73 if(editing && (player1->weaponsel->type == GUN_GRENADE) && ((grenades *)player1->weaponsel)->state < GST_THROWING) ((grenades *)player1->weaponsel)->onownerdies();
74 if(!force) addmsg(SV_EDITMODE, "ri", editing);
75}
76
77void edittoggle() { toggleedit(false); }
78

Callers 6

changemapservFunction · 0.85
parsemessagesFunction · 0.85
gets2cFunction · 0.85
edittoggleFunction · 0.85
deathstateFunction · 0.85
startmapFunction · 0.85

Calls 8

allowedittoggleFunction · 0.85
spectatemodeFunction · 0.85
entinmapFunction · 0.85
toucheditingsettingsFunction · 0.85
keyrepeatFunction · 0.85
multiplayerFunction · 0.85
addmsgFunction · 0.85
onownerdiesMethod · 0.45

Tested by

no test coverage detected