Losing Hotkeys

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

0o0o0
Posts: 93
Joined: Sun, 6. Mar 11, 19:33
x3ap

Losing Hotkeys

Post by 0o0o0 »

Now that I'm a fair way into my game I noticed that my hotkeys for the cheats instant brake and instant accel are missing. A few days later (I probably installed another script somewhere during this time) I'm missing the reload shields hotkey. Anyone know of a simple fix- maybe using the hotkey manager- for this?
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

There is a bug in AP. More details here
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

It happens when you add new hotkeys and somehow they overwrite old ones.

There is no real fix.

If you catch it immediately, you can abort the game, shut down the computer, cold restart the computer, load game, load save from before adding the new hotkey. That should load the new hotkey correctly. Then save again to be sure you keep it.

But if you add a hotkey after already starting the game, it buggers your list up. No fix if you progress to a new save with it wrong.

At this point, Egosoft are aware of it, have put it to the person who can fix it, but nothing so far has been done. Given that it only happens in a modded game (so far), they dont give it any priority.

Scripting wise, I'm now avoiding using hotkeys and going back to commands.

I dont hold any hope of this being fixed in the mid to long term, if ever. Its a case of them fixing a TC bug by breaking something different in AP and until they do a Bonus Pack update that introduces a new hotkey, they wont care about the bug because it wont affect vanilla players until then. If they never update the Bonus pack with a new hotkey, they will never trigger a need to get it fixed.

Btw, its the hotkey manager thats broken. It was completely rewritten at the command level for AP, and they c*cked it up badly. Obviously no one tested it at all before the game was released.

If your lost hotkeys are a game breaker, you may as well start a new game, as thats the only way to get them all back. BUT, do the game start after a cold start of the computer. Even shutting down and restarting doesnt clear the problem, only power off works. First thing you do is check they are all listed, and reassign all of them to the keys you want them on.
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22409
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

apricotslice wrote: Btw, its the hotkey manager thats broken. It was completely rewritten at the command level for AP, and they c*cked it up badly. Obviously no one tested it at all before the game was released.
actually thats incorrect, the hotkey manager and the AP hotkeys are 2 different things.

the problem is actually due to a bug that has existed since X3R but only started showing up due to the better hotkey handling in AP.

if you dont call the unregister hotkey command, you shoudl be able to avoid the problem. It happens because the old system used the amount of registered hotkeys as the next available id.
So if you add 10 hotkeys, the next id will be 11. If you remove a hotkey the next id will then goto 10. But as 10 is already assigned to a hotkey, it just ends up getting overwritten. The problem appeared because in AP it checks if a hotkey is already registered first, if it exists it changes the existing entry instead of simply adding another.

Its not such a major problem that there needs to be a hotfix specifically for it. If theres ever a new patch then a fix can be included then
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

@Cycrow

Did you modify the hotkey manager for AP ? If so, whats the link to its download ?

There are no unregister calls in my scripts, only in the hotkey manager add script (that I can find), and I frankly dont understand that code.

So if you didnt update hotkey manager for AP, I'd want to see some code for what needs changing.

I dont like the idea of me changing your code without knowing what I'm doing.
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22409
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

i've not modified yet, but ill upload a version where it removes the unregistered command completly
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

Thankyou, sooner the better imo.

Please link it here so I pick up the release.
User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle »

Cycrow wrote:if you add 10 hotkeys, the next id will be 11. If you remove a hotkey the next id will then goto 10. But as 10 is already assigned to a hotkey, it just ends up getting overwritten.
I stumbled across a workaround a couple of days ago. I did not know why it worked until your explanation. It is a one-minute fix for an already-corrupted saved game:

Create a new hotkey (for the overwritten script) with a new name.

1) Open the setup script in the Script Editor.

2) Change the name of the hotkey (not the script that it calls).

3) Save and reload.
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

Cycrow wrote:i've not modified yet, but ill upload a version where it removes the unregistered command completly
Isn't it already the case due to borked synchronization logic in the purge script? I found lots of orphan hotkeys in the hotkey manager collection when investigating this issue.
One thing I am wondering about: would it be possible to trick the system by registering enough "dummy" hotkeys to make it actually allocate a new one? i.e. create 100 "return null" script files called
my.crappy.script.001.xml through 099.xml and then keep registering them until you get a different hotkey handle number? I was able to make some hotkeys to show up after unregistering some hotkeys I do not use via an ad-hoc script.
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22409
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

not sure what registering 100's of scripts would achive other than having 100's of extra scripts/hotkey

if you call unregister hotkey on the last added hotkey, then it'll work.
also, unregistered all hotkeys will also fix it as it'll reset the id back to 0 and allow new ones to be added
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

Cycrow wrote: also, unregistered all hotkeys will also fix it as it'll reset the id back to 0 and allow new ones to be added
Awesome, exactly what we need. It should be fairly easy to write a script that unregisters all hotkeys and resets whatever global variables are used by scripts not using hotkey manager.
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22409
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

a simple script to unregister them all

Code: Select all

$id = 1536
while $id < 3000
  unregister hotkey: $id
  inc $id
end
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

Doesnt that have the side effect of needing to reassign all the hotkeys every time you run that ? Thats a major pain in the proverbial.

While that might be a fix, I still want the function fixed permanently. Having to reassign hotkeys every time you start a new game is a major pain.
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22409
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

im only suggesting the fix in a broken game. to you dont have to start a new game to get the hotkeys back

not something u should do every time you load the game.
if you avoid using unregister then it should be avoided.

as i said, it cant be fix without needed a patch, so until theres a patch, the only thing to do is use work arounds
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

The game just got patched. How come it wasnt included in that ?
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22409
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

it was only a language patch, nothing more
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

It was still an opportunity to fix this problem, not taken.
0o0o0
Posts: 93
Joined: Sun, 6. Mar 11, 19:33
x3ap

Post by 0o0o0 »

@cycrow. so if I run that script it will unassign all my hotkeys and return the ones that have been deleted? That would be worth it to get my hotkeys back without starting over. Also, if I want to add another script that brings in more hotkeys to my game, how can I avoid it overwriting any of my current hotkeys?
kurush
Posts: 4320
Joined: Sun, 6. Nov 05, 23:53
x3tc

Post by kurush »

0o0o0 wrote:@cycrow. so if I run that script it will unassign all my hotkeys and return the ones that have been deleted? That would be worth it to get my hotkeys back without starting over. Also, if I want to add another script that brings in more hotkeys to my game, how can I avoid it overwriting any of my current hotkeys?
As far as I can see, it won't return anything. You will also need to clear the hotkey manager global collection to make it re-register the hotkeys managed by it.
For any script that does not use the hotkey manager you would need to investigate how does it manage its hotkey handle. Usually it is a global variable and you will need to reset it to whatever value causes this script to register its hotkey. I am planning on doing it with my game at some point.
User avatar
apricotslice
Posts: 14163
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice »

The whole thing is a dogs breakfast and needs to be FIXED.

No offense intended Cycrow, but I think you underestimate the problem and its effects on people. Our previous discussion on this highlighted a much more extensive problem than what you outline here.

Personally, I consider AP broken by this problem. And I consider it to be a major problem worthy of its own patch. I've halted all mod development work, because I'm sick to death of redoing all the hotkeys every time I start a new game to test something, and having a new hotkey buggering up an ongoing test game.

But as I said before, if Egosoft never add a new hotkey to the Bonus Pack or in a patch, the problem will never occur in vanilla and thus they wont give it any priority to fix. However, if they dont fix it and at some point they add a new hotkey to the vanilla game, all hell will break loose when it breaks vanilla games unexpectedly. If I was them, I'd be fixing this one as a priority because its an unexploded bomb waiting to be triggered.

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”