checked in bug for isaac to test (current code will crash)
This commit is contained in:
parent
d7e09e5a40
commit
fbca080233
5 changed files with 62 additions and 9 deletions
|
@ -322,9 +322,9 @@ bool ai::do_combat(std::map<gamemap::location,paths>& possible_moves, const move
|
|||
std::cout << "analysis took " << time_taken << " ticks\n";
|
||||
|
||||
if(choice_rating > 0.0) {
|
||||
const location& from = choice_it->movements[0].first;
|
||||
const location& to = choice_it->movements[0].second;
|
||||
const location& target_loc = choice_it->target;
|
||||
location from = choice_it->movements[0].first;
|
||||
location to = choice_it->movements[0].second;
|
||||
location target_loc = choice_it->target;
|
||||
const int weapon = choice_it->weapons[0];
|
||||
|
||||
const unit_map::const_iterator tgt = units_.find(target_loc);
|
||||
|
|
|
@ -57,7 +57,8 @@ display::display(unit_map& units, CVideo& video, const gamemap& map,
|
|||
teams_(t), lastDraw_(0), drawSkips_(0),
|
||||
invalidateAll_(true), invalidateUnit_(true),
|
||||
invalidateGameStatus_(true), panelsDrawn_(false),
|
||||
currentTeam_(0), activeTeam_(0), hideEnergy_(false), updatesLocked_(0),
|
||||
currentTeam_(0), activeTeam_(0), hideEnergy_(false),
|
||||
deadAmount_(0.0), advancingAmount_(0.0), updatesLocked_(0),
|
||||
turbo_(false), grid_(false), sidebarScaling_(1.0),
|
||||
theme_(theme_cfg,screen_area())
|
||||
{
|
||||
|
@ -456,6 +457,7 @@ void draw_label(display& disp, SDL_Surface* target, const theme::label& label)
|
|||
|
||||
void display::draw(bool update,bool force)
|
||||
{
|
||||
image::verify_minimap("begin display::draw");
|
||||
log_scope("display::draw");
|
||||
if(!panelsDrawn_ && !teams_.empty()) {
|
||||
SDL_Surface* const screen = screen_.getSurface();
|
||||
|
@ -534,6 +536,7 @@ void display::draw(bool update,bool force)
|
|||
}
|
||||
|
||||
std::cerr << "ret\n";
|
||||
image::verify_minimap("end display::draw");
|
||||
}
|
||||
|
||||
void display::update_display()
|
||||
|
|
|
@ -227,6 +227,8 @@ SDL_Surface* getMinimap(int w, int h, const gamemap& map,
|
|||
int lawful_bonus,
|
||||
const team* tm, const unit_map* units, const std::vector<team>* teams)
|
||||
{
|
||||
verify_minimap("start getMinimap");
|
||||
|
||||
SDL_Surface* minimap = NULL;
|
||||
if(minimap == NULL) {
|
||||
std::cerr << "x\n";
|
||||
|
@ -243,8 +245,8 @@ SDL_Surface* getMinimap(int w, int h, const gamemap& map,
|
|||
return NULL;
|
||||
|
||||
typedef mini_terrain_cache_map cache_map;
|
||||
//cache_map& cache = mini_terrain_cache;
|
||||
static cache_map cache;
|
||||
cache_map& cache = mini_terrain_cache;
|
||||
//static cache_map cache;
|
||||
|
||||
std::cerr << "outputting map: " << map.x() << "," << map.y() << "\n";
|
||||
for(int y = 0; y != map.y(); ++y) {
|
||||
|
@ -283,6 +285,7 @@ SDL_Surface* getMinimap(int w, int h, const gamemap& map,
|
|||
}
|
||||
|
||||
i = cache.insert(cache_map::value_type(terrain,surf)).first;
|
||||
verify_minimap("after insert");
|
||||
} else {
|
||||
std::cerr << "e\n";
|
||||
surf = i->second;
|
||||
|
@ -291,6 +294,11 @@ SDL_Surface* getMinimap(int w, int h, const gamemap& map,
|
|||
if(fogged) {
|
||||
std::cerr << "f\n";
|
||||
scoped_surface.assign(adjust_surface_colour(surf,-50,-50,-50));
|
||||
if(scoped_surface == NULL) {
|
||||
std::cerr << "ERROR: failed to adjust surface colour\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
surf = scoped_surface;
|
||||
}
|
||||
|
||||
|
@ -308,6 +316,8 @@ SDL_Surface* getMinimap(int w, int h, const gamemap& map,
|
|||
}
|
||||
}
|
||||
|
||||
verify_minimap("a end getMinimap");
|
||||
|
||||
std::cerr << "k\n";
|
||||
|
||||
if(minimap->w != w || minimap->h != h) {
|
||||
|
@ -321,8 +331,21 @@ SDL_Surface* getMinimap(int w, int h, const gamemap& map,
|
|||
}
|
||||
std::cerr << "xxx\n";
|
||||
|
||||
verify_minimap("end getMinimap");
|
||||
|
||||
return minimap;
|
||||
}
|
||||
|
||||
void verify_minimap(const std::string& tag)
|
||||
{
|
||||
std::cerr << "BEGIN verify minimap: '" << tag << "'\n";
|
||||
typedef mini_terrain_cache_map cache_map;
|
||||
cache_map& cache = mini_terrain_cache;
|
||||
for(cache_map::iterator i = cache.begin(); i != cache.end(); ++i) {
|
||||
SDL_Surface* const surf = adjust_surface_colour(i->second,-50,-50,-50);
|
||||
SDL_FreeSurface(surf);
|
||||
}
|
||||
std::cerr << "END verify minimap: '" << tag << "'\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,6 +67,8 @@ namespace image {
|
|||
//the surface returned must be freed by the user
|
||||
SDL_Surface* getMinimap(int w, int h, const gamemap& map_, int lawful_bonus,
|
||||
const team* tm=NULL, const unit_map* units=NULL, const std::vector<team>* teams=NULL);
|
||||
|
||||
void verify_minimap(const std::string& tag);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace {
|
|||
first_time = false;
|
||||
scoped_sdl_surface surf(SDL_CreateRGBSurface(SDL_SWSURFACE,1,1,32,0xFF0000,0xFF00,0xFF,0xFF000000));
|
||||
format = *surf->format;
|
||||
format.palette = NULL;
|
||||
}
|
||||
|
||||
return format;
|
||||
|
@ -46,7 +47,10 @@ SDL_Surface* make_neutral_surface(SDL_Surface* surf)
|
|||
}
|
||||
|
||||
SDL_Surface* const result = SDL_ConvertSurface(surf,&get_neutral_pixel_format(),SDL_SWSURFACE);
|
||||
SDL_SetAlpha(result,SDL_SRCALPHA,SDL_ALPHA_OPAQUE);
|
||||
if(result != NULL) {
|
||||
SDL_SetAlpha(result,SDL_SRCALPHA,SDL_ALPHA_OPAQUE);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -111,7 +115,14 @@ SDL_Surface* clone_surface(SDL_Surface* surface)
|
|||
return NULL;
|
||||
|
||||
SDL_Surface* const result = SDL_DisplayFormatAlpha(surface);
|
||||
SDL_SetAlpha(result,SDL_SRCALPHA|SDL_RLEACCEL,SDL_ALPHA_OPAQUE);
|
||||
if(result == surface) {
|
||||
std::cerr << "resulting surface is the same as the source!!!\n";
|
||||
}
|
||||
|
||||
if(result != NULL) {
|
||||
SDL_SetAlpha(result,SDL_SRCALPHA|SDL_RLEACCEL,SDL_ALPHA_OPAQUE);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -246,6 +257,11 @@ SDL_Surface* adjust_surface_colour(SDL_Surface* surface, int r, int g, int b)
|
|||
scoped_sdl_surface surf(make_neutral_surface(surface));
|
||||
std::cerr << "~+\n";
|
||||
|
||||
if(surf == NULL) {
|
||||
std::cerr << "failed to make neutral surface\n";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
{
|
||||
surface_lock lock(surf);
|
||||
Uint32* beg = lock.pixels();
|
||||
|
@ -274,6 +290,10 @@ SDL_Surface* greyscale_image(SDL_Surface* surface)
|
|||
return NULL;
|
||||
|
||||
scoped_sdl_surface surf(make_neutral_surface(surface));
|
||||
if(surf == NULL) {
|
||||
std::cerr << "failed to make neutral surface\n";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
{
|
||||
surface_lock lock(surf);
|
||||
|
@ -510,13 +530,18 @@ private:
|
|||
|
||||
SDL_Rect get_non_transperant_portion(SDL_Surface* surface)
|
||||
{
|
||||
SDL_Rect res = {0,0,0,0};
|
||||
const scoped_sdl_surface surf(make_neutral_surface(surface));
|
||||
if(surf == NULL) {
|
||||
std::cerr << "failed to make neutral surface\n";
|
||||
return res;
|
||||
}
|
||||
|
||||
const not_alpha calc(*(surf->format));
|
||||
|
||||
surface_lock lock(surf);
|
||||
const Uint32* const pixels = lock.pixels();
|
||||
|
||||
SDL_Rect res = {0,0,0,0};
|
||||
size_t n;
|
||||
for(n = 0; n != surf->h; ++n) {
|
||||
const Uint32* const start_row = pixels + n*surf->w;
|
||||
|
|
Loading…
Add table
Reference in a new issue