ensingm2/saliengame_idler

Test planet auto-updating

ensingm2 opened this issue · 6 comments

Hopefully the recent CORS error handling fixed the issues we were having here, but I'd like to test before enabling it by default.

There will also almost definitely be issues planet-switching while animations are disabled, due to the hooks/injects I put in place. Best fix might be to figure out animation toggling first (See #49), then on planet switch, enable animations, switch, then revert to previous animation enabled/disabled state.

Note: to trigger this, you can enable it by setting auto_switch_planet.active=true, or running CheckSwitchBetterPlanet(); to do a single check.

CheckSwitchBetterPlanet(true); to allow the script to come back to the same zone, otherwise it'll stop.

I'll put that here for the record, but i got an error from a steam script when trying to move to another planet :/ (anim weren't disabled).

03:55:27,353 ReferenceError: error is not defined[En savoir plus] network.js:212:4
	CServerInterface.prototype.LeaveGameInstance/< https://steamcommunity-a.akamaihd.net/public/javascript/saliengame/network.js:212:4
	j https://steamcommunity-a.akamaihd.net/public/javascript/jquery-1.11.1.min.js:2:27239
	fireWith https://steamcommunity-a.akamaihd.net/public/javascript/jquery-1.11.1.min.js:2:28057
	x https://steamcommunity-a.akamaihd.net/public/javascript/jquery-1.11.1.min.js:4:21841
	b https://steamcommunity-a.akamaihd.net/public/javascript/jquery-1.11.1.min.js:4:25897

It was after getting the planets info (despite it fails for the 17th.

03:55:27,021 Planet #16 has higher XP potential. Switching to it. Bye planet #15
03:55:27,021 Attempting to move to Planet #16

It didn't break the script though, it kept going on. I switched manually. I waited a second time before but the same error got triggered.

Yeah, it's actually a bug in steam's own game code(lol).

If you look in network.js, line 193+ (function definition for CServerInterface.prototype.LeaveGameInstance()), you'll notice that they copied the ajax call success function from the above functions, that included an error callback if the call succeeded, but the 'x-eresult' header is not '1'. Unfortunately, they didn't define LeaveGameInstance to take an error callback function as a parameter, so if the ajax call fails, it tries to call an undefined function.

Not much we can do about that (I guess I could overwrite their function and fix their code, haha), other than try to avoid getting any ajax errors when leaving a game.

Ahah indeed, nice copy/paste on their part, can't blame them :p. For the request, i checked back. In their function, callback is triggered if x-eresult = 1. In the request that failed, it was equal to 11. Other than that, the response was the same empty json response object.

I think i saw what's the issue. It's because we're in a round already for some reason. Before the message Planet #17 has higher XP po... the log was :

04:06:49,549 Round successfully started in zone #46		Scratchpad/3:195:5
04:06:49,549 Object { response: {…} }				Scratchpad/3:196:5
04:06:53,105 Array(18) [ <10 empty slots>, … ]
04:06:53,107 Planet #17 has higher XP potential. Switching to it. Bye planet #15	Scratchpad/3:582:3
04:06:53,108 Attempting to move to Planet #17

I don't see why we're in one. I know it's the difficulty call in the start_round function CheckSwitchBetterPlanet(true); that triggered the check/switch. But there's a leave_round in the switch_planet so... Too tired to dig it atm.

Edit : Okay i just saw the problem. We need to set current_game_id before calling the check on a better planet.
Edit² : Just force tested the current script with the modifications, works pretty good (except the double round start that we could avoid) :

05:23:44,843
Array(18) [ <10 empty slots>, … ]				Scratchpad/5:577:2
05:23:44,845 Planet #17 has higher XP potential. Switching to it. Bye planet #13	Scratchpad/5:622:3
05:23:44,846 Attempting to move to Planet #17			Scratchpad/5:82:4
05:23:44,847 Leaving game: 1203					Scratchpad/5:382:2
05:23:45,350 Left Zone #92					Scratchpad/5:82:4
05:23:51,911 Initializing Planet Selection Menu.		Scratchpad/5:82:4
05:23:51,913 At Planet Selection				Scratchpad/5:82:4
05:23:52,881 Getting best zone					Scratchpad/5:82:4
05:23:52,882 Planète de l'horreur existentielle - Zone 77 Progress: 0.18048183619976044 Difficulty: 3		Scratchpad/5:512:3
05:23:53,587 Round successfully started in zone #77
05:23:53,588 Object { response: {…} }				Scratchpad/5:235:5
05:23:53,595 Initializing Battle Selection Menu.		Scratchpad/5:82:4
05:23:53,595 Previous game detected. Ending it.			Scratchpad/5:82:4
05:23:53,596 Leaving game: 1517					Scratchpad/5:382:2
05:23:53,962 Left Zone #77					Scratchpad/5:82:4
05:23:54,605 Round successfully started in zone #77