/* A more complex drawing function, using 2 separate viewports */ void draw_multi() { GLint viewport[4]; glScissor(0, 0, window_w, window_h); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* First viewport with triangles, teapot or torus, etc. */ glViewport((GLint)(window_w * 0.05), (GLint)(window_h * 0.525), (GLsizei)(window_w * 0.9), (GLsizei)(window_h * 0.45)); glScissor((GLint)(window_w * 0.05), (GLint)(window_h * 0.525), (GLsizei)(window_w * 0.9), (GLsizei)(window_h * 0.45)); glClearColor(0.2, 0.2, 0.2, 0.); glGetIntegerv(GL_VIEWPORT, viewport); gl2psBeginViewport(viewport); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.3,1.3, -1.3,1.3, -1.3,1.3); glMatrixMode(GL_MODELVIEW); objects(); triangles(); extras(); text(); gl2psEndViewport(); /* Second viewport with cube, image, etc. */ glViewport((GLint)(window_w * 0.05), (GLint)(window_h * 0.025), (GLsizei)(window_w * 0.9), (GLsizei)(window_h * 0.45)); glScissor((GLint)(window_w * 0.05), (GLint)(window_h * 0.025), (GLsizei)(window_w * 0.9), (GLsizei)(window_h * 0.45)); glClearColor(0.8, 0.8, 0.8, 0.); glGetIntegerv(GL_VIEWPORT, viewport); gl2psBeginViewport(viewport); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.3,1.3, -1.3,1.3, -1.3,1.3); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glRotatef(rotation, 1., 1., 1.); image(-0.8, -0.3, GL_TRUE); cube(); extras(); image(-0.8, 0.4, GL_FALSE); glPopMatrix(); gl2psEndViewport(); glClearColor(0.5, 0.5, 0.5, 0.); glFlush(); }
SOUNDPLUGINEXP void dllLoadScene( const char* sceneFile ) { // Remove unused resources as we are loading a new scene SoundResourceManager::instance()->releaseUnusedResources(); XMLResults results; XMLNode scene = XMLNode::parseFile( sceneFile, "Configuration", &results); XMLNode& pathes(scene.getChildNode("EnginePath")); if (!pathes.isEmpty()) { GameLog::logMessage("- Setting Sound Directory = %s", pathes.getAttribute("mediapath", "media")); SoundResourceManager::instance()->setResourceDirectory( pathes.getAttribute("mediapath", "media")); } XMLNode& extras(scene.getChildNode("Extras")); if (!extras.isEmpty()) { const XMLNode& settings(extras.getChildNode("SoundManager")); if (!settings.isEmpty()) { const char* maxSources = settings.getAttribute("maxSources"); if (maxSources) { unsigned int maxS = (unsigned)atoi(maxSources); GameLog::logMessage("- Setting max sound sources: %u", maxS); SoundManager::instance()->setMaxSources(maxS); } } } }
void Packet::read(socket& socket) { std::uint32_t bytes_read = 0; if (ext_len > 0) { std::vector<char> extras(ext_len); while (bytes_read < static_cast<std::uint32_t>(ext_len)) { bytes_read += socket.receive(boost::asio::buffer(extras)); } bytes_read = 0; if (extras.size() > 4) { char flags_buf[4] = { extras[0], extras[1], extras[2], extras[3] }; flags = readUInt32LE(flags_buf, 0); } } if (key_len > 0) { key.resize(key_len); while (bytes_read < key_len) { bytes_read += socket.receive(boost::asio::buffer(key)); } bytes_read = 0; } if (bod_len > key_len) { std::uint32_t val_len = bod_len - key_len - ext_len; val.resize(val_len); while (bytes_read < val_len) { bytes_read += socket.receive(boost::asio::buffer(val)); } } }
/* A simple drawing function, using the default viewport */ void draw_single() { glScissor(0, 0, window_w, window_h); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); triangles(); extras(); objects(); text(); glFlush(); }
void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recvData) { uint32 opcode = recvData.GetOpcode(); /* extract packet */ /* extract packet */ MovementInfo movementInfo; static MovementStatusElements const speedElement = MSEExtraFloat; ExtraMovementStatusElement extras(&speedElement); GetPlayer()->ReadMovementInfo(recvData, &movementInfo, &extras); // now can skip not our packet if (_player->GetGUID() != movementInfo.guid) { recvData.rfinish(); // prevent warnings spam return; } float newspeed = extras.Data.floatData; /*----------------*/ // client ACK send one packet for mounted/run case and need skip all except last from its // in other cases anti-cheat check can be fail in false case UnitMoveType move_type = MOVE_WALK; UnitMoveType force_move_type = MOVE_WALK; static char const* move_type_name[MAX_MOVE_TYPE] = { "Walk", "Run", "RunBack", "Swim", "SwimBack", "TurnRate", "Flight", "FlightBack", "PitchRate" }; // skip all forced speed changes except last and unexpected // in run/mounted case used one ACK and it must be skipped.m_forced_speed_changes[MOVE_RUN} store both. if (_player->m_forced_speed_changes[force_move_type] > 0) { --_player->m_forced_speed_changes[force_move_type]; if (_player->m_forced_speed_changes[force_move_type] > 0) return; } if (!_player->GetTransport() && fabs(_player->GetSpeed(move_type) - newspeed) > 0.01f) { if (_player->GetSpeed(move_type) > newspeed) // must be greater - just correct { sLog->outError(LOG_FILTER_NETWORKIO, "%sSpeedChange player %s is NOT correct (must be %f instead %f), force set to correct value", move_type_name[move_type], _player->GetName(), _player->GetSpeed(move_type), newspeed); _player->SetSpeed(move_type, _player->GetSpeedRate(move_type), true); } else // must be lesser - cheating { sLog->outDebug(LOG_FILTER_GENERAL, "Player %s from account id %u kicked for incorrect speed (must be %f instead %f)", _player->GetName(), _player->GetSession()->GetAccountId(), _player->GetSpeed(move_type), newspeed); _player->GetSession()->KickPlayer(); } } }
int wbprint::printPageHDC(model_DiagramRef view, int pagenum, HDC hdc, int width, int height) { mdc::CanvasViewExtras extras(view->get_data()->get_canvas_view()); app_PageSettingsRef page(workbench_DocumentRef::cast_from(view.get_grt()->get("/wb/doc"))->pageSettings()); // TODO: we have both paper and page margins, which is kinda confusing. extras.set_page_margins(page->marginTop(), page->marginLeft(), page->marginBottom(), page->marginRight()); extras.set_paper_size(page->paperType()->width(), page->paperType()->height()); extras.set_orientation(page->orientation() == "landscape" ? mdc::Landscape : mdc::Portrait); extras.set_scale(page->scale()); //extras.set_print_border(true); int pages= extras.print_native(hdc, width, height, pagenum); return pages; }
void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recvData) { uint32 opcode = recvData.GetOpcode(); /* extract packet */ MovementInfo movementInfo; static MovementStatusElements const speedElement = MSEExtraFloat; Movement::ExtraMovementStatusElement extras(&speedElement); GetPlayer()->ReadMovementInfo(recvData, &movementInfo, &extras); // now can skip not our packet if (_player->GetGUID() != movementInfo.guid) { recvData.rfinish(); // prevent warnings spam return; } float newspeed = extras.Data.floatData; /*----------------*/ // client ACK send one packet for mounted/run case and need skip all except last from its // in other cases anti-cheat check can be fail in false case UnitMoveType move_type; static char const* const move_type_name[MAX_MOVE_TYPE] = { "Walk", "Run", "RunBack", "Swim", "SwimBack", "TurnRate", "Flight", "FlightBack", "PitchRate" }; switch (opcode) { case CMSG_MOVE_FORCE_WALK_SPEED_CHANGE_ACK: move_type = MOVE_WALK; break; case CMSG_MOVE_FORCE_RUN_SPEED_CHANGE_ACK: move_type = MOVE_RUN; break; case CMSG_MOVE_FORCE_RUN_BACK_SPEED_CHANGE_ACK: move_type = MOVE_RUN_BACK; break; case CMSG_MOVE_FORCE_SWIM_SPEED_CHANGE_ACK: move_type = MOVE_SWIM; break; case CMSG_MOVE_FORCE_SWIM_BACK_SPEED_CHANGE_ACK: move_type = MOVE_SWIM_BACK; break; case CMSG_MOVE_FORCE_TURN_RATE_CHANGE_ACK: move_type = MOVE_TURN_RATE; break; case CMSG_MOVE_FORCE_FLIGHT_SPEED_CHANGE_ACK: move_type = MOVE_FLIGHT; break; case CMSG_MOVE_FORCE_FLIGHT_BACK_SPEED_CHANGE_ACK: move_type = MOVE_FLIGHT_BACK; break; case CMSG_MOVE_FORCE_PITCH_RATE_CHANGE_ACK: move_type = MOVE_PITCH_RATE; break; default: TC_LOG_ERROR("network", "WorldSession::HandleForceSpeedChangeAck: Unknown move type opcode: %u", opcode); return; } // skip all forced speed changes except last and unexpected // in run/mounted case used one ACK and it must be skipped. m_forced_speed_changes[MOVE_RUN] store both. if (_player->m_forced_speed_changes[move_type] > 0) { --_player->m_forced_speed_changes[move_type]; if (_player->m_forced_speed_changes[move_type] > 0) return; } if (!_player->GetTransport() && fabs(_player->GetSpeed(move_type) - newspeed) > 0.01f) { if (_player->GetSpeed(move_type) > newspeed) // must be greater - just correct { TC_LOG_ERROR("network", "%sSpeedChange player %s is NOT correct (must be %f instead %f), force set to correct value", move_type_name[move_type], _player->GetName().c_str(), _player->GetSpeed(move_type), newspeed); _player->SetSpeed(move_type, _player->GetSpeedRate(move_type), true); } else // must be lesser - cheating { TC_LOG_DEBUG("misc", "Player %s from account id %u kicked for incorrect speed (must be %f instead %f)", _player->GetName().c_str(), _player->GetSession()->GetAccountId(), _player->GetSpeed(move_type), newspeed); _player->GetSession()->KickPlayer(); } } }
AGENTPLUGINEXP void dllLoadScene( const char* sceneFile ) { XMLResults results; XMLNode scene = XMLNode::parseFile( sceneFile, "Configuration", &results); /* * Paths */ XMLNode& pathes(scene.getChildNode("EnginePath")); if (!pathes.isEmpty()) { GameLog::logMessage("- AnimationPath = %s", pathes.getAttribute("AnimationPath", "models")); h3dutSetResourcePath(H3DResTypes::Animation, pathes.getAttribute("animationpath", "animations")); } /* * Horde3D configurations */ XMLNode& engineSettings(scene.getChildNode("EngineConfig")); if ( !engineSettings.isEmpty() ) { bool fastAnim = _stricmp(engineSettings.getAttribute("fastAnimation", "false"), "true") == 0 || _stricmp(engineSettings.getAttribute("fastAnimation", "0"), "1") == 0; GameLog::logMessage("FastAnimation: %s", fastAnim ? "enabled" : "disabled"); h3dSetOption( H3DOptions::FastAnimation, fastAnim ? 1.0f : 0.0f ); } /* * Agent component configurations */ // First set default config Config::useDefault(); XMLNode& extras(scene.getChildNode("Extras")); if (!extras.isEmpty()) { const XMLNode& agentSettings(extras.getChildNode("AgentConfig")); if (!agentSettings.isEmpty()) { char* xmlString = agentSettings.createXMLString(); GameLog::logMessage("- Setting Agent settings from xml = %s", xmlString); delete xmlString; Config::loadFromXml(agentSettings); } } /* * Animation lexicon */ if (!extras.isEmpty()) { const XMLNode& animLexicon(extras.getChildNode("AnimationLexicon")); if (!animLexicon.isEmpty() && animLexicon.getAttribute("path") != 0) { GameLog::logMessage("- Parsing Animation Lexicon from %s", animLexicon.getAttribute("path")); AnimationData::loadLexiconData( &XMLNode::openFileHelper( animLexicon.getAttribute("path"), "AnimationLexicon" )); } else GameLog::errorMessage( "AgentComponent: error parsing animation lexicon (file not found?). Animation loading will only be available by filename or resource" ); } /* * Socket entity */ if (!extras.isEmpty()) { const XMLNode& socket(extras.getChildNode("SocketServer")); if (!socket.isEmpty() && socket.getAttribute("entity") != 0) { GameLog::logMessage("- SocketServer entity set to %s", socket.getAttribute("entity")); Config::setParamS(Agent_Param::SocketEntityName_S, socket.getAttribute("entity")); } else GameLog::logMessage("- SocketServer entity set to default value (%s)", Config::getParamS(Agent_Param::SocketEntityName_S)); } }