void the::object::addAction(strref name, Action && action) { initHandlers(); logger::debug("[Action ] add '%s'; object: '%s' surface : %d", name.c_str(), getTag().c_str(), action.getSurface()); getSurface(action.getSurface()).setIntersection(true); actions[name] = action; }
/** * Create and initialize a Help window. * @param title The window title. */ HelpFrame::HelpFrame(const wxString &title) : wxFrame((wxFrame*) NULL, wxID_ANY, title) { this->SetIcon(Icon::getIcon(Icon::iHelp)); // Initialize the window panels and event handlers. initPanels(); initHandlers(); }
int main(int argc, char *argv[]) { string configFilename = "Config.json"; string logFilename = "-"; #ifndef _WIN32 cmdline::parser arg; arg.add<string>("config", 'c', "configuration file", false, "Config.json"); arg.add<string>("log", 'l', "log file", false, "-"); arg.parse_check(argc, argv); configFilename = arg.get<string>("config"); logFilename = arg.get<string>("log"); #endif log_normal("Using configuration file: %s", configFilename.c_str()); log_normal("Log file: %s", logFilename.c_str()); setLogFile(logFilename); Document configDoc = loadConfigObj(configFilename); Value &roomsVal = configDoc["Rooms"]; assert(roomsVal.IsArray()); vector<RoomInfo> rooms(loadRooms(roomsVal)); initLibraries(); CubeServer server; configRooms(server, rooms); server.EnableTimer(CHECK_INTERVAL_uS); configServer(server, configDoc["Server"]); server.IsRunning = true; thread th(eventEntry, &server); initHandlers(); handleCommand(server); server.Stop(); th.join(); log_normal("%s", "Stopped."); #ifdef MEM_DEBUG #ifdef _WIN32 _CrtDumpMemoryLeaks(); #endif #endif return 0; }
Viewer::Viewer(std::string earthfile) { setThreadingModel(osgViewer::ViewerBase::SingleThreaded); initScene(earthfile); initSkyOcean(); osgEarth::Viewpoint vp; vp.setFocalPoint(osg::Vec3d(108.90199,34.04073,0)); vp.setRange(9668062); vp.setPitch(-90); _manip->setViewpoint(vp, 2); initHandlers(); }
void registerHandler(const char *name, void(*initf)(const char*), int(*parsef)(const char*, FILE*)) { handler *h = (handler*)malloc(sizeof(handler)); h->init = initf; h->parse = parsef; h->name = strdup(name); h->namelen = strlen(h->name); if (maxhandlers == 0) initHandlers(); if (nhandlers == maxhandlers) { maxhandlers += 10; handlers = (handler**)realloc(handlers, sizeof(handler*) * maxhandlers); } handlers[nhandlers++] = h; }
Client::Client() { initHandlers(); FILE_LOG(logINFO) << "Client opened... Opening window"; this->state = INGAME; //TODO: MAKE THIS GUI DEPENDENT OR SOMETHING lastUpdatedTime = RakNet::GetTimeMS(); float t = 0.0f; float dt = 1.0f / settings.fps; FILE_LOG(logDEBUG) << dt; RakNet::Time currentTime = RakNet::GetTimeMS(); float accumulator = 0.0f; //client loop while (true) { RakNet::Time newTime = RakNet::GetTimeMS(); float deltaTime = (newTime - currentTime)/1000.f; currentTime = newTime; if (deltaTime > 0.25f) deltaTime = 0.25f; accumulator += deltaTime; while (accumulator >= dt) { accumulator -= dt; //previous = current; TODO: IMPLEMENT STATES //integrate(current, t, dt); TODO: integrate here this->inputHandler.tick(); this->gameHandler.tick(); t += dt; } //State state = interpolate(previous, current, accumulator/dt); TODO: INTERPOLATE HERE, ETC //tick renderer this->view.interpolate(accumulator/dt); //we render an alpha of the current to the next state, for interpolation } }
bool Game::initialize(ENetAddress *address, const char *baseKey){ if (enet_initialize () != 0) return false; atexit(enet_deinitialize); _server = enet_host_create(address, 32, 0, 0); if(_server == NULL) return false; std::string key = base64_decode(baseKey); if(key.length() <= 0) return false; _blowfish = new BlowFish((uint8*)key.c_str(), 16); initHandlers(); map = new SummonersRift(this); //TODO: better lua implementation LuaScript script(false); script.loadScript("../../lua/config.lua"); // sol::state lua; // lua.open_libraries(sol::lib::base, sol::lib::table); // lua.open_file("../../lua/config.lua"); sol::table playerList = script.getTable("players"); for (int i=1;i<12;i++) { try { std::string playerIndex = "player"+toString(i); sol::table playerData = playerList.get<sol::table>(playerIndex); std::string rank = playerData.get<std::string>("rank"); std::string name = playerData.get<std::string>("name"); std::string champion = playerData.get<std::string>("champion"); std::string team = playerData.get<std::string>("team"); int skin = playerData.get<int>("skin"); int ribbon = playerData.get<int>("ribbon"); int icon = playerData.get<int>("icon"); std::string summoner1 = playerData.get<std::string>("summoner1"); std::string summoner2 = playerData.get<std::string>("summoner2"); ClientInfo* player = new ClientInfo(rank, ((team == "BLUE") ? TEAM_BLUE : TEAM_PURPLE), ribbon, icon); player->setName(name); player->setSkinNo(skin); static int id = 1; player->userId = id; // same as StartClient.bat id++; player->setSummoners(strToId(summoner1), strToId(summoner2)); Champion* c = ChampionFactory::getChampionFromType(champion, map, GetNewNetID(), player->userId); float respawnX, respawnY; std::tie(respawnX, respawnY) = c->getRespawnPosition(); c->setPosition(respawnX, respawnY); c->setSide((team == "BLUE") ? 0 : 1); c->levelUp(); map->addObject(c); player->setChampion(c); players.push_back(player); } catch(sol::error e) { //printf("Error loading champion: \n%s", e.what()); break; } } // Uncomment the following to get 2-players /*ClientInfo* player2 = new ClientInfo("GOLD", TEAM_PURPLE); player2->setName("tseT"); Champion* c2 = ChampionFactory::getChampionFromType("Ezreal", map, GetNewNetID()); c2->setPosition(100.f, 273.55f); c2->setSide(1); map->addObject(c2); player2->setChampion(c2); player2->setSkinNo(4); player2->userId = 2; // same as StartClient.bat player2->setSummoners(SPL_Ignite, SPL_Flash); players.push_back(player2);*/ return _isAlive = true; }
void MainFramework::parseMessages(){ //m_GPUManagers["DirectX"]->initialize(); m_GPUManagers["CUDA"]->initialize(); //m_GPUManagers["OpenCL"]->initialize(); initHandlers(); boost::mutex mut; boost::unique_lock<boost::mutex> lock(mut); while(!m_endParsing){ std::list<FrameworkMessagePtr> stack; m_messageStackMutex->lock(); stack = m_messageStack; m_messageStack.clear(); m_messageStackMutex->unlock(); std::map<std::string,MessageHandlerPtr>::iterator handlerItr; while(!stack.empty()){ if((handlerItr = m_messageHandlers.find(stack.front()->getMessage())) != m_messageHandlers.end()){ std::string gpuapi = m_guiManager->getEditText(IDC_ALGORITHM_GPUAPI); if(gpuapi.compare("DirectX") == 0){ m_gManager = m_GPUManagers["DirectX"]; } else if(gpuapi.compare("CUDA") == 0){ m_gManager = m_GPUManagers["CUDA"]; } else if(gpuapi.compare("OpenCL") == 0){ m_gManager = m_GPUManagers["OpenCL"]; } IDataPackPtr dataPack = stack.front()->getDataPack(); dataPack->m_gfxMgr = m_gManager; dataPack->m_recMgr = m_rManager; dataPack->m_gui = m_guiManager; dataPack->m_minerGUI = m_minerGUI; m_runningThreads[stack.front()->getMessage()] = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&MainFramework::runThread,this,stack.front(),dataPack))); if(SetThreadPriority(m_runningThreads[stack.front()->getMessage()]->native_handle(),THREAD_PRIORITY_BELOW_NORMAL) == 0){ assert(0); } } else if(stack.front()->getMessage().compare("StopAlgorithm") == 0){ m_guiManager->getWindow(IDC_BUTTON_STOP)->disable(); m_messageHandlers["StartAlgorithm"]->stop(); boost::shared_ptr<boost::thread> thread = m_runningThreads["StartAlgorithm"]; if(thread){ thread->join(); } m_minerGUI->enableAllButStop(); m_guiManager->setText(IDC_STATIC_INFOTEXT,L""); m_guiManager->setText(IDC_STATIC_DEBUG,L""); stack.front()->waitOnMessage(); } else{ TRACE_DEBUG("Message without registered handler recieved."); assert(0); } stack.pop_front(); } m_parseCondition->wait(lock); } }