|
General Bot Coding See what a pain it is to get those little mechs shooting around
|
|
Ex-Council Member
Status: Offline
Posts: 1,090
Join Date: Nov 2003
Location: Canada
|
What function runs when HL is shut down? -
27-10-2004
I was wondering if anyone knows off-hand what's the best function I can hook onto to detect when the HL engine is about to be shut down normally?
Maker of the (mEAn) Bot.Admin Manager
"In theory, there is no difference between theory and practice. But, in practice, there is." - Jan L.A. van de Snepscheut
|
|
|
|
|
Roi de France
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
|
Re: What function runs when HL is shut down? -
27-10-2004
Best guess would be ServerDeactivate(), however ServerDeactivate is also called on map change -- since a map change is in fact a server shutdown followed by a server restart. It depends on what you want to do.
Else if you use metamod, you might have better chances with meta_unload()...
RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
|
|
|
|
|
Summoner
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
|
Re: What function runs when HL is shut down? -
27-10-2004
look at the structure which is transfered in the GetNewDllFunctions() (sorry but I have forgot its name).
also meta_unload() is only called when we use the metamod command to unload a plugin, it isn't called when game is shutting down.
[edit]
it is GameShutdown(). however the HPB bot doesn't hook it. you can look at the Metamod source code about GetNewDllFunctions().
you can also use the DllMain() function.
[/edit]
Last edited by Whistler; 27-10-2004 at 13:10..
|
|
|
|
|
Ex-Council Member
Status: Offline
Posts: 1,090
Join Date: Nov 2003
Location: Canada
|
Re: What function runs when HL is shut down? -
27-10-2004
I'll try GameShutdown() since I want to know when the HL engine is being shut down normally for good. I cannot use DllMain() because my code has to work under linux.
The reason I want to detect a normal server shut down, is so I can write the "shutdown" event to a log file. This is usefull to detect when the server crashed vs shutdown for debugging a server setup. It works great for detecting things like bad maps and/or waypoints.
If you run a 24/7 server, there's no easy way to decide if a map + waypoint combination is causing crashes or not.
If you can view a log file and see that your server crashes a lot only when a certain map (or maps) are loaded, then you can remove the bad maps (or replace waypoints) and make your server more stable.
Under windows the feature worked great for me, so I do not want to lose it under Linux.
Maker of the (mEAn) Bot.Admin Manager
"In theory, there is no difference between theory and practice. But, in practice, there is." - Jan L.A. van de Snepscheut
|
|
|
|
|
Ex-Council Member
Status: Offline
Posts: 1,090
Join Date: Nov 2003
Location: Canada
|
Re: What function runs when HL is shut down? -
27-10-2004
Here's an example of my log file:
Thu Mar 18 20:47:59 2004 :: cs_siege (auto load from map timeout)
Thu Mar 18 20:48:02 2004 :: cs_siege (loaded - first frame check)
Thu Mar 18 21:05:38 2004 :: ** SERVER SHUTDOWN - 5.50.12 **
Thu Mar 18 21:09:54 2004 :: ** SERVER START - 5.50.12 **
Thu Mar 18 21:09:54 2004 :: cs_assault (loaded - first frame check)
Thu Mar 18 21:30:40 2004 :: fy_iceworld (auto load from map timeout)
Thu Mar 18 21:30:43 2004 :: fy_iceworld (loaded - first frame check)
I can see that on Thu Mar 18 21:05:38 2004 The server was shutdown normally then restarted the same day at 21:09:54.
Here's a server crash ...
Mon Apr 05 18:36:50 2004 :: de_inferno (auto load from map timeout)
Mon Apr 05 18:36:54 2004 :: de_inferno (loaded - first frame check)
Mon Apr 05 18:59:06 2004 :: de_nuke (auto load from map timeout)
Mon Apr 05 18:59:11 2004 :: de_nuke (loaded - first frame check)
Mon Apr 05 19:12:24 2004 :: ** SERVER START - 5.50.12 **
Mon Apr 05 19:12:25 2004 :: cs_assault (loaded - first frame check)
I see the server was started, but without a normal shutdown event being logged. The map was de_nuke, so if I see a lot of these when de_nuke is loaded, then I know there's something wrong with de_nuke, such as bad waypoints.
Maker of the (mEAn) Bot.Admin Manager
"In theory, there is no difference between theory and practice. But, in practice, there is." - Jan L.A. van de Snepscheut
|
|
|
|
|
Summoner
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
|
Re: What function runs when HL is shut down? -
28-10-2004
well I think use the destructor of a global class would be a good idea to detect server crash. if the GameShutdown() isn't called but the destructor is called then it's server crash
AFAIK it works with both Windows and GNU/Linux
Last edited by Whistler; 28-10-2004 at 13:21..
|
|
|
|
|
Ex-Council Member
Status: Offline
Posts: 1,090
Join Date: Nov 2003
Location: Canada
|
Re: What function runs when HL is shut down? -
28-10-2004
It won't work if a crash is severe enough to prevent the operating system from unloading the library and the destructor may not be called.
I can see using a global class destructor call to decide some usefull things, but I don't know how to determine and guarantee the order of constructor/destructor calls, do you know how?
Maker of the (mEAn) Bot.Admin Manager
"In theory, there is no difference between theory and practice. But, in practice, there is." - Jan L.A. van de Snepscheut
|
|
|
|
|
Roi de France
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
|
Re: What function runs when HL is shut down? -
28-10-2004
So tell me if I understand it right, but that's completely related to that other thread where you wanted to know the equivalent of DllMain() for Linux ?
Well I haven't investigated the problem but to me you should keep on searching in that direction. I would be very surprised if it were that difficult. Have you tried posting on Usenet (linux programming newsgroups), or asking particular people who know Linux better, like botman for example ? I'm sure posting on Usenet would come up with an answer in the 24 hours.
RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
|
|
|
|
|
Ex-Council Member
Status: Offline
Posts: 1,090
Join Date: Nov 2003
Location: Canada
|
Re: What function runs when HL is shut down? -
29-10-2004
Pierre, I have a lot of things to try out now but so little time.
I did test the library constructor/destructor functions and they did execute, and it looked like the constructor executes as the very first thing and before any other global classes have initialized. The library destructor seemed to execute as the last thing to destruct. Now having said that I have to investigate this behaviour in a lot more detail to determine for certain what is going on. Botman already gave me the suggestion to read through the man pages, and there's tons of info in there for me to look over before I go about asking more questions - I only skimmed through it as of this point. Finally, I reallly REALLY have to figure out how the C++ compiler decides in what order things get contructed and destructed since such a thing is very important to understand, and hopfully gain control over.
I'll be posting in the other thread whatever I learn. This thread is just a quick and dirty fix for a broken feature the mEAn mod had when it runs under linux.
Maker of the (mEAn) Bot.Admin Manager
"In theory, there is no difference between theory and practice. But, in practice, there is." - Jan L.A. van de Snepscheut
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Powered by vBulletin® Version 3.8.2 Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com
|
|