mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	[PLATFORM] MinGW support added
* disabled features unsupported by MinGW
* fixed issues with DLL_LINKAGE
! BOOST_THREAD_VERSION in now 3 workaround for existing code added, consider refactoring.
* some small tweaks ("-fpedantic" warnings)
			
			
This commit is contained in:
		
							
								
								
									
										11
									
								
								Global.h
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								Global.h
									
									
									
									
									
								
							| @@ -51,6 +51,9 @@ | ||||
|  | ||||
| //The only available version is 3, as of Boost 1.50 | ||||
| #define BOOST_FILESYSTEM_VERSION 3 | ||||
| #define BOOST_THREAD_VERSION 3 | ||||
| #define BOOST_THREAD_DONT_PROVIDE_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE 1 | ||||
| //#define BOOST_SYSTEM_NO_DEPRECATED 1 | ||||
|  | ||||
| #include <boost/algorithm/string.hpp> | ||||
| #include <boost/assert.hpp> | ||||
| @@ -97,7 +100,11 @@ typedef boost::int8_t si8; //signed int 8 bits (1 byte) | ||||
|  | ||||
| // Import + Export macro declarations | ||||
| #ifdef _WIN32 | ||||
| #ifdef __GNUC__ | ||||
| #define DLL_EXPORT __attribute__((dllexport)) | ||||
| #else | ||||
| #define DLL_EXPORT __declspec(dllexport) | ||||
| #endif | ||||
| #else | ||||
| #if defined(__GNUC__) && GCC_VERSION >= 400 | ||||
| #define DLL_EXPORT	__attribute__ ((visibility("default"))) | ||||
| @@ -107,7 +114,11 @@ typedef boost::int8_t si8; //signed int 8 bits (1 byte) | ||||
| #endif | ||||
|  | ||||
| #ifdef _WIN32 | ||||
| #ifdef __GNUC__ | ||||
| #define DLL_IMPORT __attribute__((dllimport)) | ||||
| #else | ||||
| #define DLL_IMPORT __declspec(dllimport) | ||||
| #endif | ||||
| #else | ||||
| #if defined(__GNUC__) && GCC_VERSION >= 400 | ||||
| #define DLL_IMPORT	__attribute__ ((visibility("default"))) | ||||
|   | ||||
| @@ -29,7 +29,7 @@ struct BattleResult; | ||||
| struct BattleSpellCast; | ||||
| struct CObstacleInstance; | ||||
| template <typename T> struct CondSh; | ||||
| struct SetStackEffect;; | ||||
| struct SetStackEffect; | ||||
| struct BattleAction; | ||||
| class CGTownInstance; | ||||
| struct CatapultAttack; | ||||
|   | ||||
| @@ -27,4 +27,4 @@ namespace BitmapHandler | ||||
| 	SDL_Surface * loadBitmapFromDir(std::string path, std::string fname, bool setKey=true); | ||||
| 	//Load file from any LODs | ||||
| 	SDL_Surface * loadBitmap(std::string fname, bool setKey=true); | ||||
| }; | ||||
| } | ||||
|   | ||||
| @@ -351,7 +351,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const ui8 * FDef, const BMPPal | ||||
| 	Uint32 keycol = SDL_MapRGBA(ret->format, ttcol.r, ttcol.b, ttcol.g, ttcol.unused); | ||||
| 	SDL_SetColorKey(ret, SDL_SRCCOLORKEY, keycol); | ||||
| 	return ret; | ||||
| }; | ||||
| } | ||||
|  | ||||
| CDefEssential * CDefHandler::essentialize() | ||||
| { | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
| #include "UIFramework/CIntObject.h" | ||||
|  | ||||
| #ifdef __GNUC__ | ||||
| #define sprintf_s snprintf  | ||||
| #define sprintf_s snprintf | ||||
| #endif | ||||
|  | ||||
| #ifdef max | ||||
| @@ -69,9 +69,9 @@ namespace boost | ||||
| { | ||||
| 	class mutex; | ||||
| 	class recursive_mutex; | ||||
| }; | ||||
| } | ||||
|  | ||||
| enum  | ||||
| enum | ||||
| { | ||||
| 	/*CHANGE_SCREEN_RESOLUTION = 1,*/ | ||||
| 	RETURN_TO_MAIN_MENU = 2, | ||||
| @@ -100,7 +100,7 @@ public: | ||||
| 	CCastleInterface * castleInt; //NULL if castle window isn't opened | ||||
| 	static CBattleInterface * battleInt; //NULL if no battle | ||||
| 	CInGameConsole * cingconsole; | ||||
| 	 | ||||
|  | ||||
| 	CCallback * cb; //to communicate with engine | ||||
| 	const BattleAction *curAction; //during the battle - action currently performed by active stack (or NULL) | ||||
|  | ||||
| @@ -155,7 +155,7 @@ public: | ||||
| 	void receivedResource(int type, int val) OVERRIDE; | ||||
| 	void showInfoDialog(const std::string &text, const std::vector<Component*> &components, int soundID) OVERRIDE; | ||||
| 	void showRecruitmentDialog(const CGDwelling *dwelling, const CArmedInstance *dst, int level) OVERRIDE; | ||||
| 	void showShipyardDialog(const IShipyard *obj) OVERRIDE; //obj may be town or shipyard;  | ||||
| 	void showShipyardDialog(const IShipyard *obj) OVERRIDE; //obj may be town or shipyard; | ||||
| 	void showBlockingDialog(const std::string &text, const std::vector<Component> &components, ui32 askID, int soundID, bool selection, bool cancel) OVERRIDE; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID. | ||||
| 	void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, int queryID) OVERRIDE; | ||||
| 	void showPuzzleMap() OVERRIDE; | ||||
| @@ -234,7 +234,7 @@ public: | ||||
| 	CGPath *getAndVerifyPath( const CGHeroInstance * h ); | ||||
| 	void acceptTurn(); //used during hot seat after your turn message is close | ||||
| 	void tryDiggging(const CGHeroInstance *h); | ||||
| 	void showShipyardDialogOrProblemPopup(const IShipyard *obj); //obj may be town or shipyard;  | ||||
| 	void showShipyardDialogOrProblemPopup(const IShipyard *obj); //obj may be town or shipyard; | ||||
| 	void requestReturningToMainMenu(); | ||||
| 	void requestStoppingClient(); | ||||
| 	void sendCustomEvent(int code); | ||||
|   | ||||
| @@ -124,7 +124,7 @@ public: | ||||
| 	CPicture *playerListBg; | ||||
|  | ||||
| 	CHighlightableButtonsGroup *difficulty; | ||||
| 	CDefHandler *sizes, *sFlags;; | ||||
| 	CDefHandler *sizes, *sFlags; | ||||
|  | ||||
| 	void changeSelection(const CMapInfo *to); | ||||
| 	void showAll(SDL_Surface * to); | ||||
|   | ||||
| @@ -47,7 +47,7 @@ void checkForError(bool throwing = true) | ||||
|  | ||||
| void blitBuffer(char *buffer, int x, int y, int w, int h, SDL_Surface *dst) | ||||
| { | ||||
| 	const int bpp = dst->format->BytesPerPixel;	 | ||||
| 	const int bpp = dst->format->BytesPerPixel; | ||||
| 	char *dest; | ||||
| 	for(int i = h; i > 0; i--) | ||||
| 	{ | ||||
| @@ -142,10 +142,13 @@ bool CBIKHandler::open(std::string name) | ||||
| 		tlog1 << "BIK handler: failed to open " << name << std::endl; | ||||
| 		goto checkErrorAndClean; | ||||
| 	} | ||||
| 	//GCC wants scope of waveout to dont cross labels/swith/goto | ||||
|     { | ||||
| 		void *waveout = GetProcAddress(dll,"_BinkOpenWaveOut@4"); | ||||
| 		if(waveout) | ||||
| 			binkSetSoundSystem(waveout,NULL); | ||||
|  | ||||
| 	void *waveout = GetProcAddress(dll,"_BinkOpenWaveOut@4"); | ||||
| 	if(waveout) | ||||
| 		binkSetSoundSystem(waveout,NULL); | ||||
|     } | ||||
|  | ||||
| 	hBink = binkOpen(hBinkFile, 0x8a800000); | ||||
| 	if(!hBink) | ||||
| @@ -166,8 +169,8 @@ checkErrorAndClean: | ||||
|  | ||||
| void CBIKHandler::show( int x, int y, SDL_Surface *dst, bool update ) | ||||
| { | ||||
| 	const int w = hBink->width,  | ||||
| 		h = hBink->height,  | ||||
| 	const int w = hBink->width, | ||||
| 		h = hBink->height, | ||||
| 		Bpp = dst->format->BytesPerPixel; | ||||
|  | ||||
| 	int mode = -1; | ||||
| @@ -298,7 +301,7 @@ bool CSmackPlayer::open( std::string name ) | ||||
| 	Uint32 flags[2] = {0xff400, 0xfe400}; | ||||
|  | ||||
| 	data = ptrSmackOpen( (void*)name.c_str(), flags[1], -1); | ||||
| 	if (!data)  | ||||
| 	if (!data) | ||||
| 	{ | ||||
| 		tlog1 << "Smack cannot open " << name << std::endl; | ||||
| 		checkForError(); | ||||
| @@ -337,9 +340,9 @@ void CSmackPlayer::redraw( int x, int y, SDL_Surface *dst, bool update ) | ||||
| { | ||||
| 	int w = std::min<int>(data->width, dst->w - x), h = std::min<int>(data->height, dst->h - y); | ||||
| 	/* Lock the screen for direct access to the pixels */ | ||||
| 	if ( SDL_MUSTLOCK(dst) )  | ||||
| 	if ( SDL_MUSTLOCK(dst) ) | ||||
| 	{ | ||||
| 		if ( SDL_LockSurface(dst) < 0 )  | ||||
| 		if ( SDL_LockSurface(dst) < 0 ) | ||||
| 		{ | ||||
| 			fprintf(stderr, "Can't lock screen: %s\n", SDL_GetError()); | ||||
| 			return; | ||||
| @@ -374,7 +377,7 @@ void CSmackPlayer::redraw( int x, int y, SDL_Surface *dst, bool update ) | ||||
| 				//convert rgb 555 to 565 | ||||
| 				Uint16 pixel = *addr; | ||||
| 				Uint16 *p = (Uint16 *)((Uint8 *)dst->pixels + (j+y) * dst->pitch + (i + x) * dst->format->BytesPerPixel); | ||||
| 				*p =	(pixel & 0x1F)  | ||||
| 				*p =	(pixel & 0x1F) | ||||
| 					  +	((pixel & 0x3e0) << 1) | ||||
| 					  +	((pixel & 0x7c00) << 1); | ||||
|  | ||||
| @@ -383,7 +386,7 @@ void CSmackPlayer::redraw( int x, int y, SDL_Surface *dst, bool update ) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if ( SDL_MUSTLOCK(dst) )  | ||||
| 	if ( SDL_MUSTLOCK(dst) ) | ||||
| 	{ | ||||
| 		SDL_UnlockSurface(dst); | ||||
| 	} | ||||
| @@ -425,7 +428,7 @@ bool CVideoPlayer::open(std::string name) | ||||
| 			out.exceptions(std::ifstream::failbit | std::ifstream::badbit); | ||||
| 			out.write(data.get(), myVideo->getSize()); | ||||
| 		} | ||||
| 		 | ||||
|  | ||||
| 		current->open(name); | ||||
| 		return true; | ||||
| 	} | ||||
| @@ -526,7 +529,7 @@ void CVideoPlayer::update( int x, int y, SDL_Surface *dst, bool forceRedraw, boo | ||||
|  | ||||
|  | ||||
|  | ||||
| 	if(!w)  | ||||
| 	if(!w) | ||||
| 	{ | ||||
| 		show(x,y,dst,update); | ||||
| 	} | ||||
| @@ -700,7 +703,7 @@ bool CVideoPlayer::open(std::string fname) | ||||
| bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay) | ||||
| { | ||||
| 	close(); | ||||
| 	 | ||||
|  | ||||
| 	this->fname = fname; | ||||
| 	offset = 0; | ||||
| 	refreshWait = 3; | ||||
| @@ -790,7 +793,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay) | ||||
| 		// Unsupported codec | ||||
| 		return false; | ||||
| 	} | ||||
|    | ||||
|  | ||||
| 	// Open codec | ||||
| #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 6, 0) | ||||
| 	if ( avcodec_open(codecContext, codec) < 0 ) | ||||
| @@ -802,7 +805,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay) | ||||
| 		codec = NULL; | ||||
| 		return false; | ||||
| 	} | ||||
|    | ||||
|  | ||||
| 	// Allocate video frame | ||||
| 	frame = avcodec_alloc_frame(); | ||||
|  | ||||
| @@ -826,8 +829,8 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay) | ||||
| 	// Convert the image into YUV format that SDL uses | ||||
| 	if (overlay) | ||||
| 	{ | ||||
| 		sws = sws_getContext(codecContext->width, codecContext->height,  | ||||
| 							 codecContext->pix_fmt, codecContext->width, codecContext->height,  | ||||
| 		sws = sws_getContext(codecContext->width, codecContext->height, | ||||
| 							 codecContext->pix_fmt, codecContext->width, codecContext->height, | ||||
| 							 PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL); | ||||
| 	} | ||||
| 	else | ||||
| @@ -842,8 +845,8 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay) | ||||
| 		default: return false; | ||||
| 		} | ||||
|  | ||||
| 		sws = sws_getContext(codecContext->width, codecContext->height,  | ||||
| 							 codecContext->pix_fmt, codecContext->width, codecContext->height,  | ||||
| 		sws = sws_getContext(codecContext->width, codecContext->height, | ||||
| 							 codecContext->pix_fmt, codecContext->width, codecContext->height, | ||||
| 							 screenFormat, SWS_BICUBIC, NULL, NULL, NULL); | ||||
| 	} | ||||
|  | ||||
| @@ -905,7 +908,7 @@ bool CVideoPlayer::nextFrame() | ||||
|  | ||||
| 					if (overlay) { | ||||
| 						SDL_LockYUVOverlay(overlay); | ||||
| 				 | ||||
|  | ||||
| 						pict.data[0] = overlay->pixels[0]; | ||||
| 						pict.data[1] = overlay->pixels[2]; | ||||
| 						pict.data[2] = overlay->pixels[1]; | ||||
| @@ -945,7 +948,7 @@ void CVideoPlayer::show( int x, int y, SDL_Surface *dst, bool update ) | ||||
| 	pos.x = x; | ||||
| 	pos.y = y; | ||||
| 	CSDL_Ext::blitSurface(dest, &destRect, dst, &pos); | ||||
| 	 | ||||
|  | ||||
| 	if (update) | ||||
| 		SDL_UpdateRect(dst, pos.x, pos.y, pos.w, pos.h); | ||||
| } | ||||
| @@ -968,14 +971,14 @@ void CVideoPlayer::update( int x, int y, SDL_Surface *dst, bool forceRedraw, boo | ||||
| 		else | ||||
| 		{ | ||||
| 			open(fname); | ||||
| 			nextFrame();			 | ||||
| 			 | ||||
| 			nextFrame(); | ||||
|  | ||||
| 			// The y position is wrong at the first frame. | ||||
| 			// Note: either the windows player or the linux player is | ||||
| 			// broken. Compensate here until the bug is found.			 | ||||
| 			// broken. Compensate here until the bug is found. | ||||
| 			show(x, y--, dst, update); | ||||
| 		} | ||||
| 	}  | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		redraw(x, y, dst, update); | ||||
| @@ -986,7 +989,7 @@ void CVideoPlayer::update( int x, int y, SDL_Surface *dst, bool forceRedraw, boo | ||||
|  | ||||
| void CVideoPlayer::close() | ||||
| { | ||||
| 	fname = "";	 | ||||
| 	fname = ""; | ||||
| 	if (sws) | ||||
| 	{ | ||||
| 		sws_freeContext(sws); | ||||
| @@ -1049,7 +1052,7 @@ bool CVideoPlayer::playVideo(int x, int y, SDL_Surface *dst, bool stopOnKey) | ||||
|  | ||||
| 	while(nextFrame()) | ||||
| 	{ | ||||
| 		 | ||||
|  | ||||
| 		if(stopOnKey && keyDown()) | ||||
| 			return false; | ||||
|  | ||||
| @@ -1071,7 +1074,7 @@ bool CVideoPlayer::openAndPlayVideo(std::string name, int x, int y, SDL_Surface | ||||
| 	close(); | ||||
| 	return ret; | ||||
| } | ||||
| 	 | ||||
|  | ||||
| CVideoPlayer::~CVideoPlayer() | ||||
| { | ||||
| 	close(); | ||||
|   | ||||
| @@ -89,11 +89,11 @@ public: | ||||
| 	ui8 defActionsDef; //default auto actions | ||||
| 	ui8 captureChildren; //all newly created objects will get their parents from stack and will be added to parents children list | ||||
| 	std::list<CIntObject *> createdObj; //stack of objs being created | ||||
| 	 | ||||
|  | ||||
| 	static SDLKey arrowToNum(SDLKey key); //converts arrow key to according numpad key | ||||
| 	static SDLKey numToDigit(SDLKey key);//converts numpad digit key to normal digit key | ||||
| 	static bool isNumKey(SDLKey key, bool number = true); //checks if key is on numpad (numbers - check only for numpad digits) | ||||
| 	static bool isArrowKey(SDLKey key);  | ||||
| 	static bool isArrowKey(SDLKey key); | ||||
| 	static bool amIGuiThread(); | ||||
| 	static void pushSDLEvent(int type, int usercode = 0); | ||||
| }; | ||||
| @@ -122,8 +122,8 @@ struct SSetCaptureState | ||||
|  | ||||
| namespace Colors | ||||
| { | ||||
| 	 | ||||
| }; | ||||
|  | ||||
| } | ||||
|  | ||||
| #define OBJ_CONSTRUCTION SObjectConstruction obj__i(this) | ||||
| #define OBJ_CONSTRUCTION_CAPTURING_ALL defActions = 255; SSetCaptureState obj__i1(true, 255); SObjectConstruction obj__i(this) | ||||
|   | ||||
| @@ -22,7 +22,7 @@ | ||||
| CPicture::CPicture( SDL_Surface *BG, int x, int y, bool Free ) | ||||
| { | ||||
| 	init(); | ||||
| 	bg = BG;  | ||||
| 	bg = BG; | ||||
| 	freeSurf = Free; | ||||
| 	pos.x += x; | ||||
| 	pos.y += y; | ||||
| @@ -33,7 +33,7 @@ CPicture::CPicture( SDL_Surface *BG, int x, int y, bool Free ) | ||||
| CPicture::CPicture( const std::string &bmpname, int x, int y ) | ||||
| { | ||||
| 	init(); | ||||
| 	bg = BitmapHandler::loadBitmap(bmpname);  | ||||
| 	bg = BitmapHandler::loadBitmap(bmpname); | ||||
| 	freeSurf = true;; | ||||
| 	pos.x += x; | ||||
| 	pos.y += y; | ||||
| @@ -315,12 +315,12 @@ void CAdventureMapButton::clickLeft(tribool down, bool previousState) | ||||
| 	if(isBlocked()) | ||||
| 		return; | ||||
|  | ||||
| 	if (down)  | ||||
| 	if (down) | ||||
| 	{ | ||||
| 		if (!soundDisabled) | ||||
| 			CCS->soundh->playSound(soundBase::button); | ||||
| 		setState(PRESSED); | ||||
| 	}  | ||||
| 	} | ||||
| 	else if(hoverable && hovered) | ||||
| 		setState(HIGHLIGHTED); | ||||
| 	else | ||||
| @@ -355,8 +355,8 @@ void CAdventureMapButton::hover (bool on) | ||||
| 	if(pressedL && on) | ||||
| 		setState(PRESSED); | ||||
|  | ||||
| 	std::string *name = (vstd::contains(hoverTexts,getState()))  | ||||
| 		? (&hoverTexts[getState()])  | ||||
| 	std::string *name = (vstd::contains(hoverTexts,getState())) | ||||
| 		? (&hoverTexts[getState()]) | ||||
| 		: (vstd::contains(hoverTexts,0) ? (&hoverTexts[0]) : NULL); | ||||
| 	if(name && name->size() && !isBlocked()) //if there is no name, there is nohing to display also | ||||
| 	{ | ||||
| @@ -533,7 +533,7 @@ void CHighlightableButtonsGroup::addButton(const std::map<int,std::string> &tool | ||||
| 	bt->callback += boost::bind(&CHighlightableButtonsGroup::selectionChanged,this,bt->ID); | ||||
| 	bt->onlyOn = true; | ||||
| 	buttons.push_back(bt); | ||||
| }	 | ||||
| } | ||||
|  | ||||
| CHighlightableButtonsGroup::CHighlightableButtonsGroup(const CFunctionList2<void(int)> &OnChange, bool musicLikeButtons) | ||||
| : onChange(OnChange), musicLike(musicLikeButtons) | ||||
| @@ -597,7 +597,7 @@ void CHighlightableButtonsGroup::showAll(SDL_Surface * to) | ||||
|  | ||||
| void CHighlightableButtonsGroup::block( ui8 on ) | ||||
| { | ||||
| 	for(size_t i=0;i<buttons.size(); ++i)  | ||||
| 	for(size_t i=0;i<buttons.size(); ++i) | ||||
| 	{ | ||||
| 		buttons[i]->block(on); | ||||
| 	} | ||||
| @@ -614,7 +614,7 @@ void CSlider::mouseMoved (const SDL_MouseMotionEvent & sEvent) | ||||
| 	double v = 0; | ||||
| 	if(horizontal) | ||||
| 	{ | ||||
| 		if(	std::abs(sEvent.y-(pos.y+pos.h/2)) > pos.h/2+40  ||  std::abs(sEvent.x-(pos.x+pos.w/2)) > pos.w/2  )  | ||||
| 		if(	std::abs(sEvent.y-(pos.y+pos.h/2)) > pos.h/2+40  ||  std::abs(sEvent.x-(pos.x+pos.w/2)) > pos.w/2  ) | ||||
| 			return; | ||||
| 		v = sEvent.x - pos.x - 24; | ||||
| 		v *= positions; | ||||
| @@ -622,7 +622,7 @@ void CSlider::mouseMoved (const SDL_MouseMotionEvent & sEvent) | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		if(std::abs(sEvent.x-(pos.x+pos.w/2)) > pos.w/2+40  ||  std::abs(sEvent.y-(pos.y+pos.h/2)) > pos.h/2  )  | ||||
| 		if(std::abs(sEvent.x-(pos.x+pos.w/2)) > pos.w/2+40  ||  std::abs(sEvent.y-(pos.y+pos.h/2)) > pos.h/2  ) | ||||
| 			return; | ||||
| 		v = sEvent.y - pos.y - 24; | ||||
| 		v *= positions; | ||||
| @@ -746,7 +746,7 @@ CSlider::CSlider(int x, int y, int totalw, boost::function<void(int)> Moved, int | ||||
| 		left->pos.x = pos.x; | ||||
| 		right->pos.x = pos.x + totalw - 16; | ||||
| 	} | ||||
| 	else  | ||||
| 	else | ||||
| 	{ | ||||
| 		left->pos.x = slider->pos.x = right->pos.x = pos.x; | ||||
| 		left->pos.y = pos.y; | ||||
| @@ -859,7 +859,7 @@ void CSlider::keyPressed(const SDL_KeyboardEvent & key) | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	moveTo(moveDest);  | ||||
| 	moveTo(moveDest); | ||||
| } | ||||
|  | ||||
| void CSlider::moveToMax() | ||||
| @@ -1270,7 +1270,7 @@ void CBoundedLabel::showAll(SDL_Surface * to) | ||||
| 	CIntObject::showAll(to); | ||||
|  | ||||
| 	const Font &f = *graphics->fonts[font]; | ||||
| 	int lineHeight =  f.height;  | ||||
| 	int lineHeight =  f.height; | ||||
| 	int lineCapacity = pos.h / lineHeight; | ||||
|  | ||||
| 	int dy = f.height; //line height | ||||
| @@ -1301,7 +1301,7 @@ void CBoundedLabel::recalculateLines(const std::string &Txt) | ||||
| 	lines.clear(); | ||||
|  | ||||
| 	const Font &f = *graphics->fonts[font]; | ||||
| 	int lineHeight =  f.height;  | ||||
| 	int lineHeight =  f.height; | ||||
|  | ||||
| 	lines = CMessage::breakText(Txt, pos.w, font); | ||||
|  | ||||
| @@ -1313,13 +1313,13 @@ void CBoundedLabel::recalculateLines(const std::string &Txt) | ||||
|  | ||||
| CLabelGroup::CLabelGroup(EFonts Font, EAlignment Align, const SDL_Color &Color): | ||||
| 	font(Font), align(Align), color(Color) | ||||
| {}; | ||||
| {} | ||||
|  | ||||
| void CLabelGroup::add(int x, int y, const std::string &text) | ||||
| { | ||||
| 	OBJ_CONSTRUCTION_CAPTURING_ALL; | ||||
| 	new CLabel(x, y, font, align, color, text); | ||||
| }; | ||||
| } | ||||
|  | ||||
| CTextBox::CTextBox(std::string Text, const Rect &rect, int SliderStyle, EFonts Font /*= FONT_SMALL*/, EAlignment Align /*= TOPLEFT*/, const SDL_Color &Color /*= Colors::Cornsilk*/) | ||||
| :CBoundedLabel(rect.x, rect.y, Font, Align, Color, Text), sliderStyle(SliderStyle), slider(NULL) | ||||
| @@ -1340,7 +1340,7 @@ void CTextBox::recalculateLines(const std::string &Txt) | ||||
| 	vstd::clear_pointer(slider); | ||||
| 	lines.clear(); | ||||
| 	const Font &f = *graphics->fonts[font]; | ||||
| 	int lineHeight =  f.height;  | ||||
| 	int lineHeight =  f.height; | ||||
| 	int lineCapacity = pos.h / lineHeight; | ||||
|  | ||||
| 	lines = CMessage::breakText(Txt, pos.w, font); | ||||
| @@ -1535,7 +1535,7 @@ void CTextInput::clickLeft( tribool down, bool previousState ) | ||||
|  | ||||
| void CTextInput::keyPressed( const SDL_KeyboardEvent & key ) | ||||
| { | ||||
| 	if(!focus || key.state != SDL_PRESSED)  | ||||
| 	if(!focus || key.state != SDL_PRESSED) | ||||
| 		return; | ||||
|  | ||||
| 	if(key.keysym.sym == SDLK_TAB) | ||||
|   | ||||
| @@ -193,4 +193,4 @@ namespace CSDL_Ext | ||||
| 	void applyEffect(SDL_Surface * surf, const SDL_Rect * rect, int mode); //mode: 0 - sepia, 1 - grayscale | ||||
|  | ||||
| 	std::string trimToFit(std::string text, int widthLimit, EFonts font); | ||||
| }; | ||||
| } | ||||
|   | ||||
| @@ -55,12 +55,12 @@ bool CArtifact::isBig () const | ||||
| // { | ||||
| // 	if (!vstd::contains(possibleSlots, slotID)) | ||||
| // 		return false; | ||||
| //  | ||||
| // | ||||
| // 	// Can't put an artifact in a locked slot. | ||||
| // 	std::map<ui16, const CArtifact*>::const_iterator it = artifWorn.find(slotID); | ||||
| // 	if (it != artifWorn.end() && it->second->id == 145) | ||||
| // 		return false; | ||||
| //  | ||||
| // | ||||
| // 	// Check if a combination artifact fits. | ||||
| // 	// TODO: Might want a more general algorithm? | ||||
| // 	//       Assumes that misc & rings fits only in their slots, and others in only one slot and no duplicates. | ||||
| @@ -71,14 +71,14 @@ bool CArtifact::isBig () const | ||||
| // 		const ui16 miscSlots[] = {9, 10, 11, 12, 18}; | ||||
| // 		int rings = 0; | ||||
| // 		int misc = 0; | ||||
| //  | ||||
| // | ||||
| // 		VLC->arth->unequipArtifact(tempArtifWorn, slotID); | ||||
| //  | ||||
| // 		BOOST_FOREACH(ui32 constituentID, *constituents)  | ||||
| // | ||||
| // 		BOOST_FOREACH(ui32 constituentID, *constituents) | ||||
| // 		{ | ||||
| // 			const CArtifact& constituent = *VLC->arth->artifacts[constituentID]; | ||||
| // 			const int slot = constituent.possibleSlots[0]; | ||||
| //  | ||||
| // | ||||
| // 			if (slot == 6 || slot == 7) | ||||
| // 				rings++; | ||||
| // 			else if ((slot >= 9 && slot <= 12) || slot == 18) | ||||
| @@ -86,18 +86,18 @@ bool CArtifact::isBig () const | ||||
| // 			else if (tempArtifWorn.find(slot) != tempArtifWorn.end()) | ||||
| // 				return false; | ||||
| // 		} | ||||
| //  | ||||
| // | ||||
| // 		// Ensure enough ring slots are free | ||||
| // 		for (int i = 0; i < sizeof(ringSlots)/sizeof(*ringSlots); i++)  | ||||
| // 		for (int i = 0; i < sizeof(ringSlots)/sizeof(*ringSlots); i++) | ||||
| // 		{ | ||||
| // 			if (tempArtifWorn.find(ringSlots[i]) == tempArtifWorn.end() || ringSlots[i] == slotID) | ||||
| // 				rings--; | ||||
| // 		} | ||||
| // 		if (rings > 0) | ||||
| // 			return false; | ||||
| //  | ||||
| // | ||||
| // 		// Ensure enough misc slots are free. | ||||
| // 		for (int i = 0; i < sizeof(miscSlots)/sizeof(*miscSlots); i++)  | ||||
| // 		for (int i = 0; i < sizeof(miscSlots)/sizeof(*miscSlots); i++) | ||||
| // 		{ | ||||
| // 			if (tempArtifWorn.find(miscSlots[i]) == tempArtifWorn.end() || miscSlots[i] == slotID) | ||||
| // 				misc--; | ||||
| @@ -105,7 +105,7 @@ bool CArtifact::isBig () const | ||||
| // 		if (misc > 0) | ||||
| // 			return false; | ||||
| // 	} | ||||
| //  | ||||
| // | ||||
| // 	return true; | ||||
| // } | ||||
|  | ||||
| @@ -113,16 +113,16 @@ bool CArtifact::isBig () const | ||||
| // { | ||||
| // 	if (constituentOf == NULL || !vstd::contains(*constituentOf, artifactID)) | ||||
| // 		return false; | ||||
| //  | ||||
| // | ||||
| // 	const CArtifact &artifact = *VLC->arth->artifacts[artifactID]; | ||||
| // 	assert(artifact.constituents); | ||||
| //  | ||||
| // 	BOOST_FOREACH(ui32 constituentID, *artifact.constituents)  | ||||
| // | ||||
| // 	BOOST_FOREACH(ui32 constituentID, *artifact.constituents) | ||||
| // 	{ | ||||
| // 		bool found = false; | ||||
| // 		for (std::map<ui16, const CArtifact*>::const_iterator it = artifWorn.begin(); it != artifWorn.end(); ++it)  | ||||
| // 		for (std::map<ui16, const CArtifact*>::const_iterator it = artifWorn.begin(); it != artifWorn.end(); ++it) | ||||
| // 		{ | ||||
| // 			if (it->second->id == constituentID)  | ||||
| // 			if (it->second->id == constituentID) | ||||
| // 			{ | ||||
| // 				found = true; | ||||
| // 				break; | ||||
| @@ -131,7 +131,7 @@ bool CArtifact::isBig () const | ||||
| // 		if (!found) | ||||
| // 			return false; | ||||
| // 	} | ||||
| //  | ||||
| // | ||||
| // 	return true; | ||||
| // } | ||||
|  | ||||
| @@ -237,7 +237,7 @@ void CArtHandler::loadArtifacts(bool onlyTxt) | ||||
| 	std::vector<ui16> slots; | ||||
| 	slots += 17, 16, 15, 14, 13, 18, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0; | ||||
| 	growingArtifacts += 146, 147, 148, 150, 151, 152, 153; | ||||
| 	static std::map<char, CArtifact::EartClass> classes =  | ||||
| 	static std::map<char, CArtifact::EartClass> classes = | ||||
| 	  map_list_of('S',CArtifact::ART_SPECIAL)('T',CArtifact::ART_TREASURE)('N',CArtifact::ART_MINOR)('J',CArtifact::ART_MAJOR)('R',CArtifact::ART_RELIC); | ||||
|  | ||||
| 	CLegacyConfigParser parser("DATA/ARTRAITS.TXT"); | ||||
| @@ -287,7 +287,7 @@ void CArtHandler::loadArtifacts(bool onlyTxt) | ||||
|  | ||||
| 		// Fill in information about combined artifacts. Should perhaps be moved to a config file? | ||||
| 		nart.constituentOf = NULL; | ||||
| 		switch (nart.id)  | ||||
| 		switch (nart.id) | ||||
| 		{ | ||||
| 			case 129: // Angelic Alliance | ||||
| 				nart.constituents = new std::vector<ui32>(); | ||||
| @@ -363,7 +363,7 @@ void CArtHandler::loadArtifacts(bool onlyTxt) | ||||
| 		const JsonNode config(ResourceID("config/commanders.json")); | ||||
| 		BOOST_FOREACH(const JsonNode &artifact, config["artifacts"].Vector()) | ||||
| 		{ | ||||
| 			auto ga = dynamic_cast <CGrowingArtifact *>(artifacts[artifact["id"].Float()].get());  | ||||
| 			auto ga = dynamic_cast <CGrowingArtifact *>(artifacts[artifact["id"].Float()].get()); | ||||
| 			BOOST_FOREACH (auto b, artifact["bonusesPerLevel"].Vector()) | ||||
| 			{ | ||||
| 				ga->bonusesPerLevel.push_back (std::pair <ui16, Bonus> (b["level"].Float(), *ParseBonus (b["bonus"].Vector()))); | ||||
| @@ -382,11 +382,11 @@ void CArtHandler::loadArtifacts(bool onlyTxt) | ||||
| 	addBonuses(); | ||||
|  | ||||
| 	// Populate reverse mappings of combinational artifacts. | ||||
| 	BOOST_FOREACH(CArtifact *artifact, artifacts)  | ||||
| 	BOOST_FOREACH(CArtifact *artifact, artifacts) | ||||
| 	{ | ||||
| 		if (artifact->constituents != NULL)  | ||||
| 		if (artifact->constituents != NULL) | ||||
| 		{ | ||||
| 			BOOST_FOREACH(ui32 constituentID, *artifact->constituents)  | ||||
| 			BOOST_FOREACH(ui32 constituentID, *artifact->constituents) | ||||
| 			{ | ||||
| 				if (artifacts[constituentID]->constituentOf == NULL) | ||||
| 					artifacts[constituentID]->constituentOf = new std::vector<ui32>(); | ||||
| @@ -484,7 +484,7 @@ ui16 CArtHandler::getArtSync (ui32 rand, int flags) | ||||
| 	std::vector<ConstTransitivePtr<CArtifact> > out; | ||||
| 	getAllowed(out, flags); | ||||
| 	CArtifact *art = out[rand % out.size()]; | ||||
| 	return art->id;	 | ||||
| 	return art->id; | ||||
| } | ||||
| void CArtHandler::getAllowed(std::vector<ConstTransitivePtr<CArtifact> > &out, int flags) | ||||
| { | ||||
| @@ -575,7 +575,7 @@ void CArtHandler::makeItCreatureArt (int aid, bool onlyCreature /*=true*/) | ||||
| 		a->possibleSlots[ArtBearer::COMMANDER].clear(); | ||||
| 	} | ||||
| 	a->possibleSlots[ArtBearer::CREATURE].push_back(ArtifactPosition::CREATURE_SLOT); | ||||
| }; | ||||
| } | ||||
|  | ||||
| void CArtHandler::makeItCommanderArt (int aid, bool onlyCommander /*=true*/) | ||||
| { | ||||
| @@ -587,7 +587,7 @@ void CArtHandler::makeItCommanderArt (int aid, bool onlyCommander /*=true*/) | ||||
| 	} | ||||
| 	for (int i = ArtifactPosition::COMMANDER1; i <= ArtifactPosition::COMMANDER6; ++i) | ||||
| 		a->possibleSlots[ArtBearer::COMMANDER].push_back(i); | ||||
| }; | ||||
| } | ||||
|  | ||||
| void CArtHandler::addBonuses() | ||||
| { | ||||
| @@ -601,11 +601,11 @@ void CArtHandler::addBonuses() | ||||
|  | ||||
| 	//Propagators/limiters used more than once | ||||
| 	auto battleWidePropagator = make_shared<CPropagatorNodeType>(CBonusSystemNode::BATTLE); | ||||
| 	auto visitedTownPropagator = make_shared<CPropagatorNodeType>(CBonusSystemNode::TOWN_AND_VISITOR);  | ||||
| 	auto visitedTownPropagator = make_shared<CPropagatorNodeType>(CBonusSystemNode::TOWN_AND_VISITOR); | ||||
|  | ||||
| 	auto shooterOnlyLimiter = make_shared<HasAnotherBonusLimiter>(Bonus::SHOOTER); | ||||
| 	auto dragonNatureLimiter = make_shared<HasAnotherBonusLimiter>(Bonus::DRAGON_NATURE); | ||||
| 	 | ||||
|  | ||||
| 	//Attack bonus artifacts (Weapons) | ||||
| 	ART_PRIM_SKILL(7,0,+2); //Centaur Axe | ||||
| 	ART_PRIM_SKILL(8,0,+3); //Blackshard of the Dead Knight | ||||
| @@ -625,7 +625,7 @@ void CArtHandler::addBonuses() | ||||
| 	ART_PRIM_SKILL(18,0,-3);  //Sentinel's Shield | ||||
|  | ||||
| 	//Knowledge bonus artifacts (Helmets) | ||||
| 	ART_PRIM_SKILL(19,3,+1); //Helm of the Alabaster Unicorn  | ||||
| 	ART_PRIM_SKILL(19,3,+1); //Helm of the Alabaster Unicorn | ||||
| 	ART_PRIM_SKILL(20,3,+2); //Skull Helmet | ||||
| 	ART_PRIM_SKILL(21,3,+3); //Helm of Chaos | ||||
| 	ART_PRIM_SKILL(22,3,+4); //Crown of the Supreme Magi | ||||
| @@ -662,13 +662,13 @@ void CArtHandler::addBonuses() | ||||
| 	ART_POWER_AND_KNOWLEDGE(43,+3); //Necklace of Dragonteeth | ||||
| 	ART_POWER_AND_KNOWLEDGE(44,+4); //Crown of Dragontooth | ||||
|  | ||||
| 	//Luck and morale  | ||||
| 	//Luck and morale | ||||
| 	ART_MORALE(45,+1); //Still Eye of the Dragon | ||||
| 	ART_LUCK(45,+1); //Still Eye of the Dragon | ||||
| 	ART_LUCK(46,+1); //Clover of Fortune | ||||
| 	ART_LUCK(47,+1); //Cards of Prophecy | ||||
| 	ART_LUCK(48,+1); //Ladybird of Luck | ||||
| 	ART_MORALE(49,+1); //Badge of Courage -> +1 morale  | ||||
| 	ART_MORALE(49,+1); //Badge of Courage -> +1 morale | ||||
| 	giveArtBonus(49,Bonus::MIND_IMMUNITY,0); //immunity to hostile mind spells: | ||||
| 	ART_MORALE(50,+1); //Crest of Valor | ||||
| 	ART_MORALE(51,+1); //Glyph of Gallantry | ||||
| @@ -772,11 +772,11 @@ void CArtHandler::addBonuses() | ||||
| 	giveArtBonus(121,Bonus::CREATURE_GROWTH,+2,4, visitedTownPropagator); //Arms of Legion | ||||
| 	giveArtBonus(122,Bonus::CREATURE_GROWTH,+1,5, visitedTownPropagator); //Head of Legion | ||||
|  | ||||
| 	//Sea Captain's Hat  | ||||
| 	giveArtBonus(123,Bonus::WHIRLPOOL_PROTECTION,0);  | ||||
| 	giveArtBonus(123,Bonus::SEA_MOVEMENT,+500);  | ||||
| 	giveArtBonus(123,Bonus::SPELL,3,0, Bonus::INDEPENDENT_MAX);  | ||||
| 	giveArtBonus(123,Bonus::SPELL,3,1, Bonus::INDEPENDENT_MAX);  | ||||
| 	//Sea Captain's Hat | ||||
| 	giveArtBonus(123,Bonus::WHIRLPOOL_PROTECTION,0); | ||||
| 	giveArtBonus(123,Bonus::SEA_MOVEMENT,+500); | ||||
| 	giveArtBonus(123,Bonus::SPELL,3,0, Bonus::INDEPENDENT_MAX); | ||||
| 	giveArtBonus(123,Bonus::SPELL,3,1, Bonus::INDEPENDENT_MAX); | ||||
|  | ||||
| 	giveArtBonus(124, Bonus::SPELLS_OF_LEVEL,3,1); //Spellbinder's Hat | ||||
| 	giveArtBonus(125, Bonus::BATTLE_NO_FLEEING,0, 0, battleWidePropagator); //Shackles of War | ||||
| @@ -919,32 +919,32 @@ void CArtHandler::clear() | ||||
| // void CArtHandler::equipArtifact( std::map<ui16, const CArtifact*> &artifWorn, ui16 slotID, const CArtifact* art ) const | ||||
| // { | ||||
| // 	unequipArtifact(artifWorn, slotID); | ||||
| //  | ||||
| // | ||||
| // 	if (art) //false when artifact is NULL -> slot set to empty | ||||
| // 	{ | ||||
| // 		const CArtifact &artifact = *art; | ||||
| //  | ||||
| // | ||||
| // 		// Add artifact. | ||||
| // 		artifWorn[slotID] = art; | ||||
| //  | ||||
| // | ||||
| // 		// Add locks, in reverse order of being removed. | ||||
| // 		if (artifact.constituents != NULL)  | ||||
| // 		if (artifact.constituents != NULL) | ||||
| // 		{ | ||||
| // 			bool destConsumed = false; // Determines which constituent that will be counted for together with the artifact. | ||||
| //  | ||||
| // 			BOOST_FOREACH(ui32 constituentID, *artifact.constituents)  | ||||
| // | ||||
| // 			BOOST_FOREACH(ui32 constituentID, *artifact.constituents) | ||||
| // 			{ | ||||
| // 				const CArtifact &constituent = *artifacts[constituentID]; | ||||
| //  | ||||
| // 				if (!destConsumed && vstd::contains(constituent.possibleSlots, slotID))  | ||||
| // | ||||
| // 				if (!destConsumed && vstd::contains(constituent.possibleSlots, slotID)) | ||||
| // 				{ | ||||
| // 					destConsumed = true; | ||||
| // 				}  | ||||
| // 				else  | ||||
| // 				} | ||||
| // 				else | ||||
| // 				{ | ||||
| // 					BOOST_FOREACH(ui16 slot, constituent.possibleSlots)  | ||||
| // 					BOOST_FOREACH(ui16 slot, constituent.possibleSlots) | ||||
| // 					{ | ||||
| // 						if (!vstd::contains(artifWorn, slot))  | ||||
| // 						if (!vstd::contains(artifWorn, slot)) | ||||
| // 						{ | ||||
| // 							artifWorn[slot] = VLC->arth->artifacts[145]; //lock | ||||
| // 							break; | ||||
| @@ -955,7 +955,7 @@ void CArtHandler::clear() | ||||
| // 		} | ||||
| // 	} | ||||
| // } | ||||
| //  | ||||
| // | ||||
| // /** | ||||
| //  * Locally unequips an artifact from a hero's worn slots. | ||||
| //  * Does not test if the operation is legal. | ||||
| @@ -966,30 +966,30 @@ void CArtHandler::clear() | ||||
| // { | ||||
| // 	if (!vstd::contains(artifWorn, slotID)) | ||||
| // 		return; | ||||
| //  | ||||
| // | ||||
| // 	const CArtifact &artifact = *artifWorn[slotID]; | ||||
| //  | ||||
| // | ||||
| // 	// Remove artifact, if it's not already removed. | ||||
| // 	artifWorn.erase(slotID); | ||||
| //  | ||||
| // | ||||
| // 	// Remove locks, in reverse order of being added. | ||||
| // 	if (artifact.constituents != NULL)  | ||||
| // 	if (artifact.constituents != NULL) | ||||
| // 	{ | ||||
| // 		bool destConsumed = false; | ||||
| //  | ||||
| // 		BOOST_FOREACH(ui32 constituentID, *artifact.constituents)  | ||||
| // | ||||
| // 		BOOST_FOREACH(ui32 constituentID, *artifact.constituents) | ||||
| // 		{ | ||||
| // 			const CArtifact &constituent = *artifacts[constituentID]; | ||||
| //  | ||||
| // 			if (!destConsumed && vstd::contains(constituent.possibleSlots, slotID))  | ||||
| // | ||||
| // 			if (!destConsumed && vstd::contains(constituent.possibleSlots, slotID)) | ||||
| // 			{ | ||||
| // 				destConsumed = true; | ||||
| // 			}  | ||||
| // 			else  | ||||
| // 			} | ||||
| // 			else | ||||
| // 			{ | ||||
| // 				BOOST_REVERSE_FOREACH(ui16 slot, constituent.possibleSlots)  | ||||
| // 				BOOST_REVERSE_FOREACH(ui16 slot, constituent.possibleSlots) | ||||
| // 				{ | ||||
| // 					if (vstd::contains(artifWorn, slot) && artifWorn[slot]->id == 145)  | ||||
| // 					if (vstd::contains(artifWorn, slot) && artifWorn[slot]->id == 145) | ||||
| // 					{ | ||||
| // 						artifWorn.erase(slot); | ||||
| // 						break; | ||||
| @@ -1152,7 +1152,7 @@ std::vector<const CArtifact *> CArtifactInstance::assemblyPossibilities(const CA | ||||
| 		|| artType->constituents) //combined artifact already: no combining of combined artifacts... for now. | ||||
| 		return ret; | ||||
|  | ||||
| 	BOOST_FOREACH(ui32 possibleCombinedArt, *artType->constituentOf)  | ||||
| 	BOOST_FOREACH(ui32 possibleCombinedArt, *artType->constituentOf) | ||||
| 	{ | ||||
| 		const CArtifact * const artifact = VLC->arth->artifacts[possibleCombinedArt]; | ||||
| 		assert(artifact->constituents); | ||||
| @@ -1228,7 +1228,7 @@ bool CArtifactInstance::isPart(const CArtifactInstance *supposedPart) const | ||||
| 	return supposedPart == this; | ||||
| } | ||||
|  | ||||
| bool CCombinedArtifactInstance::canBePutAt(const CArtifactSet *artSet, int slot, bool assumeDestRemoved /*= false*/) const  | ||||
| bool CCombinedArtifactInstance::canBePutAt(const CArtifactSet *artSet, int slot, bool assumeDestRemoved /*= false*/) const | ||||
| { | ||||
| 	bool canMainArtifactBePlaced = CArtifactInstance::canBePutAt(artSet, slot, assumeDestRemoved); | ||||
| 	if(!canMainArtifactBePlaced) | ||||
| @@ -1319,7 +1319,7 @@ void CCombinedArtifactInstance::putAt(ArtifactLocation al) | ||||
| 				const bool suggestedPosValid = ci.art->canBePutAt(suggestedPos); | ||||
|  | ||||
| 				int pos = -1; | ||||
| 				if(inActiveSlot  &&  suggestedPosValid) //there is a valid suggestion where to place lock  | ||||
| 				if(inActiveSlot  &&  suggestedPosValid) //there is a valid suggestion where to place lock | ||||
| 					pos = ci.slot; | ||||
| 				else | ||||
| 					ci.slot = pos = ci.art->firstAvailableSlot(al.getHolderArtSet()); | ||||
| @@ -1517,7 +1517,7 @@ CArtifactSet::~CArtifactSet() | ||||
| ArtSlotInfo & CArtifactSet::retreiveNewArtSlot(ui16 slot) | ||||
| { | ||||
| 	assert(!vstd::contains(artifactsWorn, slot)); | ||||
| 	ArtSlotInfo &ret = slot < GameConstants::BACKPACK_START  | ||||
| 	ArtSlotInfo &ret = slot < GameConstants::BACKPACK_START | ||||
| 		? artifactsWorn[slot] | ||||
| 		: *artifactsInBackpack.insert(artifactsInBackpack.begin() + (slot - GameConstants::BACKPACK_START), ArtSlotInfo()); | ||||
|  | ||||
|   | ||||
| @@ -25,9 +25,10 @@ | ||||
| #else | ||||
| 	#define WIN32_LEAN_AND_MEAN //excludes rarely used stuff from windows headers - delete this line if something is missing | ||||
| 	#include <windows.h> | ||||
| #ifndef __MINGW32__ | ||||
| 	#include <dbghelp.h> | ||||
| 	#pragma comment(lib, "dbghelp.lib") | ||||
|  | ||||
| #endif | ||||
| 	typedef WORD TColor; | ||||
| 	HANDLE handleIn; | ||||
| 	HANDLE handleOut; | ||||
| @@ -108,19 +109,20 @@ LONG WINAPI onUnhandledException(EXCEPTION_POINTERS* exception) | ||||
|  | ||||
| 	if (einfo->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) | ||||
| 	{ | ||||
| 		tlog1 << "Attempt to " << (einfo->ExceptionInformation[0] == 1 ? "write to " : "read from ")  | ||||
| 		tlog1 << "Attempt to " << (einfo->ExceptionInformation[0] == 1 ? "write to " : "read from ") | ||||
| 			<< "0x" <<  std::setw(8) << (void*)einfo->ExceptionInformation[1] << std::endl;; | ||||
| 	} | ||||
| 	const DWORD threadId = ::GetCurrentThreadId(); | ||||
| 	tlog1 << "Thread ID: " << threadId << " [" << std::dec << std::setw(0) << threadId << "]\n"; | ||||
|  | ||||
| #ifndef __MINGW32__ | ||||
| 	//exception info to be placed in the dump | ||||
| 	MINIDUMP_EXCEPTION_INFORMATION meinfo = {threadId, exception, TRUE}; | ||||
|  | ||||
| 	//create file where dump will be placed | ||||
| 	char *mname = NULL; | ||||
| 	char buffer[MAX_PATH + 1]; | ||||
| 	HMODULE hModule = NULL;	 | ||||
| 	HMODULE hModule = NULL; | ||||
| 	GetModuleFileNameA(hModule, buffer, MAX_PATH); | ||||
| 	mname = strrchr(buffer, '\\'); | ||||
| 	if (mname != 0) | ||||
| @@ -132,6 +134,7 @@ LONG WINAPI onUnhandledException(EXCEPTION_POINTERS* exception) | ||||
| 	HANDLE dfile = CreateFileA(mname, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0); | ||||
| 	tlog1 << "Crash info will be put in " << mname << std::endl; | ||||
| 	MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), dfile, MiniDumpWithDataSegs, &meinfo, 0, 0); | ||||
| #endif | ||||
| 	MessageBoxA(0, "VCMI has crashed. We are sorry. File with information about encountered problem has been created.", "VCMI Crashhandler", MB_OK | MB_ICONERROR); | ||||
| 	return EXCEPTION_EXECUTE_HANDLER; | ||||
| } | ||||
| @@ -233,7 +236,7 @@ CConsoleHandler::~CConsoleHandler() | ||||
| } | ||||
| void CConsoleHandler::end() | ||||
| { | ||||
| 	if (thread)  | ||||
| 	if (thread) | ||||
| 	{ | ||||
| #ifndef _WIN32 | ||||
| 		thread->interrupt(); | ||||
|   | ||||
| @@ -133,7 +133,7 @@ public: | ||||
|  | ||||
| class DLL_LINKAGE CCreatureSet : public IArmyDescriptor //seven combined creatures | ||||
| { | ||||
| 	CCreatureSet(const CCreatureSet&);; | ||||
| 	CCreatureSet(const CCreatureSet&); | ||||
| 	CCreatureSet &operator=(const CCreatureSet&); | ||||
| public: | ||||
| 	TSlots stacks; //slots[slot_id]->> pair(creature_id,creature_quantity) | ||||
| @@ -143,7 +143,7 @@ public: | ||||
| 	virtual ~CCreatureSet(); | ||||
| 	virtual void armyChanged(); | ||||
|  | ||||
| 	const CStackInstance &operator[](TSlot slot) const;  | ||||
| 	const CStackInstance &operator[](TSlot slot) const; | ||||
|  | ||||
| 	const TSlots &Slots() const {return stacks;} | ||||
|  | ||||
| @@ -161,13 +161,13 @@ public: | ||||
| 	void giveStackExp(expType exp); | ||||
| 	void setStackExp(TSlot slot, expType exp); | ||||
|  | ||||
| 	//derivative  | ||||
| 	//derivative | ||||
| 	void eraseStack(TSlot slot); //slot must be occupied | ||||
| 	void joinStack(TSlot slot, CStackInstance * stack); //adds new stack to the existing stack of the same type | ||||
| 	void changeStackCount(TSlot slot, TQuantity toAdd); //stack must exist! | ||||
| 	bool setCreature (TSlot slot, TCreature type, TQuantity quantity) OVERRIDE; //replaces creature in stack; slots 0 to 6, if quantity=0 erases stack | ||||
| 	void setToArmy(CSimpleArmy &src); //erases all our army and moves stacks from src to us; src MUST NOT be an armed object! WARNING: use it wisely. Or better do not use at all. | ||||
| 	 | ||||
|  | ||||
| 	const CStackInstance& getStack(TSlot slot) const; //stack must exist | ||||
| 	const CStackInstance* getStackPtr(TSlot slot) const; //if stack doesn't exist, returns NULL | ||||
| 	const CCreature* getCreature(TSlot slot) const; //workaround of map issue; | ||||
| @@ -186,7 +186,7 @@ public: | ||||
| 	ui64 getPower (TSlot slot) const; //value of specific stack | ||||
| 	std::string getRoughAmount (TSlot slot) const; //rough size of specific stack | ||||
| 	bool hasStackAtSlot(TSlot slot) const; | ||||
| 	 | ||||
|  | ||||
| 	bool contains(const CStackInstance *stack) const; | ||||
| 	bool canBeMergedWith(const CCreatureSet &cs, bool allowMergingStacks = true) const; | ||||
|  | ||||
|   | ||||
| @@ -53,13 +53,13 @@ std::vector<const CArtifact *> CGTownInstance::merchantArtifacts; | ||||
| std::vector<int> CGTownInstance::universitySkills; | ||||
|  | ||||
| void IObjectInterface::onHeroVisit(const CGHeroInstance * h) const | ||||
| {}; | ||||
| {} | ||||
|  | ||||
| void IObjectInterface::onHeroLeave(const CGHeroInstance * h) const | ||||
| {}; | ||||
| {} | ||||
|  | ||||
| void IObjectInterface::newTurn () const | ||||
| {}; | ||||
| {} | ||||
|  | ||||
| IObjectInterface::~IObjectInterface() | ||||
| {} | ||||
|   | ||||
| @@ -35,7 +35,7 @@ void CThreadHelper::processTasks() | ||||
| 	while(true) | ||||
| 	{ | ||||
| 		{ | ||||
| 			boost::unique_lock<boost::mutex> lock(rtinm);  | ||||
| 			boost::unique_lock<boost::mutex> lock(rtinm); | ||||
| 			if((pom = currentTask) >= amount) | ||||
| 				break; | ||||
| 			else | ||||
| @@ -50,6 +50,7 @@ void CThreadHelper::processTasks() | ||||
| void setThreadName(const std::string &name) | ||||
| { | ||||
| #ifdef _WIN32 | ||||
| #ifndef __GNUC__ | ||||
| 	//follows http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx | ||||
| 	const DWORD MS_VC_EXCEPTION=0x406D1388; | ||||
| #pragma pack(push,8) | ||||
| @@ -67,6 +68,7 @@ void setThreadName(const std::string &name) | ||||
| 	info.dwThreadID = -1; | ||||
| 	info.dwFlags = 0; | ||||
|  | ||||
|  | ||||
| 	__try | ||||
| 	{ | ||||
| 		RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info ); | ||||
| @@ -74,7 +76,11 @@ void setThreadName(const std::string &name) | ||||
| 	__except(EXCEPTION_EXECUTE_HANDLER) | ||||
| 	{ | ||||
| 	} | ||||
| #else | ||||
| //not supported | ||||
| #endif | ||||
|  | ||||
| #else | ||||
| 	 prctl(PR_SET_NAME, name.c_str(), 0, 0, 0); | ||||
| #endif | ||||
| } | ||||
| } | ||||
|   | ||||
| @@ -5,8 +5,8 @@ | ||||
|  | ||||
| #include <boost/type_traits/is_fundamental.hpp> | ||||
| #include <boost/type_traits/is_enum.hpp> | ||||
| #include <boost/type_traits/is_pointer.hpp>  | ||||
| #include <boost/type_traits/is_class.hpp>  | ||||
| #include <boost/type_traits/is_pointer.hpp> | ||||
| #include <boost/type_traits/is_class.hpp> | ||||
| #include <boost/type_traits/is_base_of.hpp> | ||||
| #include <boost/type_traits/is_array.hpp> | ||||
| #include <boost/type_traits/remove_pointer.hpp> | ||||
| @@ -66,7 +66,7 @@ namespace boost | ||||
| 		class basic_socket_acceptor; | ||||
| 	} | ||||
| 	class mutex; | ||||
| }; | ||||
| } | ||||
|  | ||||
| enum SerializationLvl | ||||
| { | ||||
| @@ -200,7 +200,7 @@ struct LoadWrong | ||||
|  | ||||
| template<typename T> | ||||
| struct SerializationLevel | ||||
| {     | ||||
| { | ||||
| 	typedef mpl::integral_c_tag tag; | ||||
| 	typedef | ||||
| 		typename mpl::eval_if< | ||||
| @@ -252,7 +252,7 @@ public: | ||||
| 	TTypeVecMap vectors; //entry must be a pointer to vector containing pointers to the objects of key type | ||||
|  | ||||
| 	bool smartVectorMembersSerialization; | ||||
| 	bool sendStackInstanceByIds;  | ||||
| 	bool sendStackInstanceByIds; | ||||
|  | ||||
| 	CSerializer(); | ||||
| 	~CSerializer(); | ||||
| @@ -274,7 +274,7 @@ public: | ||||
| 	const VectorisedObjectInfo<T> *getVectorisedTypeInfo() | ||||
| 	{ | ||||
| 		const std::type_info *myType = NULL; | ||||
| //  | ||||
| // | ||||
| // 		if(boost::is_base_of<CGObjectInstance, T>::value) //ugly workaround to support also types derived from CGObjectInstance -> if we encounter one, treat it aas CGObj.. | ||||
| // 			myType = &typeid(CGObjectInstance); | ||||
| // 		else | ||||
| @@ -342,7 +342,7 @@ public: | ||||
| template <typename T> //metafunction returning CGObjectInstance if T is its derivate or T elsewise | ||||
| struct VectorisedTypeFor | ||||
| { | ||||
| 	typedef typename  | ||||
| 	typedef typename | ||||
| 		//if | ||||
| 		mpl::eval_if<boost::is_base_of<CGObjectInstance,T>, | ||||
| 		mpl::identity<CGObjectInstance>, | ||||
| @@ -471,8 +471,8 @@ public: | ||||
| 	COSer & operator&(const T & t) | ||||
| 	{ | ||||
| 		return * this->This() << t; | ||||
| 	}	 | ||||
| 	 | ||||
| 	} | ||||
|  | ||||
|  | ||||
|  | ||||
| 	int write(const void * data, unsigned size); | ||||
| @@ -539,7 +539,7 @@ public: | ||||
| 	//that part of ptr serialization was extracted to allow customization of its behavior in derived classes | ||||
| 	template <typename T> | ||||
| 	void savePointerHlp(ui16 tid, const T &data) | ||||
| 	{		 | ||||
| 	{ | ||||
| 		if(!tid) | ||||
| 			*this << *data;	 //if type is unregistered simply write all data in a standard way | ||||
| 		else | ||||
| @@ -556,7 +556,7 @@ public: | ||||
| 	template <typename T> | ||||
| 	void save(const T &data) | ||||
| 	{ | ||||
| 		typedef  | ||||
| 		typedef | ||||
| 			//if | ||||
| 			typename mpl::eval_if< mpl::equal_to<SerializationLevel<T>,mpl::int_<Primitive> >, | ||||
| 			mpl::identity<SavePrimitive<Serializer,T> >, | ||||
| @@ -703,7 +703,7 @@ public: | ||||
| 	~CISer() | ||||
| 	{ | ||||
| 		std::map<ui16,CBasicPointerLoader*>::iterator iter; | ||||
| 			 | ||||
|  | ||||
| 		for(iter = loaders.begin(); iter != loaders.end(); iter++) | ||||
| 			delete iter->second; | ||||
| 	} | ||||
| @@ -725,18 +725,18 @@ public: | ||||
| 		this->This()->load(t); | ||||
| 		return * this->This(); | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	template<class T> | ||||
| 	CISer & operator&(T & t) | ||||
| 	{ | ||||
| 		return * this->This() >> t; | ||||
| 	}	 | ||||
| 	} | ||||
|  | ||||
| 	int write(const void * data, unsigned size); | ||||
| 	template <typename T> | ||||
| 	void load(T &data) | ||||
| 	{ | ||||
| 		typedef  | ||||
| 		typedef | ||||
| 			//if | ||||
| 			typename mpl::eval_if< mpl::equal_to<SerializationLevel<T>,mpl::int_<Primitive> >, | ||||
| 			mpl::identity<LoadPrimitive<Serializer,T> >, | ||||
| @@ -782,7 +782,7 @@ public: | ||||
| 		nonConstT &hlp = const_cast<nonConstT&>(data); | ||||
| 		hlp.serialize(*this,fileVersion); | ||||
| 		//data.serialize(*this,myVersion); | ||||
| 	}	 | ||||
| 	} | ||||
|  | ||||
| 	template <typename T> | ||||
| 	void loadSerializable(T &data) | ||||
| @@ -806,7 +806,7 @@ public: | ||||
| 			data = NULL; | ||||
| 			return; | ||||
| 		} | ||||
| 				 | ||||
|  | ||||
| 		if(smartVectorMembersSerialization) | ||||
| 		{ | ||||
| 			typedef typename boost::remove_const<typename boost::remove_pointer<T>::type>::type TObjectType; //eg: const CGHeroInstance * => CGHeroInstance | ||||
| @@ -830,7 +830,7 @@ public: | ||||
| 				return; | ||||
| 		} | ||||
|  | ||||
| 		ui32 pid = 0xffffffff; //pointer id (or maybe rather pointee id)  | ||||
| 		ui32 pid = 0xffffffff; //pointer id (or maybe rather pointee id) | ||||
| 		if(smartPointerSerialization) | ||||
| 		{ | ||||
| 			*this >> pid; //get the id | ||||
| @@ -1081,7 +1081,7 @@ template<typename T> | ||||
| class CApplier | ||||
| { | ||||
| public: | ||||
| 	std::map<ui16,T*> apps;  | ||||
| 	std::map<ui16,T*> apps; | ||||
|  | ||||
| 	~CApplier() | ||||
| 	{ | ||||
|   | ||||
| @@ -217,7 +217,7 @@ struct DLL_LINKAGE Bonus | ||||
| 	enum BonusDuration //when bonus is automatically removed | ||||
| 	{ | ||||
| 		PERMANENT = 1, | ||||
| 		ONE_BATTLE = 2, //at the end of battle  | ||||
| 		ONE_BATTLE = 2, //at the end of battle | ||||
| 		ONE_DAY = 4,   //at the end of day | ||||
| 		ONE_WEEK = 8, //at the end of week (bonus lasts till the end of week, thats NOT 7 days | ||||
| 		N_TURNS = 16, //used during battles, after battle bonus is always removed | ||||
| @@ -236,7 +236,7 @@ struct DLL_LINKAGE Bonus | ||||
|  | ||||
| 	enum LimitEffect | ||||
| 	{ | ||||
| 		NO_LIMIT = 0,  | ||||
| 		NO_LIMIT = 0, | ||||
| 		ONLY_DISTANCE_FIGHT=1, ONLY_MELEE_FIGHT, //used to mark bonuses for attack/defense primary skills from spells like Precision (distance only) | ||||
| 		ONLY_ENEMY_ARMY | ||||
| 	}; | ||||
| @@ -265,7 +265,7 @@ struct DLL_LINKAGE Bonus | ||||
| 	TLimiterPtr limiter; | ||||
| 	TPropagatorPtr propagator; | ||||
|  | ||||
| 	std::string description;  | ||||
| 	std::string description; | ||||
|  | ||||
| 	Bonus(ui16 Dur, ui8 Type, ui8 Src, si32 Val, ui32 ID, std::string Desc, si32 Subtype=-1); | ||||
| 	Bonus(ui16 Dur, ui8 Type, ui8 Src, si32 Val, ui32 ID, si32 Subtype=-1, ui8 ValType = ADDITIVE_VALUE); | ||||
| @@ -357,7 +357,7 @@ private: | ||||
| public: | ||||
| 	BonusList(bool BelongsToTree = false); | ||||
| 	BonusList(const BonusList &bonusList); | ||||
| 	BonusList& operator=(const BonusList &bonusList);  | ||||
| 	BonusList& operator=(const BonusList &bonusList); | ||||
|  | ||||
| 	// wrapper functions of the STL vector container | ||||
| 	std::vector<Bonus*>::size_type size() const { return bonuses.size(); } | ||||
| @@ -393,7 +393,7 @@ public: | ||||
|  | ||||
| 	//void limit(const CBonusSystemNode &node); //erases bonuses using limitor | ||||
| 	void eliminateDuplicates(); | ||||
| 	 | ||||
|  | ||||
| 	// remove_if implementation for STL vector types | ||||
| 	template <class Predicate> | ||||
| 	void remove_if(Predicate pred) | ||||
| @@ -409,7 +409,7 @@ public: | ||||
| 		bonuses.resize(newList.size()); | ||||
| 		std::copy(newList.begin(), newList.end(), bonuses.begin()); | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	template <class InputIterator> | ||||
| 	void insert(const int position, InputIterator first, InputIterator last); | ||||
|  | ||||
| @@ -465,7 +465,7 @@ public: | ||||
| 	CPropagatorNodeType(); | ||||
| 	CPropagatorNodeType(ui8 NodeType); | ||||
| 	bool shouldBeAttached(CBonusSystemNode *dest); | ||||
| 	//CBonusSystemNode *getDestNode(CBonusSystemNode *source, CBonusSystemNode *redParent, CBonusSystemNode *redChild) OVERRIDE;  | ||||
| 	//CBonusSystemNode *getDestNode(CBonusSystemNode *source, CBonusSystemNode *redParent, CBonusSystemNode *redChild) OVERRIDE; | ||||
|  | ||||
| 	template <typename Handler> void serialize(Handler &h, const int version) | ||||
| 	{ | ||||
| @@ -479,7 +479,7 @@ struct BonusLimitationContext | ||||
| 	const CBonusSystemNode &node; | ||||
| 	const BonusList &alreadyAccepted; | ||||
| }; | ||||
| 	 | ||||
|  | ||||
| class DLL_LINKAGE ILimiter | ||||
| { | ||||
| public: | ||||
| @@ -500,7 +500,7 @@ public: | ||||
| 	// * selector is predicate that tests if HeroBonus matches our criteria | ||||
| 	// * root is node on which call was made (NULL will be replaced with this) | ||||
| 	//interface | ||||
| 	virtual const TBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root = NULL, const std::string &cachingStr = "") const = 0;  | ||||
| 	virtual const TBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root = NULL, const std::string &cachingStr = "") const = 0; | ||||
| 	void getModifiersWDescr(TModDescr &out, const CSelector &selector, const std::string &cachingStr = "") const;  //out: pairs<modifier value, modifier description> | ||||
| 	int getBonusesCount(const CSelector &selector, const std::string &cachingStr = "") const; | ||||
| 	int valOfBonuses(const CSelector &selector, const std::string &cachingStr = "") const; | ||||
| @@ -508,7 +508,7 @@ public: | ||||
| 	const TBonusListPtr getBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr = "") const; | ||||
| 	const TBonusListPtr getBonuses(const CSelector &selector, const std::string &cachingStr = "") const; | ||||
|  | ||||
| 	//legacy interface  | ||||
| 	//legacy interface | ||||
| 	int valOfBonuses(Bonus::BonusType type, const CSelector &selector) const; | ||||
| 	int valOfBonuses(Bonus::BonusType type, int subtype = -1) const; //subtype -> subtype of bonus, if -1 then anyt; | ||||
| 	bool hasBonusOfType(Bonus::BonusType type, int subtype = -1) const;//determines if hero has a bonus of given type (and optionally subtype) | ||||
| @@ -540,16 +540,16 @@ private: | ||||
|  | ||||
| 	TNodesVector parents; //parents -> we inherit bonuses from them, we may attach our bonuses to them | ||||
| 	TNodesVector children; | ||||
| 	 | ||||
|  | ||||
| 	ui8 nodeType; | ||||
| 	std::string description; | ||||
| 	 | ||||
| 	static const bool cachingEnabled;  | ||||
|  | ||||
| 	static const bool cachingEnabled; | ||||
| 	mutable BonusList cachedBonuses; | ||||
| 	mutable int cachedLast;	 | ||||
| 	mutable int cachedLast; | ||||
| 	static int treeChanged; | ||||
|  | ||||
| 	// Setting a value to cachingStr before getting any bonuses caches the result for later requests.  | ||||
| 	// Setting a value to cachingStr before getting any bonuses caches the result for later requests. | ||||
| 	// This string needs to be unique, that's why it has to be setted in the following manner: | ||||
| 	// [property key]_[value] => only for selector | ||||
| 	mutable std::map<std::string, TBonusListPtr > cachedRequests; | ||||
| @@ -562,7 +562,7 @@ public: | ||||
|  | ||||
| 	explicit CBonusSystemNode(); | ||||
| 	virtual ~CBonusSystemNode(); | ||||
| 	 | ||||
|  | ||||
| 	void limitBonuses(const BonusList &allBonuses, BonusList &out) const; //out will bo populed with bonuses that are not limited here | ||||
| 	TBonusListPtr limitBonuses(const BonusList &allBonuses) const; //same as above, returns out by val for convienence | ||||
| 	const TBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root = NULL, const std::string &cachingStr = "") const; | ||||
| @@ -573,8 +573,8 @@ public: | ||||
| 	void getParents(TNodes &out);  //retrieves list of parent nodes (nodes to inherit bonuses from) | ||||
| 	void getRedParents(TNodes &out);  //retrieves list of red parent nodes (nodes bonuses propagate from) | ||||
| 	void getRedAncestors(TNodes &out); | ||||
| 	void getRedChildren(TNodes &out);  | ||||
| 	void getRedDescendants(TNodes &out);  | ||||
| 	void getRedChildren(TNodes &out); | ||||
| 	void getRedDescendants(TNodes &out); | ||||
| 	Bonus *getBonus(const CSelector &selector); | ||||
|  | ||||
| 	void attachTo(CBonusSystemNode *parent); | ||||
| @@ -604,7 +604,7 @@ public: | ||||
| 	void deserializationFix(); | ||||
| 	void exportBonus(Bonus * b); | ||||
| 	void exportBonuses(); | ||||
| 	 | ||||
|  | ||||
| 	static void incrementTreeChangedNum(); | ||||
| 	BonusList &getBonusList(); | ||||
| 	const BonusList &getBonusList() const; | ||||
| @@ -628,7 +628,7 @@ public: | ||||
| 	} | ||||
| 	enum ENodeTypes | ||||
| 	{ | ||||
| 		UNKNOWN, STACK_INSTANCE, STACK_BATTLE, SPECIALITY, ARTIFACT, CREATURE, ARTIFACT_INSTANCE, HERO, PLAYER, TEAM,  | ||||
| 		UNKNOWN, STACK_INSTANCE, STACK_BATTLE, SPECIALITY, ARTIFACT, CREATURE, ARTIFACT_INSTANCE, HERO, PLAYER, TEAM, | ||||
| 		TOWN_AND_VISITOR, BATTLE | ||||
| 	}; | ||||
| }; | ||||
| @@ -641,7 +641,7 @@ namespace NBonus | ||||
| 	//DLL_LINKAGE const HeroBonus * get(const CBonusSystemNode *obj, int from, int id ); | ||||
| 	DLL_LINKAGE void getModifiersWDescr(const CBonusSystemNode *obj, TModDescr &out, Bonus::BonusType type, int subtype = -1 );  //out: pairs<modifier value, modifier description> | ||||
| 	DLL_LINKAGE int getCount(const CBonusSystemNode *obj, int from, int id); | ||||
| }; | ||||
| } | ||||
|  | ||||
| /// generates HeroBonus from given data | ||||
| inline Bonus makeFeatureVal(Bonus::BonusType type, ui8 duration, si16 subtype, si32 value, Bonus::BonusSource source, ui16 turnsRemain = 0, si32 additionalInfo = 0) | ||||
| @@ -725,7 +725,7 @@ public: | ||||
| 	{ | ||||
| 		return turnsRequested <= 0					//every present effect will last zero (or "less") turns | ||||
| 			|| !(bonus->duration & Bonus::N_TURNS)	//so do every not expriing after N-turns effect | ||||
| 			|| bonus->turnsRemain > turnsRequested;	 | ||||
| 			|| bonus->turnsRemain > turnsRequested; | ||||
| 	} | ||||
| 	CWillLastTurns& operator()(const int &setVal) | ||||
| 	{ | ||||
| @@ -769,7 +769,7 @@ public: | ||||
| 	} | ||||
| }; | ||||
|  | ||||
| class DLL_LINKAGE CreatureNativeTerrainLimiter : public ILimiter //applies only to creatures that are on their native terrain  | ||||
| class DLL_LINKAGE CreatureNativeTerrainLimiter : public ILimiter //applies only to creatures that are on their native terrain | ||||
| { | ||||
| public: | ||||
| 	si8 terrainType; | ||||
|   | ||||
| @@ -48,7 +48,7 @@ struct CPack | ||||
| 	{ | ||||
| 		tlog1 << "CPack serialized... this should not happen!\n"; | ||||
| 	} | ||||
| 	DLL_LINKAGE void applyGs(CGameState *gs) | ||||
| 	void applyGs(CGameState *gs) | ||||
| 	{}; | ||||
| }; | ||||
|  | ||||
| @@ -60,7 +60,7 @@ struct CPackForClient : public CPack | ||||
| 	void applyFirstCl(CClient *cl)//called before applying to gs | ||||
| 	{}; | ||||
| 	void applyCl(CClient *cl)//called after applying to gs | ||||
| 	{};  | ||||
| 	{}; | ||||
| }; | ||||
|  | ||||
| struct CPackForServer : public CPack | ||||
| @@ -70,7 +70,7 @@ struct CPackForServer : public CPack | ||||
| 	CGameState* GS(CGameHandler *gh); | ||||
| 	CPackForServer() | ||||
| 	{ | ||||
| 		type = 2;  | ||||
| 		type = 2; | ||||
| 		c = NULL; | ||||
| 		player = 255; | ||||
| 	}; | ||||
| @@ -82,7 +82,7 @@ struct CPackForServer : public CPack | ||||
| struct Query : public CPackForClient | ||||
| { | ||||
| 	ui32 queryID; // equals to -1 if it is not an actual query (and should not be answered) | ||||
| 	 | ||||
|  | ||||
| 	Query() | ||||
| 	{ | ||||
| 		queryID = -1; | ||||
| @@ -95,7 +95,7 @@ struct MetaString : public CPack //2001 helper for object scrips | ||||
| private: | ||||
| 	enum EMessage {TEXACT_STRING, TLOCAL_STRING, TNUMBER, TREPLACE_ESTRING, TREPLACE_LSTRING, TREPLACE_NUMBER, TREPLACE_PLUSNUMBER}; | ||||
| public: | ||||
| 	enum {GENERAL_TXT=1, XTRAINFO_TXT, OBJ_NAMES, RES_NAMES, ART_NAMES, ARRAY_TXT, CRE_PL_NAMES, CREGENS, MINE_NAMES,  | ||||
| 	enum {GENERAL_TXT=1, XTRAINFO_TXT, OBJ_NAMES, RES_NAMES, ART_NAMES, ARRAY_TXT, CRE_PL_NAMES, CREGENS, MINE_NAMES, | ||||
| 		MINE_EVNTS, ADVOB_TXT, ART_EVNTS, SPELL_NAME, SEC_SKILL_NAME, CRE_SING_NAMES, CREGENS4, COLOR, ART_DESCR}; | ||||
|  | ||||
| 	std::vector<ui8> message; //vector of EMessage | ||||
| @@ -169,7 +169,7 @@ public: | ||||
| 	{ | ||||
| 		type = 2001; | ||||
| 	} | ||||
| };  | ||||
| }; | ||||
|  | ||||
| struct StackLocation | ||||
| { | ||||
| @@ -276,16 +276,16 @@ struct SetResource : public CPackForClient //102 | ||||
| 	{ | ||||
| 		h & player & resid & val; | ||||
| 	} | ||||
| };  | ||||
| }; | ||||
|  struct SetResources : public CPackForClient //104 | ||||
|  { | ||||
|  	SetResources(){type = 104;}; | ||||
|  	void applyCl(CClient *cl); | ||||
|  	DLL_LINKAGE void applyGs(CGameState *gs); | ||||
|   | ||||
|  | ||||
|  	ui8 player; | ||||
|  	TResources res; //res[resid] => res amount | ||||
|   | ||||
|  | ||||
|  	template <typename Handler> void serialize(Handler &h, const int version) | ||||
|  	{ | ||||
|  		h & player & res; | ||||
| @@ -307,7 +307,7 @@ struct SetPrimSkill : public CPackForClient //105 | ||||
| 	{ | ||||
| 		h & abs & id & which & val; | ||||
| 	} | ||||
| };  | ||||
| }; | ||||
| struct SetSecSkill : public CPackForClient //106 | ||||
| { | ||||
| 	SetSecSkill(){type = 106;}; | ||||
| @@ -344,7 +344,7 @@ struct HeroVisitCastle : public CPackForClient //108 | ||||
| 	{ | ||||
| 		h & flags & tid & hid; | ||||
| 	} | ||||
| };  | ||||
| }; | ||||
| struct ChangeSpells : public CPackForClient //109 | ||||
| { | ||||
| 	ChangeSpells(){type = 109;}; | ||||
| @@ -359,7 +359,7 @@ struct ChangeSpells : public CPackForClient //109 | ||||
| 	{ | ||||
| 		h & learn & hid & spells; | ||||
| 	} | ||||
| };  | ||||
| }; | ||||
|  | ||||
| struct SetMana : public CPackForClient //110 | ||||
| { | ||||
| @@ -402,7 +402,7 @@ struct FoWChange : public CPackForClient //112 | ||||
| 	{ | ||||
| 		h & tiles & player & mode; | ||||
| 	} | ||||
| };  | ||||
| }; | ||||
|  | ||||
| struct SetAvailableHeroes : public CPackForClient //113 | ||||
| { | ||||
| @@ -431,7 +431,7 @@ struct GiveBonus :  public CPackForClient //115 | ||||
| { | ||||
| 	GiveBonus(ui8 Who = 0) | ||||
| 	{ | ||||
| 		who = Who;  | ||||
| 		who = Who; | ||||
| 		type = 115; | ||||
| 	} | ||||
|  | ||||
| @@ -454,7 +454,7 @@ struct ChangeObjPos : public CPackForClient //116 | ||||
| { | ||||
| 	ChangeObjPos() | ||||
| 	{ | ||||
| 		type = 116;  | ||||
| 		type = 116; | ||||
| 		flags = 0; | ||||
| 	} | ||||
| 	void applyFirstCl(CClient *cl); | ||||
| @@ -495,7 +495,7 @@ struct RemoveBonus :  public CPackForClient //118 | ||||
| { | ||||
| 	RemoveBonus(ui8 Who = 0) | ||||
| 	{ | ||||
| 		who = Who;  | ||||
| 		who = Who; | ||||
| 		type = 118; | ||||
| 	} | ||||
|  | ||||
| @@ -584,7 +584,7 @@ struct RemoveObject : public CPackForClient //500 | ||||
| 	{ | ||||
| 		h & id; | ||||
| 	} | ||||
| };  | ||||
| }; | ||||
| struct TryMoveHero : public CPackForClient //501 | ||||
| { | ||||
| 	TryMoveHero(){type = 501;humanKnows=false; attackedFrom = int3(-1, -1, -1);}; | ||||
| @@ -616,24 +616,24 @@ struct TryMoveHero : public CPackForClient //501 | ||||
| // 	SetGarrisons(){type = 502;}; | ||||
| // 	void applyCl(CClient *cl); | ||||
| // 	DLL_LINKAGE void applyGs(CGameState *gs); | ||||
| //  | ||||
| // | ||||
| // 	std::map<ui32,CCreatureSet> garrs; | ||||
| //  | ||||
| // | ||||
| // 	template <typename Handler> void serialize(Handler &h, const int version) | ||||
| // 	{ | ||||
| // 		h & garrs; | ||||
| // 	} | ||||
| // };  | ||||
| // }; | ||||
|  | ||||
| struct NewStructures : public CPackForClient //504 | ||||
| { | ||||
| 	NewStructures(){type = 504;}; | ||||
| 	void applyCl(CClient *cl); | ||||
| 	DLL_LINKAGE virtual void applyGs(CGameState *gs); | ||||
| 	DLL_LINKAGE void applyGs(CGameState *gs); | ||||
|  | ||||
| 	si32 tid; | ||||
| 	std::set<si32> bid; | ||||
| 	si16 builded;  | ||||
| 	si16 builded; | ||||
|  | ||||
| 	template <typename Handler> void serialize(Handler &h, const int version) | ||||
| 	{ | ||||
| @@ -648,7 +648,7 @@ struct RazeStructures : public CPackForClient //505 | ||||
|  | ||||
| 	si32 tid; | ||||
| 	std::set<si32> bid; | ||||
| 	si16 destroyed;  | ||||
| 	si16 destroyed; | ||||
|  | ||||
| 	template <typename Handler> void serialize(Handler &h, const int version) | ||||
| 	{ | ||||
| @@ -668,7 +668,7 @@ struct SetAvailableCreatures : public CPackForClient //506 | ||||
| 	{ | ||||
| 		h & tid & creatures; | ||||
| 	} | ||||
| };   | ||||
| }; | ||||
| struct SetHeroesInTown : public CPackForClient //508 | ||||
| { | ||||
| 	SetHeroesInTown(){type = 508;}; | ||||
| @@ -689,19 +689,19 @@ struct SetHeroesInTown : public CPackForClient //508 | ||||
| // 	void applyCl(CClient *cl); | ||||
| // 	DLL_LINKAGE void applyGs(CGameState *gs); | ||||
| // 	DLL_LINKAGE void setArtAtPos(ui16 pos, const CArtifact* art); | ||||
| //  | ||||
| // | ||||
| // 	si32 hid; | ||||
| // 	std::vector<const CArtifact*> artifacts; //hero's artifacts from bag | ||||
| // 	std::map<ui16, const CArtifact*> artifWorn; //map<position,artifact_id>; positions: 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5 | ||||
| //  | ||||
| // | ||||
| // 	template <typename Handler> void serialize(Handler &h, const int version) | ||||
| // 	{ | ||||
| // 		h & hid & artifacts & artifWorn; | ||||
| // 	} | ||||
| //  | ||||
| // | ||||
| // 	std::vector<const CArtifact*> equipped, unequipped; //used locally | ||||
| // 	BonusList gained, lost; //used locally as hlp when applying | ||||
| // };    | ||||
| // }; | ||||
|  | ||||
| struct HeroRecruited : public CPackForClient //515 | ||||
| { | ||||
| @@ -717,7 +717,7 @@ struct HeroRecruited : public CPackForClient //515 | ||||
| 	{ | ||||
| 		h & hid & tid & tile & player; | ||||
| 	} | ||||
| };   | ||||
| }; | ||||
|  | ||||
| struct GiveHero : public CPackForClient //516 | ||||
| { | ||||
| @@ -733,7 +733,7 @@ struct GiveHero : public CPackForClient //516 | ||||
| 	{ | ||||
| 		h & id & player; | ||||
| 	} | ||||
| };   | ||||
| }; | ||||
|  | ||||
| struct OpenWindow : public CPackForClient //517 | ||||
| { | ||||
| @@ -1072,7 +1072,7 @@ struct NewTurn : public CPackForClient //101 | ||||
| 	{ | ||||
| 		h & heroes & cres & res & day & resetBuilded & specialWeek & creatureid; | ||||
| 	} | ||||
| };  | ||||
| }; | ||||
|  | ||||
| struct Component : public CPack //2002 helper for object scrips informations | ||||
| { | ||||
| @@ -1110,10 +1110,10 @@ struct InfoWindow : public CPackForClient //103  - displays simple info window | ||||
| 	{ | ||||
| 		h & text & components & player & soundID; | ||||
| 	} | ||||
| 	InfoWindow()  | ||||
| 	{  | ||||
| 	InfoWindow() | ||||
| 	{ | ||||
| 		type = 103; | ||||
| 		soundID = 0;  | ||||
| 		soundID = 0; | ||||
| 	} | ||||
| }; | ||||
|  | ||||
| @@ -1134,7 +1134,7 @@ struct SetObjectProperty : public CPackForClient//1001 | ||||
| 	ui32 val; | ||||
| 	SetObjectProperty(){type = 1001;}; | ||||
| 	SetObjectProperty(ui32 ID, ui8 What, ui32 Val):id(ID),what(What),val(Val){type = 1001;}; | ||||
| 	 | ||||
|  | ||||
| 	template <typename Handler> void serialize(Handler &h, const int version) | ||||
| 	{ | ||||
| 		h & id & what & val; | ||||
| @@ -1149,7 +1149,7 @@ struct SetHoverName : public CPackForClient//1002 | ||||
| 	MetaString name; | ||||
| 	SetHoverName(){type = 1002;}; | ||||
| 	SetHoverName(ui32 ID, MetaString& Name):id(ID),name(Name){type = 1002;}; | ||||
| 	 | ||||
|  | ||||
| 	template <typename Handler> void serialize(Handler &h, const int version) | ||||
| 	{ | ||||
| 		h & id & name; | ||||
| @@ -1165,7 +1165,7 @@ struct HeroLevelUp : public Query//2000 | ||||
| 	std::vector<ui16> skills; | ||||
|  | ||||
| 	HeroLevelUp(){type = 2000;}; | ||||
| 	 | ||||
|  | ||||
| 	template <typename Handler> void serialize(Handler &h, const int version) | ||||
| 	{ | ||||
| 		h & queryID & heroid & primskill & level & skills; | ||||
| @@ -1273,14 +1273,14 @@ struct BattleStart : public CPackForClient//3000 | ||||
|  | ||||
| 	BattleInfo * info; | ||||
|  | ||||
| 	 | ||||
|  | ||||
| 	template <typename Handler> void serialize(Handler &h, const int version) | ||||
| 	{ | ||||
| 		h & info; | ||||
| 	} | ||||
| }; | ||||
| struct BattleNextRound : public CPackForClient//3001 | ||||
| {	 | ||||
| { | ||||
| 	BattleNextRound(){type = 3001;}; | ||||
| 	void applyFirstCl(CClient *cl); | ||||
| 	void applyCl(CClient *cl); | ||||
| @@ -1874,7 +1874,7 @@ struct GarrisonHeroSwap : public CPackForServer | ||||
| { | ||||
| 	GarrisonHeroSwap(){}; | ||||
| 	GarrisonHeroSwap(si32 TID):tid(TID){}; | ||||
| 	si32 tid;  | ||||
| 	si32 tid; | ||||
|  | ||||
| 	bool applyGh(CGameHandler *gh); | ||||
| 	template <typename Handler> void serialize(Handler &h, const int version) | ||||
| @@ -1971,7 +1971,7 @@ struct HireHero : public CPackForServer | ||||
| 	} | ||||
| }; | ||||
|  | ||||
| struct BuildBoat : public CPackForServer  | ||||
| struct BuildBoat : public CPackForServer | ||||
| { | ||||
| 	BuildBoat(){}; | ||||
| 	si32 objid; //where player wants to buy a boat | ||||
| @@ -2084,7 +2084,7 @@ struct PlayerMessage : public CPackForClient, public CPackForServer //513 | ||||
| 	{ | ||||
| 		h & text & player; | ||||
| 	} | ||||
| };  | ||||
| }; | ||||
|  | ||||
|  | ||||
| struct SetSelection : public CPackForClient, public CPackForServer //514 | ||||
| @@ -2241,7 +2241,7 @@ struct RequestOptionsChange : public CPregamePackToHost | ||||
| { | ||||
| 	enum {TOWN, HERO, BONUS}; | ||||
| 	ui8 what; | ||||
| 	si8 direction; //-1 or +1  | ||||
| 	si8 direction; //-1 or +1 | ||||
| 	ui8 playerID; | ||||
|  | ||||
| 	RequestOptionsChange(ui8 What, si8 Dir, ui8 Player) | ||||
|   | ||||
| @@ -10,7 +10,7 @@ namespace Res | ||||
| 	class ResourceSet; | ||||
| 	bool canAfford(const ResourceSet &res, const ResourceSet &price); //can a be used to pay price b | ||||
|  | ||||
| 	enum ERes  | ||||
| 	enum ERes | ||||
| 	{ | ||||
| 		WOOD = 0, MERCURY, ORE, SULFUR, CRYSTAL, GEMS, GOLD, MITHRIL | ||||
| 	}; | ||||
| @@ -25,7 +25,7 @@ namespace Res | ||||
|  | ||||
|  | ||||
| #define scalarOperator(OPSIGN)									\ | ||||
| 		DLL_LINKAGE ResourceSet operator OPSIGN(const TResource &rhs) const	\ | ||||
| 		ResourceSet operator OPSIGN(const TResource &rhs) const	\ | ||||
| 		{														\ | ||||
| 			ResourceSet ret = *this;							\ | ||||
| 			for(int i = 0; i < size(); i++)						\ | ||||
| @@ -37,7 +37,7 @@ namespace Res | ||||
|  | ||||
|  | ||||
| #define vectorOperator(OPSIGN)										\ | ||||
| 		DLL_LINKAGE ResourceSet operator OPSIGN(const ResourceSet &rhs) const	\ | ||||
| 		ResourceSet operator OPSIGN(const ResourceSet &rhs) const	\ | ||||
| 		{															\ | ||||
| 			ResourceSet ret = *this;								\ | ||||
| 			for(int i = 0; i < size(); i++)							\ | ||||
| @@ -48,7 +48,7 @@ namespace Res | ||||
|  | ||||
|  | ||||
| #define opEqOperator(OPSIGN, RHS_TYPE)							\ | ||||
| 		DLL_LINKAGE ResourceSet& operator OPSIGN ## =(const RHS_TYPE &rhs)	\ | ||||
| 		ResourceSet& operator OPSIGN ## =(const RHS_TYPE &rhs)	\ | ||||
| 		{														\ | ||||
| 			return *this = *this OPSIGN rhs;					\ | ||||
| 		} | ||||
| @@ -70,7 +70,7 @@ namespace Res | ||||
| #undef opEqOperator | ||||
|  | ||||
| 		//to be used for calculations of type "how many units of sth can I afford?" | ||||
| 		DLL_LINKAGE int operator/(const ResourceSet &rhs) | ||||
| 		int operator/(const ResourceSet &rhs) | ||||
| 		{ | ||||
| 			int ret = INT_MAX; | ||||
| 			for(int i = 0; i < size(); i++) | ||||
| @@ -80,7 +80,7 @@ namespace Res | ||||
| 			return ret; | ||||
| 		} | ||||
|  | ||||
| 		DLL_LINKAGE ResourceSet & operator=(const TResource &rhs) | ||||
| 		ResourceSet & operator=(const TResource &rhs) | ||||
| 		{ | ||||
| 			for(int i = 0; i < size(); i++) | ||||
| 				at(i) = rhs; | ||||
| @@ -88,14 +88,14 @@ namespace Res | ||||
| 			return *this; | ||||
| 		} | ||||
|  | ||||
| 	// WARNING: comparison operators are used for "can afford" relation: a <= b means that foreach i a[i] <= b[i]  | ||||
| 	// WARNING: comparison operators are used for "can afford" relation: a <= b means that foreach i a[i] <= b[i] | ||||
| 	// that doesn't work the other way: a > b doesn't mean that a cannot be afforded with b, it's still b can afford a | ||||
| // 		bool operator<(const ResourceSet &rhs) | ||||
| // 		{ | ||||
| // 			for(int i = 0; i < size(); i++) | ||||
| // 				if(at(i) >= rhs[i]) | ||||
| // 					return false; | ||||
| //  | ||||
| // | ||||
| // 			return true; | ||||
| // 		} | ||||
|  | ||||
| @@ -118,7 +118,7 @@ namespace Res | ||||
| 			} cur; | ||||
| 			const ResourceSet &rs; | ||||
| 			void advance(); | ||||
| 		 | ||||
|  | ||||
| 		public: | ||||
| 			nziterator(const ResourceSet &RS); | ||||
| 			bool valid(); | ||||
| @@ -126,7 +126,7 @@ namespace Res | ||||
| 			nziterator operator++(int); | ||||
| 			const ResEntry& operator*() const; | ||||
| 			const ResEntry* operator->() const; | ||||
| 		 | ||||
|  | ||||
| 		}; | ||||
| 	}; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user