1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

changed most of std::cout to tlogX

Alt+F4 quits the game
This commit is contained in:
mateuszb 2008-09-19 12:09:15 +00:00
parent f97628e67f
commit ca1dbfe949
14 changed files with 60 additions and 48 deletions

View File

@ -301,7 +301,7 @@ void CTerrainRect::clickLeft(tribool down)
{
if (currentPath)
{
std::cout<<"Warning: Lost path?" << std::endl;
tlog2<<"Warning: Lost path?" << std::endl;
delete currentPath;
currentPath = NULL;
}

View File

@ -145,7 +145,7 @@ bool CCallback::upgradeCreature(const CArmedInstance *obj, int stackPos, int new
}
void CCallback::endTurn()
{
std::cout << "Player "<<(unsigned)player<<" end his turn."<<std::endl;
tlog5 << "Player "<<(unsigned)player<<" end his turn."<<std::endl;
cl->serv->wmx->lock();
*cl->serv << ui16(100); //report that we ended turn
cl->serv->wmx->unlock();

View File

@ -52,11 +52,11 @@ CBuildingRect::CBuildingRect(Structure *Str)
if (border = BitmapHandler::loadBitmap(str->borderName))
SDL_SetColorKey(border,SDL_SRCCOLORKEY,SDL_MapRGB(border->format,0,255,255));
else
std::cout << "Warning: no border for "<<Str->ID<<std::endl;
tlog2 << "Warning: no border for "<<Str->ID<<std::endl;
if (area = BitmapHandler::loadBitmap(str->areaName))
;//SDL_SetColorKey(area,SDL_SRCCOLORKEY,SDL_MapRGB(area->format,0,255,255));
else
std::cout << "Warning: no area for "<<Str->ID<<std::endl;
tlog2 << "Warning: no area for "<<Str->ID<<std::endl;
}
CBuildingRect::~CBuildingRect()
@ -460,7 +460,7 @@ void CCastleInterface::splitF()
}
void CCastleInterface::buildingClicked(int building)
{
std::cout<<"You've clicked on "<<building<<std::endl;
tlog5<<"You've clicked on "<<building<<std::endl;
if(building==19 || building==18)
{
building = town->town->hordeLvl[0] + 30;
@ -547,7 +547,7 @@ void CCastleInterface::buildingClicked(int building)
break;
}
default:
std::cout<<"This building isn't handled...\n";
tlog4<<"This building isn't handled...\n";
}
}
}

View File

@ -33,7 +33,7 @@ CGlobalAI * CAIHandler::getNewAI(CCallback * cb, std::string dllname)
HINSTANCE dll = LoadLibraryA(dllname.c_str());
if (!dll)
{
std::cout << "Cannot open AI library ("<<dllname<<"). Throwing..."<<std::endl;
tlog1 << "Cannot open AI library ("<<dllname<<"). Throwing..."<<std::endl;
#ifdef _MSC_VER
throw new std::exception("Cannot open AI library");
#endif
@ -49,7 +49,7 @@ CGlobalAI * CAIHandler::getNewAI(CCallback * cb, std::string dllname)
#if _WIN32
getName(temp);
#endif
std::cout << "Loaded .dll with AI named " << temp << std::endl;
tlog0 << "Loaded .dll with AI named " << temp << std::endl;
delete temp;
#if _WIN32
ret = getAI();

View File

@ -75,7 +75,7 @@ CGObjectInstance * createObject(int id, int subid, int3 pos, int owner)
nobj->ID = id;
nobj->subID = subid;
if(!nobj->defInfo)
std::cout <<"No def declaration for " <<id <<" "<<subid<<std::endl;
tlog3 <<"No def declaration for " <<id <<" "<<subid<<std::endl;
nobj->pos = pos;
//nobj->state = NULL;//new CLuaObjectScript();
nobj->tempOwner = owner;
@ -602,7 +602,7 @@ int CGameState::pickHero(int owner)
} while( map->getHero(h) && i<175);
if(i>174) //probably no free heroes - there's no point in further search, we'll take first free
{
std::cout << "Warning: cannot find free hero - trying to get first available..."<<std::endl;
tlog3 << "Warning: cannot find free hero - trying to get first available..."<<std::endl;
for(int j=0; j<HEROES_PER_TYPE * 2 * F_NUMBER; j++)
if(!map->getHero(j))
h=j;
@ -717,7 +717,7 @@ std::pair<int,int> CGameState::pickObject(CGObjectInstance *obj)
for(int i=0;i<VLC->objh->cregens.size();i++)
if(VLC->objh->cregens[i]==cid)
return std::pair<int,int>(17,i);
std::cout << "Cannot find a dwelling for creature "<<cid <<std::endl;
tlog3 << "Cannot find a dwelling for creature "<<cid <<std::endl;
return std::pair<int,int>(17,0);
}
case 217:
@ -754,7 +754,7 @@ std::pair<int,int> CGameState::pickObject(CGObjectInstance *obj)
for(int i=0;i<VLC->objh->cregens.size();i++)
if(VLC->objh->cregens[i]==cid)
return std::pair<int,int>(17,i);
std::cout << "Cannot find a dwelling for creature "<<cid <<std::endl;
tlog3 << "Cannot find a dwelling for creature "<<cid <<std::endl;
return std::pair<int,int>(17,0);
}
case 218:
@ -765,7 +765,7 @@ std::pair<int,int> CGameState::pickObject(CGObjectInstance *obj)
for(int i=0;i<VLC->objh->cregens.size();i++)
if(VLC->objh->cregens[i]==cid)
return std::pair<int,int>(17,i);
std::cout << "Cannot find a dwelling for creature "<<cid <<std::endl;
tlog3 << "Cannot find a dwelling for creature "<<cid <<std::endl;
return std::pair<int,int>(17,0);
}
}
@ -791,7 +791,7 @@ void CGameState::randomizeObject(CGObjectInstance *cur)
else if(ran.first==34)//special code for hero
{
CGHeroInstance *h = dynamic_cast<CGHeroInstance *>(cur);
if(!h) {std::cout<<"Wrong random hero at "<<cur->pos<<std::endl; return;}
if(!h) {tlog2<<"Wrong random hero at "<<cur->pos<<std::endl; return;}
cur->ID = ran.first;
h->portrait = cur->subID = ran.second;
h->type = VLC->heroh->heroes[ran.second];
@ -801,7 +801,7 @@ void CGameState::randomizeObject(CGObjectInstance *cur)
else if(ran.first==98)//special code for town
{
CGTownInstance *t = dynamic_cast<CGTownInstance*>(cur);
if(!t) {std::cout<<"Wrong random town at "<<cur->pos<<std::endl; return;}
if(!t) {tlog2<<"Wrong random town at "<<cur->pos<<std::endl; return;}
cur->ID = ran.first;
cur->subID = ran.second;
t->town = &VLC->townh->towns[ran.second];
@ -820,7 +820,7 @@ void CGameState::randomizeObject(CGObjectInstance *cur)
map->defs.insert(cur->defInfo = VLC->dobjinfo->gobjs[ran.first][ran.second]);
if(!cur->defInfo)
{
std::cout<<"*BIG* WARNING: Missing def declaration for "<<cur->ID<<" "<<cur->subID<<std::endl;
tlog1<<"*BIG* WARNING: Missing def declaration for "<<cur->ID<<" "<<cur->subID<<std::endl;
return;
}
}
@ -1099,7 +1099,7 @@ void CGameState::init(StartInfo * si, Mapa * map, int Seed)
{
if(!k->second.heroes.size())
{
std::cout << "Cannot give starting artifact - no heroes!" << std::endl;
tlog5 << "Cannot give starting artifact - no heroes!" << std::endl;
break;
}
CArtifact *toGive;

View File

@ -81,8 +81,8 @@ void CGarrisonSlot::hover (bool on)
}
else
{
std::cout << "Warning - shouldn't be - highlighted void slot "<<owner->highlighted<<std::endl;
std::cout << "Highlighted set to NULL"<<std::endl;
tlog2 << "Warning - shouldn't be - highlighted void slot "<<owner->highlighted<<std::endl;
tlog2 << "Highlighted set to NULL"<<std::endl;
owner->highlighted = NULL;
}
}
@ -1721,6 +1721,14 @@ void CPlayerInterface::handleKeyDown(SDL_Event *sEvent)
LOCPLINT->adventureInt->scrollingDown = true;
break;
}
case (SDLK_F4):
{
if(sEvent->key.keysym.mod & KMOD_LALT) //Alt+F4
{
exit(0);
break;
}
}
//case (SDLK_q):
// {
// exit(0);

View File

@ -1872,9 +1872,13 @@ StartInfo CPreGame::runLoop()
else if (sEvent.type==SDL_KEYDOWN)
{
if (sEvent.key.keysym.sym==SDLK_q)
{
exit(0);
}
{
exit(0);
}
if(sEvent.key.keysym.sym==SDLK_F4 && (sEvent.key.keysym.mod & KMOD_LALT)) //Alt+F4
{
exit(0);
}
/*if (state==EState::newGame)
{
switch (sEvent.key.keysym.sym)

View File

@ -277,7 +277,7 @@ SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey)
Entry *e = bitmaph->entries.znajdz(fname);
if(!e)
{
std::cout<<"File "<<fname<<" not found"<<std::endl;
tlog2<<"File "<<fname<<" not found"<<std::endl;
return NULL;
}
if(e->offset<0)
@ -339,7 +339,7 @@ SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey)
int res=bitmaph->infs2(pcd,e->size,e->realSize,pcx);
if(res!=0)
{
std::cout<<"an error "<<res<<" occured while extracting file "<<fname<<std::endl;
tlog2<<"an error "<<res<<" occured while extracting file "<<fname<<std::endl;
}
delete [] pcd;
}

View File

@ -99,9 +99,9 @@ void CTownHandler::loadNames()
if((i2=(i->second.find(buildingID=atoi(s.c_str()))))!=(i->second.end()))
i2->second->pos.z=itr++;
else
std::cout << "Warning1: No building "<<buildingID<<" in the castle "<<castleID<<std::endl;
tlog3 << "Warning1: No building "<<buildingID<<" in the castle "<<castleID<<std::endl;
else
std::cout << "Warning1: Castle "<<castleID<<" not defined."<<std::endl;
tlog3 << "Warning1: Castle "<<castleID<<" not defined."<<std::endl;
}
}
of.close();
@ -124,9 +124,9 @@ void CTownHandler::loadNames()
i2->second->areaName = area;
}
else
std::cout << "Warning2: No building "<<id<<" in the castle "<<town<<std::endl;
tlog3 << "Warning2: No building "<<id<<" in the castle "<<town<<std::endl;
else
std::cout << "Warning2: Castle "<<town<<" not defined."<<std::endl;
tlog3 << "Warning2: Castle "<<town<<" not defined."<<std::endl;
}
of.close();
@ -138,7 +138,7 @@ void CTownHandler::loadNames()
of >> format;
if(format!=1)
{
std::cout << "Unhandled format of buildings4.txt \n";
tlog1 << "Unhandled format of buildings4.txt \n";
}
else
{
@ -180,9 +180,9 @@ void CTownHandler::loadNames()
if((i2=(i->second.find(buildingID)))!=(i->second.end()))
i2->second->group = itr;
else
std::cout << "Warning3: No building "<<buildingID<<" in the castle "<<castleID<<std::endl;
tlog3 << "Warning3: No building "<<buildingID<<" in the castle "<<castleID<<std::endl;
else
std::cout << "Warning3: Castle "<<castleID<<" not defined."<<std::endl;
tlog3 << "Warning3: Castle "<<castleID<<" not defined."<<std::endl;
}
else //set group for selected building in ALL castles
{

View File

@ -84,7 +84,7 @@ CConnection::CConnection(std::string host, std::string port, std::string Name, s
connerror1:
tlog1 << "Something went wrong... checking for error info" << std::endl;
if(error)
std::cout << error <<std::endl;
tlog1 << error <<std::endl;
else
tlog1 << "No error info. " << std::endl;
delete io_service;
@ -107,7 +107,7 @@ CConnection::CConnection(boost::asio::basic_socket_acceptor<boost::asio::ip::tcp
acceptor->accept(*socket,error);
if (error)
{
std::cout << "Error on accepting: " << std::endl << error << std::endl;
tlog1 << "Error on accepting: " << std::endl << error << std::endl;
delete socket;
throw "Can't establish connection :(";
}

View File

@ -237,7 +237,7 @@ public:
template <typename T>
void loadPointer(T &data)
{
std::cout<<"Allocating memory for pointer!"<<std::endl;
tlog5<<"Allocating memory for pointer!"<<std::endl;
typedef typename boost::remove_pointer<T>::type npT;
data = new npT;
*this >> *data;

View File

@ -44,7 +44,7 @@ std::set<si32> convertBuildings(const std::set<si32> h3m, int castleID)
}
else
{
std::cout<<"Conversion warning: unknown building "<<*i<<" in castle "<<castleID<<std::endl;
tlog3<<"Conversion warning: unknown building "<<*i<<" in castle "<<castleID<<std::endl;
}
}

View File

@ -184,7 +184,7 @@ void CGameHandler::changePrimSkill(int ID, int which, int val, bool abs)
if(hero->exp >= VLC->heroh->reqExp(hero->level+1)) //new level
{
//give prim skill
std::cout << hero->name <<" got level "<<hero->level<<std::endl;
tlog5 << hero->name <<" got level "<<hero->level<<std::endl;
int r = rand()%100, pom=0, x=0;
int std::pair<int,int>::*g = (hero->level>9) ? (&std::pair<int,int>::second) : (&std::pair<int,int>::first);
for(;x<PRIMARY_SKILLS;x++)
@ -193,7 +193,7 @@ void CGameHandler::changePrimSkill(int ID, int which, int val, bool abs)
if(r<pom)
break;
}
std::cout << "Bohater dostaje umiejetnosc pierwszorzedna " << x << " (wynik losowania "<<r<<")"<<std::endl;
tlog5 << "Bohater dostaje umiejetnosc pierwszorzedna " << x << " (wynik losowania "<<r<<")"<<std::endl;
SetPrimSkill sps;
sps.id = ID;
sps.which = x;
@ -750,7 +750,7 @@ upgend:
}
else
{
std::cout << "Warning, wrong garrison swap command for " << tid << std::endl;
tlog3 << "Warning, wrong garrison swap command for " << tid << std::endl;
}
break;
}
@ -1028,11 +1028,11 @@ CGameHandler::~CGameHandler(void)
void CGameHandler::init(StartInfo *si, int Seed)
{
Mapa *map = new Mapa(si->mapname);
std::cout << "Map loaded!" << std::endl;
tlog0 << "Map loaded!" << std::endl;
gs = new CGameState();
std::cout << "Gamestate created!" << std::endl;
tlog0 << "Gamestate created!" << std::endl;
gs->init(si,map,Seed);
std::cout << "Gamestate initialized!" << std::endl;
tlog0 << "Gamestate initialized!" << std::endl;
/****************************LUA OBJECT SCRIPTS************************************************/
//std::vector<std::string> * lf = CLuaHandler::searchForScripts("scripts/lua/objects"); //files
//for (int i=0; i<lf->size(); i++)

View File

@ -33,7 +33,7 @@ void vaccept(tcp::acceptor *ac, tcp::socket *s, boost::system::error_code *error
CVCMIServer::CVCMIServer()
: io(new io_service()), acceptor(new tcp::acceptor(*io, tcp::endpoint(tcp::v4(), port)))
{
std::cout << "CVCMIServer created!" <<std::endl;
tlog4 << "CVCMIServer created!" <<std::endl;
}
CVCMIServer::~CVCMIServer()
{
@ -83,7 +83,7 @@ void CVCMIServer::newGame(CConnection *c)
acceptor->accept(*s,error);
if(error) //retry
{
std::cout<<"Cannot establish connection - retrying..." << std::endl;
tlog3<<"Cannot establish connection - retrying..." << std::endl;
i--;
continue;
}
@ -113,7 +113,7 @@ void CVCMIServer::start()
}
boost::system::error_code error;
std::cout<<"Listening for connections at port " << acceptor->local_endpoint().port() << std::endl;
tlog0<<"Listening for connections at port " << acceptor->local_endpoint().port() << std::endl;
tcp::socket * s = new tcp::socket(acceptor->io_service());
boost::thread acc(boost::bind(vaccept,acceptor,s,&error));
sr->setToTrueAndNotify();
@ -121,12 +121,12 @@ void CVCMIServer::start()
acc.join();
if (error)
{
std::cout<<"Got connection but there is an error " << std::endl << error;
tlog2<<"Got connection but there is an error " << std::endl << error;
return;
}
std::cout<<"We've accepted someone... " << std::endl;
tlog0<<"We've accepted someone... " << std::endl;
CConnection *connection = new CConnection(s,NAME,std::cout);
std::cout<<"Got connection!" << std::endl;
tlog0<<"Got connection!" << std::endl;
while(!end2)
{
uint8_t mode;
@ -165,7 +165,7 @@ int main(int argc, char** argv)
port = _ttoi(argv[1]);
#endif
}
std::cout << "Port " << port << " will be used." << std::endl;
tlog0 << "Port " << port << " will be used." << std::endl;
CLodHandler h3bmp;
h3bmp.init("Data" PATHSEPARATOR "H3bitmap.lod","Data");
initDLL(&h3bmp,console,logfile);