From 52178e779fa5b82e55c76eace181f908ce20b20d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 17 Jul 2010 01:55:18 +0200 Subject: [PATCH] Fixes to merged C API and windows SHM. --- library/DFTypes_C.cpp | 1 + library/modules/Maps_C.cpp | 4 ++-- library/modules/Position.cpp | 40 +++++++++++++++++++++++++++++++++++- library/shm/shms-windows.cpp | 15 ++++++++++++++ 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/library/DFTypes_C.cpp b/library/DFTypes_C.cpp index b8f0a6a9b..dc7d946aa 100644 --- a/library/DFTypes_C.cpp +++ b/library/DFTypes_C.cpp @@ -23,6 +23,7 @@ distribution. */ #include "dfhack/DFIntegers.h" +#include "dfhack/DFTileTypes.h" #include #include "string.h" #include diff --git a/library/modules/Maps_C.cpp b/library/modules/Maps_C.cpp index 0700e0a9a..09a7dc065 100644 --- a/library/modules/Maps_C.cpp +++ b/library/modules/Maps_C.cpp @@ -308,7 +308,7 @@ t_frozenliquidvein* Maps_ReadFrozenVeins(DFHackObject* maps, uint32_t x, uint32_ { if(maps != NULL) { - if(alloc_frozenliquidvein_callback == NULL) + if(alloc_frozenliquidvein_buffer_callback == NULL) return NULL; vector veins; @@ -339,7 +339,7 @@ t_spattervein* Maps_ReadSpatterVeins(DFHackObject* maps, uint32_t x, uint32_t y, { if(maps != NULL) { - if(alloc_spattervein_callback == NULL) + if(alloc_spattervein_buffer_callback == NULL) return NULL; vector veins; diff --git a/library/modules/Position.cpp b/library/modules/Position.cpp index 321460577..0b76be94e 100644 --- a/library/modules/Position.cpp +++ b/library/modules/Position.cpp @@ -41,12 +41,15 @@ struct Position::Private uint32_t hotkey_mode_offset; uint32_t hotkey_xyz_offset; uint32_t hotkey_size; + + uint32_t screen_tiles_ptr_offset; DFContextShared *d; Process * owner; bool Inited; bool Started; bool StartedHotkeys; + bool StartedScreen; }; Position::Position(DFContextShared * d_) @@ -55,7 +58,7 @@ Position::Position(DFContextShared * d_) d->d = d_; d->owner = d_->p; d->Inited = true; - d->StartedHotkeys = d->Started = false; + d->StartedHotkeys = d->Started = d->StartedScreen = false; memory_info * mem; try { @@ -77,6 +80,12 @@ Position::Position(DFContextShared * d_) d->StartedHotkeys = true; } catch(exception &){}; + try + { + d->screen_tiles_ptr_offset = mem->getAddress ("screen_tiles_pointer"); + d->StartedScreen = true; + } + catch(exception &){}; } Position::~Position() @@ -161,3 +170,32 @@ bool Position::getWindowSize (int32_t &width, int32_t &height) return true; } +/* +bool Position::getScreenTiles (int32_t width, int32_t height, t_screen screen[]) +{ + if(!d->Inited) return false; + uint32_t screen_addr; + d->owner->read (d->screen_tiles_ptr_offset, sizeof(uint32_t), (uint8_t *) screen_addr); + + uint8_t* tiles = new uint8_t[width*height*4 + 80 + width*height*4]; + + d->owner->read (screen_addr, (width*height*4 + 80 + width*height*4), (uint8_t *) tiles); + + for(int32_t iy=0; iy