2010-05-13 14:43:58 -06:00
|
|
|
/*
|
|
|
|
www.sourceforge.net/projects/dfhack
|
2010-05-25 22:48:23 -06:00
|
|
|
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
|
2010-05-13 14:43:58 -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.
|
|
|
|
*/
|
|
|
|
|
2010-05-25 22:48:23 -06:00
|
|
|
#include "dfhack/DFIntegers.h"
|
2010-07-16 17:55:18 -06:00
|
|
|
#include "dfhack/DFTileTypes.h"
|
2010-05-13 14:43:58 -06:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include "string.h"
|
|
|
|
#include <vector>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2010-05-26 04:24:45 -06:00
|
|
|
#include "Internal.h"
|
2010-05-25 22:48:23 -06:00
|
|
|
#include "dfhack/DFTypes.h"
|
2010-08-13 08:40:19 -06:00
|
|
|
#include "dfhack/DFTileTypes.h"
|
2010-05-25 22:48:23 -06:00
|
|
|
#include "dfhack-c/DFTypes_C.h"
|
2010-05-26 00:42:09 -06:00
|
|
|
#include "dfhack/modules/Materials.h"
|
2010-05-13 14:43:58 -06:00
|
|
|
|
|
|
|
using namespace DFHack;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2010-05-27 11:34:43 -06:00
|
|
|
int (*alloc_byte_buffer_callback)(int8_t*, uint32_t) = NULL;
|
|
|
|
int (*alloc_short_buffer_callback)(int16_t*, uint32_t) = NULL;
|
|
|
|
int (*alloc_int_buffer_callback)(int32_t*, uint32_t) = NULL;
|
2010-05-13 14:43:58 -06:00
|
|
|
|
2010-05-27 11:34:43 -06:00
|
|
|
int (*alloc_ubyte_buffer_callback)(uint8_t*, uint32_t) = NULL;
|
|
|
|
int (*alloc_ushort_buffer_callback)(uint16_t*, uint32_t) = NULL;
|
|
|
|
int (*alloc_uint_buffer_callback)(uint32_t*, uint32_t) = NULL;
|
2010-05-13 14:43:58 -06:00
|
|
|
|
2010-05-27 11:34:43 -06:00
|
|
|
int (*alloc_char_buffer_callback)(char*, uint32_t) = NULL;
|
2010-05-13 14:43:58 -06:00
|
|
|
|
2010-05-27 11:34:43 -06:00
|
|
|
int (*alloc_matgloss_buffer_callback)(t_matgloss*, uint32_t) = NULL;
|
|
|
|
int (*alloc_descriptor_buffer_callback)(t_descriptor_color*, uint32_t) = NULL;
|
|
|
|
int (*alloc_matgloss_other_buffer_callback)(t_matglossOther*, uint32_t) = NULL;
|
2010-05-13 14:43:58 -06:00
|
|
|
|
2010-08-26 09:27:41 -06:00
|
|
|
int (*alloc_t_feature_buffer_callback)(t_feature*, uint32_t) = NULL;
|
|
|
|
int (*alloc_t_hotkey_buffer_callback)(t_hotkey*, uint32_t) = NULL;
|
|
|
|
int (*alloc_t_screen_buffer_callback)(t_screen*, uint32_t) = NULL;
|
|
|
|
|
2010-08-18 11:59:11 -06:00
|
|
|
int (*alloc_t_customWorkshop_buffer_callback)(t_customWorkshop*, uint32_t) = NULL;
|
|
|
|
int (*alloc_t_material_buffer_callback)(t_material*, uint32_t) = NULL;
|
|
|
|
|
2010-05-27 11:34:43 -06:00
|
|
|
int (*alloc_empty_colormodifier_callback)(c_colormodifier*) = NULL;
|
|
|
|
int (*alloc_colormodifier_callback)(c_colormodifier*, const char*, uint32_t) = NULL;
|
|
|
|
int (*alloc_colormodifier_buffer_callback)(c_colormodifier*, uint32_t) = NULL;
|
2010-05-13 14:43:58 -06:00
|
|
|
|
2010-05-27 11:34:43 -06:00
|
|
|
int (*alloc_empty_creaturecaste_callback)(c_creaturecaste*)= NULL;
|
|
|
|
int (*alloc_creaturecaste_callback)(c_creaturecaste*, const char*, const char*, const char*, const char*, uint32_t, uint32_t) = NULL;
|
|
|
|
int (*alloc_creaturecaste_buffer_callback)(c_creaturecaste*, uint32_t) = NULL;
|
2010-05-25 14:36:50 -06:00
|
|
|
|
2010-05-27 11:34:43 -06:00
|
|
|
int (*alloc_empty_creaturetype_callback)(c_creaturetype*) = NULL;
|
|
|
|
int (*alloc_creaturetype_callback)(c_creaturetype*, const char*, uint32_t, uint32_t, uint8_t, uint16_t, uint16_t, uint16_t) = NULL;
|
|
|
|
int (*alloc_creaturetype_buffer_callback)(c_creaturetype*, uint32_t) = NULL;
|
2010-05-13 14:43:58 -06:00
|
|
|
|
2010-07-06 13:07:10 -06:00
|
|
|
int (*alloc_vein_buffer_callback)(t_vein*, uint32_t) = NULL;
|
|
|
|
int (*alloc_frozenliquidvein_buffer_callback)(t_frozenliquidvein*, uint32_t) = NULL;
|
|
|
|
int (*alloc_spattervein_buffer_callback)(t_spattervein*, uint32_t) = NULL;
|
|
|
|
|
|
|
|
int DFHack_isWallTerrain(int in)
|
|
|
|
{
|
|
|
|
return DFHack::isWallTerrain(in);
|
|
|
|
}
|
|
|
|
|
|
|
|
int DFHack_isFloorTerrain(int in)
|
|
|
|
{
|
|
|
|
return DFHack::isFloorTerrain(in);
|
|
|
|
}
|
|
|
|
|
|
|
|
int DFHack_isRampTerrain(int in)
|
|
|
|
{
|
|
|
|
return DFHack::isRampTerrain(in);
|
|
|
|
}
|
|
|
|
|
|
|
|
int DFHack_isStairTerrain(int in)
|
|
|
|
{
|
|
|
|
return DFHack::isStairTerrain(in);
|
|
|
|
}
|
|
|
|
|
|
|
|
int DFHack_isOpenTerrain(int in)
|
|
|
|
{
|
|
|
|
return DFHack::isOpenTerrain(in);
|
|
|
|
}
|
|
|
|
|
|
|
|
int DFHack_getVegetationType(int in)
|
|
|
|
{
|
|
|
|
return DFHack::getVegetationType(in);
|
|
|
|
}
|
|
|
|
|
2010-08-13 08:40:19 -06:00
|
|
|
int DFHack_getTileType(int index, TileRow* tPtr)
|
|
|
|
{
|
|
|
|
if(index >= TILE_TYPE_ARRAY_LENGTH)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
*tPtr = tileTypeTable[index];
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-05-13 14:43:58 -06:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int ColorListConvert(t_colormodifier* src, c_colormodifier* dest)
|
|
|
|
{
|
2010-05-25 07:52:01 -06:00
|
|
|
if(src == NULL)
|
2010-05-13 14:43:58 -06:00
|
|
|
return -1;
|
|
|
|
|
2010-05-27 11:34:43 -06:00
|
|
|
((*alloc_colormodifier_callback)(dest, src->part, src->colorlist.size()));
|
2010-05-13 14:43:58 -06:00
|
|
|
|
|
|
|
copy(src->colorlist.begin(), src->colorlist.end(), dest->colorlist);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CreatureCasteConvert(t_creaturecaste* src, c_creaturecaste* dest)
|
|
|
|
{
|
2010-05-25 07:52:01 -06:00
|
|
|
if(src == NULL)
|
2010-05-13 14:43:58 -06:00
|
|
|
return -1;
|
|
|
|
|
2010-05-27 11:34:43 -06:00
|
|
|
((*alloc_creaturecaste_callback)(dest, src->rawname, src->singular, src->plural, src->adjective, src->ColorModifier.size(), src->bodypart.size()));
|
2010-05-13 14:43:58 -06:00
|
|
|
|
|
|
|
for(int i = 0; i < dest->colorModifierLength; i++)
|
|
|
|
ColorListConvert(&src->ColorModifier[i], &dest->ColorModifier[i]);
|
|
|
|
|
|
|
|
copy(src->bodypart.begin(), src->bodypart.end(), dest->bodypart);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CreatureTypeConvert(t_creaturetype* src, c_creaturetype* dest)
|
|
|
|
{
|
2010-05-25 07:52:01 -06:00
|
|
|
if(src == NULL)
|
2010-05-13 14:43:58 -06:00
|
|
|
return -1;
|
|
|
|
|
2010-05-27 11:34:43 -06:00
|
|
|
((*alloc_creaturetype_callback)(dest, src->rawname, src->castes.size(), src->extract.size(), src->tile_character, src->tilecolor.fore, src->tilecolor.back, src->tilecolor.bright));
|
2010-05-13 14:43:58 -06:00
|
|
|
|
|
|
|
for(int i = 0; i < dest->castesCount; i++)
|
|
|
|
CreatureCasteConvert(&src->castes[i], &dest->castes[i]);
|
|
|
|
|
|
|
|
copy(src->extract.begin(), src->extract.end(), dest->extract);
|
|
|
|
|
|
|
|
return 1;
|
2010-05-25 07:52:01 -06:00
|
|
|
}
|