[ScryMUD] SVN Commit Info r902 - trunk/mud/grrmud/server

scrymud at wanfear.com scrymud at wanfear.com
Tue Feb 27 02:19:30 PST 2007


Author: eroper
Date: 2007-02-27 02:19:30 -0800 (Tue, 27 Feb 2007)
New Revision: 902

Modified:
   trunk/mud/grrmud/server/command2.cc
   trunk/mud/grrmud/server/critter.cc
   trunk/mud/grrmud/server/critter.h
   trunk/mud/grrmud/server/hegemon_handler.h
   trunk/mud/grrmud/server/misc.cc
   trunk/mud/grrmud/server/protocol_handler.h
   trunk/mud/grrmud/server/telnet_handler.cc
   trunk/mud/grrmud/server/telnet_handler.h
   trunk/mud/grrmud/server/translation2.spec
Log:
Added the player toggle "keepalives" which when set will currently send IAC
NOP packets to telnet clients every 4 ticks (~5 minutes). Hegemon will not
currently receive any keepalive packets.


Modified: trunk/mud/grrmud/server/command2.cc
===================================================================
--- trunk/mud/grrmud/server/command2.cc	2007-02-27 08:08:03 UTC (rev 901)
+++ trunk/mud/grrmud/server/command2.cc	2007-02-27 10:19:30 UTC (rev 902)
@@ -1716,7 +1716,7 @@
       show(buf, pc);
 
       Sprintf(buf, cstr(CS_TOG4_2, pc), (int)(pc.PC_FLAGS.get(33)),
-            (int)(pc.PC_FLAGS.get(34)));
+            (int)(pc.PC_FLAGS.get(34)), (int)(pc.PC_FLAGS.get(35)));
       show(buf, pc);
 
       if (pc.isImmort()) {
@@ -1812,6 +1812,11 @@
        pc.show(CS_OK);
        return 0;
    }//if         
+   else if (strncasecmp(*field, cstr(CS_TOG_KEEPALIVES, pc), len1) == 0) {
+      pc.PC_FLAGS.flip(35);
+      pc.show(CS_OK);
+      return 0;
+   }
    else {
       pc.show(CS_NO_FIND_TOGGLE);
       return -1;

Modified: trunk/mud/grrmud/server/critter.cc
===================================================================
--- trunk/mud/grrmud/server/critter.cc	2007-02-27 08:08:03 UTC (rev 901)
+++ trunk/mud/grrmud/server/critter.cc	2007-02-27 10:19:30 UTC (rev 902)
@@ -1382,8 +1382,9 @@
    host.Clear();
    mode = MODE_NORMAL;
    descriptor = age = index = hunger = thirst = drugged = violence_timer = 0;
-   birth_year = birth_day = rent_day = rent_year = pk_count = 
-      died_count = quest_points = idle_ticks = remort_count = 0;
+   birth_year = birth_day = rent_day = rent_year = pk_count
+      = died_count = quest_points = idle_ticks = last_keepalive
+      = remort_count = 0;
    link_condition = CON_LOGGING_IN;
 
    if (imm_data) {
@@ -1479,6 +1480,7 @@
    remort_count = source.remort_count;
    quest_points = source.quest_points;
    idle_ticks = source.idle_ticks;
+   last_keepalive = source.last_keepalive;
    prompt = source.prompt;
    w_eye_obj = source.w_eye_obj;
    last_login_time = source.last_login_time;

Modified: trunk/mud/grrmud/server/critter.h
===================================================================
--- trunk/mud/grrmud/server/critter.h	2007-02-27 08:08:03 UTC (rev 901)
+++ trunk/mud/grrmud/server/critter.h	2007-02-27 10:19:30 UTC (rev 902)
@@ -573,7 +573,7 @@
       // 23 in_page_break_mode, 24 wizchat, 25 has_colors, 26 use_color
       // 27 has_language_choice, 28 !show_mob_entry, 29 no_beep,
       // 30 is_remort, 31 has_sacrificed, 32 is_roleplaying,
-      // 33 is_afk, 34 gold_only
+      // 33 is_afk, 34 gold_only, 35 keepalives
 
    // Is our PC wanted in any zones?
    int wanted_in[NUMBER_OF_ZONES +1];
@@ -604,6 +604,7 @@
    short remort_count;
    short quest_points;
    short idle_ticks;
+   short last_keepalive;
 
    int last_login_time; //in seconds, since 1970 etc...
    int total_time_online; //in seconds
@@ -640,6 +641,7 @@
    pc_data& operator= (const pc_data& source);
 
    int canBeBeeped() const { return (!(pc_data_flags.get(29))); }
+   bool doKeepAlives() const { return ( pc_data_flags.get(35) ); }
 
    void Clear();
    void Write(ofstream& ofile);

Modified: trunk/mud/grrmud/server/hegemon_handler.h
===================================================================
--- trunk/mud/grrmud/server/hegemon_handler.h	2007-02-27 08:08:03 UTC (rev 901)
+++ trunk/mud/grrmud/server/hegemon_handler.h	2007-02-27 10:19:30 UTC (rev 902)
@@ -49,6 +49,7 @@
       bool parse(const char* input_buf, size_t len);
       void set_echo(bool on_off) { }
       const char* end_of_record() const { return(""); }
+      const char* keepalive() const { return(""); }
 };
 
 

Modified: trunk/mud/grrmud/server/misc.cc
===================================================================
--- trunk/mud/grrmud/server/misc.cc	2007-02-27 08:08:03 UTC (rev 901)
+++ trunk/mud/grrmud/server/misc.cc	2007-02-27 10:19:30 UTC (rev 902)
@@ -1275,10 +1275,23 @@
    stat_spell_cell* sp_ptr;
    String buf(100);
 
-   //log anyone who isn't isn't >= IMM level 2 off after 30 ticks of
-   //inactivity.
+   // 1. log anyone who isn't isn't >= IMM level 2 off after 30 ticks of
+   //    inactivity.
+   // 2. if a player has keepalives enabled, send them out once every 4
+   //    ticks (~5 minutes). [currently only telnet implements keepalives]
    while ((crit_ptr = crit_cell.next())) {
 
+      if ( crit_ptr->pc->doKeepAlives() ) {
+
+         crit_ptr->pc->last_keepalive++;
+
+         if ( ++(crit_ptr->pc->last_keepalive) >= 4 ) {
+            crit_ptr->pc->output += crit_ptr->pc->p_handler->keepalive();
+            crit_ptr->pc->last_keepalive = 0;
+         }
+
+      }//if doKeepAlives()
+
       //This used to be a prefix increment in the conditional, but that means
       //that it could be short-circuited depending on the compiler.
       crit_ptr->pc->idle_ticks++;

Modified: trunk/mud/grrmud/server/protocol_handler.h
===================================================================
--- trunk/mud/grrmud/server/protocol_handler.h	2007-02-27 08:08:03 UTC (rev 901)
+++ trunk/mud/grrmud/server/protocol_handler.h	2007-02-27 10:19:30 UTC (rev 902)
@@ -59,6 +59,8 @@
 
       // return a string used to mark end-of-record (player prompt)
       virtual const char* end_of_record() const = 0;
+      // return a string used for a keepalive.
+      virtual const char* keepalive() const = 0;
 };//class ProtocolHandler
 
 class NullHandler : public ProtocolHandler {
@@ -79,6 +81,7 @@
       bool parse(const char* input_buf, size_t len);
       void set_echo(bool on_off) { return; }
       const char* end_of_record() const { return(""); }
+      const char* keepalive() const { return(""); }
 };//class NullHandler
 
 #endif

Modified: trunk/mud/grrmud/server/telnet_handler.cc
===================================================================
--- trunk/mud/grrmud/server/telnet_handler.cc	2007-02-27 08:08:03 UTC (rev 901)
+++ trunk/mud/grrmud/server/telnet_handler.cc	2007-02-27 10:19:30 UTC (rev 902)
@@ -34,6 +34,7 @@
 //the '\0's are temporary until our send buffers start understanding binary
 //data and stop using strlen() and friends
 const char TelnetHandler::eor_str[] = { IAC, EOR, '\0'};
+const char TelnetHandler::keepalive_str[] = { IAC, NOP, '\0'};
 const char TelnetHandler::ttype_req_str[] = { IAC, SB, TELOPT_TTYPE, TELQUAL_SEND, IAC, SE, '\0'};
 
 TelnetHandler::TelnetHandler(critter* c_ptr) {
@@ -559,6 +560,10 @@
 
 }//TelnetHandler::end_of_record()
 
+const char* TelnetHandler::keepalive() const {
+   return(TelnetHandler::keepalive_str);
+}//TelnetHandler::keepalive()
+
 void TelnetHandler::newCritter(critter* c_ptr) {
    my_critter = c_ptr;
 }//TelnetHandler::newCritter()

Modified: trunk/mud/grrmud/server/telnet_handler.h
===================================================================
--- trunk/mud/grrmud/server/telnet_handler.h	2007-02-27 08:08:03 UTC (rev 901)
+++ trunk/mud/grrmud/server/telnet_handler.h	2007-02-27 10:19:30 UTC (rev 902)
@@ -33,6 +33,7 @@
    protected:
       static int _cnt;
       static const char eor_str[];
+      static const char keepalive_str[];
       static const char ttype_req_str[];
 
       enum state { ST_TEXT, ST_IAC, ST_DO, ST_DONT, ST_WILL, ST_WONT, ST_SB, ST_SB_IAC };
@@ -76,6 +77,7 @@
       bool parse(const char* input_buf, size_t len);
       void set_echo(bool on_off);
       const char* end_of_record() const;
+      const char* keepalive() const;
 
 };
 

Modified: trunk/mud/grrmud/server/translation2.spec
===================================================================
--- trunk/mud/grrmud/server/translation2.spec	2007-02-27 08:08:03 UTC (rev 901)
+++ trunk/mud/grrmud/server/translation2.spec	2007-02-27 10:19:30 UTC (rev 902)
@@ -794,9 +794,9 @@
 	~
 
 CS_TOG4_2
-	eng "afk(%i)%P20gold_only(%i)\n"
-	ser "afk(%i)%P20gold_only(%i)\n"
-	ger "afk(%i)%P20gold_only(%i)\n"
+	eng "afk(%i)%P20gold_only(%i)%P45keepalives(%i)\n"
+	ser "afk(%i)%P20gold_only(%i)%P45keepalives(%i)\n"
+	ger "afk(%i)%P20gold_only(%i)%P45keepalives(%i)\n"
 	~
 
 CS_TOG5
@@ -937,6 +937,12 @@
 	ger "gold_only"
 ~
 
+CS_TOG_KEEPALIVES
+	eng "keepalives"
+	ser "keepalives"
+	ger "keepalives"
+~
+
 CS_NO_FIND_TOGGLE
 	eng "Can't find the switch for that!\n"
 	ser "Nemozes da nadjes prekidac za to!\n"




More information about the ScryMUD mailing list