added Buildings, Constructions, and Maps C stuff

develop
doomchild 2010-05-06 16:08:24 -05:00
parent 4a0670248d
commit 1ea6a960d9
7 changed files with 667 additions and 0 deletions

@ -47,6 +47,9 @@ modules/Constructions.cpp
modules/Position_C.cpp
modules/Gui_C.cpp
modules/Materials_C.cpp
modules/Buildings_C.cpp
modules/Constructions_C.cpp
modules/Maps_C.cpp
)
SET(PROJECT_HDRS_LINUX

@ -0,0 +1,58 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
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.
*/
#ifndef BUILDINGS_C_API
#define BUILDINGS_C_API
#include "Export.h"
#include "integers.h"
#include "DFTypes.h"
#include "modules/Buildings.h"
#include "DFHackAPI_C.h"
using namespace DFHack;
#ifdef __cplusplus
extern "C" {
#endif
struct t_customWorkshop
{
uint32_t index;
char name[256];
};
DFHACK_EXPORT int Buildings_Start(DFHackObject* b_Ptr, uint32_t* numBuildings);
DFHACK_EXPORT int Buildings_Finish(DFHackObject* b_Ptr);
DFHACK_EXPORT int Buildings_Read(DFHackObject* b_Ptr, const uint32_t index, t_building* building);
DFHACK_EXPORT int Buildings_ReadCustomWorkshopTypes(DFHackObject* b_Ptr, void* (*t_customWorkshop_buffer_create)(uint32_t));
DFHACK_EXPORT int Buildings_GetCustomWorkshopType(DFHackObject* b_Ptr, t_building* building);
#ifdef __cplusplus
}
#endif
#endif

@ -0,0 +1,49 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
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.
*/
#ifndef CONSTRUCTIONS_C_API
#define CONSTRUCTIONS_C_API
#include "Export.h"
#include "integers.h"
#include "DFTypes.h"
#include "modules/Constructions.h"
#include "DFHackAPI_C.h"
using namespace DFHack;
#ifdef __cplusplus
extern "C" {
#endif
DFHACK_EXPORT int Constructions_Start(DFHackObject* c_Ptr, uint32_t* numConstructions);
DFHACK_EXPORT int Constructions_Finish(DFHackObject* c_Ptr);
DFHACK_EXPORT int Constructions_Read(DFHackObject* c_Ptr, const uint32_t index, t_construction* construction);
#ifdef __cplusplus
}
#endif
#endif

@ -0,0 +1,86 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
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.
*/
#ifndef MAPS_C_API
#define MAPS_C_API
#include "Export.h"
#include "integers.h"
#include <vector>
#include <map>
#include <string>
using namespace std;
#include "DFTypes.h"
#include "modules/Maps.h"
#include "DFHackAPI_C.h"
using namespace DFHack;
#ifdef __cplusplus
extern "C" {
#endif
DFHACK_EXPORT int Maps_Start(DFHackObject* maps);
DFHACK_EXPORT int Maps_Finish(DFHackObject* maps);
DFHACK_EXPORT void Maps_getSize(DFHackObject* maps, uint32_t* x, uint32_t* y, uint32_t* z);
DFHACK_EXPORT int Maps_isValidBlock(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z);
DFHACK_EXPORT uint32_t Maps_getBlockPtr(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z);
DFHACK_EXPORT int Maps_ReadBlock40d(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, mapblock40d* buffer);
DFHACK_EXPORT int Maps_ReadTileTypes(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, tiletypes40d* buffer);
DFHACK_EXPORT int Maps_WriteTileTypes(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, tiletypes40d* buffer);
DFHACK_EXPORT int Maps_ReadDesignations(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, designations40d* buffer);
DFHACK_EXPORT int Maps_WriteDesignations(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, designations40d* buffer);
DFHACK_EXPORT int Maps_ReadTemperatures(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, t_temperatures* temp1, t_temperatures* temp2);
DFHACK_EXPORT int Maps_WriteTemperatures(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, t_temperatures* temp1, t_temperatures* temp2);
DFHACK_EXPORT int Maps_ReadOccupancy(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, occupancies40d* buffer);
DFHACK_EXPORT int Maps_WriteOccupancy(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, occupancies40d* buffer);
DFHACK_EXPORT int Maps_ReadDirtyBit(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, int* dirtybit);
DFHACK_EXPORT int Maps_WriteDirtyBit(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, int dirtybit);
DFHACK_EXPORT int Maps_ReadFeatures(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, int16_t* local, int16_t* global);
DFHACK_EXPORT int Maps_WriteLocalFeature(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, int16_t local);
DFHACK_EXPORT int Maps_WriteEmptyLocalFeature(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z);
DFHACK_EXPORT int Maps_WriteGlobalFeature(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, int16_t local);
DFHACK_EXPORT int Maps_WriteEmptyGlobalFeature(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z);
DFHACK_EXPORT int Maps_ReadBlockFlags(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, t_blockflags* blockflags);
DFHACK_EXPORT int Maps_WriteBlockFlags(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, t_blockflags blockflags);
DFHACK_EXPORT int Maps_ReadRegionOffsets(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, biome_indices40d* buffer);
#ifdef __cplusplus
}
#endif
#endif

@ -0,0 +1,116 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
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.
*/
#include "integers.h"
#include <string>
#include <map>
#include "stdio.h"
using namespace std;
#include "DFCommonInternal.h"
#include "DFTypes.h"
#include "modules/Buildings.h"
#include "modules/Buildings_C.h"
using namespace DFHack;
#ifdef __cplusplus
extern "C" {
#endif
int Buildings_Start(DFHackObject* b_Ptr, uint32_t* numBuildings)
{
if(b_Ptr != NULL)
{
return ((DFHack::Buildings*)b_Ptr)->Start(*numBuildings);
}
return -1;
}
int Buildings_Finish(DFHackObject* b_Ptr)
{
if(b_Ptr != NULL)
{
return ((DFHack::Buildings*)b_Ptr)->Finish();
}
return -1;
}
int Buildings_Read(DFHackObject* b_Ptr, const uint32_t index, t_building* building)
{
if(b_Ptr != NULL)
{
return ((DFHack::Buildings*)b_Ptr)->Read(index, *building);
}
return -1;
}
int Buildings_GetCustomWorkshopType(DFHackObject* b_Ptr, t_building* building)
{
if(b_Ptr != NULL)
{
return ((DFHack::Buildings*)b_Ptr)->GetCustomWorkshopType(*building);
}
return -1;
}
int Buildings_ReadCustomWorkshopTypes(DFHackObject* b_Ptr, void* (*t_customWorkshop_buffer_create)(uint32_t))
{
if(b_Ptr != NULL)
{
int i;
t_customWorkshop* cw_Ptr;
map<uint32_t, string> bTypes;
map<uint32_t, string>::iterator bIter;
bool result = ((DFHack::Buildings*)b_Ptr)->ReadCustomWorkshopTypes(bTypes);
if(!result)
return 0;
cw_Ptr = (t_customWorkshop*)((*t_customWorkshop_buffer_create)(bTypes.size()));
for(i = 0, bIter = bTypes.begin(); bIter != bTypes.end(); bIter++, i++)
{
cw_Ptr[i].index = (*bIter).first;
size_t length = (*bIter).second.copy(cw_Ptr[i].name, 256);
cw_Ptr[i].name[length] = '\0';
}
return 1;
}
return -1;
}
#ifdef __cplusplus
}
#endif

@ -0,0 +1,70 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
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.
*/
#include "integers.h"
#include "DFCommonInternal.h"
#include "DFTypes.h"
#include "modules/Constructions.h"
#include "modules/Constructions_C.h"
using namespace DFHack;
#ifdef __cplusplus
extern "C" {
#endif
int Constructions_Start(DFHackObject* c_Ptr, uint32_t* numConstructions)
{
if(c_Ptr != NULL)
{
return ((DFHack::Constructions*)c_Ptr)->Start(*numConstructions);
}
return -1;
}
int Constructions_Finish(DFHackObject* c_Ptr)
{
if(c_Ptr != NULL)
{
return ((DFHack::Constructions*)c_Ptr)->Finish();
}
return -1;
}
int Constructions_Read(DFHackObject* c_Ptr, const uint32_t index, t_construction* construction)
{
if(c_Ptr != NULL)
{
return ((DFHack::Constructions*)c_Ptr)->Read(index, *construction);
}
return -1;
}
#ifdef __cplusplus
}
#endif

@ -0,0 +1,285 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
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.
*/
#include "integers.h"
#include <vector>
#include <map>
#include <string>
using namespace std;
#include "DFCommonInternal.h"
#include "DFTypes.h"
#include "modules/Maps.h"
#include "modules/Maps_C.h"
using namespace DFHack;
#ifdef __cplusplus
extern "C" {
#endif
int Maps_Start(DFHackObject* maps)
{
if(maps != NULL)
{
return ((DFHack::Maps*)maps)->Start();
}
return -1;
}
int Maps_Finish(DFHackObject* maps)
{
if(maps != NULL)
{
return ((DFHack::Maps*)maps)->Finish();
}
return -1;
}
void Maps_getSize(DFHackObject* maps, uint32_t* x, uint32_t* y, uint32_t* z)
{
if(maps != NULL)
{
((DFHack::Maps*)maps)->getSize(*x, *y, *z);
}
}
int Maps_isValidBlock(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z)
{
if(maps != NULL)
{
return ((DFHack::Maps*)maps)->isValidBlock(x, y, z);
}
return -1;
}
uint32_t Maps_getBlockPtr(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z)
{
if(maps != NULL)
{
return ((DFHack::Maps*)maps)->getBlockPtr(x, y, z);
}
return 0;
}
int Maps_ReadBlock40d(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, mapblock40d* buffer)
{
if(maps != NULL && buffer != NULL)
{
return ((DFHack::Maps*)maps)->ReadBlock40d(x, y, z, buffer);
}
return -1;
}
int Maps_ReadTileTypes(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, tiletypes40d* buffer)
{
if(maps != NULL && buffer != NULL)
{
return ((DFHack::Maps*)maps)->ReadTileTypes(x, y, z, buffer);
}
return -1;
}
int Maps_WriteTileTypes(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, tiletypes40d* buffer)
{
if(maps != NULL && buffer != NULL)
{
return ((DFHack::Maps*)maps)->WriteTileTypes(x, y, z, buffer);
}
return -1;
}
int Maps_ReadDesignations(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, designations40d* buffer)
{
if(maps != NULL && buffer != NULL)
{
return ((DFHack::Maps*)maps)->ReadDesignations(x, y, z, buffer);
}
return -1;
}
int Maps_WriteDesignations(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, designations40d* buffer)
{
if(maps != NULL && buffer != NULL)
{
return ((DFHack::Maps*)maps)->WriteDesignations(x, y, z, buffer);
}
return -1;
}
int Maps_ReadTemperatures(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, t_temperatures* temp1, t_temperatures* temp2)
{
if(maps != NULL && temp1 != NULL && temp2 != NULL)
{
return ((DFHack::Maps*)maps)->ReadTemperatures(x, y, z, temp1, temp2);
}
return -1;
}
int Maps_WriteTemperatures(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, t_temperatures* temp1, t_temperatures* temp2)
{
if(maps != NULL && temp1 != NULL && temp2 != NULL)
{
return ((DFHack::Maps*)maps)->WriteTemperatures(x, y, z, temp1, temp2);
}
return -1;
}
int Maps_ReadOccupancy(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, occupancies40d* buffer)
{
if(maps != NULL && buffer != NULL)
{
return ((DFHack::Maps*)maps)->ReadOccupancy(x, y, z, buffer);
}
return -1;
}
int Maps_WriteOccupancy(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, occupancies40d* buffer)
{
if(maps != NULL && buffer != NULL)
{
return ((DFHack::Maps*)maps)->WriteOccupancy(x, y, z, buffer);
}
return -1;
}
int Maps_ReadDirtyBit(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, int* dirtybit)
{
if(maps != NULL)
{
bool bit;
int result = ((DFHack::Maps*)maps)->ReadDirtyBit(x, y, z, bit);
*dirtybit = bit;
return result;
}
return -1;
}
int Maps_WriteDirtyBit(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, int dirtybit)
{
if(maps != NULL)
{
return ((DFHack::Maps*)maps)->WriteDirtyBit(x, y, z, (bool)dirtybit);
}
return -1;
}
int Maps_ReadFeatures(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, int16_t* local, int16_t* global)
{
if(maps != NULL)
{
return ((DFHack::Maps*)maps)->ReadFeatures(x, y, z, *local, *global);
}
return -1;
}
int Maps_WriteLocalFeature(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, int16_t local)
{
if(maps != NULL)
{
return ((DFHack::Maps*)maps)->WriteLocalFeature(x, y, z, local);
}
return -1;
}
int Maps_WriteEmptyLocalFeature(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z)
{
if(maps != NULL)
{
return ((DFHack::Maps*)maps)->WriteLocalFeature(x, y, z, -1);
}
}
int Maps_WriteGlobalFeature(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, int16_t local)
{
if(maps != NULL)
{
return ((DFHack::Maps*)maps)->WriteGlobalFeature(x, y, z, local);
}
return -1;
}
int Maps_WriteEmptyGlobalFeature(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z)
{
if(maps != NULL)
{
return ((DFHack::Maps*)maps)->WriteGlobalFeature(x, y, z, -1);
}
}
int Maps_ReadBlockFlags(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, t_blockflags* blockflags)
{
if(maps != NULL)
{
return ((DFHack::Maps*)maps)->ReadBlockFlags(x, y, z, *blockflags);
}
return -1;
}
int Maps_WriteBlockFlags(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, t_blockflags blockflags)
{
if(maps != NULL)
{
return ((DFHack::Maps*)maps)->WriteBlockFlags(x, y, z, blockflags);
}
return -1;
}
int Maps_ReadRegionOffsets(DFHackObject* maps, uint32_t x, uint32_t y, uint32_t z, biome_indices40d* buffer)
{
if(maps != NULL)
{
return ((DFHack::Maps*)maps)->ReadRegionOffsets(x, y, z, buffer);
}
return -1;
}
#ifdef __cplusplus
}
#endif