Started removing C++-isms from C wrapper. Removed DFGlobal.h

develop
Petr Mrázek 2011-04-10 13:12:28 +02:00
parent c1deee768e
commit 1d35044db3
67 changed files with 359 additions and 258 deletions

@ -25,6 +25,7 @@ distribution.
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cstring>
using namespace std;

@ -28,6 +28,7 @@ distribution.
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
@ -169,153 +170,4 @@ UNREG_MACRO(FeatureMap, alloc_featuremap_buffer_callback)
#ifdef __cplusplus
}
#endif
void BuildDescriptorList(std::vector<t_creaturetype> & src, c_creaturetype_descriptor** dest)
{
c_creaturetype_descriptor* descriptor = NULL;
descriptor = (c_creaturetype_descriptor*)calloc(src.size(), sizeof(c_creaturetype_descriptor));
for(uint32_t i = 0; i < src.size(); i++)
{
uint32_t castes_size = src[i].castes.size();
c_creaturetype_descriptor* current = &descriptor[i];
current->castesCount = castes_size;
current->caste_descriptors = (c_creaturecaste_descriptor*)calloc(castes_size, sizeof(c_creaturecaste_descriptor));
for(uint32_t j = 0; j < castes_size; j++)
{
uint32_t color_size = src[i].castes[j].ColorModifier.size();
c_creaturecaste_descriptor* current_caste = &current->caste_descriptors[j];
current_caste->colorModifierLength = color_size;
current_caste->color_descriptors = (c_colormodifier_descriptor*)calloc(color_size, sizeof(c_colormodifier_descriptor));
for(uint32_t k = 0; k < color_size; k++)
{
c_colormodifier_descriptor* current_color = &current_caste->color_descriptors[k];
current_color->colorlistLength = src[i].castes[j].ColorModifier[k].colorlist.size();
}
current_caste->bodypartLength = src[i].castes[j].bodypart.size();
}
current->extractCount = src[i].extract.size();
}
*dest = descriptor;
}
void FreeDescriptorList(c_creaturetype_descriptor* d, uint32_t length)
{
for(uint32_t i = 0; i < length; i++)
{
c_creaturetype_descriptor* desc = &d[i];
for(uint32_t j = 0; j < desc->castesCount; j++)
free(desc->caste_descriptors[j].color_descriptors);
free(desc->caste_descriptors);
}
free(d);
}
int CreatureTypeConvert(std::vector<t_creaturetype> & src, c_creaturetype** out_buf)
{
if(src.size() <= 0)
return 0;
else if(alloc_creaturetype_buffer_callback == NULL)
return -1;
else
{
c_creaturetype_descriptor* descriptor;
c_creaturetype* buf;
BuildDescriptorList(src, &descriptor);
((*alloc_creaturetype_buffer_callback)(out_buf, descriptor, src.size()));
FreeDescriptorList(descriptor, src.size());
if(out_buf == NULL)
return -1;
buf = out_buf[0];
for(uint32_t i = 0; i < src.size(); i++)
{
c_creaturetype* current = &(buf[i]);
memset(current->rawname, '\0', 128);
strncpy(current->rawname, src[i].rawname, 128);
for(uint32_t j = 0; j < current->castesCount; j++)
{
c_creaturecaste* current_caste = &current->castes[j];
t_creaturecaste* src_caste = &src[i].castes[j];
memset(current_caste->rawname, '\0', 128);
memset(current_caste->singular, '\0', 128);
memset(current_caste->plural, '\0', 128);
memset(current_caste->adjective, '\0', 128);
strncpy(current_caste->rawname, src_caste->rawname, 128);
strncpy(current_caste->singular, src_caste->singular, 128);
strncpy(current_caste->plural, src_caste->plural, 128);
strncpy(current_caste->adjective, src_caste->adjective, 128);
for(uint32_t k = 0; k < src[i].castes[j].ColorModifier.size(); k++)
{
c_colormodifier* current_color = &current_caste->colorModifier[k];
memset(current_color->part, '\0', 128);
strncpy(current_color->part, src_caste->ColorModifier[k].part, 128);
copy(src_caste->ColorModifier[k].colorlist.begin(), src_caste->ColorModifier[k].colorlist.end(), current_color->colorlist);
current_color->colorlistLength = src_caste->ColorModifier[k].colorlist.size();
current_color->startdate = src_caste->ColorModifier[k].startdate;
current_color->enddate = src_caste->ColorModifier[k].enddate;
}
current_caste->colorModifierLength = src_caste->ColorModifier.size();
copy(src_caste->bodypart.begin(), src_caste->bodypart.end(), current_caste->bodypart);
current_caste->bodypartLength = src_caste->bodypart.size();
current_caste->strength = src_caste->strength;
current_caste->agility = src_caste->agility;
current_caste->toughness = src_caste->toughness;
current_caste->endurance = src_caste->endurance;
current_caste->recuperation = src_caste->recuperation;
current_caste->disease_resistance = src_caste->disease_resistance;
current_caste->analytical_ability = src_caste->analytical_ability;
current_caste->focus = src_caste->focus;
current_caste->willpower = src_caste->willpower;
current_caste->creativity = src_caste->creativity;
current_caste->intuition = src_caste->intuition;
current_caste->patience = src_caste->patience;
current_caste->memory = src_caste->memory;
current_caste->linguistic_ability = src_caste->linguistic_ability;
current_caste->spatial_sense = src_caste->spatial_sense;
current_caste->musicality = src_caste->musicality;
current_caste->kinesthetic_sense = src_caste->kinesthetic_sense;
}
copy(src[i].extract.begin(), src[i].extract.end(), current->extract);
current->extractCount = src[i].extract.size();
current->tile_character = src[i].tile_character;
current->tilecolor.fore = src[i].tilecolor.fore;
current->tilecolor.back = src[i].tilecolor.back;
current->tilecolor.bright = src[i].tilecolor.bright;
}
return 1;
}
}
#endif

@ -7,6 +7,8 @@
* \defgroup grp_cwrap C Wrapper
*/
#pragma once
// Defines
#ifdef __GNUC__
#define DEPRECATED(func) func __attribute__ ((deprecated))

@ -22,24 +22,18 @@ must not be misrepresented as being the original software.
distribution.
*/
#pragma once
#ifndef DFHACK_C_API
#define DFHACK_C_API
#include "dfhack/DFPragma.h"
#include <cstdio>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
namespace DFHack {};
using namespace DFHack;
#include "dfhack/DFGlobal.h"
#include "dfhack/DFExport.h"
#include "dfhack/DFIntegers.h"
using namespace DFHack;
typedef void DFHackObject;
#ifdef __cplusplus

@ -0,0 +1,51 @@
/*
* 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 DFHACK_C_API
#define DFHACK_C_API
#define HBUILD(a) a ## BufferCallback
#define HREG_MACRO(type_name, type) DFHACK_EXPORT void HBUILD(Register ## type_name) (int (*funcptr)(type, uint32_t));
#define HUNREG_MACRO(type_name) DFHACK_EXPORT void HBUILD(Unregister ## type_name) ();
#include "dfhack/DFPragma.h"
#include "dfhack/DFExport.h"
#include "dfhack/DFIntegers.h"
typedef void DFHackObject;
#ifdef __cplusplus
namespace DFHack {};
using namespace DFHack;
extern "C" {
#endif
// some global stuff here
#ifdef __cplusplus
}
#endif
#endif

@ -25,7 +25,7 @@ distribution.
#ifndef DFHACK_C_CONTEXT
#define DFHACK_C_CONTEXT
#include "DFHack_C.h"
#include "dfhack-c/Common.h"
#ifdef __cplusplus
extern "C" {

@ -25,7 +25,7 @@ distribution.
#ifndef PROCESS_C_API
#define PROCESS_C_API
#include "DFHack_C.h"
#include "dfhack-c/Common.h"
#include "dfhack/DFProcess.h"
#ifdef __cplusplus

@ -25,7 +25,7 @@ distribution.
#ifndef TILETYPES_C_API
#define TILETYPES_C_API
#include "DFHack_C.h"
#include "dfhack-c/Common.h"
#include "dfhack/DFTileTypes.h"
#ifdef __cplusplus

@ -25,13 +25,12 @@ distribution.
#ifndef TYPES_C_API
#define TYPES_C_API
#include "DFHack_C.h"
#include "dfhack-c/Common.h"
#include "DFProcess_C.h"
#include "dfhack/DFTypes.h"
#include "dfhack/modules/Maps.h"
#include "dfhack/modules/Materials.h"
#include "dfhack/modules/Gui.h"
//#include "dfhack/DFTileTypes.h"
#define HBUILD(a) a ## BufferCallback
#define HREG_MACRO(type_name, type) DFHACK_EXPORT void HBUILD(Register ## type_name) (int (*funcptr)(type, uint32_t));
@ -259,10 +258,10 @@ DFHACK_EXPORT void RegisterFeatureMapBufferCallback(int (*funcptr)(c_featuremap_
#ifdef __cplusplus
}
#endif
/*
void BuildDescriptorList(std::vector<t_creaturetype> & src, c_creaturetype_descriptor** dest);
void FreeDescriptorList(c_creaturetype_descriptor* d, uint32_t length);
int CreatureTypeConvert(std::vector<t_creaturetype> &, c_creaturetype**);
*/
#endif

@ -25,7 +25,7 @@ distribution.
#ifndef BUILDINGS_C_API
#define BUILDINGS_C_API
#include "DFHack_C.h"
#include "dfhack-c/Common.h"
#include "dfhack/DFTypes.h"
#include "dfhack/modules/Buildings.h"
#include "dfhack-c/DFTypes_C.h"

@ -25,7 +25,7 @@ distribution.
#ifndef CONSTRUCTIONS_C_API
#define CONSTRUCTIONS_C_API
#include "DFHack_C.h"
#include "dfhack-c/Common.h"
#include "dfhack/DFTypes.h"
#include "dfhack/modules/Constructions.h"

@ -25,7 +25,7 @@ distribution.
#ifndef CREATURES_C_API
#define CREATURES_C_API
#include "DFHack_C.h"
#include "dfhack-c/Common.h"
#include "dfhack/DFTypes.h"
#include "dfhack-c/DFTypes_C.h"
#include "dfhack/modules/Materials.h"

@ -25,7 +25,7 @@ distribution.
#ifndef GUI_C_API
#define GUI_C_API
#include "DFHack_C.h"
#include "dfhack-c/Common.h"
#include "dfhack/DFTypes.h"
#include "dfhack/modules/Gui.h"

@ -25,7 +25,7 @@ distribution.
#ifndef ITEMS_C_API
#define ITEMS_C_API
#include "DFHack_C.h"
#include "dfhack-c/Common.h"
#include "dfhack/DFProcess.h"
#include "dfhack-c/DFTypes_C.h"
#include "dfhack/modules/Items.h"

@ -25,7 +25,7 @@ distribution.
#ifndef MAPS_C_API
#define MAPS_C_API
#include "DFHack_C.h"
#include "dfhack-c/Common.h"
#include "dfhack/DFTypes.h"
#include "dfhack/modules/Maps.h"

@ -25,7 +25,7 @@ distribution.
#ifndef MATERIALS_C_API
#define MATERIALS_C_API
#include "DFHack_C.h"
#include "dfhack-c/Common.h"
#include "dfhack-c/DFTypes_C.h"
#include "dfhack/modules/Materials.h"

@ -25,7 +25,7 @@ distribution.
#ifndef TRANSLATION_C_API
#define TRANSLATION_C_API
#include "DFHack_C.h"
#include "dfhack-c/Common.h"
#include "dfhack/DFTypes.h"
#include "dfhack-c/DFTypes_C.h"
#include "dfhack/modules/Translation.h"

@ -25,7 +25,7 @@ distribution.
#ifndef VEGETATION_C_API
#define VEGETATION_C_API
#include "DFHack_C.h"
#include "dfhack-c/Common.h"
#include "dfhack/DFTypes.h"
#include "dfhack/modules/Vegetation.h"

@ -25,7 +25,7 @@ distribution.
#ifndef WINDOWIO_C_API
#define WINDOWIO_C_API
#include "DFHack_C.h"
#include "dfhack-c/Common.h"
#include "dfhack/modules/WindowIO.h"
#ifdef __cplusplus

@ -25,7 +25,7 @@ distribution.
#ifndef WORLD_C_API
#define WORLD_C_API
#include "DFHack_C.h"
#include "dfhack-c/Common.h"
#include "dfhack/modules/World.h"
#ifdef __cplusplus

@ -22,6 +22,8 @@ must not be misrepresented as being the original software.
distribution.
*/
#pragma once
#ifndef CONTEXT_H_INCLUDED
#define CONTEXT_H_INCLUDED

@ -22,6 +22,8 @@ must not be misrepresented as being the original software.
distribution.
*/
#pragma once
#ifndef CONTEXTMANAGER_H_INCLUDED
#define CONTEXTMANAGER_H_INCLUDED

@ -22,6 +22,8 @@ must not be misrepresented as being the original software.
distribution.
*/
#pragma once
#ifndef ERROR_H_INCLUDED
#define ERROR_H_INCLUDED

@ -22,6 +22,8 @@ must not be misrepresented as being the original software.
distribution.
*/
#pragma once
#ifdef LINUX_BUILD
#ifndef DFHACK_EXPORT
#define DFHACK_EXPORT __attribute__ ((visibility("default")))

@ -1,11 +0,0 @@
#ifndef DFHACK_GLOBAL
#define DFHACK_GLOBAL
#include "DFExport.h"
// globals, if any, should be placed here.
namespace DFHack
{
// extern DFHACK_EXPORT TYPE NAME;
}
#endif

@ -7,6 +7,9 @@ stdint.h is part of the C99 standard. It's ancient and simply should be there. F
You can turn off the include by defining SKIP_DFHACK_STDINT
*/
#pragma once
#ifndef SKIP_DFHACK_STDINT
#ifndef _MSC_VER
#include <stdint.h>

@ -1,3 +1,5 @@
#pragma once
#ifndef DF_MISCUTILS
#define DF_MISCUTILS
#include <iostream>

@ -1,4 +1,3 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf
@ -23,6 +22,8 @@ must not be misrepresented as being the original software.
distribution.
*/
#pragma once
#ifndef MODULE_H_INCLUDED
#define MODULE_H_INCLUDED

@ -1,3 +1,5 @@
#pragma once
#ifndef DFHACK_TRANQUILITY
#define DFHACK_TRANQUILITY

@ -22,6 +22,8 @@ must not be misrepresented as being the original software.
distribution.
*/
#pragma once
#ifndef PROCESS_H_INCLUDED
#define PROCESS_H_INCLUDED

@ -22,6 +22,8 @@ must not be misrepresented as being the original software.
distribution.
*/
#pragma once
#ifndef PROCESSMANAGER_H_INCLUDED
#define PROCESSMANAGER_H_INCLUDED

@ -22,6 +22,8 @@ must not be misrepresented as being the original software.
distribution.
*/
#pragma once
#ifndef TILETYPES_H_INCLUDED
#define TILETYPES_H_INCLUDED

@ -22,14 +22,18 @@ must not be misrepresented as being the original software.
distribution.
*/
#pragma once
#ifndef TYPES_H_INCLUDED
#define TYPES_H_INCLUDED
#include "DFPragma.h"
#include "DFExport.h"
#ifdef __cplusplus
namespace DFHack
{
#endif
struct t_matglossPair
{
@ -44,7 +48,7 @@ struct junk_fill
{
uint8_t data[SIZE];
};
enum EFFECT_TYPE
{
EFF_MIASMA=0,
@ -205,6 +209,7 @@ struct t_attrib
uint32_t field_18;
};
#ifdef __cplusplus
struct t_level
{
uint32_t level;
@ -213,4 +218,6 @@ struct t_level
};
}// namespace DFHack
#endif
#endif // TYPES_H_INCLUDED

@ -22,6 +22,8 @@ must not be misrepresented as being the original software.
distribution.
*/
#pragma once
#ifndef DFVECTOR_H_INCLUDED
#define DFVECTOR_H_INCLUDED

@ -22,6 +22,8 @@ must not be misrepresented as being the original software.
distribution.
*/
#pragma once
#ifndef MEMINFO_H_INCLUDED
#define MEMINFO_H_INCLUDED

@ -22,6 +22,8 @@ must not be misrepresented as being the original software.
distribution.
*/
#pragma once
#ifndef MEMINFO_MANAGER_H_INCLUDED
#define MEMINFO_MANAGER_H_INCLUDED

@ -1,3 +1,4 @@
#pragma once
#ifndef MAPEXTRAS_H
#define MAPEXTRAS_H

@ -1,17 +1,17 @@
#pragma once
#ifndef CL_MOD_BUILDINGS
#define CL_MOD_BUILDINGS
/*
* Buildings - also includes zones and stockpiles
*/
#include "dfhack/DFExport.h"
#include "dfhack/DFModule.h"
/**
* \defgroup grp_buildings Building module parts
* \defgroup grp_buildings Building module parts - also includes zones and stockpiles
* @ingroup grp_modules
*/
#include "dfhack/DFExport.h"
#include "dfhack/DFModule.h"
#ifdef __cplusplus
namespace DFHack
{
#endif
/**
* Structure for holding a read DF building object
* \ingroup grp_buildings
@ -20,21 +20,17 @@ namespace DFHack
{
uint32_t origin;
uint32_t vtable;
uint32_t x1;
uint32_t y1;
uint32_t x2;
uint32_t y2;
uint32_t z;
t_matglossPair material;
uint32_t type;
// FIXME: not complete, we need building presence bitmaps for stuff like farm plots and stockpiles, orientation (N,E,S,W) and state (open/closed)
};
#ifdef __cplusplus
class DFContextShared;
/**
* The Buildings module - allows reading DF buildings
@ -50,15 +46,17 @@ namespace DFHack
// read one building at offset
bool Read (const uint32_t index, t_building & building);
bool Finish();
// read a vector of names
bool ReadCustomWorkshopTypes(std::map <uint32_t, std::string> & btypes);
// returns -1 on error, >= 0 for real value
int32_t GetCustomWorkshopType(t_building & building);
private:
struct Private;
Private *d;
};
}
#endif // __cplusplus
#endif

@ -1,3 +1,4 @@
#pragma once
#ifndef CL_MOD_CONSTRUCTIONS
#define CL_MOD_CONSTRUCTIONS
/*

@ -1,3 +1,4 @@
#pragma once
#ifndef CL_MOD_CREATURES
#define CL_MOD_CREATURES
/*

@ -1,3 +1,4 @@
#pragma once
#ifndef CL_MOD_ENGRAVINGS
#define CL_MOD_ENGRAVINGS
/*

@ -1,3 +1,4 @@
#pragma once
#ifndef CL_MOD_GUI
#define CL_MOD_GUI

@ -1,3 +1,4 @@
#pragma once
#ifndef CL_MOD_ITEMS
#define CL_MOD_ITEMS

@ -2,6 +2,7 @@
M A P S
Read and write DF's map
*******************************************************************************/
#pragma once
#ifndef CL_MOD_MAPS
#define CL_MOD_MAPS

@ -1,3 +1,4 @@
#pragma once
#ifndef CL_MOD_MATERIALS
#define CL_MOD_MATERIALS
/**

@ -1,3 +1,4 @@
#pragma once
#ifndef CL_MOD_TRANSLATION
#define CL_MOD_TRANSLATION
/**

@ -1,3 +1,4 @@
#pragma once
#ifndef CL_MOD_VEGETATION
#define CL_MOD_VEGETATION
/**
@ -26,10 +27,6 @@ namespace DFHack
uint16_t x; // +0x70
uint16_t y; // +0x72
uint16_t z; // +0x74
/*
junk_fill<0xA> junk;
uint32_t flags; // +0x80 maybe?
*/
uint32_t address;
};

@ -21,7 +21,7 @@ must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#pragma once
#ifndef KEYS_H_INCLUDED
#define KEYS_H_INCLUDED

@ -1,3 +1,4 @@
#pragma once
#ifndef CL_MOD_WORLD
#define CL_MOD_WORLD

@ -22,8 +22,11 @@ must not be misrepresented as being the original software.
distribution.
*/
#include "dfhack-c/modules/Buildings_C.h"
#include <string>
#include <map>
#include <vector>
using namespace std;
#include "dfhack-c/modules/Buildings_C.h"
#ifdef __cplusplus
extern "C" {
@ -31,42 +34,38 @@ extern "C" {
int Buildings_Start(DFHackObject* b_Ptr, uint32_t* numBuildings)
{
if(b_Ptr != NULL)
{
return ((DFHack::Buildings*)b_Ptr)->Start(*numBuildings);
}
return -1;
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;
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;
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;
if(b_Ptr != NULL)
{
return ((DFHack::Buildings*)b_Ptr)->GetCustomWorkshopType(*building);
}
return -1;
}
t_customWorkshop* Buildings_ReadCustomWorkshopTypes(DFHackObject* b_Ptr)
@ -80,19 +79,18 @@ t_customWorkshop* Buildings_ReadCustomWorkshopTypes(DFHackObject* b_Ptr)
if(!((DFHack::Buildings*)b_Ptr)->ReadCustomWorkshopTypes(bTypes))
return NULL;
(*alloc_customWorkshop_buffer_callback)(&cw_Ptr, bTypes.size());
if(cw_Ptr == NULL)
return NULL;
(*alloc_customWorkshop_buffer_callback)(&cw_Ptr, bTypes.size());
if(cw_Ptr == NULL)
return NULL;
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 cw_Ptr;
}

@ -21,7 +21,10 @@ must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include <string>
#include <map>
#include <vector>
using namespace std;
#include "dfhack-c/modules/Constructions_C.h"
#ifdef __cplusplus

@ -21,14 +21,14 @@ must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include "dfhack-c/modules/Creatures_C.h"
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
#include "dfhack-c/modules/Creatures_C.h"
#ifdef __cplusplus
extern "C" {
#endif

@ -22,6 +22,11 @@ must not be misrepresented as being the original software.
distribution.
*/
#include <string>
#include <map>
#include <vector>
using namespace std;
#include "dfhack-c/modules/Gui_C.h"
#include "dfhack-c/DFTypes_C.h"
#ifdef __cplusplus

@ -21,6 +21,10 @@ must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include <string>
#include <map>
#include <vector>
using namespace std;
#include "dfhack-c/modules/Items_C.h"

@ -21,13 +21,168 @@ must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
#include "dfhack-c/modules/Materials_C.h"
#ifdef __cplusplus
extern "C" {
#endif
void BuildDescriptorList(std::vector<t_creaturetype> & src, c_creaturetype_descriptor** dest)
{
c_creaturetype_descriptor* descriptor = NULL;
descriptor = (c_creaturetype_descriptor*)calloc(src.size(), sizeof(c_creaturetype_descriptor));
for(uint32_t i = 0; i < src.size(); i++)
{
uint32_t castes_size = src[i].castes.size();
c_creaturetype_descriptor* current = &descriptor[i];
current->castesCount = castes_size;
current->caste_descriptors = (c_creaturecaste_descriptor*)calloc(castes_size, sizeof(c_creaturecaste_descriptor));
for(uint32_t j = 0; j < castes_size; j++)
{
uint32_t color_size = src[i].castes[j].ColorModifier.size();
c_creaturecaste_descriptor* current_caste = &current->caste_descriptors[j];
current_caste->colorModifierLength = color_size;
current_caste->color_descriptors = (c_colormodifier_descriptor*)calloc(color_size, sizeof(c_colormodifier_descriptor));
for(uint32_t k = 0; k < color_size; k++)
{
c_colormodifier_descriptor* current_color = &current_caste->color_descriptors[k];
current_color->colorlistLength = src[i].castes[j].ColorModifier[k].colorlist.size();
}
current_caste->bodypartLength = src[i].castes[j].bodypart.size();
}
current->extractCount = src[i].extract.size();
}
*dest = descriptor;
}
void FreeDescriptorList(c_creaturetype_descriptor* d, uint32_t length)
{
for(uint32_t i = 0; i < length; i++)
{
c_creaturetype_descriptor* desc = &d[i];
for(uint32_t j = 0; j < desc->castesCount; j++)
free(desc->caste_descriptors[j].color_descriptors);
free(desc->caste_descriptors);
}
free(d);
}
int CreatureTypeConvert(std::vector<t_creaturetype> & src, c_creaturetype** out_buf)
{
if(src.size() <= 0)
return 0;
else if(alloc_creaturetype_buffer_callback == NULL)
return -1;
else
{
c_creaturetype_descriptor* descriptor;
c_creaturetype* buf;
BuildDescriptorList(src, &descriptor);
((*alloc_creaturetype_buffer_callback)(out_buf, descriptor, src.size()));
FreeDescriptorList(descriptor, src.size());
if(out_buf == NULL)
return -1;
buf = out_buf[0];
for(uint32_t i = 0; i < src.size(); i++)
{
c_creaturetype* current = &(buf[i]);
memset(current->rawname, '\0', 128);
strncpy(current->rawname, src[i].rawname, 128);
for(uint32_t j = 0; j < current->castesCount; j++)
{
c_creaturecaste* current_caste = &current->castes[j];
t_creaturecaste* src_caste = &src[i].castes[j];
memset(current_caste->rawname, '\0', 128);
memset(current_caste->singular, '\0', 128);
memset(current_caste->plural, '\0', 128);
memset(current_caste->adjective, '\0', 128);
strncpy(current_caste->rawname, src_caste->rawname, 128);
strncpy(current_caste->singular, src_caste->singular, 128);
strncpy(current_caste->plural, src_caste->plural, 128);
strncpy(current_caste->adjective, src_caste->adjective, 128);
for(uint32_t k = 0; k < src[i].castes[j].ColorModifier.size(); k++)
{
c_colormodifier* current_color = &current_caste->colorModifier[k];
memset(current_color->part, '\0', 128);
strncpy(current_color->part, src_caste->ColorModifier[k].part, 128);
copy(src_caste->ColorModifier[k].colorlist.begin(), src_caste->ColorModifier[k].colorlist.end(), current_color->colorlist);
current_color->colorlistLength = src_caste->ColorModifier[k].colorlist.size();
current_color->startdate = src_caste->ColorModifier[k].startdate;
current_color->enddate = src_caste->ColorModifier[k].enddate;
}
current_caste->colorModifierLength = src_caste->ColorModifier.size();
copy(src_caste->bodypart.begin(), src_caste->bodypart.end(), current_caste->bodypart);
current_caste->bodypartLength = src_caste->bodypart.size();
current_caste->strength = src_caste->strength;
current_caste->agility = src_caste->agility;
current_caste->toughness = src_caste->toughness;
current_caste->endurance = src_caste->endurance;
current_caste->recuperation = src_caste->recuperation;
current_caste->disease_resistance = src_caste->disease_resistance;
current_caste->analytical_ability = src_caste->analytical_ability;
current_caste->focus = src_caste->focus;
current_caste->willpower = src_caste->willpower;
current_caste->creativity = src_caste->creativity;
current_caste->intuition = src_caste->intuition;
current_caste->patience = src_caste->patience;
current_caste->memory = src_caste->memory;
current_caste->linguistic_ability = src_caste->linguistic_ability;
current_caste->spatial_sense = src_caste->spatial_sense;
current_caste->musicality = src_caste->musicality;
current_caste->kinesthetic_sense = src_caste->kinesthetic_sense;
}
copy(src[i].extract.begin(), src[i].extract.end(), current->extract);
current->extractCount = src[i].extract.size();
current->tile_character = src[i].tile_character;
current->tilecolor.fore = src[i].tilecolor.fore;
current->tilecolor.back = src[i].tilecolor.back;
current->tilecolor.bright = src[i].tilecolor.bright;
}
return 1;
}
}
int Materials_ReadInorganicMaterials(DFHackObject* mat)
{
if(mat != NULL)

@ -26,6 +26,7 @@ distribution.
#include <string>
#include <vector>
#include <map>
using namespace std;

@ -27,8 +27,8 @@ distribution.
#include <string>
using namespace std;
#include "dfhack-c/Common.h"
#include "dfhack/DFIntegers.h"
#include "DFHack_C.h"
#include "dfhack/modules/WindowIO.h"
#include "dfhack-c/modules/WindowIO_C.h"

@ -22,7 +22,10 @@ must not be misrepresented as being the original software.
distribution.
*/
#include "DFHack_C.h"
#include <vector>
#include <map>
using namespace std;
#include "dfhack-c/Common.h"
#include "dfhack/modules/World.h"
#include "dfhack-c/modules/World_C.h"
#include "dfhack-c/DFTypes_C.h"

@ -22,9 +22,7 @@ must not be misrepresented as being the original software.
distribution.
*/
/*
* WARNING: Only include from API modules
*/
#pragma once
#ifndef APIPRIVATE_H_INCLUDED
#define APIPRIVATE_H_INCLUDED

@ -22,6 +22,8 @@ must not be misrepresented as being the original software.
distribution.
*/
#pragma once
#ifndef DFCOMMONINTERNAL_H_INCLUDED
#define DFCOMMONINTERNAL_H_INCLUDED
@ -39,9 +41,6 @@ distribution.
#define _FILE_OFFSET_BITS 64
#endif
// one file for globals
#include "dfhack/DFGlobal.h"
// one file for telling the MSVC compiler where it can shove its pointless warnings
#include "dfhack/DFPragma.h"

@ -22,6 +22,8 @@ must not be misrepresented as being the original software.
distribution.
*/
#pragma once
#ifndef LINUX_PROCESS_H_INCLUDED
#define LINUX_PROCESS_H_INCLUDED

@ -22,7 +22,7 @@ must not be misrepresented as being the original software.
distribution.
*/
#include <string>
#pragma once
namespace DFHack {
class Process;

@ -22,6 +22,8 @@
distribution.
*/
#pragma once
#ifndef MODULE_FACTORY_H_INCLUDED
#define MODULE_FACTORY_H_INCLUDED

@ -22,6 +22,8 @@
* distribution.
*/
#pragma once
#ifndef DFPLATFORMINTERNAL_H_INCLUDED
#define DFPLATFORMINTERNAL_H_INCLUDED

@ -22,6 +22,8 @@ must not be misrepresented as being the original software.
distribution.
*/
#pragma once
#ifndef SHM_PROCESS_H_INCLUDED
#define SHM_PROCESS_H_INCLUDED

@ -1,6 +1,6 @@
#include <iostream>
#include <fstream>
#include <strstream>
#include <sstream>
#include <DFHack.h>
using namespace std;

@ -23,7 +23,6 @@ int main (void)
//DFHack::TileRow *ptile;
int32_t oldT, newT;
int16_t t;
bool dirty= false;
int count=0;