Преглед на файлове

* it's possible to use other port than 3030 by passing it as an additional argument
* removed some redundant warnings
* minor improvements for marketplace

Michał W. Urbańczyk преди 17 години
родител
ревизия
6233066b91
променени са 6 файла, в които са добавени 35 реда и са изтрити 8 реда
  1. 2 2
      CCallback.cpp
  2. 18 2
      CMT.cpp
  3. 2 1
      CPlayerInterface.cpp
  4. 1 1
      lib/Connection.cpp
  5. 1 1
      mapHandler.cpp
  6. 11 1
      server/CVCMIServer.cpp

+ 2 - 2
CCallback.cpp

@@ -569,12 +569,12 @@ void CCallback::getMarketOffer( int t1, int t2, int &give, int &rec, int mode/*=
 		g = gs->resVals[t2] / gs->getMarketEfficiency(player,mode);
 	if(r>g)
 	{
-		rec = r / g;
+		rec = ceil(r / g);
 		give = 1;
 	}
 	else
 	{
-		give = g / r;
+		give = ceil(g / r);
 		rec = 1;
 	}
 }

+ 18 - 2
CMT.cpp

@@ -51,6 +51,20 @@ int _tmain(int argc, _TCHAR* argv[])
 int main(int argc, _TCHAR* argv[])
 #endif
 { 
+	int port;
+	if(argc > 1)
+	{
+#ifdef _MSC_VER
+		port = _tstoi(argv[1]);
+#else
+		port = _ttoi(argv[1]);
+#endif
+	}
+	else
+	{
+		port = 3030;
+		std::cout << "Port " << port << " will be used." << std::endl;
+	}
 	std::cout.flags(ios::unitbuf);
 	std::cout << NAME << std::endl;
 	srand ( time(NULL) );
@@ -137,7 +151,9 @@ int main(int argc, _TCHAR* argv[])
 		cpg->mush = mush;
 		StartInfo *options = new StartInfo(cpg->runLoop());
 ///////////////////////////////////////////////////////////////////////////////////////
-		boost::thread servthr(boost::bind(system,SERVER_NAME " > server_log.txt")); //runs server executable; 
+		char portc[10]; SDL_itoa(port,portc,10);
+		std::string comm = std::string(SERVER_NAME) + " " + portc + " > server_log.txt";
+		boost::thread servthr(boost::bind(system,comm.c_str())); //runs server executable; 
 												//TODO: will it work on non-windows platforms?
 		THC tmh.getDif();pomtime.getDif();//reset timers
 		cgi->pathf = new CPathfinder();
@@ -160,7 +176,7 @@ int main(int argc, _TCHAR* argv[])
 			try
 			{
 				std::cout << "Establishing connection...\t";
-				c = new CConnection("localhost","3030",NAME,lll);
+				c = new CConnection("127.0.0.1",portc,NAME,lll);
 				std::cout << "done!" <<std::endl;
 			}
 			catch(...)

+ 2 - 1
CPlayerInterface.cpp

@@ -1822,7 +1822,8 @@ void CPlayerInterface::heroPrimarySkillChanged(const CGHeroInstance * hero, int
 void CPlayerInterface::receivedResource(int type, int val)
 {
 	boost::unique_lock<boost::mutex> un(*pim);
-	adventureInt->resdatabar.draw();
+	if(!curint->subInt)
+		adventureInt->resdatabar.draw();
 }
 
 void CPlayerInterface::showSelDialog(std::string &text, const std::vector<Component*> &components, ui32 askID)

+ 1 - 1
lib/Connection.cpp

@@ -45,7 +45,7 @@ CConnection::CConnection(std::string host, std::string port, std::string Name, s
     tcp::resolver::iterator end, pom, endpoint_iterator = resolver.resolve(tcp::resolver::query(host,port),error);
 	if(error)
 	{
-		std::cout << "Problem with resolving. " << std::endl << error <<std::endl;
+		std::cout << "Problem with resolving: " << std::endl << error <<std::endl;
 		goto connerror1;
 	}
 	pom = endpoint_iterator;

+ 1 - 1
mapHandler.cpp

@@ -494,7 +494,7 @@ void processDef (CGDefInfo* def)
 		pom->width = pom->handler->ourImages[0].bitmap->w/32;
 		pom->height = pom->handler->ourImages[0].bitmap->h/32;
 	}
-	else
+	else if(def->id != 34 && def->id != 98)
 		std::cout << "\t\tMinor warning: lacking def info for " << def->id << " " << def->subid <<" " << def->name << std::endl;
 	if(!def->handler->alphaTransformed)
 	{

+ 11 - 1
server/CVCMIServer.cpp

@@ -22,9 +22,10 @@ using namespace boost::asio;
 using namespace boost::asio::ip;
 
 bool end2 = false;
+int port = 3030;
 
 CVCMIServer::CVCMIServer()
-: io(new io_service()), acceptor(new tcp::acceptor(*io, tcp::endpoint(tcp::v4(), 3030)))
+: io(new io_service()), acceptor(new tcp::acceptor(*io, tcp::endpoint(tcp::v4(), port)))
 {
 	std::cout << "CVCMIServer created!" <<std::endl;
 }
@@ -128,6 +129,15 @@ int _tmain(int argc, _TCHAR* argv[])
 int main(int argc, _TCHAR* argv[])
 #endif
 {
+	if(argc > 1)
+	{
+#ifdef _MSC_VER
+		port = _tstoi(argv[1]);
+#else
+		port = _ttoi(argv[1]);
+#endif
+	}
+	std::cout << "Port " << port << " will be used." << std::endl;
 	CLodHandler h3bmp;
 	h3bmp.init("Data" PATHSEPARATOR "H3bitmap.lod","Data");
 	initDLL(&h3bmp);