2012-01-27 08:47:14 -07:00
|
|
|
/*
|
2011-06-16 15:53:39 -06:00
|
|
|
https://github.com/peterix/dfhack
|
|
|
|
Copyright (c) 2009-2011 Petr Mrázek (peterix@gmail.com)
|
2010-04-09 16:24:41 -06:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any
|
|
|
|
damages arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any
|
|
|
|
purpose, including commercial applications, and to alter it and
|
|
|
|
redistribute it freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must
|
|
|
|
not claim that you wrote the original software. If you use this
|
|
|
|
software in a product, an acknowledgment in the product documentation
|
|
|
|
would be appreciated but is not required.
|
|
|
|
|
|
|
|
2. Altered source versions must be plainly marked as such, and
|
|
|
|
must not be misrepresented as being the original software.
|
|
|
|
|
|
|
|
3. This notice may not be removed or altered from any source
|
|
|
|
distribution.
|
|
|
|
*/
|
|
|
|
|
2011-06-16 15:53:39 -06:00
|
|
|
|
2010-05-26 04:24:45 -06:00
|
|
|
#include "Internal.h"
|
2011-04-10 02:19:15 -06:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
using namespace std;
|
|
|
|
|
2010-05-26 04:24:45 -06:00
|
|
|
|
2011-12-31 04:48:42 -07:00
|
|
|
#include "VersionInfo.h"
|
|
|
|
#include "MemAccess.h"
|
|
|
|
#include "Types.h"
|
|
|
|
#include "Core.h"
|
2012-01-24 15:11:48 -07:00
|
|
|
#include "modules/Constructions.h"
|
|
|
|
#include "df/world.h"
|
2010-04-09 16:24:41 -06:00
|
|
|
using namespace DFHack;
|
2012-01-24 15:11:48 -07:00
|
|
|
using namespace DFHack::Simple;
|
|
|
|
using df::global::world;
|
2010-04-09 16:24:41 -06:00
|
|
|
|
2012-01-24 15:11:48 -07:00
|
|
|
bool Constructions::isValid()
|
2011-03-18 01:53:59 -06:00
|
|
|
{
|
2012-01-26 19:29:59 -07:00
|
|
|
return (world != NULL);
|
2011-03-18 01:53:59 -06:00
|
|
|
}
|
|
|
|
|
2012-01-24 15:11:48 -07:00
|
|
|
uint32_t Constructions::getCount()
|
2010-04-09 16:24:41 -06:00
|
|
|
{
|
2012-01-24 15:11:48 -07:00
|
|
|
return world->constructions.size();
|
2010-04-09 16:24:41 -06:00
|
|
|
}
|
|
|
|
|
2012-01-26 22:27:57 -07:00
|
|
|
df::construction * Constructions::getConstruction(const int32_t index)
|
2010-04-09 16:24:41 -06:00
|
|
|
{
|
2012-01-24 15:11:48 -07:00
|
|
|
if (index < 0 || index >= getCount())
|
|
|
|
return NULL;
|
|
|
|
return world->constructions[index];
|
2010-04-09 16:24:41 -06:00
|
|
|
}
|
2012-01-26 22:27:57 -07:00
|
|
|
|
2012-01-26 19:29:59 -07:00
|
|
|
bool Constructions::copyConstruction(const int32_t index, t_construction &out)
|
2010-04-09 16:24:41 -06:00
|
|
|
{
|
2012-01-24 15:11:48 -07:00
|
|
|
if (index < 0 || index >= getCount())
|
2012-01-26 19:29:59 -07:00
|
|
|
return false;
|
|
|
|
|
|
|
|
out.origin = world->constructions[index];
|
|
|
|
|
|
|
|
out.pos = out.origin->pos;
|
|
|
|
out.item_type = out.origin->item_type;
|
|
|
|
out.unk = out.origin->anon_1;
|
|
|
|
out.mat_type = out.origin->mat_type;
|
|
|
|
out.mat_index = out.origin->mat_index;
|
|
|
|
out.flags = out.origin->flags;
|
|
|
|
out.original_tile = out.origin->original_tile;
|
|
|
|
return true;
|
2010-04-09 16:24:41 -06:00
|
|
|
}
|