* Optimize swapwords and consequently shufflewords (which is called by g_maplist_shuffle) a little bit
* Avoid setting filename when not needed in Map_Check (called many times when the map vote starts)
* Save a few normalize calls in findtrajectorywithleading (called when bots use weapons like mortar and electro that fire projectiles with gravity)
findtrajectorywithleading patch probably causes a hash change due to extremely small aim direction changes (always < 0.0005) that at some point change the course of the bot match
test_sv_game:
stage: test
script:
- - export EXPECT=0406faebe1f4903266061f43557d0b1b
+ - export EXPECT=14b3e3e34253d4b41325080e77317d58
- qcsrc/tools/sv_game-hashtest.sh
- exit $?
ERASEABLE
string swapwords(string str, float i, float j)
{
- float n;
string s1, s2, s3, s4, s5;
float si, ei, sj, ej, s0, en;
- n = tokenizebyseparator(str, " "); // must match g_maplist processing in ShuffleMaplist and "shuffle"
+ int n = tokenizebyseparator(str, " "); // must match g_maplist processing in ShuffleMaplist and "shuffle"
si = argv_start_index(i);
sj = argv_start_index(j);
ei = argv_end_index(i);
s0 = argv_start_index(0);
en = argv_end_index(n - 1);
s1 = substring_range(str, s0, si);
- s2 = substring_range(str, si, ei);
+ s2 = argv(i);
s3 = substring_range(str, ei, sj);
- s4 = substring_range(str, sj, ej);
+ s4 = argv(j);
s5 = substring_range(str, ej, en);
return strcat(s1, s4, s3, s2, s5);
}
tracebox(o, targ.mins, targ.maxs, v, false, targ);
v = trace_endpos;
end = v + (targ.mins + targ.maxs) * 0.5;
- if ((vlen(end - org) / shotspeed + 0.2) > maxtime)
+ float shotdistance = max(0.001, vlen(end - org));
+ if ((shotdistance / shotspeed + 0.2) > maxtime)
{
// out of range
targ.solid = savesolid;
setorigin(tracetossfaketarget, v);
c = 0;
- dir = normalize(end - org);
+ dir = (end - org) / shotdistance; // same as dir = normalize(end - org); but cheaper
+ vector test_dir = dir;
+ vector test_dir_normalized = dir;
while (c < 10) // 10 traces
{
setorigin(tracetossent, org); // reset
- tracetossent.velocity = findtrajectory_velocity = normalize(dir) * shotspeed + shotspeedupward * '0 0 1';
+ tracetossent.velocity = findtrajectory_velocity = test_dir_normalized * shotspeed + shotspeedupward * '0 0 1';
tracetoss(tracetossent, ignore); // love builtin functions...
if (trace_ent == tracetossfaketarget) // done
{
return true;
}
- dir.z = dir.z + 0.1; // aim up a little more
+ test_dir.z += 0.1; // aim up a little more
+ test_dir_normalized = normalize(test_dir);
c = c + 1;
}
targ.solid = savesolid;
setorigin(tracetossfaketarget, v);
// leave a valid one even if it won't reach
- findtrajectory_velocity = normalize(end - org) * shotspeed + shotspeedupward * '0 0 1';
+ findtrajectory_velocity = dir * shotspeed + shotspeedupward * '0 0 1';
return false;
}
bool Map_Check(int position, float pass)
{
- string filename;
- string map_next;
- map_next = argv(position);
+ string map_next = argv(position);
if(pass <= 1)
{
if(Map_IsRecent(map_next))
return false;
}
- filename = Map_Filename(position);
if(MapInfo_CheckMap(map_next))
{
if(pass == 2)
return false;
}
else
+ {
+ string filename = Map_Filename(position);
LOG_DEBUG( "Couldn't select '", filename, "'..." );
+ }
return false;
}