MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / LocalPlayer_Init

Function LocalPlayer_Init

src/Entity.c:781–812  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

779 LocalPlayer_RenderModel, LocalPlayer_ShouldRenderName
780};
781static void LocalPlayer_Init(struct LocalPlayer* p, int index) {
782 struct HacksComp* hacks = &p->Hacks;
783
784 Entity_Init(&p->Base);
785 Entity_SetName(&p->Base, &Game_Username);
786 Entity_SetSkin(&p->Base, &Game_Username);
787 Event_Register_(&UserEvents.HackPermsChanged, p, LocalPlayer_CheckJumpVelocity);
788
789 p->Collisions.Entity = &p->Base;
790 HacksComp_Init(hacks);
791 PhysicsComp_Init(&p->Physics, &p->Base);
792 TiltComp_Init(&p->Tilt);
793
794 p->Base.Flags |= ENTITY_FLAG_MODEL_RESTRICTED_SCALE;
795 p->ReachDistance = 5.0f;
796 p->Physics.Hacks = &p->Hacks;
797 p->Physics.Collisions = &p->Collisions;
798 p->Base.VTABLE = &localPlayer_VTABLE;
799 p->index = index;
800
801 hacks->Enabled = !Game_PureClassic && Options_GetBool(OPT_HACKS_ENABLED, true);
802 if (Game_ClassicMode) return;
803
804 hacks->SpeedMultiplier = Options_GetFloat(OPT_SPEED_FACTOR, 0.1f, 50.0f, 10.0f);
805 hacks->PushbackPlacing = Options_GetBool(OPT_PUSHBACK_PLACING, false);
806 hacks->NoclipSlide = Options_GetBool(OPT_NOCLIP_SLIDE, false);
807 hacks->WOMStyleHacks = Options_GetBool(OPT_WOM_STYLE_HACKS, false);
808 hacks->FullBlockStep = Options_GetBool(OPT_FULL_BLOCK_STEP, false);
809 p->Physics.UserJumpVel = Options_GetFloat(OPT_JUMP_VELOCITY, 0.0f, 52.0f, 0.42f);
810 p->Physics.JumpVel = p->Physics.UserJumpVel;
811 hackPermMsgs = Options_GetBool(OPT_HACK_PERM_MSGS, true);
812}
813
814void LocalPlayer_ResetJumpVelocity(struct LocalPlayer* p) {
815 cc_bool higher = HacksComp_CanJumpHigher(&p->Hacks);

Callers 1

Entities_InitFunction · 0.85

Calls 8

Entity_InitFunction · 0.85
Entity_SetNameFunction · 0.85
Entity_SetSkinFunction · 0.85
HacksComp_InitFunction · 0.85
PhysicsComp_InitFunction · 0.85
TiltComp_InitFunction · 0.85
Options_GetBoolFunction · 0.85
Options_GetFloatFunction · 0.85

Tested by

no test coverage detected