Author Topic: @Badspot: Make disconnection functions more consistent  (Read 874 times)

I was trying to make something save when a server was closed, and was wondering what function is proper to use.

So I've traced closing and disconnecting in many different ways to see what functions are called when.

It seems like I should be using shutdown AND destroyserver just to cover all cases. But in one case shutdown is called twice.

There should be one default function that gets called when a server closes that people can use.
For example, onServerStop or something like that. A blank function that modders would love to use.

It also seems that disconnect() isn't called in all cases on the client side either.

Here's the notes that I took while tracing: (Were also done with only default add-ons running)


-------------------
dedicated (quit();):
-------------------
onExit()
also called on client side
shutDown()

--------------------
non-ded (disconnect):
--------------------
disconnect()
called on client side
disconnectedCleanup()
called on client side
destroyServer()
endMission()
pretty sure this gets called when you change map as well

--------------
non-ded (quit):
--------------
doQuitGame()
called on client side
shutDown()
onExit()
also called as just a client
shutDown()
twice..?

----------------
non-ded (alt+f4):
----------------
onExit()
also called as just a client
shutDown()

-------------------
client (disconnect):
-------------------
disconnect()
disconnectedCleanup()

-------------
Client (quit):
-------------
doQuitGame()
onExit()

-----------
Menu (quit):
-----------
onExit()

Yeah, this gets confusing. I'd rather have one onSomething function called when you disconnect from a server and one when you close one.
« Last Edit: November 24, 2011, 02:55:09 PM by otto-san »