diff --git a/inc/engine.h b/inc/engine.h index 4f002dd..8898a31 100644 --- a/inc/engine.h +++ b/inc/engine.h @@ -448,6 +448,10 @@ public: return ptr->string; } + StringRef name () const { + return ptr->name; + } + void set (float val) { engfuncs.pfnCVarSetFloat (ptr->name, val); } diff --git a/inc/graph.h b/inc/graph.h index 9f3a3fc..e043a0e 100644 --- a/inc/graph.h +++ b/inc/graph.h @@ -167,6 +167,7 @@ private: bool m_hasChanged {}; bool m_narrowChecked {}; bool m_silenceMessages {}; + bool m_lightChecked {}; Vector m_learnVelocity {}; Vector m_learnPosition {}; diff --git a/src/control.cpp b/src/control.cpp index 805a785..cbb768a 100644 --- a/src/control.cpp +++ b/src/control.cpp @@ -801,6 +801,14 @@ int BotControl::cmdNodeUpload () { msg ("Sorry, unable to upload graph file that contains errors. Please type \"graph check\" to verify graph consistency."); return BotCommandResult::Handled; } + String uploadUrlAddress = cv_graph_url_upload.str (); + + // only allow to upload to non-https endpoint + if (uploadUrlAddress.startsWith ("http")) { + msg ("Value of \"%s\" cvar should not contain URL scheme, only the host name and path.", cv_graph_url_upload.name ()); + return BotCommandResult::Handled; + } + String uploadUrl = strings.format ("http://%s", uploadUrlAddress); msg ("\n"); msg ("WARNING!"); @@ -808,8 +816,6 @@ int BotControl::cmdNodeUpload () { msg ("you may notice the game freezes a bit during upload and issue request creation. Please, be patient."); msg ("\n"); - String uploadUrl = strings.format ("https://%s", cv_graph_url_upload.str ()); - // try to upload the file if (http.uploadFile (uploadUrl, bstor.buildPath (BotFile::Graph))) { msg ("Graph file was successfully validated and uploaded to the YaPB Graph DB (%s).", product.download); diff --git a/src/engine.cpp b/src/engine.cpp index eab114b..4fcb0b4 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -1183,7 +1183,7 @@ template bool LightMeasure::recursiveLightPoint (const } // determine which side of the node plane our points are on, fixme: optimize for axial - auto plane = node->plane; + const auto plane = node->plane; const float front = (start | plane->normal) - plane->dist; const float back = (end | plane->normal) - plane->dist; @@ -1252,7 +1252,7 @@ template bool LightMeasure::recursiveLightPoint (const auto lightmap = surf->samples + dt * smax + ds; // compute the lightmap color at a particular point - for (int maps = 0u; maps < MAX_LIGHTMAPS && surf->styles[maps] != 255u; ++maps) { + for (int maps = 0; maps < MAX_LIGHTMAPS && surf->styles[maps] != 255; ++maps) { const uint32_t scale = m_lightstyleValue[surf->styles[maps]]; m_point.red += lightmap->r * scale; diff --git a/src/graph.cpp b/src/graph.cpp index 24605fd..9262b40 100644 --- a/src/graph.cpp +++ b/src/graph.cpp @@ -28,6 +28,7 @@ void BotGraph::reset () { m_autoPathDistance = 250.0f; m_hasChanged = false; m_narrowChecked = false; + m_lightChecked = false; m_graphAuthor.clear (); m_graphModified.clear (); @@ -1332,23 +1333,31 @@ void BotGraph::calculatePathRadius (int index) { } void BotGraph::syncInitLightLevels () { - // this function get's the light level for each waypoin on the map - - // no nodes ? no light levels, and only one-time init - if (m_paths.empty () || !cr::fequal (m_paths[0].light, kInvalidLightLevel)) { - return; - } + // this function get's the light level for each node on the map // update light levels for all nodes for (auto &path : m_paths) { - path.light = illum.getLightLevel (path.origin); + path.light = illum.getLightLevel (path.origin + Vector { 0.0f, 0.0f, 16.0f} ); } + m_lightChecked = true; + // disable lightstyle animations on finish (will be auto-enabled on mapchange) illum.enableAnimation (false); } void BotGraph::initLightLevels () { - // this function get's the light level for each waypoin on the map + // this function get's the light level for each node on the map + + // no nodes ? no light levels, and only one-time init + if (m_paths.empty () || m_lightChecked) { + return; + } + auto players = bots.countTeamPlayers (); + + // do calculation if some-one is already playing on the server + if (!players.first && !players.second) { + return; + } worker.enqueue ([this] () { syncInitLightLevels (); @@ -1664,6 +1673,8 @@ bool BotGraph::saveGraphData () { // ensure narrow places saved into file m_narrowChecked = false; + m_lightChecked = false; + initNarrowPlaces (); return bstor.save (m_paths, &exten, options); @@ -2553,6 +2564,7 @@ BotGraph::BotGraph () { m_jumpLearnNode = false; m_hasChanged = false; m_narrowChecked = false; + m_lightChecked = false; m_timeJumpStarted = 0.0f; m_lastJumpNode = kInvalidNodeIndex; diff --git a/src/navigate.cpp b/src/navigate.cpp index 35d4da7..a73cc5e 100644 --- a/src/navigate.cpp +++ b/src/navigate.cpp @@ -1639,7 +1639,7 @@ bool Bot::findNextBestNode () { } int selected = kInvalidNodeIndex; - // now pick random one from choosen + // now pick random one from chosen int index = 0; // choice from found @@ -1766,7 +1766,7 @@ int Bot::findNearestNode () { const float distanceSq = path.origin.distanceSq (pev->origin); if (distanceSq < nearestDistanceSq) { - // if bot doing navigation, make sure node really visible and reacheable + // if bot doing navigation, make sure node really visible and reachable if (isReachableNode (path.number)) { index = path.number; nearestDistanceSq = distanceSq; @@ -1774,7 +1774,7 @@ int Bot::findNearestNode () { } } - // try to search ANYTHING that can be reachaed + // try to search ANYTHING that can be reached if (!graph.exists (index)) { nearestDistanceSq = cr::sqrf (kMaxDistance); const auto &nearestNodes = graph.getNarestInRadius (kMaxDistance, pev->origin); @@ -1896,10 +1896,10 @@ int Bot::findDefendNode (const Vector &origin) { continue; } - // use the 'real' pathfinding distances + // use the 'real' path finding distances auto distance = planner.dist (srcIndex, path.number); - // skip wayponts too far + // skip nodes too far if (distance > kMaxDistance) { continue; }