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() void Core::Resume()
{ {
/*
for(unsigned int i = 0 ; i < allModules.size(); i++) for(unsigned int i = 0 ; i < allModules.size(); i++)
{ {
allModules[i]->OnResume(); allModules[i]->OnResume();
} }
*/
SDL_mutexV(AccessMutex); SDL_mutexV(AccessMutex);
} }

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

@ -33,6 +33,7 @@ distribution.
#include "dfhack/Export.h" #include "dfhack/Export.h"
#include "dfhack/Module.h" #include "dfhack/Module.h"
#include "dfhack/modules/Vegetation.h" #include "dfhack/modules/Vegetation.h"
#include <vector>
/** /**
* \defgroup grp_maps Maps module and its types * \defgroup grp_maps Maps module and its types
@ -518,6 +519,99 @@ namespace DFHack
int32_t mystery; int32_t mystery;
} mapblock40d; } 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 * The Maps module
* \ingroup grp_modules * \ingroup grp_modules

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

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

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