diff --git a/xtrn/tw2/planets.js b/xtrn/tw2/planets.js index 5c6c6a79116fc59785e0bc4f37f8154a88527fdd..135cb4f384987a38e9efe14bf2b65990fb3e87b8 100644 --- a/xtrn/tw2/planets.js +++ b/xtrn/tw2/planets.js @@ -293,11 +293,11 @@ function DestroyPlanet(planetNum) db.lock(Settings.DB,'planets.'+planetNum,LOCK_WRITE); var planet=db.read(Settings.DB,"planets."+planetNum); secnum=planet.Sector; - db.lock(Settings.DB,'sector.'+secnum,LOCK_WRITE); + db.lock(Settings.DB,'sectors.'+secnum,LOCK_WRITE); if(planet.OccupiedCount > 1) { console.writeln("Another player prevents destroying the planet."); db.unlock(Settings.DB,'planets.'+planetNum); - db.unlock(Settings.DB,'sector.'+secnum); + db.unlock(Settings.DB,'sectors.'+secnum); return(false); } var sector=db.read(Settings.DB,'sectors.'+secnum); @@ -306,7 +306,7 @@ function DestroyPlanet(planetNum) planet.Created=false; planet.Sector=0; db.write(Settings.DB,'sectors.'+secnum,sector); - db.unlock(Settings.DB,'sector.'+secnum); + db.unlock(Settings.DB,'sectors.'+secnum); db.write(Settings.DB,'planets.'+planetNum,planet); db.unlock(Settings.DB,'planets.'+planetNum); db.push(Settings.DB,'log',{Date:strftime("%a %b %d %H:%M:%S %Z"),Message:" - " + player.Alias + " destroyed the planet in sector " + secnum},LOCK_WRITE); diff --git a/xtrn/tw2/sectors.js b/xtrn/tw2/sectors.js index c399290313bf1b78575af5c8ff9d28fee897b20b..b2f505c61b067ab92510c1901bd256466635467c 100644 --- a/xtrn/tw2/sectors.js +++ b/xtrn/tw2/sectors.js @@ -104,13 +104,13 @@ function EnterSector() /* 20000 */ player.Points+=killed*100; console.writeln("You just recieved "+(killed*100)+" points for that."); } - db.read(Settings.DB,'sectors.'+player.Sector,LOCK_READ); + sector=db.read(Settings.DB,'sectors.'+player.Sector,LOCK_READ); if(sector.Fighters==0) console.writeln("You destroyed all the fighters."); break; case 'D': console.writeln("<Display>"); - sector=db.read(Settings.DB,'sector.'+player.Sector,LOCK_READ); + sector=db.read(Settings.DB,'sectors.'+player.Sector,LOCK_READ); DisplaySector(sector,player.Sector,false); break; case 'I': @@ -127,15 +127,17 @@ function EnterSector() /* 20000 */ case 'R': console.writeln("<Retreat>"); var sectorsLen=db.read(Settings.DB,'sectors.length',LOCK_READ); - if(player.LastIn<1 || player.LastIn>=sectorsLen) + while(player.LastIn<1 || player.LastIn>=sectorsLen || player.LastIn==player.Sector) { player.LastIn=random(sectorsLen-1)+1; + } + var oldsector=player.Sector; if(player.Fighters<1) { if(random(2)==1) { console.writeln("You escaped!"); db.lock(Settings.DB,'sectors.'+player.Sector,LOCK_WRITE); db.lock(Settings.DB,'sectors.'+player.LastIn,LOCK_WRITE); sector=db.read(Settings.DB,'sectors.'+player.Sector); - lastsector=db.read(Settings.DB,'sectors.'+player.Sector); + lastsector=db.read(Settings.DB,'sectors.'+player.LastIn); lastsector.Ships.push(player.Record); for(i=0; i<sector.Ships.length; i++) { if(sector.Ships[i]==player.Record) { @@ -147,7 +149,7 @@ function EnterSector() /* 20000 */ db.write(Settings.DB,'sectors.'+player.LastIn,lastsector); player.Sector=player.LastIn; player.Put(); - db.unlock(Settings.DB,'sectors.'+player.Sector); + db.unlock(Settings.DB,'sectors.'+oldsector); db.unlock(Settings.DB,'sectors.'+player.LastIn); return(false); } @@ -166,7 +168,7 @@ function EnterSector() /* 20000 */ db.lock(Settings.DB,'sectors.'+player.Sector,LOCK_WRITE); db.lock(Settings.DB,'sectors.'+player.LastIn,LOCK_WRITE); sector=db.read(Settings.DB,'sectors.'+player.Sector); - lastsector=db.read(Settings.DB,'sectors.'+player.Sector); + lastsector=db.read(Settings.DB,'sectors.'+player.LastIn); lastsector.Ships.push(player.Record); for(i=0; i<sector.Ships.length; i++) { if(sector.Ships[i]==player.Record) { @@ -178,7 +180,7 @@ function EnterSector() /* 20000 */ db.write(Settings.DB,'sectors.'+player.LastIn,lastsector); player.Sector=player.LastIn; player.Put(); - db.unlock(Settings.DB,'sectors.'+player.Sector); + db.unlock(Settings.DB,'sectors.'+oldsector); db.unlock(Settings.DB,'sectors.'+player.LastIn); return(false); }