예제 #1
0
파일: main.cpp 프로젝트: athomaj/RType
/*
 * 1 scénario / niveau (map)
 * 
 * Scénario:
 * Type obj, cycle, coord
 * 
 * Script obj:
 * debut cycle, fin cycle, coord vecteur directeur, 
 * 
 * type tir, frequence
 * 
 * scenario contient par cycle le niveau
 * 
 */
int main(int argc, char** argv)
{
	(void)argc;
	(void)argv;
#ifdef WIN32
	std::cout << "Win32" << std::endl;
#elif _WIN32
	std::cout << "_Win32" << std::endl;
#elif __WIN32
	std::cout << "__Win32" << std::endl;
#elif __CYGWIN__
	std::cout << "cygwin" << std::endl;
#else
	std::cout << "Autre" << std::endl;
#endif
//	GameObject* gg = new GameObject;
	IThread *thread = new Thread();
    IThread *manag = new Thread();
    IServer *server = new ServerTCP();
	
	thread->create(reinterpret_cast<void*>(&launchServer), server);
    manag->create(reinterpret_cast<void*>(&launchManager), server);
    manag->join();
	
//	CrossLoader *loader = new CrossLoader();
//		
//	try
//	{
//		loader->checkLibraries();
//	}
//	catch (std::exception &e)
//	{
//		std::cout << e.what() << std::endl;
//	}
//	loader->LoadLibrary("tim.dll");
//	loader->LoadSymbole();
//	loader->CloseLibrary();
//	Parser *parser = new Parser();
//	try
//	{
//		parser->load("Starwars");
//	}
//	catch (std::exception &e)
//	{
//		std::cout << e.what() << std::endl;
//	}
	return 0;
}
예제 #2
0
ThreadPool::ThreadPool(int const nbThread)
{
    IThread *thread;
    for (unsigned int i=0; i < nbThread; ++i)
    {
#ifdef _WIN32
		thread = new ThreadWin();
#else
		thread = new Thread();
#endif
        GameEngine *engine = new GameEngine();
        thread->create(reinterpret_cast<void *>(&launchGameEngine), engine);
        _pool.push_back(std::pair<IThread*, GameEngine *>(thread, engine));
    }
}
예제 #3
0
파일: ManageRoom.cpp 프로젝트: Nedwor/rtype
void	ManageRoom::handleCreateGame(void *buffer, Client *cl)
{
	t_TCPCreate *create;
	create = (t_TCPCreate *)buffer;

	Room *room = new Room;

	room->setGameId(this->currentGameId);
	room->setNbMax(create->nb_max);
	room->setName(create->name_game);
	std::cout << "Creating room=" << room->getName() << std::endl;
	char id = room->addClient(cl);
	std::cout << (int)id  << std::endl;
	this->listRoom[this->currentGameId++] = room;
	int i = 0;
	int len;
	const char *str = cl->getName().c_str();
	ISocket *sock;
	t_TCPPlayer Player;

	//On prépare le packet pour prévenir le joueur de sa connection à la partie créée

	while (str[i])
		Player.name[i] = str[i++];
	Player.name[i] = '\0';
	Player.player_id = id;
	Player.status = NOT_READY;
	Player.header.packetSize = sizeof(Player);
	Player.header.type = PLAYER;

	sock = cl->getSocket();
	this->_access[sock->getIp()] = room;
	IThread *th = new WinThread;

	std::cout <<"LOOOOOOOOOOOL" << std::endl;
	th->create(initGame, room);
	std::cout << "LOOOL2"<< std::endl;
	if ((len = sock->sendBinary(&Player, sizeof(Player))) < 0)
		std::cout << "Error while sending Create" << std::endl;
}