sync, some map data structures, commented out some dead code

develop
Petr Mrázek 2011-07-06 11:13:36 +02:00
parent b1d4163095
commit 56a409d9a4
6 changed files with 122 additions and 25 deletions

@ -189,10 +189,12 @@ void Core::Suspend()
void Core::Resume()
{
/*
for(unsigned int i = 0 ; i < allModules.size(); i++)
{
allModules[i]->OnResume();
}
*/
SDL_mutexV(AccessMutex);
}

@ -40,6 +40,7 @@ namespace DFHack
virtual ~Module(){};
virtual bool Start(){return true;};// default start...
virtual bool Finish() = 0;// everything should have a Finish()
/*
// should Context call Finish when Resume is called?
virtual bool OnResume()
{
@ -52,6 +53,7 @@ namespace DFHack
{
return false;
};
*/
};
}
#endif //MODULE_H_INCLUDED

@ -33,6 +33,7 @@ distribution.
#include "dfhack/Export.h"
#include "dfhack/Module.h"
#include "dfhack/modules/Vegetation.h"
#include <vector>
/**
* \defgroup grp_maps Maps module and its types
@ -518,6 +519,99 @@ namespace DFHack
int32_t mystery;
} mapblock40d;
// A raw DF block.
// one of the vector is the 'effects' vector. another should be item id/index vector
struct df_block
{
// FIXME: wrap the flag array!
unsigned char * flagarray;
unsigned long flagarray_slots;
// how to handle this virtual mess?
std::vector <void *> block_events;
// no idea what these are
long unk1;
long unk2;
long unk3;
// feature indexes
signed long local_feature; // local feature index, -1 = no local feature
signed long global_feature; // global feature index, -1 = no global feature
signed long mystery; // no idea. couldn't manage to catch its use in debugger.
// more mysterious numbers
long unk4;
long unk5;
long unk6;
std::vector <unsigned long> items; // item related - probly item IDs
std::vector <void *> effects;
signed long unk7; // -1 most of the time, another index?
unsigned long unk8; // again, index?
std::vector<df_plant *> plants;
unsigned short map_x;
unsigned short map_y;
unsigned short map_z;
unsigned short region_x;
unsigned short region_y;
unsigned short tiletype[16][16]; // weird 2-byte alignment here
t_designation designation[16][16];
t_occupancy occupancy[16][16];
// following is uncertain, but total length should be fixed.
unsigned char unk9[16][16];
unsigned long pathfinding[16][16];
unsigned short unk10[16][16];
unsigned short unk11[16][16];
unsigned short unk12[16][16];
// end uncertain section
unsigned short temperature_1[16][16];
unsigned short temperature_2[16][16];
// no idea again. needs research...
unsigned short unk13[16][16];
unsigned short unk14[16][16];
unsigned char region_offset[9];
};
template <typename T>
struct df_array
{
inline const T& operator[] (uint32_t index)
{
return array[index];
};
private:
T array[];
};
template <typename T>
struct df_2darray
{
inline const df_array<T>& operator[] (uint32_t index)
{
return array[index];
};
private:
df_array <T> * array;
};
template <typename T>
struct df_3darray
{
inline const df_2darray<T>& operator[] (uint32_t index)
{
return array[index];
};
private:
df_2darray <T> * array;
};
struct map_data
{
df_3darray<df_block *> map_data;
std::vector <void *> unk1;
void * unk2;
uint32_t x_size_blocks;
uint32_t y_size_blocks;
uint32_t z_size_blocks;
uint32_t x_size;
uint32_t y_size;
uint32_t z_size;
int32_t x_area_offset;
int32_t y_area_offset;
int32_t z_area_offset;
};
/**
* The Maps module
* \ingroup grp_modules

@ -46,39 +46,38 @@ namespace DFHack
RAINING,
SNOWING
};
/**
* \ingroup grp_world
*/
enum ControlMode
enum GameMode
{
CM_Managing = 0,
CM_DirectControl = 1,
CM_Kittens = 2, // not sure yet, but I think it will involve kittens
CM_Menu = 3,
CM_MAX = 3
GAMEMODE_DWARF,
GAMEMODE_ADVENTURE,
GAMEMODENUM,
GAMEMODE_NONE
};
/**
* \ingroup grp_world
*/
enum GameMode
enum GameType
{
GM_Fort = 0,
GM_Adventurer = 1,
GM_Legends = 2,
GM_Menu = 3,
GM_Arena = 4,
GM_Arena_Assumed = 5,
GM_Kittens = 6,
GM_Worldgen = 7,
GM_MAX = 7,
GAMETYPE_DWARF_MAIN,
GAMETYPE_ADVENTURE_MAIN,
GAMETYPE_VIEW_LEGENDS,
GAMETYPE_DWARF_RECLAIM,
GAMETYPE_DWARF_ARENA,
GAMETYPE_ADVENTURE_ARENA,
GAMETYPENUM,
GAMETYPE_NONE
};
/**
* \ingroup grp_world
*/
struct t_gamemodes
{
ControlMode control_mode;
GameMode game_mode;
GameMode g_mode;
GameType g_type;
};
class DFContextShared;
/**

@ -153,8 +153,8 @@ bool World::ReadGameMode(t_gamemodes& rd)
{
if(d->Inited && d->StartedMode)
{
rd.control_mode = (ControlMode) d->owner->readDWord( d->controlmode_offset);
rd.game_mode = (GameMode) d->owner->readDWord(d->gamemode_offset);
rd.g_mode = (GameMode) d->owner->readDWord( d->controlmode_offset);
rd.g_type = (GameType) d->owner->readDWord(d->gamemode_offset);
return true;
}
return false;
@ -163,8 +163,8 @@ bool World::WriteGameMode(const t_gamemodes & wr)
{
if(d->Inited && d->StartedMode)
{
d->owner->writeDWord(d->gamemode_offset,wr.game_mode);
d->owner->writeDWord(d->controlmode_offset,wr.control_mode);
d->owner->writeDWord(d->gamemode_offset,wr.g_mode);
d->owner->writeDWord(d->controlmode_offset,wr.g_type);
return true;
}
return false;

@ -50,7 +50,7 @@ DFhackCExport command_result plugin_onupdate ( Core * c )
DFHack::World *World =c->getWorld();
t_gamemodes gm;
World->ReadGameMode(gm);
if(gm.game_mode == GM_Fort)
if(gm.g_mode == GAMEMODE_DWARF)
{
World->SetPauseState(true);
}
@ -76,7 +76,7 @@ DFhackCExport command_result reveal(DFHack::Core * c, std::vector<std::string> &
DFHack::World *World =c->getWorld();
t_gamemodes gm;
World->ReadGameMode(gm);
if(gm.game_mode != GM_Fort)
if(gm.g_mode != GAMEMODE_DWARF)
{
dfout << "Only in fortress mode." << std::endl;
c->Resume();
@ -141,7 +141,7 @@ DFhackCExport command_result unreveal(DFHack::Core * c, std::vector<std::string>
DFHack::World *World =c->getWorld();
t_gamemodes gm;
World->ReadGameMode(gm);
if(gm.game_mode != GM_Fort)
if(gm.g_mode != GAMEMODE_DWARF)
{
dfout << "Only in fortress mode." << std::endl;
c->Resume();