* This helper for Create/Update PageElement Cmd procedure verifies if the page * element parameters are correct for the given page element type. * @param page_id The page id of the page which the page element (will) belong to * @param type The type of the page element to create/update * @param tile The tile parameter of the DoCommand proc * @param reference The reference parameter of the DoCo
| 57 | * @return true, if and only if the given parameters are valid for the given page element type and page id. |
| 58 | */ |
| 59 | static bool VerifyElementContentParameters(StoryPageID page_id, StoryPageElementType type, TileIndex tile, uint32_t reference, const EncodedString &text) |
| 60 | { |
| 61 | StoryPageButtonData button_data{ reference }; |
| 62 | |
| 63 | switch (type) { |
| 64 | case SPET_TEXT: |
| 65 | if (text.empty()) return false; |
| 66 | break; |
| 67 | case SPET_LOCATION: |
| 68 | if (text.empty()) return false; |
| 69 | if (!IsValidTile(tile)) return false; |
| 70 | break; |
| 71 | case SPET_GOAL: |
| 72 | if (!Goal::IsValidID((GoalID)reference)) return false; |
| 73 | /* Reject company specific goals on global pages */ |
| 74 | if (StoryPage::Get(page_id)->company == CompanyID::Invalid() && Goal::Get((GoalID)reference)->company != CompanyID::Invalid()) return false; |
| 75 | break; |
| 76 | case SPET_BUTTON_PUSH: |
| 77 | if (!button_data.ValidateColour()) return false; |
| 78 | if (!button_data.ValidateFlags()) return false; |
| 79 | return true; |
| 80 | case SPET_BUTTON_TILE: |
| 81 | if (!button_data.ValidateColour()) return false; |
| 82 | if (!button_data.ValidateFlags()) return false; |
| 83 | if (!button_data.ValidateCursor()) return false; |
| 84 | return true; |
| 85 | case SPET_BUTTON_VEHICLE: |
| 86 | if (!button_data.ValidateColour()) return false; |
| 87 | if (!button_data.ValidateFlags()) return false; |
| 88 | if (!button_data.ValidateCursor()) return false; |
| 89 | if (!button_data.ValidateVehicleType()) return false; |
| 90 | return true; |
| 91 | default: |
| 92 | return false; |
| 93 | } |
| 94 | |
| 95 | return true; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * This helper for Create/Update PageElement Cmd procedure updates a page |
no test coverage detected