1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-31 22:05:10 +02:00

* it's possible to use other port than 3030 by passing it as an additional argument

* removed some redundant warnings
* minor improvements for marketplace
This commit is contained in:
Michał W. Urbańczyk 2008-09-09 01:40:43 +00:00
parent 680cbf662a
commit 6233066b91
6 changed files with 35 additions and 8 deletions

View File

@ -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); g = gs->resVals[t2] / gs->getMarketEfficiency(player,mode);
if(r>g) if(r>g)
{ {
rec = r / g; rec = ceil(r / g);
give = 1; give = 1;
} }
else else
{ {
give = g / r; give = ceil(g / r);
rec = 1; rec = 1;
} }
} }

20
CMT.cpp
View File

@ -51,6 +51,20 @@ int _tmain(int argc, _TCHAR* argv[])
int main(int argc, _TCHAR* argv[]) int main(int argc, _TCHAR* argv[])
#endif #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.flags(ios::unitbuf);
std::cout << NAME << std::endl; std::cout << NAME << std::endl;
srand ( time(NULL) ); srand ( time(NULL) );
@ -137,7 +151,9 @@ int main(int argc, _TCHAR* argv[])
cpg->mush = mush; cpg->mush = mush;
StartInfo *options = new StartInfo(cpg->runLoop()); 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? //TODO: will it work on non-windows platforms?
THC tmh.getDif();pomtime.getDif();//reset timers THC tmh.getDif();pomtime.getDif();//reset timers
cgi->pathf = new CPathfinder(); cgi->pathf = new CPathfinder();
@ -160,7 +176,7 @@ int main(int argc, _TCHAR* argv[])
try try
{ {
std::cout << "Establishing connection...\t"; 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; std::cout << "done!" <<std::endl;
} }
catch(...) catch(...)

View File

@ -1822,7 +1822,8 @@ void CPlayerInterface::heroPrimarySkillChanged(const CGHeroInstance * hero, int
void CPlayerInterface::receivedResource(int type, int val) void CPlayerInterface::receivedResource(int type, int val)
{ {
boost::unique_lock<boost::mutex> un(*pim); 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) void CPlayerInterface::showSelDialog(std::string &text, const std::vector<Component*> &components, ui32 askID)

View File

@ -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); tcp::resolver::iterator end, pom, endpoint_iterator = resolver.resolve(tcp::resolver::query(host,port),error);
if(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; goto connerror1;
} }
pom = endpoint_iterator; pom = endpoint_iterator;

View File

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

View File

@ -22,9 +22,10 @@ using namespace boost::asio;
using namespace boost::asio::ip; using namespace boost::asio::ip;
bool end2 = false; bool end2 = false;
int port = 3030;
CVCMIServer::CVCMIServer() 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; std::cout << "CVCMIServer created!" <<std::endl;
} }
@ -128,6 +129,15 @@ int _tmain(int argc, _TCHAR* argv[])
int main(int argc, _TCHAR* argv[]) int main(int argc, _TCHAR* argv[])
#endif #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; CLodHandler h3bmp;
h3bmp.init("Data" PATHSEPARATOR "H3bitmap.lod","Data"); h3bmp.init("Data" PATHSEPARATOR "H3bitmap.lod","Data");
initDLL(&h3bmp); initDLL(&h3bmp);