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

Function CPE_DefineModel

src/Protocol.c:1692–1740  ·  view source on GitHub ↗

#######################################################################################################################* *------------------------------------------------------Custom models------------------------------------------------------* *#########################################################################################################################*/

Source from the content-addressed store, hash-verified

1690*------------------------------------------------------Custom models------------------------------------------------------*
1691*#########################################################################################################################*/
1692static void CPE_DefineModel(cc_uint8* data) {
1693 struct CustomModel* cm = CustomModel_Get(data[0]);
1694 cc_string name;
1695 cc_uint8 flags;
1696 cc_uint8 numParts;
1697
1698 if (!cm) return;
1699 CustomModel_Undefine(cm);
1700 Model_Init(&cm->model);
1701
1702 name = UNSAFE_GetString(data + 1);
1703 String_CopyToRawArray(cm->name, &name);
1704
1705 flags = data[65];
1706 cm->model.bobbing = flags & 0x01;
1707 cm->model.pushes = flags & 0x02;
1708 cm->model.usesHumanSkin = flags & 0x04;
1709 cm->model.calcHumanAnims = flags & 0x08;
1710
1711 cm->nameY = GetFloat(data + 66);
1712 cm->eyeY = GetFloat(data + 70);
1713
1714 cm->collisionBounds.x = GetFloat(data + 74);
1715 cm->collisionBounds.y = GetFloat(data + 78);
1716 cm->collisionBounds.z = GetFloat(data + 82);
1717
1718 cm->pickingBoundsAABB.Min.x = GetFloat(data + 86);
1719 cm->pickingBoundsAABB.Min.y = GetFloat(data + 90);
1720 cm->pickingBoundsAABB.Min.z = GetFloat(data + 94);
1721
1722 cm->pickingBoundsAABB.Max.x = GetFloat(data + 98);
1723 cm->pickingBoundsAABB.Max.y = GetFloat(data + 102);
1724 cm->pickingBoundsAABB.Max.z = GetFloat(data + 106);
1725
1726 cm->uScale = Stream_GetU16_BE(data + 110);
1727 cm->vScale = Stream_GetU16_BE(data + 112);
1728 numParts = data[114];
1729
1730 if (numParts > MAX_CUSTOM_MODEL_PARTS) {
1731 int maxParts = MAX_CUSTOM_MODEL_PARTS;
1732 Chat_Add2("&cCustom Model '%s' exceeds parts limit of %i", &name, &maxParts);
1733 return;
1734 }
1735
1736 cm->numParts = numParts;
1737 cm->model.vertices = (struct ModelVertex*)Mem_AllocCleared(numParts * MODEL_BOX_VERTICES,
1738 sizeof(struct ModelVertex), "CustomModel vertices");
1739 cm->defined = true;
1740}
1741
1742static void CPE_DefineModelPart(cc_uint8* data) {
1743 struct CustomModel* m;

Callers

nothing calls this directly

Calls 8

CustomModel_GetFunction · 0.85
CustomModel_UndefineFunction · 0.85
Model_InitFunction · 0.85
UNSAFE_GetStringFunction · 0.85
GetFloatFunction · 0.85
Stream_GetU16_BEFunction · 0.85
Chat_Add2Function · 0.85
Mem_AllocClearedFunction · 0.85

Tested by

no test coverage detected