Browse Source

* fixed crash on loading maps with hero placeholder
* pregame will be always displayed in 800/600 resolution
* it's possible to set game resolution in pregame (type 'resolution' in the console)
* version set to 0.7

Michał W. Urbańczyk 16 years ago
parent
commit
5fe2dc32f8
3 changed files with 29 additions and 3 deletions
  1. 28 1
      CMT.cpp
  2. 1 1
      global.h
  3. 0 1
      map.cpp

+ 28 - 1
CMT.cpp

@@ -79,7 +79,7 @@ int main(int argc, char** argv)
 	CGameInfo * cgi = CGI = new CGameInfo; //contains all global informations about game (texts, lodHandlers, map handler itp.)
 	CGameInfo * cgi = CGI = new CGameInfo; //contains all global informations about game (texts, lodHandlers, map handler itp.)
 	if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO)==0)
 	if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO)==0)
 	{
 	{
-		screen = SDL_SetVideoMode(conf.cc.resx,conf.cc.resy,conf.cc.bpp,SDL_SWSURFACE|SDL_DOUBLEBUF|(conf.cc.fullscreen?SDL_FULLSCREEN:0));  //initializing important global surface
+		screen = SDL_SetVideoMode(800,600,conf.cc.bpp,SDL_SWSURFACE|SDL_DOUBLEBUF|(conf.cc.fullscreen?SDL_FULLSCREEN:0));  //initializing important global surface
 		tlog0 <<"\tInitializing screen: "<<pomtime.getDif();
 		tlog0 <<"\tInitializing screen: "<<pomtime.getDif();
 			tlog0 << std::endl;
 			tlog0 << std::endl;
 		SDL_WM_SetCaption(NAME.c_str(),""); //set window title
 		SDL_WM_SetCaption(NAME.c_str(),""); //set window title
@@ -138,6 +138,14 @@ int main(int argc, char** argv)
 
 
 		StartInfo *options = new StartInfo(cpg->runLoop());
 		StartInfo *options = new StartInfo(cpg->runLoop());
 
 
+		if(screen->w != conf.cc.resx   ||   screen->h != conf.cc.resy)
+		{
+			SDL_QuitSubSystem(SDL_INIT_VIDEO);
+			SDL_InitSubSystem(SDL_INIT_VIDEO);
+			screen = SDL_SetVideoMode(conf.cc.resx,conf.cc.resy,conf.cc.bpp,SDL_SWSURFACE|SDL_DOUBLEBUF|(conf.cc.fullscreen?SDL_FULLSCREEN:0));  //initializing important global surface
+			SDL_WM_SetCaption(NAME.c_str(),""); //set window title
+			SDL_ShowCursor(SDL_DISABLE);
+		}
 		CClient cl;
 		CClient cl;
 		if(options->mode == 0) //new game
 		if(options->mode == 0) //new game
 		{
 		{
@@ -268,6 +276,25 @@ void processCommand(const std::string &message, CClient *&client)
 		readed >> fname;
 		readed >> fname;
 		client->load(fname);
 		client->load(fname);
 	}
 	}
+	else if(cn=="resolution")
+	{
+		std::map<std::pair<int,int>, config::GUIOptions >::iterator j;
+		int i=1, hlp=1;
+		tlog4 << "Available screen resolutions:\n";
+		for(j=conf.guiOptions.begin(); j!=conf.guiOptions.end(); j++)
+			tlog4 << i++ <<". " << j->first.first << " x " << j->first.second << std::endl;
+		tlog4 << "Type number from 1 to " << i-1 << " to set appropriate resolution or 0 to cancel.\n";
+		std::cin >> i;
+		if(!i)
+			return;
+		else
+		{
+			for(j=conf.guiOptions.begin(); j!=conf.guiOptions.end() && hlp++<i; j++);
+			conf.cc.resx = j->first.first;
+			conf.cc.resy = j->first.second;
+			tlog0 << "Screen resolution set to " << conf.cc.resx << " x " << conf.cc.resy <<". It will be aplied when the game starts.\n";
+		}
+	}
 	else if(message=="get txt")
 	else if(message=="get txt")
 	{
 	{
 		boost::filesystem::create_directory("Extracted_txts");
 		boost::filesystem::create_directory("Extracted_txts");

+ 1 - 1
global.h

@@ -19,7 +19,7 @@ typedef boost::int8_t si8; //signed int 8 bits (1 byte)
 #define THC
 #define THC
 #endif
 #endif
 
 
-#define NAME_VER ("VCMI 0.69")
+#define NAME_VER ("VCMI 0.7")
 #define CONSOLE_LOGGING_LEVEL 5
 #define CONSOLE_LOGGING_LEVEL 5
 #define FILE_LOGGING_LEVEL 6
 #define FILE_LOGGING_LEVEL 6
 
 

+ 0 - 1
map.cpp

@@ -1779,7 +1779,6 @@ void Mapa::readObjects( unsigned char * bufor, int &i)
 		case 214: //hero placeholder
 		case 214: //hero placeholder
 			{
 			{
 				i+=3; //TODO: handle it more properly
 				i+=3; //TODO: handle it more properly
-				break;
 			}
 			}
 		default:
 		default:
 			nobj = new CGObjectInstance();
 			nobj = new CGObjectInstance();