diff options
author | dreammaster | 2019-06-27 04:02:48 +0100 |
---|---|---|
committer | Paul Gilbert | 2019-07-06 15:27:08 -0700 |
commit | dc40211ec5e54d01f7cb822940714ed6e6da36d5 (patch) | |
tree | dedda7f6ce1ab7f581941d9f002ad1926fa3e367 /engines/glk/alan3/container.cpp | |
parent | aebf25661076eaa382b3025f0123f6ceb7cf920b (diff) | |
download | scummvm-rg350-dc40211ec5e54d01f7cb822940714ed6e6da36d5.tar.gz scummvm-rg350-dc40211ec5e54d01f7cb822940714ed6e6da36d5.tar.bz2 scummvm-rg350-dc40211ec5e54d01f7cb822940714ed6e6da36d5.zip |
GLK: ALAN3: Proper indentation & formatting
Diffstat (limited to 'engines/glk/alan3/container.cpp')
-rw-r--r-- | engines/glk/alan3/container.cpp | 236 |
1 files changed, 116 insertions, 120 deletions
diff --git a/engines/glk/alan3/container.cpp b/engines/glk/alan3/container.cpp index 365455c0ce..36469a336c 100644 --- a/engines/glk/alan3/container.cpp +++ b/engines/glk/alan3/container.cpp @@ -38,152 +38,148 @@ ContainerEntry *containers; /* Container table pointer */ /*----------------------------------------------------------------------*/ -static int countInContainer(int containerIndex) /* IN - the container to count in */ -{ - int j = 0; - - for (uint instanceIndex = 1; instanceIndex <= header->instanceMax; instanceIndex++) - if (isIn(instanceIndex, containerIndex, DIRECT)) - /* Then it's in this container also */ - j++; - return(j); +static int countInContainer(int containerIndex) { /* IN - the container to count in */ + int j = 0; + + for (uint instanceIndex = 1; instanceIndex <= header->instanceMax; instanceIndex++) + if (isIn(instanceIndex, containerIndex, DIRECT)) + /* Then it's in this container also */ + j++; + return (j); } /*----------------------------------------------------------------------*/ static int sumAttributeInContainer( - Aint containerIndex, /* IN - the container to sum */ - Aint attributeIndex /* IN - the attribute to sum over */ - ) { - uint instanceIndex; - int sum = 0; - - for (instanceIndex = 1; instanceIndex <= header->instanceMax; instanceIndex++) - if (isIn(instanceIndex, containerIndex, DIRECT)) { /* Then it's directly in this cont */ - if (instances[instanceIndex].container != 0) /* This is also a container! */ - sum = sum + sumAttributeInContainer(instanceIndex, attributeIndex); - sum = sum + getInstanceAttribute(instanceIndex, attributeIndex); - } - return(sum); + Aint containerIndex, /* IN - the container to sum */ + Aint attributeIndex /* IN - the attribute to sum over */ +) { + uint instanceIndex; + int sum = 0; + + for (instanceIndex = 1; instanceIndex <= header->instanceMax; instanceIndex++) + if (isIn(instanceIndex, containerIndex, DIRECT)) { /* Then it's directly in this cont */ + if (instances[instanceIndex].container != 0) /* This is also a container! */ + sum = sum + sumAttributeInContainer(instanceIndex, attributeIndex); + sum = sum + getInstanceAttribute(instanceIndex, attributeIndex); + } + return (sum); } /*----------------------------------------------------------------------*/ -static bool containerIsEmpty(int container) -{ - uint i; - - for (i = 1; i <= header->instanceMax; i++) - if (isDescribable(i) && isIn(i, container, TRANSITIVE)) - return FALSE; - return TRUE; +static bool containerIsEmpty(int container) { + uint i; + + for (i = 1; i <= header->instanceMax; i++) + if (isDescribable(i) && isIn(i, container, TRANSITIVE)) + return FALSE; + return TRUE; } /*======================================================================*/ -void describeContainer(int container) -{ - if (!containerIsEmpty(container) && !isOpaque(container)) - list(container); +void describeContainer(int container) { + if (!containerIsEmpty(container) && !isOpaque(container)) + list(container); } /*======================================================================*/ bool passesContainerLimits(Aint theContainer, Aint theAddedInstance) { - LimitEntry *limit; - Aword props; - - if (!isAContainer(theContainer)) - syserr("Checking limits for a non-container."); - - /* Find the container properties */ - props = instances[theContainer].container; - - if (containers[props].limits != 0) { /* Any limits at all? */ - for (limit = (LimitEntry *) pointerTo(containers[props].limits); !isEndOfArray(limit); limit++) - if ((int)limit->atr == 1-I_COUNT) { /* TODO This is actually some encoding of the attribute number, right? */ - if (countInContainer(theContainer) >= (int)limit->val) { - interpret(limit->stms); - return(FALSE); - } - } else { - if (sumAttributeInContainer(theContainer, limit->atr) + getInstanceAttribute(theAddedInstance, limit->atr) > limit->val) { - interpret(limit->stms); - return(FALSE); - } - } - } - return(TRUE); + LimitEntry *limit; + Aword props; + + if (!isAContainer(theContainer)) + syserr("Checking limits for a non-container."); + + /* Find the container properties */ + props = instances[theContainer].container; + + if (containers[props].limits != 0) { /* Any limits at all? */ + for (limit = (LimitEntry *) pointerTo(containers[props].limits); !isEndOfArray(limit); limit++) + if ((int)limit->atr == 1 - I_COUNT) { /* TODO This is actually some encoding of the attribute number, right? */ + if (countInContainer(theContainer) >= (int)limit->val) { + interpret(limit->stms); + return (FALSE); + } + } else { + if (sumAttributeInContainer(theContainer, limit->atr) + getInstanceAttribute(theAddedInstance, limit->atr) > limit->val) { + interpret(limit->stms); + return (FALSE); + } + } + } + return (TRUE); } /*======================================================================*/ int containerSize(int container, ATrans trans) { - Aword i; - Aint count = 0; - - for (i = 1; i <= header->instanceMax; i++) { - if (isIn(i, container, trans)) - count++; - } - return(count); + Aword i; + Aint count = 0; + + for (i = 1; i <= header->instanceMax; i++) { + if (isIn(i, container, trans)) + count++; + } + return (count); } /*======================================================================*/ -void list(int container) -{ - uint i; - Aword props; - Aword foundInstance[2] = {0,0}; - int found = 0; - Aint previousThis = current.instance; - - current.instance = container; - - /* Find container table entry */ - props = instances[container].container; - if (props == 0) syserr("Trying to list something not a container."); - - for (i = 1; i <= header->instanceMax; i++) { - if (isDescribable(i)) { - /* We can only see objects and actors directly in this container... */ - if (admin[i].location == container) { /* Yes, it's in this container */ - if (found == 0) { - if (containers[props].header != 0) - interpret(containers[props].header); - else { - if (isAActor(containers[props].owner)) - printMessageWithInstanceParameter(M_CARRIES, containers[props].owner); - else - printMessageWithInstanceParameter(M_CONTAINS, containers[props].owner); - } - foundInstance[0] = i; - } else if (found == 1) - foundInstance[1] = i; - else { - printMessageWithInstanceParameter(M_CONTAINS_COMMA, i); - } - found++; - } - } - } - - if (found > 0) { - if (found > 1) - printMessageWithInstanceParameter(M_CONTAINS_AND, foundInstance[1]); - printMessageWithInstanceParameter(M_CONTAINS_END, foundInstance[0]); - } else { - if (containers[props].empty != 0) - interpret(containers[props].empty); - else { - if (isAActor(containers[props].owner)) - printMessageWithInstanceParameter(M_EMPTYHANDED, containers[props].owner); - else - printMessageWithInstanceParameter(M_EMPTY, containers[props].owner); - } - } - needSpace = TRUE; - current.instance = previousThis; +void list(int container) { + uint i; + Aword props; + Aword foundInstance[2] = {0, 0}; + int found = 0; + Aint previousThis = current.instance; + + current.instance = container; + + /* Find container table entry */ + props = instances[container].container; + if (props == 0) syserr("Trying to list something not a container."); + + for (i = 1; i <= header->instanceMax; i++) { + if (isDescribable(i)) { + /* We can only see objects and actors directly in this container... */ + if (admin[i].location == container) { /* Yes, it's in this container */ + if (found == 0) { + if (containers[props].header != 0) + interpret(containers[props].header); + else { + if (isAActor(containers[props].owner)) + printMessageWithInstanceParameter(M_CARRIES, containers[props].owner); + else + printMessageWithInstanceParameter(M_CONTAINS, containers[props].owner); + } + foundInstance[0] = i; + } else if (found == 1) + foundInstance[1] = i; + else { + printMessageWithInstanceParameter(M_CONTAINS_COMMA, i); + } + found++; + } + } + } + + if (found > 0) { + if (found > 1) + printMessageWithInstanceParameter(M_CONTAINS_AND, foundInstance[1]); + printMessageWithInstanceParameter(M_CONTAINS_END, foundInstance[0]); + } else { + if (containers[props].empty != 0) + interpret(containers[props].empty); + else { + if (isAActor(containers[props].owner)) + printMessageWithInstanceParameter(M_EMPTYHANDED, containers[props].owner); + else + printMessageWithInstanceParameter(M_EMPTY, containers[props].owner); + } + } + needSpace = TRUE; + current.instance = previousThis; } } // End of namespace Alan3 |