Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
30 lines
3.3 KiB
Python
30 lines
3.3 KiB
Python
from pathlib import Path
|
|
import json,hashlib,subprocess
|
|
p=Path('/tmp/erri-launcher-resupply-1140'); root=Path('/home/jakub/devel/escapistsrereintroduced')
|
|
f=p/'addons/core/Scripts/Game/ERR/10_AI/ERR_InfantryResupply.c';s=f.read_text().replace('if (++checks > 128) return false;', 'if (++checks > 96 * 32) return false;').replace('magazine, true, m_LauncherTrip);','magazine, !m_LauncherTrip, m_LauncherTrip);');f.write_text(s)
|
|
f=p/'tests/test_infantry_resupply_planning.py';s=f.read_text().replace('static inline bool compatible=true;', 'static inline IEntity only=nullptr;static inline int checks=0;static inline bool compatible=true;').replace('return actor&&item&&launcher&&compatible;', 'checks++;return actor&&item&&launcher&&compatible&&(!only||item==only);');s=s.replace('int main(){','''int main(){
|
|
{Fixture f;for(int i=48;i<96;i++)f.inventory.items.Insert(&f.items[i]);f.s.Stock(0);
|
|
ERR_InfantryAmmoTransfer::only=&f.items[95];ERR_InfantryAmmoTransfer::checks=0;
|
|
assert(f.s.TryPlanLauncher(&f.recipient,&f.donor,&f.demand,&f.donorStatus,0));
|
|
assert(ERR_InfantryAmmoTransfer::checks==191);ERR_InfantryAmmoTransfer::only=nullptr;}
|
|
''',1);f.write_text(s)
|
|
f=p/'tests/test_hq_ammo_sampler.py';s=f.read_text().replace('launcher.disposable=false;','''launcher.disposable=false;
|
|
launcher.inMag=true;launcher.canReload=false;auto singleUse=Fresh();ERR_HQAmmoSampler::Inspect(&actor,&group,&singleUse);assert(!singleUse.LauncherComplete&&singleUse.LauncherMuzzles==0);launcher.inMag=false;launcher.canReload=true;
|
|
auto badMuzzles=expended;badMuzzles.LauncherMuzzles=-1;assert(!badMuzzles.Valid(1));badMuzzles.LauncherMuzzles=33;assert(!badMuzzles.Valid(1));badMuzzles.LauncherMuzzles=32;assert(badMuzzles.Valid(1));''');f.write_text(s)
|
|
rel='tests/test_hq_watch.py';f=p/rel;orig=(root/rel).read_text();b=p/'baseline'/rel;b.parent.mkdir(parents=True,exist_ok=True);b.write_text(orig)
|
|
s=orig.replace('original.MineComplete=true;', 'original.LauncherComplete=true;original.LauncherMuzzles=2;original.MineComplete=true;',1).replace('original.ReadyMines=0;', 'original.LauncherMuzzles=0;original.ReadyMines=0;',1)
|
|
s=s.replace('RadioIntake radio;StatusUnit sender;', 'assert(mineWire.AmmoState->LauncherMuzzles==2);\n RadioIntake radio;StatusUnit sender;',1)
|
|
s=s.replace('mineWire.AmmoState->ReadyMines=0;mineWire.AmmoState->MineComplete=false;', 'assert(mines->AmmoState->LauncherMuzzles==2);mineWire.AmmoState->LauncherMuzzles=0;assert(mines->AmmoState->LauncherMuzzles==2);\n mineWire.AmmoState->ReadyMines=0;mineWire.AmmoState->MineComplete=false;',1)
|
|
s=s.replace('// Mounted payload obeys', '''mineWire.MessageId=4;mineWire.ObservedAt=6000;mineWire.AmmoState->LauncherMuzzles=-1;
|
|
assert(!radio.m_Watch.Ingest(&mineWire,7000)&&mines->MessageId==3);
|
|
mineWire.AmmoState->LauncherMuzzles=129;assert(!radio.m_Watch.Ingest(&mineWire,7000));
|
|
// Mounted payload obeys''');f.write_text(s)
|
|
meta=json.loads((p/'baseline.json').read_text())
|
|
for f in (p/'tests').glob('test_*.py'):
|
|
rel=str(f.relative_to(p));base=p/'baseline'/rel
|
|
if not base.exists():base.write_bytes((root/rel).read_bytes())
|
|
if rel not in meta:
|
|
indexed=subprocess.check_output(['git','show',':'+rel],cwd=root)
|
|
meta[rel]={'working_sha256':hashlib.sha256(base.read_bytes()).hexdigest(),'index_sha256':hashlib.sha256(indexed).hexdigest()}
|
|
(p/'baseline.json').write_text(json.dumps(meta,indent=2)+'\n')
|