bool scrSkCanBuildTemplate(void) { STRUCTURE *psStructure; DROID_TEMPLATE *psTempl; SDWORD player; if (!stackPopParams(3, VAL_INT, &player, ST_STRUCTURE, &psStructure, ST_TEMPLATE, &psTempl)) { return false; } // is factory big enough? if (!validTemplateForFactory(psTempl, psStructure, false)) { goto failTempl; } if ((asBodyStats + psTempl->asParts[COMP_BODY])->size > psStructure->capacity) { goto failTempl; } // is every component from template available? // body available. if (apCompLists[player][COMP_BODY][psTempl->asParts[COMP_BODY]] != AVAILABLE) { goto failTempl; } // propulsion method available. if (apCompLists[player][COMP_PROPULSION][psTempl->asParts[COMP_PROPULSION]] != AVAILABLE) { goto failTempl; } // weapon/sensor switch (droidTemplateType(psTempl)) { case DROID_CYBORG: // cyborg-type thang.. no need to check weapon. case DROID_CYBORG_SUPER: // super cyborg-type thang break; case DROID_WEAPON: if (apCompLists[player][COMP_WEAPON][ psTempl->asWeaps[0] ] != AVAILABLE) { goto failTempl; } break; case DROID_SENSOR: if (apCompLists[player][COMP_SENSOR][psTempl->asParts[COMP_SENSOR]] != AVAILABLE) { goto failTempl; } break; case DROID_ECM: if (apCompLists[player][COMP_ECM][psTempl->asParts[COMP_ECM]] != AVAILABLE) { goto failTempl; } break; case DROID_REPAIR: if (apCompLists[player][COMP_REPAIRUNIT][psTempl->asParts[COMP_REPAIRUNIT]] != AVAILABLE) { goto failTempl; } break; case DROID_CYBORG_REPAIR: if (apCompLists[player][COMP_REPAIRUNIT][psTempl->asParts[COMP_REPAIRUNIT]] != AVAILABLE) { goto failTempl; } break; case DROID_COMMAND: if (apCompLists[player][COMP_BRAIN][psTempl->asParts[COMP_BRAIN]] != AVAILABLE) { goto failTempl; } break; case DROID_CONSTRUCT: if (apCompLists[player][COMP_CONSTRUCT][psTempl->asParts[COMP_CONSTRUCT]] != AVAILABLE) { goto failTempl; } break; case DROID_CYBORG_CONSTRUCT: if (apCompLists[player][COMP_CONSTRUCT][psTempl->asParts[COMP_CONSTRUCT]] != AVAILABLE) { goto failTempl; } break; case DROID_PERSON: // person case DROID_TRANSPORTER: // guess what this is! case DROID_SUPERTRANSPORTER: case DROID_DEFAULT: // Default droid case DROID_ANY: default: debug(LOG_FATAL, "scrSkCanBuildTemplate: Unhandled template type"); abort(); break; } scrFunctionResult.v.bval = true; if (!stackPushResult(VAL_BOOL, &scrFunctionResult)) // yes { return false; } return true; failTempl: scrFunctionResult.v.bval = false; if (!stackPushResult(VAL_BOOL, &scrFunctionResult)) // no { return false; } return true; }
BOOL scrSkCanBuildTemplate(void) { STRUCTURE *psStructure; DROID_TEMPLATE *psTempl; SDWORD player, structure, templ; if (!stackPopParams(3,VAL_INT, &player,ST_STRUCTURE, &structure, ST_TEMPLATE, &templ)) { return FALSE; } psTempl = (DROID_TEMPLATE*) templ; psStructure = (STRUCTURE *) structure; // is factory big enough? if(!validTemplateForFactory(psTempl, psStructure) ) { goto failTempl; } if ((asBodyStats + psTempl->asParts[COMP_BODY])->size > ((FACTORY*)psStructure->pFunctionality)->capacity ) { goto failTempl; } // is every component from template available? // body available. if( apCompLists[player][COMP_BODY][psTempl->asParts[COMP_BODY]] != AVAILABLE ) { goto failTempl; } // propulsion method available. if( apCompLists[player][COMP_PROPULSION][psTempl->asParts[COMP_PROPULSION]] != AVAILABLE ) { goto failTempl; } // weapon/sensor switch (droidTemplateType(psTempl)) { case DROID_CYBORG: // cyborg-type thang.. no need to check weapon. case DROID_CYBORG_SUPER: // super cyborg-type thang break; case DROID_WEAPON: if( apCompLists[player][COMP_WEAPON][ psTempl->asWeaps[0] ] != AVAILABLE ) { goto failTempl; } break; case DROID_SENSOR: if( apCompLists[player][COMP_SENSOR][psTempl->asParts[COMP_SENSOR]] != AVAILABLE ) { goto failTempl; } break; case DROID_ECM: if( apCompLists[player][COMP_ECM][psTempl->asParts[COMP_ECM]] != AVAILABLE ) { goto failTempl; } break; case DROID_REPAIR: if( apCompLists[player][COMP_REPAIRUNIT][psTempl->asParts[COMP_REPAIRUNIT]] != AVAILABLE ) { goto failTempl; } break; case DROID_COMMAND: case DROID_CONSTRUCT: // Constructor droid case DROID_PERSON: // person case DROID_CYBORG_CONSTRUCT: // cyborg-construct thang case DROID_CYBORG_REPAIR: // cyborg-repair thang case DROID_TRANSPORTER: // guess what this is! case DROID_DEFAULT: // Default droid case DROID_ANY: default: DBERROR(("scrSkCanBuildTemplate: Unhandled template type")); break; } if (!stackPushResult(VAL_BOOL, TRUE)) // yes { return FALSE; } return TRUE; failTempl: if (!stackPushResult(VAL_BOOL, FALSE)) // no { return FALSE; } return TRUE; }