Merge branch 'master' of http://github.com/doomchild/dfhack
commit
29aa8f03c0
@ -0,0 +1,182 @@
|
|||||||
|
/*
|
||||||
|
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 "Tranquility.h"
|
||||||
|
#include "Export.h"
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include "integers.h"
|
||||||
|
#include "DFTileTypes.h"
|
||||||
|
#include "DFTypes.h"
|
||||||
|
#include "DFWindow.h"
|
||||||
|
#include "DFHackAPI.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace DFHack;
|
||||||
|
|
||||||
|
#include "DFHackAPI_C.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DFHackObject* API_Alloc(const char* path_to_xml)
|
||||||
|
{
|
||||||
|
DFHack::API* api = new DFHack::API(std::string(path_to_xml));
|
||||||
|
return (DFHackObject*)api;
|
||||||
|
}
|
||||||
|
|
||||||
|
void API_Free(DFHackObject* api)
|
||||||
|
{
|
||||||
|
if(api != NULL)
|
||||||
|
{
|
||||||
|
delete api;
|
||||||
|
api = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int API_Attach(DFHackObject* api)
|
||||||
|
{
|
||||||
|
if(api != NULL)
|
||||||
|
{
|
||||||
|
if(((DFHack::API*)api)->Attach())
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int API_Detach(DFHackObject* api)
|
||||||
|
{
|
||||||
|
if(api != NULL)
|
||||||
|
{
|
||||||
|
if(((DFHack::API*)api)->Detach())
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int API_isAttached(DFHackObject* api)
|
||||||
|
{
|
||||||
|
if(api != NULL)
|
||||||
|
{
|
||||||
|
if(((DFHack::API*)api)->isAttached())
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int API_Suspend(DFHackObject* api)
|
||||||
|
{
|
||||||
|
if(api != NULL)
|
||||||
|
{
|
||||||
|
if(((DFHack::API*)api)->Suspend())
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int API_Resume(DFHackObject* api)
|
||||||
|
{
|
||||||
|
if(api != NULL)
|
||||||
|
{
|
||||||
|
if(((DFHack::API*)api)->Resume())
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int API_isSuspended(DFHackObject* api)
|
||||||
|
{
|
||||||
|
if(api != NULL)
|
||||||
|
{
|
||||||
|
if(((DFHack::API*)api)->isSuspended())
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int API_ForceResume(DFHackObject* api)
|
||||||
|
{
|
||||||
|
if(api != NULL)
|
||||||
|
{
|
||||||
|
if(((DFHack::API*)api)->ForceResume())
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int API_AsyncSuspend(DFHackObject* api)
|
||||||
|
{
|
||||||
|
if(api != NULL)
|
||||||
|
{
|
||||||
|
if(((DFHack::API*)api)->AsyncSuspend())
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void API_ReadRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* target)
|
||||||
|
{
|
||||||
|
if(api != NULL)
|
||||||
|
{
|
||||||
|
((DFHack::API*)api)->ReadRaw(offset, size, target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void API_WriteRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* source)
|
||||||
|
{
|
||||||
|
if(api != NULL)
|
||||||
|
{
|
||||||
|
((DFHack::API*)api)->WriteRaw(offset, size, source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
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
|
||||||
|
|
||||||
|
#include "Export.h"
|
||||||
|
#include "integers.h"
|
||||||
|
|
||||||
|
typedef void DFHackObject;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EXPORT DFHackObject* API_Alloc(const char* path_to_xml);
|
||||||
|
EXPORT void API_Free(DFHackObject* api);
|
||||||
|
|
||||||
|
EXPORT int API_Attach(DFHackObject* api);
|
||||||
|
EXPORT int API_Detach(DFHackObject* api);
|
||||||
|
EXPORT int API_isAttached(DFHackObject* api);
|
||||||
|
|
||||||
|
EXPORT int API_Suspend(DFHackObject* api);
|
||||||
|
EXPORT int API_Resume(DFHackObject* api);
|
||||||
|
EXPORT int API_isSuspended(DFHackObject* api);
|
||||||
|
EXPORT int API_ForceResume(DFHackObject* api);
|
||||||
|
EXPORT int API_AsyncSuspend(DFHackObject* api);
|
||||||
|
|
||||||
|
EXPORT void API_ReadRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* target);
|
||||||
|
EXPORT void API_WriteRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* source);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
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 POSITION_C_API
|
||||||
|
#define POSITION_C_API
|
||||||
|
|
||||||
|
#include "Export.h"
|
||||||
|
|
||||||
|
#include "DFHackAPI_C.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EXPORT int Position_getViewCoords(DFHackObject* pos, int32_t* x, int32_t* y, int32_t* z);
|
||||||
|
EXPORT int Position_setViewCoords(DFHackObject* pos, const int32_t x, const int32_t y, const int32_t z);
|
||||||
|
|
||||||
|
EXPORT int Position_getCursorCoords(DFHackObject* pos, int32_t* x, int32_t* y, int32_t* z);
|
||||||
|
EXPORT int Position_setCursorCoords(DFHackObject* pos, const int32_t x, const int32_t y, const int32_t z);
|
||||||
|
|
||||||
|
EXPORT int Position_getWindowSize(DFHackObject* pos, int32_t* width, int32_t* height);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,128 @@
|
|||||||
|
/*
|
||||||
|
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 "modules/Position_C.h"
|
||||||
|
#include "integers.h"
|
||||||
|
|
||||||
|
#include "DFCommonInternal.h"
|
||||||
|
#include "modules/Position.h"
|
||||||
|
|
||||||
|
using namespace DFHack;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int Position_getViewCoords(DFHackObject* pos, int32_t* x, int32_t* y, int32_t* z)
|
||||||
|
{
|
||||||
|
if(pos != NULL)
|
||||||
|
{
|
||||||
|
int32_t tx, ty, tz;
|
||||||
|
|
||||||
|
if(((DFHack::Position*)pos)->getViewCoords(tx, ty, tz))
|
||||||
|
{
|
||||||
|
*x = tx;
|
||||||
|
*y = ty;
|
||||||
|
*z = tz;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Position_setViewCoords(DFHackObject* pos, int32_t x, int32_t y, int32_t z)
|
||||||
|
{
|
||||||
|
if(pos != NULL)
|
||||||
|
{
|
||||||
|
if(((DFHack::Position*)pos)->setViewCoords(x, y, z))
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Position_getCursorCoords(DFHackObject* pos, int32_t* x, int32_t* y, int32_t* z)
|
||||||
|
{
|
||||||
|
if(pos != NULL)
|
||||||
|
{
|
||||||
|
int32_t tx, ty, tz;
|
||||||
|
|
||||||
|
if(((DFHack::Position*)pos)->getCursorCoords(tx, ty, tz))
|
||||||
|
{
|
||||||
|
*x = tx;
|
||||||
|
*y = ty;
|
||||||
|
*z = tz;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Position_setCursorCoords(DFHackObject* pos, int32_t x, int32_t y, int32_t z)
|
||||||
|
{
|
||||||
|
if(pos != NULL)
|
||||||
|
{
|
||||||
|
if(((DFHack::Position*)pos)->setCursorCoords(x, y, z))
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Position_getWindowSize(DFHackObject* pos, int32_t* width, int32_t* height)
|
||||||
|
{
|
||||||
|
if(pos != NULL)
|
||||||
|
{
|
||||||
|
int32_t tw, th;
|
||||||
|
|
||||||
|
if(((DFHack::Position*)pos)->getWindowSize(tw, th))
|
||||||
|
{
|
||||||
|
*width = tw;
|
||||||
|
*height = th;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
Reference in New Issue