Code cleanup: style and use switch () for (un)pack

This commit is contained in:
2014-04-23 19:22:03 +10:00
parent 6babb4d12b
commit ad5497b6df
3 changed files with 54 additions and 35 deletions

View File

@@ -627,45 +627,64 @@ void unpackAll(Main *bmain, ReportList *reports, int how)
/* ID should be not NULL, return 1 if there's a packed file */
bool BKE_pack_check(ID *id)
{
if (GS(id->name) == ID_IM) {
switch (GS(id->name)) {
case ID_IM:
{
Image *ima = (Image *)id;
return ima->packedfile != NULL;
}
if (GS(id->name) == ID_VF) {
case ID_VF:
{
VFont *vf = (VFont *)id;
return vf->packedfile != NULL;
}
if (GS(id->name) == ID_SO) {
case ID_SO:
{
bSound *snd = (bSound *)id;
return snd->packedfile != NULL;
}
if (GS(id->name) == ID_LI) {
case ID_LI:
{
Library *li = (Library *)id;
return li->packedfile != NULL;
}
}
return false;
}
/* ID should be not NULL */
void BKE_unpack_id(Main *bmain, ID *id, ReportList *reports, int how)
{
if (GS(id->name) == ID_IM) {
switch (GS(id->name)) {
case ID_IM:
{
Image *ima = (Image *)id;
if (ima->packedfile)
if (ima->packedfile) {
unpackImage(reports, ima, how);
}
if (GS(id->name) == ID_VF) {
break;
}
case ID_VF:
{
VFont *vf = (VFont *)id;
if (vf->packedfile)
if (vf->packedfile) {
unpackVFont(reports, vf, how);
}
if (GS(id->name) == ID_SO) {
break;
}
case ID_SO:
{
bSound *snd = (bSound *)id;
if (snd->packedfile)
if (snd->packedfile) {
unpackSound(bmain, reports, snd, how);
}
if (GS(id->name) == ID_LI) {
break;
}
case ID_LI:
{
Library *li = (Library *)id;
BKE_reportf(reports, RPT_ERROR, "Cannot unpack individual Library file, '%s'", li->name);
break;
}
}
}

View File

@@ -159,7 +159,7 @@ static int rigidbody_world_export_exec(bContext *C, wmOperator *op)
char path[FILE_MAX];
/* sanity checks */
if ELEM(NULL, scene, rbw) {
if (ELEM(NULL, scene, rbw)) {
BKE_report(op->reports, RPT_ERROR, "No Rigid Body World to export");
return OPERATOR_CANCELLED;
}