mudgangster

Tiny, scriptable MUD client
Log | Files | Refs | README

commit 4ad8e4a7073fdef762c986711f4a3b7caa1ac510
parent 3674756c859a407c60ae7616def435c958223bf9
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sun,  3 May 2020 01:47:21 +0300

Profile startup

Diffstat:
Msrc/script.cc | 18++++++++++++++++--
Msrc/textbox.cc | 2++
Msrc/ui.cc | 2++
Msrc/win32.cc | 2++
Msrc/x11.cc | 8+++++++-
5 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/src/script.cc b/src/script.cc @@ -36,6 +36,8 @@ static void pcall( int args, const char * err ) { } void script_handleInput( const char * buffer, int len ) { + ZoneScoped; + assert( inputHandlerIdx != LUA_NOREF ); lua_rawgeti( lua, LUA_REGISTRYINDEX, inputHandlerIdx ); @@ -45,6 +47,8 @@ void script_handleInput( const char * buffer, int len ) { } void script_doMacro( const char * key, int len, bool shift, bool ctrl, bool alt ) { + ZoneScoped; + // printf( "macro %s%s%s%.*s\n", shift ? "s" : "", ctrl ? "c" : "", alt ? "a" : "", len, key ); // fflush( stdout ); @@ -62,6 +66,8 @@ void script_doMacro( const char * key, int len, bool shift, bool ctrl, bool alt } void script_handleClose() { + ZoneScoped; + assert( closeHandlerIdx != LUA_NOREF ); lua_rawgeti( lua, LUA_REGISTRYINDEX, closeHandlerIdx ); @@ -69,20 +75,26 @@ void script_handleClose() { } void script_socketData( void * sock, const char * data, size_t len ) { + ZoneScoped; + assert( socketHandlerIdx != LUA_NOREF ); lua_rawgeti( lua, LUA_REGISTRYINDEX, socketHandlerIdx ); lua_pushlightuserdata( lua, sock ); - if( data == NULL ) + if( data == NULL ) { lua_pushnil( lua ); - else + } + else { lua_pushlstring( lua, data, len ); + } pcall( 2, "script_socketData" ); } void script_fire_intervals() { + ZoneScoped; + assert( intervalHandlerIdx != LUA_NOREF ); lua_rawgeti( lua, LUA_REGISTRYINDEX, intervalHandlerIdx ); @@ -240,6 +252,8 @@ extern "C" int luaopen_lfs( lua_State * L ); #endif void script_init() { + ZoneScoped; + lua = luaL_newstate(); luaL_openlibs( lua ); diff --git a/src/textbox.cc b/src/textbox.cc @@ -35,6 +35,8 @@ static void unpack_style( uint8_t style, int * fg, int * bg, int * bold ) { } void textbox_init( TextBox * tb, size_t scrollback ) { + ZoneScoped; + // TODO: this is kinda crap *tb = { }; tb->lines = ( TextBox::Line * ) calloc( sizeof( TextBox::Line ), scrollback ); diff --git a/src/ui.cc b/src/ui.cc @@ -20,6 +20,8 @@ static size_t statusLen = 0; static bool status_dirty = false; void ui_init() { + ZoneScoped; + textbox_init( &main_text, SCROLLBACK_SIZE ); textbox_init( &chat_text, CHAT_ROWS ); diff --git a/src/win32.cc b/src/win32.cc @@ -573,6 +573,8 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin input_init(); script_init(); + FrameMark; + MSG msg; while( GetMessage( &msg, NULL, 0, 0 ) > 0 ) { if( !is_macro( &msg ) ) diff --git a/src/x11.cc b/src/x11.cc @@ -382,7 +382,9 @@ static void event_focus( XEvent * xevent ) { XFree( hints ); } -void ui_handleXEvents() { +static void ui_handleXEvents() { + ZoneScoped; + void ( *event_handlers[ LASTEvent ] )( XEvent * ) = { }; event_handlers[ ButtonPress ] = event_mouse_down; event_handlers[ MotionNotify ] = event_mouse_move; @@ -478,6 +480,8 @@ static void initStyle() { } void platform_ui_init() { + ZoneScoped; + for( Socket & s : sockets ) { s.in_use = false; } @@ -580,6 +584,8 @@ int main() { platform_ui_init(); script_init(); + FrameMark; + ui_handleXEvents(); while( !closing ) {