ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/loop.C
(Generate patch)

Comparing deliantra/server/socket/loop.C (file contents):
Revision 1.70 by root, Thu Nov 8 19:43:30 2007 UTC vs.
Revision 1.76 by root, Wed Apr 23 07:49:57 2008 UTC

50 50
51#define MAX_QUEUE_DEPTH 50 51#define MAX_QUEUE_DEPTH 50
52#define MAX_QUEUE_BACKLOG 3. 52#define MAX_QUEUE_BACKLOG 3.
53 53
54// disconnect a socket after this many seconds without an ack 54// disconnect a socket after this many seconds without an ack
55#define SOCKET_TIMEOUT 8. 55#define SOCKET_TIMEOUT 16.
56 56
57void 57void
58client::reset_state () 58client::reset_state ()
59{ 59{
60 if (!pl) 60 if (!pl)
75 reset_state (); 75 reset_state ();
76 send_packet_printf ("drawinfo %d command queue overflow, ignoring.", NDI_RED); 76 send_packet_printf ("drawinfo %d command queue overflow, ignoring.", NDI_RED);
77 } 77 }
78 else 78 else
79 { 79 {
80 cmd_queue.push_back (command ()); 80 cmd_queue.resize (cmd_queue.size () + 1);
81 command &cmd = cmd_queue.back (); 81 command &cmd = cmd_queue.back ();
82 cmd.stamp = stamp; 82 cmd.stamp = stamp;
83 cmd.handler = handler; 83 cmd.handler = handler;
84 cmd.data = salloc<char> (datalen + 1, data); 84 cmd.data = salloc<char> (datalen + 1, data);
85 cmd.datalen = datalen; 85 cmd.datalen = datalen;
101 send_packet_printf ("drawinfo %d ignoring delayed commands.", NDI_RED); 101 send_packet_printf ("drawinfo %d ignoring delayed commands.", NDI_RED);
102 } 102 }
103 else 103 else
104 execute (cmd.handler, cmd.data, cmd.datalen); 104 execute (cmd.handler, cmd.data, cmd.datalen);
105 105
106 sfree<char> (cmd.data, cmd.datalen + 1);
106 cmd_queue.pop_front (); 107 cmd_queue.pop_front ();
107 return true; 108 return true;
108 } 109 }
109 else 110 else
110 return false; 111 return false;
113void 114void
114client::tick () 115client::tick ()
115{ 116{
116 if (!pl || destroyed ()) 117 if (!pl || destroyed ())
117 return; 118 return;
119
120 pl->dirty = true;
118 121
119 /* Update the players stats once per tick. More efficient than 122 /* Update the players stats once per tick. More efficient than
120 * sending them whenever they change, and probably just as useful 123 * sending them whenever they change, and probably just as useful
121 */ 124 */
122 esrv_update_stats (pl); 125 esrv_update_stats (pl);
123 126
124 if (last_weight != -1 && last_weight != WEIGHT (pl->ob)) 127 sint32 weight = pl->ob->client_weight ();
128
129 if (last_weight != weight)
125 { 130 {
131 pl->ob->update_stats ();
126 esrv_update_item (UPD_WEIGHT, pl->ob, pl->ob); 132 esrv_update_item (UPD_WEIGHT, pl->ob, pl->ob);
127 if (last_weight != WEIGHT (pl->ob))
128 LOG (llevError, "esrv_update_item(UPD_WEIGHT) did not set player weight: is %lu, should be %lu\n",
129 (unsigned long) last_weight, WEIGHT (pl->ob));
130 } 133 }
131 134
132 draw_client_map (pl); 135 draw_client_map (pl);
133 136
134 if (update_look) 137 if (update_look)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines