Allow constructing itemless actual buildings.

develop
Alexander Gavrilov 2012-05-06 10:09:39 +04:00
parent 3bd44e5367
commit 05e8083c84
2 changed files with 18 additions and 3 deletions

@ -26,7 +26,6 @@ distribution.
#include "Export.h" #include "Export.h"
#include "MiscUtils.h" #include "MiscUtils.h"
#include "Error.h" #include "Error.h"
#include "Types.h"
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
#include <Windows.h> #include <Windows.h>

@ -698,12 +698,28 @@ static bool linkForConstruct(df::job* &job, df::building *bld)
return true; return true;
} }
static bool needsItems(df::building *bld)
{
if (!bld->isActual())
return false;
switch (bld->getType())
{
case building_type::FarmPlot:
case building_type::RoadDirt:
return false;
default:
return true;
}
}
bool Buildings::constructWithItems(df::building *bld, std::vector<df::item*> items) bool Buildings::constructWithItems(df::building *bld, std::vector<df::item*> items)
{ {
CHECK_NULL_POINTER(bld); CHECK_NULL_POINTER(bld);
CHECK_INVALID_ARGUMENT(!items.empty());
CHECK_INVALID_ARGUMENT(bld->id == -1); CHECK_INVALID_ARGUMENT(bld->id == -1);
CHECK_INVALID_ARGUMENT(bld->isActual()); CHECK_INVALID_ARGUMENT(bld->isActual());
CHECK_INVALID_ARGUMENT(!items.empty() == needsItems(bld));
for (size_t i = 0; i < items.size(); i++) for (size_t i = 0; i < items.size(); i++)
{ {
@ -738,9 +754,9 @@ bool Buildings::constructWithItems(df::building *bld, std::vector<df::item*> ite
bool Buildings::constructWithFilters(df::building *bld, std::vector<df::job_item*> items) bool Buildings::constructWithFilters(df::building *bld, std::vector<df::job_item*> items)
{ {
CHECK_NULL_POINTER(bld); CHECK_NULL_POINTER(bld);
CHECK_INVALID_ARGUMENT(!items.empty());
CHECK_INVALID_ARGUMENT(bld->id == -1); CHECK_INVALID_ARGUMENT(bld->id == -1);
CHECK_INVALID_ARGUMENT(bld->isActual()); CHECK_INVALID_ARGUMENT(bld->isActual());
CHECK_INVALID_ARGUMENT(!items.empty() == needsItems(bld));
for (size_t i = 0; i < items.size(); i++) for (size_t i = 0; i < items.size(); i++)
CHECK_NULL_POINTER(items[i]); CHECK_NULL_POINTER(items[i]);