mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
parent
9f6270a1f7
commit
d6223dd137
@ -697,10 +697,9 @@ static void listenForEvents()
|
||||
}
|
||||
else if(ev->type == SDL_USEREVENT)
|
||||
{
|
||||
enum {CHANGE_SCREEN_RESOLUTION, RETURN_TO_MAIN_MENU, END_GAME_AND_DIE};
|
||||
switch(ev->user.code)
|
||||
{
|
||||
case 1:
|
||||
case CHANGE_SCREEN_RESOLUTION:
|
||||
{
|
||||
tlog0 << "Changing resolution has been requested\n";
|
||||
const JsonNode& video = settings["video"];
|
||||
@ -708,7 +707,7 @@ static void listenForEvents()
|
||||
setScreenRes(res["width"].Float(), res["height"].Float(), video["bitsPerPixel"].Float(), video["fullscreen"].Bool());
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
case RETURN_TO_MAIN_MENU:
|
||||
client->endGame();
|
||||
delete client;
|
||||
client = NULL;
|
||||
@ -721,12 +720,12 @@ static void listenForEvents()
|
||||
GH.curInt = CGP;
|
||||
GH.defActionsDef = 63;
|
||||
break;
|
||||
case STOP_CLIENT:
|
||||
client->endGame(false);
|
||||
break;
|
||||
default:
|
||||
tlog1 << "Error: unknown user event. Code " << ev->user.code << std::endl;
|
||||
assert(0);
|
||||
// case 3:
|
||||
// client->endGame(false);
|
||||
// break;
|
||||
}
|
||||
|
||||
delete ev;
|
||||
@ -795,6 +794,6 @@ void requestChangingResolution()
|
||||
//push special event to order event reading thread to change resolution
|
||||
SDL_Event ev;
|
||||
ev.type = SDL_USEREVENT;
|
||||
ev.user.code = 1;
|
||||
ev.user.code = CHANGE_SCREEN_RESOLUTION;
|
||||
SDL_PushEvent(&ev);
|
||||
}
|
||||
|
@ -2265,12 +2265,12 @@ void CPlayerInterface::showShipyardDialogOrProblemPopup(const IShipyard *obj)
|
||||
|
||||
void CPlayerInterface::requestReturningToMainMenu()
|
||||
{
|
||||
sendCustomEvent(2);
|
||||
sendCustomEvent(RETURN_TO_MAIN_MENU);
|
||||
}
|
||||
|
||||
void CPlayerInterface::requestStoppingClient()
|
||||
{
|
||||
sendCustomEvent(3);
|
||||
sendCustomEvent(STOP_CLIENT);
|
||||
}
|
||||
|
||||
void CPlayerInterface::sendCustomEvent( int code )
|
||||
|
@ -71,6 +71,8 @@ namespace boost
|
||||
class recursive_mutex;
|
||||
};
|
||||
|
||||
enum {CHANGE_SCREEN_RESOLUTION = 1, RETURN_TO_MAIN_MENU = 2, STOP_CLIENT = 3};
|
||||
|
||||
/// Central class for managing user interface logic
|
||||
class CPlayerInterface : public CGameInterface, public IUpdateable
|
||||
{
|
||||
|
@ -808,7 +808,11 @@ CGameState::~CGameState()
|
||||
|
||||
BattleInfo * CGameState::setupBattle(int3 tile, const CArmedInstance *armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance *town)
|
||||
{
|
||||
int terrain = map->getTile(tile).tertype;
|
||||
const TerrainTile &t = map->getTile(tile);
|
||||
int terrain = t.tertype;
|
||||
if(t.isCoastal() && !t.isWater())
|
||||
terrain = TerrainTile::sand;
|
||||
|
||||
int terType = battleGetBattlefieldType(tile);
|
||||
return BattleInfo::setupBattle(tile, terrain, terType, armies, heroes, creatureBank, town);
|
||||
}
|
||||
@ -1623,6 +1627,9 @@ int CGameState::battleGetBattlefieldType(int3 tile)
|
||||
}
|
||||
}
|
||||
|
||||
if(!t.isWater() && t.isCoastal())
|
||||
return 1; //sand/beach
|
||||
|
||||
switch(t.tertype)
|
||||
{
|
||||
case TerrainTile::dirt:
|
||||
|
Loading…
Reference in New Issue
Block a user