Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old May 25, 2012, 15:33   #1
PowerWyrm
Prophet
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,967
PowerWyrm is on a distinguished road
A little bugfix for Windows users not using Win client...

As I discovered when using SDL and GCU clients on Windows, the "quit" hook is not called when closing the console (resulting in a lot of memory not being freed) because the CTRL_CLOSE_EVENT is not handled.

The code below fixes that problem nicely. Declare a control handler function in the main-xxx file:

Code:
static BOOL CtrlHandler(DWORD fdwCtrlType)
{
    switch (fdwCtrlType)
    {
        case CTRL_CLOSE_EVENT:
            quit(NULL);
            return FALSE;
        default:
            return FALSE;
    }
}
And call it in the init_xxx function:

Code:
    /* Activate hooks */
    plog_aux = hook_plog;
    quit_aux = hook_quit;

    /* Register a control handler */
    if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE))
        quit("Could not set control handler");
Et voila! Closing the Windows Console now calls hook_quit(), which should call cleanup_angband() and free allocated memory properly.
__________________
PWMAngband variant maintainer - check https://github.com/draconisPW/PWMAngband (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fixing dir, shift-dir and ctrl-dir keys part 1: Win client PowerWyrm Development 14 June 4, 2012 15:30
[3.4-dev] Minor bugs with Win client PowerWyrm Development 0 April 18, 2012 13:17
Quickband bugfix release Antoine Variants 4 July 28, 2011 02:46
Bugfix release for 3.2? Timo Pietilä Development 69 April 14, 2011 20:59
Any non-Windows users in competition? chem Competition 5 January 8, 2009 11:57


All times are GMT +1. The time now is 02:39.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.