mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Patch from keen: compatibility fixes for Mac OS X
This commit is contained in:
		
							
								
								
									
										100
									
								
								Makefile.x
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										100
									
								
								Makefile.x
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,100 @@ | ||||
| CC		= g++ | ||||
| CFLAGS		= -I/Library/Frameworks/SDL_mixer.framework/Headers -I/Library/Frameworks/SDL.framework/Headers -I/Library/Frameworks/SDL_image.framework/Headers -I/Library/Frameworks/SDL_ttf.framework/Headers -I/opt/local/include | ||||
| OPTIM		= -O2 | ||||
| #DEBUG		= -ggdb -D_DEBUG | ||||
| LDFLAGS		= -Wl,-framework,SDL -Wl,-framework,SDL_mixer -Wl,-framework,SDL_image -Wl,-framework,SDL_ttf -Wl,-framework,Cocoa | ||||
| BOOSTLIBS	= -L/opt/local/lib -lboost_system-mt -lboost_filesystem-mt -lboost_thread-mt | ||||
| LIBS		= $(BOOSTLIBS) -llua -ljpeg -lpng -lm -lpthread -ldl -lauto -lz | ||||
| VCMI_CLIENT	= vcmiclient | ||||
| VCMI_LIB	= VCMI_Lib.dylib | ||||
| VCMI_SERVER	= vcmiserver | ||||
| GENIUS_AI	= GeniusAI.dll | ||||
|  | ||||
| CLIENT_SOURCES = AdventureMapButton.cpp	\ | ||||
| 	CAdvmapInterface.cpp		\ | ||||
| 	CBattleInterface.cpp		\ | ||||
| 	CCallback.cpp			\ | ||||
| 	CCastleInterface.cpp		\ | ||||
| 	CCursorHandler.cpp		\ | ||||
| 	CGameInfo.cpp			\ | ||||
| 	CGameInterface.cpp		\ | ||||
| 	CHeroWindow.cpp			\ | ||||
| 	CMT.cpp				\ | ||||
| 	CMessage.cpp			\ | ||||
| 	CPlayerInterface.cpp		\ | ||||
| 	CPreGame.cpp			\ | ||||
| 	CThreadHelper.cpp		\ | ||||
| 	SDL_Extensions.cpp		\ | ||||
| 	SDL_framerate.cpp		\ | ||||
| 	client/CBitmapHandler.cpp	\ | ||||
| 	client/CConfigHandler.cpp	\ | ||||
| 	client/CCreatureAnimation.cpp	\ | ||||
| 	client/CSpellWindow.cpp		\ | ||||
| 	client/Client.cpp		\ | ||||
| 	client/Graphics.cpp		\ | ||||
| 	hch/CDefHandler.cpp		\ | ||||
| 	hch/CMusicHandler.cpp		\ | ||||
| 	hch/CSndHandler.cpp		\ | ||||
| 	mapHandler.cpp			\ | ||||
| 	client/NetPacksClient.cpp	\ | ||||
| 	SDLMain.m | ||||
|  | ||||
| LIB_SOURCES = CConsoleHandler.cpp	\ | ||||
| 	CGameState.cpp			\ | ||||
| 	hch/CArtHandler.cpp		\ | ||||
| 	hch/CBuildingHandler.cpp	\ | ||||
| 	hch/CCreatureHandler.cpp	\ | ||||
| 	hch/CDefObjInfoHandler.cpp	\ | ||||
| 	hch/CGeneralTextHandler.cpp	\ | ||||
| 	hch/CHeroHandler.cpp		\ | ||||
| 	hch/CLodHandler.cpp		\ | ||||
| 	hch/CObjectHandler.cpp		\ | ||||
| 	hch/CSpellHandler.cpp		\ | ||||
| 	hch/CTownHandler.cpp		\ | ||||
| 	lib/Connection.cpp		\ | ||||
| 	lib/IGameCallback.cpp		\ | ||||
| 	lib/VCMI_Lib.cpp		\ | ||||
| 	lib/NetPacksLib.cpp		\ | ||||
| 	lib/RegisterTypes.cpp		\ | ||||
| 	map.cpp | ||||
|  | ||||
| SERVER_SOURCES = \ | ||||
| 	server/CGameHandler.cpp		\ | ||||
| 	server/NetPacksServer.cpp	\ | ||||
| 	server/CVCMIServer.cpp | ||||
|  | ||||
| GENIUS_SOURCES = \ | ||||
| 	AI/GeniusAI/CGeniusAI.cpp	\ | ||||
| 	AI/GeniusAI/DLLMain.cpp | ||||
|  | ||||
| OBJECTS=$(CLIENT_SOURCES:.cpp=.o) | ||||
| CLIENT_OBJECTS=$(OBJECTS:.m=.o) | ||||
| LIB_OBJECTS=$(LIB_SOURCES:.cpp=.o) | ||||
| SERVER_OBJECTS=$(SERVER_SOURCES:.cpp=.o) | ||||
| GENIUS_OBJECTS=$(GENIUS_SOURCES:.cpp=.o) | ||||
|  | ||||
| all: $(CLIENT_SOURCES) $(LIB_SOURCES) $(SERVER_SOURCES) $(VCMI_CLIENT) $(VCMI_SERVER) $(GENIUS_AI) | ||||
|  | ||||
| update: | ||||
| 	svn co https://vcmi.svn.sourceforge.net/svnroot/vcmi/trunk . | ||||
|  | ||||
| $(VCMI_CLIENT): $(CLIENT_OBJECTS) $(VCMI_LIB) | ||||
| 	$(CC) $(LDFLAGS) $(CLIENT_OBJECTS) $(VCMI_LIB) -o $@ $(BOOSTLIBS) -lz | ||||
|  | ||||
| $(VCMI_SERVER): $(SERVER_OBJECTS) $(VCMI_LIB) | ||||
| 	$(CC) $(SERVER_OBJECTS) $(VCMI_LIB) -o $@ $(BOOSTLIBS) | ||||
|  | ||||
| $(GENIUS_AI): $(GENIUS_OBJECTS) $(VCMI_LIB) | ||||
| 	$(CC) -dynamiclib -install_name $@ $(GENIUS_OBJECTS) $(VCMI_LIB) -o $@ | ||||
|  | ||||
| $(VCMI_LIB): $(LIB_OBJECTS) | ||||
| 	$(CC) -dynamiclib -install_name $@ $(LIB_OBJECTS) -o $@ $(BOOSTLIBS) -lz | ||||
|  | ||||
| .cpp.o: | ||||
| 	$(CC) -c $(OPTIM) $(DEBUG) $(CFLAGS) $< -o $@ | ||||
|  | ||||
| .m.o: | ||||
| 	$(CC) -c $(OPTIM) $(DEBUG) $(CFLAGS) $< -o $@ | ||||
| 	 | ||||
| clean: | ||||
| 	rm -f $(CLIENT_OBJECTS) $(SERVER_OBJECTS) $(LIB_OBJECTS) $(GENIUS_OBJECTS) $(VCMI_CLIENT) $(VCMI_SERVER) $(GENIUS_AI) $(VCMI_LIB) | ||||
| @@ -99,7 +99,7 @@ void CBuildingHandler::loadBuildings() | ||||
| 		{ | ||||
| 			box = it = 0; | ||||
| 			ofs.getline(line,100); | ||||
| 			if(!line[0]) | ||||
| 			if(!line[0] || line[0] == '\n' || line[0] == '\r') | ||||
| 				ofs.getline(line,100); | ||||
| 			std::string linia(line); | ||||
| 			bool areboxes=true; | ||||
|   | ||||
| @@ -91,7 +91,9 @@ void CTownHandler::loadNames() | ||||
| 			of >> town; | ||||
| 			while(true) | ||||
| 			{ | ||||
| 				of.getline(bufname,75);if(!(*bufname))of.getline(bufname,75); | ||||
| 				of.getline(bufname,75); | ||||
| 				if(!bufname[0] || bufname[0] == '\n' || bufname[0] == '\r') | ||||
| 					of.getline(bufname,75); | ||||
| 				std::istringstream ifs(bufname); | ||||
| 				ifs >> build; | ||||
| 				if(build<0) | ||||
|   | ||||
| @@ -114,7 +114,7 @@ struct SMKStruct | ||||
| class DLLHandler | ||||
| { | ||||
| public: | ||||
| #if !defined(__amigaos4__) && !defined(__unix__) | ||||
| #if !defined(__amigaos4__) && !defined(__unix__) && !defined(__APPLE__) | ||||
| 	HINSTANCE dll; | ||||
| #else | ||||
| 	void *dll; | ||||
| @@ -131,7 +131,7 @@ class CBIKHandler | ||||
| public: | ||||
| 	DLLHandler ourLib; | ||||
| 	int newmode; | ||||
| #if !defined(__amigaos4__) && !defined(__unix__) | ||||
| #if !defined(__amigaos4__) && !defined(__unix__) && !defined(__APPLE__) | ||||
| 	HANDLE hBinkFile; | ||||
| #else | ||||
| 	void *hBinkFile; | ||||
|   | ||||
| @@ -668,11 +668,11 @@ struct BattleStackAttacked : public CPackForClient//3005 | ||||
| 	ui8 flags; //1 - is stack killed; 2 - is there special effect to be shown; | ||||
| 	ui32 effect; //set only if flag 2 is present | ||||
|  | ||||
| 	bool killed() //if target stack was killed | ||||
| 	bool killed() const//if target stack was killed | ||||
| 	{ | ||||
| 		return flags & 1; | ||||
| 	} | ||||
| 	bool isEffect() //if target stack was killed | ||||
| 	bool isEffect() const//if target stack was killed | ||||
| 	{ | ||||
| 		return flags & 2; | ||||
| 	} | ||||
|   | ||||
| @@ -428,7 +428,7 @@ DLL_EXPORT void BattleAttack::applyGs( CGameState *gs ) | ||||
| 		attacker->counterAttacks--; | ||||
| 	if(shot()) | ||||
| 		attacker->shots--; | ||||
| 	BOOST_FOREACH(BattleStackAttacked &stackAttacked, bsa) | ||||
| 	BOOST_FOREACH(BattleStackAttacked stackAttacked, bsa) | ||||
| 		stackAttacked.applyGs(gs); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -485,7 +485,8 @@ void CGameHandler::prepareAttacked(BattleStackAttacked &bsa, CStack *def) | ||||
| void CGameHandler::prepareAttack(BattleAttack &bat, CStack *att, CStack *def) | ||||
| { | ||||
| 	bat.stackAttacking = att->ID; | ||||
| 	std::set<BattleStackAttacked>::iterator bsa = bat.bsa.insert(BattleStackAttacked()).first; | ||||
| 	std::set<BattleStackAttacked>::iterator i = bat.bsa.insert(BattleStackAttacked()).first; | ||||
| 	BattleStackAttacked *bsa = (BattleStackAttacked *) &*i; | ||||
|  | ||||
| 	bsa->stackAttacked = def->ID; | ||||
| 	bsa->damageAmount = BattleInfo::calculateDmg(att, def, gs->getHero(att->attackerOwned ? gs->curB->hero1 : gs->curB->hero2), gs->getHero(def->attackerOwned ? gs->curB->hero1 : gs->curB->hero2), bat.shot());//counting dealt damage | ||||
| @@ -836,13 +837,7 @@ void CGameHandler::run(bool resume) | ||||
| 			{ | ||||
| 				boost::posix_time::time_duration p; | ||||
| 				p = boost::posix_time::milliseconds(200); | ||||
| #ifdef _MSC_VER | ||||
| 				states.cv.timed_wait(lock,p);  | ||||
| #else | ||||
| 				boost::xtime time={0,0}; | ||||
| 				time.nsec = static_cast<boost::xtime::xtime_nsec_t>(p.total_nanoseconds()); | ||||
| 				states.cv.timed_wait(lock,time); | ||||
| #endif | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user