Index: src/engine/tools.cpp =================================================================== --- src/engine/tools.cpp (revision 2761) +++ src/engine/tools.cpp (working copy) @@ -761,7 +761,7 @@ if(stat(name.c_str(), &fs) || !S_ISREG(fs.st_mode)) return false; - return writable ? 0 == access(name.c_str(), W_OK) : S_IRUSR & fs.st_mode; + return writable ? 0 == access(name.c_str(), W_OK) : true; } bool IsDirectory(const std::string & name, bool writable) Index: src/engine/sdlnet.cpp =================================================================== --- src/engine/sdlnet.cpp (revision 2761) +++ src/engine/sdlnet.cpp (working copy) @@ -137,7 +137,7 @@ { if(data + dtsz < itd2 + 1) Resize(1); - *itd2 = byte8; + *(u8 *)itd2 = byte8; ++itd2; } @@ -150,10 +150,10 @@ { if(data + dtsz < itd2 + 2) Resize(2); - *itd2 = 0x00FF & (byte16 >> 8); + *(u8 *)itd2 = 0x00FF & (byte16 >> 8); ++itd2; - *itd2 = 0x00FF & byte16; + *(u8 *)itd2 = 0x00FF & byte16; ++itd2; } @@ -166,16 +166,16 @@ { if(data + dtsz < itd2 + 4) Resize(4); - *itd2 = 0x000000FF & (byte32 >> 24); + *(u8 *)itd2 = 0x000000FF & (byte32 >> 24); ++itd2; - *itd2 = 0x000000FF & (byte32 >> 16); + *(u8 *)itd2 = 0x000000FF & (byte32 >> 16); ++itd2; - *itd2 = 0x000000FF & (byte32 >> 8); + *(u8 *)itd2 = 0x000000FF & (byte32 >> 8); ++itd2; - *itd2 = 0x000000FF & byte32; + *(u8 *)itd2 = 0x000000FF & byte32; ++itd2; } @@ -270,7 +270,7 @@ { if(itd1 + 1 > itd2) return false; - byte8 = *itd1; + byte8 = *(u8 *)itd1; ++itd1; return true; @@ -291,11 +291,11 @@ { if(itd1 + 2 > itd2) return false; - byte16 = *itd1; + byte16 = *(u8 *)itd1; byte16 <<= 8; ++itd1; - byte16 |= (0x00FF & *itd1); + byte16 |= (0x00FF & *(u8 *)itd1); ++itd1; return true; @@ -316,19 +316,19 @@ { if(itd1 + 4 > itd2) return false; - byte32 = *itd1; + byte32 = *(u8 *)itd1; byte32 <<= 8; ++itd1; - byte32 |= (0x000000FF & *itd1); + byte32 |= (0x000000FF & *(u8 *)itd1); byte32 <<= 8; ++itd1; - byte32 |= (0x000000FF & *itd1); + byte32 |= (0x000000FF & *(u8 *)itd1); byte32 <<= 8; ++itd1; - byte32 |= (0x000000FF & *itd1); + byte32 |= (0x000000FF & *(u8 *)itd1); ++itd1; return true; Index: src/fheroes2/system/settings.h =================================================================== --- src/fheroes2/system/settings.h (revision 2761) +++ src/fheroes2/system/settings.h (working copy) @@ -117,9 +117,10 @@ #elif defined(ANDROID) namespace std { - #define endl "\n" + static const char * android_endl = "\n"; } - #define VERBOSE(x) { std::ostringstream osss; osss << x; __android_log_print(ANDROID_LOG_INFO, "FHeroes", "%s", osss.str().c_str()); } + #define endl android_endl + #define VERBOSE(x) if(true) { std::ostringstream osss; osss << x; __android_log_print(ANDROID_LOG_INFO, "FHeroes", "%s", osss.str().c_str()); } else String::GetTime() #else #define VERBOSE(x) std::cout << x << std::endl #endif Index: src/fheroes2/kingdom/world.cpp =================================================================== --- src/fheroes2/kingdom/world.cpp (revision 2761) +++ src/fheroes2/kingdom/world.cpp (working copy) @@ -1028,12 +1028,22 @@ Heroes* World::GetHeroes(Heroes::heroes_t id) { - return vec_heroes.Get(id); + //VERBOSE("World::GetHeroes: id " << id << " vec_heroes.size() " << vec_heroes.size()); + if(id >= vec_heroes.size()) + return NULL; + Heroes* h = vec_heroes.Get(id); + //VERBOSE("World::GetHeroes: id " << id << " hero " << h->GetID() << " name " << h->GetName()); + return h; } const Heroes* World::GetHeroes(Heroes::heroes_t id) const { - return vec_heroes.Get(id); + //VERBOSE("World::GetHeroes: id " << id << " vec_heroes.size() " << vec_heroes.size()); + if(id >= vec_heroes.size()) + return NULL; + const Heroes* h = vec_heroes.Get(id); + //VERBOSE("World::GetHeroes: id " << id << " hero " << h->GetID() << " name " << h->GetName()); + return h; } /* get heroes from index maps */ Index: src/fheroes2/network/server.cpp =================================================================== --- src/fheroes2/network/server.cpp (revision 2761) +++ src/fheroes2/network/server.cpp (working copy) @@ -876,7 +876,7 @@ int FH2Server::RunServerProcess(void*) { - const std::string command = Settings::GetProgramPath(); + const std::string command = Settings::Get().GetProgramPath(); std::ostringstream os; os << command << " -s" << ">" << GetDirname(command) << SEPARATOR << "fh2server.log"; return system(os.str().c_str()); @@ -899,7 +899,7 @@ // clear background cursor.Hide(); - display.Blit(AGG::GetICN(ICN::HEROES, 0)); + AGG::GetICN(ICN::HEROES, 0).Blit(display); //display.Blit(AGG::GetICN(ICN::HEROES, 0)); // I think that's the expected logic cursor.Show(); display.Flip(); } Index: src/fheroes2/network/localclient.cpp =================================================================== --- src/fheroes2/network/localclient.cpp (revision 2761) +++ src/fheroes2/network/localclient.cpp (working copy) @@ -490,7 +490,7 @@ { MapsFileInfoList lists; Network::PacketPopMapsFileInfoList(packet, lists); - if(Maps::FileInfo *fi = Dialog::SelectScenario(lists)) + if(const Maps::FileInfo *fi = Dialog::SelectScenario(lists)) { // send set_maps_info packet.Reset(); @@ -626,7 +626,7 @@ // clear background const Sprite &back = AGG::GetICN(ICN::HEROES, 0); cursor.Hide(); - display.Blit(back); + back.Blit(display); //display.Blit(back); // I think that's the expected logic cursor.Show(); display.Flip(); Index: src/fheroes2/network/network.cpp =================================================================== --- src/fheroes2/network/network.cpp (revision 2761) +++ src/fheroes2/network/network.cpp (working copy) @@ -159,7 +159,9 @@ Network::SetProtocolVersion(static_cast(MAJOR_VERSION << 8) | MINOR_VERSION); if(SDL::Init(INIT_TIMER)) +#ifndef ANDROID try +#endif { std::atexit(SDL::Quit); @@ -177,6 +179,7 @@ return FH2Server::Main(NULL); } +#ifndef ANDROID catch(std::bad_alloc) { } @@ -184,7 +187,7 @@ { VERBOSE(conf.String()); } - +#endif return 0; }