mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	* choosing random towns
* some minor bugfixes and improvements
This commit is contained in:
		| @@ -2011,6 +2011,17 @@ void CAmbarCendamo::processMap(std::vector<std::string> & defsToUnpack) | ||||
| 		art4DefNumbers.push_back(-1); | ||||
| 	} | ||||
|  | ||||
| 	std::vector<std::string> town0DefNames; //without fort | ||||
| 	std::vector<int> town0DefNumbers; | ||||
| 	std::vector<std::string> town1DefNames; //with fort | ||||
| 	std::vector<int> town1DefNumbers; | ||||
|  | ||||
| 	for(int dd=0; dd<9; ++dd) | ||||
| 	{ | ||||
| 		town1DefNames.push_back(CGI->dobjinfo->objs[dd+385].defName); | ||||
| 		town1DefNumbers.push_back(-1); | ||||
| 	} | ||||
| 	 | ||||
| 	//variables initialized | ||||
| 	for(int j=0; j<CGI->objh->objInstances.size(); ++j) | ||||
| 	{ | ||||
| @@ -2449,6 +2460,59 @@ void CAmbarCendamo::processMap(std::vector<std::string> & defsToUnpack) | ||||
| 				} | ||||
| 				break; | ||||
| 			} | ||||
| 		case EDefType::TOWN_DEF: | ||||
| 			{ | ||||
| 				if(curDef.bytes[16]==77) //random town | ||||
| 				{ | ||||
| 					DefInfo nxt = curDef; | ||||
| 					nxt.bytes[16] = 98; | ||||
| 					if(((CCastleObjInfo*)CGI->objh->objInstances[j].info)->player==0xff) | ||||
| 					{ | ||||
| 						nxt.bytes[20] = rand()%town1DefNames.size();		 | ||||
| 					} | ||||
| 					else | ||||
| 					{ | ||||
| 						if(CGI->scenarioOps.playerInfos[((CCastleObjInfo*)CGI->objh->objInstances[j].info)->player].castle>-1) | ||||
| 						{ | ||||
| 							nxt.bytes[20] = CGI->scenarioOps.playerInfos[((CCastleObjInfo*)CGI->objh->objInstances[j].info)->player].castle; | ||||
| 						} | ||||
| 						else | ||||
| 						{ | ||||
| 							nxt.bytes[20] = rand()%town1DefNames.size(); | ||||
| 						} | ||||
| 					} | ||||
| 					if(town1DefNumbers[nxt.bytes[20]]!=-1) | ||||
| 					{ | ||||
| 						CGI->objh->objInstances[j].defNumber = town1DefNumbers[nxt.bytes[20]]; | ||||
| 						continue; | ||||
| 					} | ||||
| 					nxt.name = town1DefNames[nxt.bytes[20]]; | ||||
| 					std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),  | ||||
| 						nxt.name); | ||||
| 					if(pit == CGameInfo::mainObj->dobjinfo->objs.end()) | ||||
| 					{ | ||||
| 						nxt.isOnDefList = false; | ||||
| 					} | ||||
| 					else | ||||
| 					{ | ||||
| 						nxt.printPriority = pit->priority; | ||||
| 						nxt.isOnDefList = true; | ||||
| 					} | ||||
| 					map.defy.push_back(nxt); // add this def to the vector | ||||
| 					defsToUnpack.push_back(nxt.name); | ||||
| 					CGI->objh->objInstances[j].defNumber = map.defy.size()-1; | ||||
| 					if(town1DefNumbers[nxt.bytes[20]]==-1) | ||||
| 					{ | ||||
| 						town1DefNumbers[nxt.bytes[20]] = map.defy.size()-1; | ||||
| 					} | ||||
| 				} | ||||
| 				//((CCastleObjInfo*)CGI->objh->objInstances[j].info) | ||||
| 				break; | ||||
| 			} | ||||
| 		} //end of main switch | ||||
| 	} //end of main loop | ||||
| 	//for(int j=0; j<CGI->objh->objInstances.size(); ++j) //for creature dwellings on map (they are town type dependent) | ||||
| 	//{ | ||||
| 	//	DefInfo curDef = map.defy[CGI->objh->objInstances[j].defNumber]; | ||||
| 	//} | ||||
| } | ||||
|   | ||||
| @@ -446,7 +446,7 @@ void CCreatureHandler::loadUnitAnimInfo(CCreature & unit, std::string & src, int | ||||
|  | ||||
| void CCreatureHandler::loadUnitAnimations() | ||||
| { | ||||
| 	std::ifstream inp("CREDEFS.TXT", std::ios::in | std::ios::binary); | ||||
| 	std::ifstream inp("CREDEFS.TXT", std::ios::in | std::ios::binary); //this file is not in lod | ||||
| 	inp.seekg(0,std::ios::end); // na koniec | ||||
| 	int andame = inp.tellg();  // read length | ||||
| 	inp.seekg(0,std::ios::beg); // wracamy na poczatek | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| #ifndef CGAMEINFO_H | ||||
| #define CGAMEINFO_H | ||||
|  | ||||
| #include "CPreGame.h" | ||||
| #include "StartInfo.h" | ||||
| #include "CSpellHandler.h" | ||||
| #include "CAbilityHandler.h" | ||||
| #include "CCreaturehandler.h" | ||||
| @@ -16,8 +18,8 @@ | ||||
| #include "CTownHandler.h" | ||||
| #include "CGeneralTextHandler.h" | ||||
| #include "SDL.h" | ||||
| #include <vector> | ||||
|  | ||||
| #include <vector> | ||||
| /* | ||||
| 	CGameInfo class | ||||
| 	for allowing different functions for modifying game informations | ||||
| @@ -43,6 +45,7 @@ public: | ||||
| 	CGeneralTextHandler * generaltexth; | ||||
| 	std::vector<SDL_Color> playerColors; | ||||
| 	SDL_Color neutralColor; | ||||
| 	StartInfo scenarioOps; | ||||
| }; | ||||
|  | ||||
| #endif //CGAMEINFO_H | ||||
| @@ -1,3 +1,6 @@ | ||||
| #ifndef CGAMEINTERFACE_H | ||||
| #define CGAMEINTERFACE_H | ||||
|  | ||||
| #include "SDL.h" | ||||
| #include "CDefHandler.h" | ||||
| #include "SDL_Extensions.h" | ||||
| @@ -59,4 +62,6 @@ class CPlayerInterface | ||||
| 	std::vector<Hoverable*> hoverable; | ||||
| 	std::vector<KeyInterested*> keyinterested; | ||||
| 	void handleEvent(SDL_Event * sEvent); | ||||
| }; | ||||
| }; | ||||
|  | ||||
| #endif //CGAMEINTERFACE_H | ||||
							
								
								
									
										2
									
								
								CMT.cpp
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								CMT.cpp
									
									
									
									
									
								
							| @@ -284,7 +284,7 @@ int _tmain(int argc, _TCHAR* argv[]) | ||||
| 		//CSDL_Ext::blueToPlayersAdv(ll->piecesOfBox[0].ourImages[0].bitmap, 0); | ||||
| 		//SDL_SaveBMP(ll->piecesOfBox[0].ourImages[0].bitmap, "test2.bmp"); | ||||
| 		cpg->mush = mush; | ||||
| 		cpg->runLoop(); | ||||
| 		cgi->scenarioOps = cpg->runLoop(); | ||||
| 		THC tmh.getDif(); | ||||
|  | ||||
| 		//////////////////////////////////////////////////////////////////////////////// lod testing | ||||
|   | ||||
							
								
								
									
										16
									
								
								CPreGame.h
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								CPreGame.h
									
									
									
									
									
								
							| @@ -1,6 +1,7 @@ | ||||
| #ifndef CPREGAME_H | ||||
| #define CPREGAME_H | ||||
| #include "SDL.h" | ||||
| #include "StartInfo.h" | ||||
| #include "CSemiDefHandler.h" | ||||
| #include "CSemiLodHandler.h" | ||||
| #include "CPreGameTextHandler.h"  | ||||
| @@ -9,7 +10,6 @@ | ||||
| #include "CMusicHandler.h" | ||||
| class CPreGame; | ||||
| extern CPreGame * CPG; | ||||
| enum Ebonus {brandom=-1,bartifact, bgold, bresource}; | ||||
|  | ||||
| typedef void(CPreGame::*ttt)(); | ||||
| template <class T=ttt> class CGroup; | ||||
| @@ -105,20 +105,6 @@ public: | ||||
| 	CGroup():selected(NULL),type(0){}; | ||||
| }; | ||||
|  | ||||
| struct StartInfo | ||||
| { | ||||
| 	struct PlayerSettings | ||||
| 	{ | ||||
| 		int castle, hero, heroPortrait; //ID, if -1 then random, if -2 then none | ||||
| 		std::string heroName; | ||||
| 		Ebonus bonus;  | ||||
| 		Ecolor color; //from 0 -  | ||||
| 		int handicap;//0-no, 1-mild, 2-severe | ||||
| 		std::string name; | ||||
| 	}; | ||||
| 	std::vector<PlayerSettings> playerInfos; | ||||
| 	int turnTime; //in minutes, 0=unlimited | ||||
| }; | ||||
| class PreGameTab | ||||
| { | ||||
| public: | ||||
|   | ||||
							
								
								
									
										23
									
								
								StartInfo.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								StartInfo.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| #ifndef STARTINFO_H | ||||
| #define STARTINFO_H | ||||
|  | ||||
| #include "global.h" | ||||
|  | ||||
| enum Ebonus {brandom=-1,bartifact, bgold, bresource}; | ||||
|  | ||||
| struct StartInfo | ||||
| { | ||||
| 	struct PlayerSettings | ||||
| 	{ | ||||
| 		int castle, hero, heroPortrait; //ID, if -1 then random, if -2 then none | ||||
| 		std::string heroName; | ||||
| 		Ebonus bonus;  | ||||
| 		Ecolor color; //from 0 -  | ||||
| 		int handicap;//0-no, 1-mild, 2-severe | ||||
| 		std::string name; | ||||
| 	}; | ||||
| 	std::vector<PlayerSettings> playerInfos; | ||||
| 	int turnTime; //in minutes, 0=unlimited | ||||
| }; | ||||
|  | ||||
| #endif | ||||
| @@ -140,7 +140,7 @@ void CMapHandler::init() | ||||
| 					} | ||||
| 					if(cDir==8 || cDir==9) | ||||
| 					{ | ||||
| 						if(j-Hoff+1<reader->map.height && !(reader->map.terrain[i-Woff][j-Hoff+1].malle)) | ||||
| 						if((j-Hoff+1<reader->map.height && !(reader->map.terrain[i-Woff][j-Hoff+1].malle)) || j-Hoff+1==reader->map.height) | ||||
| 						{ | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::hFlip(roadBitmaps[i][j]); | ||||
| 							roadBitmaps[i][j] = CSDL_Ext::alphaTransform(roadBitmaps[i][j]); | ||||
| @@ -222,7 +222,7 @@ void CMapHandler::init() | ||||
| 						} | ||||
| 						if(cDir==8 || cDir==9) | ||||
| 						{ | ||||
| 							if(j-Hoff+1<reader->map.height && !(reader->map.undergroungTerrain[i-Woff][j-Hoff+1].malle)) | ||||
| 							if((j-Hoff+1<reader->map.height && !(reader->map.undergroungTerrain[i-Woff][j-Hoff+1].malle)) || j-Hoff+1==reader->map.height) | ||||
| 							{ | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::hFlip(undRoadBitmaps[i][j]); | ||||
| 								undRoadBitmaps[i][j] = CSDL_Ext::alphaTransform(undRoadBitmaps[i][j]); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user