mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	* displaying roads and static rivers
* small bugfix in reading map * small bugfix in lod handler * small upgrade in def handler (should work a bit faster and better)
This commit is contained in:
		| @@ -564,7 +564,11 @@ void CAmbarCendamo::deh3m() | ||||
| 				spec->bytes[2] = bufor[i]; ++i; | ||||
| 				spec->bytes[3] = bufor[i]; ++i; | ||||
| 				spec->player = bufor[i]; ++i; | ||||
| 				spec->type = CGameInfo::mainObj->heroh->heroes[readNormalNr(i, 1)]; ++i; | ||||
| 				int typeBuf = readNormalNr(i, 1); ++i; | ||||
| 				if(typeBuf==0xff) | ||||
| 					spec->type = NULL; | ||||
| 				else | ||||
| 					spec->type = CGameInfo::mainObj->heroh->heroes[typeBuf]; | ||||
| 				bool isName = bufor[i]; ++i; //true if hero has nonstandard name | ||||
| 				if(isName) | ||||
| 				{ | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								CDefHandler.cpp
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								CDefHandler.cpp
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -385,6 +385,7 @@ int CLodHandler::infm(FILE *source, FILE *dest, int wBits) | ||||
| } | ||||
| CDefHandler * CLodHandler::giveDef(std::string defName)  | ||||
| { | ||||
| 	std::transform(defName.begin(), defName.end(), defName.begin(), (int(*)(int))toupper); | ||||
| 	Entry * ourEntry = entries.znajdz(Entry(defName)); | ||||
| 	CDefHandler * ret; | ||||
| 	FLOD.seekg(ourEntry->offset,std::ios_base::beg); | ||||
|   | ||||
							
								
								
									
										2
									
								
								global.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								global.h
									
									
									
									
									
								
							| @@ -10,7 +10,7 @@ | ||||
| #endif | ||||
| enum Ecolor {RED, BLUE, TAN, GREEN, ORANGE, PURPLE, TEAL, PINK}; | ||||
| enum EterrainType {dirt, sand, grass, snow, swamp, rough, subterranean, lava, water, rock}; | ||||
| enum Eriver {clearRiver=1, icyRiver, muddyRiver, lavaRiver}; | ||||
| enum Eriver {noRiver=0, clearRiver, icyRiver, muddyRiver, lavaRiver}; | ||||
| enum Eroad {dirtRoad=1, grazvelRoad, cobblestoneRoad}; | ||||
| enum Eformat { WoG=0x33, AB=0x15, RoE=0x0e,  SoD=0x1c}; | ||||
| enum EvictoryConditions {artifact, gatherTroop, gatherResource, buildCity, buildGrail, beatHero,  | ||||
|   | ||||
							
								
								
									
										371
									
								
								mapHandler.cpp
									
									
									
									
									
								
							
							
						
						
									
										371
									
								
								mapHandler.cpp
									
									
									
									
									
								
							| @@ -75,7 +75,327 @@ void CMapHandler::init() | ||||
| 	visibility[7][6] = false; | ||||
| 	visibility[6][9] = false; | ||||
|  | ||||
| 	terrainBitmap = new SDL_Surface **[reader->map.width+8]; | ||||
|  | ||||
| 	//initializing road's and river's DefHandlers | ||||
|  | ||||
| #if SDL_BYTEORDER == SDL_BIG_ENDIAN | ||||
|     int rmask = 0xff000000; | ||||
|     int gmask = 0x00ff0000; | ||||
|     int bmask = 0x0000ff00; | ||||
|     int amask = 0x000000ff; | ||||
| #else | ||||
|     int rmask = 0x000000ff; | ||||
|     int gmask = 0x0000ff00; | ||||
|     int bmask = 0x00ff0000; | ||||
|     int amask = 0xff000000; | ||||
| #endif | ||||
|  | ||||
| 	SDL_Surface * su = SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, | ||||
|                                    rmask, gmask, bmask, amask); | ||||
|  | ||||
| 	roadDefs.push_back(CGameInfo::mainObj->spriteh->giveDef("dirtrd.def")); | ||||
| 	roadDefs.push_back(CGameInfo::mainObj->spriteh->giveDef("gravrd.def")); | ||||
| 	roadDefs.push_back(CGameInfo::mainObj->spriteh->giveDef("cobbrd.def")); | ||||
| 	staticRiverDefs.push_back(CGameInfo::mainObj->spriteh->giveDef("clrrvr.def")); | ||||
| 	staticRiverDefs.push_back(CGameInfo::mainObj->spriteh->giveDef("icyrvr.def")); | ||||
| 	staticRiverDefs.push_back(CGameInfo::mainObj->spriteh->giveDef("mudrvr.def")); | ||||
| 	staticRiverDefs.push_back(CGameInfo::mainObj->spriteh->giveDef("lavrvr.def")); | ||||
|  | ||||
| 	roadBitmaps = new SDL_Surface **[reader->map.width+2*Woff]; | ||||
| 	for (int ii=0;ii<reader->map.width+2*Woff;ii++) | ||||
| 		roadBitmaps[ii] = new SDL_Surface*[reader->map.height+2*Hoff]; // allocate memory  | ||||
|  | ||||
| 	for (int i=0; i<reader->map.width+2*Woff; i++) //jest po szeroko�ci | ||||
| 	{ | ||||
| 		for (int j=0; j<reader->map.height+2*Hoff;j++) //po wysoko�ci | ||||
| 		{ | ||||
| 			if(i<Woff || i>reader->map.width+Woff-1 || j<Woff || j>reader->map.height+Hoff-1) | ||||
| 				roadBitmaps[i][j] = NULL; | ||||
| 			else | ||||
| 			{ | ||||
| 				if(reader->map.terrain[i-Woff][j-Hoff].malle) | ||||
| 				{ | ||||
| 					roadBitmaps[i][j] = roadDefs[reader->map.terrain[i-Woff][j-Hoff].malle-1]->ourImages[reader->map.terrain[i-Woff][j-Hoff].roadDir].bitmap; | ||||
| 					int cDir = reader->map.terrain[i-Woff][j-Hoff].roadDir; | ||||
| 					if(cDir==0 || cDir==1 || cDir==2 || cDir==3 || cDir==4 || cDir==5) | ||||
| 					{ | ||||
| 						if(i-Woff+1<reader->map.width && j-Hoff-1>0 && reader->map.terrain[i-Woff+1][j-Hoff].malle && reader->map.terrain[i-Woff][j-Hoff-1].malle) | ||||
| 						{ | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::hFlip(roadBitmaps[i][j]); | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::alphaTransform(roadBitmaps[i][j]); | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(roadBitmaps[i][j], su); | ||||
| 						} | ||||
| 						if(i-Woff-1>0 && j-Hoff-1>0 && reader->map.terrain[i-Woff-1][j-Hoff].malle && reader->map.terrain[i-Woff][j-Hoff-1].malle) | ||||
| 						{ | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::rotate03(roadBitmaps[i][j]); | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::alphaTransform(roadBitmaps[i][j]); | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(roadBitmaps[i][j], su); | ||||
| 						} | ||||
| 						if(i-Woff-1>0 && j-Hoff+1<reader->map.height && reader->map.terrain[i-Woff-1][j-Hoff].malle && reader->map.terrain[i-Woff][j-Hoff+1].malle) | ||||
| 						{ | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::rotate01(roadBitmaps[i][j]); | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::alphaTransform(roadBitmaps[i][j]); | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(roadBitmaps[i][j], su); | ||||
| 						} | ||||
| 					} | ||||
| 					if(cDir==8 || cDir==9) | ||||
| 					{ | ||||
| 						if(j-Hoff+1<reader->map.height && !(reader->map.terrain[i-Woff][j-Hoff+1].malle)) | ||||
| 						{ | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::hFlip(roadBitmaps[i][j]); | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::alphaTransform(roadBitmaps[i][j]); | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(roadBitmaps[i][j], su); | ||||
| 						} | ||||
| 					} | ||||
| 					if(cDir==6 || cDir==7) | ||||
| 					{ | ||||
| 						if(i-Woff+1<reader->map.width && !(reader->map.terrain[i-Woff+1][j-Hoff].malle)) | ||||
| 						{ | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::rotate01(roadBitmaps[i][j]); | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::alphaTransform(roadBitmaps[i][j]); | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(roadBitmaps[i][j], su); | ||||
| 						} | ||||
| 					} | ||||
| 					if(cDir==0x0e) | ||||
| 					{ | ||||
| 						if(j-Hoff+1<reader->map.height && !(reader->map.terrain[i-Woff][j-Hoff+1].malle)) | ||||
| 						{ | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::hFlip(roadBitmaps[i][j]); | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::alphaTransform(roadBitmaps[i][j]); | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(roadBitmaps[i][j], su); | ||||
| 						} | ||||
| 					} | ||||
| 					if(cDir==0x0f) | ||||
| 					{ | ||||
| 						if(i-Woff+1<reader->map.width && !(reader->map.terrain[i-Woff+1][j-Hoff].malle)) | ||||
| 						{ | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::rotate01(roadBitmaps[i][j]); | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::alphaTransform(roadBitmaps[i][j]); | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(roadBitmaps[i][j], su); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				else | ||||
| 					roadBitmaps[i][j] = NULL; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	undRoadBitmaps = new SDL_Surface **[reader->map.width+2*Woff]; | ||||
| 	for (int ii=0;ii<reader->map.width+2*Woff;ii++) | ||||
| 		undRoadBitmaps[ii] = new SDL_Surface*[reader->map.height+2*Hoff]; // allocate memory  | ||||
|  | ||||
| 	if(reader->map.twoLevel) | ||||
| 	{ | ||||
| 		for (int i=0; i<reader->map.width+2*Woff; i++) //jest po szeroko�ci | ||||
| 		{ | ||||
| 			for (int j=0; j<reader->map.height+2*Hoff;j++) //po wysoko�ci | ||||
| 			{ | ||||
| 				if(i<Woff || i>reader->map.width+Woff-1 || j<Woff || j>reader->map.height+Hoff-1) | ||||
| 					undRoadBitmaps[i][j] = NULL; | ||||
| 				else | ||||
| 				{ | ||||
| 					if(reader->map.terrain[i-Woff][j-Hoff].malle) | ||||
| 					{ | ||||
| 						undRoadBitmaps[i][j] = roadDefs[reader->map.undergroungTerrain[i-Woff][j-Hoff].malle-1]->ourImages[reader->map.undergroungTerrain[i-Woff][j-Hoff].roadDir].bitmap; | ||||
| 						int cDir = reader->map.terrain[i-Woff][j-Hoff].roadDir; | ||||
| 						if(cDir==0 || cDir==1 || cDir==2 || cDir==3 || cDir==4 || cDir==5) | ||||
| 						{ | ||||
| 							if(i-Woff+1<reader->map.width && j-Hoff-1>0 && reader->map.undergroungTerrain[i-Woff+1][j-Hoff].malle && reader->map.undergroungTerrain[i-Woff][j-Hoff-1].malle) | ||||
| 							{ | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::hFlip(undRoadBitmaps[i][j]); | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::alphaTransform(undRoadBitmaps[i][j]); | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(undRoadBitmaps[i][j], su); | ||||
| 							} | ||||
| 							if(i-Woff-1>0 && j-Hoff-1>0 && reader->map.undergroungTerrain[i-Woff-1][j-Hoff].malle && reader->map.undergroungTerrain[i-Woff][j-Hoff-1].malle) | ||||
| 							{ | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::rotate03(undRoadBitmaps[i][j]); | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::alphaTransform(undRoadBitmaps[i][j]); | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(undRoadBitmaps[i][j], su); | ||||
| 							} | ||||
| 							if(i-Woff-1>0 && j-Hoff+1<reader->map.height && reader->map.undergroungTerrain[i-Woff-1][j-Hoff].malle && reader->map.undergroungTerrain[i-Woff][j-Hoff+1].malle) | ||||
| 							{ | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::rotate01(undRoadBitmaps[i][j]); | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::alphaTransform(undRoadBitmaps[i][j]); | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(undRoadBitmaps[i][j], su); | ||||
| 							} | ||||
| 						} | ||||
| 						if(cDir==8 || cDir==9) | ||||
| 						{ | ||||
| 							if(j-Hoff+1<reader->map.height && !(reader->map.undergroungTerrain[i-Woff][j-Hoff+1].malle)) | ||||
| 							{ | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::hFlip(undRoadBitmaps[i][j]); | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::alphaTransform(undRoadBitmaps[i][j]); | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(undRoadBitmaps[i][j], su); | ||||
| 							} | ||||
| 						} | ||||
| 						if(cDir==6 || cDir==7) | ||||
| 						{ | ||||
| 							if(i-Woff+1<reader->map.width && !(reader->map.undergroungTerrain[i-Woff+1][j-Hoff].malle)) | ||||
| 							{ | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::rotate01(undRoadBitmaps[i][j]); | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::alphaTransform(undRoadBitmaps[i][j]); | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(undRoadBitmaps[i][j], su); | ||||
| 							} | ||||
| 						} | ||||
| 						if(cDir==0x0e) | ||||
| 						{ | ||||
| 							if(j-Hoff+1<reader->map.height && !(reader->map.undergroungTerrain[i-Woff][j-Hoff+1].malle)) | ||||
| 							{ | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::hFlip(undRoadBitmaps[i][j]); | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::alphaTransform(undRoadBitmaps[i][j]); | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(undRoadBitmaps[i][j], su); | ||||
| 							} | ||||
| 						} | ||||
| 						if(cDir==0x0f) | ||||
| 						{ | ||||
| 							if(i-Woff+1<reader->map.width && !(reader->map.undergroungTerrain[i-Woff+1][j-Hoff].malle)) | ||||
| 							{ | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::rotate01(undRoadBitmaps[i][j]); | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::alphaTransform(undRoadBitmaps[i][j]); | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(undRoadBitmaps[i][j], su); | ||||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 					else | ||||
| 						undRoadBitmaps[i][j] = NULL; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	staticRiverBitmaps = new SDL_Surface **[reader->map.width+2*Woff]; | ||||
| 	for (int ii=0;ii<reader->map.width+2*Woff;ii++) | ||||
| 		staticRiverBitmaps[ii] = new SDL_Surface*[reader->map.height+2*Hoff]; // allocate memory  | ||||
|  | ||||
| 	for (int i=0; i<reader->map.width+2*Woff; i++) //jest po szeroko�ci | ||||
| 	{ | ||||
| 		for (int j=0; j<reader->map.height+2*Hoff;j++) //po wysoko�ci | ||||
| 		{ | ||||
| 			if(i<Woff || i>reader->map.width+Woff-1 || j<Woff || j>reader->map.height+Hoff-1) | ||||
| 				staticRiverBitmaps[i][j] = NULL; | ||||
| 			else | ||||
| 			{ | ||||
| 				if(reader->map.terrain[i-Woff][j-Hoff].nuine) | ||||
| 				{ | ||||
| 					staticRiverBitmaps[i][j] = staticRiverDefs[reader->map.terrain[i-Woff][j-Hoff].nuine-1]->ourImages[reader->map.terrain[i-Woff][j-Hoff].rivDir].bitmap; | ||||
| 					int cDir = reader->map.terrain[i-Woff][j-Hoff].rivDir; | ||||
| 					if(cDir==0 || cDir==1 || cDir==2 || cDir==3) | ||||
| 					{ | ||||
| 						if(i-Woff+1<reader->map.width && j-Hoff-1>0 && reader->map.terrain[i-Woff+1][j-Hoff].nuine && reader->map.terrain[i-Woff][j-Hoff-1].nuine) | ||||
| 						{ | ||||
| 							staticRiverBitmaps[i][j] = CSDL_Ext::hFlip(staticRiverBitmaps[i][j]); | ||||
| 							staticRiverBitmaps[i][j] = CSDL_Ext::alphaTransform(staticRiverBitmaps[i][j]); | ||||
| 							staticRiverBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(staticRiverBitmaps[i][j], su); | ||||
| 						} | ||||
| 						if(i-Woff-1>0 && j-Hoff-1>0 && reader->map.terrain[i-Woff-1][j-Hoff].nuine && reader->map.terrain[i-Woff][j-Hoff-1].nuine) | ||||
| 						{ | ||||
| 							staticRiverBitmaps[i][j] = CSDL_Ext::rotate03(staticRiverBitmaps[i][j]); | ||||
| 							staticRiverBitmaps[i][j] = CSDL_Ext::alphaTransform(staticRiverBitmaps[i][j]); | ||||
| 							staticRiverBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(staticRiverBitmaps[i][j], su); | ||||
| 						} | ||||
| 						if(i-Woff-1>0 && j-Hoff+1<reader->map.height && reader->map.terrain[i-Woff-1][j-Hoff].nuine && reader->map.terrain[i-Woff][j-Hoff+1].nuine) | ||||
| 						{ | ||||
| 							staticRiverBitmaps[i][j] = CSDL_Ext::rotate01(staticRiverBitmaps[i][j]); | ||||
| 							staticRiverBitmaps[i][j] = CSDL_Ext::alphaTransform(staticRiverBitmaps[i][j]); | ||||
| 							staticRiverBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(staticRiverBitmaps[i][j], su); | ||||
| 						} | ||||
| 					} | ||||
| 					if(cDir==5 || cDir==6) | ||||
| 					{ | ||||
| 						if(j-Hoff+1<reader->map.height && !(reader->map.terrain[i-Woff][j-Hoff+1].nuine)) | ||||
| 						{ | ||||
| 							staticRiverBitmaps[i][j] = CSDL_Ext::hFlip(staticRiverBitmaps[i][j]); | ||||
| 							staticRiverBitmaps[i][j] = CSDL_Ext::alphaTransform(staticRiverBitmaps[i][j]); | ||||
| 							staticRiverBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(staticRiverBitmaps[i][j], su); | ||||
| 						} | ||||
| 					} | ||||
| 					if(cDir==7 || cDir==8) | ||||
| 					{ | ||||
| 						if(i-Woff+1<reader->map.width && !(reader->map.terrain[i-Woff+1][j-Hoff].nuine)) | ||||
| 						{ | ||||
| 							staticRiverBitmaps[i][j] = CSDL_Ext::rotate01(staticRiverBitmaps[i][j]); | ||||
| 							staticRiverBitmaps[i][j] = CSDL_Ext::alphaTransform(staticRiverBitmaps[i][j]); | ||||
| 							staticRiverBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(staticRiverBitmaps[i][j], su); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				else | ||||
| 					staticRiverBitmaps[i][j] = NULL; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	undStaticRiverBitmaps = new SDL_Surface **[reader->map.width+2*Woff]; | ||||
| 	for (int ii=0;ii<reader->map.width+2*Woff;ii++) | ||||
| 		undStaticRiverBitmaps[ii] = new SDL_Surface*[reader->map.height+2*Hoff]; // allocate memory  | ||||
|  | ||||
| 	if(reader->map.twoLevel) | ||||
| 	{ | ||||
| 		for (int i=0; i<reader->map.width+2*Woff; i++) //jest po szeroko�ci | ||||
| 		{ | ||||
| 			for (int j=0; j<reader->map.height+2*Hoff;j++) //po wysoko�ci | ||||
| 			{ | ||||
| 				if(i<Woff || i>reader->map.width+Woff-1 || j<Woff || j>reader->map.height+Hoff-1) | ||||
| 					undStaticRiverBitmaps[i][j] = NULL; | ||||
| 				else | ||||
| 				{ | ||||
| 					if(reader->map.undergroungTerrain[i-Woff][j-Hoff].nuine) | ||||
| 					{ | ||||
| 						undStaticRiverBitmaps[i][j] = staticRiverDefs[reader->map.undergroungTerrain[i-Woff][j-Hoff].nuine-1]->ourImages[reader->map.undergroungTerrain[i-Woff][j-Hoff].rivDir].bitmap; | ||||
| 						int cDir = reader->map.undergroungTerrain[i-Woff][j-Hoff].rivDir; | ||||
| 						if(cDir==0 || cDir==1 || cDir==2 || cDir==3) | ||||
| 						{ | ||||
| 							if(i-Woff+1<reader->map.width && j-Hoff-1>0 && reader->map.undergroungTerrain[i-Woff+1][j-Hoff].nuine && reader->map.undergroungTerrain[i-Woff][j-Hoff-1].nuine) | ||||
| 							{ | ||||
| 								undStaticRiverBitmaps[i][j] = CSDL_Ext::hFlip(undStaticRiverBitmaps[i][j]); | ||||
| 								undStaticRiverBitmaps[i][j] = CSDL_Ext::alphaTransform(undStaticRiverBitmaps[i][j]); | ||||
| 								undStaticRiverBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(undStaticRiverBitmaps[i][j], su); | ||||
| 							} | ||||
| 							if(i-Woff-1>0 && j-Hoff-1>0 && reader->map.undergroungTerrain[i-Woff-1][j-Hoff].nuine && reader->map.undergroungTerrain[i-Woff][j-Hoff-1].nuine) | ||||
| 							{ | ||||
| 								undStaticRiverBitmaps[i][j] = CSDL_Ext::rotate03(undStaticRiverBitmaps[i][j]); | ||||
| 								undStaticRiverBitmaps[i][j] = CSDL_Ext::alphaTransform(undStaticRiverBitmaps[i][j]); | ||||
| 								undStaticRiverBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(undStaticRiverBitmaps[i][j], su); | ||||
| 							} | ||||
| 							if(i-Woff-1>0 && j-Hoff+1<reader->map.height && reader->map.undergroungTerrain[i-Woff-1][j-Hoff].nuine && reader->map.undergroungTerrain[i-Woff][j-Hoff+1].nuine) | ||||
| 							{ | ||||
| 								undStaticRiverBitmaps[i][j] = CSDL_Ext::rotate01(undStaticRiverBitmaps[i][j]); | ||||
| 								undStaticRiverBitmaps[i][j] = CSDL_Ext::alphaTransform(undStaticRiverBitmaps[i][j]); | ||||
| 								undStaticRiverBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(undStaticRiverBitmaps[i][j], su); | ||||
| 							} | ||||
| 						} | ||||
| 						if(cDir==5 || cDir==6) | ||||
| 						{ | ||||
| 							if(j-Hoff+1<reader->map.height && !(reader->map.undergroungTerrain[i-Woff][j-Hoff+1].nuine)) | ||||
| 							{ | ||||
| 								undStaticRiverBitmaps[i][j] = CSDL_Ext::hFlip(undStaticRiverBitmaps[i][j]); | ||||
| 								undStaticRiverBitmaps[i][j] = CSDL_Ext::alphaTransform(undStaticRiverBitmaps[i][j]); | ||||
| 								undStaticRiverBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(undStaticRiverBitmaps[i][j], su); | ||||
| 							} | ||||
| 						} | ||||
| 						if(cDir==7 || cDir==8) | ||||
| 						{ | ||||
| 							if(i-Woff+1<reader->map.width && !(reader->map.undergroungTerrain[i-Woff+1][j-Hoff].nuine)) | ||||
| 							{ | ||||
| 								undStaticRiverBitmaps[i][j] = CSDL_Ext::rotate01(undStaticRiverBitmaps[i][j]); | ||||
| 								undStaticRiverBitmaps[i][j] = CSDL_Ext::alphaTransform(undStaticRiverBitmaps[i][j]); | ||||
| 								undStaticRiverBitmaps[i][j] = CSDL_Ext::secondAlphaTransform(undStaticRiverBitmaps[i][j], su); | ||||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 					else | ||||
| 						undStaticRiverBitmaps[i][j] = NULL; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	SDL_FreeSurface(su); | ||||
|  | ||||
| 	//road's and river's DefHandlers initialized | ||||
|  | ||||
| 	terrainBitmap = new SDL_Surface **[reader->map.width+2*Woff]; | ||||
| 	for (int ii=0;ii<reader->map.width+2*Woff;ii++) | ||||
| 		terrainBitmap[ii] = new SDL_Surface*[reader->map.height+2*Hoff]; // allocate memory  | ||||
| 	CDefHandler * bord = CGameInfo::mainObj->spriteh->giveDef("EDG.DEF"); | ||||
| @@ -311,7 +631,54 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level, | ||||
| 			delete sr; | ||||
| 		} | ||||
| 	} | ||||
| 	////terrain printed; printing objects | ||||
| 	////terrain printed | ||||
| 	////printing rivers | ||||
| 	for (int bx=0; bx<dx; bx++) | ||||
| 	{ | ||||
| 		for (int by=0; by<dy; by++) | ||||
| 		{ | ||||
| 			SDL_Rect * sr = new SDL_Rect; | ||||
| 			sr->y=by*32; | ||||
| 			sr->x=bx*32; | ||||
| 			sr->h=sr->w=32; | ||||
| 			if (!level) | ||||
| 			{ | ||||
| 				if(staticRiverBitmaps[bx+x][by+y]) | ||||
| 					SDL_BlitSurface(staticRiverBitmaps[bx+x][by+y],NULL,su,sr); | ||||
| 			} | ||||
| 			else  | ||||
| 			{ | ||||
| 				if(undStaticRiverBitmaps[bx+x][by+y]) | ||||
| 					SDL_BlitSurface(undStaticRiverBitmaps[bx+x][by+y],NULL,su,sr); | ||||
| 			} | ||||
| 			delete sr; | ||||
| 		} | ||||
| 	} | ||||
| 	////rivers printed | ||||
| 	////printing roads | ||||
| 	for (int bx=0; bx<dx; bx++) | ||||
| 	{ | ||||
| 		for (int by=0; by<dy; by++) | ||||
| 		{ | ||||
| 			SDL_Rect * sr = new SDL_Rect; | ||||
| 			sr->y=by*32; | ||||
| 			sr->x=bx*32; | ||||
| 			sr->h=sr->w=32; | ||||
| 			if (!level) | ||||
| 			{ | ||||
| 				if(roadBitmaps[bx+x][by+y]) | ||||
| 					SDL_BlitSurface(roadBitmaps[bx+x][by+y],NULL,su,sr); | ||||
| 			} | ||||
| 			else  | ||||
| 			{ | ||||
| 				if(undRoadBitmaps[bx+x][by+y]) | ||||
| 					SDL_BlitSurface(undRoadBitmaps[bx+x][by+y],NULL,su,sr); | ||||
| 			} | ||||
| 			delete sr; | ||||
| 		} | ||||
| 	} | ||||
| 	////roads printed | ||||
| 	////printing objects | ||||
| 	std::vector<ObjSorter> lowPrObjs; | ||||
| 	std::vector<ObjSorter> highPrObjs; | ||||
| 	std::vector<ObjSorter> highPrObjsVis; | ||||
|   | ||||
| @@ -4,6 +4,7 @@ | ||||
| #include "CAmbarCendamo.h" | ||||
| #include "CSemiDefHandler.h" | ||||
| #include "CGameInfo.h" | ||||
| #include "CDefHandler.h" | ||||
|  | ||||
| const int Woff = 4; //width of map's frame | ||||
| const int Hoff = 4;  | ||||
| @@ -29,6 +30,12 @@ public: | ||||
|  | ||||
| 	std::vector< std::vector<char> > visibility; //true means that pointed place is visible | ||||
| 	std::vector< std::vector<char> > undVisibility; //true means that pointed place is visible | ||||
| 	std::vector<CDefHandler *> roadDefs; | ||||
| 	std::vector<CDefHandler *> staticRiverDefs; | ||||
| 	SDL_Surface *** roadBitmaps; | ||||
| 	SDL_Surface *** undRoadBitmaps; | ||||
| 	SDL_Surface *** staticRiverBitmaps; | ||||
| 	SDL_Surface *** undStaticRiverBitmaps; | ||||
| 	char & visAccess(int x, int y); | ||||
| 	char & undVisAccess(int x, int y); | ||||
| 	SDL_Surface mirrorImage(SDL_Surface *src); //what is this?? | ||||
|   | ||||
		Reference in New Issue
	
	Block a user