2007-06-06 19:12:12 +03:00
# include "stdafx.h"
# include "mapHandler.h"
# include "SDL_rotozoom.h"
2007-06-07 04:46:25 +03:00
# include "SDL_Extensions.h"
2007-06-22 19:36:05 +03:00
# include "CGameInfo.h"
2007-06-25 17:55:45 +03:00
# include "stdlib.h"
2007-08-30 13:11:53 +03:00
# include "hch\CLodHandler.h"
# include "hch\CDefObjInfoHandler.h"
2007-07-02 22:44:30 +03:00
# include <algorithm>
2007-10-27 23:14:25 +03:00
# include "CGameState.h"
2007-11-03 18:46:08 +02:00
# include "CLua.h"
2007-11-24 20:54:34 +02:00
# include "hch\CHeroHandler.h"
2007-12-14 20:49:41 +02:00
# include "hch\CTownHandler.h"
2008-06-08 03:58:29 +03:00
# include "hch\CArtHandler.h"
2008-06-13 11:16:51 +03:00
# include "client\Graphics.h"
2007-11-24 20:54:34 +02:00
# include <iomanip>
# include <sstream>
2008-04-25 12:25:59 +03:00
extern SDL_Surface * screen ;
2008-06-07 20:16:52 +03:00
std : : string nameFromType ( EterrainType typ )
{
switch ( typ )
{
case dirt :
{
return std : : string ( " DIRTTL.DEF " ) ;
break ;
}
case sand :
{
return std : : string ( " SANDTL.DEF " ) ;
break ;
}
case grass :
{
return std : : string ( " GRASTL.DEF " ) ;
break ;
}
case snow :
{
return std : : string ( " SNOWTL.DEF " ) ;
break ;
}
case swamp :
{
return std : : string ( " SWMPTL.DEF " ) ;
break ;
}
case rough :
{
return std : : string ( " ROUGTL.DEF " ) ;
break ;
}
case subterranean :
{
return std : : string ( " SUBBTL.DEF " ) ;
break ;
}
case lava :
{
return std : : string ( " LAVATL.DEF " ) ;
break ;
}
case water :
{
return std : : string ( " WATRTL.DEF " ) ;
break ;
}
case rock :
{
return std : : string ( " ROCKTL.DEF " ) ;
break ;
}
}
return std : : string ( ) ;
}
2007-08-09 19:28:01 +03:00
class OCM_HLP
2007-07-02 22:44:30 +03:00
{
public :
2008-02-10 19:44:51 +02:00
bool operator ( ) ( const std : : pair < CGObjectInstance * , SDL_Rect > & a , const std : : pair < CGObjectInstance * , SDL_Rect > & b )
2007-07-02 22:44:30 +03:00
{
2007-08-09 19:28:01 +03:00
return ( * a . first ) < ( * b . first ) ;
}
} ocmptwo ;
2008-02-05 05:56:45 +02:00
void alphaTransformDef ( CGDefInfo * defInfo )
{
SDL_Surface * alphaTransSurf = SDL_CreateRGBSurface ( SDL_SWSURFACE , 12 , 12 , 32 , 0x000000ff , 0x0000ff00 , 0x00ff0000 , 0xff000000 ) ;
for ( int yy = 0 ; yy < defInfo - > handler - > ourImages . size ( ) ; yy + + )
{
defInfo - > handler - > ourImages [ yy ] . bitmap = CSDL_Ext : : alphaTransform ( defInfo - > handler - > ourImages [ yy ] . bitmap ) ;
2008-02-10 19:44:51 +02:00
//SDL_Surface * bufs = CSDL_Ext::secondAlphaTransform(defInfo->handler->ourImages[yy].bitmap, alphaTransSurf);
//SDL_FreeSurface(defInfo->handler->ourImages[yy].bitmap);
//defInfo->handler->ourImages[yy].bitmap = bufs;
2008-02-05 05:56:45 +02:00
defInfo - > handler - > alphaTransformed = true ;
}
SDL_FreeSurface ( alphaTransSurf ) ;
}
2008-02-10 11:35:52 +02:00
int CMapHandler : : pickHero ( int owner )
{
2008-02-10 14:57:56 +02:00
int h ;
if ( usedHeroes . find ( h = CGI - > scenarioOps . getIthPlayersSettings ( owner ) . hero ) = = usedHeroes . end ( ) & & h > = 0 ) //we haven't used selected hero
2008-02-10 11:35:52 +02:00
{
usedHeroes . insert ( h ) ;
return h ;
}
int f = CGI - > scenarioOps . getIthPlayersSettings ( owner ) . castle ;
2008-02-10 14:57:56 +02:00
int i = 0 ;
2008-02-10 11:35:52 +02:00
do //try to find free hero of our faction
{
i + + ;
h = CGI - > scenarioOps . getIthPlayersSettings ( owner ) . castle * HEROES_PER_TYPE * 2 + ( rand ( ) % ( HEROES_PER_TYPE * 2 ) ) ; //cgi->scenarioOps.playerInfos[pru].hero = cgi->
} while ( ( usedHeroes . find ( h ) ! = usedHeroes . end ( ) ) & & i < 175 ) ;
if ( i > 174 ) //probably no free heroes - there's no point in further search, we'll take first free
{
for ( int j = 0 ; j < HEROES_PER_TYPE * 2 * F_NUMBER ; j + + )
if ( usedHeroes . find ( j ) = = usedHeroes . end ( ) )
h = j ;
}
usedHeroes . insert ( h ) ;
return h ;
}
2008-02-05 05:56:45 +02:00
std : : pair < int , int > CMapHandler : : pickObject ( CGObjectInstance * obj )
2007-06-06 19:12:12 +03:00
{
2008-02-05 05:56:45 +02:00
switch ( obj - > ID )
{
case 65 : //random artifact
return std : : pair < int , int > ( 5 , ( rand ( ) % 136 ) + 7 ) ; //tylko sensowny zakres - na poczatku sa katapulty itp, na koncu specjalne i blanki
case 66 : //random treasure artifact
return std : : pair < int , int > ( 5 , CGI - > arth - > treasures [ rand ( ) % CGI - > arth - > treasures . size ( ) ] - > id ) ;
case 67 : //random minor artifact
return std : : pair < int , int > ( 5 , CGI - > arth - > minors [ rand ( ) % CGI - > arth - > minors . size ( ) ] - > id ) ;
case 68 : //random major artifact
return std : : pair < int , int > ( 5 , CGI - > arth - > majors [ rand ( ) % CGI - > arth - > majors . size ( ) ] - > id ) ;
case 69 : //random relic artifact
return std : : pair < int , int > ( 5 , CGI - > arth - > relics [ rand ( ) % CGI - > arth - > relics . size ( ) ] - > id ) ;
case 70 : //random hero
2008-02-10 11:35:52 +02:00
{
return std : : pair < int , int > ( 34 , pickHero ( obj - > tempOwner ) ) ;
}
2008-02-05 05:56:45 +02:00
case 71 : //random monster
return std : : pair < int , int > ( 54 , rand ( ) % ( CGI - > creh - > creatures . size ( ) ) ) ;
case 72 : //random monster lvl1
return std : : pair < int , int > ( 54 , CGI - > creh - > levelCreatures [ 1 ] [ rand ( ) % CGI - > creh - > levelCreatures [ 1 ] . size ( ) ] - > idNumber ) ;
case 73 : //random monster lvl2
return std : : pair < int , int > ( 54 , CGI - > creh - > levelCreatures [ 2 ] [ rand ( ) % CGI - > creh - > levelCreatures [ 2 ] . size ( ) ] - > idNumber ) ;
case 74 : //random monster lvl3
return std : : pair < int , int > ( 54 , CGI - > creh - > levelCreatures [ 3 ] [ rand ( ) % CGI - > creh - > levelCreatures [ 3 ] . size ( ) ] - > idNumber ) ;
case 75 : //random monster lvl4
return std : : pair < int , int > ( 54 , CGI - > creh - > levelCreatures [ 4 ] [ rand ( ) % CGI - > creh - > levelCreatures [ 4 ] . size ( ) ] - > idNumber ) ;
case 76 : //random resource
return std : : pair < int , int > ( 79 , rand ( ) % 7 ) ; //now it's OH3 style, use %8 for mithril
case 77 : //random town
2008-02-10 11:35:52 +02:00
{
2008-06-08 03:58:29 +03:00
int align = ( ( CGTownInstance * ) obj ) - > alignment ,
2008-02-10 11:35:52 +02:00
f ;
if ( align > PLAYER_LIMIT - 1 ) //same as owner / random
{
if ( obj - > tempOwner > PLAYER_LIMIT - 1 )
f = - 1 ; //random
else
f = CGI - > scenarioOps . getIthPlayersSettings ( obj - > tempOwner ) . castle ;
}
else
{
f = CGI - > scenarioOps . getIthPlayersSettings ( align ) . castle ;
}
if ( f < 0 ) f = rand ( ) % CGI - > townh - > towns . size ( ) ;
return std : : pair < int , int > ( 98 , f ) ;
}
2008-02-05 05:56:45 +02:00
case 162 : //random monster lvl5
return std : : pair < int , int > ( 54 , CGI - > creh - > levelCreatures [ 5 ] [ rand ( ) % CGI - > creh - > levelCreatures [ 5 ] . size ( ) ] - > idNumber ) ;
case 163 : //random monster lvl6
return std : : pair < int , int > ( 54 , CGI - > creh - > levelCreatures [ 6 ] [ rand ( ) % CGI - > creh - > levelCreatures [ 6 ] . size ( ) ] - > idNumber ) ;
case 164 : //random monster lvl7
return std : : pair < int , int > ( 54 , CGI - > creh - > levelCreatures [ 7 ] [ rand ( ) % CGI - > creh - > levelCreatures [ 7 ] . size ( ) ] - > idNumber ) ;
case 216 : //random dwelling
2007-11-20 19:52:22 +02:00
{
2008-02-05 05:56:45 +02:00
int faction = rand ( ) % F_NUMBER ;
CCreGen2ObjInfo * info = ( CCreGen2ObjInfo * ) obj - > info ;
if ( info - > asCastle )
2007-11-20 19:52:22 +02:00
{
2008-06-11 04:53:57 +03:00
for ( int i = 0 ; i < map - > objects . size ( ) ; i + + )
2007-11-20 19:52:22 +02:00
{
2008-06-11 04:53:57 +03:00
if ( map - > objects [ i ] - > ID = = 77 & & dynamic_cast < CGTownInstance * > ( map - > objects [ i ] ) - > identifier = = info - > identifier )
2007-11-24 20:54:34 +02:00
{
2008-06-11 04:53:57 +03:00
randomizeObject ( map - > objects [ i ] ) ; //we have to randomize the castle first
faction = map - > objects [ i ] - > subID ;
2008-02-05 05:56:45 +02:00
break ;
}
2008-06-11 04:53:57 +03:00
else if ( map - > objects [ i ] - > ID = = 98 & & dynamic_cast < CGTownInstance * > ( map - > objects [ i ] ) - > identifier = = info - > identifier )
2008-02-05 05:56:45 +02:00
{
2008-06-11 04:53:57 +03:00
faction = map - > objects [ i ] - > subID ;
2007-11-24 20:54:34 +02:00
break ;
}
2007-11-20 19:52:22 +02:00
}
2008-02-05 05:56:45 +02:00
}
else
{
while ( ( ! ( info - > castles [ 0 ] & ( 1 < < faction ) ) ) )
2007-11-24 20:54:34 +02:00
{
2008-02-05 05:56:45 +02:00
if ( ( faction > 7 ) & & ( info - > castles [ 1 ] & ( 1 < < ( faction - 8 ) ) ) )
break ;
faction = rand ( ) % F_NUMBER ;
2007-11-24 20:54:34 +02:00
}
2008-02-05 05:56:45 +02:00
}
int level = ( ( info - > maxLevel - info - > minLevel ) ? ( rand ( ) % ( info - > maxLevel - info - > minLevel ) + info - > minLevel ) : ( info - > minLevel ) ) ;
int cid = CGI - > townh - > towns [ faction ] . basicCreatures [ level ] ;
for ( int i = 0 ; i < CGI - > objh - > cregens . size ( ) ; i + + )
if ( CGI - > objh - > cregens [ i ] = = cid )
return std : : pair < int , int > ( 17 , i ) ;
std : : cout < < " Cannot find a dwelling for creature " < < cid < < std : : endl ;
return std : : pair < int , int > ( 17 , 0 ) ;
}
case 217 :
{
int faction = rand ( ) % F_NUMBER ;
CCreGenObjInfo * info = ( CCreGenObjInfo * ) obj - > info ;
if ( info - > asCastle )
{
2008-06-11 04:53:57 +03:00
for ( int i = 0 ; i < map - > objects . size ( ) ; i + + )
2007-11-24 20:54:34 +02:00
{
2008-06-11 04:53:57 +03:00
if ( map - > objects [ i ] - > ID = = 77 & & dynamic_cast < CGTownInstance * > ( map - > objects [ i ] ) - > identifier = = info - > identifier )
2007-11-24 20:54:34 +02:00
{
2008-06-11 04:53:57 +03:00
randomizeObject ( map - > objects [ i ] ) ; //we have to randomize the castle first
faction = map - > objects [ i ] - > subID ;
2008-02-05 05:56:45 +02:00
break ;
}
2008-06-11 04:53:57 +03:00
else if ( map - > objects [ i ] - > ID = = 98 & & dynamic_cast < CGTownInstance * > ( map - > objects [ i ] ) - > identifier = = info - > identifier )
2008-02-05 05:56:45 +02:00
{
2008-06-11 04:53:57 +03:00
faction = map - > objects [ i ] - > subID ;
2008-02-05 05:56:45 +02:00
break ;
2007-11-24 20:54:34 +02:00
}
}
2008-02-05 05:56:45 +02:00
}
else
{
while ( ( ! ( info - > castles [ 0 ] & ( 1 < < faction ) ) ) )
2007-11-24 20:54:34 +02:00
{
2008-02-05 05:56:45 +02:00
if ( ( faction > 7 ) & & ( info - > castles [ 1 ] & ( 1 < < ( faction - 8 ) ) ) )
break ;
faction = rand ( ) % F_NUMBER ;
2007-11-20 19:52:22 +02:00
}
}
2008-02-05 05:56:45 +02:00
int cid = CGI - > townh - > towns [ faction ] . basicCreatures [ obj - > subID ] ;
for ( int i = 0 ; i < CGI - > objh - > cregens . size ( ) ; i + + )
if ( CGI - > objh - > cregens [ i ] = = cid )
return std : : pair < int , int > ( 17 , i ) ;
std : : cout < < " Cannot find a dwelling for creature " < < cid < < std : : endl ;
return std : : pair < int , int > ( 17 , 0 ) ;
}
case 218 :
{
CCreGen3ObjInfo * info = ( CCreGen3ObjInfo * ) obj - > info ;
int level = ( ( info - > maxLevel - info - > minLevel ) ? ( rand ( ) % ( info - > maxLevel - info - > minLevel ) + info - > minLevel ) : ( info - > minLevel ) ) ;
int cid = CGI - > townh - > towns [ obj - > subID ] . basicCreatures [ level ] ;
for ( int i = 0 ; i < CGI - > objh - > cregens . size ( ) ; i + + )
if ( CGI - > objh - > cregens [ i ] = = cid )
return std : : pair < int , int > ( 17 , i ) ;
std : : cout < < " Cannot find a dwelling for creature " < < cid < < std : : endl ;
return std : : pair < int , int > ( 17 , 0 ) ;
2007-11-20 19:52:22 +02:00
}
}
2008-02-05 05:56:45 +02:00
return std : : pair < int , int > ( - 1 , - 1 ) ;
}
void CMapHandler : : randomizeObject ( CGObjectInstance * cur )
{
std : : pair < int , int > ran = pickObject ( cur ) ;
if ( ran . first < 0 | | ran . second < 0 ) //this is not a random object, or we couldn't find anything
2008-05-03 18:30:11 +03:00
{
if ( cur - > ID = = 98 ) //town - set def
{
CGTownInstance * t = dynamic_cast < CGTownInstance * > ( cur ) ;
if ( t - > hasCapitol ( ) )
t - > defInfo = capitols [ t - > subID ] ;
else if ( t - > hasFort ( ) )
t - > defInfo = CGI - > dobjinfo - > castles [ t - > subID ] ;
else
t - > defInfo = villages [ t - > subID ] ;
if ( ! t - > defInfo - > handler )
{
2008-06-12 09:45:51 +03:00
t - > defInfo - > handler = CDefHandler : : giveDef ( t - > defInfo - > name ) ;
2008-06-17 20:48:32 +03:00
t - > defInfo - > width = t - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > w / 32 ;
t - > defInfo - > height = t - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > h / 32 ;
2008-05-03 18:30:11 +03:00
alphaTransformDef ( t - > defInfo ) ;
}
}
2008-02-05 05:56:45 +02:00
return ;
2008-05-03 18:30:11 +03:00
}
2008-02-05 05:56:45 +02:00
else if ( ran . first = = 34 ) //special code for hero
{
CGHeroInstance * h = dynamic_cast < CGHeroInstance * > ( cur ) ;
if ( ! h ) { std : : cout < < " Wrong random hero at " < < cur - > pos < < std : : endl ; return ; }
cur - > ID = ran . first ;
cur - > subID = ran . second ;
h - > type = CGI - > heroh - > heroes [ ran . second ] ;
2008-06-11 04:53:57 +03:00
map - > heroes . push_back ( h ) ;
map - > objects . erase ( std : : find ( map - > objects . begin ( ) , map - > objects . end ( ) , h ) ) ;
2008-02-05 05:56:45 +02:00
return ; //TODO: maybe we should do something with definfo?
}
else if ( ran . first = = 98 ) //special code for town
{
CGTownInstance * t = dynamic_cast < CGTownInstance * > ( cur ) ;
if ( ! t ) { std : : cout < < " Wrong random town at " < < cur - > pos < < std : : endl ; return ; }
cur - > ID = ran . first ;
cur - > subID = ran . second ;
t - > town = & CGI - > townh - > towns [ ran . second ] ;
if ( t - > hasCapitol ( ) )
t - > defInfo = capitols [ t - > subID ] ;
else if ( t - > hasFort ( ) )
t - > defInfo = CGI - > dobjinfo - > castles [ t - > subID ] ;
else
t - > defInfo = villages [ t - > subID ] ;
if ( ! t - > defInfo - > handler )
{
2008-06-12 09:45:51 +03:00
t - > defInfo - > handler = CDefHandler : : giveDef ( t - > defInfo - > name ) ;
2008-06-17 20:48:32 +03:00
t - > defInfo - > width = t - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > w / 32 ;
t - > defInfo - > height = t - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > h / 32 ;
2008-02-05 05:56:45 +02:00
alphaTransformDef ( t - > defInfo ) ;
}
2008-02-07 20:45:22 +02:00
//CGI->townh->townInstances.push_back(t);
2008-02-05 05:56:45 +02:00
return ;
}
//we have to replace normal random object
cur - > ID = ran . first ;
cur - > subID = ran . second ;
cur - > defInfo = CGI - > dobjinfo - > gobjs [ ran . first ] [ ran . second ] ;
if ( ! cur - > defInfo ) { std : : cout < < " Missing def declaration for " < < cur - > ID < < " " < < cur - > subID < < std : : endl ; return ; }
if ( ! cur - > defInfo - > handler ) //if we have to load def
{
2008-06-12 09:45:51 +03:00
cur - > defInfo - > handler = CDefHandler : : giveDef ( cur - > defInfo - > name ) ;
2008-06-17 20:48:32 +03:00
cur - > defInfo - > width = cur - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > w / 32 ;
cur - > defInfo - > height = cur - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > h / 32 ;
2008-02-05 05:56:45 +02:00
alphaTransformDef ( cur - > defInfo ) ;
}
}
void CMapHandler : : randomizeObjects ( )
{
CGObjectInstance * cur ;
2008-06-11 04:53:57 +03:00
for ( int no = 0 ; no < map - > objects . size ( ) ; + + no )
2008-02-05 05:56:45 +02:00
{
2008-06-11 04:53:57 +03:00
randomizeObject ( map - > objects [ no ] ) ;
if ( map - > objects [ no ] - > ID = = 26 )
map - > objects [ no ] - > defInfo - > handler = NULL ;
2008-02-05 05:56:45 +02:00
}
2007-12-22 23:06:49 +02:00
}
void CMapHandler : : prepareFOWDefs ( )
{
2008-06-12 09:45:51 +03:00
fullHide = CDefHandler : : giveDef ( " TSHRC.DEF " ) ;
partialHide = CDefHandler : : giveDef ( " TSHRE.DEF " ) ;
2007-06-25 17:55:45 +03:00
2007-10-18 23:14:26 +03:00
//adding necessary rotations
Cimage nw = partialHide - > ourImages [ 22 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 15 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 2 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 13 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 12 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 16 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 18 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 17 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 20 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 19 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 7 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 24 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 26 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 25 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 30 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 32 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 27 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
nw = partialHide - > ourImages [ 28 ] ; nw . bitmap = CSDL_Ext : : rotate01 ( nw . bitmap ) ;
partialHide - > ourImages . push_back ( nw ) ;
//necessaary rotations added
2007-06-25 17:55:45 +03:00
for ( int i = 0 ; i < partialHide - > ourImages . size ( ) ; + + i )
{
2008-02-10 19:44:51 +02:00
CSDL_Ext : : alphaTransform ( partialHide - > ourImages [ i ] . bitmap ) ;
2007-06-25 17:55:45 +03:00
}
2008-06-11 04:53:57 +03:00
//visibility.resize(map->width+2*Woff);
//for(int gg=0; gg<map->width+2*Woff; ++gg)
2007-10-16 20:46:01 +03:00
//{
2008-06-11 04:53:57 +03:00
// visibility[gg].resize(map->height+2*Hoff);
// for(int jj=0; jj<map->height+2*Hoff; ++jj)
2007-10-16 20:46:01 +03:00
// visibility[gg][jj] = true;
//}
2008-06-12 09:45:51 +03:00
visibility . resize ( CGI - > mh - > map - > width , Woff ) ;
2007-10-16 20:46:01 +03:00
for ( int i = 0 - Woff ; i < visibility . size ( ) - Woff ; i + + )
2007-06-25 17:55:45 +03:00
{
2008-06-12 09:45:51 +03:00
visibility [ i ] . resize ( CGI - > mh - > map - > height , Hoff ) ;
2007-06-25 17:55:45 +03:00
}
2007-10-16 20:46:01 +03:00
for ( int i = 0 - Woff ; i < visibility . size ( ) - Woff ; + + i )
2007-06-25 17:55:45 +03:00
{
2008-06-12 09:45:51 +03:00
for ( int j = 0 - Hoff ; j < CGI - > mh - > map - > height + Hoff ; + + j )
2007-10-16 20:46:01 +03:00
{
2008-06-12 09:45:51 +03:00
visibility [ i ] [ j ] . resize ( CGI - > mh - > map - > twoLevel + 1 , 0 ) ;
for ( int k = 0 ; k < CGI - > mh - > map - > twoLevel + 1 ; + + k )
2007-10-16 20:46:01 +03:00
visibility [ i ] [ j ] [ k ] = true ;
}
2007-06-25 17:55:45 +03:00
}
2008-06-12 09:45:51 +03:00
hideBitmap . resize ( CGI - > mh - > map - > width , Woff ) ;
2007-12-11 20:49:24 +02:00
for ( int i = 0 - Woff ; i < visibility . size ( ) - Woff ; i + + )
{
2008-06-12 09:45:51 +03:00
hideBitmap [ i ] . resize ( CGI - > mh - > map - > height , Hoff ) ;
2007-12-11 20:49:24 +02:00
}
for ( int i = 0 - Woff ; i < hideBitmap . size ( ) - Woff ; + + i )
{
2008-06-12 09:45:51 +03:00
for ( int j = 0 - Hoff ; j < CGI - > mh - > map - > height + Hoff ; + + j )
2007-12-11 20:49:24 +02:00
{
2008-06-12 09:45:51 +03:00
hideBitmap [ i ] [ j ] . resize ( CGI - > mh - > map - > twoLevel + 1 , 0 ) ;
for ( int k = 0 ; k < CGI - > mh - > map - > twoLevel + 1 ; + + k )
2007-12-11 20:49:24 +02:00
hideBitmap [ i ] [ j ] [ k ] = rand ( ) % fullHide - > ourImages . size ( ) ;
}
}
2007-10-16 20:46:01 +03:00
//visibility[6][7][1] = false;
//visibility[7][7][1] = false;
//visibility[6][8][1] = false;
//visibility[6][6][1] = false;
//visibility[5][8][1] = false;
//visibility[7][6][1] = false;
//visibility[6][9][1] = false;
2007-12-22 23:06:49 +02:00
}
2007-06-25 17:55:45 +03:00
2007-12-22 23:06:49 +02:00
void CMapHandler : : roadsRiverTerrainInit ( )
{
2007-07-31 16:09:34 +03:00
//initializing road's and river's DefHandlers
2008-06-12 09:45:51 +03:00
roadDefs . push_back ( CDefHandler : : giveDef ( " dirtrd.def " ) ) ;
roadDefs . push_back ( CDefHandler : : giveDef ( " gravrd.def " ) ) ;
roadDefs . push_back ( CDefHandler : : giveDef ( " cobbrd.def " ) ) ;
staticRiverDefs . push_back ( CDefHandler : : giveDef ( " clrrvr.def " ) ) ;
staticRiverDefs . push_back ( CDefHandler : : giveDef ( " icyrvr.def " ) ) ;
staticRiverDefs . push_back ( CDefHandler : : giveDef ( " mudrvr.def " ) ) ;
staticRiverDefs . push_back ( CDefHandler : : giveDef ( " lavrvr.def " ) ) ;
2008-02-10 19:44:51 +02:00
for ( int g = 0 ; g < staticRiverDefs . size ( ) ; + + g )
{
for ( int h = 0 ; h < staticRiverDefs [ g ] - > ourImages . size ( ) ; + + h )
{
CSDL_Ext : : alphaTransform ( staticRiverDefs [ g ] - > ourImages [ h ] . bitmap ) ;
}
}
for ( int g = 0 ; g < roadDefs . size ( ) ; + + g )
{
for ( int h = 0 ; h < roadDefs [ g ] - > ourImages . size ( ) ; + + h )
{
CSDL_Ext : : alphaTransform ( roadDefs [ g ] - > ourImages [ h ] . bitmap ) ;
}
}
2007-07-31 16:09:34 +03:00
2008-06-11 04:53:57 +03:00
//roadBitmaps = new SDL_Surface** [map->width+2*Woff];
//for (int ii=0;ii<map->width+2*Woff;ii++)
// roadBitmaps[ii] = new SDL_Surface*[map->height+2*Hoff]; // allocate memory
2008-06-12 09:45:51 +03:00
sizes . x = CGI - > mh - > map - > width ;
sizes . y = CGI - > mh - > map - > height ;
sizes . z = CGI - > mh - > map - > twoLevel + 1 ;
ttiles . resize ( CGI - > mh - > map - > width , Woff ) ;
2007-08-17 20:42:21 +03:00
for ( int i = 0 - Woff ; i < ttiles . size ( ) - Woff ; i + + )
2007-08-08 22:28:56 +03:00
{
2008-06-12 09:45:51 +03:00
ttiles [ i ] . resize ( CGI - > mh - > map - > height , Hoff ) ;
2007-08-08 22:28:56 +03:00
}
2007-08-17 20:42:21 +03:00
for ( int i = 0 - Woff ; i < ttiles . size ( ) - Woff ; i + + )
2007-08-08 22:28:56 +03:00
{
2008-06-12 09:45:51 +03:00
for ( int j = 0 - Hoff ; j < CGI - > mh - > map - > height + Hoff ; j + + )
ttiles [ i ] [ j ] . resize ( CGI - > mh - > map - > twoLevel + 1 , 0 ) ;
2007-08-08 22:28:56 +03:00
}
2007-07-31 16:09:34 +03:00
2008-06-11 04:53:57 +03:00
for ( int i = 0 ; i < map - > width ; i + + ) //jest po szeroko�ci
2007-07-31 16:09:34 +03:00
{
2008-06-11 04:53:57 +03:00
for ( int j = 0 ; j < map - > height ; j + + ) //po wysoko�ci
2007-07-31 16:09:34 +03:00
{
2008-06-11 04:53:57 +03:00
for ( int k = 0 ; k < = map - > twoLevel ; + + k )
2007-07-31 16:09:34 +03:00
{
2008-06-11 04:53:57 +03:00
TerrainTile * * pomm = map - > terrain ; ;
2007-08-17 20:42:21 +03:00
if ( k = = 0 )
2008-06-11 04:53:57 +03:00
pomm = map - > terrain ;
2007-08-17 20:42:21 +03:00
else
2008-06-11 04:53:57 +03:00
pomm = map - > undergroungTerrain ;
2007-08-17 20:42:21 +03:00
if ( pomm [ i ] [ j ] . malle )
2007-07-31 16:09:34 +03:00
{
2007-08-17 20:42:21 +03:00
int cDir ;
bool rotV , rotH ;
if ( k = = 0 )
{
2008-06-11 04:53:57 +03:00
int roadpom = map - > terrain [ i ] [ j ] . malle - 1 ,
impom = map - > terrain [ i ] [ j ] . roadDir ;
2007-08-17 20:42:21 +03:00
SDL_Surface * pom1 = roadDefs [ roadpom ] - > ourImages [ impom ] . bitmap ;
ttiles [ i ] [ j ] [ k ] . roadbitmap . push_back ( pom1 ) ;
2008-06-11 04:53:57 +03:00
cDir = map - > terrain [ i ] [ j ] . roadDir ;
2007-12-22 23:06:49 +02:00
2008-06-11 04:53:57 +03:00
rotH = ( map - > terrain [ i ] [ j ] . siodmyTajemniczyBajt > > 5 ) & 1 ;
rotV = ( map - > terrain [ i ] [ j ] . siodmyTajemniczyBajt > > 4 ) & 1 ;
2007-08-17 20:42:21 +03:00
}
2007-08-08 22:28:56 +03:00
else
2007-07-31 16:09:34 +03:00
{
2008-06-11 04:53:57 +03:00
int pom111 = map - > undergroungTerrain [ i ] [ j ] . malle - 1 ,
pom777 = map - > undergroungTerrain [ i ] [ j ] . roadDir ;
2007-08-17 20:42:21 +03:00
SDL_Surface * pom1 = roadDefs [ pom111 ] - > ourImages [ pom777 ] . bitmap ;
ttiles [ i ] [ j ] [ k ] . roadbitmap . push_back ( pom1 ) ;
2008-06-11 04:53:57 +03:00
cDir = map - > undergroungTerrain [ i ] [ j ] . roadDir ;
2007-08-17 20:42:21 +03:00
2008-06-11 04:53:57 +03:00
rotH = ( map - > undergroungTerrain [ i ] [ j ] . siodmyTajemniczyBajt > > 5 ) & 1 ;
rotV = ( map - > undergroungTerrain [ i ] [ j ] . siodmyTajemniczyBajt > > 4 ) & 1 ;
2007-08-17 20:42:21 +03:00
}
if ( rotH )
{
ttiles [ i ] [ j ] [ k ] . roadbitmap [ 0 ] = CSDL_Ext : : hFlip ( ttiles [ i ] [ j ] [ k ] . roadbitmap [ 0 ] ) ;
}
if ( rotV )
{
ttiles [ i ] [ j ] [ k ] . roadbitmap [ 0 ] = CSDL_Ext : : rotate01 ( ttiles [ i ] [ j ] [ k ] . roadbitmap [ 0 ] ) ;
}
if ( rotH | | rotV )
{
ttiles [ i ] [ j ] [ k ] . roadbitmap [ 0 ] = CSDL_Ext : : alphaTransform ( ttiles [ i ] [ j ] [ k ] . roadbitmap [ 0 ] ) ;
2007-07-31 16:09:34 +03:00
}
}
}
}
}
2007-08-11 17:58:07 +03:00
//initializing simple values
2008-06-12 09:45:51 +03:00
for ( int i = 0 ; i < CGI - > mh - > map - > width ; i + + ) //jest po szeroko�ci
2007-08-11 17:58:07 +03:00
{
2008-06-12 09:45:51 +03:00
for ( int j = 0 ; j < CGI - > mh - > map - > height ; j + + ) //po wysoko�ci
2007-08-11 17:58:07 +03:00
{
for ( int k = 0 ; k < ttiles [ 0 ] [ 0 ] . size ( ) ; + + k )
{
ttiles [ i ] [ j ] [ k ] . pos = int3 ( i , j , k ) ;
ttiles [ i ] [ j ] [ k ] . blocked = false ;
ttiles [ i ] [ j ] [ k ] . visitable = false ;
2008-06-12 09:45:51 +03:00
if ( i < 0 | | j < 0 | | i > = CGI - > mh - > map - > width | | j > = CGI - > mh - > map - > height )
2007-08-11 17:58:07 +03:00
{
ttiles [ i ] [ j ] [ k ] . blocked = true ;
continue ;
}
2008-06-12 09:45:51 +03:00
ttiles [ i ] [ j ] [ k ] . terType = ( k = = 0 ? CGI - > mh - > map - > terrain [ i ] [ j ] . tertype : CGI - > mh - > map - > undergroungTerrain [ i ] [ j ] . tertype ) ;
ttiles [ i ] [ j ] [ k ] . malle = ( k = = 0 ? CGI - > mh - > map - > terrain [ i ] [ j ] . malle : CGI - > mh - > map - > undergroungTerrain [ i ] [ j ] . malle ) ;
ttiles [ i ] [ j ] [ k ] . nuine = ( k = = 0 ? CGI - > mh - > map - > terrain [ i ] [ j ] . nuine : CGI - > mh - > map - > undergroungTerrain [ i ] [ j ] . nuine ) ;
ttiles [ i ] [ j ] [ k ] . rivdir = ( k = = 0 ? CGI - > mh - > map - > terrain [ i ] [ j ] . rivDir : CGI - > mh - > map - > undergroungTerrain [ i ] [ j ] . rivDir ) ;
ttiles [ i ] [ j ] [ k ] . roaddir = ( k = = 0 ? CGI - > mh - > map - > terrain [ i ] [ j ] . roadDir : CGI - > mh - > map - > undergroungTerrain [ i ] [ j ] . roadDir ) ;
2007-08-11 17:58:07 +03:00
}
}
}
//simple values initialized
2008-06-11 04:53:57 +03:00
for ( int i = 0 ; i < map - > width ; i + + ) //jest po szeroko�ci
2007-07-31 16:09:34 +03:00
{
2008-06-11 04:53:57 +03:00
for ( int j = 0 ; j < map - > height ; j + + ) //po wysoko�ci
2007-07-31 16:09:34 +03:00
{
2008-06-11 04:53:57 +03:00
for ( int k = 0 ; k < = map - > twoLevel ; + + k )
2007-07-31 16:09:34 +03:00
{
2008-06-11 04:53:57 +03:00
TerrainTile * * pomm = map - > terrain ;
2007-08-08 22:28:56 +03:00
if ( k = = 0 )
{
2008-06-11 04:53:57 +03:00
pomm = map - > terrain ;
2007-08-08 22:28:56 +03:00
}
2007-07-31 16:09:34 +03:00
else
{
2008-06-11 04:53:57 +03:00
pomm = map - > undergroungTerrain ;
2007-07-31 16:09:34 +03:00
}
2007-08-17 20:42:21 +03:00
if ( pomm [ i ] [ j ] . nuine )
2007-07-31 16:09:34 +03:00
{
2007-08-08 22:28:56 +03:00
int cDir ;
bool rotH , rotV ;
if ( k = = 0 )
2007-07-31 16:09:34 +03:00
{
2008-06-11 04:53:57 +03:00
ttiles [ i ] [ j ] [ k ] . rivbitmap . push_back ( staticRiverDefs [ map - > terrain [ i ] [ j ] . nuine - 1 ] - > ourImages [ map - > terrain [ i ] [ j ] . rivDir ] . bitmap ) ;
cDir = map - > terrain [ i ] [ j ] . rivDir ;
rotH = ( map - > terrain [ i ] [ j ] . siodmyTajemniczyBajt > > 3 ) & 1 ;
rotV = ( map - > terrain [ i ] [ j ] . siodmyTajemniczyBajt > > 2 ) & 1 ;
2007-07-31 16:09:34 +03:00
}
2007-08-08 22:28:56 +03:00
else
2007-07-31 16:09:34 +03:00
{
2008-06-11 04:53:57 +03:00
ttiles [ i ] [ j ] [ k ] . rivbitmap . push_back ( staticRiverDefs [ map - > undergroungTerrain [ i ] [ j ] . nuine - 1 ] - > ourImages [ map - > undergroungTerrain [ i ] [ j ] . rivDir ] . bitmap ) ;
cDir = map - > undergroungTerrain [ i ] [ j ] . rivDir ;
rotH = ( map - > undergroungTerrain [ i ] [ j ] . siodmyTajemniczyBajt > > 3 ) & 1 ;
rotV = ( map - > undergroungTerrain [ i ] [ j ] . siodmyTajemniczyBajt > > 2 ) & 1 ;
2007-07-31 16:09:34 +03:00
}
2007-08-08 22:28:56 +03:00
if ( rotH )
2007-07-31 16:09:34 +03:00
{
2007-08-08 22:28:56 +03:00
ttiles [ i ] [ j ] [ k ] . rivbitmap [ 0 ] = CSDL_Ext : : hFlip ( ttiles [ i ] [ j ] [ k ] . rivbitmap [ 0 ] ) ;
2007-07-31 16:09:34 +03:00
}
2007-08-08 22:28:56 +03:00
if ( rotV )
2007-07-31 16:09:34 +03:00
{
2007-08-08 22:28:56 +03:00
ttiles [ i ] [ j ] [ k ] . rivbitmap [ 0 ] = CSDL_Ext : : rotate01 ( ttiles [ i ] [ j ] [ k ] . rivbitmap [ 0 ] ) ;
2007-07-31 16:09:34 +03:00
}
2007-08-11 17:58:07 +03:00
if ( rotH | | rotV )
{
ttiles [ i ] [ j ] [ k ] . rivbitmap [ 0 ] = CSDL_Ext : : alphaTransform ( ttiles [ i ] [ j ] [ k ] . rivbitmap [ 0 ] ) ;
}
2007-07-31 16:09:34 +03:00
}
}
}
}
2007-12-22 23:06:49 +02:00
}
void CMapHandler : : borderAndTerrainBitmapInit ( )
{
2008-06-11 04:53:57 +03:00
//terrainBitmap = new SDL_Surface **[map->width+2*Woff];
//for (int ii=0;ii<map->width+2*Woff;ii++)
// terrainBitmap[ii] = new SDL_Surface*[map->height+2*Hoff]; // allocate memory
2007-08-08 22:28:56 +03:00
2008-06-12 09:45:51 +03:00
CDefHandler * bord = CDefHandler : : giveDef ( " EDG.DEF " ) ;
2008-02-22 19:47:14 +02:00
bord - > notFreeImgs = true ;
2008-06-11 04:53:57 +03:00
for ( int i = 0 - Woff ; i < map - > width + Woff ; i + + ) //jest po szeroko�ci
2007-06-06 19:12:12 +03:00
{
2008-06-11 04:53:57 +03:00
for ( int j = 0 - Hoff ; j < map - > height + Hoff ; j + + ) //po wysoko�ci
2007-06-06 19:12:12 +03:00
{
2008-06-11 04:53:57 +03:00
for ( int k = 0 ; k < = map - > twoLevel ; + + k )
2007-06-09 05:32:43 +03:00
{
2008-06-11 04:53:57 +03:00
if ( i < 0 | | i > ( map - > width - 1 ) | | j < 0 | | j > ( map - > height - 1 ) )
2007-06-22 19:36:05 +03:00
{
2007-08-17 20:42:21 +03:00
if ( i = = - 1 & & j = = - 1 )
2007-06-22 19:36:05 +03:00
{
2007-08-08 22:28:56 +03:00
ttiles [ i ] [ j ] [ k ] . terbitmap . push_back ( bord - > ourImages [ 16 ] . bitmap ) ;
2007-06-22 19:36:05 +03:00
continue ;
}
2008-06-11 04:53:57 +03:00
else if ( i = = - 1 & & j = = ( map - > height ) )
2007-06-22 19:36:05 +03:00
{
2007-08-08 22:28:56 +03:00
ttiles [ i ] [ j ] [ k ] . terbitmap . push_back ( bord - > ourImages [ 19 ] . bitmap ) ;
2007-06-22 19:36:05 +03:00
continue ;
}
2008-06-11 04:53:57 +03:00
else if ( i = = ( map - > width ) & & j = = - 1 )
2007-06-22 19:36:05 +03:00
{
2007-08-08 22:28:56 +03:00
ttiles [ i ] [ j ] [ k ] . terbitmap . push_back ( bord - > ourImages [ 17 ] . bitmap ) ;
2007-06-22 19:36:05 +03:00
continue ;
}
2008-06-11 04:53:57 +03:00
else if ( i = = ( map - > width ) & & j = = ( map - > height ) )
2007-06-22 19:36:05 +03:00
{
2007-08-08 22:28:56 +03:00
ttiles [ i ] [ j ] [ k ] . terbitmap . push_back ( bord - > ourImages [ 18 ] . bitmap ) ;
2007-06-22 19:36:05 +03:00
continue ;
}
2008-06-11 04:53:57 +03:00
else if ( j = = - 1 & & i > - 1 & & i < map - > height )
2007-06-22 19:36:05 +03:00
{
2007-08-08 22:28:56 +03:00
ttiles [ i ] [ j ] [ k ] . terbitmap . push_back ( bord - > ourImages [ 22 + rand ( ) % 2 ] . bitmap ) ;
2007-06-22 19:36:05 +03:00
continue ;
}
2008-06-11 04:53:57 +03:00
else if ( i = = - 1 & & j > - 1 & & j < map - > height )
2007-06-22 19:36:05 +03:00
{
2007-08-08 22:28:56 +03:00
ttiles [ i ] [ j ] [ k ] . terbitmap . push_back ( bord - > ourImages [ 33 + rand ( ) % 2 ] . bitmap ) ;
2007-06-22 19:36:05 +03:00
continue ;
}
2008-06-11 04:53:57 +03:00
else if ( j = = map - > height & & i > - 1 & & i < map - > width )
2007-06-22 19:36:05 +03:00
{
2007-08-08 22:28:56 +03:00
ttiles [ i ] [ j ] [ k ] . terbitmap . push_back ( bord - > ourImages [ 29 + rand ( ) % 2 ] . bitmap ) ;
2007-06-22 19:36:05 +03:00
continue ;
}
2008-06-11 04:53:57 +03:00
else if ( i = = map - > width & & j > - 1 & & j < map - > height )
2007-06-22 19:36:05 +03:00
{
2007-08-08 22:28:56 +03:00
ttiles [ i ] [ j ] [ k ] . terbitmap . push_back ( bord - > ourImages [ 25 + rand ( ) % 2 ] . bitmap ) ;
2007-06-22 19:36:05 +03:00
continue ;
}
else
{
2007-08-08 22:28:56 +03:00
ttiles [ i ] [ j ] [ k ] . terbitmap . push_back ( bord - > ourImages [ rand ( ) % 16 ] . bitmap ) ;
2007-06-22 19:36:05 +03:00
continue ;
}
}
2008-06-11 04:53:57 +03:00
//TerrainTile zz = map->terrain[i-Woff][j-Hoff];
2007-08-08 22:28:56 +03:00
std : : string name ;
if ( k > 0 )
2008-06-11 04:53:57 +03:00
name = nameFromType ( map - > undergroungTerrain [ i ] [ j ] . tertype ) ;
2007-08-08 22:28:56 +03:00
else
2008-06-11 04:53:57 +03:00
name = nameFromType ( map - > terrain [ i ] [ j ] . tertype ) ;
2008-06-07 20:16:52 +03:00
for ( unsigned int m = 0 ; m < defs . size ( ) ; m + + )
2007-06-09 05:32:43 +03:00
{
try
{
2008-06-07 20:16:52 +03:00
if ( defs [ m ] - > defName ! = name )
2007-06-09 05:32:43 +03:00
continue ;
else
{
2007-08-08 22:28:56 +03:00
int ktora ;
if ( k = = 0 )
2008-06-11 04:53:57 +03:00
ktora = map - > terrain [ i ] [ j ] . terview ;
2007-08-08 22:28:56 +03:00
else
2008-06-11 04:53:57 +03:00
ktora = map - > undergroungTerrain [ i ] [ j ] . terview ;
2008-06-07 20:16:52 +03:00
ttiles [ i ] [ j ] [ k ] . terbitmap . push_back ( defs [ m ] - > ourImages [ ktora ] . bitmap ) ;
2007-08-08 22:28:56 +03:00
int zz ;
if ( k = = 0 )
2008-06-11 04:53:57 +03:00
zz = ( map - > terrain [ i ] [ j ] . siodmyTajemniczyBajt ) % 4 ;
2007-12-22 23:06:49 +02:00
else
2008-06-11 04:53:57 +03:00
zz = ( map - > undergroungTerrain [ i ] [ j ] . siodmyTajemniczyBajt ) % 4 ;
2007-08-08 22:28:56 +03:00
switch ( zz )
2007-06-09 05:32:43 +03:00
{
case 1 :
{
2007-08-08 22:28:56 +03:00
ttiles [ i ] [ j ] [ k ] . terbitmap [ 0 ] = CSDL_Ext : : rotate01 ( ttiles [ i ] [ j ] [ k ] . terbitmap [ 0 ] ) ;
2007-06-09 05:32:43 +03:00
break ;
}
case 2 :
{
2007-08-08 22:28:56 +03:00
ttiles [ i ] [ j ] [ k ] . terbitmap [ 0 ] = CSDL_Ext : : hFlip ( ttiles [ i ] [ j ] [ k ] . terbitmap [ 0 ] ) ;
2007-06-09 05:32:43 +03:00
break ;
}
case 3 :
{
2007-08-08 22:28:56 +03:00
ttiles [ i ] [ j ] [ k ] . terbitmap [ 0 ] = CSDL_Ext : : rotate03 ( ttiles [ i ] [ j ] [ k ] . terbitmap [ 0 ] ) ;
2007-06-09 05:32:43 +03:00
break ;
}
}
break ;
}
}
catch ( . . . )
2007-12-22 23:06:49 +02:00
{
continue ;
2007-08-08 22:28:56 +03:00
}
2007-06-09 05:32:43 +03:00
}
2007-08-08 22:28:56 +03:00
}
}
}
2008-02-22 19:47:14 +02:00
delete bord ;
2007-12-22 23:06:49 +02:00
}
void CMapHandler : : initObjectRects ( )
{
2007-08-09 19:28:01 +03:00
//initializing objects / rects
2008-06-11 04:53:57 +03:00
for ( int f = 0 ; f < map - > objects . size ( ) ; + + f )
2007-12-22 23:06:49 +02:00
{
2008-06-11 04:53:57 +03:00
/*map->objects[f]->pos.x+=1;
map - > objects [ f ] - > pos . y + = 1 ; */
if ( ! map - > objects [ f ] - > defInfo )
2008-02-05 05:56:45 +02:00
{
continue ;
}
2008-06-11 04:53:57 +03:00
CDefHandler * curd = map - > objects [ f ] - > defInfo - > handler ;
2008-02-07 20:45:22 +02:00
if ( curd )
2007-08-09 19:28:01 +03:00
{
2008-02-07 20:45:22 +02:00
for ( int fx = 0 ; fx < curd - > ourImages [ 0 ] . bitmap - > w > > 5 ; + + fx ) //curd->ourImages[0].bitmap->w/32
2007-08-09 19:28:01 +03:00
{
2008-02-07 20:45:22 +02:00
for ( int fy = 0 ; fy < curd - > ourImages [ 0 ] . bitmap - > h > > 5 ; + + fy ) //curd->ourImages[0].bitmap->h/32
2007-10-24 22:54:35 +03:00
{
2008-02-07 20:45:22 +02:00
SDL_Rect cr ;
cr . w = 32 ;
cr . h = 32 ;
cr . x = fx < < 5 ; //fx*32
cr . y = fy < < 5 ; //fy*32
2008-06-11 04:53:57 +03:00
std : : pair < CGObjectInstance * , SDL_Rect > toAdd = std : : make_pair ( map - > objects [ f ] , cr ) ;
2008-02-07 21:05:16 +02:00
2008-06-11 04:53:57 +03:00
if ( ( map - > objects [ f ] - > pos . x + fx - curd - > ourImages [ 0 ] . bitmap - > w / 32 + 1 ) > = 0 & & ( map - > objects [ f ] - > pos . x + fx - curd - > ourImages [ 0 ] . bitmap - > w / 32 + 1 ) < ttiles . size ( ) - Woff & & ( map - > objects [ f ] - > pos . y + fy - curd - > ourImages [ 0 ] . bitmap - > h / 32 + 1 ) > = 0 & & ( map - > objects [ f ] - > pos . y + fy - curd - > ourImages [ 0 ] . bitmap - > h / 32 + 1 ) < ttiles [ 0 ] . size ( ) - Hoff )
2008-02-07 20:45:22 +02:00
{
//TerrainTile2 & curt =
// ttiles
2008-06-11 04:53:57 +03:00
// [map->objects[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32]
//[map->objects[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32]
//[map->objects[f]->pos.z];
ttiles [ map - > objects [ f ] - > pos . x + fx - curd - > ourImages [ 0 ] . bitmap - > w / 32 + 1 ] [ map - > objects [ f ] - > pos . y + fy - curd - > ourImages [ 0 ] . bitmap - > h / 32 + 1 ] [ map - > objects [ f ] - > pos . z ] . objects . push_back ( toAdd ) ;
2008-02-07 20:45:22 +02:00
}
} // for(int fy=0; fy<curd->ourImages[0].bitmap->h/32; ++fy)
} //for(int fx=0; fx<curd->ourImages[0].bitmap->w/32; ++fx)
} //if curd
2008-06-11 04:53:57 +03:00
} // for(int f=0; f<map->objects.size(); ++f)
2007-12-22 23:06:49 +02:00
for ( int ix = 0 ; ix < ttiles . size ( ) - Woff ; + + ix )
{
for ( int iy = 0 ; iy < ttiles [ 0 ] . size ( ) - Hoff ; + + iy )
{
for ( int iz = 0 ; iz < ttiles [ 0 ] [ 0 ] . size ( ) ; + + iz )
{
stable_sort ( ttiles [ ix ] [ iy ] [ iz ] . objects . begin ( ) , ttiles [ ix ] [ iy ] [ iz ] . objects . end ( ) , ocmptwo ) ;
}
}
}
}
void CMapHandler : : calculateBlockedPos ( )
{
2008-06-11 04:53:57 +03:00
for ( int f = 0 ; f < map - > objects . size ( ) ; + + f ) //calculationg blocked / visitable positions
2007-12-22 23:06:49 +02:00
{
2008-06-11 04:53:57 +03:00
if ( ! map - > objects [ f ] - > defInfo )
2008-02-05 05:56:45 +02:00
continue ;
2008-06-11 04:53:57 +03:00
CDefHandler * curd = map - > objects [ f ] - > defInfo - > handler ;
2007-08-11 17:58:07 +03:00
for ( int fx = 0 ; fx < 8 ; + + fx )
{
for ( int fy = 0 ; fy < 6 ; + + fy )
{
2008-06-11 04:53:57 +03:00
int xVal = map - > objects [ f ] - > pos . x + fx - 7 ;
int yVal = map - > objects [ f ] - > pos . y + fy - 5 ;
int zVal = map - > objects [ f ] - > pos . z ;
2007-08-17 20:42:21 +03:00
if ( xVal > = 0 & & xVal < ttiles . size ( ) - Woff & & yVal > = 0 & & yVal < ttiles [ 0 ] . size ( ) - Hoff )
2007-08-11 17:58:07 +03:00
{
TerrainTile2 & curt = ttiles [ xVal ] [ yVal ] [ zVal ] ;
2008-06-11 04:53:57 +03:00
if ( ( ( map - > objects [ f ] - > defInfo - > visitMap [ fy ] > > ( 7 - fx ) ) & 1 ) )
2007-08-11 17:58:07 +03:00
curt . visitable = true ;
2008-06-11 04:53:57 +03:00
if ( ! ( ( map - > objects [ f ] - > defInfo - > blockMap [ fy ] > > ( 7 - fx ) ) & 1 ) )
2007-08-11 17:58:07 +03:00
curt . blocked = true ;
}
}
}
}
2007-12-22 23:06:49 +02:00
}
void CMapHandler : : init ( )
{
2008-06-11 04:53:57 +03:00
timeHandler th ;
th . getDif ( ) ;
///loading defs from lod
for ( int ir = 0 ; ir < map - > defy . size ( ) ; ir + + )
{
2008-06-12 09:45:51 +03:00
map - > defy [ ir ] - > handler = CDefHandler : : giveDef ( map - > defy [ ir ] - > name ) ;
2008-06-17 20:48:32 +03:00
map - > defy [ ir ] - > width = map - > defy [ ir ] - > handler - > ourImages [ 0 ] . bitmap - > w / 32 ;
map - > defy [ ir ] - > height = map - > defy [ ir ] - > handler - > ourImages [ 0 ] . bitmap - > h / 32 ;
2008-06-11 04:53:57 +03:00
CGDefInfo * pom = CGI - > dobjinfo - > gobjs [ map - > defy [ ir ] - > id ] [ map - > defy [ ir ] - > subid ] ;
if ( pom )
2008-06-17 20:48:32 +03:00
{
2008-06-11 04:53:57 +03:00
pom - > handler = map - > defy [ ir ] - > handler ;
2008-06-17 20:48:32 +03:00
pom - > width = pom - > handler - > ourImages [ 0 ] . bitmap - > w / 32 ;
pom - > height = pom - > handler - > ourImages [ 0 ] . bitmap - > h / 32 ;
}
2008-06-11 04:53:57 +03:00
else
std : : cout < < " Lacking def info for " < < map - > defy [ ir ] - > id < < " " < < map - > defy [ ir ] - > subid < < " " < < map - > defy [ ir ] - > name < < std : : endl ;
}
for ( int vv = 0 ; vv < map - > defy . size ( ) ; + + vv )
{
if ( map - > defy [ vv ] - > handler - > alphaTransformed )
continue ;
for ( int yy = 0 ; yy < map - > defy [ vv ] - > handler - > ourImages . size ( ) ; + + yy )
{
map - > defy [ vv ] - > handler - > ourImages [ yy ] . bitmap = CSDL_Ext : : alphaTransform ( map - > defy [ vv ] - > handler - > ourImages [ yy ] . bitmap ) ;
map - > defy [ vv ] - > handler - > alphaTransformed = true ;
}
}
THC std : : cout < < " \t Unpacking and handling defs: " < < th . getDif ( ) < < std : : endl ;
2008-02-10 11:35:52 +02:00
//loading castles' defs
2008-02-05 05:56:45 +02:00
std : : ifstream ifs ( " config/townsDefs.txt " ) ;
int ccc ;
ifs > > ccc ;
for ( int i = 0 ; i < ccc * 2 ; i + + )
{
CGDefInfo * n = new CGDefInfo ( * CGI - > dobjinfo - > castles [ i % ccc ] ) ;
ifs > > n - > name ;
2008-06-12 09:45:51 +03:00
if ( ! ( n - > handler = CDefHandler : : giveDef ( n - > name ) ) )
2008-02-05 05:56:45 +02:00
std : : cout < < " Cannot open " < < n - > name < < std : : endl ;
2008-06-17 20:48:32 +03:00
else
{
n - > width = n - > handler - > ourImages [ 0 ] . bitmap - > w / 32 ;
n - > height = n - > handler - > ourImages [ 0 ] . bitmap - > h / 32 ;
}
2008-02-05 05:56:45 +02:00
if ( i < ccc )
villages [ i ] = n ;
else
capitols [ i % ccc ] = n ;
alphaTransformDef ( n ) ;
}
2008-02-10 11:35:52 +02:00
for ( int i = 0 ; i < CGI - > scenarioOps . playerInfos . size ( ) ; i + + )
{
if ( CGI - > scenarioOps . playerInfos [ i ] . castle = = - 1 )
{
int f ;
do
{
f = rand ( ) % F_NUMBER ;
2008-06-11 04:53:57 +03:00
} while ( ! ( map - > players [ CGI - > scenarioOps . playerInfos [ i ] . color ] . allowedFactions & 1 < < f ) ) ;
2008-02-10 11:35:52 +02:00
CGI - > scenarioOps . playerInfos [ i ] . castle = f ;
}
}
for ( int i = 0 ; i < PLAYER_LIMIT ; i + + )
{
2008-06-11 04:53:57 +03:00
for ( int j = 0 ; j < map - > players [ i ] . heroesNames . size ( ) ; j + + )
2008-02-10 11:35:52 +02:00
{
2008-06-11 04:53:57 +03:00
usedHeroes . insert ( map - > players [ i ] . heroesNames [ j ] . heroID ) ;
2008-02-10 11:35:52 +02:00
}
}
2008-06-11 04:53:57 +03:00
std : : cout < < " \t Loading town defs, picking random factions and heroes: " < < th . getDif ( ) < < std : : endl ;
2008-02-10 11:35:52 +02:00
2007-12-22 23:06:49 +02:00
randomizeObjects ( ) ; //randomizing objects on map
2008-02-03 06:22:58 +02:00
std : : cout < < " \t Randomizing objects: " < < th . getDif ( ) < < std : : endl ;
2007-12-22 23:06:49 +02:00
2008-06-11 04:53:57 +03:00
for ( int h = 0 ; h < map - > defy . size ( ) ; + + h ) //initializing loaded def handler's info
2007-08-09 19:28:01 +03:00
{
2008-06-11 04:53:57 +03:00
//std::string hlp = map->defy[h]->name;
2008-02-05 05:56:45 +02:00
//std::transform(hlp.begin(), hlp.end(), hlp.begin(), (int(*)(int))toupper);
2008-06-11 04:53:57 +03:00
CGI - > mh - > loadedDefs . insert ( std : : make_pair ( map - > defy [ h ] - > name , map - > defy [ h ] - > handler ) ) ;
2007-08-09 19:28:01 +03:00
}
2008-02-03 06:22:58 +02:00
std : : cout < < " \t Collecting loaded def's handlers: " < < th . getDif ( ) < < std : : endl ;
2007-12-22 23:06:49 +02:00
prepareFOWDefs ( ) ;
roadsRiverTerrainInit ( ) ; //road's and river's DefHandlers; and simple values initialization
borderAndTerrainBitmapInit ( ) ;
2008-02-03 06:22:58 +02:00
std : : cout < < " \t Preparing FoW, roads, rivers,borders: " < < th . getDif ( ) < < std : : endl ;
2008-02-23 21:20:41 +02:00
//giving starting hero
2008-02-07 20:45:22 +02:00
for ( int i = 0 ; i < PLAYER_LIMIT ; i + + )
{
2008-06-11 04:53:57 +03:00
if ( ( map - > players [ i ] . generateHeroAtMainTown & & map - > players [ i ] . hasMainTown ) | | ( map - > players [ i ] . hasMainTown & & map - > version = = RoE ) )
2008-02-07 20:45:22 +02:00
{
2008-06-11 04:53:57 +03:00
int3 hpos = map - > players [ i ] . posOfMainTown ;
2008-02-23 21:20:41 +02:00
hpos . x + = 1 ; // hpos.y+=1;
2008-02-07 20:45:22 +02:00
int j ;
for ( j = 0 ; j < CGI - > scenarioOps . playerInfos . size ( ) ; j + + )
if ( CGI - > scenarioOps . playerInfos [ j ] . color = = i )
break ;
if ( j = = CGI - > scenarioOps . playerInfos . size ( ) )
continue ;
2008-02-23 21:20:41 +02:00
int h ; //= CGI->scenarioOps.playerInfos[j].hero;
//if(h<0)
2008-02-10 11:35:52 +02:00
h = pickHero ( i ) ;
CGHeroInstance * nnn = ( CGHeroInstance * ) createObject ( 34 , h , hpos , i ) ;
2008-06-13 11:16:51 +03:00
nnn - > defInfo - > handler = graphics - > flags1 [ 0 ] ;
2008-06-11 04:53:57 +03:00
map - > heroes . push_back ( nnn ) ;
map - > objects . push_back ( nnn ) ;
2008-02-07 20:45:22 +02:00
}
}
2008-02-23 21:20:41 +02:00
std : : cout < < " \t Giving starting heroes: " < < th . getDif ( ) < < std : : endl ;
2008-02-07 20:45:22 +02:00
2007-12-22 23:06:49 +02:00
initObjectRects ( ) ;
2008-02-03 06:22:58 +02:00
std : : cout < < " \t Making object rects: " < < th . getDif ( ) < < std : : endl ;
2007-12-22 23:06:49 +02:00
calculateBlockedPos ( ) ;
2008-02-03 06:22:58 +02:00
std : : cout < < " \t Calculating blockmap: " < < th . getDif ( ) < < std : : endl ;
2008-02-26 20:01:26 +02:00
//initailizing battle backgrounds
std : : ifstream bback ( " config/battleBack.txt " ) ;
battleBacks . resize ( 9 ) ;
for ( int i = 0 ; i < 9 ; + + i ) //9 - number of terrains battle can be fought on
{
int am ;
bback > > am ;
battleBacks [ i ] . resize ( am ) ;
for ( int f = 0 ; f < am ; + + f )
{
bback > > battleBacks [ i ] [ f ] ;
}
}
2008-03-03 21:41:10 +02:00
//initializing battle hero animation
std : : ifstream bher ( " config/battleHeroes.txt " ) ;
int numberofh ;
bher > > numberofh ;
battleHeroes . resize ( numberofh ) ;
for ( int i = 0 ; i < numberofh ; + + i ) //9 - number of terrains battle can be fought on
{
bher > > battleHeroes [ i ] ;
}
2007-06-06 19:12:12 +03:00
}
2007-06-25 17:55:45 +03:00
2008-02-11 20:40:10 +02:00
SDL_Surface * CMapHandler : : terrainRect ( int x , int y , int dx , int dy , int level , unsigned char anim , PseudoV < PseudoV < PseudoV < unsigned char > > > & visibilityMap , bool otherHeroAnim , unsigned char heroAnim , SDL_Surface * extSurf , SDL_Rect * extRect )
2007-06-06 19:12:12 +03:00
{
2008-01-08 15:31:44 +02:00
if ( ! otherHeroAnim )
heroAnim = anim ; //the same, as it should be
2008-02-06 15:50:40 +02:00
2008-02-11 20:40:10 +02:00
//setting surface to blit at
SDL_Surface * su = NULL ; //blitting surface CSDL_Ext::newSurface(dx*32, dy*32, CSDL_Ext::std32bppSurface);
if ( extSurf )
{
su = extSurf ;
}
else
{
su = CSDL_Ext : : newSurface ( dx * 32 , dy * 32 , CSDL_Ext : : std32bppSurface ) ;
}
2008-06-11 04:53:57 +03:00
if ( ( ( dx + x ) > ( ( map - > width + Woff ) ) | | ( dy + y ) > ( ( map - > height + Hoff ) ) ) | | ( ( x < - Woff ) | | ( y < - Hoff ) ) )
2007-08-11 17:58:07 +03:00
throw new std : : string ( " terrainRect: out of range " ) ;
2007-06-27 23:17:58 +03:00
////printing terrain
2007-06-06 19:12:12 +03:00
for ( int bx = 0 ; bx < dx ; bx + + )
{
for ( int by = 0 ; by < dy ; by + + )
{
2007-09-13 16:34:59 +03:00
SDL_Rect sr ;
sr . y = by * 32 ;
sr . x = bx * 32 ;
sr . h = sr . w = 32 ;
2008-02-11 20:40:10 +02:00
validateRectTerr ( & sr , extRect ) ;
2008-02-12 19:40:01 +02:00
SDL_BlitSurface ( ttiles [ x + bx ] [ y + by ] [ level ] . terbitmap [ anim % ttiles [ x + bx ] [ y + by ] [ level ] . terbitmap . size ( ) ] , & genRect ( sr . h , sr . w , 0 , 0 ) , su , & sr ) ;
2007-06-27 23:17:58 +03:00
}
}
2007-07-31 16:09:34 +03:00
////terrain printed
////printing rivers
for ( int bx = 0 ; bx < dx ; bx + + )
{
for ( int by = 0 ; by < dy ; by + + )
{
2007-09-13 16:34:59 +03:00
SDL_Rect sr ;
sr . y = by * 32 ;
sr . x = bx * 32 ;
sr . h = sr . w = 32 ;
2008-02-11 20:40:10 +02:00
validateRectTerr ( & sr , extRect ) ;
2007-08-08 22:28:56 +03:00
if ( ttiles [ x + bx ] [ y + by ] [ level ] . rivbitmap . size ( ) )
2008-02-09 16:44:32 +02:00
{
2008-02-12 19:40:01 +02:00
CSDL_Ext : : blit8bppAlphaTo24bpp ( ttiles [ x + bx ] [ y + by ] [ level ] . rivbitmap [ anim % ttiles [ x + bx ] [ y + by ] [ level ] . rivbitmap . size ( ) ] , & genRect ( sr . h , sr . w , 0 , 0 ) , su , & sr ) ;
2008-02-09 16:44:32 +02:00
}
2007-07-31 16:09:34 +03:00
}
}
////rivers printed
////printing roads
for ( int bx = 0 ; bx < dx ; bx + + )
{
2007-08-23 20:38:00 +03:00
for ( int by = - 1 ; by < dy ; by + + )
2007-07-31 16:09:34 +03:00
{
2007-08-23 20:38:00 +03:00
if ( y + by < = - 4 )
continue ;
2007-09-13 16:34:59 +03:00
SDL_Rect sr ;
sr . y = by * 32 + 16 ;
sr . x = bx * 32 ;
sr . h = sr . w = 32 ;
2008-02-11 20:40:10 +02:00
validateRectTerr ( & sr , extRect ) ;
2007-08-08 22:28:56 +03:00
if ( ttiles [ x + bx ] [ y + by ] [ level ] . roadbitmap . size ( ) )
2008-02-10 19:44:51 +02:00
{
2008-02-12 19:40:01 +02:00
CSDL_Ext : : blit8bppAlphaTo24bpp ( ttiles [ x + bx ] [ y + by ] [ level ] . roadbitmap [ anim % ttiles [ x + bx ] [ y + by ] [ level ] . roadbitmap . size ( ) ] , & genRect ( sr . h , sr . w , 0 , ( by = = - 1 ? 16 : 0 ) ) , su , & sr ) ;
2008-02-10 19:44:51 +02:00
}
2007-07-31 16:09:34 +03:00
}
}
////roads printed
////printing objects
2007-08-09 19:28:01 +03:00
2007-08-17 20:42:21 +03:00
for ( int bx = 0 ; bx < dx ; bx + + )
2007-07-02 22:44:30 +03:00
{
2007-08-17 20:42:21 +03:00
for ( int by = 0 ; by < dy ; by + + )
2007-07-02 22:44:30 +03:00
{
2007-08-25 20:51:32 +03:00
for ( int h = 0 ; h < ttiles [ x + bx ] [ y + by ] [ level ] . objects . size ( ) ; + + h )
2007-07-07 14:09:25 +03:00
{
2007-09-13 16:34:59 +03:00
SDL_Rect sr ;
sr . w = 32 ;
sr . h = 32 ;
sr . x = ( bx ) * 32 ;
sr . y = ( by ) * 32 ;
2008-02-11 20:40:10 +02:00
validateRectTerr ( & sr , extRect ) ;
2007-07-07 15:28:15 +03:00
2008-02-10 19:44:51 +02:00
SDL_Rect pp = ttiles [ x + bx ] [ y + by ] [ level ] . objects [ h ] . second ;
2008-02-12 19:40:01 +02:00
pp . h = sr . h ;
pp . w = sr . w ;
2007-10-27 22:38:48 +03:00
CGHeroInstance * themp = ( dynamic_cast < CGHeroInstance * > ( ttiles [ x + bx ] [ y + by ] [ level ] . objects [ h ] . first ) ) ;
2008-02-09 16:44:32 +02:00
2008-01-08 18:08:25 +02:00
if ( themp & & themp - > moveDir & & ! themp - > isStanding & & themp - > ID ! = 62 ) //last condition - this is not prison
2007-09-15 21:04:12 +03:00
{
int imgVal = 8 ;
SDL_Surface * tb ;
2008-01-30 16:19:35 +02:00
2008-02-07 20:45:22 +02:00
if ( themp - > type = = NULL )
2008-01-30 16:19:35 +02:00
continue ;
2008-02-07 20:45:22 +02:00
std : : vector < Cimage > & iv = themp - > type - > heroClass - > moveAnim - > ourImages ;
2008-02-09 16:44:32 +02:00
int gg ;
for ( gg = 0 ; gg < iv . size ( ) ; + + gg )
2007-09-15 21:04:12 +03:00
{
2008-02-09 16:44:32 +02:00
if ( iv [ gg ] . groupNumber = = getHeroFrameNum ( themp - > moveDir , ! themp - > isStanding ) )
2007-09-15 21:04:12 +03:00
{
2008-02-09 16:44:32 +02:00
tb = iv [ gg + heroAnim % imgVal ] . bitmap ;
2007-10-08 21:47:23 +03:00
break ;
}
}
2008-02-10 19:44:51 +02:00
CSDL_Ext : : blit8bppAlphaTo24bpp ( tb , & pp , su , & sr ) ;
2008-02-09 16:44:32 +02:00
pp . y + = imgVal * 2 - 32 ;
sr . y - = 16 ;
2008-06-13 11:16:51 +03:00
SDL_BlitSurface ( graphics - > flags4 [ themp - > getOwner ( ) ] - > ourImages [ gg + heroAnim % imgVal + 35 ] . bitmap , & pp , su , & sr ) ;
2007-10-08 21:47:23 +03:00
}
2008-02-09 16:44:32 +02:00
else if ( themp & & themp - > moveDir & & themp - > isStanding & & themp - > ID ! = 62 ) //last condition - this is not prison)
2007-10-08 21:47:23 +03:00
{
int imgVal = 8 ;
SDL_Surface * tb ;
2008-01-30 16:19:35 +02:00
2008-02-07 20:45:22 +02:00
if ( themp - > type = = NULL )
2008-01-30 16:19:35 +02:00
continue ;
2008-02-07 20:45:22 +02:00
std : : vector < Cimage > & iv = themp - > type - > heroClass - > moveAnim - > ourImages ;
2008-02-09 16:44:32 +02:00
int gg ;
for ( gg = 0 ; gg < iv . size ( ) ; + + gg )
2007-10-08 21:47:23 +03:00
{
2008-02-09 16:44:32 +02:00
if ( iv [ gg ] . groupNumber = = getHeroFrameNum ( themp - > moveDir , ! themp - > isStanding ) )
2007-10-08 21:47:23 +03:00
{
2008-02-09 16:44:32 +02:00
tb = iv [ gg ] . bitmap ;
2007-09-15 21:04:12 +03:00
break ;
}
}
2008-02-10 19:44:51 +02:00
CSDL_Ext : : blit8bppAlphaTo24bpp ( tb , & pp , su , & sr ) ;
2008-02-09 16:44:32 +02:00
if ( themp - > pos . x = = x + bx & & themp - > pos . y = = y + by )
{
SDL_Rect bufr = sr ;
bufr . x - = 2 * 32 ;
bufr . y - = 1 * 32 ;
2008-02-26 20:01:26 +02:00
bufr . h = 64 ;
bufr . w = 96 ;
if ( bufr . x - extRect - > x > - 64 )
2008-06-13 11:16:51 +03:00
SDL_BlitSurface ( graphics - > flags4 [ themp - > getOwner ( ) ] - > ourImages [ getHeroFrameNum ( themp - > moveDir , ! themp - > isStanding ) * 8 + ( heroAnim / 4 ) % imgVal ] . bitmap , NULL , su , & bufr ) ;
2008-02-09 16:44:32 +02:00
themp - > flagPrinted = true ;
}
2007-09-15 21:04:12 +03:00
}
else
{
2007-10-27 22:38:48 +03:00
int imgVal = ttiles [ x + bx ] [ y + by ] [ level ] . objects [ h ] . first - > defInfo - > handler - > ourImages . size ( ) ;
2008-06-03 16:15:34 +03:00
int phaseShift = ttiles [ x + bx ] [ y + by ] [ level ] . objects [ h ] . first - > animPhaseShift ;
2008-02-10 19:44:51 +02:00
//setting appropriate flag color
2008-02-22 19:47:14 +02:00
if ( ( ttiles [ x + bx ] [ y + by ] [ level ] . objects [ h ] . first - > tempOwner > = 0 & & ttiles [ x + bx ] [ y + by ] [ level ] . objects [ h ] . first - > tempOwner < 8 ) | | ttiles [ x + bx ] [ y + by ] [ level ] . objects [ h ] . first - > tempOwner = = 255 )
2008-06-03 16:15:34 +03:00
CSDL_Ext : : setPlayerColor ( ttiles [ x + bx ] [ y + by ] [ level ] . objects [ h ] . first - > defInfo - > handler - > ourImages [ ( anim + phaseShift ) % imgVal ] . bitmap , ttiles [ x + bx ] [ y + by ] [ level ] . objects [ h ] . first - > tempOwner ) ;
2008-02-10 19:44:51 +02:00
2008-06-03 16:15:34 +03:00
CSDL_Ext : : blit8bppAlphaTo24bpp ( ttiles [ x + bx ] [ y + by ] [ level ] . objects [ h ] . first - > defInfo - > handler - > ourImages [ ( anim + phaseShift ) % imgVal ] . bitmap , & pp , su , & sr ) ;
2007-10-25 19:14:43 +03:00
}
2007-07-02 22:44:30 +03:00
}
}
}
2007-08-09 19:28:01 +03:00
2007-06-27 23:17:58 +03:00
////objects printed, printing shadow
for ( int bx = 0 ; bx < dx ; bx + + )
{
for ( int by = 0 ; by < dy ; by + + )
{
2007-09-13 16:34:59 +03:00
SDL_Rect sr ;
sr . y = by * 32 ;
sr . x = bx * 32 ;
sr . h = sr . w = 32 ;
2008-02-11 20:40:10 +02:00
validateRectTerr ( & sr , extRect ) ;
2008-02-09 16:44:32 +02:00
2008-06-11 04:53:57 +03:00
if ( bx + x > = 0 & & by + y > = 0 & & bx + x < CGI - > mh - > map - > width & & by + y < CGI - > mh - > map - > height & & ! visibilityMap [ bx + x ] [ by + y ] [ level ] )
2007-06-25 17:55:45 +03:00
{
2008-02-09 16:44:32 +02:00
SDL_Surface * hide = getVisBitmap ( bx + x , by + y , visibilityMap , level ) ;
2008-02-12 19:40:01 +02:00
CSDL_Ext : : blit8bppAlphaTo24bpp ( hide , & genRect ( sr . h , sr . w , 0 , 0 ) , su , & sr ) ;
2007-06-25 17:55:45 +03:00
}
2007-06-06 19:12:12 +03:00
}
}
2007-06-27 23:17:58 +03:00
////shadow printed
2007-07-07 19:04:15 +03:00
//printing borders
2007-08-17 20:42:21 +03:00
for ( int bx = 0 ; bx < dx ; bx + + )
2007-07-07 19:04:15 +03:00
{
2007-08-17 20:42:21 +03:00
for ( int by = 0 ; by < dy ; by + + )
2007-07-07 19:04:15 +03:00
{
2008-06-11 04:53:57 +03:00
if ( bx + x < 0 | | by + y < 0 | | bx + x > map - > width + ( - 1 ) | | by + y > map - > height + ( - 1 ) )
2007-07-07 19:04:15 +03:00
{
2007-09-13 16:34:59 +03:00
SDL_Rect sr ;
sr . y = by * 32 ;
sr . x = bx * 32 ;
sr . h = sr . w = 32 ;
2008-02-11 20:40:10 +02:00
validateRectTerr ( & sr , extRect ) ;
2007-08-08 22:28:56 +03:00
2008-02-12 19:40:01 +02:00
SDL_BlitSurface ( ttiles [ x + bx ] [ y + by ] [ level ] . terbitmap [ anim % ttiles [ x + bx ] [ y + by ] [ level ] . terbitmap . size ( ) ] , & genRect ( sr . h , sr . w , 0 , 0 ) , su , & sr ) ;
2007-08-11 17:58:07 +03:00
}
else
{
if ( MARK_BLOCKED_POSITIONS & & ttiles [ x + bx ] [ y + by ] [ level ] . blocked ) //temporary hiding blocked positions
{
2007-09-13 16:34:59 +03:00
SDL_Rect sr ;
sr . y = by * 32 ;
sr . x = bx * 32 ;
sr . h = sr . w = 32 ;
2008-02-11 20:40:10 +02:00
validateRectTerr ( & sr , extRect ) ;
2007-08-11 17:58:07 +03:00
2008-02-06 15:50:40 +02:00
SDL_Surface * ns = CSDL_Ext : : newSurface ( 32 , 32 , CSDL_Ext : : std32bppSurface ) ;
2007-08-11 17:58:07 +03:00
for ( int f = 0 ; f < ns - > w * ns - > h * 4 ; + + f )
{
* ( ( unsigned char * ) ( ns - > pixels ) + f ) = 128 ;
}
2008-02-12 19:40:01 +02:00
SDL_BlitSurface ( ns , & genRect ( sr . h , sr . w , 0 , 0 ) , su , & sr ) ;
2007-08-11 17:58:07 +03:00
SDL_FreeSurface ( ns ) ;
}
if ( MARK_VISITABLE_POSITIONS & & ttiles [ x + bx ] [ y + by ] [ level ] . visitable ) //temporary hiding visitable positions
{
2007-09-13 16:34:59 +03:00
SDL_Rect sr ;
sr . y = by * 32 ;
sr . x = bx * 32 ;
sr . h = sr . w = 32 ;
2008-02-11 20:40:10 +02:00
validateRectTerr ( & sr , extRect ) ;
2007-08-11 17:58:07 +03:00
2008-02-06 15:50:40 +02:00
SDL_Surface * ns = CSDL_Ext : : newSurface ( 32 , 32 , CSDL_Ext : : std32bppSurface ) ;
2007-08-11 17:58:07 +03:00
for ( int f = 0 ; f < ns - > w * ns - > h * 4 ; + + f )
{
* ( ( unsigned char * ) ( ns - > pixels ) + f ) = 128 ;
}
2008-02-12 19:40:01 +02:00
SDL_BlitSurface ( ns , & genRect ( sr . h , sr . w , 0 , 0 ) , su , & sr ) ;
2007-08-11 17:58:07 +03:00
SDL_FreeSurface ( ns ) ;
}
2007-07-07 19:04:15 +03:00
}
}
}
//borders printed
2007-06-06 19:12:12 +03:00
return su ;
}
2007-06-25 17:55:45 +03:00
SDL_Surface * CMapHandler : : terrBitmap ( int x , int y )
{
2007-08-08 22:28:56 +03:00
return ttiles [ x + Woff ] [ y + Hoff ] [ 0 ] . terbitmap [ 0 ] ;
2007-06-25 17:55:45 +03:00
}
SDL_Surface * CMapHandler : : undTerrBitmap ( int x , int y )
{
2007-08-08 22:28:56 +03:00
return ttiles [ x + Woff ] [ y + Hoff ] [ 0 ] . terbitmap [ 1 ] ;
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
SDL_Surface * CMapHandler : : getVisBitmap ( int x , int y , PseudoV < PseudoV < PseudoV < unsigned char > > > & visibilityMap , int lvl )
2007-06-25 17:55:45 +03:00
{
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-12-11 20:49:24 +02:00
return fullHide - > ourImages [ hideBitmap [ x ] [ y ] [ lvl ] ] . bitmap ; //fully hidden
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 22 ] . bitmap ; //visible right bottom corner
}
2007-10-17 23:05:49 +03:00
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 15 ] . bitmap ; //visible right top corner
}
2007-10-17 23:05:49 +03:00
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[22].bitmap); //visible left bottom corner
return partialHide - > ourImages [ 34 ] . bitmap ; //visible left bottom corner
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[15].bitmap); //visible left top corner
return partialHide - > ourImages [ 35 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-07-07 14:09:25 +03:00
//return partialHide->ourImages[rand()%2].bitmap; //visible top
return partialHide - > ourImages [ 0 ] . bitmap ; //visible top
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
else if ( visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-07-07 14:09:25 +03:00
//return partialHide->ourImages[4+rand()%2].bitmap; //visble bottom
return partialHide - > ourImages [ 4 ] . bitmap ; //visble bottom
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-07-07 14:09:25 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[2+rand()%2].bitmap); //visible left
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[2].bitmap); //visible left
return partialHide - > ourImages [ 36 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-07-07 14:09:25 +03:00
//return partialHide->ourImages[2+rand()%2].bitmap; //visible right
return partialHide - > ourImages [ 2 ] . bitmap ; //visible right
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
else if ( visibilityMap [ x ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-07-07 14:09:25 +03:00
//return partialHide->ourImages[12+2*(rand()%2)].bitmap; //visible bottom, right - bottom, right; left top corner hidden
return partialHide - > ourImages [ 12 ] . bitmap ; //visible bottom, right - bottom, right; left top corner hidden
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 13 ] . bitmap ; //visible right, right - top; left bottom corner hidden
}
2007-10-17 23:05:49 +03:00
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & visibilityMap [ x - 1 ] [ y ] [ lvl ] & & visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[13].bitmap); //visible top, top - left, left; right bottom corner hidden
return partialHide - > ourImages [ 37 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
else if ( visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-07-07 14:09:25 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[12+2*(rand()%2)].bitmap); //visible left, left - bottom, bottom; right top corner hidden
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[12].bitmap); //visible left, left - bottom, bottom; right top corner hidden
return partialHide - > ourImages [ 38 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2008-03-10 22:19:41 +02:00
else if ( visibilityMap [ x ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y ] [ lvl ] & & visibilityMap [ x - 1 ] [ y ] [ lvl ] & & visibilityMap [ x ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 10 ] . bitmap ; //visible left, right, bottom and top
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 16 ] . bitmap ; //visible right corners
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 18 ] . bitmap ; //visible top corners
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[16].bitmap); //visible left corners
return partialHide - > ourImages [ 39 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::hFlip(partialHide->ourImages[18].bitmap); //visible bottom corners
return partialHide - > ourImages [ 40 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 17 ] . bitmap ; //visible right - top and bottom - left corners
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::hFlip(partialHide->ourImages[17].bitmap); //visible top - left and bottom - right corners
return partialHide - > ourImages [ 41 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 19 ] . bitmap ; //visible corners without left top
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 20 ] . bitmap ; //visible corners without left bottom
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[20].bitmap); //visible corners without right bottom
return partialHide - > ourImages [ 42 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[19].bitmap); //visible corners without right top
return partialHide - > ourImages [ 43 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 21 ] . bitmap ; //visible all corners only
}
2007-10-17 23:05:49 +03:00
if ( visibilityMap [ x ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y ] [ lvl ] & & visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 6 ] . bitmap ; //hidden top
}
2007-10-17 23:05:49 +03:00
if ( visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & visibilityMap [ x - 1 ] [ y ] [ lvl ] & & visibilityMap [ x ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 7 ] . bitmap ; //hidden right
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y ] [ lvl ] & & visibilityMap [ x - 1 ] [ y ] [ lvl ] & & visibilityMap [ x ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 8 ] . bitmap ; //hidden bottom
}
2007-10-17 23:05:49 +03:00
if ( visibilityMap [ x ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & visibilityMap [ x ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[7].bitmap); //hidden left
return partialHide - > ourImages [ 44 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2007-10-20 15:07:15 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y ] [ lvl ] & & visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 9 ] . bitmap ; //hidden top and bottom
}
2007-10-20 15:07:15 +03:00
if ( visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & visibilityMap [ x ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 29 ] . bitmap ; //hidden left and right
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 24 ] . bitmap ; //visible top and right bottom corner
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[24].bitmap); //visible top and left bottom corner
return partialHide - > ourImages [ 45 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 33 ] . bitmap ; //visible top and bottom corners
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[26].bitmap); //visible left and right top corner
return partialHide - > ourImages [ 46 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[25].bitmap); //visible left and right bottom corner
return partialHide - > ourImages [ 47 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 32 ] . bitmap ; //visible left and right corners
}
2007-10-17 23:05:49 +03:00
if ( visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[30].bitmap); //visible bottom and left top corner
return partialHide - > ourImages [ 48 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
if ( visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 30 ] . bitmap ; //visible bottom and right top corner
}
2007-10-17 23:05:49 +03:00
if ( visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 31 ] . bitmap ; //visible bottom and top corners
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 25 ] . bitmap ; //visible right and left bottom corner
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 26 ] . bitmap ; //visible right and left top corner
}
2007-10-17 23:05:49 +03:00
if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[32].bitmap); //visible right and left cornres
return partialHide - > ourImages [ 49 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
if ( visibilityMap [ x ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 28 ] . bitmap ; //visible bottom, right - bottom, right; left top corner visible
}
2007-10-17 23:05:49 +03:00
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
return partialHide - > ourImages [ 27 ] . bitmap ; //visible right, right - top; left bottom corner visible
}
2007-10-17 23:05:49 +03:00
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & visibilityMap [ x - 1 ] [ y ] [ lvl ] & & visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[27].bitmap); //visible top, top - left, left; right bottom corner visible
return partialHide - > ourImages [ 50 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2007-10-17 23:05:49 +03:00
else if ( visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] )
2007-06-25 17:55:45 +03:00
{
2007-10-18 23:14:26 +03:00
//return CSDL_Ext::rotate01(partialHide->ourImages[28].bitmap); //visible left, left - bottom, bottom; right top corner visible
return partialHide - > ourImages [ 51 ] . bitmap ;
2007-06-25 17:55:45 +03:00
}
2007-10-19 20:47:28 +03:00
//newly added
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] ) //visible t and tr
{
return partialHide - > ourImages [ 0 ] . bitmap ;
}
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] ) //visible t and tl
{
return partialHide - > ourImages [ 1 ] . bitmap ;
}
else if ( visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] ) //visible b and br
{
return partialHide - > ourImages [ 4 ] . bitmap ;
}
else if ( visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] ) //visible b and bl
{
return partialHide - > ourImages [ 5 ] . bitmap ;
}
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] ) //visible l and tl
{
return partialHide - > ourImages [ 36 ] . bitmap ;
}
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y ] [ lvl ] & & visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] ) //visible l and bl
{
return partialHide - > ourImages [ 36 ] . bitmap ;
}
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] ) //visible r and tr
{
return partialHide - > ourImages [ 2 ] . bitmap ;
}
else if ( ! visibilityMap [ x ] [ y + 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y ] [ lvl ] & & ! visibilityMap [ x ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y - 1 ] [ lvl ] & & visibilityMap [ x + 1 ] [ y + 1 ] [ lvl ] & & ! visibilityMap [ x + 1 ] [ y - 1 ] [ lvl ] & & ! visibilityMap [ x - 1 ] [ y + 1 ] [ lvl ] ) //visible r and br
{
return partialHide - > ourImages [ 3 ] . bitmap ;
}
2007-06-25 17:55:45 +03:00
return fullHide - > ourImages [ 0 ] . bitmap ; //this case should never happen, but it is better to hide too much than reveal it....
}
2007-06-26 15:38:58 +03:00
2007-10-27 22:38:48 +03:00
int CMapHandler : : getCost ( int3 & a , int3 & b , const CGHeroInstance * hero )
2007-08-12 20:48:05 +03:00
{
2007-11-03 18:46:08 +02:00
int ret = - 1 ;
2008-06-11 04:53:57 +03:00
if ( a . x > = CGI - > mh - > map - > width & & a . y > = CGI - > mh - > map - > height )
ret = hero - > type - > heroClass - > terrCosts [ CGI - > mh - > ttiles [ CGI - > mh - > map - > width - 1 ] [ CGI - > mh - > map - > width - 1 ] [ a . z ] . malle ] ;
else if ( a . x > = CGI - > mh - > map - > width & & a . y < CGI - > mh - > map - > height )
ret = hero - > type - > heroClass - > terrCosts [ CGI - > mh - > ttiles [ CGI - > mh - > map - > width - 1 ] [ a . y ] [ a . z ] . malle ] ;
else if ( a . x < CGI - > mh - > map - > width & & a . y > = CGI - > mh - > map - > height )
ret = hero - > type - > heroClass - > terrCosts [ CGI - > mh - > ttiles [ a . x ] [ CGI - > mh - > map - > width - 1 ] [ a . z ] . malle ] ;
2007-11-03 18:46:08 +02:00
else
ret = hero - > type - > heroClass - > terrCosts [ CGI - > mh - > ttiles [ a . x ] [ a . y ] [ a . z ] . malle ] ;
2007-08-15 18:13:11 +03:00
if ( ! ( a . x = = b . x | | a . y = = b . y ) )
2007-09-15 21:04:12 +03:00
ret * = 1.41421 ;
2007-08-12 20:48:05 +03:00
2007-08-15 18:13:11 +03:00
//TODO: use hero's pathfinding skill during calculating cost
return ret ;
2007-09-15 21:04:12 +03:00
}
2007-10-05 21:10:33 +03:00
std : : vector < std : : string > CMapHandler : : getObjDescriptions ( int3 pos )
{
2008-02-10 19:44:51 +02:00
std : : vector < std : : pair < CGObjectInstance * , SDL_Rect > > objs = ttiles [ pos . x ] [ pos . y ] [ pos . z ] . objects ;
2007-10-05 21:10:33 +03:00
std : : vector < std : : string > ret ;
for ( int g = 0 ; g < objs . size ( ) ; + + g )
{
2007-11-19 00:58:28 +02:00
if ( ( 5 - ( objs [ g ] . first - > pos . y - pos . y ) ) > = 0 & & ( 5 - ( objs [ g ] . first - > pos . y - pos . y ) ) < 6 & & ( objs [ g ] . first - > pos . x - pos . x ) > = 0 & & ( objs [ g ] . first - > pos . x - pos . x ) < 7 & & objs [ g ] . first - > defInfo & &
( ( ( objs [ g ] . first - > defInfo - > blockMap [ 5 - ( objs [ g ] . first - > pos . y - pos . y ) ] ) > > ( ( objs [ g ] . first - > pos . x - pos . x ) ) ) & 1 ) = = 0
2007-10-05 21:10:33 +03:00
) //checking position blocking
{
2007-11-19 00:58:28 +02:00
//unsigned char * blm = objs[g].first->defInfo->blockMap;
if ( objs [ g ] . first - > state )
ret . push_back ( objs [ g ] . first - > state - > hoverText ( objs [ g ] . first ) ) ;
else
2008-02-05 05:56:45 +02:00
ret . push_back ( CGI - > objh - > objects [ objs [ g ] . first - > ID ] . name ) ;
2007-10-05 21:10:33 +03:00
}
}
return ret ;
}
2007-10-26 20:55:33 +03:00
2007-10-27 22:38:48 +03:00
std : : vector < CGObjectInstance * > CMapHandler : : getVisitableObjs ( int3 pos )
2007-10-26 20:55:33 +03:00
{
2007-10-27 22:38:48 +03:00
std : : vector < CGObjectInstance * > ret ;
2007-10-26 20:55:33 +03:00
for ( int h = 0 ; h < ttiles [ pos . x ] [ pos . y ] [ pos . z ] . objects . size ( ) ; + + h )
{
2007-10-27 22:38:48 +03:00
CGObjectInstance * curi = ttiles [ pos . x ] [ pos . y ] [ pos . z ] . objects [ h ] . first ;
if ( curi - > visitableAt ( - curi - > pos . x + pos . x + curi - > getWidth ( ) - 1 , - curi - > pos . y + pos . y + curi - > getHeight ( ) - 1 ) )
2007-10-26 20:55:33 +03:00
ret . push_back ( curi ) ;
}
return ret ;
}
2007-11-03 18:46:08 +02:00
2008-02-07 20:45:22 +02:00
CGObjectInstance * CMapHandler : : createObject ( int id , int subid , int3 pos , int owner )
2007-11-03 18:46:08 +02:00
{
CGObjectInstance * nobj ;
switch ( id )
{
2008-02-07 20:45:22 +02:00
case 34 : //hero
{
CGHeroInstance * nobj ;
nobj = new CGHeroInstance ( ) ;
nobj - > pos = pos ;
nobj - > tempOwner = owner ;
nobj - > defInfo = new CGDefInfo ( ) ;
nobj - > defInfo - > id = 34 ;
nobj - > defInfo - > subid = subid ;
2008-02-23 21:20:41 +02:00
nobj - > defInfo - > printPriority = 0 ;
2008-02-07 20:45:22 +02:00
nobj - > type = CGI - > heroh - > heroes [ subid ] ;
for ( int i = 0 ; i < 6 ; i + + )
{
2008-02-10 11:35:52 +02:00
nobj - > defInfo - > blockMap [ i ] = 255 ;
2008-02-07 20:45:22 +02:00
nobj - > defInfo - > visitMap [ i ] = 0 ;
}
nobj - > ID = id ;
nobj - > subID = subid ;
nobj - > defInfo - > handler = NULL ;
2008-02-10 11:35:52 +02:00
nobj - > defInfo - > blockMap [ 5 ] = 253 ;
nobj - > defInfo - > visitMap [ 5 ] = 2 ;
2008-02-07 20:45:22 +02:00
nobj - > artifacts . resize ( 20 ) ;
2008-06-08 03:58:29 +03:00
nobj - > artifWorn [ 16 ] = 3 ;
2008-02-10 17:43:11 +02:00
nobj - > primSkills . resize ( 4 ) ;
nobj - > primSkills [ 0 ] = nobj - > type - > heroClass - > initialAttack ;
nobj - > primSkills [ 1 ] = nobj - > type - > heroClass - > initialDefence ;
nobj - > primSkills [ 2 ] = nobj - > type - > heroClass - > initialPower ;
nobj - > primSkills [ 3 ] = nobj - > type - > heroClass - > initialKnowledge ;
nobj - > mana = 10 * nobj - > primSkills [ 3 ] ;
2008-02-07 20:45:22 +02:00
return nobj ;
}
2007-11-03 18:46:08 +02:00
case 98 : //town
nobj = new CGTownInstance ;
break ;
default : //rest of objects
nobj = new CGObjectInstance ;
2008-02-07 20:45:22 +02:00
nobj - > defInfo = CGI - > dobjinfo - > gobjs [ id ] [ subid ] ;
2007-11-03 18:46:08 +02:00
break ;
}
nobj - > ID = id ;
nobj - > subID = subid ;
2008-02-05 05:56:45 +02:00
if ( ! nobj - > defInfo )
std : : cout < < " No def declaration for " < < id < < " " < < subid < < std : : endl ;
2007-11-03 18:46:08 +02:00
nobj - > pos = pos ;
2007-11-19 00:58:28 +02:00
//nobj->state = NULL;//new CLuaObjectScript();
2008-02-07 20:45:22 +02:00
nobj - > tempOwner = owner ;
2007-11-03 18:46:08 +02:00
nobj - > info = NULL ;
nobj - > defInfo - > id = id ;
nobj - > defInfo - > subid = subid ;
//assigning defhandler
2008-02-07 20:45:22 +02:00
if ( nobj - > ID = = 34 | | nobj - > ID = = 98 )
return nobj ;
nobj - > defInfo = CGI - > dobjinfo - > gobjs [ id ] [ subid ] ;
if ( ! nobj - > defInfo - > handler )
2008-06-17 20:48:32 +03:00
{
2008-06-12 09:45:51 +03:00
nobj - > defInfo - > handler = CDefHandler : : giveDef ( nobj - > defInfo - > name ) ;
2008-06-17 20:48:32 +03:00
nobj - > defInfo - > width = nobj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > w / 32 ;
nobj - > defInfo - > height = nobj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > h / 32 ;
}
2007-11-03 18:46:08 +02:00
return nobj ;
}
std : : string CMapHandler : : getDefName ( int id , int subid )
{
2008-02-05 05:56:45 +02:00
CGDefInfo * temp = CGI - > dobjinfo - > gobjs [ id ] [ subid ] ;
if ( temp )
return temp - > name ;
2007-11-24 00:33:55 +02:00
throw new std : : exception ( " Def not found. " ) ;
2007-11-03 18:46:08 +02:00
}
bool CMapHandler : : printObject ( CGObjectInstance * obj )
{
CDefHandler * curd = obj - > defInfo - > handler ;
for ( int fx = 0 ; fx < curd - > ourImages [ 0 ] . bitmap - > w / 32 ; + + fx )
{
for ( int fy = 0 ; fy < curd - > ourImages [ 0 ] . bitmap - > h / 32 ; + + fy )
{
SDL_Rect cr ;
cr . w = 32 ;
cr . h = 32 ;
cr . x = fx * 32 ;
cr . y = fy * 32 ;
2008-02-10 19:44:51 +02:00
std : : pair < CGObjectInstance * , SDL_Rect > toAdd = std : : make_pair ( obj , cr ) ;
2007-11-03 18:46:08 +02:00
if ( ( obj - > pos . x + fx - curd - > ourImages [ 0 ] . bitmap - > w / 32 + 1 ) > = 0 & & ( obj - > pos . x + fx - curd - > ourImages [ 0 ] . bitmap - > w / 32 + 1 ) < ttiles . size ( ) - Woff & & ( obj - > pos . y + fy - curd - > ourImages [ 0 ] . bitmap - > h / 32 + 1 ) > = 0 & & ( obj - > pos . y + fy - curd - > ourImages [ 0 ] . bitmap - > h / 32 + 1 ) < ttiles [ 0 ] . size ( ) - Hoff )
{
TerrainTile2 & curt =
ttiles
[ obj - > pos . x + fx - curd - > ourImages [ 0 ] . bitmap - > w / 32 ]
[ obj - > pos . y + fy - curd - > ourImages [ 0 ] . bitmap - > h / 32 ]
[ obj - > pos . z ] ;
ttiles [ obj - > pos . x + fx - curd - > ourImages [ 0 ] . bitmap - > w / 32 + 1 ] [ obj - > pos . y + fy - curd - > ourImages [ 0 ] . bitmap - > h / 32 + 1 ] [ obj - > pos . z ] . objects . push_back ( toAdd ) ;
}
} // for(int fy=0; fy<curd->ourImages[0].bitmap->h/32; ++fy)
} //for(int fx=0; fx<curd->ourImages[0].bitmap->w/32; ++fx)
return true ;
}
bool CMapHandler : : hideObject ( CGObjectInstance * obj )
{
CDefHandler * curd = obj - > defInfo - > handler ;
for ( int fx = 0 ; fx < curd - > ourImages [ 0 ] . bitmap - > w / 32 ; + + fx )
{
for ( int fy = 0 ; fy < curd - > ourImages [ 0 ] . bitmap - > h / 32 ; + + fy )
{
if ( ( obj - > pos . x + fx - curd - > ourImages [ 0 ] . bitmap - > w / 32 + 1 ) > = 0 & & ( obj - > pos . x + fx - curd - > ourImages [ 0 ] . bitmap - > w / 32 + 1 ) < ttiles . size ( ) - Woff & & ( obj - > pos . y + fy - curd - > ourImages [ 0 ] . bitmap - > h / 32 + 1 ) > = 0 & & ( obj - > pos . y + fy - curd - > ourImages [ 0 ] . bitmap - > h / 32 + 1 ) < ttiles [ 0 ] . size ( ) - Hoff )
{
2008-02-10 19:44:51 +02:00
std : : vector < std : : pair < CGObjectInstance * , SDL_Rect > > & ctile = ttiles [ obj - > pos . x + fx - curd - > ourImages [ 0 ] . bitmap - > w / 32 + 1 ] [ obj - > pos . y + fy - curd - > ourImages [ 0 ] . bitmap - > h / 32 + 1 ] [ obj - > pos . z ] . objects ;
2007-11-03 18:46:08 +02:00
for ( int dd = 0 ; dd < ctile . size ( ) ; + + dd )
{
if ( ctile [ dd ] . first - > id = = obj - > id )
ctile . erase ( ctile . begin ( ) + dd ) ;
}
}
} // for(int fy=0; fy<curd->ourImages[0].bitmap->h/32; ++fy)
} //for(int fx=0; fx<curd->ourImages[0].bitmap->w/32; ++fx)
return true ;
2007-11-20 19:52:22 +02:00
}
std : : string CMapHandler : : getRandomizedDefName ( CGDefInfo * di , CGObjectInstance * obj )
{
return std : : string ( ) ;
}
2007-11-24 20:54:34 +02:00
bool CMapHandler : : removeObject ( CGObjectInstance * obj )
{
hideObject ( obj ) ;
2008-06-11 04:53:57 +03:00
std : : vector < CGObjectInstance * > : : iterator db = std : : find ( map - > objects . begin ( ) , map - > objects . end ( ) , obj ) ;
2007-11-25 20:32:11 +02:00
recalculateHideVisPosUnderObj ( * db ) ;
delete * db ;
2008-06-11 04:53:57 +03:00
map - > objects . erase ( db ) ;
2007-11-25 20:32:11 +02:00
return true ;
}
bool CMapHandler : : recalculateHideVisPos ( int3 & pos )
{
ttiles [ pos . x ] [ pos . y ] [ pos . z ] . visitable = false ;
ttiles [ pos . x ] [ pos . y ] [ pos . z ] . blocked = false ;
for ( int i = 0 ; i < ttiles [ pos . x ] [ pos . y ] [ pos . z ] . objects . size ( ) ; + + i )
{
CDefHandler * curd = ttiles [ pos . x ] [ pos . y ] [ pos . z ] . objects [ i ] . first - > defInfo - > handler ;
for ( int fx = 0 ; fx < 8 ; + + fx )
{
for ( int fy = 0 ; fy < 6 ; + + fy )
{
int xVal = ttiles [ pos . x ] [ pos . y ] [ pos . z ] . objects [ i ] . first - > pos . x + fx - 7 ;
int yVal = ttiles [ pos . x ] [ pos . y ] [ pos . z ] . objects [ i ] . first - > pos . y + fy - 5 ;
int zVal = ttiles [ pos . x ] [ pos . y ] [ pos . z ] . objects [ i ] . first - > pos . z ;
if ( xVal > = 0 & & xVal < ttiles . size ( ) - Woff & & yVal > = 0 & & yVal < ttiles [ 0 ] . size ( ) - Hoff )
{
TerrainTile2 & curt = ttiles [ xVal ] [ yVal ] [ zVal ] ;
if ( ( ( ttiles [ pos . x ] [ pos . y ] [ pos . z ] . objects [ i ] . first - > defInfo - > visitMap [ fy ] > > ( 7 - fx ) ) & 1 ) )
curt . visitable = true ;
if ( ! ( ( ttiles [ pos . x ] [ pos . y ] [ pos . z ] . objects [ i ] . first - > defInfo - > blockMap [ fy ] > > ( 7 - fx ) ) & 1 ) )
curt . blocked = true ;
}
}
}
}
return true ;
}
2007-11-29 20:45:47 +02:00
bool CMapHandler : : recalculateHideVisPosUnderObj ( CGObjectInstance * obj , bool withBorder )
2007-11-25 20:32:11 +02:00
{
2007-11-29 20:45:47 +02:00
if ( withBorder )
2007-11-25 20:32:11 +02:00
{
2007-11-29 20:45:47 +02:00
for ( int fx = - 1 ; fx < = obj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > w / 32 ; + + fx )
2007-11-25 20:32:11 +02:00
{
2007-11-29 20:45:47 +02:00
for ( int fy = - 1 ; fy < = obj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > h / 32 ; + + fy )
2007-11-25 20:32:11 +02:00
{
2007-11-29 20:45:47 +02:00
if ( ( obj - > pos . x + fx - obj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > w / 32 + 1 ) > = 0 & & ( obj - > pos . x + fx - obj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > w / 32 + 1 ) < ttiles . size ( ) - Woff & & ( obj - > pos . y + fy - obj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > h / 32 + 1 ) > = 0 & & ( obj - > pos . y + fy - obj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > h / 32 + 1 ) < ttiles [ 0 ] . size ( ) - Hoff )
{
recalculateHideVisPos ( int3 ( obj - > pos . x + fx - obj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > w / 32 + 1 , obj - > pos . y + fy - obj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > h / 32 + 1 , obj - > pos . z ) ) ;
}
}
}
}
else
{
for ( int fx = 0 ; fx < obj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > w / 32 ; + + fx )
{
for ( int fy = 0 ; fy < obj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > h / 32 ; + + fy )
{
if ( ( obj - > pos . x + fx - obj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > w / 32 + 1 ) > = 0 & & ( obj - > pos . x + fx - obj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > w / 32 + 1 ) < ttiles . size ( ) - Woff & & ( obj - > pos . y + fy - obj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > h / 32 + 1 ) > = 0 & & ( obj - > pos . y + fy - obj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > h / 32 + 1 ) < ttiles [ 0 ] . size ( ) - Hoff )
{
recalculateHideVisPos ( int3 ( obj - > pos . x + fx - obj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > w / 32 + 1 , obj - > pos . y + fy - obj - > defInfo - > handler - > ourImages [ 0 ] . bitmap - > h / 32 + 1 , obj - > pos . z ) ) ;
}
2007-11-25 20:32:11 +02:00
}
}
}
2007-11-24 20:54:34 +02:00
return true ;
}
2008-02-09 16:44:32 +02:00
unsigned char CMapHandler : : getHeroFrameNum ( const unsigned char & dir , const bool & isMoving ) const
{
if ( isMoving )
{
switch ( dir )
{
case 1 :
return 10 ;
case 2 :
return 5 ;
case 3 :
return 6 ;
case 4 :
return 7 ;
case 5 :
return 8 ;
case 6 :
return 9 ;
case 7 :
return 12 ;
case 8 :
return 11 ;
default :
return - 1 ; //should never happen
}
}
else //if(isMoving)
{
switch ( dir )
{
case 1 :
return 13 ;
case 2 :
return 0 ;
case 3 :
return 1 ;
case 4 :
return 2 ;
case 5 :
return 3 ;
case 6 :
return 4 ;
case 7 :
return 15 ;
case 8 :
return 14 ;
default :
return - 1 ; //should never happen
}
}
2008-02-11 20:40:10 +02:00
}
void CMapHandler : : validateRectTerr ( SDL_Rect * val , const SDL_Rect * ext )
{
if ( ext )
{
if ( val - > x < 0 )
{
val - > w + = val - > x ;
val - > x = ext - > x ;
}
else
{
val - > x + = ext - > x ;
}
if ( val - > y < 0 )
{
val - > h + = val - > y ;
val - > y = ext - > y ;
}
else
{
val - > y + = ext - > y ;
}
if ( val - > x + val - > w > ext - > x + ext - > w )
{
val - > w = ext - > x + ext - > w - val - > x ;
}
if ( val - > y + val - > h > ext - > y + ext - > h )
{
val - > h = ext - > y + ext - > h - val - > y ;
}
2008-02-12 19:40:01 +02:00
//for sign problems
if ( val - > h > 20000 | | val - > w > 20000 )
{
val - > h = val - > w = 0 ;
}
2008-02-11 20:40:10 +02:00
}
}
2008-02-17 21:04:27 +02:00
unsigned char CMapHandler : : getDir ( const int3 & a , const int3 & b )
{
if ( a . z ! = b . z )
return - 1 ; //error!
if ( a . x = = b . x + 1 & & a . y = = b . y + 1 ) //lt
{
return 0 ;
}
else if ( a . x = = b . x & & a . y = = b . y + 1 ) //t
{
return 1 ;
}
else if ( a . x = = b . x - 1 & & a . y = = b . y + 1 ) //rt
{
return 2 ;
}
else if ( a . x = = b . x - 1 & & a . y = = b . y ) //r
{
return 3 ;
}
else if ( a . x = = b . x - 1 & & a . y = = b . y - 1 ) //rb
{
return 4 ;
}
else if ( a . x = = b . x & & a . y = = b . y - 1 ) //b
{
return 5 ;
}
else if ( a . x = = b . x + 1 & & a . y = = b . y - 1 ) //lb
{
return 6 ;
}
else if ( a . x = = b . x + 1 & & a . y = = b . y ) //l
{
return 7 ;
}
2008-02-22 17:47:01 +02:00
return - 2 ; //shouldn't happen
2008-02-17 21:04:27 +02:00
}
2008-06-07 20:16:52 +03:00
void CMapHandler : : loadDefs ( )
{
std : : set < int > loadedTypes ;
2008-06-11 04:53:57 +03:00
for ( int i = 0 ; i < map - > width ; i + + )
2008-06-07 20:16:52 +03:00
{
2008-06-11 04:53:57 +03:00
for ( int j = 0 ; j < map - > width ; j + + )
2008-06-07 20:16:52 +03:00
{
2008-06-11 04:53:57 +03:00
if ( loadedTypes . find ( map - > terrain [ i ] [ j ] . tertype ) = = loadedTypes . end ( ) )
2008-06-07 20:16:52 +03:00
{
2008-06-12 09:45:51 +03:00
CDefHandler * sdh = CDefHandler : : giveDef ( nameFromType ( map - > terrain [ i ] [ j ] . tertype ) . c_str ( ) ) ;
2008-06-11 04:53:57 +03:00
loadedTypes . insert ( map - > terrain [ i ] [ j ] . tertype ) ;
2008-06-07 20:16:52 +03:00
defs . push_back ( sdh ) ;
}
2008-06-11 04:53:57 +03:00
if ( map - > twoLevel & & loadedTypes . find ( map - > undergroungTerrain [ i ] [ j ] . tertype ) = = loadedTypes . end ( ) )
2008-06-07 20:16:52 +03:00
{
2008-06-12 09:45:51 +03:00
CDefHandler * sdh = CDefHandler : : giveDef ( nameFromType ( map - > undergroungTerrain [ i ] [ j ] . tertype ) . c_str ( ) ) ;
2008-06-11 04:53:57 +03:00
loadedTypes . insert ( map - > undergroungTerrain [ i ] [ j ] . tertype ) ;
2008-06-07 20:16:52 +03:00
defs . push_back ( sdh ) ;
}
}
}
}