Merge remote-tracking branch 'q-github/master'

develop
Alexander Gavrilov 2012-05-26 14:41:36 +04:00
commit 8644ea4dc0
10 changed files with 76 additions and 76 deletions

@ -200,7 +200,9 @@ google/protobuf/compiler/zip_writer.cc
LIST(APPEND LIBPROTOBUF_FULL_SRCS ${LIBPROTOBUF_LITE_SRCS}) LIST(APPEND LIBPROTOBUF_FULL_SRCS ${LIBPROTOBUF_LITE_SRCS})
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -Wno-sign-compare") IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -Wno-sign-compare")
ENDIF()
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
SET(PROTOBUF_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) SET(PROTOBUF_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})

@ -208,6 +208,8 @@ IF(UNIX)
SET_SOURCE_FILES_PROPERTIES(DataStatics.cpp DataStaticsCtor.cpp DataStaticsFields.cpp SET_SOURCE_FILES_PROPERTIES(DataStatics.cpp DataStaticsCtor.cpp DataStaticsFields.cpp
PROPERTIES COMPILE_FLAGS "-g0 -O1") PROPERTIES COMPILE_FLAGS "-g0 -O1")
ELSE(WIN32) ELSE(WIN32)
SET_SOURCE_FILES_PROPERTIES(DataStatics.cpp DataStaticsCtor.cpp DataStaticsFields.cpp
PROPERTIES COMPILE_FLAGS "/O1 /bigobj")
ENDIF() ENDIF()

@ -37,16 +37,6 @@ distribution.
namespace DFHack namespace DFHack
{ {
/**
* \ingroup grp_world
*/
enum WeatherType
{
CLEAR,
RAINING,
SNOWING
};
typedef unsigned char weather_map [5][5];
/** /**
* \ingroup grp_world * \ingroup grp_world
*/ */
@ -113,7 +103,6 @@ namespace DFHack
class DFHACK_EXPORT World : public Module class DFHACK_EXPORT World : public Module
{ {
public: public:
weather_map * wmap;
World(); World();
~World(); ~World();
bool Start(); bool Start();

@ -998,16 +998,29 @@ bool Gui::setDesignationCoords (const int32_t x, const int32_t y, const int32_t
bool Gui::getMousePos (int32_t & x, int32_t & y) bool Gui::getMousePos (int32_t & x, int32_t & y)
{ {
x = gps->mouse_x; if (gps) {
y = gps->mouse_y; x = gps->mouse_x;
y = gps->mouse_y;
}
else {
x = -1;
y = -1;
}
return (x == -1) ? false : true; return (x == -1) ? false : true;
} }
bool Gui::getWindowSize (int32_t &width, int32_t &height) bool Gui::getWindowSize (int32_t &width, int32_t &height)
{ {
width = gps->dimx; if (gps) {
height = gps->dimy; width = gps->dimx;
return true; height = gps->dimy;
return true;
}
else {
width = 80;
height = 25;
return false;
}
} }
bool Gui::getMenuWidth(uint8_t &menu_width, uint8_t &area_map_width) bool Gui::getMenuWidth(uint8_t &menu_width, uint8_t &area_map_width)

@ -34,10 +34,12 @@ distribution.
#include "modules/Windows.h" #include "modules/Windows.h"
using namespace DFHack; using namespace DFHack;
using df::global::gps;
Windows::df_screentile *Windows::getScreenBuffer() Windows::df_screentile *Windows::getScreenBuffer()
{ {
return (df_screentile *) df::global::gps->screen; if (!gps) return NULL;
return (df_screentile *) gps->screen;
} }
Windows::df_window::df_window(int x, int y, unsigned int width, unsigned int height) Windows::df_window::df_window(int x, int y, unsigned int width, unsigned int height)
@ -79,7 +81,7 @@ bool Windows::df_window::unlock (painter * painter)
return false; return false;
} }
Windows::top_level_window::top_level_window(): df_window(0,0,df::global::gps->dimx,df::global::gps->dimy) Windows::top_level_window::top_level_window() : df_window(0,0,gps ? gps->dimx : 80,gps ? gps->dimy : 25)
{ {
buffer = 0; buffer = 0;
} }

@ -63,15 +63,8 @@ struct World::Private
bool Inited; bool Inited;
bool PauseInited; bool PauseInited;
void * pause_state_offset;
bool StartedWeather; bool StartedWeather;
char * weather_offset;
bool StartedMode; bool StartedMode;
void * gamemode_offset;
void * controlmode_offset;
void * controlmodecopy_offset;
int next_persistent_id; int next_persistent_id;
std::multimap<std::string, int> persistent_index; std::multimap<std::string, int> persistent_index;
@ -86,21 +79,14 @@ World::World()
Core & c = Core::getInstance(); Core & c = Core::getInstance();
d = new Private; d = new Private;
d->owner = c.p; d->owner = c.p;
wmap = 0;
d->pause_state_offset = (void *) c.vinfo->getAddress ("pause_state"); if(df::global::pause_state)
if(d->pause_state_offset)
d->PauseInited = true; d->PauseInited = true;
d->weather_offset = (char *) c.vinfo->getAddress( "current_weather" ); if(df::global::current_weather)
if(d->weather_offset)
{
wmap = (weather_map *) d->weather_offset;
d->StartedWeather = true; d->StartedWeather = true;
} if (df::global::game_mode && df::global::control_mode)
d->gamemode_offset = (void *) c.vinfo->getAddress( "game_mode" ); d->StartedMode = true;
d->controlmode_offset = (void *) c.vinfo->getAddress( "control_mode" );
d->StartedMode = true;
d->Inited = true; d->Inited = true;
} }
@ -123,14 +109,13 @@ bool World::Finish()
bool World::ReadPauseState() bool World::ReadPauseState()
{ {
if(!d->PauseInited) return false; if(!d->PauseInited) return false;
uint8_t pauseState = d->owner->readByte (d->pause_state_offset); return *df::global::pause_state;
return pauseState & 1;
} }
void World::SetPauseState(bool paused) void World::SetPauseState(bool paused)
{ {
if(!d->PauseInited) return; if (d->PauseInited)
d->owner->writeByte (d->pause_state_offset, paused); *df::global::pause_state = paused;
} }
uint32_t World::ReadCurrentYear() uint32_t World::ReadCurrentYear()
@ -147,8 +132,8 @@ bool World::ReadGameMode(t_gamemodes& rd)
{ {
if(d->Inited && d->StartedMode) if(d->Inited && d->StartedMode)
{ {
rd.g_mode = (GameMode) d->owner->readDWord( d->controlmode_offset); rd.g_mode = (DFHack::GameMode)*df::global::control_mode;
rd.g_type = (GameType) d->owner->readDWord(d->gamemode_offset); rd.g_type = (DFHack::GameType)*df::global::game_mode;
return true; return true;
} }
return false; return false;
@ -157,8 +142,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.g_type); *df::global::control_mode = wr.g_mode;
d->owner->writeDWord(d->controlmode_offset,wr.g_mode); *df::global::game_mode = wr.g_type;
return true; return true;
} }
return false; return false;
@ -199,18 +184,14 @@ uint32_t World::ReadCurrentDay()
uint8_t World::ReadCurrentWeather() uint8_t World::ReadCurrentWeather()
{ {
if (d->Inited && d->StartedWeather) if (d->Inited && d->StartedWeather)
return(d->owner->readByte(d->weather_offset + 12)); return (*df::global::current_weather)[2][2];
return 0; return 0;
} }
void World::SetCurrentWeather(uint8_t weather) void World::SetCurrentWeather(uint8_t weather)
{ {
if (d->Inited && d->StartedWeather) if (d->Inited && d->StartedWeather)
{ memset(df::global::current_weather, weather, 25);
uint8_t buf[25];
memset(&buf,weather, sizeof(buf));
d->owner->write(d->weather_offset,sizeof(buf),buf);
}
} }
string World::ReadWorldFolder() string World::ReadWorldFolder()

@ -706,7 +706,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
{ {
static int step_count = 0; static int step_count = 0;
// check run conditions // check run conditions
if(!world->map.block_index || !enable_autolabor) if(!world || !world->map.block_index || !enable_autolabor)
{ {
// give up if we shouldn't be running' // give up if we shouldn't be running'
return CR_OK; return CR_OK;

@ -28,7 +28,7 @@ static int enable_fastdwarf = false;
DFhackCExport command_result plugin_onupdate ( color_ostream &out ) DFhackCExport command_result plugin_onupdate ( color_ostream &out )
{ {
// check run conditions // check run conditions
if(!world->map.block_index || !enable_fastdwarf) if(!world || !world->map.block_index || !enable_fastdwarf)
{ {
// give up if we shouldn't be running' // give up if we shouldn't be running'
return CR_OK; return CR_OK;

@ -100,37 +100,37 @@ command_result df_showmood (color_ostream &out, vector <string> & parameters)
switch (job->job_type) switch (job->job_type)
{ {
case job_type::StrangeMoodCrafter: case job_type::StrangeMoodCrafter:
out.print("become a Craftsdwarf (or Engraver)"); out.print("claim a Craftsdwarf's Workshop");
break; break;
case job_type::StrangeMoodJeweller: case job_type::StrangeMoodJeweller:
out.print("become a Jeweler"); out.print("claim a Jeweler's Workshop");
break; break;
case job_type::StrangeMoodForge: case job_type::StrangeMoodForge:
out.print("become a Metalworker"); out.print("claim a Metalsmith's Forge");
break; break;
case job_type::StrangeMoodMagmaForge: case job_type::StrangeMoodMagmaForge:
out.print("become a Metalworker using a Magma Forge"); out.print("claim a Magma Forge");
break; break;
case job_type::StrangeMoodCarpenter: case job_type::StrangeMoodCarpenter:
out.print("become a Carpenter"); out.print("claim a Carpenter's Workshop");
break; break;
case job_type::StrangeMoodMason: case job_type::StrangeMoodMason:
out.print("become a Mason (or Miner)"); out.print("claim a Mason's Workshop");
break; break;
case job_type::StrangeMoodBowyer: case job_type::StrangeMoodBowyer:
out.print("become a Bowyer"); out.print("claim a Boywer's Workshop");
break; break;
case job_type::StrangeMoodTanner: case job_type::StrangeMoodTanner:
out.print("become a Leatherworker (or Tanner)"); out.print("claim a Leather Works");
break; break;
case job_type::StrangeMoodWeaver: case job_type::StrangeMoodWeaver:
out.print("become a Clothier (or Weaver)"); out.print("claim a Clothier's Shop");
break; break;
case job_type::StrangeMoodGlassmaker: case job_type::StrangeMoodGlassmaker:
out.print("become a Glassmaker"); out.print("claim a Glass Furnace");
break; break;
case job_type::StrangeMoodMechanics: case job_type::StrangeMoodMechanics:
out.print("become a Mechanic"); out.print("claim a Mechanic's Workshop");
break; break;
case job_type::StrangeMoodBrooding: case job_type::StrangeMoodBrooding:
out.print("enter a macabre mood?"); out.print("enter a macabre mood?");
@ -142,20 +142,28 @@ command_result df_showmood (color_ostream &out, vector <string> & parameters)
out.print("do something else..."); out.print("do something else...");
break; break;
} }
out.print(" and become a legendary %s", ENUM_ATTR_STR(job_skill, caption_noun, unit->job.mood_skill));
if (unit->mood == mood_type::Possessed)
out.print(" (but not really)");
break; break;
default: default:
out.print("insane?"); out.print("insane?");
break; break;
} }
out.print(".\n");
if (unit->sex)
out.print("He has ");
else
out.print("She has ");
if (building) if (building)
{ {
string name; string name;
building->getName(&name); building->getName(&name);
out.print(" and has claimed a %s\n", name.c_str()); out.print("claimed a %s and wants", name.c_str());
} }
else else
out.print(" and has not yet claimed a workshop\n"); out.print("not yet claimed a workshop but will want");
out.print(" the following items:\n");
for (size_t i = 0; i < job->job_items.size(); i++) for (size_t i = 0; i < job->job_items.size(); i++)
{ {

@ -5,10 +5,13 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include "modules/World.h" #include "modules/World.h"
#include "DataDefs.h"
#include "df/weather_type.h"
using std::vector; using std::vector;
using std::string; using std::string;
using namespace DFHack; using namespace DFHack;
using namespace df::enums;
bool locked = false; bool locked = false;
unsigned char locked_data[25]; unsigned char locked_data[25];
@ -82,7 +85,7 @@ command_result weather (color_ostream &con, vector <string> & parameters)
CoreSuspender suspend; CoreSuspender suspend;
DFHack::World * w = Core::getInstance().getWorld(); DFHack::World * w = Core::getInstance().getWorld();
if(!w->wmap) if(!df::global::current_weather)
{ {
con << "Weather support seems broken :(" << std::endl; con << "Weather support seems broken :(" << std::endl;
return CR_FAILURE; return CR_FAILURE;
@ -95,19 +98,19 @@ command_result weather (color_ostream &con, vector <string> & parameters)
{ {
for(int x = 0; x<5;x++) for(int x = 0; x<5;x++)
{ {
switch((*w->wmap)[x][y]) switch((*df::global::current_weather)[x][y])
{ {
case CLEAR: case weather_type::None:
con << "C "; con << "C ";
break; break;
case RAINING: case weather_type::Rain:
con << "R "; con << "R ";
break; break;
case SNOWING: case weather_type::Snow:
con << "S "; con << "S ";
break; break;
default: default:
con << (int) (*w->wmap)[x][y] << " "; con << (int) (*df::global::current_weather)[x][y] << " ";
break; break;
} }
} }
@ -120,17 +123,17 @@ command_result weather (color_ostream &con, vector <string> & parameters)
if(rain) if(rain)
{ {
con << "Here comes the rain." << std::endl; con << "Here comes the rain." << std::endl;
w->SetCurrentWeather(RAINING); w->SetCurrentWeather(weather_type::Rain);
} }
if(snow) if(snow)
{ {
con << "Snow everywhere!" << std::endl; con << "Snow everywhere!" << std::endl;
w->SetCurrentWeather(SNOWING); w->SetCurrentWeather(weather_type::Snow);
} }
if(clear) if(clear)
{ {
con << "Suddenly, sunny weather!" << std::endl; con << "Suddenly, sunny weather!" << std::endl;
w->SetCurrentWeather(CLEAR); w->SetCurrentWeather(weather_type::None);
} }
if(val_override != -1) if(val_override != -1)
{ {