Bug fixes, perf improvement, don't load until there is a world. (breaks arena mode)

develop
Warmist 2013-07-03 10:44:23 +03:00
parent c2db761a1b
commit a3d3c34671
4 changed files with 46 additions and 18 deletions

@ -53,6 +53,8 @@ DFHack v0.34.11-r4
- outsideOnly: make raw-specified buildings impossible to build inside
- resume: A plugin to help display and resume suspended constructions conveniently
- stocks: An improved stocks display screen.
- rendermax: a heap of rendering experiments. Including one that does lighting.
Internals:
- Core: there is now a per-save dfhack.init file for when the save is loaded, and another for when it is unloaded
- EventManager: fixed job completion detection, fixed removal of TICK events, added EQUIPMENT_CHANGE event

@ -105,7 +105,6 @@ lightingEngineViewscreen::lightingEngineViewscreen(renderer_light* target):light
{
reinit();
defaultSettings();
loadSettings();
int numTreads=tthread::thread::hardware_concurrency();
if(numTreads==0)numTreads=1;
threading.start(numTreads);
@ -240,6 +239,11 @@ void lightingEngineViewscreen::clear()
}
void lightingEngineViewscreen::calculate()
{
if(lightMap.size()!=myRenderer->lightGrid.size())
{
reinit();
myRenderer->invalidate();
}
rect2d vp=getMapViewport();
const rgbf dim(levelDim,levelDim,levelDim);
lightMap.assign(lightMap.size(),rgbf(1,1,1));
@ -1035,8 +1039,7 @@ lightThread::lightThread( lightThreadDispatch& dispatch ):dispatch(dispatch),isD
}
lightThread::~lightThread()
{
if(myThread)
delete myThread;
delete myThread;
}
void lightThread::run()

@ -67,7 +67,7 @@ private:
void reinitLightGrid(int w,int h)
{
tthread::lock_guard<tthread::fast_mutex> guard(dataMutex);
lightGrid.resize(w*h);
lightGrid.resize(w*h,rgbf(1,1,1));
}
void reinitLightGrid()
{

@ -279,7 +279,41 @@ DFHACK_PLUGIN_LUA_COMMANDS {
DFHACK_LUA_END
};
static void enable_hooks(bool enable)
{
INTERPOSE_HOOK(dwarmode_render_hook,render).apply(enable);
INTERPOSE_HOOK(dungeon_render_hook,render).apply(enable);
if(enable && engine)
{
engine->loadSettings();
}
}
DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event)
{
switch(event)
{
case SC_VIEWSCREEN_CHANGED:
{
CoreSuspendClaimer suspender;
if(current_mode==MODE_LIGHT)
{
engine->clear();
}
}
break;
case SC_WORLD_LOADED:
enable_hooks(true);
break;
case SC_WORLD_UNLOADED:
enable_hooks(false);
break;
default:
break;
}
return CR_OK;
}
static command_result rendermax(color_ostream &out, vector <string> & parameters)
@ -361,8 +395,9 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
renderer_light *myRender=new renderer_light(df::global::enabler->renderer);
installNew(myRender,MODE_LIGHT);
engine=new lightingEngineViewscreen(myRender);
INTERPOSE_HOOK(dwarmode_render_hook,render).apply(true);
INTERPOSE_HOOK(dungeon_render_hook,render).apply(true);
if (Core::getInstance().isWorldLoaded())
plugin_onstatechange(out, SC_WORLD_LOADED);
}
else if(current_mode==MODE_LIGHT && parameters.size()>1)
{
@ -417,15 +452,3 @@ DFhackCExport command_result plugin_shutdown(color_ostream &)
removeOld();
return CR_OK;
}
DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event)
{
if(event==SC_VIEWSCREEN_CHANGED)
{
CoreSuspendClaimer suspender;
if(current_mode==MODE_LIGHT)
{
engine->clear();
}
}
return CR_OK;
}