diff options
| author | B. Watson <urchlay@slackware.uk> | 2026-03-09 21:41:56 -0400 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2026-03-09 21:41:56 -0400 |
| commit | 15488c9cb3c7200efc3c863b505959a07e96e89a (patch) | |
| tree | 2a81ce3238db200c74964eab3dc99f3cb7cac905 /src/irc.c | |
| parent | 5d38ff9d6a6e9d0fe7d0d03896780f393a13ba0d (diff) | |
| download | fujinet-chat-15488c9cb3c7200efc3c863b505959a07e96e89a.tar.gz | |
use 16-bit ints for ping times (saves 778 bytes).
Diffstat (limited to 'src/irc.c')
| -rw-r--r-- | src/irc.c | 33 |
1 files changed, 22 insertions, 11 deletions
@@ -81,21 +81,31 @@ static void do_chan_nick(void) { } static void do_priv_nick(void) { - scr_print_active("*"); - scr_print_active(msg_src); - scr_print_active("* "); - bell(); + if(msg_src) { + scr_print_active("*"); + scr_print_active(msg_src); + scr_print_active("* "); + bell(); + } } +/* this ping calculation relies on the assumption that + nobody's ping time will ever be more than 9 minutes. anyone + that lagged will have been disconnected from the server already. + if this assumption turns out to be false, the ping time displayed + will be wrong (module ~9 mins). I don't think it's ever going to be + a real problem. + Why do it this way? Because using longs instead of ints bloats the + code by 778 bytes! */ static void print_ping_time(char *p) { - static long now, pingtime; - static int sec, frac; + static unsigned int now, pingtime; + static unsigned int sec, frac; now = read_rtclok(); - pingtime = atol(p); + pingtime = (unsigned int)atoi(p); - /* correct for rtclock rollover (every 77 hours) */ - if(now < pingtime) now |= 0x01000000L; + /* correct for rtclock rollover (every ~9 mins) */ + if(now < pingtime) now |= 0x8000; pingtime = now - pingtime; @@ -114,9 +124,10 @@ static void print_ping_time(char *p) { scr_print_active(numbuf); scr_print_active(" sec"); - /* for debugging: + /* + // for debugging: scr_print_active(" "); - ltoa(pingtime, numbuf, 10); + itoa(pingtime, numbuf, 10); scr_print_active(numbuf); */ } |
