[c][cpp] Port 687260a384df3461f72738d08be85993fb83ec70

This commit is contained in:
Mario Zechner 2024-05-15 13:56:48 +02:00
parent 687260a384
commit e99899e819
6 changed files with 0 additions and 95 deletions

View File

@ -51,7 +51,6 @@ typedef struct spSlotData {
spColor *darkColor;
spBlendMode blendMode;
int/*bool*/ visible;
char *path;
} spSlotData;
SP_API spSlotData *spSlotData_create(const int index, const char *name, spBoneData *boneData);

View File

@ -57,35 +57,6 @@ typedef struct {
_spLinkedMesh *linkedMeshes;
} _spSkeletonBinary;
static int string_lastIndexOf(const char *str, char needle) {
if (!str) return -1;
int lastIndex = -1;
for (int i = 0; str[i] != '\0'; i++) {
if (str[i] == needle) {
lastIndex = i;
}
}
return lastIndex;
}
static char *string_substring(const char *str, int start, int end) {
if (str == NULL || start > end || start < 0) {
return NULL;
}
int len = end - start;
char *substr = MALLOC(char, len + 1);
if (substr == NULL) {
return NULL;
}
strncpy(substr, str + start, len);
substr[len] = '\0';
return substr;
}
static int string_starts_with(const char *str, const char *needle) {
int lenStr, lenNeedle, i;
if (!str) return 0;
@ -1437,14 +1408,6 @@ spSkeletonData *spSkeletonBinary_readSkeletonData(spSkeletonBinary *self, const
skeletonData->slots = MALLOC(spSlotData *, skeletonData->slotsCount);
for (i = 0; i < skeletonData->slotsCount; ++i) {
char *slotName = readString(input);
char *pathName = NULL;
if (nonessential) {
int slash = string_lastIndexOf(slotName, '/');
if (slash != -1) {
pathName = string_substring(slotName, 0, slash);
slotName = string_substring(slotName, slash + 1, strlen(slotName));
}
}
spBoneData *boneData = skeletonData->bones[readVarint(input, 1)];
spSlotData *slotData = spSlotData_create(i, slotName, boneData);
FREE(slotName);
@ -1464,7 +1427,6 @@ spSkeletonData *spSkeletonBinary_readSkeletonData(spSkeletonBinary *self, const
slotData->blendMode = (spBlendMode) readVarint(input, 1);
if (nonessential) {
slotData->visible = readBoolean(input);
slotData->path = pathName;
}
skeletonData->slots[i] = slotData;
}

View File

@ -1041,34 +1041,6 @@ static int string_starts_with(const char *str, const char *needle) {
return -1;
}
static int string_lastIndexOf(const char *str, char needle) {
if (!str) return -1;
int lastIndex = -1;
for (int i = 0; str[i] != '\0'; i++) {
if (str[i] == needle) {
lastIndex = i;
}
}
return lastIndex;
}
static char *string_substring(const char *str, int start, int end) {
if (str == NULL || start > end || start < 0) {
return NULL;
}
int len = end - start;
char *substr = MALLOC(char, len + 1);
if (substr == NULL) {
return NULL;
}
strncpy(substr, str + start, len);
substr[len] = '\0';
return substr;
}
spSkeletonData *spSkeletonJson_readSkeletonData(spSkeletonJson *self, const char *json) {
int i, ii;
spSkeletonData *skeletonData;
@ -1192,13 +1164,7 @@ spSkeletonData *spSkeletonJson_readSkeletonData(spSkeletonJson *self, const char
return NULL;
}
char *pathName = NULL;
char *slotName = (char *) Json_getString(slotMap, "name", NULL);
int slash = string_lastIndexOf(slotName, '/');
if (slash != -1) {
pathName = string_substring(slotName, 0, slash);
slotName = string_substring(slotName, slash + 1, strlen(slotName));
}
data = spSlotData_create(i, slotName, boneData);
color = Json_getString(slotMap, "color", 0);
@ -1234,7 +1200,6 @@ spSkeletonData *spSkeletonJson_readSkeletonData(spSkeletonJson *self, const char
}
data->visible = Json_getInt(slotMap, "visible", -1);
data->path = pathName;
skeletonData->slots[i] = data;
skeletonData->slotsCount++;
}

View File

@ -109,10 +109,6 @@ namespace spine {
void setVisible(bool inValue);
String &getPath() { return _path; }
void setPath(const String &inValue) { _path = inValue; }
private:
const int _index;
String _name;
@ -124,7 +120,6 @@ namespace spine {
String _attachmentName;
BlendMode _blendMode;
bool _visible;
String _path;
};
}

View File

@ -176,14 +176,6 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
skeletonData->_slots.setSize(slotsCount, 0);
for (int i = 0; i < slotsCount; ++i) {
String slotName = String(readString(input), true);
String pathName = "";
if (nonessential) {
int slash = slotName.lastIndexOf('/');
if (slash != -1) {
pathName = slotName.substring(0, slash);
slotName = slotName.substring(slash + 1);
}
}
BoneData *boneData = skeletonData->_bones[readVarint(input, true)];
SlotData *slotData = new (__FILE__, __LINE__) SlotData(i, slotName, *boneData);
@ -200,7 +192,6 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
slotData->_blendMode = static_cast<BlendMode>(readVarint(input, true));
if (nonessential) {
slotData->_visible = readBoolean(input);
slotData->_path = pathName;
}
skeletonData->_slots[i] = slotData;
}

View File

@ -241,13 +241,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
return NULL;
}
String pathName = "";
String slotName = String(Json::getString(slotMap, "name", 0));
int slash = slotName.lastIndexOf('/');
if (slash != -1) {
pathName = slotName.substring(0, slash);
slotName = slotName.substring(slash + 1);
}
data = new (__FILE__, __LINE__) SlotData(i, slotName, *boneData);
color = Json::getString(slotMap, "color", 0);
@ -281,7 +275,6 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
data->_blendMode = BlendMode_Screen;
}
data->_visible = Json::getBoolean(slotMap, "visible", true);
data->_path = pathName;
skeletonData->_slots[i] = data;
}
}