I don’t see how github makes anything trivial. If the code is in separate branch than any recent change relating to the same code as my changes can cause incompatibility, or worse, it could be a source of sneaky non-obvious bugs. It needs to be done by hand if you want to be certain it still fits with the most recent official build at the time of the merge. Anyway, if you already have room to put this in some side-branch in the meantime then go ahead and do that.
SOURCE:
There is “//CAT:” comment before any change.
Obviously, you are correct about the windows bit - those of us not on windows wouldn't be able to test out the windows-specific components, but most of what you described isn't just windows specific, and we would at least be able to see if the code looked good, and limit the amount of review the windows folks with their limited numbers and time would have to devote to going over it.
At the very least you should post a diff.
The most important change is about Windows proper rendering, speed up and working animations. Although I think Linux version runs smoother and faster too, faster than Windows certainly. The reset are just some minor bug fixes and there is also this automatic distance viewing feature for driving.
BUG FIXES:
- optimised rendering, significant speed increase and much smoother game-play
- animations now working on Windows, sleeping and waiting “fast forward”, as seen on Linux
The main problem was in catacurse.cpp, in getch() function. InvalidateRect() does not belong there, so I moved it to DrawWindow() and added call to UpdateWindow(), like this:
void DrawWindow(WINDOW *win)
{
.
.
win->draw=false; //We drew the window, mark it as so
//CAT:
InvalidateRect(WindowHandle,NULL,true);
UpdateWindow(WindowHandle);
}
I also removed all the unnecessary stuff from getch() function, so it boils down to this:
[code]int getch(void)
{
//CAT:
refresh();
lastchar=ERR;
do{
CheckMessages();
}while (lastchar==ERR);
return lastchar;
};
[/code]
That will give you working animation on Windows, only then you will see a lot of flickering, so the second part of this fix mostly involves commenting out redundant calls to wrefresh(), refresh(), refresh_all(), and such, in game.cpp, and moving some of them around or elsewhere. That would fix the flickering and speeds up rendering quite a bit. And that’s it. Actually I also disabled calls to nanosleep(). There is no need to slow down what is already slow and needs to be faster, it only makes for choppy scrolling. These changes will also fix more recent bug where there is no message shown on top of the screen asking which direction you want to examine, and some other action related questions like that are missing.
BUG FIXES:
- flashlight to draw “gradual fade off” properly all around instead if only on one side
Basically commenting this part out in map.cpp, map::draw() function will fill the bug:
//CAT:
/*
// Don't display area as shadowy if it's outside and illuminated by natural light
else if (dist <= g->u.sight_range(g->natural_light_level()))
{
lowlight_sight_range = std::max(g_light_level, natural_sight_range);
}
*/
I see someone just very recently also tried to address this issue, but their result does not have dark shade area. Is that what what you call “gradual_night_light”? What is it supposed to be difference with that option ON and OFF, can you show me on a screenshoot? In any case, I also reduced that dark shade rim to be one pixel wide instead of half of the total light range, because it grays out yellow lines on the road so it often looks as if the road ends when it does not. And those yellow lines should be visible even further and more than light range, certainly not less visible than the pavement itself.
NEW FEATURE:
- automatic “distance view” when driving, shifts view forward in front of the vehicle (depending on current speed and bearing), so you can see more road in the direction car is facing
In game.cpp add this few lines at the end of game::pldrive() function:
//CAT:
float cat_vel= veh->velocity*1.5;
if(cat_vel > 10000) cat_vel= 10000;
float cat_sin = sin(veh->turn_dir*M_PI/180)* cat_vel;
float cat_cos = cos(veh->turn_dir*M_PI/180)* cat_vel;
u.view_offset_y= (int)cat_sin/1000;
u.view_offset_x= (int)cat_cos/1000;
In map.cpp, map::unboard_vehicle() function add these lines to center the screen in case player bailed from a moving vehicle:
//CAT:
g->u.view_offset_y= 0;
g->u.view_offset_x= 0;
And to increase headlights range, change this line in lightmap.cpp, light_map::generate() function:
//CAT: longer range headlights
// float luminance = c[sx - x + LIGHTMAP_RANGE_X][sy - y + LIGHTMAP_RANGE_Y].veh_light;
float luminance = 250+ c[sx - x + LIGHTMAP_RANGE_X][sy - y + LIGHTMAP_RANGE_Y].veh_light;
That’s about it.